[wp-hackers] Accessing wp classes/functions from command line for upgrades
Josh Eaton
jage32 at gmail.com
Thu Jul 7 23:25:04 UTC 2011
My host has file permission limitations that make plugin
installs/upgrades and core upgrades very difficult. I have to do it
all from ssh. I upgrade core using SVN, which works great for me, but
since I maintain 6-7 sites at this same host, plugin upgrades become
quite time-consuming. I end up having to do this:
cd /home/public/blog/wp-content/plugins
wget http://downloads.wordpress.org/plugin/google-analytics-for-wordpress.4.0.13.zip
rm -rf google-analytics-for-wordpress
unzip google-analytics-for-wordpress.4.0.13.zip
For each plugin I have installed, and then repeat 6-7 times for each
site. I planned to write a bash script to accomplish this via ssh, or
a php script to run from the command line, but before I went through
the effort, I briefly browsed through core to see if I could re-use
any of the upgrade components (e.g. WP_Upgrader class).
As a quick test, I dropped the following script into my blog root, and
ran it from ssh using 'php script.php'
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader = new Plugin_Upgrader();
$upgrader->upgrade('core-control');
I get the following error: "Fatal error: Call to undefined function
screen_icon() in
/home/public/blog/wp-admin/includes/class-wp-upgrader.php on line
960". I am assuming that since I'm not using themes from the command
line, that all of the UI code in this class may not work correctly.
So my questions:
1. Is there an easy way for me to call this class or other core code
to accomplish this? (maybe subclass the Plugin_Upgrader class and
remove the UI code?)
2. Am I setting up the script correctly to run from the command line?
3. Is this a stupid idea, and I should just write my own php/ssh
script to handle it?
Thanks!
Josh Eaton
More information about the wp-hackers
mailing list