Skip to content

Commit b0a9764

Browse files
committed
Remove to it's own function.
1 parent 9e82a0b commit b0a9764

File tree

3 files changed

+40
-27
lines changed

3 files changed

+40
-27
lines changed

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

+1-27
Original file line numberDiff line numberDiff line change
@@ -65,40 +65,14 @@ public static function get_theme_data( $deprecated = array(), $settings = array(
6565
if ( ! $settings['with_supports'] ) {
6666
return static::$theme;
6767
}
68-
69-
$editor_settings = array(
70-
'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),
71-
'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
72-
'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ),
73-
'disableLayoutStyles' => get_theme_support( 'disable-layout-styles' ),
74-
'enableCustomLineHeight' => get_theme_support( 'custom-line-height' ),
75-
'enableCustomSpacing' => get_theme_support( 'custom-spacing' ),
76-
'enableCustomUnits' => get_theme_support( 'custom-units' ),
77-
);
78-
79-
// Theme settings.
80-
$color_palette = current( (array) get_theme_support( 'editor-color-palette' ) );
81-
if ( false !== $color_palette ) {
82-
$editor_settings['colors'] = $color_palette;
83-
}
84-
85-
$font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) );
86-
if ( false !== $font_sizes ) {
87-
$editor_settings['fontSizes'] = $font_sizes;
88-
}
89-
90-
$gradient_presets = current( (array) get_theme_support( 'editor-gradient-presets' ) );
91-
if ( false !== $gradient_presets ) {
92-
$editor_settings['gradients'] = $gradient_presets;
93-
}
9468

9569
/*
9670
* We want the presets and settings declared in theme.json
9771
* to override the ones declared via theme supports.
9872
* So we take theme supports, transform it to theme.json shape
9973
* and merge the static::$theme upon that.
10074
*/
101-
$theme_support_data = WP_Theme_JSON_Gutenberg::get_from_editor_settings( $editor_settings );
75+
$theme_support_data = WP_Theme_JSON_Gutenberg::get_from_editor_settings( gutenberg_get_block_theme_supports() );
10276
if ( ! wp_theme_has_theme_json() ) {
10377
if ( ! isset( $theme_support_data['settings']['color'] ) ) {
10478
$theme_support_data['settings']['color'] = array();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
4+
/**
5+
* Repeated logic from `get_default_block_editor_settings` function. When implemented into core,
6+
* remove logic from `get_default_block_editor_settings` and simple call this function instead.
7+
*
8+
* @return array
9+
*/
10+
function gutenberg_get_block_theme_supports(){
11+
$theme_settings = array(
12+
'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),
13+
'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
14+
'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ),
15+
'disableLayoutStyles' => get_theme_support( 'disable-layout-styles' ),
16+
'enableCustomLineHeight' => get_theme_support( 'custom-line-height' ),
17+
'enableCustomSpacing' => get_theme_support( 'custom-spacing' ),
18+
'enableCustomUnits' => get_theme_support( 'custom-units' ),
19+
);
20+
21+
// Theme settings.
22+
$color_palette = current( (array) get_theme_support( 'editor-color-palette' ) );
23+
if ( false !== $color_palette ) {
24+
$theme_settings['colors'] = $color_palette;
25+
}
26+
27+
$font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) );
28+
if ( false !== $font_sizes ) {
29+
$theme_settings['fontSizes'] = $font_sizes;
30+
}
31+
32+
$gradient_presets = current( (array) get_theme_support( 'editor-gradient-presets' ) );
33+
if ( false !== $gradient_presets ) {
34+
$theme_settings['gradients'] = $gradient_presets;
35+
}
36+
37+
return $theme_settings;
38+
}

lib/load.php

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ function gutenberg_is_experiment_enabled( $name ) {
115115
if ( ! class_exists( 'WP_HTML_Tag_Processor' ) ) {
116116
require __DIR__ . '/experimental/html/index.php';
117117
}
118+
require __DIR__ . '/experimental/get-global-styles-and-settings.php';
118119
require __DIR__ . '/experimental/class-wp-theme-json-gutenberg.php';
119120
require __DIR__ . '/experimental/class-wp-theme-json-resolver-gutenberg.php';
120121
require __DIR__ . '/experimental/class-wp-webfonts.php';

0 commit comments

Comments
 (0)