get_comment_author_url_link

The timeline below displays how wordpress function get_comment_author_url_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 the HTML link of the URL of the author of the current comment.
 *
 * $link_text parameter is only used if the URL does not exist for the comment
 * author. If the URL does exist then the URL will be used and the $link_text
 * will be ignored.
 *
 * Encapsulate the HTML link between the $before and $after. So it will appear
 * in the order of $before, link, and finally $after.
 *
 * @since 1.5.0
 * @since 4.6.0 Added the `$comment` parameter.
 *
 * @param string         $link_text Optional. The text to display instead of the comment
 *                                  author's email address. Default empty.
 * @param string         $before    Optional. The text or HTML to display before the email link.
 *                                  Default empty.
 * @param string         $after     Optional. The text or HTML to display after the email link.
 *                                  Default empty.
 * @param int|WP_Comment $comment   Optional. Comment ID or WP_Comment object.
 *                                  Default is the current comment.
 * @return string The HTML link between the $before and $after parameters.
 */
function get_comment_author_url_link($link_text = '', $before = '', $after = '', $comment = 0)
{
    $comment_author_url = get_comment_author_url($comment);
    $display = ('' !== $link_text) ? $link_text : $comment_author_url;
    $display = str_replace('http://www.', '', $display);
    $display = str_replace('http://', '', $display);
    if (str_ends_with($display, '/')) {
        $display = substr($display, 0, -1);
    }
    $comment_author_url_link = $before . sprintf('<a href="%1$s" rel="external">%2$s</a>', $comment_author_url, $display) . $after;
    /**
     * Filters the comment author's returned URL link.
     *
     * @since 1.5.0
     *
     * @param string $comment_author_url_link The HTML-formatted comment author URL link.
     */
    return apply_filters('get_comment_author_url_link', $comment_author_url_link);
}

WordPress Version: 5.5

/**
 * Retrieves the HTML link of the URL of the author of the current comment.
 *
 * $linktext parameter is only used if the URL does not exist for the comment
 * author. If the URL does exist then the URL will be used and the $linktext
 * will be ignored.
 *
 * Encapsulate the HTML link between the $before and $after. So it will appear
 * in the order of $before, link, and finally $after.
 *
 * @since 1.5.0
 * @since 4.6.0 Added the `$comment` parameter.
 *
 * @param string         $linktext Optional. The text to display instead of the comment
 *                                 author's email address. Default empty.
 * @param string         $before   Optional. The text or HTML to display before the email link.
 *                                 Default empty.
 * @param string         $after    Optional. The text or HTML to display after the email link.
 *                                 Default empty.
 * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object.
 *                                 Default is the current comment.
 * @return string The HTML link between the $before and $after parameters.
 */
function get_comment_author_url_link($linktext = '', $before = '', $after = '', $comment = 0)
{
    $url = get_comment_author_url($comment);
    $display = ('' !== $linktext) ? $linktext : $url;
    $display = str_replace('http://www.', '', $display);
    $display = str_replace('http://', '', $display);
    if ('/' === substr($display, -1)) {
        $display = substr($display, 0, -1);
    }
    $return = "{$before}<a href='{$url}' rel='external'>{$display}</a>{$after}";
    /**
     * Filters the comment author's returned URL link.
     *
     * @since 1.5.0
     *
     * @param string $return The HTML-formatted comment author URL link.
     */
    return apply_filters('get_comment_author_url_link', $return);
}

WordPress Version: 5.4

/**
 * Retrieves the HTML link of the URL of the author of the current comment.
 *
 * $linktext parameter is only used if the URL does not exist for the comment
 * author. If the URL does exist then the URL will be used and the $linktext
 * will be ignored.
 *
 * Encapsulate the HTML link between the $before and $after. So it will appear
 * in the order of $before, link, and finally $after.
 *
 * @since 1.5.0
 * @since 4.6.0 Added the `$comment` parameter.
 *
 * @param string         $linktext Optional. The text to display instead of the comment
 *                                 author's email address. Default empty.
 * @param string         $before   Optional. The text or HTML to display before the email link.
 *                                 Default empty.
 * @param string         $after    Optional. The text or HTML to display after the email link.
 *                                 Default empty.
 * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object.
 *                                 Default is the current comment.
 * @return string The HTML link between the $before and $after parameters.
 */
function get_comment_author_url_link($linktext = '', $before = '', $after = '', $comment = 0)
{
    $url = get_comment_author_url($comment);
    $display = ('' != $linktext) ? $linktext : $url;
    $display = str_replace('http://www.', '', $display);
    $display = str_replace('http://', '', $display);
    if ('/' == substr($display, -1)) {
        $display = substr($display, 0, -1);
    }
    $return = "{$before}<a href='{$url}' rel='external'>{$display}</a>{$after}";
    /**
     * Filters the comment author's returned URL link.
     *
     * @since 1.5.0
     *
     * @param string $return The HTML-formatted comment author URL link.
     */
    return apply_filters('get_comment_author_url_link', $return);
}

WordPress Version: 4.6

/**
 * Retrieves the HTML link of the url of the author of the current comment.
 *
 * $linktext parameter is only used if the URL does not exist for the comment
 * author. If the URL does exist then the URL will be used and the $linktext
 * will be ignored.
 *
 * Encapsulate the HTML link between the $before and $after. So it will appear
 * in the order of $before, link, and finally $after.
 *
 * @since 1.5.0
 * @since 4.6.0 Added the `$comment` parameter.
 *
 * @param string         $linktext Optional. The text to display instead of the comment
 *                                 author's email address. Default empty.
 * @param string         $before   Optional. The text or HTML to display before the email link.
 *                                 Default empty.
 * @param string         $after    Optional. The text or HTML to display after the email link.
 *                                 Default empty.
 * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object.
 *                                 Default is the current comment.
 * @return string The HTML link between the $before and $after parameters.
 */
function get_comment_author_url_link($linktext = '', $before = '', $after = '', $comment = 0)
{
    $url = get_comment_author_url($comment);
    $display = ($linktext != '') ? $linktext : $url;
    $display = str_replace('http://www.', '', $display);
    $display = str_replace('http://', '', $display);
    if ('/' == substr($display, -1)) {
        $display = substr($display, 0, -1);
    }
    $return = "{$before}<a href='{$url}' rel='external'>{$display}</a>{$after}";
    /**
     * Filters the comment author's returned URL link.
     *
     * @since 1.5.0
     *
     * @param string $return The HTML-formatted comment author URL link.
     */
    return apply_filters('get_comment_author_url_link', $return);
}

WordPress Version: 3.9

/**
 * Retrieves the HTML link of the url of the author of the current comment.
 *
 * $linktext parameter is only used if the URL does not exist for the comment
 * author. If the URL does exist then the URL will be used and the $linktext
 * will be ignored.
 *
 * Encapsulate the HTML link between the $before and $after. So it will appear
 * in the order of $before, link, and finally $after.
 *
 * @since 1.5.0
 *
 * @param string $linktext Optional. The text to display instead of the comment
 *                         author's email address. Default empty.
 * @param string $before   Optional. The text or HTML to display before the email link.
 *                         Default empty.
 * @param string $after    Optional. The text or HTML to display after the email link.
 *                         Default empty.
 * @return string The HTML link between the $before and $after parameters.
 */
function get_comment_author_url_link($linktext = '', $before = '', $after = '')
{
    $url = get_comment_author_url();
    $display = ($linktext != '') ? $linktext : $url;
    $display = str_replace('http://www.', '', $display);
    $display = str_replace('http://', '', $display);
    if ('/' == substr($display, -1)) {
        $display = substr($display, 0, -1);
    }
    $return = "{$before}<a href='{$url}' rel='external'>{$display}</a>{$after}";
    /**
     * Filter the comment author's returned URL link.
     *
     * @since 1.5.0
     *
     * @param string $return The HTML-formatted comment author URL link.
     */
    return apply_filters('get_comment_author_url_link', $return);
}

WordPress Version: 3.8

/**
 * Retrieves the HTML link of the url of the author of the current comment.
 *
 * $linktext parameter is only used if the URL does not exist for the comment
 * author. If the URL does exist then the URL will be used and the $linktext
 * will be ignored.
 *
 * Encapsulate the HTML link between the $before and $after. So it will appear
 * in the order of $before, link, and finally $after.
 *
 * @since 1.5.0
 *
 * @param string $linktext Optional. The text to display instead of the comment author's email address. Default empty.
 * @param string $before   Optional. The text or HTML to display before the email link. Default empty.
 * @param string $after    Optional. The text or HTML to display after the email link. Default empty.
 * @return string The HTML link between the $before and $after parameters.
 */
function get_comment_author_url_link($linktext = '', $before = '', $after = '')
{
    $url = get_comment_author_url();
    $display = ($linktext != '') ? $linktext : $url;
    $display = str_replace('http://www.', '', $display);
    $display = str_replace('http://', '', $display);
    if ('/' == substr($display, -1)) {
        $display = substr($display, 0, -1);
    }
    $return = "{$before}<a href='{$url}' rel='external'>{$display}</a>{$after}";
    /**
     * Filter the comment author's returned URL link.
     *
     * @since 1.5.0
     *
     * @param string $return The HTML-formatted comment author URL link.
     */
    return apply_filters('get_comment_author_url_link', $return);
}

WordPress Version: 3.7

/**
 * Retrieves the HTML link of the url of the author of the current comment.
 *
 * $linktext parameter is only used if the URL does not exist for the comment
 * author. If the URL does exist then the URL will be used and the $linktext
 * will be ignored.
 *
 * Encapsulate the HTML link between the $before and $after. So it will appear
 * in the order of $before, link, and finally $after.
 *
 * @since 1.5.0
 *
 * @param string $linktext Optional. The text to display instead of the comment author's email address. Default empty.
 * @param string $before   Optional. The text or HTML to display before the email link. Default empty.
 * @param string $after    Optional. The text or HTML to display after the email link. Default empty.
 * @return string The HTML link between the $before and $after parameters.
 */
function get_comment_author_url_link($linktext = '', $before = '', $after = '')
{
    $url = get_comment_author_url();
    $display = ($linktext != '') ? $linktext : $url;
    $display = str_replace('http://www.', '', $display);
    $display = str_replace('http://', '', $display);
    if ('/' == substr($display, -1)) {
        $display = substr($display, 0, -1);
    }
    $return = "{$before}<a href='{$url}' rel='external'>{$display}</a>{$after}";
    /**
     * Filter the comment author's returned URL link.
     *
     * @since 1.5.2
     *
     * @param string $return The HTML-formatted comment author URL link.
     */
    return apply_filters('get_comment_author_url_link', $return);
}