Make WordPress Core


Ignore:
Timestamp:
04/26/2009 06:17:19 PM (16 years ago)
Author:
ryan
Message:

WP_Upgrader updates from DD32. see #7875

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-upgrader.php

    r11084 r11089  
    11<?php
    22/**
    3  * 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.
    4  * It is designed to be as flexible as possible, but some logic may seem rather, crazy to say the least.
    5  * Yes, this header is designed to be replaced before commiting, Hopefully i'll get some proper documentation in here.
    6  *
    7  * This File obviously needs some new PHPDoc, However:
    8  * Tested:
    9  *   Theme/Plugin Upgrades/Installs
    10  *   Core Upgrade
    11  *   FTP Extension, FTP Sockets, Direct.
    12  * Untested:
    13  *   SSH2 Layer - Needs a good cleanup.
    14  *
    15  * TODO: Remove this commentblock and replace with some better docs.
     3 * A File upgrader class for WordPress.
     4 *
     5 * 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.
     6 *
     7 * @link http://trac.wordpress.org/ticket/7875 consolidate plugin/theme/core upgrade/install functions
     8 *
     9 * @package WordPress
     10 * @subpackage Upgrader
     11 * @since 2.8.0
    1612 */
    1713
     14/**
     15 * WordPress Upgrader class for Upgrading/Installing a local set of files via the Filesystem Abstraction classes from a Zip file.
     16 *
     17 * @TODO More Detailed docs, for methods as well.
     18 *
     19 * @package WordPress
     20 * @subpackage Upgrader
     21 * @since 2.8.0
     22 */
    1823class WP_Upgrader {
    1924    var $strings = array();
     
    2934        else
    3035            $this->skin = $skin;
     36    }
     37   
     38    function init() {
    3139        $this->skin->set_upgrader($this);
     40        $this->generic_strings();
    3241    }
    3342
     
    324333}
    325334
     335/**
     336 * Plugin Upgrader class for WordPress Plugins, It is designed to upgrade/install plugins from a local zip, remote zip URL, or uploaded zip file.
     337 *
     338 * @TODO More Detailed docs, for methods as well.
     339 *
     340 * @package WordPress
     341 * @subpackage Upgrader
     342 * @since 2.8.0
     343 */
    326344class Plugin_Upgrader extends WP_Upgrader {
    327345
     
    329347
    330348    function upgrade_strings() {
    331         $this->generic_strings();
    332349        $this->strings['up_to_date'] = __('The plugin is at the latest version.');
    333350        $this->strings['no_package'] = __('Upgrade package not available.');
     
    342359
    343360    function install_strings() {
    344         $this->generic_strings();
    345361        $this->strings['no_package'] = __('Install package not available.');
    346362        $this->strings['downloading_package'] = __('Downloading install package from %s.');
     
    353369    function install($package) {
    354370
     371        $this->init();
    355372        $this->install_strings();
    356373
     
    370387    function upgrade($plugin) {
    371388
     389        $this->init();
    372390        $this->upgrade_strings();
    373391
     
    470488}
    471489
    472 
     490/**
     491 * Theme Upgrader class for WordPress Themes, It is designed to upgrade/install themes from a local zip, remote zip URL, or uploaded zip file.
     492 *
     493 * @TODO More Detailed docs, for methods as well.
     494 *
     495 * @package WordPress
     496 * @subpackage Upgrader
     497 * @since 2.8.0
     498 */
    473499class Theme_Upgrader extends WP_Upgrader {
    474500
     
    476502
    477503    function upgrade_strings() {
    478         $this->generic_strings();
    479504        $this->strings['up_to_date'] = __('The theme is at the latest version.');
    480505        $this->strings['no_package'] = __('Upgrade package not available.');
     
    488513
    489514    function install_strings() {
    490         $this->generic_strings();
    491515        $this->strings['no_package'] = __('Install package not available.');
    492516        $this->strings['downloading_package'] = __('Downloading install package from %s.');
     
    498522
    499523    function install($package) {
    500 
     524       
     525        $this->init();
    501526        $this->install_strings();
    502527
     
    524549    function upgrade($theme) {
    525550
     551        $this->init();
    526552        $this->upgrade_strings();
    527553
     
    617643}
    618644
    619 //Untested.
     645/**
     646 * Core Upgrader class for WordPress. It allows for WordPress to upgrade itself in combiantion with the wp-admin/includes/update-core.php file
     647 *
     648 * @TODO More Detailed docs, for methods as well.
     649 *
     650 * @package WordPress
     651 * @subpackage Upgrader
     652 * @since 2.8.0
     653 */
    620654class Core_Upgrader extends WP_Upgrader {
    621655
    622656    function upgrade_strings() {
    623         $this->generic_strings();
    624657        $this->strings['up_to_date'] = __('WordPress is at the latest version.');
    625658        $this->strings['no_package'] = __('Upgrade package not available.');
     
    631664    function upgrade($current) {
    632665        global $wp_filesystem;
     666
     667        $this->init();
    633668        $this->upgrade_strings();
    634 
    635669
    636670        if ( !empty($feedback) )
     
    669703}
    670704
    671 
    672705/**
    673  * Skin stuff here.
    674  * ============================================
    675  * ============================================
    676  * ============================================
     706 * Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes.
     707 *
     708 * @TODO More Detailed docs, for methods as well.
     709 *
     710 * @package WordPress
     711 * @subpackage Upgrader
     712 * @since 2.8.0
    677713 */
    678 
    679714class WP_Upgrader_Skin {
    680715
     
    733768
    734769    function feedback($string) {
    735         if ( isset( $this->upgrader->strings[$string]) )
     770        if ( isset( $this->upgrader->strings[$string] ) )
    736771            $string = $this->upgrader->strings[$string];
    737772
     
    751786}
    752787
     788/**
     789 * Plugin Upgrader Skin for WordPress Plugin Upgrades.
     790 *
     791 * @TODO More Detailed docs, for methods as well.
     792 *
     793 * @package WordPress
     794 * @subpackage Upgrader
     795 * @since 2.8.0
     796 */
    753797class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
    754798    var $plugin = '';
     
    791835}
    792836
    793 
     837/**
     838 * Plugin Installer Skin for WordPress Plugin Installer.
     839 *
     840 * @TODO More Detailed docs, for methods as well.
     841 *
     842 * @package WordPress
     843 * @subpackage Upgrader
     844 * @since 2.8.0
     845 */
    794846class Plugin_Installer_Skin extends WP_Upgrader_Skin {
    795847    var $api;
     
    830882
    831883        if ( ! $this->result || is_wp_error($this->result) )
    832             unset( $update_actions['activate_plugin'] );
     884            unset( $install_actions['activate_plugin'] );
    833885
    834886        $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file);
     
    838890}
    839891
     892/**
     893 * Theme Installer Skin for the WordPress Theme Installer.
     894 *
     895 * @TODO More Detailed docs, for methods as well.
     896 *
     897 * @package WordPress
     898 * @subpackage Upgrader
     899 * @since 2.8.0
     900 */
    840901class Theme_Installer_Skin extends WP_Upgrader_Skin {
    841902    var $api;
     
    886947
    887948        if ( ! $this->result || is_wp_error($this->result) )
    888             unset( $update_actions['activate'], $update_actions['preview'] );
     949            unset( $install_actions['activate'], $install_actions['preview'] );
    889950
    890951        $install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info);
     
    894955}
    895956
     957/**
     958 * Theme Upgrader Skin for WordPress Theme Upgrades.
     959 *
     960 * @TODO More Detailed docs, for methods as well.
     961 *
     962 * @package WordPress
     963 * @subpackage Upgrader
     964 * @since 2.8.0
     965 */
    896966class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
    897967    var $theme = '';
     
    9391009}
    9401010
     1011/**
     1012 * 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.
     1013 *
     1014 * @TODO More Detailed docs, for methods as well.
     1015 *
     1016 * @package WordPress
     1017 * @subpackage Upgrader
     1018 * @since 2.8.0
     1019 */
    9411020class File_Upload_Upgrader {
    9421021    var $package;
Note: See TracChangeset for help on using the changeset viewer.