Skip to content

Commit bc66ed4

Browse files
committed
Merge branch 'trunk' into try/post-navigation-block
2 parents a0f10b0 + 1418afc commit bc66ed4

File tree

172 files changed

+2108
-2952
lines changed

Some content is hidden

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

172 files changed

+2108
-2952
lines changed

.github/CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/packages/block-library/src/comment-template @michalczaplinski
1919
/packages/block-library/src/comments @michalczaplinski
2020
/packages/block-library/src/table-of-contents @ZebulanStanphill
21-
/packages/block-library/src/image @artemiomorales @michalczaplinski
21+
/packages/block-library/src/image @artemiomorales
2222

2323
# Duotone
2424
/lib/block-supports/duotone.php

.github/workflows/check-backport-changelog.yml

+4-11
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,15 @@ on:
1818
- '!packages/e2e-tests/**'
1919
jobs:
2020
check:
21-
name: Check CHANGELOG diff
21+
name: Check for a Core backport changelog entry
2222
runs-on: ubuntu-latest
23+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'No Core Sync Required') && !contains(github.event.pull_request.labels.*.name, 'Backport from WordPress Core') }}
2324
steps:
24-
- name: 'Get PR commit count'
25-
run: echo "PR_COMMIT_COUNT=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
26-
- name: Checkout code
27-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
25+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2826
with:
2927
ref: ${{ github.event.pull_request.head.ref }}
3028
repository: ${{ github.event.pull_request.head.repo.full_name }}
31-
fetch-depth: ${{ env.PR_COMMIT_COUNT }}
32-
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
33-
- name: 'Fetch relevant history from origin'
34-
run: git fetch origin ${{ github.event.pull_request.base.ref }}
35-
- name: Check CHANGELOG status
36-
if: ${{ !contains(github.event.pull_request.labels.*.name, 'No Core Sync Required') && !contains(github.event.pull_request.labels.*.name, 'Backport from WordPress Core') }}
29+
- name: Check the changelog folder
3730
env:
3831
PR_NUMBER: ${{ github.event.number }}
3932
run: |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Sync Core Backport Issue
2+
3+
on:
4+
push:
5+
branches:
6+
- trunk
7+
8+
jobs:
9+
sync-backport-changelog:
10+
name: Sync Core Backport Issue
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
14+
with:
15+
fetch-depth: 2 # Fetch the last two commits to compare changes
16+
- name: Check for changes in backport-changelog
17+
run: |
18+
git diff --quiet HEAD^ HEAD -- backport-changelog || echo "changes=true" >> $GITHUB_OUTPUT
19+
- name: Sync Issue
20+
if: env.changes == 'true'
21+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
22+
with:
23+
script: |
24+
const labelName = '🤖 Sync Backport Changelog';
25+
const issues = await github.paginate(github.rest.issues.listForRepo, {
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
labels: [labelName],
29+
state: 'open',
30+
per_page: 1,
31+
});
32+
33+
if (issues.length === 0) {
34+
console.log(`No issues found with the "${labelName}" label.`);
35+
return;
36+
}
37+
38+
const [latestIssue] = issues;
39+
const versionMatch = latestIssue.title.match(/(\d+\.\d+)/);
40+
if (!versionMatch) {
41+
console.log('Could not find a version number in the latest issue title.');
42+
return;
43+
}
44+
45+
const version = versionMatch[1];
46+
console.log(`Latest version: ${version}`);
47+
48+
const { execSync } = require('child_process');
49+
const processedChangelog = execSync(`awk '/./ {print ($0 ~ /^[-*]/ ? " " : "- ") $0}' backport-changelog/${version}/*.md`).toString().trim();
50+
51+
const startDelimiter = '<!-- START TRUNK BACKPORT CHANGELOG -->';
52+
const endDelimiter = '<!-- END TRUNK BACKPORT CHANGELOG -->';
53+
const autoGeneratedContent = `${startDelimiter}\n${processedChangelog}\n${endDelimiter}`;
54+
55+
const regex = new RegExp(`${startDelimiter}[\\s\\S]*${endDelimiter}`);
56+
let newBody;
57+
58+
if (regex.test(latestIssue.body)) {
59+
// If delimiters exist, replace the content between them
60+
newBody = latestIssue.body.replace(regex, autoGeneratedContent);
61+
} else {
62+
// If delimiters don't exist, append the new content at the end
63+
newBody = `${latestIssue.body}\n\n${autoGeneratedContent}`;
64+
}
65+
66+
if (newBody.trim() !== latestIssue.body.trim()) {
67+
await github.rest.issues.update({
68+
owner: context.repo.owner,
69+
repo: context.repo.repo,
70+
issue_number: latestIssue.number,
71+
body: newBody
72+
});
73+
console.log('Issue description updated successfully.');
74+
} else {
75+
console.log('Issue description is already up to date.');
76+
}

.wp-env.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "./schemas/json/wp-env.json",
23
"core": "WordPress/WordPress",
34
"plugins": [ "." ],
45
"themes": [ "./test/emptytheme" ],

backport-changelog/6.6/6987.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
https://github.com/WordPress/wordpress-develop/pull/6987
2+
3+
* https://github.com/WordPress/gutenberg/pull/63207

backport-changelog/6.6/6989.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
https://github.com/WordPress/wordpress-develop/pull/6989
2+
3+
* https://github.com/WordPress/gutenberg/pull/63172

backport-changelog/6.7/6668.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
https://github.com/WordPress/wordpress-develop/pull/6668
2+
3+
* https://github.com/WordPress/gutenberg/pull/62092

backport-changelog/6.7/6910.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ https://github.com/WordPress/wordpress-develop/pull/6910
22

33
* https://github.com/WordPress/gutenberg/pull/59483
44
* https://github.com/WordPress/gutenberg/pull/60652
5-
* https://github.com/WordPress/gutenberg/pull/62777
5+
* https://github.com/WordPress/gutenberg/pull/62777
6+
* https://github.com/WordPress/gutenberg/pull/63108

docs/reference-guides/block-api/block-metadata.md

+43-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ See the [Example documentation](/docs/reference-guides/block-api/block-registrat
427427

428428
### Variations
429429

430-
- Type: `object[]`
430+
- Type: `object[]|WPDefinedPath` ([learn more](#wpdefinedpath))
431431
- Optional
432432
- Localized: Yes (`title`, `description`, and `keywords` of each variation only)
433433
- Property: `variations`
@@ -454,6 +454,48 @@ Block Variations is the API that allows a block to have similar versions of it,
454454

455455
_Note: In JavaScript you can provide a function for the `isActive` property, and a React element for the `icon`. In the `block.json` file both only support strings_
456456

457+
Starting with version 6.7, it is possible to specify a PHP file in `block.json` that generates the list of block variations on the server side:
458+
459+
```json
460+
{ "variations": "file:./variations.php" }
461+
```
462+
463+
That PHP file is expected to `return` an array that contains the block variations. Strings found in the variations returned from the PHP file will not be localized automatically; instead, use the `__()` function as usual.
464+
465+
For example:
466+
467+
```php
468+
<?php
469+
// Generate variations for a Social Icon kind of block.
470+
471+
return array(
472+
array(
473+
'isDefault' => true,
474+
'name' => 'wordpress',
475+
'title' => 'WordPress',
476+
'icon' => 'wordpress',
477+
'attributes' => array(
478+
'service' => 'wordpress',
479+
),
480+
'isActive' => array( 'service' )
481+
),
482+
array(
483+
'name' => 'mail',
484+
'title' => __( 'Mail' ),
485+
'keywords' => array(
486+
__( 'email' ),
487+
__( 'e-mail' )
488+
),
489+
'icon' => 'mail',
490+
'attributes' => array(
491+
'service' => 'mail',
492+
),
493+
'isActive' => array( 'mail' )
494+
),
495+
);
496+
497+
```
498+
457499
See [the variations documentation](/docs/reference-guides/block-api/block-variations.md) for more details.
458500

459501
### Block Hooks

docs/reference-guides/core-blocks.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Embed a simple audio player. ([Source](https://github.com/WordPress/gutenberg/tr
2424
- **Name:** core/audio
2525
- **Category:** media
2626
- **Supports:** align, anchor, interactivity (clientNavigation), spacing (margin, padding)
27-
- **Attributes:** autoplay, caption, id, loop, preload, src
27+
- **Attributes:** autoplay, blob, caption, id, loop, preload, src
2828

2929
## Avatar
3030

@@ -273,7 +273,7 @@ Add a link to a downloadable file. ([Source](https://github.com/WordPress/gutenb
273273
- **Name:** core/file
274274
- **Category:** media
275275
- **Supports:** align, anchor, color (background, gradients, link, ~~text~~), interactivity, spacing (margin, padding)
276-
- **Attributes:** displayPreview, downloadButtonText, fileId, fileName, href, id, previewHeight, showDownloadButton, textLinkHref, textLinkTarget
276+
- **Attributes:** blob, displayPreview, downloadButtonText, fileId, fileName, href, id, previewHeight, showDownloadButton, textLinkHref, textLinkTarget
277277

278278
## Footnotes
279279

@@ -350,7 +350,7 @@ Gather blocks in a layout container. ([Source](https://github.com/WordPress/gute
350350

351351
- **Name:** core/group
352352
- **Category:** design
353-
- **Supports:** align (full, wide), anchor, ariaLabel, background (backgroundImage, backgroundSize), color (background, button, gradients, heading, link, text), dimensions (minHeight), interactivity (clientNavigation), layout (allowSizingOnChildren), position (sticky), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~
353+
- **Supports:** align (full, wide), anchor, ariaLabel, background (backgroundImage, backgroundSize), color (background, button, gradients, heading, link, text), dimensions (minHeight), interactivity (clientNavigation), layout (allowSizingOnChildren), position (sticky), shadow, spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~
354354
- **Attributes:** allowedBlocks, tagName, templateLock
355355

356356
## Heading
@@ -388,7 +388,7 @@ Insert an image to make a visual statement. ([Source](https://github.com/WordPre
388388
- **Name:** core/image
389389
- **Category:** media
390390
- **Supports:** align (center, full, left, right, wide), anchor, color (~~background~~, ~~text~~), filter (duotone), interactivity, shadow ()
391-
- **Attributes:** alt, aspectRatio, caption, height, href, id, lightbox, linkClass, linkDestination, linkTarget, rel, scale, sizeSlug, title, url, width
391+
- **Attributes:** alt, aspectRatio, blob, caption, height, href, id, lightbox, linkClass, linkDestination, linkTarget, rel, scale, sizeSlug, title, url, width
392392

393393
## Latest Comments
394394

@@ -967,6 +967,6 @@ Embed a video from your media library or upload a new one. ([Source](https://git
967967
- **Name:** core/video
968968
- **Category:** media
969969
- **Supports:** align, anchor, interactivity (clientNavigation), spacing (margin, padding)
970-
- **Attributes:** autoplay, caption, controls, id, loop, muted, playsInline, poster, preload, src, tracks
970+
- **Attributes:** autoplay, blob, caption, controls, id, loop, muted, playsInline, poster, preload, src, tracks
971971

972972
<!-- END TOKEN Autogenerated - DO NOT EDIT -->

docs/reference-guides/interactivity-api/iapi-about.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ store( 'wpmovies', {
130130
>
131131
<button
132132
data-wp-on--click="actions.toggle"
133-
data-wp-bind--aria-expanded="context.ispen"
133+
data-wp-bind--aria-expanded="context.isOpen"
134134
aria-controls="p-1"
135135
>
136136
Toggle

lib/block-supports/block-style-variations.php

+40
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,42 @@ function gutenberg_get_block_style_variation_name_from_class( $class_string ) {
3838
return $matches[1] ?? null;
3939
}
4040

41+
/**
42+
* Recursively resolves any `ref` values within a block style variation's data.
43+
*
44+
* @since 6.6.0
45+
*
46+
* @param array $variation_data Reference to the variation data being processed.
47+
* @param array $theme_json Theme.json data to retrieve referenced values from.
48+
*/
49+
function gutenberg_resolve_block_style_variation_ref_values( &$variation_data, $theme_json ) {
50+
foreach ( $variation_data as $key => &$value ) {
51+
// Only need to potentially process arrays.
52+
if ( is_array( $value ) ) {
53+
// If ref value is set, attempt to find its matching value and update it.
54+
if ( array_key_exists( 'ref', $value ) ) {
55+
// Clean up any invalid ref value.
56+
if ( empty( $value['ref'] ) || ! is_string( $value['ref'] ) ) {
57+
unset( $variation_data[ $key ] );
58+
}
59+
60+
$value_path = explode( '.', $value['ref'] ?? '' );
61+
$ref_value = _wp_array_get( $theme_json, $value_path );
62+
63+
// Only update the current value if the referenced path matched a value.
64+
if ( null === $ref_value ) {
65+
unset( $variation_data[ $key ] );
66+
} else {
67+
$value = $ref_value;
68+
}
69+
} else {
70+
// Recursively look for ref instances.
71+
gutenberg_resolve_block_style_variation_ref_values( $value, $theme_json );
72+
}
73+
}
74+
}
75+
}
76+
4177
/**
4278
* Render the block style variation's styles.
4379
*
@@ -79,6 +115,10 @@ function gutenberg_render_block_style_variation_support_styles( $parsed_block )
79115
return $parsed_block;
80116
}
81117

118+
// Recursively resolve any ref values with the appropriate value within the
119+
// theme_json data.
120+
gutenberg_resolve_block_style_variation_ref_values( $variation_data, $theme_json );
121+
82122
$variation_instance = gutenberg_create_block_style_variation_instance_name( $parsed_block, $variation );
83123
$class_name = "is-style-$variation_instance";
84124
$updated_class_name = $parsed_block['attrs']['className'] . " $class_name";

lib/block-supports/layout.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support
501501
if ( ! empty( $layout['rowCount'] ) ) {
502502
$layout_styles[] = array(
503503
'selector' => $selector,
504-
'declarations' => array( 'grid-template-rows' => 'repeat(' . $layout['rowCount'] . ', minmax(8px, auto))' ),
504+
'declarations' => array( 'grid-template-rows' => 'repeat(' . $layout['rowCount'] . ', minmax(1rem, auto))' ),
505505
);
506506
}
507507
} elseif ( ! empty( $layout['columnCount'] ) ) {
@@ -512,7 +512,7 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support
512512
if ( ! empty( $layout['rowCount'] ) ) {
513513
$layout_styles[] = array(
514514
'selector' => $selector,
515-
'declarations' => array( 'grid-template-rows' => 'repeat(' . $layout['rowCount'] . ', minmax(8px, auto))' ),
515+
'declarations' => array( 'grid-template-rows' => 'repeat(' . $layout['rowCount'] . ', minmax(1rem, auto))' ),
516516
);
517517
}
518518
} else {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -3000,10 +3000,10 @@ public function get_root_layout_rules( $selector, $block_metadata ) {
30003000
$css .= '.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }';
30013001
// Alignfull children of the container with left and right padding have negative margins so they can still be full width.
30023002
$css .= '.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }';
3003-
// Nested children of the container with left and right padding that are not wide or full aligned do not get padding, unless they are direct children of an alignfull flow container.
3004-
$css .= '.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }';
3003+
// Nested children of the container with left and right padding that are not full aligned do not get padding, unless they are direct children of an alignfull flow container.
3004+
$css .= '.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; }';
30053005
// Alignfull direct children of the containers that are targeted by the rule above do not need negative margins.
3006-
$css .= '.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0; }';
3006+
$css .= '.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0; }';
30073007
}
30083008

30093009
$css .= '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }';

lib/compat/wordpress-6.7/blocks.php

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Temporary compatibility shims for block APIs present in Gutenberg.
4+
*
5+
* @package gutenberg
6+
*/
7+
8+
/**
9+
* Allow passing a PHP file as `variations` field for Core versions < 6.7
10+
*
11+
* @param array $settings Array of determined settings for registering a block type.
12+
* @param array $metadata Metadata provided for registering a block type.
13+
* @return array The block type settings
14+
*/
15+
function gutenberg_filter_block_type_metadata_settings_allow_variations_php_file( $settings, $metadata ) {
16+
// If `variations` is a string, it's the name of a PHP file that
17+
// generates the variations.
18+
if ( ! empty( $settings['variations'] ) && is_string( $settings['variations'] ) ) {
19+
$variations_path = wp_normalize_path(
20+
realpath(
21+
dirname( $metadata['file'] ) . '/' .
22+
remove_block_asset_path_prefix( $settings['variations'] )
23+
)
24+
);
25+
if ( $variations_path ) {
26+
/**
27+
* Generates the list of block variations.
28+
*
29+
* @since 6.7.0
30+
*
31+
* @return string Returns the list of block variations.
32+
*/
33+
$settings['variation_callback'] = static function () use ( $variations_path ) {
34+
$variations = require $variations_path;
35+
return $variations;
36+
};
37+
// The block instance's `variations` field is only allowed to be an array
38+
// (of known block variations). We unset it so that the block instance will
39+
// provide a getter that returns the result of the `variation_callback` instead.
40+
unset( $settings['variations'] );
41+
}
42+
}
43+
return $settings;
44+
}
45+
add_filter( 'block_type_metadata_settings', 'gutenberg_filter_block_type_metadata_settings_allow_variations_php_file', 10, 2 );

lib/load.php

+3
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ function gutenberg_is_experiment_enabled( $name ) {
152152
require __DIR__ . '/compat/wordpress-6.6/option.php';
153153
require __DIR__ . '/compat/wordpress-6.6/post.php';
154154

155+
// WordPress 6.7 compat.
156+
require __DIR__ . '/compat/wordpress-6.7/blocks.php';
157+
155158
// Experimental features.
156159
require __DIR__ . '/experimental/block-editor-settings-mobile.php';
157160
require __DIR__ . '/experimental/blocks.php';

0 commit comments

Comments
 (0)