validate_current_theme [ WordPress Function ]
| See: |
|
| Returns: |
|
| Defined at: |
|
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.
Source
<?php
function validate_current_theme() {
// Don't validate during an install/upgrade.
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, WP_DEFAULT_THEME );
return false;
}
if ( get_stylesheet() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/style.css') ) {
switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
return false;
}
if ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {
switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
return false;
}
return true;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/validate current theme « WordPress Codex
Description. Checks that current theme files 'index.php' and 'style.css' exists. Does not check the 'default' theme. The 'default' theme should always exist or ...
codex.wordpress.org - #3907 (WP reverts to default theme on file access collision ...
+1 to removing the call validate_current_theme() from wp-settings.php ... validate_current_theme with its 2 file checks is useful for basic sanity when going to the ...
core.trac.wordpress.org - PHPXRef 0.7 : WordPress : Detail view of theme.php
_preview_theme_stylesheet_filter() preview_theme_ob_filter() preview_theme_ob_filter_callback() switch_theme() validate_current_theme() get_theme_mods() ...
phpxref.ftwr.co.uk - 常用函数-validate_current_theme() | WordPress啦!
2009年5月4日 ... 若当前主题为未生效,该函数会将主题转换成默认主题。用户可以使用' validate_current_theme' 过滤器返回false,从而禁用该函数的功能。
www.wordpress.la