wp_get_active_and_valid_plugins()
Gets an array of paths to the main files of active plugins.
The list of active plugins is obtained by the function from the database, from the options:
get_option( 'active_plugins' )for standard installation.
The default directory for plugins is wp-content/plugins. It can be changed through the constants WP_PLUGIN_DIR and WP_PLUGIN_URL, defined in the file wp-config.php.
Use wp_get_active_network_plugins() when you need to get a list of plugins activated for the network (multisite).
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
Uses: validate_file(), get_option()
No Hooks.
Returns
String[]. An array of absolute paths to the main files of active plugins.
Note: When updating or installing WordPress, an empty list will be returned.
Usage
wp_get_active_and_valid_plugins();
Examples
#1 An example of how the function works
$list = wp_get_active_and_valid_plugins(); print_r( $list ); /* Array ( [0] => F:\server\www\example.com/wp-content/plugins/query-monitor/query-monitor.php [1] => F:\server\www\example.com/wp-content/plugins/advanced-custom-fields-pro/acf.php [2] => F:\server\www\example.com/wp-content/plugins/akismet/akismet.php [3] => F:\server\www\example.com/wp-content/plugins/crypto-currencies-live-charts/crypto-currencies-live-charts.php [4] => F:\server\www\example.com/wp-content/plugins/cryptocurrency-reviews/cryptocurrency-reviews.php [5] => F:\server\www\example.com/wp-content/plugins/cyr3lat/cyr-to-lat.php [6] => F:\server\www\example.com/wp-content/plugins/democracy-poll/democracy.php [7] => F:\server\www\example.com/wp-content/plugins/font-awesome-4-menus/n9m-font-awesome-4.php [8] => F:\server\www\example.com/wp-content/plugins/image-watermark/image-watermark.php [9] => F:\server\www\example.com/wp-content/plugins/luckywp-scripts-control/luckywp-scripts-control.php [10] => F:\server\www\example.com/wp-content/plugins/profunctions/profunctions.php [11] => F:\server\www\example.com/wp-content/plugins/tablepress/tablepress.php [12] => F:\server\www\example.com/wp-content/plugins/widget-logic/widget_logic.php [13] => F:\server\www\example.com/wp-content/plugins/wp-subscribe/wp-subscribe.php ) */
Changelog
| Since 3.0.0 | Introduced. |