On this page
wp_get_global_settings( array $path = array(), array $context = array() ): array
Gets the settings resulting of merging core, theme, and user data.
Parameters
$patharray Optional-
Path to the specific setting to retrieve. Optional.
If empty, will return all settings.Default:
array() $contextarray Optional-
Metadata to know where to retrieve the $path from. Optional.
block_namestringWhich block to retrieve the settings from.
If empty, it'll return the settings for the global context.originstringWhich 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.
Default:
array()
Return
array The settings to retrieve.
Source
File: wp-includes/global-styles-and-settings.php. View all references
function wp_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::get_merged_data( $origin )->get_settings();
return _wp_array_get( $settings, $path, $settings );
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Theme_JSON_Resolver::get_merged_data() wp-includes/class-wp-theme-json-resolver.php | Returns the data merged from multiple origins. |
| _wp_array_get() wp-includes/functions.php | Accesses an array in depth based on a path of keys. |
Used By
| Used By | Description |
|---|---|
| get_block_editor_settings() wp-includes/block-editor.php | Returns the contextualized block editor settings for a selected editor context. |
Changelog
| Version | Description |
|---|---|
| 5.9.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_global_settings