Ticket #7875: 7875.10.diff
File 7875.10.diff, 8.3 KB (added by , 15 years ago) |
---|
-
wp-admin/includes/class-wp-upgrader.php
1 1 <?php 2 2 /** 3 * This file is an attempt at an abstracted version of the plugin/theme/core installer/upgrader which can be used interchangably for all uses needed within WordPress. 4 * It is designed to be as flexible as possible, but some logic may seem rather, crazy to say the least. 5 * Yes, this header is designed to be replaced before commiting, Hopefully i'll get some proper documentation in here. 3 * A File upgrader class for WordPress. 6 4 * 7 * This File obviously needs some new PHPDoc, However: 8 * Tested: 9 * Theme/Plugin Upgrades/Installs 10 * Core Upgrade 11 * FTP Extension, FTP Sockets, Direct. 12 * Untested: 13 * SSH2 Layer - Needs a good cleanup. 5 * This set of classes are designed to be used to upgrade/install a local set of files on the filesystem via the Filesystem Abstraction classes. 14 6 * 15 * TODO: Remove this commentblock and replace with some better docs. 7 * @link http://trac.wordpress.org/ticket/7875 consolidate plugin/theme/core upgrade/install functions 8 * 9 * @package WordPress 10 * @subpackage Upgrader 11 * @since 2.8.0 16 12 */ 17 13 14 /** 15 * WordPress Upgrader class for Upgrading/Installing a local set of files via the Filesystem Abstraction classes from a Zip file. 16 * 17 * @TODO More Detailed docs, for methods as well. 18 * 19 * @package WordPress 20 * @subpackage Upgrader 21 * @since 2.8.0 22 */ 18 23 class WP_Upgrader { 19 24 var $strings = array(); 20 25 var $skin = null; … … 28 33 $this->skin = new WP_Upgrader_Skin(); 29 34 else 30 35 $this->skin = $skin; 36 } 37 38 function init() { 31 39 $this->skin->set_upgrader($this); 40 $this->generic_strings(); 32 41 } 33 42 34 43 function generic_strings() { … … 323 332 324 333 } 325 334 335 /** 336 * Plugin Upgrader class for WordPress Plugins, It is designed to upgrade/install plugins from a local zip, remote zip URL, or uploaded zip file. 337 * 338 * @TODO More Detailed docs, for methods as well. 339 * 340 * @package WordPress 341 * @subpackage Upgrader 342 * @since 2.8.0 343 */ 326 344 class Plugin_Upgrader extends WP_Upgrader { 327 345 328 346 var $result; 329 347 330 348 function upgrade_strings() { 331 $this->generic_strings();332 349 $this->strings['up_to_date'] = __('The plugin is at the latest version.'); 333 350 $this->strings['no_package'] = __('Upgrade package not available.'); 334 351 $this->strings['downloading_package'] = __('Downloading update from %s.'); … … 341 358 } 342 359 343 360 function install_strings() { 344 $this->generic_strings();345 361 $this->strings['no_package'] = __('Install package not available.'); 346 362 $this->strings['downloading_package'] = __('Downloading install package from %s.'); 347 363 $this->strings['unpack_package'] = __('Unpacking the package.'); … … 352 368 353 369 function install($package) { 354 370 371 $this->init(); 355 372 $this->install_strings(); 356 373 357 374 $this->run(array( … … 369 386 370 387 function upgrade($plugin) { 371 388 389 $this->init(); 372 390 $this->upgrade_strings(); 373 391 374 392 $current = get_transient( 'update_plugins' ); … … 469 487 } 470 488 } 471 489 472 490 /** 491 * Theme Upgrader class for WordPress Themes, It is designed to upgrade/install themes from a local zip, remote zip URL, or uploaded zip file. 492 * 493 * @TODO More Detailed docs, for methods as well. 494 * 495 * @package WordPress 496 * @subpackage Upgrader 497 * @since 2.8.0 498 */ 473 499 class Theme_Upgrader extends WP_Upgrader { 474 500 475 501 var $result; 476 502 477 503 function upgrade_strings() { 478 $this->generic_strings();479 504 $this->strings['up_to_date'] = __('The theme is at the latest version.'); 480 505 $this->strings['no_package'] = __('Upgrade package not available.'); 481 506 $this->strings['downloading_package'] = __('Downloading update from %s.'); … … 487 512 } 488 513 489 514 function install_strings() { 490 $this->generic_strings();491 515 $this->strings['no_package'] = __('Install package not available.'); 492 516 $this->strings['downloading_package'] = __('Downloading install package from %s.'); 493 517 $this->strings['unpack_package'] = __('Unpacking the package.'); … … 497 521 } 498 522 499 523 function install($package) { 500 524 525 $this->init(); 501 526 $this->install_strings(); 502 527 503 528 $options = array( … … 523 548 524 549 function upgrade($theme) { 525 550 551 $this->init(); 526 552 $this->upgrade_strings(); 527 553 528 554 // Is an update available? … … 616 642 617 643 } 618 644 619 //Untested. 645 /** 646 * Core Upgrader class for WordPress. It allows for WordPress to upgrade itself in combiantion with the wp-admin/includes/update-core.php file 647 * 648 * @TODO More Detailed docs, for methods as well. 649 * 650 * @package WordPress 651 * @subpackage Upgrader 652 * @since 2.8.0 653 */ 620 654 class Core_Upgrader extends WP_Upgrader { 621 655 622 656 function upgrade_strings() { 623 $this->generic_strings();624 657 $this->strings['up_to_date'] = __('WordPress is at the latest version.'); 625 658 $this->strings['no_package'] = __('Upgrade package not available.'); 626 659 $this->strings['downloading_package'] = __('Downloading update from %s.'); … … 630 663 631 664 function upgrade($current) { 632 665 global $wp_filesystem; 666 667 $this->init(); 633 668 $this->upgrade_strings(); 634 669 635 636 670 if ( !empty($feedback) ) 637 671 add_filter('update_feedback', $feedback); 638 672 … … 668 702 669 703 } 670 704 671 672 705 /** 673 * Skin stuff here. 674 * ============================================ 675 * ============================================ 676 * ============================================ 706 * Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes. 707 * 708 * @TODO More Detailed docs, for methods as well. 709 * 710 * @package WordPress 711 * @subpackage Upgrader 712 * @since 2.8.0 677 713 */ 678 679 714 class WP_Upgrader_Skin { 680 715 681 716 var $upgrader; … … 732 767 } 733 768 734 769 function feedback($string) { 735 if ( isset( $this->upgrader->strings[$string] ) )770 if ( isset( $this->upgrader->strings[$string] ) ) 736 771 $string = $this->upgrader->strings[$string]; 737 772 738 773 if ( strpos($string, '%') !== false ) { … … 750 785 751 786 } 752 787 788 /** 789 * Plugin Upgrader Skin for WordPress Plugin Upgrades. 790 * 791 * @TODO More Detailed docs, for methods as well. 792 * 793 * @package WordPress 794 * @subpackage Upgrader 795 * @since 2.8.0 796 */ 753 797 class Plugin_Upgrader_Skin extends WP_Upgrader_Skin { 754 798 var $plugin = ''; 755 799 var $plugin_active = false; … … 790 834 } 791 835 } 792 836 793 837 /** 838 * Plugin Installer Skin for WordPress Plugin Installer. 839 * 840 * @TODO More Detailed docs, for methods as well. 841 * 842 * @package WordPress 843 * @subpackage Upgrader 844 * @since 2.8.0 845 */ 794 846 class Plugin_Installer_Skin extends WP_Upgrader_Skin { 795 847 var $api; 796 848 var $type; … … 829 881 830 882 831 883 if ( ! $this->result || is_wp_error($this->result) ) 832 unset( $ update_actions['activate_plugin'] );884 unset( $install_actions['activate_plugin'] ); 833 885 834 886 $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file); 835 887 if ( ! empty($install_actions) ) … … 837 889 } 838 890 } 839 891 892 /** 893 * Theme Installer Skin for the WordPress Theme Installer. 894 * 895 * @TODO More Detailed docs, for methods as well. 896 * 897 * @package WordPress 898 * @subpackage Upgrader 899 * @since 2.8.0 900 */ 840 901 class Theme_Installer_Skin extends WP_Upgrader_Skin { 841 902 var $api; 842 903 var $type; … … 885 946 $install_actions['themes_page'] = '<a href="' . admin_url('themes.php') . '" title="' . attribute_escape(__('Themes page')) . '" target="_parent">' . __('Return to Themes page') . '</a>'; 886 947 887 948 if ( ! $this->result || is_wp_error($this->result) ) 888 unset( $ update_actions['activate'], $update_actions['preview'] );949 unset( $install_actions['activate'], $install_actions['preview'] ); 889 950 890 951 $install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info); 891 952 if ( ! empty($install_actions) ) … … 893 954 } 894 955 } 895 956 957 /** 958 * Theme Upgrader Skin for WordPress Theme Upgrades. 959 * 960 * @TODO More Detailed docs, for methods as well. 961 * 962 * @package WordPress 963 * @subpackage Upgrader 964 * @since 2.8.0 965 */ 896 966 class Theme_Upgrader_Skin extends WP_Upgrader_Skin { 897 967 var $theme = ''; 898 968 … … 938 1008 } 939 1009 } 940 1010 1011 /** 1012 * Upgrade Skin helper for File uploads. This class handles the upload process and passes it as if its a local file to the Upgrade/Installer functions. 1013 * 1014 * @TODO More Detailed docs, for methods as well. 1015 * 1016 * @package WordPress 1017 * @subpackage Upgrader 1018 * @since 2.8.0 1019 */ 941 1020 class File_Upload_Upgrader { 942 1021 var $package; 943 1022 var $filename;