mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@44691 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user