diff --git src/wp-includes/formatting.php src/wp-includes/formatting.php
index dc97605..3d0d0f7 100644
|
|
function wp_rel_nofollow_callback( $matches ) { |
3039 | 3039 | */ |
3040 | 3040 | function wp_targeted_link_rel( $text ) { |
3041 | 3041 | // Don't run (more expensive) regex if no links with targets. |
3042 | | if ( stripos( $text, 'target' ) !== false && stripos( $text, '<a ' ) !== false ) { |
| 3042 | if ( stripos( $text, ' target' ) !== false && stripos( $text, '<a ' ) !== false ) { |
3043 | 3043 | $text = preg_replace_callback( '|<a\s([^>]*target\s*=[^>]*)>|i', 'wp_targeted_link_rel_callback', $text ); |
3044 | 3044 | } |
3045 | 3045 | |
diff --git tests/phpunit/tests/formatting/WPTargetedLinkRel.php tests/phpunit/tests/formatting/WPTargetedLinkRel.php
index 08f8ac1..4655d2c 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 the data-target attribute is ignored. |
| 107 | * |
| 108 | * @ticket 46886. |
| 109 | */ |
| 110 | public function test_ignore_data_target_attribute() { |
| 111 | $content = '<a href="https://example.com" data-target="thisandthat">click here</a>'; |
| 112 | $expected = $content; |
| 113 | $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); |
| 114 | } |
| 115 | |
104 | 116 | } |