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

validate_active_plugins

Definition:
function validate_active_plugins() {}

Validate active plugins
Validate all active plugins, deactivates invalid and returns an array of deactivated ones.

Return values

returns:invalid plugins, plugin as key, error as value

Source code

function validate_active_plugins() {

	$plugins = get_option( 'active_plugins', array() );

	// validate vartype: array

	if ( ! is_array( $plugins ) ) {

		update_option( 'active_plugins', array() );

		$plugins = array();

	}



	if ( is_multisite() && is_super_admin() ) {

		$network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );

		$plugins = array_merge( $plugins, array_keys( $network_plugins ) );

	}



	if ( empty( $plugins ) )

		return;



	$invalid = array();



	// invalid plugins get deactivated

	foreach ( $plugins as $plugin ) {

		$result = validate_plugin( $plugin );

		if ( is_wp_error( $result ) ) {

			$invalid[$plugin] = $result;

			deactivate_plugins( $plugin, true );

		}

	}

	return $invalid;

}

3311