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.

git-svn-id: https://develop.svn.wordpress.org/trunk@29357 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2014-08-02 14:36:31 +00:00
parent ee91f3f94f
commit c976db478f
1 changed files with 15 additions and 25 deletions

View File

@ -104,13 +104,22 @@ class WP_Upgrader_Skin {
if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
return;
}
echo '<script type="text/javascript">
(function( wp ) {
if ( wp && wp.updates.decrementCount ) {
wp.updates.decrementCount( "' . $type . '" );
if ( defined( 'IFRAME_REQUEST' ) ) {
echo '<script type="text/javascript">
if ( window.postMessage && JSON ) {
window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname );
}
})( window.wp );
</script>';
</script>';
} else {
echo '<script type="text/javascript">
(function( wp ) {
if ( wp && wp.updates.decrementCount ) {
wp.updates.decrementCount( "' . $type . '" );
}
})( window.wp );
</script>';
}
}
}
@ -284,25 +293,6 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
wp_ob_end_flush_all();
flush();
}
/**
* Output JavaScript that sends message to parent window to decrement the update counts.
*
* @since 3.9.0
*
* @param string $type Type of update count to decrement. Likely values include 'plugin',
* 'theme', 'translation', etc.
*/
protected function decrement_update_count( $type ) {
if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
return;
}
echo '<script type="text/javascript">
if ( window.postMessage && JSON ) {
window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname );
}
</script>';
}
}
class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {