bbp_get_topic_admin_links

Return admin links for topic.

Description

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

Move topic functionality is handled by the edit topic page.

Returns (string)

Topic admin links

Parameters (1)

0. $args — Optional. (array) => array()
This function supports these arguments: - id: Optional. Topic id - before: Before the links - after: After the links - sep: Links separator - links: Topic admin links array

Usage

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

Defined (1)

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

/includes/topics/template.php  
  1. function bbp_get_topic_admin_links( $args = array() ) { 
  2.  
  3. // Parse arguments against default values 
  4. $r = bbp_parse_args( $args, array ( 
  5. 'id' => bbp_get_topic_id(),  
  6. 'before' => '<span class="bbp-admin-links">',  
  7. 'after' => '</span>',  
  8. 'sep' => ' | ',  
  9. 'links' => array() 
  10. ), 'get_topic_admin_links' ); 
  11.  
  12. if ( empty( $r['links'] ) ) { 
  13. $r['links'] = apply_filters( 'bbp_topic_admin_links', array( 
  14. 'edit' => bbp_get_topic_edit_link ( $r ),  
  15. 'close' => bbp_get_topic_close_link( $r ),  
  16. 'stick' => bbp_get_topic_stick_link( $r ),  
  17. 'merge' => bbp_get_topic_merge_link( $r ),  
  18. 'trash' => bbp_get_topic_trash_link( $r ),  
  19. 'spam' => bbp_get_topic_spam_link ( $r ),  
  20. 'reply' => bbp_get_topic_reply_link( $r ) 
  21. ), $r['id'] ); 
  22.  
  23. // See if links need to be unset 
  24. $topic_status = bbp_get_topic_status( $r['id'] ); 
  25. if ( in_array( $topic_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) { 
  26.  
  27. // Close link shouldn't be visible on trashed/spammed topics 
  28. unset( $r['links']['close'] ); 
  29.  
  30. // Spam link shouldn't be visible on trashed topics 
  31. if ( bbp_get_trash_status_id() === $topic_status ) { 
  32. unset( $r['links']['spam'] ); 
  33.  
  34. // Trash link shouldn't be visible on spam topics 
  35. } elseif ( bbp_get_spam_status_id() === $topic_status ) { 
  36. unset( $r['links']['trash'] ); 
  37.  
  38. // Process the admin links 
  39. $links = implode( $r['sep'], array_filter( $r['links'] ) ); 
  40. $retval = $r['before'] . $links . $r['after']; 
  41.  
  42. return apply_filters( 'bbp_get_topic_admin_links', $retval, $r, $args );