Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




validate_current_theme [ WordPress Function ]

validate_current_theme ( No parameters )
See:
  • WP_DEFAULT_THEME
Returns:
  • (bool)
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_themeWP_DEFAULT_THEMEWP_DEFAULT_THEME );
        return 
false;
    }

    if ( 
get_stylesheet() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/style.css') ) {
        
switch_themeWP_DEFAULT_THEMEWP_DEFAULT_THEME );
        return 
false;
    }

    if ( 
is_child_theme() && ! file_existsget_stylesheet_directory() . '/style.css' ) ) {
        
switch_themeWP_DEFAULT_THEMEWP_DEFAULT_THEME );
        return 
false;
    }

    return 
true;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics