Make WordPress Core

Ticket #29054: 29054.patch

File 29054.patch, 2.0 KB (added by ocean90, 11 years ago)
  • src/wp-admin/includes/class-wp-upgrader-skins.php

     
    104104                if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
    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' ) && 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}
    116125
     
    284293                wp_ob_end_flush_all();
    285294                flush();
    286295        }
    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>';
    305         }
    306296}
    307297
    308298class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {