Changeset 58143
- Timestamp:
- 05/13/2024 10:37:38 PM (5 months ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/embed.php
r58097 r58143 967 967 if ( ! empty( $content[1] ) ) { 968 968 // We have a blockquote to fall back on. Hide the iframe by default. 969 $html = str_replace( '<iframe', '<iframe style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"', $html );969 $html = str_replace( '<iframe', '<iframe style="position: absolute; visibility: hidden;"', $html ); 970 970 $html = str_replace( '<blockquote', '<blockquote class="wp-embedded-content"', $html ); 971 971 } … … 1100 1100 */ 1101 1101 function _oembed_filter_feed_content( $content ) { 1102 return str_replace( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $content ); 1102 $p = new WP_HTML_Tag_Processor( $content ); 1103 while ( $p->next_tag( array( 'tag_name' => 'iframe' ) ) ) { 1104 if ( $p->has_class( 'wp-embedded-content' ) ) { 1105 $p->remove_attribute( 'style' ); 1106 } 1107 } 1108 return $p->get_updated_html(); 1103 1109 } 1104 1110 -
trunk/src/wp-includes/media.php
r58110 r58143 2198 2198 */ 2199 2199 function wp_iframe_tag_add_loading_attr( $iframe, $context ) { 2200 /*2201 * Iframes with fallback content (see `wp_filter_oembed_result()`) should not be lazy-loaded because they are2202 * visually hidden initially.2203 */2204 if ( str_contains( $iframe, ' data-secret="' ) ) {2205 return $iframe;2206 }2207 2208 2200 /* 2209 2201 * Get loading attribute value to use. This must occur before the conditional check below so that even iframes that -
trunk/tests/phpunit/tests/media.php
r57987 r58143 3258 3258 /** 3259 3259 * @ticket 52768 3260 */ 3261 public function test_wp_iframe_tag_add_loading_attr_skip_wp_embed() { 3260 * @ticket 58773 3261 */ 3262 public function test_wp_iframe_tag_add_loading_attr_include_wp_embed() { 3262 3263 $iframe = '<iframe src="https://www.example.com" width="640" height="360"></iframe>'; 3263 3264 $fallback = '<blockquote>Fallback content.</blockquote>'; … … 3265 3266 $iframe = wp_iframe_tag_add_loading_attr( $iframe, 'test' ); 3266 3267 3267 $this->assertString NotContainsString( ' loading=', $iframe );3268 $this->assertStringContainsString( ' loading="lazy"', $iframe ); 3268 3269 } 3269 3270 -
trunk/tests/phpunit/tests/oembed/filterResult.php
r57987 r58143 84 84 $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); 85 85 86 $this->assertSame( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"></iframe>', $actual );86 $this->assertSame( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;"></iframe>', $actual ); 87 87 } 88 88 … … 91 91 $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); 92 92 93 $this->assertSame( '<blockquote class="wp-embedded-content"><a href=""></a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"></iframe>', $actual );93 $this->assertSame( '<blockquote class="wp-embedded-content"><a href=""></a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;"></iframe>', $actual ); 94 94 } 95 95 … … 98 98 array( 99 99 '<blockquote></blockquote><iframe title=""></iframe>', 100 '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="Hola"></iframe>',100 '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="Hola"></iframe>', 101 101 ), 102 102 array( 103 103 '<blockquote class="foo" id="bar"><strong><a href="" target=""></a></strong></blockquote><iframe width=123></iframe>', 104 '<blockquote class="wp-embedded-content"><a href=""></a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="Hola" width="123"></iframe>',104 '<blockquote class="wp-embedded-content"><a href=""></a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="Hola" width="123"></iframe>', 105 105 ), 106 106 array( 107 107 '<blockquote><iframe width="100"></iframe></blockquote><iframe stitle="aaaa"></iframe>', 108 '<blockquote class="wp-embedded-content"><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="Hola" width="100"></iframe></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="Hola"></iframe>',108 '<blockquote class="wp-embedded-content"><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="Hola" width="100"></iframe></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="Hola"></iframe>', 109 109 ), 110 110 array( 111 111 "<blockquote><iframe title=' width=\"'></iframe></blockquote><iframe title='' height=' title=' width=\"'' height='123'\"></iframe>", 112 '<blockquote class="wp-embedded-content"><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title=" width=""></iframe></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title=" width="" height=\' title=\' width="\'\' height=\'123\'"></iframe>',112 '<blockquote class="wp-embedded-content"><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title=" width=""></iframe></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title=" width="" height=\' title=\' width="\'\' height=\'123\'"></iframe>', 113 113 ), 114 114 ); … … 135 135 $actual = _oembed_filter_feed_content( wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ) ); 136 136 137 $this->assertSame( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" ></iframe>', $actual );137 $this->assertSame( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" ></iframe>', $actual ); 138 138 } 139 139 } -
trunk/tests/phpunit/tests/oembed/template.php
r57306 r58143 322 322 $this->assertFalse( $scripts->query( 'wp-embed', 'enqueued' ) ); 323 323 324 $post_embed = '<blockquote class="wp-embedded-content" data-secret="S24AQCJW9i"><a href="https://make.wordpress.org/core/2016/03/11/embeds-changes-in-wordpress-4-5/">Embeds Changes in WordPress 4.5</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="“Embeds Changes in WordPress 4.5” — Make WordPress Core" src="https://make.wordpress.org/core/2016/03/11/embeds-changes-in-wordpress-4-5/embed/#?secret=S24AQCJW9i" data-secret="S24AQCJW9i" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>';324 $post_embed = '<blockquote class="wp-embedded-content" data-secret="S24AQCJW9i"><a href="https://make.wordpress.org/core/2016/03/11/embeds-changes-in-wordpress-4-5/">Embeds Changes in WordPress 4.5</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="“Embeds Changes in WordPress 4.5” — Make WordPress Core" src="https://make.wordpress.org/core/2016/03/11/embeds-changes-in-wordpress-4-5/embed/#?secret=S24AQCJW9i" data-secret="S24AQCJW9i" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>'; 325 325 $non_post_embed = '<iframe title="Zoo Cares For 23 Tiny Pond Turtles" width="750" height="422" src="https://www.youtube.com/embed/6ZXHqUjL6f8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'; 326 326 … … 339 339 $this->assertFalse( $scripts->query( 'wp-embed', 'enqueued' ) ); 340 340 341 $post_embed = '<blockquote class="wp-embedded-content" data-secret="S24AQCJW9i"><a href="https://make.wordpress.org/core/2016/03/11/embeds-changes-in-wordpress-4-5/">Embeds Changes in WordPress 4.5</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="“Embeds Changes in WordPress 4.5” — Make WordPress Core" src="https://make.wordpress.org/core/2016/03/11/embeds-changes-in-wordpress-4-5/embed/#?secret=S24AQCJW9i" data-secret="S24AQCJW9i" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>';341 $post_embed = '<blockquote class="wp-embedded-content" data-secret="S24AQCJW9i"><a href="https://make.wordpress.org/core/2016/03/11/embeds-changes-in-wordpress-4-5/">Embeds Changes in WordPress 4.5</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="“Embeds Changes in WordPress 4.5” — Make WordPress Core" src="https://make.wordpress.org/core/2016/03/11/embeds-changes-in-wordpress-4-5/embed/#?secret=S24AQCJW9i" data-secret="S24AQCJW9i" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>'; 342 342 343 343 wp_maybe_enqueue_oembed_host_js( $post_embed );
Note: See TracChangeset
for help on using the changeset viewer.