Make WordPress Core

Ticket #31739: 31739.diff

File 31739.diff, 2.2 KB (added by jorbin, 10 years ago)
  • src/wp-admin/includes/plugin-install.php

     
    561561                                break;
    562562                        case 'update_available':
    563563                                if ( $status['url'] ) {
    564                                         echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) .'</a>';
     564                                        echo '<a data-slug="' . esc_attr( $api->slug ) . '"  class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) .'</a>';
    565565                                }
    566566                                break;
    567567                        case 'newer_installed':
  • src/wp-admin/js/updates.js

     
     1/* global tb_remove */
    12window.wp = window.wp || {};
    23
    34(function( $, wp, pagenow ) {
     
    470471                        wp.updates.updatePlugin( $button.data( 'plugin' ), $button.data( 'slug' ) );
    471472                } );
    472473
     474                //
     475                $( '#plugin-information #plugin-information-footer a' ).on( 'click' , function( e ) {
     476                        var target = window.parent == window ? null : window.parent,
     477                                data;
     478                        $.support.postMessage = !! window.postMessage;
     479                        if ( $.support.postMessage === false || target === null )
     480                                return;
     481
     482                        e.preventDefault();
     483
     484                        data = {
     485                                'action' : 'updatePlugin',
     486                                'slug'   : $(this).data('slug')
     487                        };
     488
     489                        target.postMessage( JSON.stringify( data ), window.location.origin );
     490                });
     491
    473492        } );
    474493
    475494        $( window ).on( 'message', function( e ) {
     
    484503
    485504                message = $.parseJSON( event.data );
    486505
    487                 if ( typeof message.action === 'undefined' || message.action !== 'decrementUpdateCount' ) {
     506                if ( typeof message.action === 'undefined' ) {
    488507                        return;
    489508                }
    490509
    491                 wp.updates.decrementCount( message.upgradeType );
     510                switch (message.action){
     511                        case 'decrementUpdateCount' :
     512                                wp.updates.decrementCount( message.upgradeType );
     513                                break;
     514                        case 'updatePlugin' :
     515                                tb_remove();
     516                                $( '.plugin-update-tr[data-slug="' + message.slug + '"]' ).focus().find( '.update-link' ).trigger( 'click' );
     517                                break;
     518                }
    492519
     520                               
     521
    493522        } );
    494523
    495524        /*