wp_rel_nofollow_callback

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

WordPress Version: 5.3

/**
 * Callback to add `rel="nofollow"` string to HTML A element.
 *
 * @since 2.3.0
 * @deprecated 5.3.0 Use wp_rel_callback()
 *
 * @param array $matches Single match.
 * @return string HTML A Element with `rel="nofollow"`.
 */
function wp_rel_nofollow_callback($matches)
{
    return wp_rel_callback($matches, 'nofollow');
}

WordPress Version: .20

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href']['value'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href']['value'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . '">';
}

WordPress Version: 2.2

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"" . esc_attr($value) . '" ';
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . '">';
}

WordPress Version: .10

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href']['value'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href']['value'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . '">';
}

WordPress Version: 5.2

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"" . esc_attr($value) . '" ';
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . '">';
}

WordPress Version: .10

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href']['value'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href']['value'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . '">';
}

WordPress Version: 1.1

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"" . esc_attr($value) . '" ';
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . '">';
}

WordPress Version: 5.1

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: 0.6

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href']['value'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href']['value'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 0.4

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"" . esc_attr($value) . "\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 0.3

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .20

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href']['value'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href']['value'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 0.2

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .10

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href']['value'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href']['value'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 9.3

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .20

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href']['value'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href']['value'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 9.2

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .11

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href']['value'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href']['value'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: .10

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"" . esc_attr($value) . "\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 4.9

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: 8.9

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"" . esc_attr($value) . "\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 8.2

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .10

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        if (in_array(strtolower(wp_parse_url($atts['href']['value'], PHP_URL_SCHEME)), array('http', 'https'), true)) {
            if (strtolower(wp_parse_url($atts['href']['value'], PHP_URL_HOST)) === strtolower(wp_parse_url(home_url(), PHP_URL_HOST))) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 6.3

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .20

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        $href_parts = wp_parse_url($atts['href']['value']);
        $href_scheme = isset($href_parts['scheme']) ? $href_parts['scheme'] : '';
        $href_host = isset($href_parts['host']) ? $href_parts['host'] : '';
        $home_parts = wp_parse_url(home_url());
        $home_host = isset($home_parts['host']) ? $home_parts['host'] : '';
        if (in_array(strtolower($href_scheme), array('http', 'https'), true)) {
            if (strtolower($href_host) === strtolower($home_host)) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 6.2

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .15

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        $href_parts = wp_parse_url($atts['href']['value']);
        $href_scheme = isset($href_parts['scheme']) ? $href_parts['scheme'] : '';
        $href_host = isset($href_parts['host']) ? $href_parts['host'] : '';
        $home_parts = wp_parse_url(home_url());
        $home_host = isset($home_parts['host']) ? $home_parts['host'] : '';
        if (in_array(strtolower($href_scheme), array('http', 'https'), true)) {
            if (strtolower($href_host) === strtolower($home_host)) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: .14

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        $href_parts = wp_parse_url($atts['href']);
        $href_scheme = isset($href_parts['scheme']) ? $href_parts['scheme'] : '';
        $href_host = isset($href_parts['host']) ? $href_parts['host'] : '';
        $home_parts = wp_parse_url(home_url());
        $home_host = isset($home_parts['host']) ? $home_parts['host'] : '';
        if (in_array(strtolower($href_scheme), array('http', 'https'), true)) {
            if (strtolower($href_host) === strtolower($home_host)) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"" . esc_attr($value) . "\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 5.4

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .30

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        $href_parts = wp_parse_url($atts['href']['value']);
        $href_scheme = isset($href_parts['scheme']) ? $href_parts['scheme'] : '';
        $href_host = isset($href_parts['host']) ? $href_parts['host'] : '';
        $home_parts = wp_parse_url(home_url());
        $home_host = isset($home_parts['host']) ? $home_parts['host'] : '';
        if (in_array(strtolower($href_scheme), array('http', 'https'), true)) {
            if (strtolower($href_host) === strtolower($home_host)) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 5.3

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .20

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        $href_parts = wp_parse_url($atts['href']['value']);
        $href_scheme = isset($href_parts['scheme']) ? $href_parts['scheme'] : '';
        $href_host = isset($href_parts['host']) ? $href_parts['host'] : '';
        $home_parts = wp_parse_url(home_url());
        $home_host = isset($home_parts['host']) ? $home_parts['host'] : '';
        if (in_array(strtolower($href_scheme), array('http', 'https'), true)) {
            if (strtolower($href_host) === strtolower($home_host)) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 5.2

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .18

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        $href_parts = wp_parse_url($atts['href']['value']);
        $href_scheme = isset($href_parts['scheme']) ? $href_parts['scheme'] : '';
        $href_host = isset($href_parts['host']) ? $href_parts['host'] : '';
        $home_parts = wp_parse_url(home_url());
        $home_host = isset($home_parts['host']) ? $home_parts['host'] : '';
        if (in_array(strtolower($href_scheme), array('http', 'https'), true)) {
            if (strtolower($href_host) === strtolower($home_host)) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: .17

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['href'])) {
        $href_parts = wp_parse_url($atts['href']);
        $href_scheme = isset($href_parts['scheme']) ? $href_parts['scheme'] : '';
        $href_host = isset($href_parts['host']) ? $href_parts['host'] : '';
        $home_parts = wp_parse_url(home_url());
        $home_host = isset($home_parts['host']) ? $home_parts['host'] : '';
        if (in_array(strtolower($href_scheme), array('http', 'https'), true)) {
            if (strtolower($href_host) === strtolower($home_host)) {
                return "<a {$text}>";
            }
        }
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"" . esc_attr($value) . "\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 4.5

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'http')) . ')%i', $text) || preg_match('%href=["\'](' . preg_quote(set_url_scheme(home_url(), 'https')) . ')%i', $text)) {
        return "<a {$text}>";
    }
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: 4.4

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .30

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 4.3

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .20

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 4.2

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: .19

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = wp_kses_hair($matches[1], wp_allowed_protocols());
    $rel = 'nofollow';
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']['value']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            if (isset($value['vless']) && 'y' === $value['vless']) {
                $html .= $name . ' ';
            } else {
                $html .= "{$name}=\"" . esc_attr($value['value']) . '" ';
            }
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: .18

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"" . esc_attr($value) . "\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"" . esc_attr($rel) . "\">";
}

WordPress Version: 4.4

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $atts = shortcode_parse_atts($matches[1]);
    $rel = 'nofollow';
    if (!empty($atts['rel'])) {
        $parts = array_map('trim', explode(' ', $atts['rel']));
        if (false === array_search('nofollow', $parts)) {
            $parts[] = 'nofollow';
        }
        $rel = implode(' ', $parts);
        unset($atts['rel']);
        $html = '';
        foreach ($atts as $name => $value) {
            $html .= "{$name}=\"{$value}\" ";
        }
        $text = trim($html);
    }
    return "<a {$text} rel=\"{$rel}\">";
}

WordPress Version: 3.7

/**
 * Callback to add rel=nofollow string to HTML A element.
 *
 * Will remove already existing rel="nofollow" and rel='nofollow' from the
 * string to prevent from invalidating (X)HTML.
 *
 * @since 2.3.0
 *
 * @param array $matches Single Match
 * @return string HTML A Element with rel nofollow.
 */
function wp_rel_nofollow_callback($matches)
{
    $text = $matches[1];
    $text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text);
    return "<a {$text} rel=\"nofollow\">";
}