diff options
author | John Blackbourn <johnbillion@git.wordpress.org> | 2021-01-07 16:21:09 +0000 |
---|---|---|
committer | John Blackbourn <johnbillion@git.wordpress.org> | 2021-01-07 16:21:09 +0000 |
commit | 9010454dfe44df99c89d98696c0c152848e5e7af (patch) | |
tree | 9bb97c0f446a5aa5b3a68728bb520a2be1b8cd88 /src | |
parent | 6409904a19cd9768dc3a53a0b38755bc2f81204a (diff) | |
download | wordpress-9010454dfe44df99c89d98696c0c152848e5e7af.tar.gz wordpress-9010454dfe44df99c89d98696c0c152848e5e7af.zip |
Quick/Bulk Edit: By the power vested in me, I hereby declare the top bulk actions and the bottom bulk actions joined forever in MatrimonyScript.
This joyous marriage means that users will no longer find a selected top bulk action on a list table unexpectedly being applied instead of their selected bottom bulk action. The top and bottom controls for changing user roles are equally wedded forever too.
Props clayray, subrataemfluence, garrett-eclipse, pbiron, hareesh-pillai
Fixes #46872
git-svn-id: https://develop.svn.wordpress.org/trunk@49944 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src')
-rw-r--r-- | src/js/_enqueues/admin/common.js | 59 | ||||
-rw-r--r-- | src/js/_enqueues/admin/edit-comments.js | 2 | ||||
-rw-r--r-- | src/js/_enqueues/admin/inline-edit-post.js | 2 | ||||
-rw-r--r-- | src/js/_enqueues/admin/media.js | 7 | ||||
-rw-r--r-- | src/wp-admin/css/forms.css | 10 | ||||
-rw-r--r-- | src/wp-admin/edit-comments.php | 2 | ||||
-rw-r--r-- | src/wp-admin/includes/class-wp-list-table.php | 4 | ||||
-rw-r--r-- | src/wp-admin/includes/class-wp-terms-list-table.php | 2 | ||||
-rw-r--r-- | src/wp-admin/includes/class-wp-users-list-table.php | 3 | ||||
-rw-r--r-- | src/wp-admin/network/site-users.php | 7 | ||||
-rw-r--r-- | src/wp-admin/network/sites.php | 4 | ||||
-rw-r--r-- | src/wp-admin/network/users.php | 4 | ||||
-rw-r--r-- | src/wp-admin/users.php | 7 |
13 files changed, 81 insertions, 32 deletions
diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js index eea96d3778..2a037d81db 100644 --- a/src/js/_enqueues/admin/common.js +++ b/src/js/_enqueues/admin/common.js @@ -1220,6 +1220,62 @@ $document.ready( function() { }); /** + * Marries a secondary control to its primary control. + * + * @param {jQuery} topSelector The top selector element. + * @param {jQuery} topSubmit The top submit element. + * @param {jQuery} bottomSelector The bottom selector element. + * @param {jQuery} bottomSubmit The bottom submit element. + * @return {void} + */ + function marryControls( topSelector, topSubmit, bottomSelector, bottomSubmit ) { + /** + * Updates the primary selector when the secondary selector is changed. + * + * @since 5.7.0 + * + * @return {void} + */ + function updateTopSelector() { + topSelector.val($(this).val()); + } + bottomSelector.on('change', updateTopSelector); + + /** + * Updates the secondary selector when the primary selector is changed. + * + * @since 5.7.0 + * + * @return {void} + */ + function updateBottomSelector() { + bottomSelector.val($(this).val()); + } + topSelector.on('change', updateBottomSelector); + + /** + * Triggers the primary submit when then secondary submit is clicked. + * + * @since 5.7.0 + * + * @return {void} + */ + function triggerSubmitClick(e) { + e.preventDefault(); + e.stopPropagation(); + + topSubmit.trigger('click'); + } + bottomSubmit.on('click', triggerSubmitClick); + } + + // Marry the secondary "Bulk actions" controls to the primary controls: + marryControls( $('#bulk-action-selector-top'), $('#doaction'), $('#bulk-action-selector-bottom'), $('#doaction2') ); + + // Marry the secondary "Change role to" controls to the primary controls: + marryControls( $('#new_role'), $('#changeit'), $('#new_role2'), $('#changeit2') ); + + /** * Shows row actions on focus of its parent container element or any other elements contained within. * * @return {void} @@ -1321,9 +1377,8 @@ $document.ready( function() { pageInput.closest('form').submit( function() { /* * action = bulk action dropdown at the top of the table - * action2 = bulk action dropdow at the bottom of the table */ - if ( $('select[name="action"]').val() == -1 && $('select[name="action2"]').val() == -1 && pageInput.val() == currentPage ) + if ( $('select[name="action"]').val() == -1 && pageInput.val() == currentPage ) pageInput.val('1'); }); } diff --git a/src/js/_enqueues/admin/edit-comments.js b/src/js/_enqueues/admin/edit-comments.js index 5afe2f793f..0dc393ef02 100644 --- a/src/js/_enqueues/admin/edit-comments.js +++ b/src/js/_enqueues/admin/edit-comments.js @@ -808,7 +808,7 @@ window.commentReply = { commentReply.toggle($(this).parent()); }); - $('#doaction, #doaction2, #post-query-submit').click(function(){ + $('#doaction, #post-query-submit').click(function(){ if ( $('#the-comment-list #replyrow').length > 0 ) commentReply.close(); }); diff --git a/src/js/_enqueues/admin/inline-edit-post.js b/src/js/_enqueues/admin/inline-edit-post.js index 98fdb6cf32..8205963fc3 100644 --- a/src/js/_enqueues/admin/inline-edit-post.js +++ b/src/js/_enqueues/admin/inline-edit-post.js @@ -139,7 +139,7 @@ window.wp = window.wp || {}; /** * Adds onclick events to the apply buttons. */ - $('#doaction, #doaction2').click(function(e){ + $('#doaction').click(function(e){ var n; t.whichBulkButtonId = $( this ).attr( 'id' ); diff --git a/src/js/_enqueues/admin/media.js b/src/js/_enqueues/admin/media.js index c992b5d3a4..e34718b466 100644 --- a/src/js/_enqueues/admin/media.js +++ b/src/js/_enqueues/admin/media.js @@ -178,13 +178,12 @@ $( '#find-posts-close' ).click( findPosts.close ); // Binds the bulk action events to the submit buttons. - $( '#doaction, #doaction2' ).click( function( event ) { + $( '#doaction' ).click( function( event ) { /* - * Retrieves all select elements for bulk actions that have a name starting with `action` - * and handle its action based on its value. + * Handle the bulk action based on its value. */ - $( 'select[name^="action"]' ).each( function() { + $( 'select[name="action"]' ).each( function() { var optionValue = $( this ).val(); if ( 'attach' === optionValue ) { diff --git a/src/wp-admin/css/forms.css b/src/wp-admin/css/forms.css index 1d54bd743f..1b593496e4 100644 --- a/src/wp-admin/css/forms.css +++ b/src/wp-admin/css/forms.css @@ -492,6 +492,16 @@ input[type="number"].tiny-text { margin: 0 8px 0 0; } +/* @since 5.7.0 secondary bulk action controls require JS. */ +.no-js label[for="bulk-action-selector-bottom"], +.no-js select#bulk-action-selector-bottom, +.no-js input#doaction2, +.no-js label[for="new_role2"], +.no-js select#new_role2, +.no-js input#changeit2 { + display: none; +} + .tablenav .actions select { float: left; margin-right: 6px; diff --git a/src/wp-admin/edit-comments.php b/src/wp-admin/edit-comments.php index 361cd2f47a..253d60b961 100644 --- a/src/wp-admin/edit-comments.php +++ b/src/wp-admin/edit-comments.php @@ -31,7 +31,7 @@ if ( $doaction ) { $doaction = 'delete'; } elseif ( isset( $_REQUEST['delete_comments'] ) ) { $comment_ids = $_REQUEST['delete_comments']; - $doaction = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2']; + $doaction = $_REQUEST['action']; } elseif ( isset( $_REQUEST['ids'] ) ) { $comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) ); } elseif ( wp_get_referer() ) { diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index 45a3ee9bd8..5797bbcc1a 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -526,10 +526,6 @@ class WP_List_Table { return $_REQUEST['action']; } - if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) { - return $_REQUEST['action2']; - } - return false; } diff --git a/src/wp-admin/includes/class-wp-terms-list-table.php b/src/wp-admin/includes/class-wp-terms-list-table.php index 24df0daf6b..5dd29d5ce1 100644 --- a/src/wp-admin/includes/class-wp-terms-list-table.php +++ b/src/wp-admin/includes/class-wp-terms-list-table.php @@ -171,7 +171,7 @@ class WP_Terms_List_Table extends WP_List_Table { * @return string */ public function current_action() { - if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) { + if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && 'delete' === $_REQUEST['action'] ) { return 'bulk-delete'; } diff --git a/src/wp-admin/includes/class-wp-users-list-table.php b/src/wp-admin/includes/class-wp-users-list-table.php index 42cf19f5f8..7e1e79f500 100644 --- a/src/wp-admin/includes/class-wp-users-list-table.php +++ b/src/wp-admin/includes/class-wp-users-list-table.php @@ -335,8 +335,7 @@ class WP_Users_List_Table extends WP_List_Table { * @return string The bulk action required. */ public function current_action() { - if ( ( isset( $_REQUEST['changeit'] ) || isset( $_REQUEST['changeit2'] ) ) && - ( ! empty( $_REQUEST['new_role'] ) || ! empty( $_REQUEST['new_role2'] ) ) ) { + if ( isset( $_REQUEST['changeit'] ) && ! empty( $_REQUEST['new_role'] ) ) { return 'promote'; } diff --git a/src/wp-admin/network/site-users.php b/src/wp-admin/network/site-users.php index 3de5fd4a51..1130bf58c7 100644 --- a/src/wp-admin/network/site-users.php +++ b/src/wp-admin/network/site-users.php @@ -140,12 +140,7 @@ if ( $action ) { case 'promote': check_admin_referer( 'bulk-users' ); $editable_roles = get_editable_roles(); - $role = false; - if ( ! empty( $_REQUEST['new_role2'] ) ) { - $role = $_REQUEST['new_role2']; - } elseif ( ! empty( $_REQUEST['new_role'] ) ) { - $role = $_REQUEST['new_role']; - } + $role = $_REQUEST['new_role']; if ( empty( $editable_roles[ $role ] ) ) { wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 ); diff --git a/src/wp-admin/network/sites.php b/src/wp-admin/network/sites.php index 0cad45e1cd..dd476765d1 100644 --- a/src/wp-admin/network/sites.php +++ b/src/wp-admin/network/sites.php @@ -177,8 +177,8 @@ if ( isset( $_GET['action'] ) ) { break; case 'allblogs': - if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) { - $doaction = -1 != $_POST['action'] ? $_POST['action'] : $_POST['action2']; + if ( isset( $_POST['action'] ) && isset( $_POST['allblogs'] ) ) { + $doaction = $_POST['action']; foreach ( (array) $_POST['allblogs'] as $key => $val ) { if ( '0' != $val && get_network()->site_id != $val ) { diff --git a/src/wp-admin/network/users.php b/src/wp-admin/network/users.php index e15a5811cd..5943a7819a 100644 --- a/src/wp-admin/network/users.php +++ b/src/wp-admin/network/users.php @@ -46,10 +46,10 @@ if ( isset( $_GET['action'] ) ) { wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); } - if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) { + if ( isset( $_POST['action'] ) && isset( $_POST['allusers'] ) ) { check_admin_referer( 'bulk-users-network' ); - $doaction = -1 != $_POST['action'] ? $_POST['action'] : $_POST['action2']; + $doaction = $_POST['action']; $userfunction = ''; foreach ( (array) $_POST['allusers'] as $user_id ) { diff --git a/src/wp-admin/users.php b/src/wp-admin/users.php index a62f6f1286..e8f006b9f4 100644 --- a/src/wp-admin/users.php +++ b/src/wp-admin/users.php @@ -112,12 +112,7 @@ switch ( $wp_list_table->current_action() ) { } $editable_roles = get_editable_roles(); - $role = false; - if ( ! empty( $_REQUEST['new_role2'] ) ) { - $role = $_REQUEST['new_role2']; - } elseif ( ! empty( $_REQUEST['new_role'] ) ) { - $role = $_REQUEST['new_role']; - } + $role = $_REQUEST['new_role']; if ( ! $role || empty( $editable_roles[ $role ] ) ) { wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 ); |