forked from scribu/wp-lib-posts-to-posts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshortcodes.php
More file actions
35 lines (27 loc) · 727 Bytes
/
shortcodes.php
File metadata and controls
35 lines (27 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
class P2P_Shortcodes {
static function init() {
add_shortcode( 'p2p_connected', array( __CLASS__, 'connected' ) );
add_shortcode( 'p2p_related', array( __CLASS__, 'related' ) );
}
static function connected( $attr ) {
return self::get_list( $attr, 'get_connected' );
}
static function related( $attr ) {
return self::get_list( $attr, 'get_related' );
}
private static function get_list( $attr, $method ) {
global $post;
$attr = shortcode_atts( array(
'type' => '',
'mode' => 'ul',
), $attr );
return P2P_List_Renderer::query_and_render( array(
'ctype' => $attr['type'],
'method' => $method,
'item' => $post,
'mode' => $attr['mode'],
'context' => 'shortcode'
) );
}
}