Make WordPress Core

Ticket #29086: 29086.diff

File 29086.diff, 24.1 KB (added by jdgrimes, 11 years ago)

First run

  • 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 same.
     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();
    2764
     65        /**
     66         * Construct the upgrader with a skin.
     67         *
     68         * @since 2.8.0
     69         *
     70         * @param WP_Upgrader_Skin $skin The upgrader skin to use. Default is a WP_Upgrader_Skin.
     71         */
    2872        public function __construct($skin = null) {
    2973                if ( null == $skin )
    3074                        $this->skin = new WP_Upgrader_Skin();
     
    3276                        $this->skin = $skin;
    3377        }
    3478
     79        /**
     80         * Initialize the upgrader.
     81         *
     82         * This will set the relationship between the skin being used and this upgrader,
     83         * and also add the generic strings to WP_Upgrader::$strings.
     84         *
     85         * @since 2.8.0
     86         */
    3587        public function init() {
    3688                $this->skin->set_upgrader($this);
    3789                $this->generic_strings();
    3890        }
    3991
     92        /**
     93         * Add the generic strings to WP_Upgrader::$strings.
     94         *
     95         * @since 2.8.0
     96         */
    4097        public function generic_strings() {
    4198                $this->strings['bad_request'] = __('Invalid Data provided.');
    4299                $this->strings['fs_unavailable'] = __('Could not access filesystem.');
     
    59116                $this->strings['maintenance_end'] = __('Disabling Maintenance mode…');
    60117        }
    61118
     119        /**
     120         * Connect to the filesystem.
     121         *
     122         * @since 2.8.0
     123         *
     124         * @param array $directories An optional list of directories. If any of these do
     125         *                           not exist, a WP_Error will be returned.
     126         *
     127         * @return bool|WP_Error True if able to connect, false or a WP_Error otherwise.
     128         */
    62129        public function fs_connect( $directories = array() ) {
    63130                global $wp_filesystem;
    64131
     
    106173                return true;
    107174        } //end fs_connect();
    108175
     176        /**
     177         * Download a package.
     178         *
     179         * @since 2.8.0
     180         *
     181         * @param string $package The URI of the package. If this is the full path to an
     182         *                        existing local file, it will be returned untouched.
     183         *
     184         * @return string|WP_Error The full path to the downloaded package file, or a WP_Error.
     185         */
    109186        public function download_package($package) {
    110187
    111188                /**
     
    138215                return $download_file;
    139216        }
    140217
     218        /**
     219         * Unpack a compressed package file.
     220         *
     221         * @since 2.8.0
     222         *
     223         * @param string $package        Full path to the package file.
     224         * @param bool   $delete_package Whether to delete the package file after attempting to unpack it.
     225         *
     226         * @return string|WP_Error The path to the unpacked contents, or a WP_Error on failure.
     227         */
    141228        public function unpack_package($package, $delete_package = true) {
    142229                global $wp_filesystem;
    143230
     
    177264                return $working_dir;
    178265        }
    179266
     267        /**
     268         * Install a package.
     269         *
     270         * Copies the contents of a package form a source directory, and installs them in
     271         * a destination directory. Optionally removes the source. It can also optionally
     272         * clear out the destination folder if it already exists.
     273         *
     274         * @since 2.8.0
     275         *
     276         * @param array $args {
     277         *        @type string $source            Required path to the package source.
     278         *        @type string $destination       Required path to a folder to install the package in.
     279         *        @type bool   $clear_destination Whether to delete any files already in the
     280         *                                        destination folder. Default is false.
     281         *        @type bool   $clear_working     Whether to delete the files form the working
     282         *                                        directory after copying to the destination. Default is false.
     283         *        @type bool   $abort_if_destination_exists Whether to abort the installation if
     284         *                                        the destination folder already exists. Default is true.
     285         *        @type array  $hook_extra        Extra arguments to pass to the filter hooks called by this function.
     286         * }
     287         *
     288         * @return array|WP_Error The result (also stored in self:$result), or a WP_Error on failure.
     289         */
    180290        public function install_package( $args = array() ) {
    181291                global $wp_filesystem, $wp_theme_directories;
    182292
     
    353463                return $this->result;
    354464        }
    355465
     466        /**
     467         * Run an upgrade/install.
     468         *
     469         * Attempts to download the package (if it is not a local file), unpack it, and
     470         * install it in the destination folder.
     471         *
     472         * @since 2.8.0
     473         *
     474         * @param array $options {
     475         *        @type string $package           The full path or URI of the package to install.
     476         *        @type string $destination       The full path to the destination folder.
     477         *        @type bool   $clear_destination Whether to delete any files already in the
     478         *                                        destination folder. Default is false.
     479         *        @type bool   $clear_working     Whether to delete the files form the working
     480         *                                        directory after copying to the destination. Default is false.
     481         *        @type bool   $abort_if_destination_exists Whether to abort the installation if
     482         *                                        the destination folder already exists. When true,
     483         *                                        $clear_destination should be false. Default is true.
     484         *        @type bool   $is_multi          Whether this run is one of multiple upgrade/install
     485         *                                        actions being performed in bulk. When true, the skin
     486         *                                        header() and footer() aren't called. Default is false.
     487         *        @type array  $hook_extra        Extra arguments to pass to the filter hooks called by this function.
     488         * }
     489         *
     490         * @return array|false|WP_error The result from self::install_package() on success, otherwise a WP_Error,
     491         *                              or false if unable to connect to the filesystem.
     492         */
    356493        public function run( $options ) {
    357494
    358495                $defaults = array(
     
    447584                return $result;
    448585        }
    449586
     587        /**
     588         * Toggle maintenance mode for the site.
     589         *
     590         * Creates/deletes the maintenance file to enable/disable maintenance mode.
     591         *
     592         * @since 2.8.0
     593         *
     594         * @param bool $enable True to enable maintenance mode, false to disable.
     595         */
    450596        public function maintenance_mode($enable = false) {
    451597                global $wp_filesystem;
    452598                $file = $wp_filesystem->abspath() . '.maintenance';
     
    473619 */
    474620class Plugin_Upgrader extends WP_Upgrader {
    475621
     622        /**
     623         * @since 2.8.0
     624         *
     625         * @see WP_Upgrader::$result
     626         */
    476627        public $result;
     628
     629        /**
     630         * Whether a bulk upgrade/install is being performed.
     631         *
     632         * @since 2.9.0
     633         *
     634         * @var bool
     635         */
    477636        public $bulk = false;
    478637
     638        /**
     639         * Initialize the upgrade strings.
     640         *
     641         * @since 2.8.0
     642         */
    479643        public function upgrade_strings() {
    480644                $this->strings['up_to_date'] = __('The plugin is at the latest version.');
    481645                $this->strings['no_package'] = __('Update package not available.');
     
    487651                $this->strings['process_success'] = __('Plugin updated successfully.');
    488652        }
    489653
     654        /**
     655         * Initialize the install strings.
     656         *
     657         * @since 2.8.0
     658         */
    490659        public function install_strings() {
    491660                $this->strings['no_package'] = __('Install package not available.');
    492661                $this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>&#8230;');
     
    497666                $this->strings['process_success'] = __('Plugin installed successfully.');
    498667        }
    499668
     669        /**
     670         * Install a plugin package.
     671         *
     672         * @since 2.8.0
     673         * @since 3.7.0 The $args parameter was added, making clearing the plugin update cache optional.
     674         *
     675         * @param string $package The full local path or URI of the package.
     676         * @param array  $args {
     677         *        Other optional arguments.
     678         *
     679         *        @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. Default is true.
     680         * }
     681         *
     682         * @return bool|WP_Error True if the install was successful, false or a WP_Error otherwise.
     683         */
    500684        public function install( $package, $args = array() ) {
    501685
    502686                $defaults = array(
     
    531715                return true;
    532716        }
    533717
     718        /**
     719         * Upgrade a plugin.
     720         *
     721         * @since 2.8.0
     722         * @since 3.7.0 The $args parameter was added, making clearing the plugin update cache optional.
     723         *
     724         * @param string $plugin The basename path to the main plugin file.
     725         * @param array  $args {
     726         *        Other optional arguments.
     727         *
     728         *        @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. Default is true.
     729         * }
     730         *
     731         * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error otherwise.
     732         */
    534733        public function upgrade( $plugin, $args = array() ) {
    535734
    536735                $defaults = array(
     
    582781                return true;
    583782        }
    584783
     784        /**
     785         * Bulk upgrade several plugins at once.
     786         *
     787         * @since 2.8.0
     788         * @since 3.7.0 The $args parameter was added, making clearing the plugin update cache optional.
     789         *
     790         * @param string[] $plugins Array of the basename paths of the plugins' main files.
     791         * @param array  $args {
     792         *        Other optinoal arguments.
     793         *
     794         *        @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. Default is true.
     795         * }
     796         *
     797         * @return array|false An array of results indexed by plugin file, or false if unable to connect to the filesystem.
     798         */
    585799        public function bulk_upgrade( $plugins, $args = array() ) {
    586800
    587801                $defaults = array(
     
    696910                return $results;
    697911        }
    698912
     913        /**
     914         * Check a source package to be sure it contains a plugin.
     915         *
     916         * This function is added to the 'upgrader_source_selection' filter by
     917         * Plugin_Upgrader::install().
     918         *
     919         * @since 3.3.0
     920         *
     921         * @param string $source The path to the downloaded package source.
     922         *
     923         * @return string|WP_Error The source as passed, or a WP_Error if no plugins were found.
     924         */
    699925        public function check_package($source) {
    700926                global $wp_filesystem;
    701927
     
    722948                return $source;
    723949        }
    724950
    725         // Return plugin info.
     951        /**
     952         * Retrieve the path to the file that contains the plugin info.
     953         *
     954         * This isn't used internally in the class, but is called by the skins.
     955         *
     956         * @since 2.8.0
     957         *
     958         * @return string|false The full path to the main plugin file, or false.
     959         */
    726960        public function plugin_info() {
    727961                if ( ! is_array($this->result) )
    728962                        return false;
     
    738972                return $this->result['destination_name'] . '/' . $pluginfiles[0];
    739973        }
    740974
    741         //Hooked to pre_install
     975        /**
     976         * Deactivates a plugin before it is upgraded.
     977         *
     978         * Hooked to the 'upgrader_pre_install' filter by Plugin_Upgrader::upgrade().
     979         *
     980         * @since 2.8.0
     981         */
    742982        public function deactivate_plugin_before_upgrade($return, $plugin) {
    743983
    744984                if ( is_wp_error($return) ) //Bypass.
     
    758998                }
    759999        }
    7601000
    761         //Hooked to upgrade_clear_destination
     1001        /**
     1002         * Delete the old plugin during an upgrade.
     1003         *
     1004         * Hooked to the 'upgrader_clear_destination' filter by
     1005         * Plugin_Upgrader::upgrade() and Plugin_Upgrader::bulk_upgrade().
     1006         *
     1007         * @since 2.8.0
     1008         */
    7621009        public function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) {
    7631010                global $wp_filesystem;
    7641011
     
    7971044 */
    7981045class Theme_Upgrader extends WP_Upgrader {
    7991046
     1047        /**
     1048         * @since 2.8.0
     1049         *
     1050         * @see WP_Upgrader::$result
     1051         */
    8001052        public $result;
     1053
     1054        /**
     1055         * Whether multiple plugins are being upgraded/installed in bulk.
     1056         *
     1057         * @since 2.9.0
     1058         *
     1059         * @var bool
     1060         */
    8011061        public $bulk = false;
    8021062
     1063        /**
     1064         * Initialize the upgrade strings.
     1065         *
     1066         * @since 2.8.0
     1067         */
    8031068        public function upgrade_strings() {
    8041069                $this->strings['up_to_date'] = __('The theme is at the latest version.');
    8051070                $this->strings['no_package'] = __('Update package not available.');
     
    8111076                $this->strings['process_success'] = __('Theme updated successfully.');
    8121077        }
    8131078
     1079        /**
     1080         * Initialize the install strings.
     1081         *
     1082         * @since 2.8.0
     1083         */
    8141084        public function install_strings() {
    8151085                $this->strings['no_package'] = __('Install package not available.');
    8161086                $this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>&#8230;');
     
    8311101                $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.');
    8321102        }
    8331103
     1104        /**
     1105         * Check if a child theme is being installed and we need to install its parent.
     1106         *
     1107         * Hooked to the 'upgrader_post_install' filter by Theme_Upgrader::install().
     1108         *
     1109         * @since 3.4.0
     1110         */
    8341111        public function check_parent_theme_filter($install_result, $hook_extra, $child_result) {
    8351112                // Check to see if we need to install a parent theme
    8361113                $theme_info = $this->theme_info();
     
    8901167                return $install_result;
    8911168        }
    8921169
     1170        /**
     1171         * Don't display the activate and preview actions to the user.
     1172         *
     1173         * Hooked to the 'install_theme_complete_actions' filter by
     1174         * Theme_Upgrader::check_parent_theme_filter() when installing a child theme and
     1175         * installing the parent theme fails.
     1176         *
     1177         * @since 3.4.0
     1178         */
    8931179        public function hide_activate_preview_actions($actions) {
    8941180                unset($actions['activate'], $actions['preview']);
    8951181                return $actions;
    8961182        }
    8971183
     1184        /**
     1185         * Install a theme package.
     1186         *
     1187         * @since 2.8.0
     1188         * @since 3.7.0 The $args parameter was added, making clearing the update cache optional.
     1189         *
     1190         * @param string $package The full local path or URI of the package.
     1191         * @param array  $args {
     1192         *        Other optional arguments.
     1193         *
     1194         *        @type bool $clear_update_cache Whether to clear the updates cache if successful. Default is true.
     1195         * }
     1196         *
     1197         * @return bool|WP_Error True if the install was successful, false or a WP_Error otherwise.
     1198         */
    8981199        public function install( $package, $args = array() ) {
    8991200
    9001201                $defaults = array(
     
    9311232                return true;
    9321233        }
    9331234
     1235        /**
     1236         * Upgrade a theme.
     1237         *
     1238         * @since 2.8.0
     1239         * @since 3.7.0 The $args parameter was added, making clearing the update cache optional.
     1240         *
     1241         * @param string $theme The theme slug.
     1242         * @param array  $args {
     1243         *        Other optional arguments.
     1244         *
     1245         *        @type bool $clear_update_cache Whether to clear the update cache if successful. Default is true.
     1246         * }
     1247         *
     1248         * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error otherwise.
     1249         */
    9341250        public function upgrade( $theme, $args = array() ) {
    9351251
    9361252                $defaults = array(
     
    9811297                return true;
    9821298        }
    9831299
     1300        /**
     1301         * Upgrade several themes at once.
     1302         *
     1303         * @since 3.0.0
     1304         * @since 3.7.0 The $args parameter was added, making clearing the update cache optional.
     1305         *
     1306         * @param string[] $themes The theme slugs.
     1307         * @param array  $args {
     1308         *        Other optional arguments.
     1309         *
     1310         *        @type bool $clear_update_cache Whether to clear the update cache if successful. Default is true.
     1311         * }
     1312         *
     1313         * @return array[]|false An array of results, or false if unable to connect to the filesystem.
     1314         */
    9841315        public function bulk_upgrade( $themes, $args = array() ) {
    9851316
    9861317                $defaults = array(
     
    10821413                return $results;
    10831414        }
    10841415
     1416        /**
     1417         * Check that the package source contains a valid theme.
     1418         *
     1419         * Hooked to the 'upgrader_source_selection' filter by Theme_Upgrader::install().
     1420         * It will return an error if the theme doesn't have style.css or index.php
     1421         * files.
     1422         *
     1423         * @since 3.3.0
     1424         *
     1425         * @param string $source The full path to the package source.
     1426         *
     1427         * @return string|WP_Error The source or a WP_Error.
     1428         */
    10851429        public function check_package($source) {
    10861430                global $wp_filesystem;
    10871431
     
    11091453                return $source;
    11101454        }
    11111455
     1456        /**
     1457         * Turn on maintenance mode before attempting to upgrade the current theme.
     1458         *
     1459         * Hooked to the 'upgrader_pre_install' filter by Theme_Upgrader::upgrade() and
     1460         * Theme_Upgrader::bulk_upgrade().
     1461         *
     1462         * @since 2.8.0
     1463         */
    11121464        public function current_before($return, $theme) {
    11131465
    11141466                if ( is_wp_error($return) )
     
    11251477                return $return;
    11261478        }
    11271479
     1480        /**
     1481         * Turn off maintenance mode after upgrading the current theme.
     1482         *
     1483         * Hooked to the 'upgrader_post_install' filter by Theme_Upgrader::upgrade() and
     1484         * Theme_Upgrader::bulk_upgrade().
     1485         *
     1486         * @since 2.8.0
     1487         */
    11281488        public function current_after($return, $theme) {
    11291489                if ( is_wp_error($return) )
    11301490                        return $return;
     
    11471507                return $return;
    11481508        }
    11491509
     1510        /**
     1511         * Delete the old theme during an upgrade.
     1512         *
     1513         * Hooked to the 'upgrader_clear_destination' filter by Theme_Upgrader::upgrade()
     1514         * and Theme_Upgrader::bulk_upgrade().
     1515         *
     1516         * @since 2.8.0
     1517         */
    11501518        public function delete_old_theme( $removed, $local_destination, $remote_destination, $theme ) {
    11511519                global $wp_filesystem;
    11521520
     
    11661534                return true;
    11671535        }
    11681536
     1537        /**
     1538         * Get the WP_Theme object for a theme.
     1539         *
     1540         * @since 2.8.0
     1541         * @since 3.0.0 The $theme argument was added.
     1542         *
     1543         * @param string $theme The directory name of the theme. This is optional, and if not supplied,
     1544         *                      the directory name from the last result will be used.
     1545         *
     1546         * @return WP_Theme|false The theme's info object, or false $theme is not supplied
     1547         *                        and the last result isn't set.
     1548         */
    11691549        public function theme_info($theme = null) {
    11701550
    11711551                if ( empty($theme) ) {
     
    11901570 */
    11911571class Language_Pack_Upgrader extends WP_Upgrader {
    11921572
     1573        /**
     1574         * @since 3.7.0
     1575         *
     1576         * @see WP_Upgrader::$result
     1577         */
    11931578        public $result;
     1579
     1580        /**
     1581         * Whether a bulk upgrade/install is being performed.
     1582         *
     1583         * @since 3.7.0
     1584         *
     1585         * @var bool
     1586         */
    11941587        public $bulk = true;
    11951588
     1589        /**
     1590         * Asynchronously upgrade language packs after other upgrades have been made.
     1591         *
     1592         * Hooked to the 'upgrader_process_complete' action by default.
     1593         *
     1594         * @since 3.7.0
     1595         */
    11961596        public static function async_upgrade( $upgrader = false ) {
    11971597                // Avoid recursion.
    11981598                if ( $upgrader && $upgrader instanceof Language_Pack_Upgrader )
     
    12111611                $lp_upgrader->upgrade();
    12121612        }
    12131613
     1614        /**
     1615         * Initialize the upgrade strings.
     1616         *
     1617         * @since 3.7.0
     1618         */
    12141619        public function upgrade_strings() {
    12151620                $this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while we update them as well.' );
    12161621                $this->strings['up_to_date'] = __( 'The translation is up to date.' ); // We need to silently skip this case
     
    12211626                $this->strings['process_success'] = __( 'Translation updated successfully.' );
    12221627        }
    12231628
     1629        /**
     1630         * Upgrade a language pack.
     1631         *
     1632         * @since 3.7.0
     1633         *
     1634         * @param string|false $update
     1635         * @param array $args Other optional arguments, see Language_Pack_Upgrader::bulk_upgrade().
     1636         *
     1637         * @return array|WP_Error The result of the upgrade.
     1638         */
    12241639        public function upgrade( $update = false, $args = array() ) {
    12251640                if ( $update )
    12261641                        $update = array( $update );
     
    12281643                return $results[0];
    12291644        }
    12301645
     1646        /**
     1647         * Bulk upgrade language packs.
     1648         *
     1649         * @since 3.7.0
     1650         *
     1651         * @param array $language_updates
     1652         * @param array $args {
     1653         *        Other optional arguments.
     1654         *
     1655         *        @type bool $clear_update_cache Whether to clear the update cache when done. Default is true.
     1656         * }
     1657         *
     1658         * @return array|true|false|WP_Error Will return an array of results, or true if there are no updates,
     1659         *                                   false or WP_Error for initial errors.
     1660         */
    12311661        public function bulk_upgrade( $language_updates = array(), $args = array() ) {
    12321662                global $wp_filesystem;
    12331663
     
    13311761                return $results;
    13321762        }
    13331763
     1764        /**
     1765         * Check the package source to make sure there are .mo and .po files.
     1766         *
     1767         * Hooked to the 'upgrader_source_selection' filter by
     1768         * Language_Pack_Upgrader::bulk_upgrade().
     1769         *
     1770         * @since 3.7.0
     1771         */
    13341772        public function check_package( $source, $remote_source ) {
    13351773                global $wp_filesystem;
    13361774
     
    13561794                return $source;
    13571795        }
    13581796
     1797        /**
     1798         * Get the name of an item being updated.
     1799         *
     1800         * @since 3.7.0
     1801         *
     1802         * @param object The data for an update.
     1803         *
     1804         * @return string The name of the item being updated.
     1805         */
    13591806        public function get_name_for_update( $update ) {
    13601807                switch ( $update->type ) {
    13611808                        case 'core':
     
    13871834 */
    13881835class Core_Upgrader extends WP_Upgrader {
    13891836
     1837        /**
     1838         * Initialize the upgrade strings.
     1839         *
     1840         * @since 2.8.0
     1841         */
    13901842        public function upgrade_strings() {
    13911843                $this->strings['up_to_date'] = __('WordPress is at the latest version.');
    13921844                $this->strings['no_package'] = __('Update package not available.');
     
    13981850                $this->strings['rollback_was_required'] = __( 'Due to an error during updating, WordPress has rolled back to your previous version.' );
    13991851        }
    14001852
     1853        /**
     1854         * Upgrade WordPress core.
     1855         *
     1856         * @since 2.8.0
     1857         *
     1858         * @param  $current
     1859         * @param array $args {
     1860         *        Optional arguments.
     1861         *
     1862         *        @type bool $pre_check_md5    Whether to check the file checksums before attempting the upgrade. Default is true.
     1863         *        @type bool $attempt_rollback Whether to attempt to rollback the chances if there is a problem. Default is false.
     1864         *        @type bool $do_rollback      Whether to perform this "upgrade" as a rollback. Default is false.
     1865         * }
     1866         *
     1867         * @return null|false|WP_Error False or WP_Error on failure, null on success.
     1868         */
    14011869        public function upgrade( $current, $args = array() ) {
    14021870                global $wp_filesystem;
    14031871
     
    15452013                return $result;
    15462014        }
    15472015
    1548         // Determines if this WordPress Core version should update to $offered_ver or not
     2016        /**
     2017         * Determines if this WordPress Core version should update to an offered version or not.
     2018         *
     2019         * @since 3.7.0
     2020         *
     2021         * @param string $offered_ver The offered version, of the format x.y.z.
     2022         *
     2023         * @return bool True if we should update to the offered version, otherwise false.
     2024         */
    15492025        public static function should_update_to_version( $offered_ver /* x.y.z */ ) {
    15502026                include( ABSPATH . WPINC . '/version.php' ); // $wp_version; // x.y.z
    15512027
     
    16442120                return false;
    16452121        }
    16462122
     2123        /**
     2124         * Compare the disk file checksums agains the expected checksums.
     2125         *
     2126         * @since 3.7.0
     2127         *
     2128         * return bool True if the checksums match, otherwise false.
     2129         */
    16472130        public function check_files() {
    16482131                global $wp_version, $wp_local_package;
    16492132
     
    16722155 * @since 2.8.0
    16732156 */
    16742157class File_Upload_Upgrader {
     2158
     2159        /**
     2160         * The full path to the file package.
     2161         *
     2162         * @since 2.8.0
     2163         *
     2164         * @var string
     2165         */
    16752166        public $package;
     2167
     2168        /**
     2169         * The name of the file.
     2170         *
     2171         * @since 2.8.0
     2172         *
     2173         * @var string
     2174         */
    16762175        public $filename;
     2176
     2177        /**
     2178         * The ID of the attachment post for this file.
     2179         *
     2180         * @since 3.3.0
     2181         *
     2182         * @var int
     2183         */
    16772184        public $id = 0;
    16782185
     2186        /**
     2187         * Construct the upgrader for a form.
     2188         *
     2189         * @since 2.8.0
     2190         *
     2191         * @param string $form The name of the form the file was uploaded from.
     2192         * @param string $urlholder The name of the GET parameter that holds the filename.
     2193         */
    16792194        public function __construct($form, $urlholder) {
    16802195
    16812196                if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) )
     
    17272242                }
    17282243        }
    17292244
     2245        /**
     2246         * Delete the attachment/uploaded file.
     2247         *
     2248         * @since 3.2.2
     2249         *
     2250         * @return bool Whether the cleanup was successful.
     2251         */
    17302252        public function cleanup() {
    17312253                if ( $this->id )
    17322254                        wp_delete_attachment( $this->id );