get_cancel_comment_reply_link

The timeline below displays how wordpress function get_cancel_comment_reply_link has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Retrieves HTML content for cancel comment reply link.
 *
 * @since 2.7.0
 * @since 6.2.0 Added the `$post` parameter.
 *
 * @param string           $link_text Optional. Text to display for cancel reply link. If empty,
 *                                    defaults to 'Click here to cancel reply'. Default empty.
 * @param int|WP_Post|null $post      Optional. The post the comment thread is being
 *                                    displayed for. Defaults to the current global post.
 * @return string
 */
function get_cancel_comment_reply_link($link_text = '', $post = null)
{
    if (empty($link_text)) {
        $link_text = __('Click here to cancel reply.');
    }
    $post = get_post($post);
    $reply_to_id = $post ? _get_comment_reply_id($post->ID) : 0;
    $link_style = (0 !== $reply_to_id) ? '' : ' style="display:none;"';
    $link_url = esc_url(remove_query_arg(array('replytocom', 'unapproved', 'moderation-hash'))) . '#respond';
    $cancel_comment_reply_link = sprintf('<a rel="nofollow" id="cancel-comment-reply-link" href="%1$s"%2$s>%3$s</a>', $link_url, $link_style, $link_text);
    /**
     * Filters the cancel comment reply link HTML.
     *
     * @since 2.7.0
     *
     * @param string $cancel_comment_reply_link The HTML-formatted cancel comment reply link.
     * @param string $link_url                  Cancel comment reply link URL.
     * @param string $link_text                 Cancel comment reply link text.
     */
    return apply_filters('cancel_comment_reply_link', $cancel_comment_reply_link, $link_url, $link_text);
}

WordPress Version: 6.2

/**
 * Retrieves HTML content for cancel comment reply link.
 *
 * @since 2.7.0
 * @since 6.2.0 Added the `$post` parameter.
 *
 * @param string           $text Optional. Text to display for cancel reply link. If empty,
 *                               defaults to 'Click here to cancel reply'. Default empty.
 * @param int|WP_Post|null $post Optional. The post the comment thread is being
 *                               displayed for. Defaults to the current global post.
 * @return string
 */
function get_cancel_comment_reply_link($text = '', $post = null)
{
    if (empty($text)) {
        $text = __('Click here to cancel reply.');
    }
    $post = get_post($post);
    $reply_to_id = $post ? _get_comment_reply_id($post->ID) : 0;
    $style = (0 !== $reply_to_id) ? '' : ' 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);
}

WordPress Version: 5.5

/**
 * Retrieves HTML content for cancel comment reply link.
 *
 * @since 2.7.0
 *
 * @param string $text Optional. Text to display for cancel reply link. If empty,
 *                     defaults to 'Click here to cancel reply'. Default empty.
 * @return string
 */
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);
}

WordPress Version: 5.4

/**
 * Retrieves HTML content for cancel comment reply link.
 *
 * @since 2.7.0
 *
 * @param string $text Optional. Text to display for cancel reply link. Default empty.
 * @return string
 */
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);
}

WordPress Version: 5.1

/**
 * Retrieve HTML content for cancel comment reply link.
 *
 * @since 2.7.0
 *
 * @param string $text Optional. Text to display for cancel reply link. Default empty.
 * @return string
 */
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);
}

WordPress Version: 4.6

/**
 * Retrieve HTML content for cancel comment reply link.
 *
 * @since 2.7.0
 *
 * @param string $text Optional. Text to display for cancel reply link. Default empty.
 * @return string
 */
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 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);
}

WordPress Version: 4.3

/**
 * Retrieve HTML content for cancel comment reply link.
 *
 * @since 2.7.0
 *
 * @param string $text Optional. Text to display for cancel reply link. Default empty.
 * @return string
 */
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>';
    /**
     * Filter 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);
}

WordPress Version: 3.9

/**
 * Retrieve HTML content for cancel comment reply link.
 *
 * @since 2.7.0
 *
 * @param string $text Optional. Text to display for cancel reply link. Default empty.
 */
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>';
    /**
     * Filter 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);
}

WordPress Version: 3.7

/**
 * Retrieve HTML content for cancel comment reply link.
 *
 * @since 2.7.0
 *
 * @param string $text Optional. Text to display for cancel reply link. Default empty.
 */
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>';
    /**
     * Filter the cancel comment reply link HTML.
     *
     * @since 2.7.0
     *
     * @param string $formatted_link The HTML-formatted cancel comment reply link.
     * @param string $link           The cancel comment reply link URL.
     * @param string $text           The cancel comment reply link text.
     */
    return apply_filters('cancel_comment_reply_link', $formatted_link, $link, $text);
}