Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PHP command-line shell script to access the WordPress database and print out the list of active plugins.
php wp-active-plugins.php $host $db $user $pw
For example:
php wp-active-plugins.php localhost my_wp_db my_wp_login abc123
By Mike Schinkel (
Licensed GPLv2
list($script,$host,$db,$user,$pw) = $_SERVER['argv'];
$link = mysql_connect($host,$user,$pw);
if (!$link) {
die('Could not connect: ' . mysql_error());
$db_selected = mysql_select_db($db, $link);
if (!$db_selected) {
die ("Can\'t use $db: " . mysql_error());
$result = mysql_query("SELECT option_value FROM wp_options WHERE option_name = 'active_plugins'");
if (!$result) {
die('Invalid query: ' . mysql_error());
$row = mysql_fetch_assoc($result);
$plugins = unserialize($row['option_value']);
foreach($plugins as $plugin)
echo "$plugin\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment