bbp_get_reply_admin_links

Return admin links for reply.

Description

(string) bbp_get_reply_admin_links( (array) $args = array() ); 

Returns (string)

Reply admin links

Parameters (1)

0. $args — Optional. (array) => array()
This function supports these arguments: - id: Optional. Reply id - before: HTML before the links. Defaults to ' - after: HTML after the links. Defaults to - sep: Separator. Defaults to | - links: Array of the links to display. By default, edit, trash, spam, reply move, and topic split links are displayed

Usage

  1. if ( !function_exists( 'bbp_get_reply_admin_links' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/replies/template.php'; 
  3. $args = array(); 
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bbp_get_reply_admin_links($args); 
  7.  

Defined (1)

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

/includes/replies/template.php  
  1. function bbp_get_reply_admin_links( $args = array() ) { 
  2.  
  3. // Parse arguments against default values 
  4. $r = bbp_parse_args( $args, array( 
  5. 'id' => 0,  
  6. 'before' => '<span class="bbp-admin-links">',  
  7. 'after' => '</span>',  
  8. 'sep' => ' | ',  
  9. 'links' => array() 
  10. ), 'get_reply_admin_links' ); 
  11.  
  12. $r['id'] = bbp_get_reply_id( (int) $r['id'] ); 
  13.  
  14. // If post is a topic, return the topic admin links instead 
  15. if ( bbp_is_topic( $r['id'] ) ) { 
  16. return bbp_get_topic_admin_links( $args ); 
  17.  
  18. // If post is not a reply, return 
  19. if ( !bbp_is_reply( $r['id'] ) ) { 
  20. return; 
  21.  
  22. // If topic is trashed, do not show admin links 
  23. if ( bbp_is_topic_trash( bbp_get_reply_topic_id( $r['id'] ) ) ) { 
  24. return; 
  25.  
  26. // If no links were passed, default to the standard 
  27. if ( empty( $r['links'] ) ) { 
  28. $r['links'] = apply_filters( 'bbp_reply_admin_links', array( 
  29. 'edit' => bbp_get_reply_edit_link ( $r ),  
  30. 'move' => bbp_get_reply_move_link ( $r ),  
  31. 'split' => bbp_get_topic_split_link( $r ),  
  32. 'trash' => bbp_get_reply_trash_link( $r ),  
  33. 'spam' => bbp_get_reply_spam_link ( $r ),  
  34. 'reply' => bbp_get_reply_to_link ( $r ) 
  35. ), $r['id'] ); 
  36.  
  37. // See if links need to be unset 
  38. $reply_status = bbp_get_reply_status( $r['id'] ); 
  39. if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) { 
  40.  
  41. // Spam link shouldn't be visible on trashed topics 
  42. if ( bbp_get_trash_status_id() === $reply_status ) { 
  43. unset( $r['links']['spam'] ); 
  44.  
  45. // Trash link shouldn't be visible on spam topics 
  46. } elseif ( bbp_get_spam_status_id() === $reply_status ) { 
  47. unset( $r['links']['trash'] ); 
  48.  
  49. // Process the admin links 
  50. $links = implode( $r['sep'], array_filter( $r['links'] ) ); 
  51. $retval = $r['before'] . $links . $r['after']; 
  52.  
  53. return apply_filters( 'bbp_get_reply_admin_links', $retval, $r, $args );