wp_get_global_settings() WordPress Function

The wp_get_global_settings() function is used to retrieve global WordPress settings. These settings include the database table prefix, the default language, the date format, and the time format. This function can be useful when you need to programmatically access WordPress settings.

wp_get_global_settings( array $path = array(), array $context = array() ) #

Function to get the settings resulting of merging core, theme, and user data.


Parameters

$path

(array)(Optional)Path to the specific setting to retrieve. Optional. If empty, will return all settings.

Default value: array()

$context

(array)(Optional)Metadata to know where to retrieve the $path from. Optional.

  • 'block_name'
    (string) Which block to retrieve the settings from. If empty, it'll return the settings for the global context.
  • 'origin'
    (string) 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.

Default value: array()


Top ↑

Return

(array) The settings to retrieve.


Top ↑

Source

File: wp-includes/global-styles-and-settings.php

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 );
}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.