Skip to content

Commit 2aebf33

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@37681 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 18ef7d6 commit 2aebf33

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

src/wp-admin/js/plugin-install.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ jQuery( document ).ready( function( $ ) {
1111
$iframeBody,
1212
$tabbables,
1313
$firstTabbable,
14-
$lastTabbable;
14+
$lastTabbable,
15+
uploadViewToggle = $( '.upload-view-toggle' ),
16+
$body = $( document.body );
1517

1618
tb_position = function() {
1719
var width = $( window ).width(),
@@ -53,7 +55,7 @@ jQuery( document ).ready( function( $ ) {
5355
* Custom events: when a Thickbox iframe has loaded and when the Thickbox
5456
* modal gets removed from the DOM.
5557
*/
56-
$( 'body' )
58+
$body
5759
.on( 'thickbox:iframe:loaded', tbWindow, function() {
5860
iframeLoaded();
5961
})
@@ -180,19 +182,21 @@ jQuery( document ).ready( function( $ ) {
180182
/*
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
});

0 commit comments

Comments
 (0)