diff --git a/docs/designers-developers/developers/themes/theme-json.md b/docs/designers-developers/developers/themes/theme-json.md index 1deafc2e0d0f84..58a4ca6cb27578 100644 --- a/docs/designers-developers/developers/themes/theme-json.md +++ b/docs/designers-developers/developers/themes/theme-json.md @@ -87,7 +87,7 @@ The settings section has the following structure and default values: "palette": [ ... ], /* color presets, as in add_theme_support('editor-color-palette', ... ) */ }, "spacing": { - "customPadding": false, /* true to opt-in, as in add_theme_support('experimental-custom-spacing') */ + "customPadding": false, /* true to opt-in, as in add_theme_support('custom-spacing') */ "units": [ "px", "em", "rem", "vh", "vw" ], /* filter values, as in add_theme_support('custom-units', ... ) */ }, "typography": { diff --git a/docs/designers-developers/developers/themes/theme-support.md b/docs/designers-developers/developers/themes/theme-support.md index bc0d8080503ab5..8331a41d2d935b 100644 --- a/docs/designers-developers/developers/themes/theme-support.md +++ b/docs/designers-developers/developers/themes/theme-support.md @@ -388,12 +388,12 @@ To make the content resize and keep its aspect ratio, the `
` element needs add_theme_support( 'responsive-embeds' ); ``` -## Experimental — Cover block padding +## Cover block padding -Using the Gutenberg plugin (version 8.3 or later), Cover blocks can provide padding controls in the editor for users. This is off by default, and requires the theme to opt in by declaring support: +Some blocks can provide padding controls in the editor for users. This is off by default, and requires the theme to opt in by declaring support: ```php -add_theme_support('experimental-custom-spacing'); +add_theme_support('custom-spacing'); ``` ## Experimental — Link color control diff --git a/lib/global-styles.php b/lib/global-styles.php index e4ec344af7738e..c385b72f18bcac 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -289,7 +289,7 @@ function gutenberg_experimental_global_styles_get_theme_support_settings() { } $theme_settings['global']['settings']['typography']['customLineHeight'] = true; } - if ( get_theme_support( 'experimental-custom-spacing' ) ) { + if ( get_theme_support( 'custom-spacing' ) ) { if ( ! isset( $theme_settings['global']['settings']['spacing'] ) ) { $theme_settings['global']['settings']['spacing'] = array(); } diff --git a/packages/block-editor/src/hooks/padding.js b/packages/block-editor/src/hooks/padding.js index 7632943e5d075d..a83d6aff730f00 100644 --- a/packages/block-editor/src/hooks/padding.js +++ b/packages/block-editor/src/hooks/padding.js @@ -3,7 +3,7 @@ */ import { __ } from '@wordpress/i18n'; import { Platform } from '@wordpress/element'; -import { hasBlockSupport } from '@wordpress/blocks'; +import { getBlockSupport } from '@wordpress/blocks'; import { __experimentalBoxControl as BoxControl } from '@wordpress/components'; /** @@ -12,7 +12,12 @@ import { __experimentalBoxControl as BoxControl } from '@wordpress/components'; import { cleanEmptyObject } from './utils'; import { useCustomUnits } from '../components/unit-control'; -export const PADDING_SUPPORT_KEY = '__experimentalPadding'; +export const SPACING_SUPPORT_KEY = 'spacing'; + +const hasPaddingSupport = ( blockName ) => { + const spacingSupport = getBlockSupport( blockName, SPACING_SUPPORT_KEY ); + return spacingSupport && spacingSupport.padding !== false; +}; /** * Inspector control panel containing the line height related configuration @@ -30,7 +35,7 @@ export function PaddingEdit( props ) { const units = useCustomUnits(); - if ( ! hasBlockSupport( blockName, PADDING_SUPPORT_KEY ) ) { + if ( ! hasPaddingSupport( blockName ) ) { return null; } diff --git a/packages/block-editor/src/hooks/style.js b/packages/block-editor/src/hooks/style.js index fe2f66a9c141c7..adec7bb0d02df0 100644 --- a/packages/block-editor/src/hooks/style.js +++ b/packages/block-editor/src/hooks/style.js @@ -18,13 +18,13 @@ import { createHigherOrderComponent } from '@wordpress/compose'; */ import { COLOR_SUPPORT_KEY, ColorEdit } from './color'; import { TypographyPanel, TYPOGRAPHY_SUPPORT_KEYS } from './typography'; -import { PADDING_SUPPORT_KEY, PaddingEdit } from './padding'; +import { SPACING_SUPPORT_KEY, PaddingEdit } from './padding'; import SpacingPanelControl from '../components/spacing-panel-control'; const styleSupportKeys = [ ...TYPOGRAPHY_SUPPORT_KEYS, COLOR_SUPPORT_KEY, - PADDING_SUPPORT_KEY, + SPACING_SUPPORT_KEY, ]; const hasStyleSupport = ( blockType ) => @@ -148,16 +148,16 @@ export const withBlockControls = createHigherOrderComponent( ( BlockEdit ) => ( props ) => { const { name: blockName } = props; - const hasPaddingSupport = hasBlockSupport( + const hasSpacingSupport = hasBlockSupport( blockName, - PADDING_SUPPORT_KEY + SPACING_SUPPORT_KEY ); return [