Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ add_theme_support( 'responsive-embeds' );

## Spacing control

Using the Gutenberg plugin (version 8.3 or later), 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:
Some blocks can have padding controls. This is off by default, and requires the theme to opt in by declaring support:

```php
add_theme_support('custom-spacing');
Expand Down
1 change: 1 addition & 0 deletions lib/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function gutenberg_get_common_block_editor_settings() {
'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ),
'enableCustomLineHeight' => get_theme_support( 'custom-line-height' ),
'enableCustomUnits' => get_theme_support( 'custom-units' ),
'enableCustomSpacing' => get_theme_support( 'custom-spacing' ),
'imageSizes' => $available_image_sizes,
'isRTL' => is_rtl(),
'maxUploadFileSize' => $max_upload_size,
Expand Down
14 changes: 12 additions & 2 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,23 @@ function gutenberg_experimental_global_styles_get_theme_support_settings( $setti
$theme_settings['settings'][ $all_blocks ]['typography']['fontSizes'] = $font_sizes;
}

// Things that didn't land in core yet, so didn't have a setting assigned.
if ( current( (array) get_theme_support( 'custom-spacing' ) ) ) {
// This allows to make the plugin work with WordPress 5.7 beta
// as well as lower versions. The second check can be removed
// as soon as the minimum WordPress version for the plugin
// is bumped to 5.7.
if ( isset( $settings['enableCustomSpacing'] ) ) {
if ( ! isset( $theme_settings['settings'][ $all_blocks ]['spacing'] ) ) {
$theme_settings['settings'][ $all_blocks ]['spacing'] = array();
}
$theme_settings['settings'][ $all_blocks ]['spacing']['customPadding'] = $settings['enableCustomSpacing'];
} else if ( current( (array) get_theme_support( 'custom-spacing' ) ) ) {
if ( ! isset( $theme_settings['settings'][ $all_blocks ]['spacing'] ) ) {
$theme_settings['settings'][ $all_blocks ]['spacing'] = array();
}
$theme_settings['settings'][ $all_blocks ]['spacing']['customPadding'] = true;
}

// Things that didn't land in core yet, so didn't have a setting assigned.
if ( current( (array) get_theme_support( 'experimental-link-color' ) ) ) {
if ( ! isset( $theme_settings['settings'][ $all_blocks ]['color'] ) ) {
$theme_settings['settings'][ $all_blocks ]['color'] = array();
Expand Down Expand Up @@ -197,6 +206,7 @@ function gutenberg_experimental_global_styles_settings( $settings ) {
unset( $settings['disableCustomGradients'] );
unset( $settings['enableCustomLineHeight'] );
unset( $settings['enableCustomUnits'] );
unset( $settings['enableCustomSpacing'] );
unset( $settings['fontSizes'] );
unset( $settings['gradients'] );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const deprecatedFlags = {

return settings.enableCustomUnits;
},
'spacing.customPadding': ( settings ) => settings.enableCustomSpacing,
};

function blockAttributesMatch( blockAttributes, attributes ) {
Expand Down