Skip to content

Commit

Permalink
Remove usage of get_default_block_editor_settings (WordPress#46112)
Browse files Browse the repository at this point in the history
* 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é <583546+oandregal@users.noreply.github.com>

* Move functionality around again.

* Fix merge conflict

* Fix more issues.

* More moving.

* Revert changes.

* More reverts.

Co-authored-by: André <583546+oandregal@users.noreply.github.com>
  • Loading branch information
2 people authored and mpkelly committed Dec 7, 2022
1 parent 685407a commit 60843b4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions lib/compat/wordpress-6.1/get-global-styles-and-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,38 @@ function ( $item ) {
}
}
}

/**
* Repeated logic from `get_default_block_editor_settings` function. When implemented into core,
* remove logic from `get_default_block_editor_settings` and simple call this function instead.
*
* @return array
*/
function gutenberg_get_legacy_theme_supports_for_theme_json() {
$theme_settings = array(
'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),
'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ),
'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 ) {
$theme_settings['colors'] = $color_palette;
}

$font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) );
if ( false !== $font_sizes ) {
$theme_settings['fontSizes'] = $font_sizes;
}

$gradient_presets = current( (array) get_theme_support( 'editor-gradient-presets' ) );
if ( false !== $gradient_presets ) {
$theme_settings['gradients'] = $gradient_presets;
}

return $theme_settings;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static function get_theme_data( $deprecated = array(), $settings = array(
* 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( gutenberg_get_legacy_theme_supports_for_theme_json() );
if ( ! wp_theme_has_theme_json() ) {
if ( ! isset( $theme_support_data['settings']['color'] ) ) {
$theme_support_data['settings']['color'] = array();
Expand Down

0 comments on commit 60843b4

Please sign in to comment.