get_cancel_comment_reply_link

Retrieve HTML content for cancel comment reply link.

Description

(string) get_cancel_comment_reply_link( (string) $text = '' ); 

Returns (string)

Parameters (1)

0. $text — Optional. (string) => ''
Text to display for cancel reply link. Default empty.

Usage

  1. if ( !function_exists( 'get_cancel_comment_reply_link' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment-template.php'; 
  3.  
  4. // Optional. Text to display for cancel reply link. Default empty. 
  5. $text = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_cancel_comment_reply_link($text); 
  9.  

Defined (1)

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

/wp-includes/comment-template.php  
  1. function get_cancel_comment_reply_link( $text = '' ) { 
  2. if ( empty($text) ) 
  3. $text = __('Click here to cancel reply.'); 
  4.  
  5. $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; 
  6. $link = esc_html( remove_query_arg('replytocom') ) . '#respond'; 
  7.  
  8. $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>'; 
  9.  
  10. /** 
  11. * Filters the cancel comment reply link HTML. 
  12. * @since 2.7.0 
  13. * @param string $formatted_link The HTML-formatted cancel comment reply link. 
  14. * @param string $link Cancel comment reply link URL. 
  15. * @param string $text Cancel comment reply link text. 
  16. */ 
  17. return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text );