Created
August 3, 2010 08:37
-
-
Save mikeschinkel/506055 to your computer and use it in GitHub Desktop.
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 | |
/* | |
PHP command-line shell script to access the WordPress database and print out the list of active plugins. | |
SYNTAX: | |
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 (http://mikeschinkel.com/custom-wordpress-plugins/) | |
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"; | |
mysql_free_result($result); | |
mysql_close($link); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment