Advertisements

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

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: