mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-04 06:37:06 +00:00
General: Add "noopener" to wp_list_bookmarks() output.
In the bookmarks walker `_walk_bookmarks()`, add a `'noopener'` to the bookmark's `rel` attribute when there's `target` attribute. Adds a new test class for `wp_list_bookmarks()` and tests for this change. Follow-up to [3880], [10712]. Props birgire, costdev, hellofromTonya, mukesh27 , sergeybiryukov, tw2113. Fixes #53839. git-svn-id: https://develop.svn.wordpress.org/trunk@52061 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -102,13 +102,24 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
|
||||
$title = ' title="' . $title . '"';
|
||||
}
|
||||
$rel = $bookmark->link_rel;
|
||||
|
||||
$target = $bookmark->link_target;
|
||||
if ( '' !== $target ) {
|
||||
if ( is_string( $rel ) && '' !== $rel ) {
|
||||
if ( ! str_contains( $rel, 'noopener' ) ) {
|
||||
$rel = trim( $rel ) . ' noopener';
|
||||
}
|
||||
} else {
|
||||
$rel = 'noopener';
|
||||
}
|
||||
|
||||
$target = ' target="' . $target . '"';
|
||||
}
|
||||
|
||||
if ( '' !== $rel ) {
|
||||
$rel = ' rel="' . esc_attr( $rel ) . '"';
|
||||
}
|
||||
$target = $bookmark->link_target;
|
||||
if ( '' !== $target ) {
|
||||
$target = ' target="' . $target . '"';
|
||||
}
|
||||
|
||||
$output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>';
|
||||
|
||||
$output .= $parsed_args['link_before'];
|
||||
|
||||
Reference in New Issue
Block a user