Skip to content

Commit

Permalink
Merge branch 'trunk' into try/metaboxes-flex
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Sep 12, 2024
2 parents c31b7cf + e9d31c2 commit 64590b2
Show file tree
Hide file tree
Showing 660 changed files with 11,194 additions and 4,920 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ module.exports = {
'SelectControl',
'TextControl',
'ToggleGroupControl',
'UnitControl',
].map( ( componentName ) => ( {
// Falsy `__next40pxDefaultSize` without a non-default `size` prop.
selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__next40pxDefaultSize"][value.expression.value!=false])):not(:has(JSXAttribute[name.name="size"][value.value!="default"]))`,
Expand All @@ -345,7 +346,7 @@ module.exports = {
'FormFileUpload should have the `__next40pxDefaultSize` prop to opt-in to the new default size.',
},
// Temporary rules until all existing components have the `__next40pxDefaultSize` prop.
...[ 'Button', 'UnitControl' ].map( ( componentName ) => ( {
...[ 'Button' ].map( ( componentName ) => ( {
// Not strict. Allows pre-existing __next40pxDefaultSize={ false } usage until they are all manually updated.
selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__next40pxDefaultSize"])):not(:has(JSXAttribute[name.name="size"]))`,
message:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bundle-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ jobs:
- uses: preactjs/compressed-size-action@f780fd104362cfce9e118f9198df2ee37d12946c # v2.6.0
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
pattern: '{build/**/*.min.js,build/**/*.css}'
pattern: '{build/**/*.min.js,build/**/*.css,build-module/**/*.min.js}'
clean-script: 'distclean'
3 changes: 3 additions & 0 deletions backport-changelog/6.7/7258.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7258

* https://github.com/WordPress/gutenberg/pull/64570
File renamed without changes.
1 change: 1 addition & 0 deletions bin/build-plugin-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ zip -r gutenberg.zip \
packages/block-serialization-default-parser/*.php \
post-content.php \
$build_files \
build-module \
readme.txt \
changelog.txt \
README.md
Expand Down
369 changes: 369 additions & 0 deletions changelog.txt

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,12 @@
"markdown_source": "../packages/eslint-plugin/README.md",
"parent": "packages"
},
{
"title": "@wordpress/fields",
"slug": "packages-fields",
"markdown_source": "../packages/fields/README.md",
"parent": "packages"
},
{
"title": "@wordpress/format-library",
"slug": "packages-format-library",
Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/block-api/block-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export default function Edit( props ) {
return (
<div>
<TextControl
label={ __( 'Record ID:' ) }
label={ __( 'Record ID' ) }
value={ recordId }
onChange={ ( val ) =>
setAttributes( { recordId: Number( val ) } )
Expand Down
32 changes: 16 additions & 16 deletions docs/reference-guides/interactivity-api/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ It provides a **local** state available to a specific HTML node and its children
The `wp-context` directive accepts a stringified JSON as a value.

```php
//render.php
// render.php
<div data-wp-context='{ "post": { "id": <?php echo $post->ID; ?> } }' >
<button data-wp-on--click="actions.logId" >
Click Me!
Expand All @@ -110,13 +110,13 @@ store( "myPlugin", {
Different contexts can be defined at different levels, and deeper levels will merge their own context with any parent one:

```html
<div data-wp-context="{ foo: 'bar' }">
<div data-wp-context='{ "foo": "bar" }'>
<span data-wp-text="context.foo"><!-- Will output: "bar" --></span>

<div data-wp-context="{ bar: 'baz' }">
<div data-wp-context='{ "bar": "baz" }'>
<span data-wp-text="context.foo"><!-- Will output: "bar" --></span>

<div data-wp-context="{ foo: 'bob' }">
<div data-wp-context='{ "foo": "bob" }'>
<span data-wp-text="context.foo"><!-- Will output: "bob" --></span>
</div>

Expand Down Expand Up @@ -356,8 +356,7 @@ The callback passed as the reference receives [the event](https://developer.mozi

### `wp-on-async`

This directive is a more performant approach for `wp-on`. It immediately yields to main to avoid contributing to a long task, allowing other interactions that otherwise would be waiting on the main thread
to run sooner. Use this async version whenever there is no need for synchronous access to the `event` object, in particular the methods `event.preventDefault()`, `event.stopPropagation()`, and `event.stopImmediatePropagation()`.
This directive is a more performant approach for `wp-on`. It immediately yields to main to avoid contributing to a long task, allowing other interactions that otherwise would be waiting on the main thread to run sooner. Use this async version whenever there is no need for synchronous access to the `event` object, in particular the methods `event.preventDefault()`, `event.stopPropagation()`, and `event.stopImmediatePropagation()`.

### `wp-on-window`

Expand All @@ -369,8 +368,7 @@ This directive allows you to attach global window events like `resize`, `copy`,

[List of supported window events.](https://developer.mozilla.org/en-US/docs/Web/API/Window#events)

The syntax of this directive is `data-wp-on-window--[window-event]` (like `data-wp-on-window--resize`
or `data-wp-on-window--languagechange`).
The syntax of this directive is `data-wp-on-window--[window-event]` (like `data-wp-on-window--resize` or `data-wp-on-window--languagechange`).

```php
<div data-wp-on-window--resize="callbacks.logWidth"></div>
Expand Down Expand Up @@ -406,8 +404,7 @@ This directive allows you to attach global document events like `scroll`, `mouse

[List of supported document events.](https://developer.mozilla.org/en-US/docs/Web/API/Document#events)

The syntax of this directive is `data-wp-on-document--[document-event]` (like `data-wp-on-document--keydown`
or `data-wp-on-document--selectionchange`).
The syntax of this directive is `data-wp-on-document--[document-event]` (like `data-wp-on-document--keydown` or `data-wp-on-document--selectionchange`).

```php
<div data-wp-on-document--keydown="callbacks.logKeydown"></div>
Expand Down Expand Up @@ -520,6 +517,8 @@ Here's another example with several `wp-init` directives on the same DOM element
<summary><em>See store used with the directive above</em></summary>

```js
import { store, getElement } from '@wordpress/interactivity';

store( "myPlugin", {
callbacks: {
logTimeInit: () => console.log( `Init at ` + new Date() ),
Expand Down Expand Up @@ -882,10 +881,10 @@ const { state } = store( "myPlugin", {
GBP: 0.85,
},
get amountInUSD() {
return state.currencyExchange[ 'USD' ] * state.amount,
return state.currencyExchange[ 'USD' ] * state.amount;
},
get amountInGBP() {
return state.currencyExchange[ 'GBP' ] * state.amount,
return state.currencyExchange[ 'GBP' ] * state.amount;
},
},
} );
Expand Down Expand Up @@ -965,7 +964,7 @@ This approach enables some functionalities that make directives flexible and pow

*In the `view.js` file of each block* the developer can define both the state and the elements of the store referencing functions like actions, side effects or derived state.

The `store` method used to set the store in javascript can be imported from `@wordpress/interactivity`.
The `store` method used to set the store in JavaScript can be imported from `@wordpress/interactivity`.

```js
// store
Expand Down Expand Up @@ -1111,7 +1110,7 @@ store( "myPlugin", {
actions: {
log: () => {
const element = getElement();
// Logs "false"
// Logs attributes
console.log('element attributes => ', element.attributes)
},
},
Expand All @@ -1122,7 +1121,7 @@ The code will log:

```json
{
"data-wp-on--click": 'actions.increaseCounter',
"data-wp-on--click": 'actions.log',
"children": ['Log'],
"onclick": event => { evaluate(entry, event); }
}
Expand All @@ -1147,6 +1146,7 @@ store('mySliderPlugin', {
3_000
);
},
},
})
```

Expand Down Expand Up @@ -1245,7 +1245,7 @@ echo $processed_html;

will output:
```html
<div data-wp-text="create-block::state.greeting">Hello, World!</div>
<div data-wp-text="myPlugin::state.greeting">Hello, World!</div>
```

### wp_interactivity_data_wp_context
Expand Down
2 changes: 1 addition & 1 deletion gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Printing since 1440. This is the development plugin for the block editor, site editor, and other future WordPress core functionality.
* Requires at least: 6.5
* Requires PHP: 7.2
* Version: 19.1.0
* Version: 19.2.0
* Author: Gutenberg Team
* Text Domain: gutenberg
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ public static function decode( $context, $text ) {
*
* @since 6.6.0
*
* @global WP_Token_Map $html5_named_character_references
*
* @param string $context `attribute` for decoding attribute values, `data` otherwise.
* @param string $text Text document containing span of text to decode.
* @param int $at Optional. Byte offset into text where span begins, defaults to the beginning (0).
Expand Down
15 changes: 15 additions & 0 deletions lib/compat/wordpress-6.7/block-bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,18 @@ function gutenberg_add_server_block_bindings_sources_to_editor_settings( $editor
}

add_filter( 'block_editor_settings_all', 'gutenberg_add_server_block_bindings_sources_to_editor_settings', 10 );

/**
* Initialize `canUpdateBlockBindings` editor setting if it doesn't exist. By default, it is `true` only for admin users.
*
* @param array $settings The block editor settings from the `block_editor_settings_all` filter.
* @return array The editor settings including `canUpdateBlockBindings`.
*/
function gutenberg_add_can_update_block_bindings_editor_setting( $editor_settings ) {
if ( empty( $editor_settings['canUpdateBlockBindings'] ) ) {
$editor_settings['canUpdateBlockBindings'] = current_user_can( 'manage_options' );
}
return $editor_settings;
}

add_filter( 'block_editor_settings_all', 'gutenberg_add_can_update_block_bindings_editor_setting', 10 );
4 changes: 2 additions & 2 deletions lib/compat/wordpress-6.7/block-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* Register a template.
*
* @param string $template_name Template name in the form of `plugin_uri//template_name`.
* @param array|string $args Object type or array of object types with which the taxonomy should be associated.
* @param array|string $args {
* @type string $title Optional. Title of the template as it will be shown in the Site Editor
* and other UI elements.
Expand All @@ -33,7 +32,8 @@ function wp_register_block_template( $template_name, $args = array() ) {
* Unregister a template.
*
* @param string $template_name Template name in the form of `plugin_uri//template_name`.
* @return true|WP_Error True on success, WP_Error on failure or if the template doesn't exist.
* @return WP_Block_Template|WP_Error The unregistered template object on success, WP_Error object on failure or if
* the template doesn't exist.
*/
function wp_unregister_block_template( $template_name ) {
return WP_Block_Templates_Registry::get_instance()->unregister( $template_name );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class WP_Block_Templates_Registry {
*
* @param string $template_name Template name including namespace.
* @param array $args Optional. Array of template arguments.
* @return WP_Block_Template|WP_Error The registered template on success, or false on failure.
* @return WP_Block_Template|WP_Error The registered template on success, or WP_Error on failure.
*/
public function register( $template_name, $args = array() ) {

Expand Down Expand Up @@ -100,7 +100,7 @@ public function register( $template_name, $args = array() ) {
*
* @since 6.7.0
*
* @return WP_Block_Template[]|false Associative array of `$template_name => $template` pairs.
* @return WP_Block_Template[] Associative array of `$template_name => $template` pairs.
*/
public function get_all_registered() {
return $this->registered_templates;
Expand All @@ -112,7 +112,7 @@ public function get_all_registered() {
* @since 6.7.0
*
* @param string $template_name Template name including namespace.
* @return WP_Block_Template|null|false The registered template, or null if it is not registered.
* @return WP_Block_Template|null The registered template, or null if it is not registered.
*/
public function get_registered( $template_name ) {
if ( ! $this->is_registered( $template_name ) ) {
Expand Down Expand Up @@ -216,7 +216,7 @@ public function is_registered( $template_name ) {
* @since 6.7.0
*
* @param string $template_name Template name including namespace.
* @return WP_Block_Template|false The unregistered template on success, or false on failure.
* @return WP_Block_Template|WP_Error The unregistered template on success, or WP_Error on failure.
*/
public function unregister( $template_name ) {
if ( ! $this->is_registered( $template_name ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ public static function decode( $context, $text ): string {
*
* @since 6.6.0
*
* @global WP_Token_Map $html5_named_character_references
*
* @param string $context `attribute` for decoding attribute values, `data` otherwise.
* @param string $text Text document containing span of text to decode.
* @param int $at Optional. Byte offset into text where span begins, defaults to the beginning (0).
Expand Down
9 changes: 3 additions & 6 deletions lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,15 @@ function gutenberg_enable_experiments() {
if ( gutenberg_is_experiment_enabled( 'gutenberg-full-page-client-side-navigation' ) ) {
wp_add_inline_script( 'wp-block-library', 'window.__experimentalFullPageClientSideNavigation = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-zoomed-out-patterns-tab', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableZoomedOutPatternsTab = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-quick-edit-dataviews', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalQuickEditDataViews = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-block-bindings-ui', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalBlockBindingsUI = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-media-processing', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalMediaProcessing = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-zoom-out-experiment', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableZoomOutExperiment = true', 'before' );
}
}

add_action( 'admin_init', 'gutenberg_enable_experiments' );
Expand Down
29 changes: 8 additions & 21 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,6 @@ function gutenberg_initialize_experiments_settings() {
)
);

add_settings_field(
'gutenberg-zoomed-out-patterns-tab',
__( 'Enable zoomed out view when patterns are browsed in the inserter', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Enable zoomed out view when selecting a pattern category in the main inserter.', 'gutenberg' ),
'id' => 'gutenberg-zoomed-out-patterns-tab',
)
);

add_settings_field(
'gutenberg-new-posts-dashboard',
__( 'Redesigned posts dashboard', 'gutenberg' ),
Expand All @@ -176,29 +164,28 @@ function gutenberg_initialize_experiments_settings() {
);

add_settings_field(
'gutenberg-block-bindings-ui',
__( 'UI to create block bindings', 'gutenberg' ),
'gutenberg-media-processing',
__( 'Client-side media processing', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Add UI to create and update block bindings in block inspector controls.', 'gutenberg' ),
'id' => 'gutenberg-block-bindings-ui',
'label' => __( 'Enable client-side media processing.', 'gutenberg' ),
'id' => 'gutenberg-media-processing',
)
);

add_settings_field(
'gutenberg-media-processing',
__( 'Client-side media processing', 'gutenberg' ),
'gutenberg-zoom-out-experiment',
__( 'Zoom out experiments', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Enable client-side media processing.', 'gutenberg' ),
'id' => 'gutenberg-media-processing',
'label' => __( 'Enable zoom out experiments; shows zoom out in the device preview and other zoom out experiments.', 'gutenberg' ),
'id' => 'gutenberg-zoom-out-experiment',
)
);

register_setting(
'gutenberg-experiments',
'gutenberg-experiments'
Expand Down
4 changes: 2 additions & 2 deletions lib/interactivity-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ function gutenberg_reregister_interactivity_script_modules() {

wp_register_script_module(
'@wordpress/interactivity',
gutenberg_url( '/build/interactivity/' . ( SCRIPT_DEBUG ? 'debug.min.js' : 'index.min.js' ) ),
gutenberg_url( '/build-module/' . ( SCRIPT_DEBUG ? 'interactivity/debug.min.js' : 'interactivity/index.min.js' ) ),
array(),
$default_version
);

wp_register_script_module(
'@wordpress/interactivity-router',
gutenberg_url( '/build/interactivity/router.min.js' ),
gutenberg_url( '/build-module/interactivity-router/index.min.js' ),
array( '@wordpress/interactivity' ),
$default_version
);
Expand Down
Loading

0 comments on commit 64590b2

Please sign in to comment.