Make WordPress Core

Changeset 37681


Ignore:
Timestamp:
06/10/2016 10:38:57 PM (8 years ago)
Author:
afercia
Message:

Plugin Install: fix edge-case where the tab=upload page can be accessed directly.

The ?tab=upload page still exists for no-js support and for users who may
access it directly (e.g. from bookmarks or history) or plugins doing the same.
In this page, the "Browse plugins" link should always behave like a link.

Fixes #35429.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/plugin-install.js

    r37221 r37681  
    1212        $tabbables,
    1313        $firstTabbable,
    14         $lastTabbable;
     14        $lastTabbable,
     15        uploadViewToggle = $( '.upload-view-toggle' ),
     16        $body = $( document.body );
    1517
    1618    tb_position = function() {
     
    5456     * modal gets removed from the DOM.
    5557     */
    56     $( 'body' )
     58    $body
    5759        .on( 'thickbox:iframe:loaded', tbWindow, function() {
    5860            iframeLoaded();
     
    181183     * When a user presses the "Upload Plugin" button, show the upload form in place
    182184     * rather than sending them to the devoted upload plugin page.
    183      * @todo consider to abstract this in a generic, reusable, utility, see theme.js
     185     * The `?tab=upload` page still exists for no-js support and for plugins that
     186     * might access it directly (?). When we're in this page, let the link behave
     187     * like a link. Otherwise we're in the normal plugin installer pages and the
     188     * link should behave like a toggle button.
    184189     */
    185     var uploadViewToggle = $( '.upload-view-toggle' ),
    186         $body = $( document.body );
    187 
    188     uploadViewToggle
    189         .attr({
    190             role: 'button',
    191             'aria-expanded': 'false'
    192         })
    193         .on( 'click', function( event ) {
    194             event.preventDefault();
    195             $body.toggleClass( 'show-upload-view' );
    196             uploadViewToggle.attr( 'aria-expanded', $body.hasClass( 'show-upload-view' ) );
    197         });
     190    if ( ! uploadViewToggle.hasClass( 'upload-tab' ) ) {
     191        uploadViewToggle
     192            .attr({
     193                role: 'button',
     194                'aria-expanded': 'false'
     195            })
     196            .on( 'click', function( event ) {
     197                event.preventDefault();
     198                $body.toggleClass( 'show-upload-view' );
     199                uploadViewToggle.attr( 'aria-expanded', $body.hasClass( 'show-upload-view' ) );
     200            });
     201    }
    198202});
Note: See TracChangeset for help on using the changeset viewer.