-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove usage of get_default_block_editor_settings #46112
Changes from 1 commit
9e82a0b
b0a9764
2e646a7
999b258
4d1a053
0e7894a
725db89
0f3c45b
c978b88
90cc1ce
f595fba
fcc46b2
0a2fcfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,14 +65,40 @@ public static function get_theme_data( $deprecated = array(), $settings = array( | |
if ( ! $settings['with_supports'] ) { | ||
return static::$theme; | ||
} | ||
|
||
$editor_settings = array( | ||
'disableCustomColors' => get_theme_support( 'disable-custom-colors' ), | ||
'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ), | ||
'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ), | ||
'disableLayoutStyles' => get_theme_support( 'disable-layout-styles' ), | ||
'enableCustomLineHeight' => get_theme_support( 'custom-line-height' ), | ||
'enableCustomSpacing' => get_theme_support( 'custom-spacing' ), | ||
'enableCustomUnits' => get_theme_support( 'custom-units' ), | ||
); | ||
|
||
// Theme settings. | ||
$color_palette = current( (array) get_theme_support( 'editor-color-palette' ) ); | ||
if ( false !== $color_palette ) { | ||
$editor_settings['colors'] = $color_palette; | ||
} | ||
|
||
$font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) ); | ||
if ( false !== $font_sizes ) { | ||
$editor_settings['fontSizes'] = $font_sizes; | ||
} | ||
|
||
$gradient_presets = current( (array) get_theme_support( 'editor-gradient-presets' ) ); | ||
if ( false !== $gradient_presets ) { | ||
$editor_settings['gradients'] = $gradient_presets; | ||
} | ||
|
||
/* | ||
* We want the presets and settings declared in theme.json | ||
* to override the ones declared via theme supports. | ||
* So we take theme supports, transform it to theme.json shape | ||
* and merge the static::$theme upon that. | ||
*/ | ||
$theme_support_data = WP_Theme_JSON_Gutenberg::get_from_editor_settings( get_default_block_editor_settings() ); | ||
$theme_support_data = WP_Theme_JSON_Gutenberg::get_from_editor_settings( $editor_settings ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I would suggest is the following:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically so that we can do something like: $theme_support_data = WP_Theme_JSON_Gutenberg::get_from_editor_settings(
get_default_block_editor_settings(
array(
'disableCustomColors',
'disableCustomFontSizes',
'disableCustomGradients',
'disableLayoutStyles',
'enableCustomLineHeight',
'enableCustomSpacing',
'enableCustomUnits',
'colors',
'fontSizes',
'gradients',
)
)
); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Broken it up into it's own function with a comment. b0a9764 |
||
if ( ! wp_theme_has_theme_json() ) { | ||
if ( ! isset( $theme_support_data['settings']['color'] ) ) { | ||
$theme_support_data['settings']['color'] = array(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the new code here is now a bit of a duplicate code from what is already in
get_default_block_editor_settings()
. I think we can solve the problem in a more efficient way by enhancing that function.