Title: wp_get_active_and_valid_plugins
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_get_active_and_valid_plugins(): string[]

## In this article

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

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

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Retrieves an array of active and valid plugin files.

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

While upgrading or installing WordPress, no plugins are returned.

The default directory is `wp-content/plugins`. To change the default directory manually,
define `WP_PLUGIN_DIR` and `WP_PLUGIN_URL` in `wp-config.php`.

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

 string[] Array of paths to plugin files relative to the plugins directory.

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

    ```php
    function wp_get_active_and_valid_plugins() {
    	$plugins        = array();
    	$active_plugins = (array) get_option( 'active_plugins', array() );

    	// Check for hacks file if the option is enabled.
    	if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) {
    		_deprecated_file( 'my-hacks.php', '1.5.0' );
    		array_unshift( $plugins, ABSPATH . 'my-hacks.php' );
    	}

    	if ( empty( $active_plugins ) || wp_installing() ) {
    		return $plugins;
    	}

    	$network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;

    	foreach ( $active_plugins as $plugin ) {
    		if ( ! validate_file( $plugin )                     // $plugin must validate as file.
    			&& str_ends_with( $plugin, '.php' )             // $plugin must end with '.php'.
    			&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist.
    			// Not already included as a network plugin.
    			&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins, true ) )
    		) {
    			$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
    		}
    	}

    	/*
    	 * Remove plugins from the list of active plugins when we're on an endpoint
    	 * that should be protected against WSODs and the plugin is paused.
    	 */
    	if ( wp_is_recovery_mode() ) {
    		$plugins = wp_skip_paused_plugins( $plugins );
    	}

    	return $plugins;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/load.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/load.php#L1013)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/load.php#L1013-L1049)

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

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

Determines whether WordPress is in Recovery Mode.

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

Filters a given list of plugins, removing any paused plugins from it.

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

Checks or sets whether WordPress is in “installation” mode.

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

Marks a file as deprecated and inform when it has been used.

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

Validates a file name and path against an allowed set of rules.

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

Returns array of network plugin files to be included in global scope.

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

Determines whether Multisite is enabled.

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

Retrieves an option value based on an option name.

  |

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

| Used by | Description | 
| [WP_REST_Templates_Controller::get_wp_templates_author_text_field()](https://developer.wordpress.org/reference/classes/wp_rest_templates_controller/get_wp_templates_author_text_field/)`wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php` |

Returns a human readable text for the author of the template.

  |

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

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

## User Contributed Notes

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