Last active
April 8, 2019 17:16
-
-
Save davidsword/caa284d940d7e2a75cfc0d8b09fc72bb to your computer and use it in GitHub Desktop.
WordPress - list all plugins in text via shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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