[wp-hackers] Accessing wp classes/functions from command line for upgrades
jage32 at gmail.com
Fri Jul 8 01:42:39 UTC 2011
Thanks for this, it helps to have the correct usage.
I guess I should have been more persistent, because I was able to get
it to work after including a few more files.
include ABSPATH . 'wp-admin/includes/misc.php';
include ABSPATH . 'wp-admin/includes/template.php';
include ABSPATH . 'wp-admin/includes/file.php';
include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$url = 'http://downloads.wordpress.org/plugin/polldaddy.2.0.4.zip';
$folder = 'polldaddy';
$upgrader = new Plugin_Upgrader();
$options = array( 'package' => $url,
'destination' => WP_PLUGIN_DIR .'/' . $folder,
'clear_destination' => true,
'clear_working' => false,
'is_multi' => false,
'hook_extra' => array()
I basically just had to use trial and error until it worked, which
made it feel like I was going about it the wrong way. Am I setting up
the script appropriately to run outside of wordpress?
On Thu, Jul 7, 2011 at 7:19 PM, Simon Prosser <pross at pross.org.uk> wrote:
> Used this in a plugin:
> $upgrader = new Plugin_Upgrader();
> $options = array( 'package' => $url,
> 'destination' => WP_PLUGIN_DIR .'/' . $folder,
> 'clear_destination' => true,
> 'clear_working' => false,
> 'is_multi' => false,
> 'hook_extra' => array()
> $url is the url on plugin download page, $folder is the actual plugin
> folder name.
> On 8 July 2011 00:25, Josh Eaton <jage32 at gmail.com> wrote:
>> 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);
>> include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
>> $upgrader = new Plugin_Upgrader();
>> 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?
>> Josh Eaton
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
> My Blog: http://www.pross.org.uk/
> Plugins : http://www.pross.org.uk/plugins/
> Themes: http://wordpress.org/extend/themes/profile/pross
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers