wp_get_global_settings

函式
wp_get_global_settings ( $path = array(), $context = array() )
引數
  • (array) $path Path to the specific setting to retrieve. Optional. If empty, will return all settings.
    Required:
    Default: array()
  • (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. }
    Required:
    Default: array()
返回值
  • (array) The settings to retrieve.
定義位置
相關方法
wp_get_global_styleswp_set_all_user_settingswp_get_global_stylesheetget_settingsget_all_user_settings
引入
5.9.0
棄用
-

wp_get_global_settings: 這個函式返回一個在整個WordPress中使用的全域性設定的陣列。這些設定在wp-admin/includes/default-constants.php檔案中定義,包括諸如文章的最大尺寸、保留的修訂次數和預設的時區等值。

獲得合併核心、主題和使用者資料後的設定。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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 );
}

常見問題

FAQs
檢視更多 >