bbp_get_reply_to_link

Return the link for a reply to a reply.

Description

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

Returns (string)

Link for a reply to a reply

Parameters (1)

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

Usage

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

Defined (1)

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

/includes/replies/template.php  
  1. function bbp_get_reply_to_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' => __( 'Reply', bbpress ),  
  9. 'depth' => 0,  
  10. 'add_below' => 'post',  
  11. 'respond_id' => 'new-reply-' . bbp_get_topic_id(),  
  12. ), 'get_reply_to_link' ); 
  13.  
  14. // Get the reply to use it's ID and post_parent 
  15. $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) ); 
  16.  
  17. // Bail if no reply or user cannot reply 
  18. if ( empty( $reply ) || ! bbp_current_user_can_access_create_reply_form() ) 
  19. return; 
  20.  
  21. // Build the URI and return value 
  22. $uri = remove_query_arg( array( 'bbp_reply_to' ) ); 
  23. $uri = add_query_arg( array( 'bbp_reply_to' => $reply->ID ) ); 
  24. $uri = wp_nonce_url( $uri, 'respond_id_' . $reply->ID ); 
  25. $uri = $uri . '#new-post'; 
  26.  
  27. // Only add onclick if replies are threaded 
  28. if ( bbp_thread_replies() ) { 
  29.  
  30. // Array of classes to pass to moveForm 
  31. $move_form = array( 
  32. $r['add_below'] . '-' . $reply->ID,  
  33. $reply->ID,  
  34. $r['respond_id'],  
  35. $reply->post_parent 
  36. ); 
  37.  
  38. // Build the onclick 
  39. $onclick = ' onclick="return addReply.moveForm(\'' . implode( "', '", $move_form ) . '\');"'; 
  40.  
  41. // No onclick if replies are not threaded 
  42. } else { 
  43. $onclick = ''; 
  44.  
  45. // Add $uri to the array, to be passed through the filter 
  46. $r['uri'] = $uri; 
  47. $retval = $r['link_before'] . '<a href="' . esc_url( $r['uri'] ) . '" class="bbp-reply-to-link"' . $onclick . '>' . esc_html( $r['reply_text'] ) . '</a>' . $r['link_after']; 
  48.  
  49. return apply_filters( 'bbp_get_reply_to_link', $retval, $r, $args );