Changeset 25272
- Timestamp:
- 09/06/2013 01:32:09 AM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-upgrader.php
r25254 r25272 164 164 } 165 165 166 function install_package( $args = array()) {166 function install_package( $args = array() ) { 167 167 global $wp_filesystem, $wp_theme_directories; 168 168 169 $defaults = array( 'source' => '', 'destination' => '', //Please always pass these 170 'clear_destination' => false, 'clear_working' => false, 171 'abort_if_destination_exists' => true, 172 'hook_extra' => array()); 169 $defaults = array( 170 'source' => '', // Please always pass this 171 'destination' => '', // and this 172 'clear_destination' => false, 173 'clear_working' => false, 174 'abort_if_destination_exists' => true, 175 'hook_extra' => array() 176 ); 173 177 174 178 $args = wp_parse_args($args, $defaults); … … 278 282 function run($options) { 279 283 280 $defaults = array( 'package' => '', //Please always pass this. 281 'destination' => '', //And this 282 'clear_destination' => false, 283 'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please 284 'clear_working' => true, 285 'is_multi' => false, 286 'hook_extra' => array() //Pass any extra $hook_extra args here, this will be passed to any hooked filters. 287 ); 284 $defaults = array( 285 'package' => '', // Please always pass this. 286 'destination' => '', // And this 287 'clear_destination' => false, 288 'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please 289 'clear_working' => true, 290 'is_multi' => false, 291 'hook_extra' => array() // Pass any extra $hook_extra args here, this will be passed to any hooked filters. 292 ); 288 293 289 294 $options = wp_parse_args($options, $defaults); … … 325 330 //With the given options, this installs it to the destination directory. 326 331 $result = $this->install_package( array( 327 'source' => $working_dir, 328 'destination' => $destination, 329 'clear_destination' => $clear_destination, 330 'abort_if_destination_exists' => $abort_if_destination_exists, 331 'clear_working' => $clear_working, 332 'hook_extra' => $hook_extra 333 ) ); 332 'source' => $working_dir, 333 'destination' => $destination, 334 'clear_destination' => $clear_destination, 335 'abort_if_destination_exists' => $abort_if_destination_exists, 336 'clear_working' => $clear_working, 337 'hook_extra' => $hook_extra 338 ) ); 339 334 340 $this->skin->set_result($result); 335 341 if ( is_wp_error($result) ) { … … 399 405 } 400 406 401 function install($package) { 407 function install( $package, $args = array() ) { 408 409 $defaults = array( 410 'clear_update_cache' => true, 411 ); 412 $parsed_args = wp_parse_args( $defaults, $args ); 402 413 403 414 $this->init(); … … 406 417 add_filter('upgrader_source_selection', array($this, 'check_package') ); 407 418 408 $this->run( array(409 410 411 'clear_destination' => false, //Do not overwrite files.412 413 414 ));419 $this->run( array( 420 'package' => $package, 421 'destination' => WP_PLUGIN_DIR, 422 'clear_destination' => false, // Do not overwrite files. 423 'clear_working' => true, 424 'hook_extra' => array() 425 ) ); 415 426 416 427 remove_filter('upgrader_source_selection', array($this, 'check_package') ); … … 420 431 421 432 // Force refresh of plugin update information 422 delete_site_transient('update_plugins');423 wp_cache_delete( 'plugins', 'plugins' ); 433 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 434 424 435 do_action( 'upgrader_process_complete', $this, array( 'action' => 'install', 'type' => 'plugin' ), $package ); 425 436 … … 427 438 } 428 439 429 function upgrade($plugin) { 440 function upgrade( $plugin, $args = array() ) { 441 442 $defaults = array( 443 'clear_update_cache' => true, 444 ); 445 $parsed_args = wp_parse_args( $defaults, $args ); 430 446 431 447 $this->init(); … … 448 464 //'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. 449 465 450 $this->run( array(451 452 453 454 455 456 457 )458 ));466 $this->run( array( 467 'package' => $r->package, 468 'destination' => WP_PLUGIN_DIR, 469 'clear_destination' => true, 470 'clear_working' => true, 471 'hook_extra' => array( 472 'plugin' => $plugin 473 ), 474 ) ); 459 475 460 476 // Cleanup our hooks, in case something else does a upgrade on this connection. … … 466 482 467 483 // Force refresh of plugin update information 468 delete_site_transient('update_plugins');469 wp_cache_delete( 'plugins', 'plugins' ); 484 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 485 470 486 do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'plugin' ), $plugin ); 471 487 … … 473 489 } 474 490 475 function bulk_upgrade($plugins) { 491 function bulk_upgrade( $plugins, $args = array() ) { 492 493 $defaults = array( 494 'clear_update_cache' => true, 495 ); 496 $parsed_args = wp_parse_args( $defaults, $args ); 476 497 477 498 $this->init(); … … 526 547 $this->skin->plugin_active = is_plugin_active($plugin); 527 548 528 $result = $this->run( array(529 530 531 532 533 534 535 536 537 ));549 $result = $this->run( array( 550 'package' => $r->package, 551 'destination' => WP_PLUGIN_DIR, 552 'clear_destination' => true, 553 'clear_working' => true, 554 'is_multi' => true, 555 'hook_extra' => array( 556 'plugin' => $plugin 557 ) 558 ) ); 538 559 539 560 $results[$plugin] = $this->result; … … 554 575 555 576 // Force refresh of plugin update information 556 delete_site_transient('update_plugins');557 wp_cache_delete( 'plugins', 'plugins' ); 577 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 578 558 579 do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'plugin', 'bulk' => true ), $plugins ); 559 580 … … 756 777 } 757 778 758 function install($package) { 779 function install( $package, $args = array() ) { 780 781 $defaults = array( 782 'clear_update_cache' => true, 783 ); 784 $parsed_args = wp_parse_args( $defaults, $args ); 759 785 760 786 $this->init(); … … 764 790 add_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'), 10, 3); 765 791 766 $ options =array(792 $this->run( array( 767 793 'package' => $package, 768 794 'destination' => get_theme_root(), 769 795 'clear_destination' => false, //Do not overwrite files. 770 796 'clear_working' => true 771 ); 772 773 $this->run($options); 797 ) ); 774 798 775 799 remove_filter('upgrader_source_selection', array($this, 'check_package') ); … … 779 803 return $this->result; 780 804 781 // Force refresh of theme update information 782 wp_clean_themes_cache(); 805 // Refresh the Theme Update information 806 wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); 807 783 808 do_action( 'upgrader_process_complete', $this, array( 'action' => 'install', 'type' => 'theme' ), $package ); 784 809 … … 786 811 } 787 812 788 function upgrade($theme) { 813 function upgrade( $theme, $args = array() ) { 814 815 $defaults = array( 816 'clear_update_cache' => true, 817 ); 818 $parsed_args = wp_parse_args( $defaults, $args ); 789 819 790 820 $this->init(); … … 807 837 add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4); 808 838 809 $ options =array(839 $this->run( array( 810 840 'package' => $r['package'], 811 841 'destination' => get_theme_root( $theme ), … … 815 845 'theme' => $theme 816 846 ), 817 ); 818 819 $this->run($options); 847 ) ); 820 848 821 849 remove_filter('upgrader_pre_install', array($this, 'current_before')); … … 826 854 return $this->result; 827 855 828 // Force refresh of theme update information829 wp_clean_themes_cache(); 856 wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); 857 830 858 do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'theme' ), $theme ); 831 859 … … 833 861 } 834 862 835 function bulk_upgrade($themes) { 863 function bulk_upgrade( $themes, $args = array() ) { 864 865 $defaults = array( 866 'clear_update_cache' => true, 867 ); 868 $parsed_args = wp_parse_args( $defaults, $args ); 836 869 837 870 $this->init(); … … 887 920 $r = $current->response[ $theme ]; 888 921 889 $ options =array(922 $result = $this->run( array( 890 923 'package' => $r['package'], 891 924 'destination' => get_theme_root( $theme ), … … 895 928 'theme' => $theme 896 929 ), 897 ); 898 899 $result = $this->run($options); 930 ) ); 900 931 901 932 $results[$theme] = $this->result; … … 917 948 remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme')); 918 949 919 // Force refresh of theme update information 920 wp_clean_themes_cache(); 950 // Refresh the Theme Update information 951 wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); 952 921 953 do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'theme', 'bulk' => true ), $themes ); 922 954 … … 1039 1071 } 1040 1072 1041 function upgrade( $current) {1073 function upgrade( $current, $args = array() ) { 1042 1074 global $wp_filesystem, $wp_version; 1075 1076 $defaults = array( 1077 ); 1078 $parsed_args = wp_parse_args( $defaults, $args ); 1043 1079 1044 1080 $this->init(); -
trunk/src/wp-admin/includes/plugin.php
r25081 r25272 1765 1765 wp_nonce_field("$option_group-options"); 1766 1766 } 1767 1768 /** 1769 * Clears the Plugins cache used by get_plugins() and by default, the Plugin Update cache. 1770 * 1771 * @since 3.7.0 1772 * 1773 * @param bool $clear_update_cache Whether to clear the Plugin updates cache 1774 */ 1775 function wp_clean_plugins_cache( $clear_update_cache = true ) { 1776 if ( $clear_update_cache ) 1777 delete_site_transient( 'update_plugins' ); 1778 wp_cache_delete( 'plugins', 'plugins' ); 1779 } -
trunk/src/wp-includes/theme.php
r25235 r25272 111 111 * 112 112 * @since 3.5.0 113 */ 114 function wp_clean_themes_cache() { 115 delete_site_transient('update_themes'); 113 * @param bool $clear_update_cache Whether to clear the Theme updates cache 114 */ 115 function wp_clean_themes_cache( $clear_update_cache = true ) { 116 if ( $clear_update_cache ) 117 delete_site_transient( 'update_themes' ); 116 118 search_theme_directories( true ); 117 119 foreach ( wp_get_themes( array( 'errors' => null ) ) as $theme )
Note: See TracChangeset
for help on using the changeset viewer.