Skip to content

Instantly share code, notes, and snippets.

@tradesouthwest
Created March 4, 2019 00:53
Show Gist options
  • Save tradesouthwest/f0ef36ae5f43f288443af25e8597c38e to your computer and use it in GitHub Desktop.
Save tradesouthwest/f0ef36ae5f43f288443af25e8597c38e to your computer and use it in GitHub Desktop.
This snippet adds a shortcode to wordpress which will list all plugins in your wordpress plugins folder
<?php
// Check if get_plugins() function exists. This is required on the front end of the
// site, since it is in a file that is normally only loaded in the admin.
// This snippet adds a shortcode to wordpress which will list all plugins
function tradesouthwest_custom_listtall_plugins()
{
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$all_plugins = get_plugins();
header('Content-type: text/plain');
// Save the data to the error log so you can see what the array format is like.
echo '<pre>'; print_r($all_plugins); echo '</pre>';
}
add_shortcode( 'listall_plugins', 'tradesouthwest_custom_listtall_plugins' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment