bbp_get_topic_stick_link

Return the stick link of the topic.

Description

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

Returns (string)

Topic stick link

Parameters (1)

0. $args — Optional. (string) => ''
This function supports these args: - id: Optional. Topic id - link_before: Before the link - link_after: After the link - stick_text: Stick text - unstick_text: Unstick text - super_text: Stick to front text

Usage

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

Defined (1)

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

/includes/topics/template.php  
  1. function bbp_get_topic_stick_link( $args = '' ) { 
  2.  
  3. // Parse arguments against default values 
  4. $r = bbp_parse_args( $args, array( 
  5. 'id' => 0,  
  6. 'link_before' => '',  
  7. 'link_after' => '',  
  8. 'stick_text' => esc_html__( 'Stick', bbpress ),  
  9. 'unstick_text' => esc_html__( 'Unstick', bbpress ),  
  10. 'super_text' => esc_html__( '(to front)', bbpress ),  
  11. ), 'get_topic_stick_link' ); 
  12.  
  13. $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 
  14.  
  15. if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) 
  16. return; 
  17.  
  18. $is_sticky = bbp_is_topic_sticky( $topic->ID ); 
  19.  
  20. $stick_uri = add_query_arg( array( 'action' => 'bbp_toggle_topic_stick', 'topic_id' => $topic->ID ) ); 
  21. $stick_uri = wp_nonce_url( $stick_uri, 'stick-topic_' . $topic->ID ); 
  22.  
  23. $stick_display = ( true === $is_sticky ) ? $r['unstick_text'] : $r['stick_text']; 
  24. $stick_display = '<a href="' . esc_url( $stick_uri ) . '" class="bbp-topic-sticky-link">' . $stick_display . '</a>'; 
  25.  
  26. if ( empty( $is_sticky ) ) { 
  27. $super_uri = add_query_arg( array( 'action' => 'bbp_toggle_topic_stick', 'topic_id' => $topic->ID, 'super' => 1 ) ); 
  28. $super_uri = wp_nonce_url( $super_uri, 'stick-topic_' . $topic->ID ); 
  29.  
  30. $super_display = ' <a href="' . esc_url( $super_uri ) . '" class="bbp-topic-super-sticky-link">' . $r['super_text'] . '</a>'; 
  31. } else { 
  32. $super_display = ''; 
  33.  
  34. // Combine the HTML into 1 string 
  35. $retval = $r['link_before'] . $stick_display . $super_display . $r['link_after']; 
  36.  
  37. return apply_filters( 'bbp_get_topic_stick_link', $retval, $r );