WordPress.org

Make WordPress Core

Changeset 27280


Ignore:
Timestamp:
02/26/2014 06:54:26 AM (7 years ago)
Author:
nacin
Message:

Decrement update count bubbles as plugins/themes are updated, live.

props gcorne, mitchoyoshitaka.
fixes #17703.

Location:
trunk/src
Files:
1 added
6 edited

Legend:

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

    r26518 r27280  
    9393    function after() {}
    9494
     95    /**
     96     * Output JavaScript that calls function to decrement the update counts.
     97     *
     98     * @since 3.9.0
     99     */
     100    protected function decrement_update_count( $type ) {
     101        if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
     102            return;
     103        }
     104        echo '<script type="text/javascript">
     105                (function( wp ) {
     106                    if ( wp && wp.updates.decrementCount ) {
     107                        wp.updates.decrementCount( "' . $type . '" );
     108                    }
     109                })( window.wp );
     110            </script>';
     111    }
    95112}
    96113
     
    124141            echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) .'"></iframe>';
    125142        }
     143
     144        $this->decrement_update_count( 'plugin' );
    126145
    127146        $update_actions =  array(
     
    253272        flush();
    254273    }
     274
     275    /**
     276     * Output JavaScript that sends message to parent window to decrement the update counts.
     277     *
     278     * @since 3.9.0
     279     */
     280    protected function decrement_update_count( $type ) {
     281        if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
     282            return;
     283        }
     284        echo '<script type="text/javascript">
     285                if ( window.postMessage && JSON ) {
     286                    window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname );
     287                }
     288            </script>';
     289    }
    255290}
    256291
     
    273308    function after($title = '') {
    274309        parent::after($this->plugin_info['Title']);
     310        $this->decrement_update_count( 'plugin' );
    275311    }
    276312    function bulk_footer() {
     
    307343    function after($title = '') {
    308344        parent::after( $this->theme_info->display('Name') );
     345        $this->decrement_update_count( 'theme' );
    309346    }
    310347
     
    480517
    481518    function after() {
     519        $this->decrement_update_count( 'theme' );
    482520
    483521        $update_actions = array();
     
    562600
    563601    function bulk_footer() {
     602        $this->decrement_update_count( 'translation' );
    564603        $update_actions = array();
    565604        $update_actions['updates_page'] = '<a href="' . self_admin_url( 'update-core.php' ) . '" title="' . esc_attr__( 'Go to WordPress Updates page' ) . '" target="_parent">' . __( 'Return to WordPress Updates' ) . '</a>';
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r27047 r27280  
    561561
    562562            if ( !isset( $current->response[ $plugin ] ) ) {
    563                 $this->skin->set_result(true);
     563                $this->skin->set_result('up_to_date');
    564564                $this->skin->before();
    565565                $this->skin->feedback('up_to_date');
     
    864864            $this->skin->before();
    865865            $this->skin->set_result(false);
    866             $this->skin->error('up_to_date');
     866            $this->skin->error( 'up_to_date' );
    867867            $this->skin->after();
    868868            return false;
     
    949949                $this->skin->set_result(true);
    950950                $this->skin->before();
    951                 $this->skin->feedback('up_to_date');
     951                $this->skin->feedback( 'up_to_date' );
    952952                $this->skin->after();
    953953                $results[$theme] = true;
  • trunk/src/wp-admin/plugins.php

    r27158 r27280  
    114114            $parent_file = 'plugins.php';
    115115
     116            wp_enqueue_script( 'updates' );
    116117            require_once(ABSPATH . 'wp-admin/admin-header.php');
    117118
  • trunk/src/wp-admin/update-core.php

    r27205 r27280  
    1212wp_enqueue_style( 'plugin-install' );
    1313wp_enqueue_script( 'plugin-install' );
     14wp_enqueue_script( 'updates' );
    1415add_thickbox();
    1516
  • trunk/src/wp-admin/update.php

    r27158 r27280  
    3838        $nonce = 'bulk-update-plugins';
    3939
    40         wp_enqueue_script('jquery');
     40        wp_enqueue_script( 'updates' );
    4141        iframe_header();
    4242
     
    5555        $parent_file = 'plugins.php';
    5656        $submenu_file = 'plugins.php';
     57
     58        wp_enqueue_script( 'updates' );
    5759        require_once(ABSPATH . 'wp-admin/admin-header.php');
    5860
     
    155157
    156158        wp_enqueue_script( 'customize-loader' );
     159        wp_enqueue_script( 'updates' );
    157160
    158161        $title = __('Update Theme');
     
    186189        $nonce = 'bulk-update-themes';
    187190
    188         wp_enqueue_script('jquery');
     191        wp_enqueue_script( 'updates' );
    189192        iframe_header();
    190193
  • trunk/src/wp-includes/script-loader.php

    r27271 r27280  
    482482        ) );
    483483
     484        $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery' ) );
     485
    484486        $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
    485487
Note: See TracChangeset for help on using the changeset viewer.