WP_Upgrader updates from DD32. see #7875
git-svn-id: http://svn.automattic.com/wordpress/trunk@11089 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
84f5771dfa
commit
b56c151d71
|
@ -1,20 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is an attempt at an abstracted version of the plugin/theme/core installer/upgrader which can be used interchangably for all uses needed within WordPress.
|
||||
* It is designed to be as flexible as possible, but some logic may seem rather, crazy to say the least.
|
||||
* Yes, this header is designed to be replaced before commiting, Hopefully i'll get some proper documentation in here.
|
||||
* A File upgrader class for WordPress.
|
||||
*
|
||||
* This File obviously needs some new PHPDoc, However:
|
||||
* Tested:
|
||||
* Theme/Plugin Upgrades/Installs
|
||||
* Core Upgrade
|
||||
* FTP Extension, FTP Sockets, Direct.
|
||||
* Untested:
|
||||
* SSH2 Layer - Needs a good cleanup.
|
||||
* This set of classes are designed to be used to upgrade/install a local set of files on the filesystem via the Filesystem Abstraction classes.
|
||||
*
|
||||
* TODO: Remove this commentblock and replace with some better docs.
|
||||
* @link http://trac.wordpress.org/ticket/7875 consolidate plugin/theme/core upgrade/install functions
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Upgrader
|
||||
* @since 2.8.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* WordPress Upgrader class for Upgrading/Installing a local set of files via the Filesystem Abstraction classes from a Zip file.
|
||||
*
|
||||
* @TODO More Detailed docs, for methods as well.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Upgrader
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class WP_Upgrader {
|
||||
var $strings = array();
|
||||
var $skin = null;
|
||||
|
@ -28,7 +33,11 @@ class WP_Upgrader {
|
|||
$this->skin = new WP_Upgrader_Skin();
|
||||
else
|
||||
$this->skin = $skin;
|
||||
}
|
||||
|
||||
function init() {
|
||||
$this->skin->set_upgrader($this);
|
||||
$this->generic_strings();
|
||||
}
|
||||
|
||||
function generic_strings() {
|
||||
|
@ -323,12 +332,20 @@ class WP_Upgrader {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin Upgrader class for WordPress Plugins, It is designed to upgrade/install plugins from a local zip, remote zip URL, or uploaded zip file.
|
||||
*
|
||||
* @TODO More Detailed docs, for methods as well.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Upgrader
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class Plugin_Upgrader extends WP_Upgrader {
|
||||
|
||||
var $result;
|
||||
|
||||
function upgrade_strings() {
|
||||
$this->generic_strings();
|
||||
$this->strings['up_to_date'] = __('The plugin is at the latest version.');
|
||||
$this->strings['no_package'] = __('Upgrade package not available.');
|
||||
$this->strings['downloading_package'] = __('Downloading update from %s.');
|
||||
|
@ -341,7 +358,6 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
}
|
||||
|
||||
function install_strings() {
|
||||
$this->generic_strings();
|
||||
$this->strings['no_package'] = __('Install package not available.');
|
||||
$this->strings['downloading_package'] = __('Downloading install package from %s.');
|
||||
$this->strings['unpack_package'] = __('Unpacking the package.');
|
||||
|
@ -352,6 +368,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
|
||||
function install($package) {
|
||||
|
||||
$this->init();
|
||||
$this->install_strings();
|
||||
|
||||
$this->run(array(
|
||||
|
@ -369,6 +386,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
|
||||
function upgrade($plugin) {
|
||||
|
||||
$this->init();
|
||||
$this->upgrade_strings();
|
||||
|
||||
$current = get_transient( 'update_plugins' );
|
||||
|
@ -469,13 +487,20 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Theme Upgrader class for WordPress Themes, It is designed to upgrade/install themes from a local zip, remote zip URL, or uploaded zip file.
|
||||
*
|
||||
* @TODO More Detailed docs, for methods as well.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Upgrader
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class Theme_Upgrader extends WP_Upgrader {
|
||||
|
||||
var $result;
|
||||
|
||||
function upgrade_strings() {
|
||||
$this->generic_strings();
|
||||
$this->strings['up_to_date'] = __('The theme is at the latest version.');
|
||||
$this->strings['no_package'] = __('Upgrade package not available.');
|
||||
$this->strings['downloading_package'] = __('Downloading update from %s.');
|
||||
|
@ -487,7 +512,6 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
}
|
||||
|
||||
function install_strings() {
|
||||
$this->generic_strings();
|
||||
$this->strings['no_package'] = __('Install package not available.');
|
||||
$this->strings['downloading_package'] = __('Downloading install package from %s.');
|
||||
$this->strings['unpack_package'] = __('Unpacking the package.');
|
||||
|
@ -497,7 +521,8 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
}
|
||||
|
||||
function install($package) {
|
||||
|
||||
|
||||
$this->init();
|
||||
$this->install_strings();
|
||||
|
||||
$options = array(
|
||||
|
@ -523,6 +548,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
|
||||
function upgrade($theme) {
|
||||
|
||||
$this->init();
|
||||
$this->upgrade_strings();
|
||||
|
||||
// Is an update available?
|
||||
|
@ -616,11 +642,18 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
|
||||
}
|
||||
|
||||
//Untested.
|
||||
/**
|
||||
* Core Upgrader class for WordPress. It allows for WordPress to upgrade itself in combiantion with the wp-admin/includes/update-core.php file
|
||||
*
|
||||
* @TODO More Detailed docs, for methods as well.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Upgrader
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class Core_Upgrader extends WP_Upgrader {
|
||||
|
||||
function upgrade_strings() {
|
||||
$this->generic_strings();
|
||||
$this->strings['up_to_date'] = __('WordPress is at the latest version.');
|
||||
$this->strings['no_package'] = __('Upgrade package not available.');
|
||||
$this->strings['downloading_package'] = __('Downloading update from %s.');
|
||||
|
@ -630,8 +663,9 @@ class Core_Upgrader extends WP_Upgrader {
|
|||
|
||||
function upgrade($current) {
|
||||
global $wp_filesystem;
|
||||
$this->upgrade_strings();
|
||||
|
||||
$this->init();
|
||||
$this->upgrade_strings();
|
||||
|
||||
if ( !empty($feedback) )
|
||||
add_filter('update_feedback', $feedback);
|
||||
|
@ -668,14 +702,15 @@ class Core_Upgrader extends WP_Upgrader {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Skin stuff here.
|
||||
* ============================================
|
||||
* ============================================
|
||||
* ============================================
|
||||
* Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes.
|
||||
*
|
||||
* @TODO More Detailed docs, for methods as well.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Upgrader
|
||||
* @since 2.8.0
|
||||
*/
|
||||
|
||||
class WP_Upgrader_Skin {
|
||||
|
||||
var $upgrader;
|
||||
|
@ -732,7 +767,7 @@ class WP_Upgrader_Skin {
|
|||
}
|
||||
|
||||
function feedback($string) {
|
||||
if ( isset( $this->upgrader->strings[$string]) )
|
||||
if ( isset( $this->upgrader->strings[$string] ) )
|
||||
$string = $this->upgrader->strings[$string];
|
||||
|
||||
if ( strpos($string, '%') !== false ) {
|
||||
|
@ -750,6 +785,15 @@ class WP_Upgrader_Skin {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin Upgrader Skin for WordPress Plugin Upgrades.
|
||||
*
|
||||
* @TODO More Detailed docs, for methods as well.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Upgrader
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
var $plugin = '';
|
||||
var $plugin_active = false;
|
||||
|
@ -790,7 +834,15 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Plugin Installer Skin for WordPress Plugin Installer.
|
||||
*
|
||||
* @TODO More Detailed docs, for methods as well.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Upgrader
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class Plugin_Installer_Skin extends WP_Upgrader_Skin {
|
||||
var $api;
|
||||
var $type;
|
||||
|
@ -829,7 +881,7 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
|
|||
|
||||
|
||||
if ( ! $this->result || is_wp_error($this->result) )
|
||||
unset( $update_actions['activate_plugin'] );
|
||||
unset( $install_actions['activate_plugin'] );
|
||||
|
||||
$install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file);
|
||||
if ( ! empty($install_actions) )
|
||||
|
@ -837,6 +889,15 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme Installer Skin for the WordPress Theme Installer.
|
||||
*
|
||||
* @TODO More Detailed docs, for methods as well.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Upgrader
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
||||
var $api;
|
||||
var $type;
|
||||
|
@ -885,7 +946,7 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
|||
$install_actions['themes_page'] = '<a href="' . admin_url('themes.php') . '" title="' . attribute_escape(__('Themes page')) . '" target="_parent">' . __('Return to Themes page') . '</a>';
|
||||
|
||||
if ( ! $this->result || is_wp_error($this->result) )
|
||||
unset( $update_actions['activate'], $update_actions['preview'] );
|
||||
unset( $install_actions['activate'], $install_actions['preview'] );
|
||||
|
||||
$install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info);
|
||||
if ( ! empty($install_actions) )
|
||||
|
@ -893,6 +954,15 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme Upgrader Skin for WordPress Theme Upgrades.
|
||||
*
|
||||
* @TODO More Detailed docs, for methods as well.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Upgrader
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
var $theme = '';
|
||||
|
||||
|
@ -938,6 +1008,15 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade Skin helper for File uploads. This class handles the upload process and passes it as if its a local file to the Upgrade/Installer functions.
|
||||
*
|
||||
* @TODO More Detailed docs, for methods as well.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Upgrader
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class File_Upload_Upgrader {
|
||||
var $package;
|
||||
var $filename;
|
||||
|
|
Loading…
Reference in New Issue