Skip to content

Commit 3687668

Browse files
committed
Merge branch 'trunk' into add/document-outline-main
2 parents 56316b6 + edbd360 commit 3687668

File tree

318 files changed

+1603
-1093
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

318 files changed

+1603
-1093
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
https://github.com/WordPress/gutenberg/blob/trunk/CONTRIBUTING.md -->
33

44
## What?
5+
<!-- Link this PR to its associated issue with an appropriate keyword: Closes, See, Follow up to, etc. -->
6+
Closes <!-- #ISSUE-NUMBER or URL -->
7+
58
<!-- In a few words, what is the PR actually doing? -->
69

710
## Why?

.github/workflows/build-plugin-zip.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ jobs:
174174
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
175175

176176
- name: Use desired version of Node.js
177-
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
177+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
178178
with:
179179
node-version-file: '.nvmrc'
180180
check-latest: true
@@ -336,7 +336,7 @@ jobs:
336336
git config user.email gutenberg@wordpress.org
337337
338338
- name: Setup Node.js
339-
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
339+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
340340
with:
341341
node-version-file: 'main/.nvmrc'
342342
registry-url: 'https://registry.npmjs.org'

.github/workflows/bundle-size.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
4444

4545
- name: Use desired version of Node.js
46-
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
46+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
4747
with:
4848
node-version-file: '.nvmrc'
4949
check-latest: true

.github/workflows/publish-npm-packages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ jobs:
6767
6868
- name: Setup Node.js
6969
if: ${{ github.event.inputs.release_type != 'wp' }}
70-
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
70+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
7171
with:
7272
node-version-file: 'cli/.nvmrc'
7373
registry-url: 'https://registry.npmjs.org'
7474
check-latest: true
7575

7676
- name: Setup Node.js (for WP major version)
7777
if: ${{ github.event.inputs.release_type == 'wp' && github.event.inputs.wp_version }}
78-
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
78+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
7979
with:
8080
node-version-file: 'publish/.nvmrc'
8181
registry-url: 'https://registry.npmjs.org'

.github/workflows/rnmobile-ios-runner.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
with:
2929
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
3030

31-
- uses: ruby/setup-ruby@28c4deda893d5a96a6b2d958c5b47fc18d65c9d3 # v1.213.0
31+
- uses: ruby/setup-ruby@1287d2b408066abada82d5ad1c63652e758428d9 # v1.214.0
3232
with:
3333
# `.ruby-version` file location
3434
working-directory: packages/react-native-editor/ios

.github/workflows/static-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
2828

2929
- name: Use desired version of Node.js
30-
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
30+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
3131
with:
3232
node-version-file: '.nvmrc'
3333
check-latest: true

backport-changelog/6.8/7903.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
https://github.com/WordPress/wordpress-develop/pull/7903
22

33
* https://github.com/WordPress/gutenberg/pull/67199
4+
* https://github.com/WordPress/gutenberg/pull/68971
5+

backport-changelog/6.8/8212.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
https://github.com/WordPress/wordpress-develop/pull/8212
2+
3+
* https://github.com/WordPress/gutenberg/pull/68926

bin/generate-php-sync-issue.mjs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,6 @@ async function main() {
156156
fs.writeFileSync( nodePath.join( __dirname, 'issueContent.md' ), content );
157157
}
158158

159-
/**
160-
* Checks if the first date is after the second date.
161-
*
162-
* @param {string} date1 - The first date.
163-
* @param {string} date2 - The second date.
164-
* @return {boolean} - Returns true if the first date is after the second date, false otherwise.
165-
*/
166-
function isAfter( date1, date2 ) {
167-
return new Date( date1 ) > new Date( date2 );
168-
}
169-
170159
function validateDate( sinceArg ) {
171160
const sinceDate = new Date( sinceArg );
172161
const maxPreviousDate = new Date();

changelog.txt

Lines changed: 145 additions & 294 deletions
Large diffs are not rendered by default.

docs/contributors/code/coding-guidelines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ Many third-party dependencies will distribute their own TypeScript typings. For
607607

608608
If you use a [TypeScript integration](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Editor-Support) for your editor, you can typically see that this works if the type resolves to anything other than the fallback `any` type.
609609

610-
For packages which do not distribute their own TypeScript types, you are welcomed to install and use the [DefinitelyTyped](http://definitelytyped.org/) community-maintained types definitions, if one exists.
610+
For packages which do not distribute their own TypeScript types, you are welcomed to install and use the [DefinitelyTyped](https://definitelytyped.org/) community-maintained types definitions, if one exists.
611611

612612
### Generic types
613613

docs/contributors/code/testing-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Assuming you've followed the [instructions](/docs/contributors/code/getting-star
2929
npm test
3030
```
3131

32-
Linting is static code analysis used to enforce coding standards and to avoid potential errors. This project uses [ESLint](http://eslint.org/) and [TypeScript's JavaScript type-checking](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html) to capture these issues. While the above `npm test` will execute both unit tests and code linting, code linting can be verified independently by running `npm run lint`. Some JavaScript issues can be fixed automatically by running `npm run lint:js:fix`.
32+
Linting is static code analysis used to enforce coding standards and to avoid potential errors. This project uses [ESLint](https://eslint.org/) and [TypeScript's JavaScript type-checking](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html) to capture these issues. While the above `npm test` will execute both unit tests and code linting, code linting can be verified independently by running `npm run lint`. Some JavaScript issues can be fixed automatically by running `npm run lint:js:fix`.
3333

3434
To improve your developer workflow, you should setup an editor linting integration. See the [getting started documentation](/docs/contributors/code/getting-started-with-code-contribution.md) for additional information.
3535

docs/reference-guides/core-blocks.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Display a date archive of your posts. ([Source](https://github.com/WordPress/gut
1414

1515
- **Name:** core/archives
1616
- **Category:** widgets
17-
- **Supports:** align, interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
17+
- **Supports:** align, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
1818
- **Attributes:** displayAsDropdown, showLabel, showPostCounts, type
1919

2020
## Audio
@@ -78,7 +78,7 @@ Display a list of all terms of a given taxonomy. ([Source](https://github.com/Wo
7878

7979
- **Name:** core/categories
8080
- **Category:** widgets
81-
- **Supports:** align, interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
81+
- **Supports:** align, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
8282
- **Attributes:** displayAsDropdown, label, showEmpty, showHierarchy, showLabel, showOnlyTopLevel, showPostCounts, taxonomy
8383

8484
## Code
@@ -255,7 +255,7 @@ Hide and show additional content. ([Source](https://github.com/WordPress/gutenbe
255255
- **Name:** core/details
256256
- **Category:** text
257257
- **Supports:** align (full, wide), anchor, color (background, gradients, link, text), interactivity (clientNavigation), layout (~~allowEditing~~), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~
258-
- **Attributes:** allowedBlocks, name, showContent, summary
258+
- **Attributes:** allowedBlocks, name, placeholder, showContent, summary
259259

260260
## Embed
261261

@@ -811,7 +811,7 @@ Display entries from any RSS or Atom feed. ([Source](https://github.com/WordPres
811811

812812
- **Name:** core/rss
813813
- **Category:** widgets
814-
- **Supports:** align, color (background, gradients, link, text), interactivity (clientNavigation), ~~html~~
814+
- **Supports:** align, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), ~~html~~
815815
- **Attributes:** blockLayout, columns, displayAuthor, displayDate, displayExcerpt, excerptLength, feedURL, itemsToShow
816816

817817
## Search

docs/reference-guides/interactivity-api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Here you have some more resources to learn/read more about the Interactivity API
113113
- [Merge announcement](https://make.wordpress.org/core/2024/02/19/merge-announcement-interactivity-api/)
114114
- [Proposal: The Interactivity API – A better developer experience in building interactive blocks](https://make.wordpress.org/core/2023/03/30/proposal-the-interactivity-api-a-better-developer-experience-in-building-interactive-blocks/)
115115
- [Interactivity API Discussions](https://github.com/WordPress/gutenberg/discussions/52882), especially the [showcase](https://github.com/WordPress/gutenberg/discussions/55642#discussioncomment-9667164) discussions.
116-
- [wpmovies.dev](http://wpmovies.dev/) demo and its [wp-movies-demo](https://github.com/WordPress/wp-movies-demo) repo
116+
- [wpmovies.dev](https://wpmovies.dev/) demo and its [wp-movies-demo](https://github.com/WordPress/wp-movies-demo) repo
117117
- Examples using the Interactivity API at [block-development-examples](https://github.com/WordPress/block-development-examples):
118118
- [`interactivity-api-block-833d15`](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/interactivity-api-block-833d15)
119119
- [`interactivity-api-countdown-3cd73e`](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/interactivity-api-countdown-3cd73e)

gutenberg.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Description: Printing since 1440. This is the development plugin for the block editor, site editor, and other future WordPress core functionality.
66
* Requires at least: 6.6
77
* Requires PHP: 7.2
8-
* Version: 20.1.0
8+
* Version: 20.2.0-rc.1
99
* Author: Gutenberg Team
1010
* Text Domain: gutenberg
1111
*

lib/class-wp-theme-json-resolver-gutenberg.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ public static function get_theme_data( $deprecated = array(), $options = array()
359359
}
360360
if ( current_theme_supports( 'experimental-link-color' ) ) {
361361
_doing_it_wrong(
362-
current_theme_supports( 'experimental-link-color' ),
362+
"add_theme_support( 'experimental-link-color' )",
363363
__( '`experimental-link-color` is no longer supported. Use `link-color` instead.', 'gutenberg' ),
364364
'6.3.0'
365365
);

lib/client-assets.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ function gutenberg_enqueue_stored_styles( $options = array() ) {
539539

540540
// Combines Core styles.
541541
if ( ! empty( $compiled_core_stylesheet ) ) {
542-
wp_register_style( $style_tag_id, false, array(), true, true );
542+
wp_register_style( $style_tag_id, false, array(), true );
543543
wp_add_inline_style( $style_tag_id, $compiled_core_stylesheet );
544544
wp_enqueue_style( $style_tag_id );
545545
}
@@ -562,7 +562,7 @@ function gutenberg_enqueue_stored_styles( $options = array() ) {
562562
$styles = gutenberg_style_engine_get_stylesheet_from_context( $store_name, $options );
563563
if ( ! empty( $styles ) ) {
564564
$key = "wp-style-engine-$store_name";
565-
wp_register_style( $key, false, array(), true, true );
565+
wp_register_style( $key, false, array(), true );
566566
wp_add_inline_style( $key, $styles );
567567
wp_enqueue_style( $key );
568568
}

lib/compat/wordpress-6.8/blocks.php

Lines changed: 81 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,79 @@
55
* @package gutenberg
66
*/
77

8-
function gutenberg_apply_block_hooks_to_post_content( $content ) {
9-
// The `the_content` filter does not provide the post that the content is coming from.
10-
// However, we can infer it by calling `get_post()`, which will return the current post
11-
// if no post ID is provided.
12-
return apply_block_hooks_to_content( $content, get_post(), 'insert_hooked_blocks' );
8+
if ( ! function_exists( 'apply_block_hooks_to_content_from_post_object' ) ) {
9+
/**
10+
* Run the Block Hooks algorithm on a post object's content.
11+
*
12+
* This function is different from `apply_block_hooks_to_content` in that
13+
* it takes ignored hooked block information from the post's metadata into
14+
* account. This ensures that any blocks hooked as first or last child
15+
* of the block that corresponds to the post type are handled correctly.
16+
*
17+
* @since 6.8.0
18+
* @access private
19+
*
20+
* @param string $content Serialized content.
21+
* @param WP_Post|null $post A post object that the content belongs to. If set to `null`,
22+
* `get_post()` will be called to use the current post as context.
23+
* Default: `null`.
24+
* @param callable $callback A function that will be called for each block to generate
25+
* the markup for a given list of blocks that are hooked to it.
26+
* Default: 'insert_hooked_blocks'.
27+
* @return string The serialized markup.
28+
*/
29+
function apply_block_hooks_to_content_from_post_object( $content, WP_Post $post = null, $callback = 'insert_hooked_blocks' ) {
30+
// Default to the current post if no context is provided.
31+
if ( null === $post ) {
32+
$post = get_post();
33+
}
34+
35+
if ( ! $post instanceof WP_Post ) {
36+
return apply_block_hooks_to_content( $content, $post, $callback );
37+
}
38+
39+
$attributes = array();
40+
41+
// If context is a post object, `ignoredHookedBlocks` information is stored in its post meta.
42+
$ignored_hooked_blocks = get_post_meta( $post->ID, '_wp_ignored_hooked_blocks', true );
43+
if ( ! empty( $ignored_hooked_blocks ) ) {
44+
$ignored_hooked_blocks = json_decode( $ignored_hooked_blocks, true );
45+
$attributes['metadata'] = array(
46+
'ignoredHookedBlocks' => $ignored_hooked_blocks,
47+
);
48+
}
49+
50+
// We need to wrap the content in a temporary wrapper block with that metadata
51+
// so the Block Hooks algorithm can insert blocks that are hooked as first or last child
52+
// of the wrapper block.
53+
// To that end, we need to determine the wrapper block type based on the post type.
54+
if ( 'wp_navigation' === $post->post_type ) {
55+
$wrapper_block_type = 'core/navigation';
56+
} elseif ( 'wp_block' === $post->post_type ) {
57+
$wrapper_block_type = 'core/block';
58+
} else {
59+
$wrapper_block_type = 'core/post-content';
60+
}
61+
62+
$content = get_comment_delimited_block_content(
63+
$wrapper_block_type,
64+
$attributes,
65+
$content
66+
);
67+
68+
// Apply Block Hooks.
69+
$content = apply_block_hooks_to_content( $content, $post, $callback );
70+
71+
// Finally, we need to remove the temporary wrapper block.
72+
$content = remove_serialized_parent_block( $content );
73+
74+
return $content;
75+
}
76+
// We need to apply this filter before `do_blocks` (which is hooked to `the_content` at priority 9).
77+
add_filter( 'the_content', 'apply_block_hooks_to_content_from_post_object', 8 );
78+
// Remove apply_block_hooks_to_content filter (previously added in Core).
79+
remove_filter( 'the_content', 'apply_block_hooks_to_content', 8 );
1380
}
14-
// We need to apply this filter before `do_blocks` (which is hooked to `the_content` at priority 9).
15-
add_filter( 'the_content', 'gutenberg_apply_block_hooks_to_post_content', 8 );
1681

1782
/**
1883
* Hooks into the REST API response for the Posts endpoint and adds the first and last inner blocks.
@@ -29,57 +94,32 @@ function gutenberg_insert_hooked_blocks_into_rest_response( $response, $post ) {
2994
return $response;
3095
}
3196

32-
$attributes = array();
33-
$ignored_hooked_blocks = get_post_meta( $post->ID, '_wp_ignored_hooked_blocks', true );
34-
if ( ! empty( $ignored_hooked_blocks ) ) {
35-
$ignored_hooked_blocks = json_decode( $ignored_hooked_blocks, true );
36-
$attributes['metadata'] = array(
37-
'ignoredHookedBlocks' => $ignored_hooked_blocks,
38-
);
39-
}
40-
41-
if ( 'wp_navigation' === $post->post_type ) {
42-
$wrapper_block_type = 'core/navigation';
43-
} elseif ( 'wp_block' === $post->post_type ) {
44-
$wrapper_block_type = 'core/block';
45-
} else {
46-
$wrapper_block_type = 'core/post-content';
47-
}
48-
49-
$content = get_comment_delimited_block_content(
50-
$wrapper_block_type,
51-
$attributes,
52-
$response->data['content']['raw']
53-
);
54-
55-
$content = apply_block_hooks_to_content(
56-
$content,
97+
$response->data['content']['raw'] = apply_block_hooks_to_content_from_post_object(
98+
$response->data['content']['raw'],
5799
$post,
58100
'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata'
59101
);
60102

61-
// Remove mock block wrapper.
62-
$content = remove_serialized_parent_block( $content );
63-
64-
$response->data['content']['raw'] = $content;
65-
66103
// If the rendered content was previously empty, we leave it like that.
67104
if ( empty( $response->data['content']['rendered'] ) ) {
68105
return $response;
69106
}
70107

71108
// No need to inject hooked blocks twice.
72-
$priority = has_filter( 'the_content', 'apply_block_hooks_to_content' );
109+
$priority = has_filter( 'the_content', 'apply_block_hooks_to_content_from_post_object' );
73110
if ( false !== $priority ) {
74-
remove_filter( 'the_content', 'apply_block_hooks_to_content', $priority );
111+
remove_filter( 'the_content', 'apply_block_hooks_to_content_from_post_object', $priority );
75112
}
76113

77114
/** This filter is documented in wp-includes/post-template.php */
78-
$response->data['content']['rendered'] = apply_filters( 'the_content', $content );
115+
$response->data['content']['rendered'] = apply_filters(
116+
'the_content',
117+
$response->data['content']['raw']
118+
);
79119

80120
// Add back the filter.
81121
if ( false !== $priority ) {
82-
add_filter( 'the_content', 'apply_block_hooks_to_content', $priority );
122+
add_filter( 'the_content', 'apply_block_hooks_to_content_from_post_object', $priority );
83123
}
84124

85125
return $response;

lib/compat/wordpress-6.8/site-editor.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ function ( $settings ) {
1515
}
1616
);
1717

18+
/**
19+
* Maps old site editor urls to the new updated ones.
20+
*
21+
* @since 6.8.0
22+
* @access private
23+
*
24+
* @global string $pagenow The filename of the current screen.
25+
*
26+
* @return string|false The new URL to redirect to, or false if no redirection is needed.
27+
*/
1828
function gutenberg_get_site_editor_redirection() {
1929
global $pagenow;
2030
if ( 'site-editor.php' !== $pagenow || isset( $_REQUEST['p'] ) || ! $_SERVER['QUERY_STRING'] ) {
@@ -96,10 +106,13 @@ function gutenberg_get_site_editor_redirection() {
96106
return add_query_arg( array( 'p' => '/' ) );
97107
}
98108

109+
/**
110+
* Redirect old site editor urls to the new updated ones.
111+
*/
99112
function gutenberg_redirect_site_editor_deprecated_urls() {
100113
$redirection = gutenberg_get_site_editor_redirection();
101114
if ( false !== $redirection ) {
102-
wp_redirect( $redirection, 301 );
115+
wp_safe_redirect( $redirection );
103116
exit;
104117
}
105118
}

0 commit comments

Comments
 (0)