bp_groupblog_override_new_blog_post_activity_filter

Add "new_groupblog_post" activity type to "Posts" dropdown filter option.

Description

(string) bp_groupblog_override_new_blog_post_activity_filter( (string) $qs, (string) $object ); 

When the Posts option is selected in the activity dropdown filter, it only filters activity items by blog posts and not groupblog posts. This function allows both types of blog posts to be filtered in activity loops.

Returns (string)

Modified querystring

Parameters (2)

0. $qs (string)
The querystring for the BP loop
1. $object (string)
The current object for the querystring

Usage

  1. if ( !function_exists( 'bp_groupblog_override_new_blog_post_activity_filter' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bp-groupblog/bp-groupblog.php'; 
  3.  
  4. // The querystring for the BP loop 
  5. $qs = ''; 
  6.  
  7. // The current object for the querystring 
  8. $object = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_groupblog_override_new_blog_post_activity_filter($qs, $object); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bp-groupblog.php  
  1. function bp_groupblog_override_new_blog_post_activity_filter( $qs, $object ) { 
  2. // not on the blogs object? stop now! 
  3. if ( $object != 'activity' ) { 
  4. return $qs; 
  5.  
  6. // parse querystring into an array 
  7. $r = wp_parse_args( $qs ); 
  8.  
  9. if ( empty( $r['type'] ) || 'new_blog_post' !== $r['type'] ) { 
  10. return $qs; 
  11.  
  12. // add the 'new_groupblog_post' type if it doesn't exist 
  13. if ( false === strpos( $r['action'], 'new_groupblog_post' ) ) { 
  14. // 'action' filters activity items by the 'type' column 
  15. $r['action'] .= ', new_groupblog_post'; 
  16.  
  17. // 'type' isn't used anywhere internally 
  18. unset( $r['type'] ); 
  19.  
  20. // return a querystring 
  21. return build_query( $r );