-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add partial override for getting global theme.json setting
This only gets the settings working in the block editor. The Site Editor is reloading settings and somewhere it's base config isn't getting the correct settings.
- Loading branch information
1 parent
5da9def
commit 840b77d
Showing
3 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
lib/compat/wordpress-6.0/get-global-styles-and-settings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* API to interact with global settings & styles. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
if ( ! function_exists( 'gutenberg_get_global_settings' ) ) { | ||
/** | ||
* Function to get the settings resulting of merging core, theme, and user data. | ||
* | ||
* @param array $path Path to the specific setting to retrieve. Optional. | ||
* If empty, will return all settings. | ||
* @param array $context { | ||
* Metadata to know where to retrieve the $path from. Optional. | ||
* | ||
* @type string $block_name Which block to retrieve the settings from. | ||
* If empty, it'll return the settings for the global context. | ||
* @type string $origin Which origin to take data from. | ||
* Valid values are 'all' (core, theme, and user) or 'base' (core and theme). | ||
* If empty or unknown, 'all' is used. | ||
* } | ||
* | ||
* @return array The settings to retrieve. | ||
*/ | ||
function gutenberg_get_global_settings( $path = array(), $context = array() ) { | ||
if ( ! empty( $context['block_name'] ) ) { | ||
$path = array_merge( array( 'blocks', $context['block_name'] ), $path ); | ||
} | ||
$origin = 'custom'; | ||
if ( isset( $context['origin'] ) && 'base' === $context['origin'] ) { | ||
$origin = 'theme'; | ||
} | ||
$settings = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data( $origin )->get_settings(); | ||
return _wp_array_get( $settings, $path, $settings ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters