88 *
99 * @return the number of matching linkbacks
1010 */
11- function get_linkbacks_number ( $ type = null , $ post_id = 0 ) {
11+ function get_linkbacks_number ( $ type = null , $ post_id = null ) {
12+ if ( null === $ post_id ) {
13+ $ post_id = get_the_ID ();
14+ }
1215 $ args = array (
1316 'post_id ' => $ post_id ,
1417 'count ' => true ,
@@ -50,15 +53,30 @@ function get_linkbacks_number( $type = null, $post_id = 0 ) {
5053 *
5154 * @return the matching linkback "comments"
5255 */
53- function get_linkbacks ( $ type = null , $ post_id = 0 , $ order = 'DESC ' ) {
56+ function get_linkbacks ( $ type = null , $ post_id = null , $ order = 'DESC ' ) {
57+ if ( null === $ post_id ) {
58+ $ post_id = get_the_ID ();
59+ }
5460 $ args = array (
5561 'post_id ' => $ post_id ,
5662 'status ' => 'approve ' ,
5763 'order ' => $ order ,
5864 );
5965
6066 if ( $ type ) { // use type if set
61- $ args ['meta_query ' ] = array ( array ( 'key ' => 'semantic_linkbacks_type ' , 'value ' => $ type ) );
67+ if ( 'mention ' == $ type ) {
68+ $ args ['type__not_in ' ] = 'comment ' ;
69+ $ args ['meta_query ' ] = array (
70+ 'relation ' => 'OR ' ,
71+ array ( 'key ' => 'semantic_linkbacks_type ' , 'value ' => '' ),
72+ array ( 'key ' => 'semantic_linkbacks_type ' , 'compare ' => 'NOT EXISTS ' ),
73+ array ( 'key ' => 'semantic_linkbacks_type ' , 'value ' => 'mention ' ),
74+ );
75+ } elseif ( 'rsvp ' == $ type ) {
76+ $ args ['meta_query ' ] = array ( array ( 'key ' => 'semantic_linkbacks_type ' , 'value ' => 'rsvp ' , 'compare ' => 'LIKE ' ) );
77+ } else {
78+ $ args ['meta_query ' ] = array ( array ( 'key ' => 'semantic_linkbacks_type ' , 'value ' => $ type ) );
79+ }
6280 } else { // check only if type exists
6381 $ args ['meta_query ' ] = array ( array ( 'key ' => 'semantic_linkbacks_type ' , 'compare ' => 'EXISTS ' ) );
6482 }
@@ -67,9 +85,10 @@ function get_linkbacks( $type = null, $post_id = 0, $order = 'DESC' ) {
6785}
6886
6987
70- function has_linkbacks ( $ type = null , $ post_ID = 0 ) {
88+ function has_linkbacks ( $ type = null , $ post_ID = null ) {
7189 if ( get_linkbacks ( $ type , $ post_ID ) ) {
7290 return true ;
7391 }
7492 return false ;
7593}
94+
0 commit comments