Formatting: Prevent wp_targeted_link_rel() adding an empty attribute.

Bypass adding a `rel` attribute when the `wp_targeted_link_rel` filter returns an empty string or other falsy result.

Props mcmwebsol, spartank, meatman89fs.
Fixes #45352.

Built from https://develop.svn.wordpress.org/trunk@44691


git-svn-id: http://core.svn.wordpress.org/trunk@44522 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2019-01-22 21:55:51 +00:00
parent c204ac4bc7
commit 24e8467c6f
2 changed files with 6 additions and 1 deletions

View File

@ -3065,6 +3065,11 @@ function wp_targeted_link_rel_callback( $matches ) {
*/
$rel = apply_filters( 'wp_targeted_link_rel', 'noopener noreferrer', $link_html );
// Avoid additional regex if the filter removes rel values.
if ( ! $rel ) {
return "<a $link_html>";
}
// Value with delimiters, spaces around are optional.
$attr_regex = '|rel\s*=\s*?(\\\\{0,1}["\'])(.*?)\\1|i';
preg_match( $attr_regex, $link_html, $rel_match );

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.1-beta2-44690';
$wp_version = '5.1-beta2-44691';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.