-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions.php
103 lines (96 loc) · 2.06 KB
/
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* Template tags for users
*
* @package Anyway Feedback
* @since 0.1
*/
/**
* Display Anyway Feedback buttons.Use inside loop.
*
*/
function afb_display() {
$afb = _afb();
if ( in_the_loop() ) {
echo $afb->get_controller_tag( get_the_ID(), get_post_type() );
}
}
/**
* Display Anyway Feedback buttons for comment.
* @param int $comment_id
* @return void
*/
function afb_comment_display( $comment_id ) {
$afb = _afb();
echo $afb->get_controller_tag( $comment_id, 'comment' );
}
/**
* Retrieve total feedback count. Use inside loop.
*
* @param boolean $echo (optional) Return value if false.
* @param int $object_id,
* @param string $post_type
* @return int
*/
function afb_total( $echo = true, $object_id = null, $post_type = null ) {
$afb = _afb();
if ( is_null( $object_id ) ) {
$object_id = get_the_ID();
}
if ( is_null( $post_type ) ) {
$post_type = get_post_type();
}
$total = $afb->feedbacks->total_answer( $object_id, $post_type );
if ( $echo ) {
echo $total;
}
return $total;
}
/**
* Retrieve affirmative feedback count. Use inside loop.
*
* @param boolean $echo (optional) Return value if false.
* @return int
*/
function afb_affirmative( $echo = true, $object_id = null, $post_type = null ) {
$afb = _afb();
if ( is_null( $object_id ) ) {
$object_id = get_the_ID();
}
if ( is_null( $post_type ) ) {
$post_type = get_post_type();
}
$total = $afb->feedbacks->affirmative( $object_id, $post_type );
if ( $echo ) {
echo $total;
}
return $total;
}
/**
* Retrieve negative feedback count. Use inside loop.
*
* @param boolean $echo (optional) Return value if false.
* @return void|int
*/
function afb_negative( $echo = true, $object_id = null, $post_type = null ) {
$afb = _afb();
if ( is_null( $object_id ) ) {
$object_id = get_the_ID();
}
if ( is_null( $post_type ) ) {
$post_type = get_post_type();
}
$total = $afb->feedbacks->negative( $object_id, $post_type );
if ( $echo ) {
echo $total;
}
return $total;
}
/**
* Get instance
*
* @return \AFB\Main
*/
function _afb() {
return AFB\Main::get_instance();
}