mirror of
git://develop.git.wordpress.org/
synced 2025-01-17 21:08:44 +01:00
Formatting: Improve rel="nofollow"
handling in comments.
Merges [44833] to the 4.6 branch. git-svn-id: https://develop.svn.wordpress.org/branches/4.6@44839 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
647892a950
commit
db7b94f7db
@ -2716,10 +2716,12 @@ function wp_rel_nofollow_callback( $matches ) {
|
||||
$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['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'] ) ) {
|
||||
@ -2732,11 +2734,11 @@ function wp_rel_nofollow_callback( $matches ) {
|
||||
|
||||
$html = '';
|
||||
foreach ( $atts as $name => $value ) {
|
||||
$html .= "{$name}=\"$value\" ";
|
||||
$html .= "{$name}=\"" . esc_attr( $value ) . "\" ";
|
||||
}
|
||||
$text = trim( $html );
|
||||
}
|
||||
return "<a $text rel=\"$rel\">";
|
||||
return "<a $text rel=\"" . esc_attr( $rel ) . "\">";
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user