Ticket #29086: 29086.2.diff
File 29086.2.diff, 24.8 KB (added by , 10 years ago) |
---|
-
src/wp-admin/includes/class-wp-upgrader.php
21 21 * @since 2.8.0 22 22 */ 23 23 class 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 */ 24 32 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 */ 25 41 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 */ 26 63 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 */ 27 74 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 */ 28 85 public $update_current = 0; 29 86 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 */ 30 94 public function __construct($skin = null) { 31 95 if ( null == $skin ) 32 96 $this->skin = new WP_Upgrader_Skin(); … … 34 98 $this->skin = $skin; 35 99 } 36 100 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 */ 37 109 public function init() { 38 110 $this->skin->set_upgrader($this); 39 111 $this->generic_strings(); 40 112 } 41 113 114 /** 115 * Add the generic strings to WP_Upgrader::$strings. 116 * 117 * @since 2.8.0 118 */ 42 119 public function generic_strings() { 43 120 $this->strings['bad_request'] = __('Invalid Data provided.'); 44 121 $this->strings['fs_unavailable'] = __('Could not access filesystem.'); … … 61 138 $this->strings['maintenance_end'] = __('Disabling Maintenance mode…'); 62 139 } 63 140 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 */ 64 151 public function fs_connect( $directories = array(), $allow_relaxed_file_ownership = false ) { 65 152 global $wp_filesystem; 66 153 … … 110 197 return true; 111 198 } //end fs_connect(); 112 199 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 */ 113 210 public function download_package($package) { 114 211 115 212 /** … … 142 239 return $download_file; 143 240 } 144 241 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 */ 145 252 public function unpack_package($package, $delete_package = true) { 146 253 global $wp_filesystem; 147 254 … … 181 288 return $working_dir; 182 289 } 183 290 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 */ 184 314 public function install_package( $args = array() ) { 185 315 global $wp_filesystem, $wp_theme_directories; 186 316 … … 357 487 return $this->result; 358 488 } 359 489 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 */ 360 517 public function run( $options ) { 361 518 362 519 $defaults = array( … … 451 608 return $result; 452 609 } 453 610 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 */ 454 620 public function maintenance_mode($enable = false) { 455 621 global $wp_filesystem; 456 622 $file = $wp_filesystem->abspath() . '.maintenance'; … … 477 643 */ 478 644 class Plugin_Upgrader extends WP_Upgrader { 479 645 646 /** 647 * @since 2.8.0 648 * 649 * @see WP_Upgrader::$result 650 */ 480 651 public $result; 652 653 /** 654 * Whether a bulk upgrade/install is being performed. 655 * 656 * @since 2.9.0 657 * 658 * @var bool 659 */ 481 660 public $bulk = false; 482 661 662 /** 663 * Initialize the upgrade strings. 664 * 665 * @since 2.8.0 666 */ 483 667 public function upgrade_strings() { 484 668 $this->strings['up_to_date'] = __('The plugin is at the latest version.'); 485 669 $this->strings['no_package'] = __('Update package not available.'); … … 491 675 $this->strings['process_success'] = __('Plugin updated successfully.'); 492 676 } 493 677 678 /** 679 * Initialize the install strings. 680 * 681 * @since 2.8.0 682 */ 494 683 public function install_strings() { 495 684 $this->strings['no_package'] = __('Install package not available.'); 496 685 $this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>…'); … … 501 690 $this->strings['process_success'] = __('Plugin installed successfully.'); 502 691 } 503 692 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 */ 504 708 public function install( $package, $args = array() ) { 505 709 506 710 $defaults = array( … … 535 739 return true; 536 740 } 537 741 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 */ 538 757 public function upgrade( $plugin, $args = array() ) { 539 758 540 759 $defaults = array( … … 586 805 return true; 587 806 } 588 807 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 */ 589 823 public function bulk_upgrade( $plugins, $args = array() ) { 590 824 591 825 $defaults = array( … … 700 934 return $results; 701 935 } 702 936 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 */ 703 949 public function check_package($source) { 704 950 global $wp_filesystem; 705 951 … … 726 972 return $source; 727 973 } 728 974 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 */ 730 984 public function plugin_info() { 731 985 if ( ! is_array($this->result) ) 732 986 return false; … … 742 996 return $this->result['destination_name'] . '/' . $pluginfiles[0]; 743 997 } 744 998 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 */ 746 1006 public function deactivate_plugin_before_upgrade($return, $plugin) { 747 1007 748 1008 if ( is_wp_error($return) ) //Bypass. … … 762 1022 } 763 1023 } 764 1024 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 */ 766 1033 public function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) { 767 1034 global $wp_filesystem; 768 1035 … … 801 1068 */ 802 1069 class Theme_Upgrader extends WP_Upgrader { 803 1070 1071 /** 1072 * @since 2.8.0 1073 * 1074 * @see WP_Upgrader::$result 1075 */ 804 1076 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 */ 805 1085 public $bulk = false; 806 1086 1087 /** 1088 * Initialize the upgrade strings. 1089 * 1090 * @since 2.8.0 1091 */ 807 1092 public function upgrade_strings() { 808 1093 $this->strings['up_to_date'] = __('The theme is at the latest version.'); 809 1094 $this->strings['no_package'] = __('Update package not available.'); … … 815 1100 $this->strings['process_success'] = __('Theme updated successfully.'); 816 1101 } 817 1102 1103 /** 1104 * Initialize the install strings. 1105 * 1106 * @since 2.8.0 1107 */ 818 1108 public function install_strings() { 819 1109 $this->strings['no_package'] = __('Install package not available.'); 820 1110 $this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>…'); … … 835 1125 $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.'); 836 1126 } 837 1127 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 */ 838 1135 public function check_parent_theme_filter($install_result, $hook_extra, $child_result) { 839 1136 // Check to see if we need to install a parent theme 840 1137 $theme_info = $this->theme_info(); … … 894 1191 return $install_result; 895 1192 } 896 1193 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 */ 897 1203 public function hide_activate_preview_actions($actions) { 898 1204 unset($actions['activate'], $actions['preview']); 899 1205 return $actions; 900 1206 } 901 1207 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 */ 902 1223 public function install( $package, $args = array() ) { 903 1224 904 1225 $defaults = array( … … 935 1256 return true; 936 1257 } 937 1258 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 */ 938 1274 public function upgrade( $theme, $args = array() ) { 939 1275 940 1276 $defaults = array( … … 985 1321 return true; 986 1322 } 987 1323 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 */ 988 1339 public function bulk_upgrade( $themes, $args = array() ) { 989 1340 990 1341 $defaults = array( … … 1087 1438 return $results; 1088 1439 } 1089 1440 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 */ 1090 1454 public function check_package($source) { 1091 1455 global $wp_filesystem; 1092 1456 … … 1114 1478 return $source; 1115 1479 } 1116 1480 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 */ 1117 1489 public function current_before($return, $theme) { 1118 1490 1119 1491 if ( is_wp_error($return) ) … … 1130 1502 return $return; 1131 1503 } 1132 1504 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 */ 1133 1513 public function current_after($return, $theme) { 1134 1514 if ( is_wp_error($return) ) 1135 1515 return $return; … … 1152 1532 return $return; 1153 1533 } 1154 1534 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 */ 1155 1543 public function delete_old_theme( $removed, $local_destination, $remote_destination, $theme ) { 1156 1544 global $wp_filesystem; 1157 1545 … … 1171 1559 return true; 1172 1560 } 1173 1561 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 */ 1174 1574 public function theme_info($theme = null) { 1175 1575 1176 1576 if ( empty($theme) ) { … … 1195 1595 */ 1196 1596 class Language_Pack_Upgrader extends WP_Upgrader { 1197 1597 1598 /** 1599 * @since 3.7.0 1600 * 1601 * @see WP_Upgrader::$result 1602 */ 1198 1603 public $result; 1604 1605 /** 1606 * Whether a bulk upgrade/install is being performed. 1607 * 1608 * @since 3.7.0 1609 * 1610 * @var bool 1611 */ 1199 1612 public $bulk = true; 1200 1613 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 */ 1201 1621 public static function async_upgrade( $upgrader = false ) { 1202 1622 // Avoid recursion. 1203 1623 if ( $upgrader && $upgrader instanceof Language_Pack_Upgrader ) { … … 1247 1667 $lp_upgrader->bulk_upgrade( $language_updates ); 1248 1668 } 1249 1669 1670 /** 1671 * Initialize the upgrade strings. 1672 * 1673 * @since 3.7.0 1674 */ 1250 1675 public function upgrade_strings() { 1251 1676 $this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while we update them as well.' ); 1252 1677 $this->strings['up_to_date'] = __( 'The translation is up to date.' ); // We need to silently skip this case … … 1257 1682 $this->strings['process_success'] = __( 'Translation updated successfully.' ); 1258 1683 } 1259 1684 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 */ 1260 1695 public function upgrade( $update = false, $args = array() ) { 1261 1696 if ( $update ) { 1262 1697 $update = array( $update ); … … 1271 1706 return $results[0]; 1272 1707 } 1273 1708 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 */ 1274 1724 public function bulk_upgrade( $language_updates = array(), $args = array() ) { 1275 1725 global $wp_filesystem; 1276 1726 … … 1378 1828 return $results; 1379 1829 } 1380 1830 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 */ 1381 1839 public function check_package( $source, $remote_source ) { 1382 1840 global $wp_filesystem; 1383 1841 … … 1403 1861 return $source; 1404 1862 } 1405 1863 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 */ 1406 1873 public function get_name_for_update( $update ) { 1407 1874 switch ( $update->type ) { 1408 1875 case 'core': … … 1434 1901 */ 1435 1902 class Core_Upgrader extends WP_Upgrader { 1436 1903 1904 /** 1905 * Initialize the upgrade strings. 1906 * 1907 * @since 2.8.0 1908 */ 1437 1909 public function upgrade_strings() { 1438 1910 $this->strings['up_to_date'] = __('WordPress is at the latest version.'); 1439 1911 $this->strings['no_package'] = __('Update package not available.'); … … 1445 1917 $this->strings['rollback_was_required'] = __( 'Due to an error during updating, WordPress has rolled back to your previous version.' ); 1446 1918 } 1447 1919 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 */ 1448 1936 public function upgrade( $current, $args = array() ) { 1449 1937 global $wp_filesystem; 1450 1938 … … 1593 2081 return $result; 1594 2082 } 1595 2083 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 */ 1597 2093 public static function should_update_to_version( $offered_ver /* x.y.z */ ) { 1598 2094 include( ABSPATH . WPINC . '/version.php' ); // $wp_version; // x.y.z 1599 2095 … … 1692 2188 return false; 1693 2189 } 1694 2190 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 */ 1695 2198 public function check_files() { 1696 2199 global $wp_version, $wp_local_package; 1697 2200 … … 1720 2223 * @since 2.8.0 1721 2224 */ 1722 2225 class File_Upload_Upgrader { 2226 2227 /** 2228 * The full path to the file package. 2229 * 2230 * @since 2.8.0 2231 * 2232 * @var string 2233 */ 1723 2234 public $package; 2235 2236 /** 2237 * The name of the file. 2238 * 2239 * @since 2.8.0 2240 * 2241 * @var string 2242 */ 1724 2243 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 */ 1725 2252 public $id = 0; 1726 2253 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 */ 1727 2262 public function __construct($form, $urlholder) { 1728 2263 1729 2264 if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) ) … … 1775 2310 } 1776 2311 } 1777 2312 2313 /** 2314 * Delete the attachment/uploaded file. 2315 * 2316 * @since 3.2.2 2317 * 2318 * @return bool Whether the cleanup was successful. 2319 */ 1778 2320 public function cleanup() { 1779 2321 if ( $this->id ) 1780 2322 wp_delete_attachment( $this->id ); … … 2093 2635 'attempt_rollback' => true, 2094 2636 // Allow relaxed file ownership in some scenarios 2095 2637 'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership, 2096 2638 2097 2639 ) ); 2098 2640 2099 2641 // If the filesystem is unavailable, false is returned.