Skip to content

Commit 607fb15

Browse files
ellatrixdmsnell
authored andcommitted
Restore: Sync Gutenberg @ 8c78d87453509661a9f28f978ba2c242d515563b
See changelog in 21d3c57 > Editor: Bump pinned hash for the Gutenberg repository. > This updates the pinned hash from the `gutenberg` from `9b8144036fa5faf75de43d4502ff9809fcf689ad` to `8c78d87453509661a9f28f978ba2c242d515563b`. > > The following changes are included:
1 parent 46df533 commit 607fb15

File tree

11 files changed

+550
-152
lines changed

11 files changed

+550
-152
lines changed

src/wp-includes/assets/script-loader-packages.min.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
'wp-url',
101101
'wp-warning'
102102
),
103-
'version' => 'ca7e8cfd2cd06d8897bb'
103+
'version' => 'd803068b8e202e8ddcc9'
104104
),
105105
'block-library.min.js' => array(
106106
'dependencies' => array(
@@ -142,7 +142,7 @@
142142
'import' => 'dynamic'
143143
)
144144
),
145-
'version' => 'c2d339cfc3f518d7ae7d'
145+
'version' => '34fa1c224ed894b32e72'
146146
),
147147
'block-serialization-default-parser.min.js' => array(
148148
'dependencies' => array(
@@ -175,7 +175,7 @@
175175
'wp-shortcode',
176176
'wp-warning'
177177
),
178-
'version' => '043731fad526d26793c6'
178+
'version' => 'ef38e42500165bfda301'
179179
),
180180
'commands.min.js' => array(
181181
'dependencies' => array(
@@ -214,7 +214,7 @@
214214
'wp-rich-text',
215215
'wp-warning'
216216
),
217-
'version' => '0405cfa25ddf48f7c0f2'
217+
'version' => 'e778951c7b5eb4671d91'
218218
),
219219
'compose.min.js' => array(
220220
'dependencies' => array(
@@ -266,7 +266,7 @@
266266
'wp-url',
267267
'wp-warning'
268268
),
269-
'version' => 'f45e47fb68691ad2950f'
269+
'version' => '767b16974e5758002db2'
270270
),
271271
'customize-widgets.min.js' => array(
272272
'dependencies' => array(
@@ -377,7 +377,7 @@
377377
'import' => 'static'
378378
)
379379
),
380-
'version' => '8a4bb8684179cd65c841'
380+
'version' => '5eccb583f18c127f6b68'
381381
),
382382
'edit-site.min.js' => array(
383383
'dependencies' => array(
@@ -424,7 +424,7 @@
424424
'import' => 'static'
425425
)
426426
),
427-
'version' => 'f1371886f952c7d1e117'
427+
'version' => 'd2dda88d87840f09cc45'
428428
),
429429
'edit-widgets.min.js' => array(
430430
'dependencies' => array(
@@ -511,7 +511,7 @@
511511
'import' => 'static'
512512
)
513513
),
514-
'version' => 'f01d293e2d88336274ff'
514+
'version' => 'd6964395bb65759fe0ab'
515515
),
516516
'element.min.js' => array(
517517
'dependencies' => array(

src/wp-includes/assets/script-modules-packages.min.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
'wp-i18n',
176176
'wp-private-apis'
177177
),
178-
'version' => 'bd74f3db1cc1555ee90d'
178+
'version' => '0db9a26c7920b6ab9f4a'
179179
),
180180
'core-abilities/index.min.js' => array(
181181
'dependencies' => array(
@@ -298,7 +298,7 @@
298298
'dependencies' => array(
299299

300300
),
301-
'version' => 'a742676bcc8809271cc6'
301+
'version' => '61b86a5f5540ba666280'
302302
),
303303
'workflow/index.min.js' => array(
304304
'dependencies' => array(

src/wp-includes/blocks/accordion-item.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
* @package WordPress
77
* @since 6.9.0
88
*
9-
* @param array $attributes The block attributes.
10-
* @param string $content The block content.
11-
*
9+
* @param array{ openByDefault: bool } $attributes The block attributes.
10+
* @param string $content The block content.
1211
* @return string Returns the updated markup.
1312
*/
14-
function block_core_accordion_item_render( $attributes, $content ) {
15-
if ( ! $content ) {
13+
function block_core_accordion_item_render( array $attributes, string $content ): string {
14+
if ( '' === $content ) {
1615
return $content;
1716
}
1817

@@ -56,6 +55,19 @@ function block_core_accordion_item_render( $attributes, $content ) {
5655
}
5756
}
5857

58+
/*
59+
* If an Accordion Item is collapsed by default, ensure any contained IMG has fetchpriority=low to deprioritize it
60+
* from contending with resources in the critical rendering path. In contrast, remove the loading attribute to
61+
* prevent the image from not being available when the item is expanded.
62+
*/
63+
if ( ! $attributes['openByDefault'] ) {
64+
$processor = new WP_HTML_Tag_Processor( $content );
65+
while ( $processor->next_tag( 'IMG' ) ) {
66+
$processor->set_attribute( 'fetchpriority', 'low' );
67+
}
68+
$content = $processor->get_updated_html();
69+
}
70+
5971
return $content;
6072
}
6173

src/wp-includes/blocks/cover.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ function render_block_core_cover( $attributes, $content ) {
6666
$query_params['controls'] = '0';
6767
$query_params['modestbranding'] = '1';
6868
$query_params['playsinline'] = '1';
69+
70+
// For loop to work, we need the playlist parameter.
71+
$path = $parsed_url['path'] ?? '';
72+
$path_segments = explode( '/', $path );
73+
$video_id = end( $path_segments );
74+
if ( $video_id ) {
75+
$query_params['playlist'] = $video_id;
76+
}
6977
} elseif ( 'vimeo' === $provider ) {
7078
$query_params['autoplay'] = '1';
7179
$query_params['muted'] = '1';

src/wp-includes/blocks/details.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Server-side rendering of the `core/details` block.
4+
*
5+
* @package WordPress
6+
*/
7+
8+
/**
9+
* Sets fetchpriority="low" on all IMG tags within the collapsed Details block.
10+
*
11+
* Images in a collapsed Details block are hidden until the block is expanded, so they should
12+
* not compete with any resources in the critical rendering path, such as the LCP element image.
13+
*
14+
* @since 7.0.0
15+
*
16+
* @param string $block_content The block content.
17+
* @param array $block The full block, including name and attributes.
18+
* @return string Modified HTML with fetchpriority="low" on all IMG tags when the showContent attribute is false.
19+
*/
20+
function block_core_details_set_img_fetchpriority_low( $block_content, array $block ): string {
21+
if ( ! is_string( $block_content ) ) {
22+
return '';
23+
}
24+
25+
// If the Details block is open by default, short-circuit to let core add fetchpriority=high if appropriate.
26+
if ( $block['attrs']['showContent'] ?? false ) {
27+
return $block_content;
28+
}
29+
30+
$tags = new WP_HTML_Tag_Processor( $block_content );
31+
while ( $tags->next_tag( 'IMG' ) ) {
32+
$tags->set_attribute( 'fetchpriority', 'low' );
33+
}
34+
return $tags->get_updated_html();
35+
}
36+
37+
add_filter( 'render_block_core/details', 'block_core_details_set_img_fetchpriority_low', 10, 2 );
38+
39+
/**
40+
* Registers the `core/details` block on server.
41+
*
42+
* @since 7.0.0
43+
*/
44+
function register_block_core_details() {
45+
register_block_type_from_metadata( __DIR__ . '/details' );
46+
}
47+
add_action( 'init', 'register_block_core_details' );

src/wp-includes/blocks/navigation.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,12 @@ private static function get_responsive_container_markup( $attributes, $inner_blo
710710
$tags = new WP_HTML_Tag_Processor( $overlay_blocks_html );
711711
$overlay_blocks_html = block_core_navigation_add_directives_to_overlay_close( $tags );
712712
}
713+
// Images in the overlay are hidden until the menu is opened. Pre-set
714+
// fetchpriority="low" so that when wp_filter_content_tags() processes the
715+
// parent template part, it sees the attribute already present and calls
716+
// wp_get_loading_optimization_attributes() with fetchpriority="low", which both prevents
717+
// fetchpriority="high" from being added and stops the LCP counter from being incremented.
718+
$overlay_blocks_html = block_core_navigation_set_overlay_image_fetch_priority( $overlay_blocks_html );
713719
}
714720

715721
$has_custom_overlay = ! empty( $overlay_blocks_html );
@@ -1111,6 +1117,25 @@ function block_core_navigation_add_directives_to_overlay_close( $tags ) {
11111117
return $tags->get_updated_html();
11121118
}
11131119

1120+
/**
1121+
* Sets fetchpriority="low" on all IMG tags within the navigation overlay.
1122+
*
1123+
* Images in the overlay are hidden until the menu is opened, so they should
1124+
* not compete with any actual LCP element image on the page.
1125+
*
1126+
* @since 7.0.0
1127+
*
1128+
* @param string $overlay_blocks_html The rendered HTML of the overlay blocks.
1129+
* @return string Modified HTML with fetchpriority="low" on all IMG tags.
1130+
*/
1131+
function block_core_navigation_set_overlay_image_fetch_priority( string $overlay_blocks_html ): string {
1132+
$tags = new WP_HTML_Tag_Processor( $overlay_blocks_html );
1133+
while ( $tags->next_tag( 'IMG' ) ) {
1134+
$tags->set_attribute( 'fetchpriority', 'low' );
1135+
}
1136+
return $tags->get_updated_html();
1137+
}
1138+
11141139
/**
11151140
* Add Interactivity API directives to the navigation-submenu and page-list
11161141
* blocks markup using the Tag Processor.

src/wp-includes/blocks/require-dynamic-blocks.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
require_once ABSPATH . WPINC . '/blocks/comments-pagination-previous.php';
2525
require_once ABSPATH . WPINC . '/blocks/comments-title.php';
2626
require_once ABSPATH . WPINC . '/blocks/cover.php';
27+
require_once ABSPATH . WPINC . '/blocks/details.php';
2728
require_once ABSPATH . WPINC . '/blocks/file.php';
2829
require_once ABSPATH . WPINC . '/blocks/footnotes.php';
2930
require_once ABSPATH . WPINC . '/blocks/gallery.php';

src/wp-includes/blocks/require-static-blocks.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
'code',
1111
'column',
1212
'columns',
13-
'details',
1413
'embed',
1514
'freeform',
1615
'group',

0 commit comments

Comments
 (0)