bbp_get_topic_reply_link

Return the link to go directly to the reply form.

Description

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

Returns (string)

Link for a reply to a topic

Parameters (1)

0. $args — Optional. (array) => array()
The args.

Usage

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

Defined (1)

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

/includes/topics/template.php  
  1. function bbp_get_topic_reply_link( $args = array() ) { 
  2.  
  3. // Parse arguments against default values 
  4. $r = bbp_parse_args( $args, array( 
  5. 'id' => 0,  
  6. 'link_before' => '',  
  7. 'link_after' => '',  
  8. 'reply_text' => esc_html__( 'Reply', bbpress ),  
  9. ), 'get_topic_reply_link' ); 
  10.  
  11. // Get the reply to use it's ID and post_parent 
  12. $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 
  13.  
  14. // Bail if no reply or user cannot reply 
  15. if ( empty( $topic ) || ! bbp_current_user_can_access_create_reply_form() ) 
  16. return; 
  17.  
  18. $uri = '#new-post'; 
  19.  
  20. // Add $uri to the array, to be passed through the filter 
  21. $r['uri'] = $uri; 
  22. $retval = $r['link_before'] . '<a href="' . esc_url( $r['uri'] ) . '" class="bbp-topic-reply-link">' . $r['reply_text'] . '</a>' . $r['link_after']; 
  23.  
  24. return apply_filters( 'bbp_get_topic_reply_link', $retval, $r, $args );