get_cancel_comment_reply_link() WordPress Function

The get_cancel_comment_reply_link() function displays a link that allows a user to cancel their reply to a comment. This function is useful if you want to give your users the ability to change their mind after they have begun replying to a comment.

get_cancel_comment_reply_link( string $text = '' ) #

Retrieves HTML content for cancel comment reply link.


Parameters

$text

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

Default value: ''


Top ↑

Return

(string)


Top ↑

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( array( 'replytocom', 'unapproved', 'moderation-hash' ) ) ) . '#respond';

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

	/**
	 * Filters the cancel comment reply link HTML.
	 *
	 * @since 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 );
}


Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More