WordPress函数文档current_theme_supports()
判断当前主题是否支持某个功能特性 描述 Checks a theme’s support for a give…
判断当前主题是否支持某个功能特性
描述
Checks a theme’s support for a given theme feature.
用法
<?php current_theme_supports( $feature ); ?>
参数
$feature
(string) (必填) the feature being checked
默认值: None
Features list:
- ‘post-thumbnails’
- ‘post-formats’
- ‘custom-header’
- ‘custom-background’
- ‘menus’
- ‘automatic-feed-links’
- ‘editor-style’
- ‘widgets’
- ‘html5’
- ‘title-tag’
返回值
(boolean)
示例
1
2
3
4
5
6
7
8
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
<?php
if (current_theme_supports(‘custom-header’)) {
// do something special when custom-header is supported…
}
?>
|
注意
- 使用到 global: (unknown type) $_wp_theme_features
历史
- 添加于 版本: 2.9.0
源文件
current_theme_supports() 函数的代码位于 wp-includes/theme.php
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
/**
* Checks a theme’s support for a given feature
*
* @since 2.9.0
*
* @global array $_wp_theme_features
*
* @param string $feature the feature being checked
* @return bool
*/
function current_theme_supports( $feature ) {
global $_wp_theme_features;
if ( ‘custom-header-uploads’ == $feature )
return current_theme_supports( ‘custom-header’, ‘uploads’ );
if ( !isset( $_wp_theme_features[$feature] ) )
return false;
if ( ‘title-tag’ == $feature ) {
// Don’t confirm support unless called internally.
$trace = debug_backtrace();
if ( ! in_array( $trace[1][‘function’], array( ‘_wp_render_title_tag’, ‘wp_title’ ) ) ) {
return false;
}
}
// If no args passed then no extra checks need be performed
if ( func_num_args() <= 1=“” )=“” return=“” true;=“” $args=“array_slice(“ func_get_args(),=“” 1=“” );=“” switch=“” (=“” $feature=“” )=“” {=“” case=“” ‘post-thumbnails’:=“” post–thumbnails=“” can=“” be=“” registered=“” for=“” only=“” certain=“” content/post=“” types=“” by=“” passing=“” an=“” array=“” of=“” types=“” to=“” add_theme_support().=“” if=“” no=“” array=“” was=“” passed,=“” then=“” any=“” type=“” is=“” accepted=“” if=“” (=“” true=“==” $_wp_theme_features[$feature]=“” )=“” registered=“” for=“” all=“” types=“” return=“” true;=“” $content_type=“$args[0];” return=“” in_array(=“” $content_type,=“” $_wp_theme_features[$feature][0]=“” );=“” case=“” ‘html5’:=“” case=“” ‘post-formats’:=“” specific=“” post=“” formats=“” can=“” be=“” registered=“” by=“” passing=“” an=“” array=“” of=“” types=“” to=“” add_theme_support()=“” specific=“” areas=“” of=“” html5=“” support=“” *must*=“” be=“” passed=“” via=“” an=“” array=“” to=“” add_theme_support()=“” $type=“$args[0];” return=“” in_array(=“” $type,=“” $_wp_theme_features[$feature][0]=“” );=“” case=“” ‘custom-header’:=“” case=“” ‘custom-background’=“” :=“” specific=“” custom=“” header=“” and=“” background=“” capabilities=“” can=“” be=“” registered=“” by=“” passing=“” an=“” array=“” to=“” add_theme_support()=“” $header_support=“$args[0];” return=“” (=“” isset(=“” $_wp_theme_features[$feature][0][$header_support]=“” )=“” &&=“” $_wp_theme_features[$feature][0][$header_support]=“” );=“” }=“” *=“” *=“” filter=“” whether=“” the=“” current=“” theme=“” supports=“” a=“” specific=“” feature.=“” *=“” *=“” the=“” dynamic=“” portion=“” of=“” the=“” hook=“” name,=“” `$feature`,=“” refers=“” to=“” the=“” specific=“” theme=“” *=“” feature.=“” possible=“” values=“” include=“” ‘post-formats’,=“” ‘post-thumbnails’,=“” ‘custom-background’,=“” *=“” ‘custom-header’,=“” ‘menus’,=“” ‘automatic-feed-links’,=“” and=“” ‘html5’.=“” *=“” *=“” @since=“” 3.4.0=“” *=“” *=“” @param=“” bool=“” true=“” whether=“” the=“” current=“” theme=“” supports=“” the=“” given=“” feature.=“” default=“” true.=“” *=“” @param=“” array=“” $args=“” array=“” of=“” arguments=“” for=“” the=“” feature.=“” *=“” @param=“” string=“” $feature=“” the=“” theme=“” feature.=“” */=“” return=“” apply_filters(=“” “current_theme_supports-{$feature}”,=“” true,=“” $args,=“” $_wp_theme_features[$feature]=“” );=“” }=“”></=>
|
相关
Theme Support:
add_theme_support(),
remove_theme_support(),
current_theme_supports()
Theme Features:
sidebar,
menus,
post-formats,
title-tag,
custom-background,
custom-header,
post-thumbnails,
automatic-feed-links,
html5,
editor-style,
content_width
- 原文:http://codex.wordpress.org/Function_Reference/current_theme_supports
类别:WordPress函数文档、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
评论功能已经关闭!