validate_current_theme()
validate_current_theme() 检查当前主题文件’索引.php’和’样式表’存在。 Chec…
validate_current_theme()
检查当前主题文件’索引.php’和’样式表’存在。
Checks that current theme files ‘index.php’ and ‘style.css’ exists.
检查当前主题文件’索引.php’和’样式表’存在。
Checks that current theme files ‘index.php’ and ‘style.css’ exists.
目录锚点:#说明#参数#源码
说明(Description)
最初不检查默认主题,该主题是备用主题,应该始终存在。但如果它不存在,它将回到最新的核心默认主题。如果当前主题未验证,则将主题切换到回退主题。您可以使用“验证当前主题”筛选器返回false以禁用此功能。另请参阅“默认主题”
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|
源码(Source)
/**
* Checks that current theme files 'index.php' and 'style.css' exists.
*
* Does not check the default theme, which is the fallback and should always exist.
* Will switch theme to the fallback theme if current theme does not validate.
* You can use the 'validate_current_theme' filter to return false to
* disable this functionality.
*
* @since 1.5.0
* @see WP_DEFAULT_THEME
*
* @return bool
*/
function validate_current_theme() {
/**
* Filter whether to validate the current theme.
*
* @since 2.7.0
*
* @param bool true Validation flag to check the current theme.
*/
if ( defined('WP_INSTALLING') || ! apply_filters( 'validate_current_theme', true ) )
return true;
if ( get_template() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/index.php') ) {
switch_theme( WP_DEFAULT_THEME );
return false;
}
if ( get_stylesheet() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/style.css') ) {
switch_theme( WP_DEFAULT_THEME );
return false;
}
if ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {
switch_theme( WP_DEFAULT_THEME );
return false;
}
return true;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 1.5.0 | wp-includes/theme.php | 18 | 2 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!