bpbbpst_support_admin_links

Hooks bbp_get_topic_admin_links to eventually add the selectbox of available support status.

Description

(string) bpbbpst_support_admin_links( (string) $input = '', (array) $args = array() ); 

Returns (string)

$input or the input with the selectbox

Parameters (2)

0. $input — Optional. (string) => ''
The html containing bbPress admin links
1. $args — Optional. (array) => array()
The array containing eventual args

Usage

  1. if ( !function_exists( 'bpbbpst_support_admin_links' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddy-bbpress-support-topic/includes/functions.php'; 
  3.  
  4. // the html containing bbPress admin links 
  5. $input = ''; 
  6.  
  7. // the array containing eventual args 
  8. $args = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bpbbpst_support_admin_links($input, $args); 
  12.  

Defined (1)

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

/includes/functions.php  
  1. function bpbbpst_support_admin_links( $input = '', $args = array() ) { 
  2.  
  3. if ( ! bbp_is_single_topic() ) { 
  4. return $input; 
  5.  
  6. $defaults = array ( 
  7. 'id' => bbp_get_topic_id(),  
  8. 'before' => '<span class="bbp-admin-links">',  
  9. 'after' => '</span>',  
  10. 'sep' => ' | ',  
  11. 'links' => array() 
  12. ); 
  13.  
  14. $r = bbp_parse_args( $args, $defaults, 'get_topic_admin_links' ); 
  15.  
  16. // Since 2.0, we first need to check parent forum has support for support :) 
  17. $forum_id = bbp_get_topic_forum_id( $r['id'] ); 
  18.  
  19. if ( empty( $forum_id ) ) { 
  20. return $input; 
  21.  
  22. if ( 3 == bpbbpst_get_forum_support_setting( $forum_id ) ) { 
  23. return $input; 
  24.  
  25. // now let's check the post meta ! 
  26. $support_status = get_post_meta( $r['id'], '_bpbbpst_support_topic', true ); 
  27.  
  28. if ( current_user_can( 'edit_topic', $r['id'] ) && ! empty( $support_status ) ) { 
  29.  
  30. $support_selectbox = bpbbpst_get_selectbox( $support_status, $r['id'] ) . $r['sep'] ; 
  31.  
  32. $new_span = str_replace( $r['before'], $r['before'] . $support_selectbox, $input ); 
  33.  
  34. return apply_filters( 'bpbbpst_support_admin_links', $new_span, $args ); 
  35.  
  36. } else { 
  37. return $input; 
  38.