save
function for the Preformatted core block looks like this:
+The following save
function for the Preformatted core block looks like this:
```js
import { RichText, useBlockProps } from '@wordpress/block-editor';
@@ -160,7 +160,7 @@ On the front end, the `render_callback` is used to dynamically render the markup
### HTML representation of dynamic blocks in the database (`save`)
-For dynamic blocks, the `save` callback function can return just `null`, which tells the editor to save only the block delimiter comment (along with any existing [block attributes](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/)) to the database. These attributes are then passed into the server-side rendering callback, which will determine how to display the block on the front end of your site.
+For dynamic blocks, the `save` callback function can return just `null`, which tells the editor to save only the block delimiter comment (along with any existing [block attributes](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/)) to the database. These attributes are then passed into the server-side rendering callback, which will determine how to display the block on the front end of your site.
When `save` is `null`, the Block Editor will skip the [block markup validation process](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#validation), avoiding issues with frequently changing markup.
@@ -176,4 +176,4 @@ If you are using [InnerBlocks](https://developer.wordpress.org/block-editor/how-
## Additional resources
- [Static vs. dynamic blocks: What’s the difference?](https://developer.wordpress.org/news/2023/02/27/static-vs-dynamic-blocks-whats-the-difference/) | Developer Blog
-- [Block deprecation – a tutorial](https://developer.wordpress.org/news/2023/03/10/block-deprecation-a-tutorial/) | Developer Blog
\ No newline at end of file
+- [Block deprecation – a tutorial](https://developer.wordpress.org/news/2023/03/10/block-deprecation-a-tutorial/) | Developer Blog
diff --git a/docs/how-to-guides/curating-the-editor-experience/disable-editor-functionality.md b/docs/how-to-guides/curating-the-editor-experience/disable-editor-functionality.md
index 23803888f9522..2491d12ce9482 100644
--- a/docs/how-to-guides/curating-the-editor-experience/disable-editor-functionality.md
+++ b/docs/how-to-guides/curating-the-editor-experience/disable-editor-functionality.md
@@ -1,14 +1,14 @@
# Disable Editor functionality
-This page is dedicated to the many ways you can disable specific functionality in the Post Editor and Site Editor that are not covered in other areas of the curation documentation.
+This page is dedicated to the many ways you can disable specific functionality in the Post Editor and Site Editor that are not covered in other areas of the curation documentation.
## Restrict block options
-There might be times when you don’t want access to a block at all to be available for users. To control what’s available in the inserter, you can take two approaches: [an allow list](/docs/reference-guides/filters/block-filters.md#using-an-allow-list) that disables all blocks except those on the list or a [deny list that unregisters specific blocks](/docs/reference-guides/filters/block-filters.md#using-a-deny-list).
+There might be times when you don’t want access to a block at all to be available for users. To control what’s available in the inserter, you can take two approaches: [an allow list](/docs/reference-guides/filters/block-filters.md#using-an-allow-list) that disables all blocks except those on the list or a [deny list that unregisters specific blocks](/docs/reference-guides/filters/block-filters.md#using-a-deny-list).
## Disable the Pattern Directory
-To fully remove patterns bundled with WordPress core from being accessed in the Inserter, the following can be added to your `functions.php` file:
+To fully remove patterns bundled with WordPress core from being accessed in the Inserter, the following can be added to your `functions.php` file:
```php
function example_theme_support() {
@@ -21,7 +21,7 @@ add_action( 'after_setup_theme', 'example_theme_support' );
Some Core blocks are actually [block variations](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/). A great example is the Row and Stack blocks, which are actually variations of the Group block. If you want to disable these "blocks", you actually need to disable the respective variations.
-Block variations are registered using JavaScript and need to be disabled with JavaScript. The code below will disable the Row variation.
+Block variations are registered using JavaScript and need to be disabled with JavaScript. The code below will disable the Row variation.
```js
wp.domReady( () => {
@@ -48,7 +48,7 @@ add_action( 'enqueue_block_editor_assets', 'example_disable_variations_script' )
There are a few Core blocks that include their own [block styles](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/). An example is the Image block, which includes a block style for rounded images called "Rounded". You many not want your users to round images, or you might prefer to use the border-radius control instead of the block style. Either way, it's easy to disable any unwanted block styles.
-Unlike block variations, you can register styles in either JavaScript or PHP. If a style was registered in JavaScript, it must be disabled with JavaScript. If registered using PHP, the style can be disabled with either. All Core block styles are registed in JavaScript.
+Unlike block variations, you can register styles in either JavaScript or PHP. If a style was registered in JavaScript, it must be disabled with JavaScript. If registered using PHP, the style can be disabled with either. All Core block styles are registered in JavaScript.
So, you would use the following code to disable the "Rounded" block style for the Image block.
@@ -58,7 +58,7 @@ wp.domReady( () => {
});
```
-This JavaScript should be enqueued much like the block variation example above. Refer to the [block styles](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/) documentation for how to register and unregister styles using PHP.
+This JavaScript should be enqueued much like the block variation example above. Refer to the [block styles](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/) documentation for how to register and unregister styles using PHP.
## Disable access to the Template Editor
@@ -71,7 +71,7 @@ function example_theme_support() {
add_action( 'after_setup_theme', 'example_theme_support' );
```
-This prevents both the ability to create new block templates or edit them from within the Post Editor.
+This prevents both the ability to create new block templates or edit them from within the Post Editor.
## Disable access to the Code Editor
@@ -86,4 +86,4 @@ function example_restrict_code_editor_access( $settings, $context ) {
add_filter( 'block_editor_settings_all', 'example_restrict_code_editor_access', 10, 2 );
```
-This code prevents all users from accessing the Code Editor. You could also add [capability](https://wordpress.org/documentation/article/roles-and-capabilities/) checks to disable access for specific users.
\ No newline at end of file
+This code prevents all users from accessing the Code Editor. You could also add [capability](https://wordpress.org/documentation/article/roles-and-capabilities/) checks to disable access for specific users.
diff --git a/docs/reference-guides/filters/block-filters.md b/docs/reference-guides/filters/block-filters.md
index ce7eb4d0b2d12..7fa2024976040 100644
--- a/docs/reference-guides/filters/block-filters.md
+++ b/docs/reference-guides/filters/block-filters.md
@@ -283,6 +283,24 @@ wp.hooks.addFilter(
```
+### `editor.postContentBlockTypes`
+
+Used to modify the list of blocks that should be enabled even when used inside a locked template. Any block that saves data to a post should be added here. Examples of this are the post featured image block. Which often gets used in templates but should still allow selecting the image even when the template is locked.
+
+_Example:_
+
+```js
+const addExampleBlockToPostContentBlockTypes = ( blockTypes ) => {
+ return [ ...blockTypes, 'namespace/example' ];
+};
+
+wp.hooks.addFilter(
+ 'editor.postContentBlockTypes',
+ 'my-plugin/post-content-block-types',
+ addExampleBlockToPostContentBlockTypes
+);
+```
+
## Removing Blocks
### Using a deny list
diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php
index 789e6b2a53183..bf55d08c1d4b3 100644
--- a/lib/class-wp-theme-json-gutenberg.php
+++ b/lib/class-wp-theme-json-gutenberg.php
@@ -286,26 +286,31 @@ class WP_Theme_JSON_Gutenberg {
*
* Indirect properties are not output directly by `compute_style_properties`,
* but are used elsewhere in the processing of global styles. The indirect
- * property is used to validate whether or not a style value is allowed.
+ * property is used to validate whether a style value is allowed.
*
* @since 6.2.0
+ * @since 6.6.0 Added background-image properties.
*
* @var array
*/
const INDIRECT_PROPERTIES_METADATA = array(
- 'gap' => array(
+ 'gap' => array(
array( 'spacing', 'blockGap' ),
),
- 'column-gap' => array(
+ 'column-gap' => array(
array( 'spacing', 'blockGap', 'left' ),
),
- 'row-gap' => array(
+ 'row-gap' => array(
array( 'spacing', 'blockGap', 'top' ),
),
- 'max-width' => array(
+ 'max-width' => array(
array( 'layout', 'contentSize' ),
array( 'layout', 'wideSize' ),
),
+ 'background-image' => array(
+ array( 'background', 'backgroundImage', 'url' ),
+ array( 'background', 'backgroundImage', 'source' ),
+ ),
);
/**
@@ -1359,7 +1364,7 @@ public function get_block_custom_css_nodes() {
*
* @since 6.6.0
*
- * @param array $css The block css node.
+ * @param array $css The block css node.
* @param string $selector The block selector.
*
* @return string The global styles custom CSS for the block.
@@ -2680,7 +2685,7 @@ static function ( $pseudo_selector ) use ( $selector ) {
}
// 2. Generate and append the rules that use the general selector.
- $block_rules .= static::to_ruleset( $selector, $declarations );
+ $block_rules .= static::to_ruleset( ":where($selector)", $declarations );
// 3. Generate and append the rules that use the duotone selector.
if ( isset( $block_metadata['duotone'] ) && ! empty( $declarations_duotone ) ) {
@@ -2697,7 +2702,7 @@ static function ( $pseudo_selector ) use ( $selector ) {
// 5. Generate and append the feature level rulesets.
foreach ( $feature_declarations as $feature_selector => $individual_feature_declarations ) {
- $block_rules .= static::to_ruleset( $feature_selector, $individual_feature_declarations );
+ $block_rules .= static::to_ruleset( ":where($feature_selector)", $individual_feature_declarations );
}
// 6. Generate and append the style variation rulesets.
diff --git a/package-lock.json b/package-lock.json
index 5a23420f5d888..b0bb35d0e4071 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "gutenberg",
- "version": "18.0.0-rc.1",
+ "version": "18.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "gutenberg",
- "version": "18.0.0-rc.1",
+ "version": "18.0.0",
"hasInstallScript": true,
"license": "GPL-2.0-or-later",
"dependencies": {
@@ -55757,8 +55757,7 @@
"is-plain-object": "^5.0.0",
"memize": "^2.1.0",
"react-autosize-textarea": "^7.1.0",
- "rememo": "^4.0.2",
- "remove-accents": "^0.5.0"
+ "rememo": "^4.0.2"
},
"engines": {
"node": ">=12"
@@ -56646,7 +56645,7 @@
},
"packages/react-native-aztec": {
"name": "@wordpress/react-native-aztec",
- "version": "1.115.0",
+ "version": "1.116.0",
"license": "GPL-2.0-or-later",
"dependencies": {
"@wordpress/element": "file:../element",
@@ -56659,7 +56658,7 @@
},
"packages/react-native-bridge": {
"name": "@wordpress/react-native-bridge",
- "version": "1.115.0",
+ "version": "1.116.0",
"license": "GPL-2.0-or-later",
"dependencies": {
"@wordpress/react-native-aztec": "file:../react-native-aztec"
@@ -56670,7 +56669,7 @@
},
"packages/react-native-editor": {
"name": "@wordpress/react-native-editor",
- "version": "1.115.0",
+ "version": "1.116.0",
"hasInstallScript": true,
"license": "GPL-2.0-or-later",
"dependencies": {
@@ -71531,8 +71530,7 @@
"is-plain-object": "^5.0.0",
"memize": "^2.1.0",
"react-autosize-textarea": "^7.1.0",
- "rememo": "^4.0.2",
- "remove-accents": "^0.5.0"
+ "rememo": "^4.0.2"
}
},
"@wordpress/edit-widgets": {
diff --git a/package.json b/package.json
index 5c63beee49d2a..fcb742cb379fd 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gutenberg",
- "version": "18.0.0-rc.1",
+ "version": "18.0.0",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
diff --git a/packages/block-editor/src/components/block-list/block.js b/packages/block-editor/src/components/block-list/block.js
index 3bfe8eb5cdef2..237fecd05b6e0 100644
--- a/packages/block-editor/src/components/block-list/block.js
+++ b/packages/block-editor/src/components/block-list/block.js
@@ -225,6 +225,11 @@ function BlockListBlock( {
// We set a new context with the adjusted and filtered wrapperProps (through
// `editor.BlockListBlock`), which the `BlockListBlockProvider` did not have
// access to.
+ // Note that the context value doesn't have to be memoized in this case
+ // because when it changes, this component will be re-rendered anyway, and
+ // none of the consumers (BlockListBlock and useBlockProps) are memoized or
+ // "pure". This is different from the public BlockEditContext, where
+ // consumers might be memoized or "pure".
return (
Dummy text
- +