bb_get_topic_sticky_link

The BuddyPress bb get topic sticky link function.

Description

bb_get_topic_sticky_link( (string) $args = '' ); 

Parameters (1)

0. $args — Optional. (string) => ''
The args.

Usage

  1. if ( !function_exists( 'bb_get_topic_sticky_link' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-template.php'; 
  3.  
  4. // The args. 
  5. $args = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_get_topic_sticky_link($args); 
  9.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-template.php  
  1. function bb_get_topic_sticky_link( $args = '' ) { 
  2. $defaults = array( 'id' => 0, 'before' => '[', 'after' => ']' ); 
  3. extract(wp_parse_args( $args, $defaults ), EXTR_SKIP); 
  4. $id = (int) $id; 
  5.  
  6. $topic = get_topic( get_topic_id( $id ) ); 
  7.  
  8. if ( !$topic || !bb_current_user_can( 'stick_topic', $topic->topic_id ) ) 
  9. return; 
  10.  
  11. $uri_stick = bb_get_uri('bb-admin/sticky.php', array('id' => $topic->topic_id), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN); 
  12. $uri_stick = esc_url( bb_nonce_url( $uri_stick, 'stick-topic_' . $topic->topic_id ) ); 
  13.  
  14. $uri_super = bb_get_uri('bb-admin/sticky.php', array('id' => $topic->topic_id, 'super' => 1), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN); 
  15. $uri_super = esc_url( bb_nonce_url( $uri_super, 'stick-topic_' . $topic->topic_id ) ); 
  16.  
  17. if ( topic_is_sticky( $topic->topic_id ) ) 
  18. return "$before<a href='" . $uri_stick . "'>". __('Unstick topic') ."</a>$after"; 
  19. else 
  20. return "$before<a href='" . $uri_stick . "'>". __('Stick topic') . "</a> (<a href='" . $uri_super . "'>" . __('to front') . "</a>)$after";