-
Notifications
You must be signed in to change notification settings - Fork 1
/
public-functions.php
65 lines (59 loc) · 1.3 KB
/
public-functions.php
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* get global object
* @return \Crowd\Plugin
*/
function crowd_get_plugin(){
return \Crowd\Plugin::instance();
}
/**
* get slug of crowd card post type
*
* @return string
*/
function crowd_get_card_post_type(){
$plugin = crowd_get_plugin();
return $plugin->card_post_type->getSlug();
}
/**
* @param null $post_id
*
* @return WP_User|null
*/
function crowd_get_initiator($post_id = null){
if(null == $post_id){
global $post;
} else {
$post = get_post($post_id);
}
$initiator_id=get_post_meta( $post->ID, \Crowd\MetaBoxInitiator::META_INITIATOR, TRUE );
$initiator = null;
if ( FALSE != $initiator_id && "" != $initiator_id ) {
/**
* @var \WP_User $initiator
*/
$initiator = get_user_by("ID", $initiator_id);
}
return $initiator;
}
/**
* renders initiator by id or for global post
* @param null $post_id
*/
function crowd_render_initiator( $post_id = null ){
do_action(\Crowd\Plugin::ACTION_RENDER_INITIATOR, $post_id);
}
/**
* renders cards that are connected to a post
* @param null $post_id
*/
function crowd_render_post_cards($post_id = null){
do_action(\Crowd\Plugin::ACTION_RENDER_POST_CARDS, $post_id);
}
/**
* renders a single card card
* @param null $card_id
*/
function crowd_render_card($card_id = null){
do_action(\Crowd\Plugin::ACTION_RENDER_CARD, $card_id);
}