I would like to generate a simple text report for a Wordpress instance listing:

  • Wordpress version
  • Plugins installed (version and whether enabled)

I can get this information from the Dashboard, but is there a way to get it programmatically (with WP API or other smart ways)?

  • If by WP API you mean the REST API, it is not possible without adding your custom endpoints. If you have SSH access, you can wp core version && wp plugin list using WP-CLI, is that an option?
    – kero
    Oct 5, 2018 at 9:07

1 Answer 1


Yes, there is a way to get that information programmatically.

WordPress Version Info

The WordPress version exists as a global, but you can also get it using the get_bloginfo() function:

global $wp_version;
echo $wp_version;

// OR

$wordpress_version = get_bloginfo( 'version' );
echo $wordpress_version;

Plugin Info

For retrieving plugin info, use the get_plugins() function. You'll need to make sure that you also include the wp-admin/includes/plugin.php file to use it as this file cannot be considered loaded in every use case.

include_once( 'wp-admin/includes/plugin.php' );
$plugins = get_plugins();

From the Codex article on get_plugins() you can see that the above will give you an array that contains info on all installed plugins:

    [hello-dolly/hello.php] => Array
            [Name] => Hello Dolly
            [PluginURI] => http://wordpress.org/extend/plugins/hello-dolly/
            [Version] => 1.6
            [Description] => This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page.
            [Author] => Matt Mullenweg
            [AuthorURI] => http://ma.tt/
            [TextDomain] => 
            [DomainPath] => 
            [Network] => 
            [Title] => Hello Dolly
            [AuthorName] => Matt Mullenweg


To get information on active plugins, use the following:

$active_plugins = get_option( 'active_plugins' );

$active_plugins will be an array of the active plugins as follows (continuing from the example above):

    [0] => hello-dolly/hello.php

Putting those things together, here's a utility function you could use to get all installed plugins and all active plugins, and put the results into an array containing the plugin name, version, and whether it is active or not:

function my_get_plugin_info() {

    // Get all plugins
    include_once( 'wp-admin/includes/plugin.php' );
    $all_plugins = get_plugins();

    // Get active plugins
    $active_plugins = get_option('active_plugins');

    // Assemble array of name, version, and whether plugin is active (boolean)
    foreach ( $all_plugins as $key => $value ) {
        $is_active = ( in_array( $key, $active_plugins ) ) ? true : false;
        $plugins[ $key ] = array(
            'name'    => $value['Name'],
            'version' => $value['Version'],
            'active'  => $is_active,

    return $plugins;

This would give you an array result:

[akismet/akismet.php] => Array
        [name] => Akismet Anti-Spam
        [version] => 4.08
        [active] => 1
[gutenberg/gutenberg.php] => Array
        [name] => Gutenberg
        [version] => 3.9.0
        [active] => 1

[hello-dolly/hello.php] => Array
        [name] => Hello Dolly
        [version] => 1.6
        [active] => 

Note that I made "active" a boolean, but in the utility function you could make it "active"/"inactive" or whatever. Also, I only included name, version, and active in my array since that what you mentioned in the OP, but any data from the get_plugins() result could be included.

I put together the above utility function as well as an alternate version that simply adds an "Active" key to the array returned by get_plugins() and saved those as a gist for anyone who needs it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.