Skip to content

Instantly share code, notes, and snippets.

@davidsword
Last active April 8, 2019 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsword/caa284d940d7e2a75cfc0d8b09fc72bb to your computer and use it in GitHub Desktop.
Save davidsword/caa284d940d7e2a75cfc0d8b09fc72bb to your computer and use it in GitHub Desktop.
WordPress - list all plugins in text via shortcode
<?php
/**
* List off all plugins used via `[list_plugins]` shortcode.
*
* Note that this includes inactive plugins, so keep the plugins tidy.
*
* @return string of html, list of plufins and links to their site.
*/
add_shortcode('list_plugins', function(){
$list_plugins = [];
$plugins = get_plugins();
foreach ( $plugins as $plugin ) {
if ( in_array( $plugin['Name'], [ 'Gutenberg', 'Classic Editor' ] ) ) {
continue;
}
$list_plugins[] = "<a href='".esc_url( $plugin['PluginURI'] )."'>".esc_html( $plugin['Name'] )."</a>";
}
return implode( ', ', $list_plugins );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment