1. 首页
  2. WordPress 函数手册

get_theme_support()

get_theme_support( string $feature, mixed $args )

获取注册该支持时传递的主题支持参数
Gets the theme support arguments passed when registering that support

目录锚点:#说明#参数#返回#源码#笔记


说明(Description)

示例用法:

获取主题支持(“自定义徽标”);

获取主题支持(’自定义标题’,’宽度’);


参数(Parameters)

参数 类型 必填 说明
$feature (string) 必需 要检查的功能。
$args (mixed) 可选 要对照某些功能检查的额外参数。

返回(Return)

(mixed)额外参数的数组或已注册功能的值。


源码(Source)

/**
 * Gets the theme support arguments passed when registering that support
 *
 * @since 3.1.0
 *
 * @global array $_wp_theme_features
 *
 * @param string $feature the feature to check
 * @return mixed The array of extra arguments or the value for the registered feature.
 */
function get_theme_support( $feature ) {
	global $_wp_theme_features;
	if ( ! isset( $_wp_theme_features[ $feature ] ) )
		return false;

	if ( func_num_args() <= 1="" )="" return="" $_wp_theme_features&#91;="" $feature="" &#93;;="" $args="array_slice(" func_get_args(),="" 1="" );="" switch="" (="" $feature="" )="" {="" case="" 'custom-header'="" :="" case="" 'custom-background'="" :="" if="" (="" isset(="" $_wp_theme_features&#91;="" $feature="" &#93;&#91;0&#93;&#91;="" $args&#91;0&#93;="" &#93;="" )="" )="" return="" $_wp_theme_features&#91;="" $feature="" &#93;&#91;0&#93;&#91;="" $args&#91;0&#93;="" &#93;;="" return="" false;="" default="" :="" return="" $_wp_theme_features&#91;="" $feature="" &#93;;="" }="" }="">
更新版本 源码位置 使用 被使用
5.3.0 wp-includes/theme.php:2704 34 0

笔记(Notes)

获取“自定义背景”主题支持参数

get_theme_support() 为WP2原创文章,链接:https://www.wp2.cn/functions/get_theme_support/