While I don't know exactly why you would want to display your active WordPress plugins for the world to see, there may come a time where it's necessary. The WordPress shortcode function on this page will do just that: render all your active plugins in a list (with optional link back to the plugin page). We'll provide a few different ways of accomplishing the same thing.
The shortcode of
[showplugins] returns the following list:
In our case, there's 11 plugins. However, three of those are ours and aren't hosted with WordPress. The plugin
beliefmedia-examples, for example, is a plugin we use just to host example code that isn't part of our own site core. The next function addresses this in a couple of different ways.
WP Shortcode Functions
Copy and paste the WordPress function into your theme's
functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.
The first function makes use of get_option to retrieve the plugin array.
Rather than use
get_option, you may choose to use wp_get_active_and_valid_plugins() . Rather than return just the
directory/filename.php, it returns the full path in its array. The function, located in wp-includes/load.php , will first do what we did above - use
get_option to return an array - but then it continues to check the validity of the file and ensures it's not a default network plugin. Interestingly, it first checks for the old hackfile.php (I'm surprised WP still include it).
The shortcode of
[showactivevalid] will return the same list as above.
Linking back to Plugins on WordPress.org
Sometimes you might want to link the plugin back to WordPress.org. However, WordPress doesn't discriminate against plugins installed from their own library or something you've written yourself, or something you've downloaded from elsewhere. So, to circumvent this we can create an
$exclude array that'll give us a crude means of checking whether the plugin link should be created or just returned by name.
The result is as follows (sample only):
- While there's not much use to this code, we use it to query client websites (via an API built into a company plugin) that returns plugin data so it can be surveyed at times when a security exploit is identified. We also use it to simply tally the number of plugins they have installed.