Make WordPress Core


Ignore:
Timestamp:
03/06/2010 08:39:50 AM (16 years ago)
Author:
dd32
Message:

First scrape at new UI for Bulk plugin upgrades. See #11232

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-upgrader.php

    r13089 r13602  
    298298                if ( is_wp_error($download) ) {
    299299                        $this->skin->error($download);
     300                        $this->skin->after();
    300301                        return $download;
    301302                }
     
    305306                if ( is_wp_error($working_dir) ) {
    306307                        $this->skin->error($working_dir);
     308                        $this->skin->after();
    307309                        return $working_dir;
    308310                }
     
    410412                $current = get_site_transient( 'update_plugins' );
    411413                if ( !isset( $current->response[ $plugin ] ) ) {
     414                        $this->skin->before();
    412415                        $this->skin->set_result(false);
    413416                        $this->skin->error('up_to_date');
     
    467470                $results = array();
    468471
    469                 $all = count($plugins);
    470                 $i = 1;
     472                $this->plugin_count = count($plugins);
     473                $this->plugin_current = 0;
    471474                foreach ( $plugins as $plugin ) {
    472 
    473                         $this->show_before = sprintf( '<h4>' . __('Updating plugin %1$d of %2$d&#8230;') . '</h4>', $i, $all );
    474                         $i++;
     475                        $this->plugin_current++;
     476                        $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true);
    475477
    476478                        if ( !isset( $current->response[ $plugin ] ) ) {
    477479                                $this->skin->set_result(false);
     480                                $this->skin->before();
    478481                                $this->skin->error('up_to_date');
    479482                                $this->skin->after();
     
    503506                        if ( false === $result )
    504507                                break;
    505                 }
     508                } //end foreach $plugins
    506509                $this->maintenance_mode(false);
    507510                $this->skin->footer();
     
    646649                $current = get_site_transient( 'update_themes' );
    647650                if ( !isset( $current->response[ $theme ] ) ) {
     651                        $this->skin->before();
    648652                        $this->skin->set_result(false);
    649653                        $this->skin->error('up_to_date');
     
    911915
    912916        function after() {
    913                 if ( $this->upgrader->bulk )
    914                         return;
    915 
    916917                $this->plugin = $this->upgrader->plugin_info();
    917918                if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
     
    943944
    944945/**
     946 * Plugin Upgrader Skin for WordPress Plugin Upgrades.
     947 *
     948 * @package WordPress
     949 * @subpackage Upgrader
     950 * @since 3.0
     951 */
     952class Bulk_Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
     953        var $in_loop = false;
     954        var $error = false;
     955
     956        function Plugin_Upgrader_Skin($args = array()) {
     957                return $this->__construct($args);
     958        }
     959
     960        function __construct($args = array()) {
     961                $defaults = array( 'url' => '', 'nonce' => '' );
     962                $args = wp_parse_args($args, $defaults);
     963
     964                parent::__construct($args);
     965        }
     966       
     967        function feedback($string) {
     968                if ( isset( $this->upgrader->strings[$string] ) )
     969                        $string = $this->upgrader->strings[$string];
     970
     971                if ( strpos($string, '%') !== false ) {
     972                        $args = func_get_args();
     973                        $args = array_splice($args, 1);
     974                        if ( !empty($args) )
     975                                $string = vsprintf($string, $args);
     976                }
     977                if ( empty($string) )
     978                        return;
     979                if ( $this->in_loop )
     980                        echo "$string<br />\n";
     981                else
     982                        echo "<p>$string</p>\n";
     983        }
     984
     985        function header() {
     986                // Nothing, This will be displayed within a iframe.
     987        }
     988
     989        function footer() {
     990                // Nothing, This will be displayed within a iframe.
     991        }
     992        function error($error) {
     993                if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
     994                        $this->error = $this->upgrader->strings[$error];
     995               
     996                if ( is_wp_error($error) && $error->get_error_code() ) {
     997                        foreach ( $error->get_error_messages() as $emessage ) {
     998                                if ( $error->get_error_data() )
     999                                        $messages[] = $emessage . ' ' . $error->get_error_data();
     1000                                else
     1001                                        $messages[] = $emessage;
     1002                        }
     1003                        $this->error = implode(', ', $messages);
     1004                }
     1005        }
     1006
     1007        function before() {
     1008                $this->in_loop = true;
     1009                printf( '<h4>' . __('Updating Plugin %1$s (%2$d/%3$d)') . '</h4>',  $this->plugin_info['Title'], $this->upgrader->plugin_current, $this->upgrader->plugin_count);
     1010                echo '<div class="update-messages" style="display:none" id="progress-' . esc_attr($this->upgrader->plugin_current) . '"><p>';
     1011                $this->flush_output();
     1012        }
     1013
     1014        function after() {
     1015                echo '</p></div>';
     1016                if ( $this->error || ! $this->result ) {
     1017                        if ( $this->error )
     1018                                echo '<div class="error"><p>' . sprintf(__('An error occured while updating %1$s: <strong>%2$s</strong>.'), $this->plugin_info['Title'], $this->error) . '</p></div>';
     1019                        else
     1020                                echo '<div class="error"><p>' . sprintf(__('The update of %1$s failed.'), $this->plugin_info['Title']) . '</p></div>';
     1021                        echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->plugin_current) . '\').show();</script>';
     1022                }
     1023                if ( !empty($this->result) && !is_wp_error($this->result) ) {
     1024                        echo '<div class="updated"><p>' . sprintf(__('%1$s updated successfully. <a onclick="%2$s" href="#">See Details</a>.'), $this->plugin_info['Title'], 'jQuery(\'#progress-' . esc_js($this->upgrader->plugin_current) . '\').toggle(); return false;') . '</p></div>';
     1025                }
     1026                $this->reset();
     1027                $this->flush_output();
     1028        }
     1029
     1030        function reset() {
     1031                $this->in_loop = false;
     1032                $this->error = false;
     1033        }
     1034
     1035        function flush_output() {
     1036                wp_ob_end_flush_all();
     1037                flush();
     1038        }
     1039
     1040}
     1041
     1042/**
    9451043 * Plugin Installer Skin for WordPress Plugin Installer.
    9461044 *
Note: See TracChangeset for help on using the changeset viewer.