Discover in this tutorial how to get and display all the active plugins of a WordPress installation using code.
It is possible that in some cases you may want to show (or get) all the plugins of a WordPress installation, including version, author and other data.
So in this tutorial you are going to learn how you can get a list of all active plugins of a WordPress installation. This would be the result:
Let’s see it:
Steps to display all active plugins of a WordPress installation using a shortcode
1. Create the shortcode
First you are going to encapsulate the active plugins inside a shortcode to be able to display the list wherever you want.
Add the following code at the end of functions.php or in your functionality plugin:
With this code you create a shortcode that allows you to display a list of all active plugins in the WordPress installation using the [plugin_list] shortcode.
To get the list of plugins you use the
get_plugins() function together with a foreach loop.
In this case, 3 details of plugin information are displayed:
- Plugin name
[Name]> with link to it
- Plugin version
[Version]> with link to it
- Author’s name
[Author]> with link to it
But you can remove or add more to customize it to your liking. These are all the details you can display:
For example, for the Osom Blocks plugin, it returns something like this:
[Name] => Osom Blocks [PluginURI] => https://osompress.com [Version] => 1.2 [Description] => Gutenberg Block collection for OsomPress themes [Author] => OsomPress [AuthorURI] => https://twitter.com/osompress [TextDomain] => osomblocks [DomainPath] => /languages [Network] => [RequiresWP] => [RequiresPHP] => [UpdateURI] => [Title] => Osom Blocks [AuthorName] => OsomPress
So you can customize the details you prefer to be displayed.
You can also get all plugins to be shown, not just the active ones, by removing the
if ( is_plugin_active( $plugin ) ) conditional.
If you have any questions or suggestions you can leave them in the comments.
To be able to see the list there is only one step left.
2. Insert the shortcode where you want
The advantage of shortcodes is that you can insert them anywhere on the web.
You only have to type
[plugin_list] where you want it to be displayed.
- If you are using the classic editor, use the HTML tab to enter the shortcode.
- In case you are already using the new block editor (Gutenberg) you can add it to the normal paragraph block, the HTML block or the shortcode block. All of them will render the content correctly.
This would be an example of the listing that the shortcode would display:
Now you know how to get and display all the active plugins of a WordPress installation to decide if you need them all or not.
Any questions? I read you in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉