wp_get_global_settings( array $path = array(), array $context = array() ): mixed
- Since
- 5.9.0
- Source
wp-includes/global-styles-and-settings.php:26
Compatibility
- WordPress
- since 5.9.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$patharrayoptional- Path to the specific setting to retrieve. Optional.
If empty, will return all settings.Default:array() $contextarrayoptional- Metadata to know where to retrieve the $path from. Optional.Default:
array()$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.
Return value
mixed- The settings array or individual setting value to retrieve.
Performance profile
How much work a call to wp_get_global_settings() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Moderate
- Scaling
- Scales with input
- Instructions
- 23–52
- Plugin surface
- None
- Called by
- 12
Only touches the object cache, via wp_cache_get().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 55.
Nothing here hands control to plugin code.
12 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- cacheobject cache
wp_cache_get()called directly
What one call costs · 6 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_get_global_settings() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$value && $settings !== false | 23–35 | wp_is_development_mode(), _wp_array_get() |
!$value && $settings !== false | 28–40 | wp_is_development_mode(), wp_cache_get(), _wp_array_get() |
$value && $settings === false | 30–42 | wp_is_development_mode(), ::WP_Theme_JSON_Resolver(), ->get_settings(), _wp_array_get() |
$settings === false | 35–47 | wp_is_development_mode(), ::WP_Theme_JSON_Resolver(), ->get_settings(), wp_cache_set(), _wp_array_get() |
$settings === false | 35–47 | wp_is_development_mode(), wp_cache_get(), ::WP_Theme_JSON_Resolver(), ->get_settings(), _wp_array_get() |
!$value && $settings === false | 40–52 | wp_is_development_mode(), wp_cache_get(), ::WP_Theme_JSON_Resolver(), ->get_settings(), wp_cache_set(), _wp_array_get() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 55 instructions, 23–52 executed per call, 8 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 6
- wp_is_development_mode()Checks whether the site is in the given development mode.
- wp_cache_get()Retrieves the cache contents from the cache by key and group.
- wp_cache_set()Saves the data to the cache.
- _wp_array_get()Accesses an array in depth based on a path of keys.
- WP_Theme_JSON_Resolver::get_merged_data($origin)::get_settings()
- WP_Theme_JSON_Resolver::get_merged_data()Returns the data merged from multiple origins.
Used by · 12
- WP_Duotone::get_all_global_styles_presets()Scrape all possible duotone presets from global and theme styles and store them in self::$global_styles_presets.
- WP_Font_Face_Resolver::get_fonts_from_theme_json()Gets fonts defined in theme.json.
- block_core_gallery_render()Renders the `core/gallery` block on the server.
- block_core_image_get_lightbox_settings()Adds the lightboxEnabled flag to the block data.
- block_core_navigation_add_support_classes_to_container()Adds Navigation block support classes to inner list containers.
- get_block_editor_settings()Returns the contextualized block editor settings for a selected editor context.
- render_block_core_button()Renders the `core/button` block on the server,
- wp_get_typography_font_size_value()Returns a font-size value based on a given font-size preset.
- wp_render_block_states_support()Renders per-instance state styles on the frontend.
- wp_render_block_visibility_support()Render nothing if the block is hidden, or add viewport visibility styles.
- wp_render_layout_support_flag()Renders the layout config to the block wrapper.
- wp_render_position_support()Renders position styles to the block wrapper.
Changelog
Introduced in 5.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/global-styles-and-settings.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.