diff --git src/wp-includes/formatting.php src/wp-includes/formatting.php
index e690948..b00e0ac 100644
|
|
|
function wp_targeted_link_rel_callback( $matches ) {
|
| 3094 | 3094 | $delimiter = trim( $rel_match[1] ) ? $rel_match[1] : '"'; |
| 3095 | 3095 | $rel = 'rel=' . $delimiter . trim( implode( ' ', $parts ) ) . $delimiter; |
| 3096 | 3096 | $link_html = str_replace( $rel_match[0], $rel, $link_html ); |
| | 3097 | } elseif ( preg_match( '|target\s*=\s*?\\\\"|', $link_html ) ) { |
| | 3098 | $link_html .= " rel=\\\"$rel\\\""; |
| 3097 | 3099 | } else { |
| 3098 | 3100 | $link_html .= " rel=\"$rel\""; |
| 3099 | 3101 | } |
diff --git tests/phpunit/tests/formatting/WPTargetedLinkRel.php tests/phpunit/tests/formatting/WPTargetedLinkRel.php
index 08f8ac1..56ea40c 100644
|
|
|
class Tests_Targeted_Link_Rel extends WP_UnitTestCase {
|
| 101 | 101 | |
| 102 | 102 | $this->assertEquals( $expected, $post->post_content ); |
| 103 | 103 | } |
| | 104 | |
| | 105 | /** |
| | 106 | * Ensure JSON format is preserved when relation attribute (rel) is missing. |
| | 107 | * |
| | 108 | * @ticket 46316 |
| | 109 | */ |
| | 110 | public function test_wp_targeted_link_rel_should_preserve_json() { |
| | 111 | $content = '<p>Links: <a href=\"\/\" target=\"_blank\">No rel<\/a><\/p>'; |
| | 112 | $expected = '<p>Links: <a href=\"\/\" target=\"_blank\" rel=\"noopener noreferrer\">No rel<\/a><\/p>'; |
| | 113 | $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); |
| | 114 | } |
| 104 | 115 | } |