Make WordPress Core

Changeset 29357


Ignore:
Timestamp:
08/02/2014 02:36:31 PM (10 years ago)
Author:
ocean90
Message:

Upgrader: Use always window.postMessage for decrement of update count bubbles when IFRAME_REQUEST is defined.
Fixes decrement of translation update count bubbles when updated through the bulk upgrader.

fixes #29054.

File:
1 edited

Legend:

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

    r29313 r29357  
    105105            return;
    106106        }
    107         echo '<script type="text/javascript">
    108                 (function( wp ) {
    109                     if ( wp && wp.updates.decrementCount ) {
    110                         wp.updates.decrementCount( "' . $type . '" );
     107
     108        if ( defined( 'IFRAME_REQUEST' ) ) {
     109            echo '<script type="text/javascript">
     110                    if ( window.postMessage && JSON ) {
     111                        window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname );
    111112                    }
    112                 })( window.wp );
    113             </script>';
     113                </script>';
     114        } else {
     115            echo '<script type="text/javascript">
     116                    (function( wp ) {
     117                        if ( wp && wp.updates.decrementCount ) {
     118                            wp.updates.decrementCount( "' . $type . '" );
     119                        }
     120                    })( window.wp );
     121                </script>';
     122        }
    114123    }
    115124}
     
    284293        wp_ob_end_flush_all();
    285294        flush();
    286     }
    287 
    288     /**
    289      * Output JavaScript that sends message to parent window to decrement the update counts.
    290      *
    291      * @since 3.9.0
    292      *
    293      * @param string $type Type of update count to decrement. Likely values include 'plugin',
    294      *                     'theme', 'translation', etc.
    295      */
    296     protected function decrement_update_count( $type ) {
    297         if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
    298             return;
    299         }
    300         echo '<script type="text/javascript">
    301                 if ( window.postMessage && JSON ) {
    302                     window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname );
    303                 }
    304             </script>';
    305295    }
    306296}
Note: See TracChangeset for help on using the changeset viewer.