validate_current_theme

Definition:
function validate_current_theme() {}

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.

Defined filters

  • validate_current_theme
    apply_filters( 'validate_current_theme', true )

Source code

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;

}

3319

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: