Ticket #29086: 29086.diff
File 29086.diff, 24.1 KB (added by , 11 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 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 */ 26 63 public $result = array(); 27 64 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 */ 28 72 public function __construct($skin = null) { 29 73 if ( null == $skin ) 30 74 $this->skin = new WP_Upgrader_Skin(); … … 32 76 $this->skin = $skin; 33 77 } 34 78 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 */ 35 87 public function init() { 36 88 $this->skin->set_upgrader($this); 37 89 $this->generic_strings(); 38 90 } 39 91 92 /** 93 * Add the generic strings to WP_Upgrader::$strings. 94 * 95 * @since 2.8.0 96 */ 40 97 public function generic_strings() { 41 98 $this->strings['bad_request'] = __('Invalid Data provided.'); 42 99 $this->strings['fs_unavailable'] = __('Could not access filesystem.'); … … 59 116 $this->strings['maintenance_end'] = __('Disabling Maintenance mode…'); 60 117 } 61 118 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 */ 62 129 public function fs_connect( $directories = array() ) { 63 130 global $wp_filesystem; 64 131 … … 106 173 return true; 107 174 } //end fs_connect(); 108 175 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 */ 109 186 public function download_package($package) { 110 187 111 188 /** … … 138 215 return $download_file; 139 216 } 140 217 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 */ 141 228 public function unpack_package($package, $delete_package = true) { 142 229 global $wp_filesystem; 143 230 … … 177 264 return $working_dir; 178 265 } 179 266 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 */ 180 290 public function install_package( $args = array() ) { 181 291 global $wp_filesystem, $wp_theme_directories; 182 292 … … 353 463 return $this->result; 354 464 } 355 465 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 */ 356 493 public function run( $options ) { 357 494 358 495 $defaults = array( … … 447 584 return $result; 448 585 } 449 586 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 */ 450 596 public function maintenance_mode($enable = false) { 451 597 global $wp_filesystem; 452 598 $file = $wp_filesystem->abspath() . '.maintenance'; … … 473 619 */ 474 620 class Plugin_Upgrader extends WP_Upgrader { 475 621 622 /** 623 * @since 2.8.0 624 * 625 * @see WP_Upgrader::$result 626 */ 476 627 public $result; 628 629 /** 630 * Whether a bulk upgrade/install is being performed. 631 * 632 * @since 2.9.0 633 * 634 * @var bool 635 */ 477 636 public $bulk = false; 478 637 638 /** 639 * Initialize the upgrade strings. 640 * 641 * @since 2.8.0 642 */ 479 643 public function upgrade_strings() { 480 644 $this->strings['up_to_date'] = __('The plugin is at the latest version.'); 481 645 $this->strings['no_package'] = __('Update package not available.'); … … 487 651 $this->strings['process_success'] = __('Plugin updated successfully.'); 488 652 } 489 653 654 /** 655 * Initialize the install strings. 656 * 657 * @since 2.8.0 658 */ 490 659 public function install_strings() { 491 660 $this->strings['no_package'] = __('Install package not available.'); 492 661 $this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>…'); … … 497 666 $this->strings['process_success'] = __('Plugin installed successfully.'); 498 667 } 499 668 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 */ 500 684 public function install( $package, $args = array() ) { 501 685 502 686 $defaults = array( … … 531 715 return true; 532 716 } 533 717 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 */ 534 733 public function upgrade( $plugin, $args = array() ) { 535 734 536 735 $defaults = array( … … 582 781 return true; 583 782 } 584 783 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 */ 585 799 public function bulk_upgrade( $plugins, $args = array() ) { 586 800 587 801 $defaults = array( … … 696 910 return $results; 697 911 } 698 912 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 */ 699 925 public function check_package($source) { 700 926 global $wp_filesystem; 701 927 … … 722 948 return $source; 723 949 } 724 950 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 */ 726 960 public function plugin_info() { 727 961 if ( ! is_array($this->result) ) 728 962 return false; … … 738 972 return $this->result['destination_name'] . '/' . $pluginfiles[0]; 739 973 } 740 974 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 */ 742 982 public function deactivate_plugin_before_upgrade($return, $plugin) { 743 983 744 984 if ( is_wp_error($return) ) //Bypass. … … 758 998 } 759 999 } 760 1000 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 */ 762 1009 public function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) { 763 1010 global $wp_filesystem; 764 1011 … … 797 1044 */ 798 1045 class Theme_Upgrader extends WP_Upgrader { 799 1046 1047 /** 1048 * @since 2.8.0 1049 * 1050 * @see WP_Upgrader::$result 1051 */ 800 1052 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 */ 801 1061 public $bulk = false; 802 1062 1063 /** 1064 * Initialize the upgrade strings. 1065 * 1066 * @since 2.8.0 1067 */ 803 1068 public function upgrade_strings() { 804 1069 $this->strings['up_to_date'] = __('The theme is at the latest version.'); 805 1070 $this->strings['no_package'] = __('Update package not available.'); … … 811 1076 $this->strings['process_success'] = __('Theme updated successfully.'); 812 1077 } 813 1078 1079 /** 1080 * Initialize the install strings. 1081 * 1082 * @since 2.8.0 1083 */ 814 1084 public function install_strings() { 815 1085 $this->strings['no_package'] = __('Install package not available.'); 816 1086 $this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>…'); … … 831 1101 $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.'); 832 1102 } 833 1103 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 */ 834 1111 public function check_parent_theme_filter($install_result, $hook_extra, $child_result) { 835 1112 // Check to see if we need to install a parent theme 836 1113 $theme_info = $this->theme_info(); … … 890 1167 return $install_result; 891 1168 } 892 1169 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 */ 893 1179 public function hide_activate_preview_actions($actions) { 894 1180 unset($actions['activate'], $actions['preview']); 895 1181 return $actions; 896 1182 } 897 1183 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 */ 898 1199 public function install( $package, $args = array() ) { 899 1200 900 1201 $defaults = array( … … 931 1232 return true; 932 1233 } 933 1234 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 */ 934 1250 public function upgrade( $theme, $args = array() ) { 935 1251 936 1252 $defaults = array( … … 981 1297 return true; 982 1298 } 983 1299 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 */ 984 1315 public function bulk_upgrade( $themes, $args = array() ) { 985 1316 986 1317 $defaults = array( … … 1082 1413 return $results; 1083 1414 } 1084 1415 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 */ 1085 1429 public function check_package($source) { 1086 1430 global $wp_filesystem; 1087 1431 … … 1109 1453 return $source; 1110 1454 } 1111 1455 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 */ 1112 1464 public function current_before($return, $theme) { 1113 1465 1114 1466 if ( is_wp_error($return) ) … … 1125 1477 return $return; 1126 1478 } 1127 1479 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 */ 1128 1488 public function current_after($return, $theme) { 1129 1489 if ( is_wp_error($return) ) 1130 1490 return $return; … … 1147 1507 return $return; 1148 1508 } 1149 1509 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 */ 1150 1518 public function delete_old_theme( $removed, $local_destination, $remote_destination, $theme ) { 1151 1519 global $wp_filesystem; 1152 1520 … … 1166 1534 return true; 1167 1535 } 1168 1536 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 */ 1169 1549 public function theme_info($theme = null) { 1170 1550 1171 1551 if ( empty($theme) ) { … … 1190 1570 */ 1191 1571 class Language_Pack_Upgrader extends WP_Upgrader { 1192 1572 1573 /** 1574 * @since 3.7.0 1575 * 1576 * @see WP_Upgrader::$result 1577 */ 1193 1578 public $result; 1579 1580 /** 1581 * Whether a bulk upgrade/install is being performed. 1582 * 1583 * @since 3.7.0 1584 * 1585 * @var bool 1586 */ 1194 1587 public $bulk = true; 1195 1588 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 */ 1196 1596 public static function async_upgrade( $upgrader = false ) { 1197 1597 // Avoid recursion. 1198 1598 if ( $upgrader && $upgrader instanceof Language_Pack_Upgrader ) … … 1211 1611 $lp_upgrader->upgrade(); 1212 1612 } 1213 1613 1614 /** 1615 * Initialize the upgrade strings. 1616 * 1617 * @since 3.7.0 1618 */ 1214 1619 public function upgrade_strings() { 1215 1620 $this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while we update them as well.' ); 1216 1621 $this->strings['up_to_date'] = __( 'The translation is up to date.' ); // We need to silently skip this case … … 1221 1626 $this->strings['process_success'] = __( 'Translation updated successfully.' ); 1222 1627 } 1223 1628 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 */ 1224 1639 public function upgrade( $update = false, $args = array() ) { 1225 1640 if ( $update ) 1226 1641 $update = array( $update ); … … 1228 1643 return $results[0]; 1229 1644 } 1230 1645 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 */ 1231 1661 public function bulk_upgrade( $language_updates = array(), $args = array() ) { 1232 1662 global $wp_filesystem; 1233 1663 … … 1331 1761 return $results; 1332 1762 } 1333 1763 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 */ 1334 1772 public function check_package( $source, $remote_source ) { 1335 1773 global $wp_filesystem; 1336 1774 … … 1356 1794 return $source; 1357 1795 } 1358 1796 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 */ 1359 1806 public function get_name_for_update( $update ) { 1360 1807 switch ( $update->type ) { 1361 1808 case 'core': … … 1387 1834 */ 1388 1835 class Core_Upgrader extends WP_Upgrader { 1389 1836 1837 /** 1838 * Initialize the upgrade strings. 1839 * 1840 * @since 2.8.0 1841 */ 1390 1842 public function upgrade_strings() { 1391 1843 $this->strings['up_to_date'] = __('WordPress is at the latest version.'); 1392 1844 $this->strings['no_package'] = __('Update package not available.'); … … 1398 1850 $this->strings['rollback_was_required'] = __( 'Due to an error during updating, WordPress has rolled back to your previous version.' ); 1399 1851 } 1400 1852 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 */ 1401 1869 public function upgrade( $current, $args = array() ) { 1402 1870 global $wp_filesystem; 1403 1871 … … 1545 2013 return $result; 1546 2014 } 1547 2015 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 */ 1549 2025 public static function should_update_to_version( $offered_ver /* x.y.z */ ) { 1550 2026 include( ABSPATH . WPINC . '/version.php' ); // $wp_version; // x.y.z 1551 2027 … … 1644 2120 return false; 1645 2121 } 1646 2122 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 */ 1647 2130 public function check_files() { 1648 2131 global $wp_version, $wp_local_package; 1649 2132 … … 1672 2155 * @since 2.8.0 1673 2156 */ 1674 2157 class File_Upload_Upgrader { 2158 2159 /** 2160 * The full path to the file package. 2161 * 2162 * @since 2.8.0 2163 * 2164 * @var string 2165 */ 1675 2166 public $package; 2167 2168 /** 2169 * The name of the file. 2170 * 2171 * @since 2.8.0 2172 * 2173 * @var string 2174 */ 1676 2175 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 */ 1677 2184 public $id = 0; 1678 2185 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 */ 1679 2194 public function __construct($form, $urlholder) { 1680 2195 1681 2196 if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) ) … … 1727 2242 } 1728 2243 } 1729 2244 2245 /** 2246 * Delete the attachment/uploaded file. 2247 * 2248 * @since 3.2.2 2249 * 2250 * @return bool Whether the cleanup was successful. 2251 */ 1730 2252 public function cleanup() { 1731 2253 if ( $this->id ) 1732 2254 wp_delete_attachment( $this->id );