Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

After seeing thousands of useful API functions in the WordPress core, I'm surprised to discover today that there ain't a function that would list the active plug-ins. I don't know you but I'm quite surprised at that.

I was wondering if there is a reason for missing that? If so, I'd like to know about it.

And, if there is a quick PHP snippet you know of that could give you a list of active plugins, ( the same way that a get_post_types('','names'); does for CPT's or get_taxonomies('','names'); does for CTs ), I'd appreciate it if you provide the code.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

wp_get_active_and_valid_plugins()

get_plugins()

and get_option('active_plugins')

share|improve this answer
    
Interesting. So we do have such a function. That's good. But check this (google.com/… ) or this (google.com/…) to see how google fails to pick that up. –  Average Joe May 15 '12 at 12:22

There multiple WordPress Apis for getting a list of plugins like OTP listed in his answer.

get_plugins() :Check the plugins directory and retrieve all plugin files with plugin data. Returns an array. Note: Only works on the admin side

Example:

function list_the_plugins() {
    $plugins = get_plugins();
        foreach ( $plugins as $plugin ) {
        var_dump( $plugin );
    }

Returns:

array
  'Name' => string 'WP Coda Slider' (length=14)
  'PluginURI' => string 'http://c3mdigital.com/wp-coda-slider/' (length=37)
  'Version' => string '0.3.2' (length=5)
  'Description' => string 'Add a jQuery Coda slider to any WordPress post or page' (length=54)
  'Author' => string 'c3mdigital' (length=10)
  'AuthorURI' => string 'http://c3mdigital.com/' (length=22)
  'TextDomain' => string '' (length=0)
  'DomainPath' => string '' (length=0)
  'Network' => boolean false
  'Title' => string 'WP Coda Slider' (length=14)
  'AuthorName' => string 'c3mdigital' (length=10)

get_option( 'active_plugins' ) Returns the path relative to wp-content/plugins of the plugin file:

Example:

function list_the_plugins() {
    $plugins = get_option ( 'active_plugins', array () );
    foreach ( $plugins as $plugin ) {
        echo "<li>$plugin</li>";
    }
}

Returns:

  • debug-bar-extender/debug-bar-extender.php
  • debug-bar/debug-bar.php
  • log-deprecated-notices/log-deprecated-notices.php
  • manage-post-schedule/manage-post-schedule.php
  • wp-coda-slider/wpcodaslider.php

Other API functions related to plugin status:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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