Title: validate_active_plugins
Published: April 25, 2014
Last modified: May 20, 2026

---

# validate_active_plugins(): 󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿[]

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#description)
 * [Return](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#wp--skip-link--target)

Validates active plugins.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#description)󠁿

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

## 󠀁[Return](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#return)󠁿

 [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)[] Array
of plugin errors keyed by plugin file name.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#source)󠁿

    ```php
    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() && current_user_can( 'manage_network_plugins' ) ) {
    		$network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
    		$plugins         = array_merge( $plugins, array_keys( $network_plugins ) );
    	}

    	if ( empty( $plugins ) ) {
    		return array();
    	}

    	$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;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/plugin.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/plugin.php#L1069)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/plugin.php#L1069-L1097)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#related)󠁿

| Uses | Description | 
| [validate_plugin()](https://developer.wordpress.org/reference/functions/validate_plugin/)`wp-admin/includes/plugin.php` |

Validates the plugin path.

  | 
| [deactivate_plugins()](https://developer.wordpress.org/reference/functions/deactivate_plugins/)`wp-admin/includes/plugin.php` |

Deactivates a single plugin or multiple plugins.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [is_multisite()](https://developer.wordpress.org/reference/functions/is_multisite/)`wp-includes/load.php` |

Determines whether Multisite is enabled.

  | 
| [get_site_option()](https://developer.wordpress.org/reference/functions/get_site_option/)`wp-includes/option.php` |

Retrieve an option value for the current network based on name of option.

  | 
| [update_option()](https://developer.wordpress.org/reference/functions/update_option/)`wp-includes/option.php` |

Updates the value of an option that was already added.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  |

[Show 6 more](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/validate_active_plugins/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fvalidate_active_plugins%2F)
before being able to contribute a note or feedback.