diff --git a/docs/reference-guides/theme-json-reference/theme-json-living.md b/docs/reference-guides/theme-json-reference/theme-json-living.md index da08b4fe9eac12..9f9e4f68aedec4 100644 --- a/docs/reference-guides/theme-json-reference/theme-json-living.md +++ b/docs/reference-guides/theme-json-reference/theme-json-living.md @@ -115,6 +115,7 @@ Settings related to layout. | --- | --- | --- |--- | | contentSize | string | | | | wideSize | string | | | +| allowEditing | boolean | true | | --- diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index dd8bf832174e67..0995896532a7a6 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -346,6 +346,7 @@ class WP_Theme_JSON_Gutenberg { * @since 6.2.0 Added `dimensions.minHeight`, 'shadow.presets', 'shadow.defaultPresets', * `position.fixed` and `position.sticky`. * @since 6.3.0 Removed `layout.definitions`. Added `typography.writingMode`. + * @since 6.4.0 Added `layout.allowEditing`. * @var array */ const VALID_SETTINGS = array( @@ -379,8 +380,9 @@ class WP_Theme_JSON_Gutenberg { 'minHeight' => null, ), 'layout' => array( - 'contentSize' => null, - 'wideSize' => null, + 'contentSize' => null, + 'wideSize' => null, + 'allowEditing' => null, ), 'position' => array( 'fixed' => null, diff --git a/packages/block-editor/src/hooks/layout.js b/packages/block-editor/src/hooks/layout.js index b873d382091e2b..6238225cc1d36b 100644 --- a/packages/block-editor/src/hooks/layout.js +++ b/packages/block-editor/src/hooks/layout.js @@ -31,6 +31,7 @@ import { getLayoutType, getLayoutTypes } from '../layouts'; import { useBlockEditingMode } from '../components/block-editing-mode'; import { LAYOUT_DEFINITIONS } from '../layouts/definitions'; import { kebabCase } from '../utils/object'; +import { useBlockSettings } from './utils'; const layoutBlockSupportKey = 'layout'; @@ -136,6 +137,11 @@ export function useLayoutStyles( blockAttributes = {}, blockName, selector ) { } function LayoutPanel( { setAttributes, attributes, name: blockName } ) { + const settings = useBlockSettings( blockName ); + const { + layout: { allowEditing: allowEditingSetting }, + } = settings; + const { layout } = attributes; const defaultThemeLayout = useSetting( 'layout' ); const { themeSupportsLayout } = useSelect( ( select ) => { @@ -153,7 +159,7 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) { ); const { allowSwitching, - allowEditing = true, + allowEditing = allowEditingSetting ?? true, allowInheriting = true, default: defaultBlockLayout, } = layoutBlockSupport; diff --git a/schemas/json/theme.json b/schemas/json/theme.json index 06e588d26f815a..8cdf2ba520f7ab 100644 --- a/schemas/json/theme.json +++ b/schemas/json/theme.json @@ -291,6 +291,11 @@ "wideSize": { "description": "Sets the max-width of wide (`.alignwide`) content. Also used as the maximum viewport when calculating fluid font sizes", "type": "string" + }, + "allowEditing": { + "description": "Disable the layout UI controls.", + "type": "boolean", + "default": true } }, "additionalProperties": false