Improve handling the existing `rel` attribute in `wp_rel_nofollow_callback()`.
Props xknown, sstoqnov. Built from https://develop.svn.wordpress.org/trunk@45990 git-svn-id: http://core.svn.wordpress.org/trunk@45801 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
90d9bdc54c
commit
62b22b86a7
|
@ -3043,19 +3043,19 @@ function wp_rel_nofollow( $text ) {
|
||||||
*/
|
*/
|
||||||
function wp_rel_nofollow_callback( $matches ) {
|
function wp_rel_nofollow_callback( $matches ) {
|
||||||
$text = $matches[1];
|
$text = $matches[1];
|
||||||
$atts = shortcode_parse_atts( $matches[1] );
|
$atts = wp_kses_hair( $matches[1], wp_allowed_protocols() );
|
||||||
$rel = 'nofollow';
|
$rel = 'nofollow';
|
||||||
|
|
||||||
if ( ! empty( $atts['href'] ) ) {
|
if ( ! empty( $atts['href'] ) ) {
|
||||||
if ( in_array( strtolower( wp_parse_url( $atts['href'], PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) {
|
if ( in_array( strtolower( wp_parse_url( $atts['href']['value'], 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 ) ) ) {
|
if ( strtolower( wp_parse_url( $atts['href']['value'], 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'] ) ) {
|
||||||
$parts = array_map( 'trim', explode( ' ', $atts['rel'] ) );
|
$parts = array_map( 'trim', explode( ' ', $atts['rel']['value'] ) );
|
||||||
if ( false === array_search( 'nofollow', $parts ) ) {
|
if ( false === array_search( 'nofollow', $parts ) ) {
|
||||||
$parts[] = 'nofollow';
|
$parts[] = 'nofollow';
|
||||||
}
|
}
|
||||||
|
@ -3064,7 +3064,11 @@ function wp_rel_nofollow_callback( $matches ) {
|
||||||
|
|
||||||
$html = '';
|
$html = '';
|
||||||
foreach ( $atts as $name => $value ) {
|
foreach ( $atts as $name => $value ) {
|
||||||
$html .= "{$name}=\"" . esc_attr( $value ) . '" ';
|
if ( isset( $value['vless'] ) && 'y' === $value['vless'] ) {
|
||||||
|
$html .= $name . ' ';
|
||||||
|
} else {
|
||||||
|
$html .= "{$name}=\"" . esc_attr( $value['value'] ) . '" ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$text = trim( $html );
|
$text = trim( $html );
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.3-alpha-45979';
|
$wp_version = '5.3-alpha-45990';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue