Skip to content

Commit 60843b4

Browse files
spacedmonkeyoandregal
authored andcommitted
Remove usage of get_default_block_editor_settings (WordPress#46112)
* Remove usage of get_default_block_editor_settings`. * Remove to it's own function. * Fix lints. * Move to 6.2 class. * WP_Theme_JSON -> WP_Theme_JSON_Gutenberg. * Update lib/compat/wordpress-6.2/class-wp-theme-json-resolver-6-2.php Co-authored-by: André <[email protected]> * Move functionality around again. * Fix merge conflict * Fix more issues. * More moving. * Revert changes. * More reverts. Co-authored-by: André <[email protected]>
1 parent 685407a commit 60843b4

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

lib/compat/wordpress-6.1/get-global-styles-and-settings.php

+35
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,38 @@ function ( $item ) {
5454
}
5555
}
5656
}
57+
58+
/**
59+
* Repeated logic from `get_default_block_editor_settings` function. When implemented into core,
60+
* remove logic from `get_default_block_editor_settings` and simple call this function instead.
61+
*
62+
* @return array
63+
*/
64+
function gutenberg_get_legacy_theme_supports_for_theme_json() {
65+
$theme_settings = array(
66+
'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),
67+
'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
68+
'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ),
69+
'enableCustomLineHeight' => get_theme_support( 'custom-line-height' ),
70+
'enableCustomSpacing' => get_theme_support( 'custom-spacing' ),
71+
'enableCustomUnits' => get_theme_support( 'custom-units' ),
72+
);
73+
74+
// Theme settings.
75+
$color_palette = current( (array) get_theme_support( 'editor-color-palette' ) );
76+
if ( false !== $color_palette ) {
77+
$theme_settings['colors'] = $color_palette;
78+
}
79+
80+
$font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) );
81+
if ( false !== $font_sizes ) {
82+
$theme_settings['fontSizes'] = $font_sizes;
83+
}
84+
85+
$gradient_presets = current( (array) get_theme_support( 'editor-gradient-presets' ) );
86+
if ( false !== $gradient_presets ) {
87+
$theme_settings['gradients'] = $gradient_presets;
88+
}
89+
90+
return $theme_settings;
91+
}

lib/experimental/class-wp-theme-json-resolver-gutenberg.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static function get_theme_data( $deprecated = array(), $settings = array(
7373
* So we take theme supports, transform it to theme.json shape
7474
* and merge the static::$theme upon that.
7575
*/
76-
$theme_support_data = WP_Theme_JSON_Gutenberg::get_from_editor_settings( get_default_block_editor_settings() );
76+
$theme_support_data = WP_Theme_JSON_Gutenberg::get_from_editor_settings( gutenberg_get_legacy_theme_supports_for_theme_json() );
7777
if ( ! wp_theme_has_theme_json() ) {
7878
if ( ! isset( $theme_support_data['settings']['color'] ) ) {
7979
$theme_support_data['settings']['color'] = array();

0 commit comments

Comments
 (0)