Make WordPress Core

Ticket #29086: 29086.2.diff

File 29086.2.diff, 24.8 KB (added by jdgrimes, 10 years ago)
  • src/wp-admin/includes/class-wp-upgrader.php

     
    2121 * @since 2.8.0
    2222 */
    2323class WP_Upgrader {
     24
     25        /**
     26         * The error/notification strings used to update the user on the progress.
     27         *
     28         * @since 2.8.0
     29         *
     30         * @var string[] $strings
     31         */
    2432        public $strings = array();
     33
     34        /**
     35         * The upgrader skin being used.
     36         *
     37         * @since 2.8.0
     38         *
     39         * @var WP_Upgrader_Skin $skin
     40         */
    2541        public $skin = null;
     42
     43        /**
     44         * The result of the installation.
     45         *
     46         * This is set by self::install_package(), only when the package is installed
     47         * successfully. It will then be an array, unless a WP_Error is returned by the
     48         * 'upgrader_post_install' filter. In that case, the WP_Error will be assigned to
     49         * it.
     50         *
     51         * @since 2.8.0
     52         *
     53         * @var WP_Error|array $result {
     54         *      @type string $source The full path to the source the files were installed from.
     55         *      @type string $source_files List of all the files in the source directory.
     56         *      @type string $destination The full path to the install destination folder.
     57         *      @type string $destination_name The name of the destination folder, or empty if $destination and $local_destination are the sa
     58         *      @type string $local_destination The full local path to the destination folder. This is usually the same as $destination.
     59         *      @type string $remote_destination The full remote path to the destination folder (i.e., from $wp_filesystem).
     60         *      @type bool   $clear_destination Whether the destination folder was cleared.
     61         * }
     62         */
    2663        public $result = array();
     64
     65        /**
     66         * The total number of updates being performed.
     67         *
     68         * Set by the bulk update methods.
     69         *
     70         * @since 3.0.0
     71         *
     72         * @var int
     73         */
    2774        public $update_count = 0;
     75
     76        /**
     77         * The current update if multiple updates are being performed.
     78         *
     79         * Used by the bulk update methods, and incremented for each update.
     80         *
     81         * @since 3.0.0
     82         *
     83         * @var int
     84         */
    2885        public $update_current = 0;
    2986
     87        /**
     88         * Construct the upgrader with a skin.
     89         *
     90         * @since 2.8.0
     91         *
     92         * @param WP_Upgrader_Skin $skin The upgrader skin to use. Default is a WP_Upgrader_Skin.
     93         */
    3094        public function __construct($skin = null) {
    3195                if ( null == $skin )
    3296                        $this->skin = new WP_Upgrader_Skin();
     
    3498                        $this->skin = $skin;
    3599        }
    36100
     101        /**
     102         * Initialize the upgrader.
     103         *
     104         * This will set the relationship between the skin being used and this upgrader,
     105         * and also add the generic strings to WP_Upgrader::$strings.
     106         *
     107         * @since 2.8.0
     108         */
    37109        public function init() {
    38110                $this->skin->set_upgrader($this);
    39111                $this->generic_strings();
    40112        }
    41113
     114        /**
     115         * Add the generic strings to WP_Upgrader::$strings.
     116         *
     117         * @since 2.8.0
     118         */
    42119        public function generic_strings() {
    43120                $this->strings['bad_request'] = __('Invalid Data provided.');
    44121                $this->strings['fs_unavailable'] = __('Could not access filesystem.');
     
    61138                $this->strings['maintenance_end'] = __('Disabling Maintenance mode…');
    62139        }
    63140
     141        /**
     142         * Connect to the filesystem.
     143         *
     144         * @since 2.8.0
     145         *
     146         * @param array $directories An optional list of directories. If any of these do
     147         *                           not exist, a WP_Error will be returned.
     148         *
     149         * @return bool|WP_Error True if able to connect, false or a WP_Error otherwise.
     150         */
    64151        public function fs_connect( $directories = array(), $allow_relaxed_file_ownership = false ) {
    65152                global $wp_filesystem;
    66153
     
    110197                return true;
    111198        } //end fs_connect();
    112199
     200        /**
     201         * Download a package.
     202         *
     203         * @since 2.8.0
     204         *
     205         * @param string $package The URI of the package. If this is the full path to an
     206         *                        existing local file, it will be returned untouched.
     207         *
     208         * @return string|WP_Error The full path to the downloaded package file, or a WP_Error.
     209         */
    113210        public function download_package($package) {
    114211
    115212                /**
     
    142239                return $download_file;
    143240        }
    144241
     242        /**
     243         * Unpack a compressed package file.
     244         *
     245         * @since 2.8.0
     246         *
     247         * @param string $package        Full path to the package file.
     248         * @param bool   $delete_package Whether to delete the package file after attempting to unpack it.
     249         *
     250         * @return string|WP_Error The path to the unpacked contents, or a WP_Error on failure.
     251         */
    145252        public function unpack_package($package, $delete_package = true) {
    146253                global $wp_filesystem;
    147254
     
    181288                return $working_dir;
    182289        }
    183290
     291        /**
     292         * Install a package.
     293         *
     294         * Copies the contents of a package form a source directory, and installs them in
     295         * a destination directory. Optionally removes the source. It can also optionally
     296         * clear out the destination folder if it already exists.
     297         *
     298         * @since 2.8.0
     299         *
     300         * @param array $args {
     301         *        @type string $source            Required path to the package source.
     302         *        @type string $destination       Required path to a folder to install the package in.
     303         *        @type bool   $clear_destination Whether to delete any files already in the
     304         *                                        destination folder. Default is false.
     305         *        @type bool   $clear_working     Whether to delete the files form the working
     306         *                                        directory after copying to the destination. Default is false.
     307         *        @type bool   $abort_if_destination_exists Whether to abort the installation if
     308         *                                        the destination folder already exists. Default is true.
     309         *        @type array  $hook_extra        Extra arguments to pass to the filter hooks called by this function.
     310         * }
     311         *
     312         * @return array|WP_Error The result (also stored in self:$result), or a WP_Error on failure.
     313         */
    184314        public function install_package( $args = array() ) {
    185315                global $wp_filesystem, $wp_theme_directories;
    186316
     
    357487                return $this->result;
    358488        }
    359489
     490        /**
     491         * Run an upgrade/install.
     492         *
     493         * Attempts to download the package (if it is not a local file), unpack it, and
     494         * install it in the destination folder.
     495         *
     496         * @since 2.8.0
     497         *
     498         * @param array $options {
     499         *        @type string $package           The full path or URI of the package to install.
     500         *        @type string $destination       The full path to the destination folder.
     501         *        @type bool   $clear_destination Whether to delete any files already in the
     502         *                                        destination folder. Default is false.
     503         *        @type bool   $clear_working     Whether to delete the files form the working
     504         *                                        directory after copying to the destination. Default is false.
     505         *        @type bool   $abort_if_destination_exists Whether to abort the installation if
     506         *                                        the destination folder already exists. When true,
     507         *                                        $clear_destination should be false. Default is true.
     508         *        @type bool   $is_multi          Whether this run is one of multiple upgrade/install
     509         *                                        actions being performed in bulk. When true, the skin
     510         *                                        header() and footer() aren't called. Default is false.
     511         *        @type array  $hook_extra        Extra arguments to pass to the filter hooks called by this function.
     512         * }
     513         *
     514         * @return array|false|WP_error The result from self::install_package() on success, otherwise a WP_Error,
     515         *                              or false if unable to connect to the filesystem.
     516         */
    360517        public function run( $options ) {
    361518
    362519                $defaults = array(
     
    451608                return $result;
    452609        }
    453610
     611        /**
     612         * Toggle maintenance mode for the site.
     613         *
     614         * Creates/deletes the maintenance file to enable/disable maintenance mode.
     615         *
     616         * @since 2.8.0
     617         *
     618         * @param bool $enable True to enable maintenance mode, false to disable.
     619         */
    454620        public function maintenance_mode($enable = false) {
    455621                global $wp_filesystem;
    456622                $file = $wp_filesystem->abspath() . '.maintenance';
     
    477643 */
    478644class Plugin_Upgrader extends WP_Upgrader {
    479645
     646        /**
     647         * @since 2.8.0
     648         *
     649         * @see WP_Upgrader::$result
     650         */
    480651        public $result;
     652
     653        /**
     654         * Whether a bulk upgrade/install is being performed.
     655         *
     656         * @since 2.9.0
     657         *
     658         * @var bool
     659         */
    481660        public $bulk = false;
    482661
     662        /**
     663         * Initialize the upgrade strings.
     664         *
     665         * @since 2.8.0
     666         */
    483667        public function upgrade_strings() {
    484668                $this->strings['up_to_date'] = __('The plugin is at the latest version.');
    485669                $this->strings['no_package'] = __('Update package not available.');
     
    491675                $this->strings['process_success'] = __('Plugin updated successfully.');
    492676        }
    493677
     678        /**
     679         * Initialize the install strings.
     680         *
     681         * @since 2.8.0
     682         */
    494683        public function install_strings() {
    495684                $this->strings['no_package'] = __('Install package not available.');
    496685                $this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>&#8230;');
     
    501690                $this->strings['process_success'] = __('Plugin installed successfully.');
    502691        }
    503692
     693        /**
     694         * Install a plugin package.
     695         *
     696         * @since 2.8.0
     697         * @since 3.7.0 The $args parameter was added, making clearing the plugin update cache optional.
     698         *
     699         * @param string $package The full local path or URI of the package.
     700         * @param array  $args {
     701         *        Other optional arguments.
     702         *
     703         *        @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. Default is true.
     704         * }
     705         *
     706         * @return bool|WP_Error True if the install was successful, false or a WP_Error otherwise.
     707         */
    504708        public function install( $package, $args = array() ) {
    505709
    506710                $defaults = array(
     
    535739                return true;
    536740        }
    537741
     742        /**
     743         * Upgrade a plugin.
     744         *
     745         * @since 2.8.0
     746         * @since 3.7.0 The $args parameter was added, making clearing the plugin update cache optional.
     747         *
     748         * @param string $plugin The basename path to the main plugin file.
     749         * @param array  $args {
     750         *        Other optional arguments.
     751         *
     752         *        @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. Default is true.
     753         * }
     754         *
     755         * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error otherwise.
     756         */
    538757        public function upgrade( $plugin, $args = array() ) {
    539758
    540759                $defaults = array(
     
    586805                return true;
    587806        }
    588807
     808        /**
     809         * Bulk upgrade several plugins at once.
     810         *
     811         * @since 2.8.0
     812         * @since 3.7.0 The $args parameter was added, making clearing the plugin update cache optional.
     813         *
     814         * @param string[] $plugins Array of the basename paths of the plugins' main files.
     815         * @param array  $args {
     816         *        Other optinoal arguments.
     817         *
     818         *        @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. Default is true.
     819         * }
     820         *
     821         * @return array|false An array of results indexed by plugin file, or false if unable to connect to the filesystem.
     822         */
    589823        public function bulk_upgrade( $plugins, $args = array() ) {
    590824
    591825                $defaults = array(
     
    700934                return $results;
    701935        }
    702936
     937        /**
     938         * Check a source package to be sure it contains a plugin.
     939         *
     940         * This function is added to the 'upgrader_source_selection' filter by
     941         * Plugin_Upgrader::install().
     942         *
     943         * @since 3.3.0
     944         *
     945         * @param string $source The path to the downloaded package source.
     946         *
     947         * @return string|WP_Error The source as passed, or a WP_Error if no plugins were found.
     948         */
    703949        public function check_package($source) {
    704950                global $wp_filesystem;
    705951
     
    726972                return $source;
    727973        }
    728974
    729         // Return plugin info.
     975        /**
     976         * Retrieve the path to the file that contains the plugin info.
     977         *
     978         * This isn't used internally in the class, but is called by the skins.
     979         *
     980         * @since 2.8.0
     981         *
     982         * @return string|false The full path to the main plugin file, or false.
     983         */
    730984        public function plugin_info() {
    731985                if ( ! is_array($this->result) )
    732986                        return false;
     
    742996                return $this->result['destination_name'] . '/' . $pluginfiles[0];
    743997        }
    744998
    745         //Hooked to pre_install
     999        /**
     1000         * Deactivates a plugin before it is upgraded.
     1001         *
     1002         * Hooked to the 'upgrader_pre_install' filter by Plugin_Upgrader::upgrade().
     1003         *
     1004         * @since 2.8.0
     1005         */
    7461006        public function deactivate_plugin_before_upgrade($return, $plugin) {
    7471007
    7481008                if ( is_wp_error($return) ) //Bypass.
     
    7621022                }
    7631023        }
    7641024
    765         //Hooked to upgrade_clear_destination
     1025        /**
     1026         * Delete the old plugin during an upgrade.
     1027         *
     1028         * Hooked to the 'upgrader_clear_destination' filter by
     1029         * Plugin_Upgrader::upgrade() and Plugin_Upgrader::bulk_upgrade().
     1030         *
     1031         * @since 2.8.0
     1032         */
    7661033        public function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) {
    7671034                global $wp_filesystem;
    7681035
     
    8011068 */
    8021069class Theme_Upgrader extends WP_Upgrader {
    8031070
     1071        /**
     1072         * @since 2.8.0
     1073         *
     1074         * @see WP_Upgrader::$result
     1075         */
    8041076        public $result;
     1077
     1078        /**
     1079         * Whether multiple plugins are being upgraded/installed in bulk.
     1080         *
     1081         * @since 2.9.0
     1082         *
     1083         * @var bool
     1084         */
    8051085        public $bulk = false;
    8061086
     1087        /**
     1088         * Initialize the upgrade strings.
     1089         *
     1090         * @since 2.8.0
     1091         */
    8071092        public function upgrade_strings() {
    8081093                $this->strings['up_to_date'] = __('The theme is at the latest version.');
    8091094                $this->strings['no_package'] = __('Update package not available.');
     
    8151100                $this->strings['process_success'] = __('Theme updated successfully.');
    8161101        }
    8171102
     1103        /**
     1104         * Initialize the install strings.
     1105         *
     1106         * @since 2.8.0
     1107         */
    8181108        public function install_strings() {
    8191109                $this->strings['no_package'] = __('Install package not available.');
    8201110                $this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>&#8230;');
     
    8351125                $this->strings['parent_theme_not_found'] = __('<strong>The parent theme could not be found.</strong> You will need to install the parent theme, <strong>%s</strong>, before you can use this child theme.');
    8361126        }
    8371127
     1128        /**
     1129         * Check if a child theme is being installed and we need to install its parent.
     1130         *
     1131         * Hooked to the 'upgrader_post_install' filter by Theme_Upgrader::install().
     1132         *
     1133         * @since 3.4.0
     1134         */
    8381135        public function check_parent_theme_filter($install_result, $hook_extra, $child_result) {
    8391136                // Check to see if we need to install a parent theme
    8401137                $theme_info = $this->theme_info();
     
    8941191                return $install_result;
    8951192        }
    8961193
     1194        /**
     1195         * Don't display the activate and preview actions to the user.
     1196         *
     1197         * Hooked to the 'install_theme_complete_actions' filter by
     1198         * Theme_Upgrader::check_parent_theme_filter() when installing a child theme and
     1199         * installing the parent theme fails.
     1200         *
     1201         * @since 3.4.0
     1202         */
    8971203        public function hide_activate_preview_actions($actions) {
    8981204                unset($actions['activate'], $actions['preview']);
    8991205                return $actions;
    9001206        }
    9011207
     1208        /**
     1209         * Install a theme package.
     1210         *
     1211         * @since 2.8.0
     1212         * @since 3.7.0 The $args parameter was added, making clearing the update cache optional.
     1213         *
     1214         * @param string $package The full local path or URI of the package.
     1215         * @param array  $args {
     1216         *        Other optional arguments.
     1217         *
     1218         *        @type bool $clear_update_cache Whether to clear the updates cache if successful. Default is true.
     1219         * }
     1220         *
     1221         * @return bool|WP_Error True if the install was successful, false or a WP_Error otherwise.
     1222         */
    9021223        public function install( $package, $args = array() ) {
    9031224
    9041225                $defaults = array(
     
    9351256                return true;
    9361257        }
    9371258
     1259        /**
     1260         * Upgrade a theme.
     1261         *
     1262         * @since 2.8.0
     1263         * @since 3.7.0 The $args parameter was added, making clearing the update cache optional.
     1264         *
     1265         * @param string $theme The theme slug.
     1266         * @param array  $args {
     1267         *        Other optional arguments.
     1268         *
     1269         *        @type bool $clear_update_cache Whether to clear the update cache if successful. Default is true.
     1270         * }
     1271         *
     1272         * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error otherwise.
     1273         */
    9381274        public function upgrade( $theme, $args = array() ) {
    9391275
    9401276                $defaults = array(
     
    9851321                return true;
    9861322        }
    9871323
     1324        /**
     1325         * Upgrade several themes at once.
     1326         *
     1327         * @since 3.0.0
     1328         * @since 3.7.0 The $args parameter was added, making clearing the update cache optional.
     1329         *
     1330         * @param string[] $themes The theme slugs.
     1331         * @param array  $args {
     1332         *        Other optional arguments.
     1333         *
     1334         *        @type bool $clear_update_cache Whether to clear the update cache if successful. Default is true.
     1335         * }
     1336         *
     1337         * @return array[]|false An array of results, or false if unable to connect to the filesystem.
     1338         */
    9881339        public function bulk_upgrade( $themes, $args = array() ) {
    9891340
    9901341                $defaults = array(
     
    10871438                return $results;
    10881439        }
    10891440
     1441        /**
     1442         * Check that the package source contains a valid theme.
     1443         *
     1444         * Hooked to the 'upgrader_source_selection' filter by Theme_Upgrader::install().
     1445         * It will return an error if the theme doesn't have style.css or index.php
     1446         * files.
     1447         *
     1448         * @since 3.3.0
     1449         *
     1450         * @param string $source The full path to the package source.
     1451         *
     1452         * @return string|WP_Error The source or a WP_Error.
     1453         */
    10901454        public function check_package($source) {
    10911455                global $wp_filesystem;
    10921456
     
    11141478                return $source;
    11151479        }
    11161480
     1481        /**
     1482         * Turn on maintenance mode before attempting to upgrade the current theme.
     1483         *
     1484         * Hooked to the 'upgrader_pre_install' filter by Theme_Upgrader::upgrade() and
     1485         * Theme_Upgrader::bulk_upgrade().
     1486         *
     1487         * @since 2.8.0
     1488         */
    11171489        public function current_before($return, $theme) {
    11181490
    11191491                if ( is_wp_error($return) )
     
    11301502                return $return;
    11311503        }
    11321504
     1505        /**
     1506         * Turn off maintenance mode after upgrading the current theme.
     1507         *
     1508         * Hooked to the 'upgrader_post_install' filter by Theme_Upgrader::upgrade() and
     1509         * Theme_Upgrader::bulk_upgrade().
     1510         *
     1511         * @since 2.8.0
     1512         */
    11331513        public function current_after($return, $theme) {
    11341514                if ( is_wp_error($return) )
    11351515                        return $return;
     
    11521532                return $return;
    11531533        }
    11541534
     1535        /**
     1536         * Delete the old theme during an upgrade.
     1537         *
     1538         * Hooked to the 'upgrader_clear_destination' filter by Theme_Upgrader::upgrade()
     1539         * and Theme_Upgrader::bulk_upgrade().
     1540         *
     1541         * @since 2.8.0
     1542         */
    11551543        public function delete_old_theme( $removed, $local_destination, $remote_destination, $theme ) {
    11561544                global $wp_filesystem;
    11571545
     
    11711559                return true;
    11721560        }
    11731561
     1562        /**
     1563         * Get the WP_Theme object for a theme.
     1564         *
     1565         * @since 2.8.0
     1566         * @since 3.0.0 The $theme argument was added.
     1567         *
     1568         * @param string $theme The directory name of the theme. This is optional, and if not supplied,
     1569         *                      the directory name from the last result will be used.
     1570         *
     1571         * @return WP_Theme|false The theme's info object, or false $theme is not supplied
     1572         *                        and the last result isn't set.
     1573         */
    11741574        public function theme_info($theme = null) {
    11751575
    11761576                if ( empty($theme) ) {
     
    11951595 */
    11961596class Language_Pack_Upgrader extends WP_Upgrader {
    11971597
     1598        /**
     1599         * @since 3.7.0
     1600         *
     1601         * @see WP_Upgrader::$result
     1602         */
    11981603        public $result;
     1604
     1605        /**
     1606         * Whether a bulk upgrade/install is being performed.
     1607         *
     1608         * @since 3.7.0
     1609         *
     1610         * @var bool
     1611         */
    11991612        public $bulk = true;
    12001613
     1614        /**
     1615         * Asynchronously upgrade language packs after other upgrades have been made.
     1616         *
     1617         * Hooked to the 'upgrader_process_complete' action by default.
     1618         *
     1619         * @since 3.7.0
     1620         */
    12011621        public static function async_upgrade( $upgrader = false ) {
    12021622                // Avoid recursion.
    12031623                if ( $upgrader && $upgrader instanceof Language_Pack_Upgrader ) {
     
    12471667                $lp_upgrader->bulk_upgrade( $language_updates );
    12481668        }
    12491669
     1670        /**
     1671         * Initialize the upgrade strings.
     1672         *
     1673         * @since 3.7.0
     1674         */
    12501675        public function upgrade_strings() {
    12511676                $this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while we update them as well.' );
    12521677                $this->strings['up_to_date'] = __( 'The translation is up to date.' ); // We need to silently skip this case
     
    12571682                $this->strings['process_success'] = __( 'Translation updated successfully.' );
    12581683        }
    12591684
     1685        /**
     1686         * Upgrade a language pack.
     1687         *
     1688         * @since 3.7.0
     1689         *
     1690         * @param string|false $update
     1691         * @param array $args Other optional arguments, see Language_Pack_Upgrader::bulk_upgrade().
     1692         *
     1693         * @return array|WP_Error The result of the upgrade.
     1694         */
    12601695        public function upgrade( $update = false, $args = array() ) {
    12611696                if ( $update ) {
    12621697                        $update = array( $update );
     
    12711706                return $results[0];
    12721707        }
    12731708
     1709        /**
     1710         * Bulk upgrade language packs.
     1711         *
     1712         * @since 3.7.0
     1713         *
     1714         * @param array $language_updates
     1715         * @param array $args {
     1716         *        Other optional arguments.
     1717         *
     1718         *        @type bool $clear_update_cache Whether to clear the update cache when done. Default is true.
     1719         * }
     1720         *
     1721         * @return array|true|false|WP_Error Will return an array of results, or true if there are no updates,
     1722         *                                   false or WP_Error for initial errors.
     1723         */
    12741724        public function bulk_upgrade( $language_updates = array(), $args = array() ) {
    12751725                global $wp_filesystem;
    12761726
     
    13781828                return $results;
    13791829        }
    13801830
     1831        /**
     1832         * Check the package source to make sure there are .mo and .po files.
     1833         *
     1834         * Hooked to the 'upgrader_source_selection' filter by
     1835         * Language_Pack_Upgrader::bulk_upgrade().
     1836         *
     1837         * @since 3.7.0
     1838         */
    13811839        public function check_package( $source, $remote_source ) {
    13821840                global $wp_filesystem;
    13831841
     
    14031861                return $source;
    14041862        }
    14051863
     1864        /**
     1865         * Get the name of an item being updated.
     1866         *
     1867         * @since 3.7.0
     1868         *
     1869         * @param object The data for an update.
     1870         *
     1871         * @return string The name of the item being updated.
     1872         */
    14061873        public function get_name_for_update( $update ) {
    14071874                switch ( $update->type ) {
    14081875                        case 'core':
     
    14341901 */
    14351902class Core_Upgrader extends WP_Upgrader {
    14361903
     1904        /**
     1905         * Initialize the upgrade strings.
     1906         *
     1907         * @since 2.8.0
     1908         */
    14371909        public function upgrade_strings() {
    14381910                $this->strings['up_to_date'] = __('WordPress is at the latest version.');
    14391911                $this->strings['no_package'] = __('Update package not available.');
     
    14451917                $this->strings['rollback_was_required'] = __( 'Due to an error during updating, WordPress has rolled back to your previous version.' );
    14461918        }
    14471919
     1920        /**
     1921         * Upgrade WordPress core.
     1922         *
     1923         * @since 2.8.0
     1924         *
     1925         * @param  $current
     1926         * @param array $args {
     1927         *        Optional arguments.
     1928         *
     1929         *        @type bool $pre_check_md5    Whether to check the file checksums before attempting the upgrade. Default is true.
     1930         *        @type bool $attempt_rollback Whether to attempt to rollback the chances if there is a problem. Default is false.
     1931         *        @type bool $do_rollback      Whether to perform this "upgrade" as a rollback. Default is false.
     1932         * }
     1933         *
     1934         * @return null|false|WP_Error False or WP_Error on failure, null on success.
     1935         */
    14481936        public function upgrade( $current, $args = array() ) {
    14491937                global $wp_filesystem;
    14501938
     
    15932081                return $result;
    15942082        }
    15952083
    1596         // Determines if this WordPress Core version should update to $offered_ver or not
     2084        /**
     2085         * Determines if this WordPress Core version should update to an offered version or not.
     2086         *
     2087         * @since 3.7.0
     2088         *
     2089         * @param string $offered_ver The offered version, of the format x.y.z.
     2090         *
     2091         * @return bool True if we should update to the offered version, otherwise false.
     2092         */
    15972093        public static function should_update_to_version( $offered_ver /* x.y.z */ ) {
    15982094                include( ABSPATH . WPINC . '/version.php' ); // $wp_version; // x.y.z
    15992095
     
    16922188                return false;
    16932189        }
    16942190
     2191        /**
     2192         * Compare the disk file checksums agains the expected checksums.
     2193         *
     2194         * @since 3.7.0
     2195         *
     2196         * return bool True if the checksums match, otherwise false.
     2197         */
    16952198        public function check_files() {
    16962199                global $wp_version, $wp_local_package;
    16972200
     
    17202223 * @since 2.8.0
    17212224 */
    17222225class File_Upload_Upgrader {
     2226
     2227        /**
     2228         * The full path to the file package.
     2229         *
     2230         * @since 2.8.0
     2231         *
     2232         * @var string
     2233         */
    17232234        public $package;
     2235
     2236        /**
     2237         * The name of the file.
     2238         *
     2239         * @since 2.8.0
     2240         *
     2241         * @var string
     2242         */
    17242243        public $filename;
     2244
     2245        /**
     2246         * The ID of the attachment post for this file.
     2247         *
     2248         * @since 3.3.0
     2249         *
     2250         * @var int
     2251         */
    17252252        public $id = 0;
    17262253
     2254        /**
     2255         * Construct the upgrader for a form.
     2256         *
     2257         * @since 2.8.0
     2258         *
     2259         * @param string $form The name of the form the file was uploaded from.
     2260         * @param string $urlholder The name of the GET parameter that holds the filename.
     2261         */
    17272262        public function __construct($form, $urlholder) {
    17282263
    17292264                if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) )
     
    17752310                }
    17762311        }
    17772312
     2313        /**
     2314         * Delete the attachment/uploaded file.
     2315         *
     2316         * @since 3.2.2
     2317         *
     2318         * @return bool Whether the cleanup was successful.
     2319         */
    17782320        public function cleanup() {
    17792321                if ( $this->id )
    17802322                        wp_delete_attachment( $this->id );
     
    20932635                        'attempt_rollback'   => true,
    20942636                        // Allow relaxed file ownership in some scenarios
    20952637                        'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
    2096                        
     2638
    20972639                ) );
    20982640
    20992641                // If the filesystem is unavailable, false is returned.