Formatting: Improve rel="nofollow"
handling in comments.
git-svn-id: https://develop.svn.wordpress.org/trunk@44833 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
da7b514926
commit
4a0e3f009d
@ -3004,10 +3004,12 @@ function wp_rel_nofollow_callback( $matches ) {
|
|||||||
$atts = shortcode_parse_atts( $matches[1] );
|
$atts = shortcode_parse_atts( $matches[1] );
|
||||||
$rel = 'nofollow';
|
$rel = 'nofollow';
|
||||||
|
|
||||||
if ( preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'http' ) ) . ')%i', $text ) ||
|
if ( ! empty( $atts['href'] ) ) {
|
||||||
preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'https' ) ) . ')%i', $text ) ) {
|
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>";
|
return "<a $text>";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $atts['rel'] ) ) {
|
if ( ! empty( $atts['rel'] ) ) {
|
||||||
@ -3020,11 +3022,11 @@ function wp_rel_nofollow_callback( $matches ) {
|
|||||||
|
|
||||||
$html = '';
|
$html = '';
|
||||||
foreach ( $atts as $name => $value ) {
|
foreach ( $atts as $name => $value ) {
|
||||||
$html .= "{$name}=\"$value\" ";
|
$html .= "{$name}=\"" . esc_attr( $value ) . "\" ";
|
||||||
}
|
}
|
||||||
$text = trim( $html );
|
$text = trim( $html );
|
||||||
}
|
}
|
||||||
return "<a $text rel=\"$rel\">";
|
return "<a $text rel=\"" . esc_attr( $rel ) . "\">";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user