Ticket #27365: 27365.3.diff
File 27365.3.diff, 9.9 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/class-wp-upgrader.php
class WP_Upgrader { 552 552 553 553 $this->result = compact( 'source', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination' ); 554 554 555 555 /** 556 556 * Filter the install response after the installation has finished. 557 557 * 558 558 * @since 2.8.0 559 559 * 560 560 * @param bool $response Install response. 561 561 * @param array $hook_extra Extra arguments passed to hooked filters. 562 562 * @param array $result Installation result data. 563 563 */ 564 564 $res = apply_filters( 'upgrader_post_install', true, $args['hook_extra'], $this->result ); 565 565 566 566 if ( is_wp_error($res) ) { 567 $this->result = $res;568 567 return $res; 569 568 } 570 569 571 570 //Bombard the calling function will all the info which we've just used. 572 571 return $this->result; 573 572 } 574 573 575 574 /** 576 575 * Run an upgrade/install. 577 576 * 578 577 * Attempts to download the package (if it is not a local file), unpack it, and 579 578 * install it in the destination folder. 580 579 * 581 580 * @since 2.8.0 582 581 * @access public … … class Plugin_Upgrader extends WP_Upgrade 835 834 */ 836 835 public function install( $package, $args = array() ) { 837 836 838 837 $defaults = array( 839 838 'clear_update_cache' => true, 840 839 ); 841 840 $parsed_args = wp_parse_args( $args, $defaults ); 842 841 843 842 $this->init(); 844 843 $this->install_strings(); 845 844 846 845 add_filter('upgrader_source_selection', array($this, 'check_package') ); 847 846 // Clear cache so wp_update_plugins() knows about the new plugin. 848 847 add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); 849 848 850 $ this->run( array(849 $result = $this->run( array( 851 850 'package' => $package, 852 851 'destination' => WP_PLUGIN_DIR, 853 852 'clear_destination' => false, // Do not overwrite files. 854 853 'clear_working' => true, 855 854 'hook_extra' => array( 856 855 'type' => 'plugin', 857 856 'action' => 'install', 858 857 ) 859 858 ) ); 860 859 861 860 remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); 862 861 remove_filter('upgrader_source_selection', array($this, 'check_package') ); 863 862 864 if ( ! $ this->result || is_wp_error($this->result) )865 return $ this->result;863 if ( ! $result || is_wp_error( $result ) ) 864 return $result; 866 865 867 866 // Force refresh of plugin update information 868 867 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 869 868 870 869 return true; 871 870 } 872 871 873 872 /** 874 873 * Upgrade a plugin. 875 874 * 876 875 * @since 2.8.0 877 876 * @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional. 878 877 * @access public 879 878 * 880 879 * @param string $plugin The basename path to the main plugin file. … … class Plugin_Upgrader extends WP_Upgrade 900 899 if ( !isset( $current->response[ $plugin ] ) ) { 901 900 $this->skin->before(); 902 901 $this->skin->set_result(false); 903 902 $this->skin->error('up_to_date'); 904 903 $this->skin->after(); 905 904 return false; 906 905 } 907 906 908 907 // Get the URL to the zip file 909 908 $r = $current->response[ $plugin ]; 910 909 911 910 add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2); 912 911 add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); 913 912 //'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins. 914 913 915 $ this->run( array(914 $result = $this->run( array( 916 915 'package' => $r->package, 917 916 'destination' => WP_PLUGIN_DIR, 918 917 'clear_destination' => true, 919 918 'clear_working' => true, 920 919 'hook_extra' => array( 921 920 'plugin' => $plugin, 922 921 'type' => 'plugin', 923 922 'action' => 'update', 924 923 ), 925 924 ) ); 926 925 927 926 // Cleanup our hooks, in case something else does a upgrade on this connection. 928 927 remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade')); 929 928 remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); 930 929 931 if ( ! $ this->result || is_wp_error($this->result) )932 return $ this->result;930 if ( ! $result || is_wp_error( $result ) ) 931 return $result; 933 932 934 933 // Force refresh of plugin update information 935 934 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 936 935 937 936 return true; 938 937 } 939 938 940 939 /** 941 940 * Bulk upgrade several plugins at once. 942 941 * 943 942 * @since 2.8.0 944 943 * @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional. 945 944 * @access public 946 945 * 947 946 * @param array $plugins Array of the basename paths of the plugins' main files. … … class Plugin_Upgrader extends WP_Upgrade 1012 1011 $r = $current->response[ $plugin ]; 1013 1012 1014 1013 $this->skin->plugin_active = is_plugin_active($plugin); 1015 1014 1016 1015 $result = $this->run( array( 1017 1016 'package' => $r->package, 1018 1017 'destination' => WP_PLUGIN_DIR, 1019 1018 'clear_destination' => true, 1020 1019 'clear_working' => true, 1021 1020 'is_multi' => true, 1022 1021 'hook_extra' => array( 1023 1022 'plugin' => $plugin 1024 1023 ) 1025 1024 ) ); 1026 1025 1027 $results[$plugin] = $ this->result;1026 $results[$plugin] = $result; 1028 1027 1029 1028 // Prevent credentials auth screen from displaying multiple times 1030 1029 if ( false === $result ) 1031 1030 break; 1032 1031 } //end foreach $plugins 1033 1032 1034 1033 $this->maintenance_mode(false); 1035 1034 1036 1035 /** 1037 1036 * Fires when the bulk upgrader process is complete. 1038 1037 * 1039 1038 * @since 3.6.0 1040 1039 * 1041 1040 * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might 1042 1041 * be a Theme_Upgrader or Core_Upgrade instance. … … class Theme_Upgrader extends WP_Upgrader 1402 1401 public function install( $package, $args = array() ) { 1403 1402 1404 1403 $defaults = array( 1405 1404 'clear_update_cache' => true, 1406 1405 ); 1407 1406 $parsed_args = wp_parse_args( $args, $defaults ); 1408 1407 1409 1408 $this->init(); 1410 1409 $this->install_strings(); 1411 1410 1412 1411 add_filter('upgrader_source_selection', array($this, 'check_package') ); 1413 1412 add_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'), 10, 3); 1414 1413 // Clear cache so wp_update_themes() knows about the new theme. 1415 1414 add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 ); 1416 1415 1417 $ this->run( array(1416 $result = $this->run( array( 1418 1417 'package' => $package, 1419 1418 'destination' => get_theme_root(), 1420 1419 'clear_destination' => false, //Do not overwrite files. 1421 1420 'clear_working' => true, 1422 1421 'hook_extra' => array( 1423 1422 'type' => 'theme', 1424 1423 'action' => 'install', 1425 1424 ), 1426 1425 ) ); 1427 1426 1428 1427 remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 ); 1429 1428 remove_filter('upgrader_source_selection', array($this, 'check_package') ); 1430 1429 remove_filter('upgrader_post_install', array($this, 'check_parent_theme_filter')); 1431 1430 1432 if ( ! $ this->result || is_wp_error($this->result) )1433 return $ this->result;1431 if ( ! $result || is_wp_error( $result ) ) 1432 return $result; 1434 1433 1435 1434 // Refresh the Theme Update information 1436 1435 wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); 1437 1436 1438 1437 return true; 1439 1438 } 1440 1439 1441 1440 /** 1442 1441 * Upgrade a theme. 1443 1442 * 1444 1443 * @since 2.8.0 1445 1444 * @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional. 1446 1445 * @access public 1447 1446 * 1448 1447 * @param string $theme The theme slug. … … class Theme_Upgrader extends WP_Upgrader 1484 1483 'package' => $r['package'], 1485 1484 'destination' => get_theme_root( $theme ), 1486 1485 'clear_destination' => true, 1487 1486 'clear_working' => true, 1488 1487 'hook_extra' => array( 1489 1488 'theme' => $theme, 1490 1489 'type' => 'theme', 1491 1490 'action' => 'update', 1492 1491 ), 1493 1492 ) ); 1494 1493 1495 1494 remove_filter('upgrader_pre_install', array($this, 'current_before')); 1496 1495 remove_filter('upgrader_post_install', array($this, 'current_after')); 1497 1496 remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme')); 1498 1497 1499 if ( ! $ this->result || is_wp_error($this->result) )1500 return $ this->result;1498 if ( ! $result || is_wp_error( $result ) ) 1499 return $result; 1501 1500 1502 1501 wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); 1503 1502 1504 1503 return true; 1505 1504 } 1506 1505 1507 1506 /** 1508 1507 * Upgrade several themes at once. 1509 1508 * 1510 1509 * @since 3.0.0 1511 1510 * @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional. 1512 1511 * @access public 1513 1512 * 1514 1513 * @param array $themes The theme slugs. 1515 1514 * @param array $args { … … class Theme_Upgrader extends WP_Upgrader 1578 1577 1579 1578 // Get the URL to the zip file 1580 1579 $r = $current->response[ $theme ]; 1581 1580 1582 1581 $result = $this->run( array( 1583 1582 'package' => $r['package'], 1584 1583 'destination' => get_theme_root( $theme ), 1585 1584 'clear_destination' => true, 1586 1585 'clear_working' => true, 1587 1586 'is_multi' => true, 1588 1587 'hook_extra' => array( 1589 1588 'theme' => $theme 1590 1589 ), 1591 1590 ) ); 1592 1591 1593 $results[$theme] = $ this->result;1592 $results[$theme] = $result; 1594 1593 1595 1594 // Prevent credentials auth screen from displaying multiple times 1596 1595 if ( false === $result ) 1597 1596 break; 1598 1597 } //end foreach $plugins 1599 1598 1600 1599 $this->maintenance_mode(false); 1601 1600 1602 1601 /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ 1603 1602 do_action( 'upgrader_process_complete', $this, array( 1604 1603 'action' => 'update', 1605 1604 'type' => 'theme', 1606 1605 'bulk' => true, 1607 1606 'themes' => $themes, 1608 1607 ) ); … … class Language_Pack_Upgrader extends WP_ 2019 2018 $options = array( 2020 2019 'package' => $language_update->package, 2021 2020 'destination' => $destination, 2022 2021 'clear_destination' => false, 2023 2022 'abort_if_destination_exists' => false, // We expect the destination to exist. 2024 2023 'clear_working' => true, 2025 2024 'is_multi' => true, 2026 2025 'hook_extra' => array( 2027 2026 'language_update_type' => $language_update->type, 2028 2027 'language_update' => $language_update, 2029 2028 ) 2030 2029 ); 2031 2030 2032 2031 $result = $this->run( $options ); 2033 2032 2034 $results[] = $ this->result;2033 $results[] = $result; 2035 2034 2036 2035 // Prevent credentials auth screen from displaying multiple times. 2037 2036 if ( false === $result ) 2038 2037 break; 2039 2038 } 2040 2039 2041 2040 $this->skin->bulk_footer(); 2042 2041 2043 2042 $this->skin->footer(); 2044 2043 2045 2044 // Clean up our hooks, in case something else does an upgrade on this connection. 2046 2045 remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); 2047 2046 2048 2047 if ( $parsed_args['clear_update_cache'] ) { 2049 2048 wp_clean_update_cache();