get_cancel_comment_reply_link( string $text = '', int|WP_Post|null $post = null )

Retrieves HTML content for cancel comment reply link.


Parameters

$text

(Optional) Text to display for cancel reply link. If empty, defaults to 'Click here to cancel reply'.

Default value: ''

$post

(Optional) The post the comment thread is being displayed for. Defaults to the current global post.

Default value: null


Return

(string)


Source

File: wp-includes/comment-template.php

function get_cancel_comment_reply_link( $text = '' ) {
	if ( empty($text) )
		$text = __('Click here to cancel reply.');

	$style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';
	$link = esc_html( remove_query_arg('replytocom') ) . '#respond';

	$formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>';

	/**
	 * Filters the cancel comment reply link HTML.
	 *
	 * @since WP-2.7.0
	 *
	 * @param string $formatted_link The HTML-formatted cancel comment reply link.
	 * @param string $link           Cancel comment reply link URL.
	 * @param string $text           Cancel comment reply link text.
	 */
	return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text );
}

Changelog

Changelog
Version Description
6.2.0 Added the $post parameter.
2.7.0 Introduced.