Another win this week. I’ve needed this for some time – a way to list currently active plugins on a WordPress site.
I cobbled the following PHP script together from fragments found on the web. You’ll need to edit the IP address at the top of the script. While there are other ways to lock down this script, this is my preferred method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
<?php // Restrict who can access this script. $permitted_ips = array('0.0.0.0', ); if (in_array($_SERVER['REMOTE_ADDR'], $permitted_ips) == false) { header('HTTP/1.0 403 Forbidden'); die(); } ?> <!DOCTYPE html> <html lang="en-US"> <head> <style> table.greyGridTable { border: 2px solid #FFFFFF; width: 100%; text-align: center; border-collapse: collapse; } table.greyGridTable td, table.greyGridTable th { border: 1px solid #FFFFFF; padding: 3px 4px; } table.greyGridTable tbody td { font-size: 13px; } table.greyGridTable td:nth-child(even) { background: #EBEBEB; } table.greyGridTable thead { background: #FFFFFF; border-bottom: 4px solid #333333; } table.greyGridTable thead th { font-size: 15px; font-weight: bold; color: #333333; text-align: center; border-left: 2px solid #333333; } table.greyGridTable thead th:first-child { border-left: none; } table.greyGridTable tfoot { font-size: 14px; font-weight: bold; color: #333333; border-top: 4px solid #333333; } table.greyGridTable tfoot td { font-size: 14px; }</style> <meta charset="UTF-8" /> <title>List Active Plugins</title> <meta name="viewport" content="width=device-width, initial-scale=1" /> </head> <body> <h1>Active Wordpress Plugins</h1> <?php define('WP_USE_THEMES', false); /** Loads the WordPress Environment and Template */ require( '/var/www/html/wp-load.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. if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $active_plugins = get_option('active_plugins'); $all_plugins = get_plugins(); //print_r( $all_plugins ); echo '<table class="greyGridTable" style="width=100%">'; echo "<colgroup>"; echo '<col span="1" style="width: 35%;">'; echo '<col span="1" style="width: 40%;">'; echo '<col span="1" style="width: 15%;">'; echo "</colgroup>"; echo "<tr>"; echo "<th>Plugin</th>"; echo "<th>filename</th>"; echo "<th>version</th>"; echo "<th>Author Details</th>"; echo "</tr>"; foreach($active_plugins as $key => $value) { $string = explode('/',$value); // Folder name will be displayed echo "<tr><td>".$string[0] ."</td>"; echo "<td>".$string[1]."</td>"; echo "<td>".$all_plugins[$value]['Version']."</td>"; echo "<td>".$all_plugins[$value]['AuthorName']." - ".$all_plugins[$value]['AuthorURI']."</td>"; echo "</tr>"; } echo "</table>"; ?> </body> |
Here’s the output: (truncated)
Groovy!
Leave a Reply
Be the First to Comment!