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

Built from https://develop.svn.wordpress.org/trunk@49944


git-svn-id: http://core.svn.wordpress.org/trunk@49643 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2021-01-07 16:23:07 +00:00
parent 7e4a39ba6e
commit bc5b34672c
21 changed files with 98 additions and 39 deletions

View File

@ -493,6 +493,16 @@ input[type="number"].tiny-text {
margin: 0 0 0 8px; margin: 0 0 0 8px;
} }
/* @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 { .tablenav .actions select {
float: right; float: right;
margin-left: 6px; margin-left: 6px;

File diff suppressed because one or more lines are too long

View File

@ -492,6 +492,16 @@ input[type="number"].tiny-text {
margin: 0 8px 0 0; 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 { .tablenav .actions select {
float: left; float: left;
margin-right: 6px; margin-right: 6px;

File diff suppressed because one or more lines are too long

View File

@ -31,7 +31,7 @@ if ( $doaction ) {
$doaction = 'delete'; $doaction = 'delete';
} elseif ( isset( $_REQUEST['delete_comments'] ) ) { } elseif ( isset( $_REQUEST['delete_comments'] ) ) {
$comment_ids = $_REQUEST['delete_comments']; $comment_ids = $_REQUEST['delete_comments'];
$doaction = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2']; $doaction = $_REQUEST['action'];
} elseif ( isset( $_REQUEST['ids'] ) ) { } elseif ( isset( $_REQUEST['ids'] ) ) {
$comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) ); $comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) );
} elseif ( wp_get_referer() ) { } elseif ( wp_get_referer() ) {

View File

@ -526,10 +526,6 @@ class WP_List_Table {
return $_REQUEST['action']; return $_REQUEST['action'];
} }
if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) {
return $_REQUEST['action2'];
}
return false; return false;
} }

View File

@ -171,7 +171,7 @@ class WP_Terms_List_Table extends WP_List_Table {
* @return string * @return string
*/ */
public function current_action() { 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'; return 'bulk-delete';
} }

View File

@ -335,8 +335,7 @@ class WP_Users_List_Table extends WP_List_Table {
* @return string The bulk action required. * @return string The bulk action required.
*/ */
public function current_action() { public function current_action() {
if ( ( isset( $_REQUEST['changeit'] ) || isset( $_REQUEST['changeit2'] ) ) && if ( isset( $_REQUEST['changeit'] ) && ! empty( $_REQUEST['new_role'] ) ) {
( ! empty( $_REQUEST['new_role'] ) || ! empty( $_REQUEST['new_role2'] ) ) ) {
return 'promote'; return 'promote';
} }

View File

@ -1219,6 +1219,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. * Shows row actions on focus of its parent container element or any other elements contained within.
* *
@ -1321,9 +1377,8 @@ $document.ready( function() {
pageInput.closest('form').submit( function() { pageInput.closest('form').submit( function() {
/* /*
* action = bulk action dropdown at the top of the table * 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'); pageInput.val('1');
}); });
} }

File diff suppressed because one or more lines are too long

View File

@ -808,7 +808,7 @@ window.commentReply = {
commentReply.toggle($(this).parent()); commentReply.toggle($(this).parent());
}); });
$('#doaction, #doaction2, #post-query-submit').click(function(){ $('#doaction, #post-query-submit').click(function(){
if ( $('#the-comment-list #replyrow').length > 0 ) if ( $('#the-comment-list #replyrow').length > 0 )
commentReply.close(); commentReply.close();
}); });

File diff suppressed because one or more lines are too long

View File

@ -139,7 +139,7 @@ window.wp = window.wp || {};
/** /**
* Adds onclick events to the apply buttons. * Adds onclick events to the apply buttons.
*/ */
$('#doaction, #doaction2').click(function(e){ $('#doaction').click(function(e){
var n; var n;
t.whichBulkButtonId = $( this ).attr( 'id' ); t.whichBulkButtonId = $( this ).attr( 'id' );

File diff suppressed because one or more lines are too long

View File

@ -178,13 +178,12 @@
$( '#find-posts-close' ).click( findPosts.close ); $( '#find-posts-close' ).click( findPosts.close );
// Binds the bulk action events to the submit buttons. // 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` * Handle the bulk action based on its value.
* and handle its action based on its value.
*/ */
$( 'select[name^="action"]' ).each( function() { $( 'select[name="action"]' ).each( function() {
var optionValue = $( this ).val(); var optionValue = $( this ).val();
if ( 'attach' === optionValue ) { if ( 'attach' === optionValue ) {

View File

@ -1,2 +1,2 @@
/*! This file is auto-generated */ /*! This file is auto-generated */
!function(s){window.findPosts={open:function(n,e){var i=s(".ui-find-overlay");return 0===i.length&&(s("body").append('<div class="ui-find-overlay"></div>'),findPosts.overlay()),i.show(),n&&e&&s("#affected").attr("name",n).val(e),s("#find-posts").show(),s("#find-posts-input").focus().keyup(function(n){27==n.which&&findPosts.close()}),findPosts.send(),!1},close:function(){s("#find-posts-response").empty(),s("#find-posts").hide(),s(".ui-find-overlay").hide()},overlay:function(){s(".ui-find-overlay").on("click",function(){findPosts.close()})},send:function(){var n={ps:s("#find-posts-input").val(),action:"find_posts",_ajax_nonce:s("#_ajax_nonce").val()},e=s(".find-box-search .spinner");e.addClass("is-active"),s.ajax(ajaxurl,{type:"POST",data:n,dataType:"json"}).always(function(){e.removeClass("is-active")}).done(function(n){n.success||s("#find-posts-response").text(wp.i18n.__("An error has occurred. Please reload the page and try again.")),s("#find-posts-response").html(n.data)}).fail(function(){s("#find-posts-response").text(wp.i18n.__("An error has occurred. Please reload the page and try again."))})}},s(document).ready(function(){var n,e=s("#wp-media-grid");e.length&&window.wp&&window.wp.media&&(n=_wpMediaGridSettings,n=window.wp.media({frame:"manage",container:e,library:n.queryVars}).open(),e.trigger("wp-media-grid-ready",n)),s("#find-posts-submit").click(function(n){s('#find-posts-response input[type="radio"]:checked').length||n.preventDefault()}),s("#find-posts .find-box-search :input").keypress(function(n){if(13==n.which)return findPosts.send(),!1}),s("#find-posts-search").click(findPosts.send),s("#find-posts-close").click(findPosts.close),s("#doaction, #doaction2").click(function(e){s('select[name^="action"]').each(function(){var n=s(this).val();"attach"===n?(e.preventDefault(),findPosts.open()):"delete"===n&&(showNotice.warn()||e.preventDefault())})}),s(".find-box-inside").on("click","tr",function(){s(this).find(".found-radio input").prop("checked",!0)})})}(jQuery); !function(s){window.findPosts={open:function(n,e){var i=s(".ui-find-overlay");return 0===i.length&&(s("body").append('<div class="ui-find-overlay"></div>'),findPosts.overlay()),i.show(),n&&e&&s("#affected").attr("name",n).val(e),s("#find-posts").show(),s("#find-posts-input").focus().keyup(function(n){27==n.which&&findPosts.close()}),findPosts.send(),!1},close:function(){s("#find-posts-response").empty(),s("#find-posts").hide(),s(".ui-find-overlay").hide()},overlay:function(){s(".ui-find-overlay").on("click",function(){findPosts.close()})},send:function(){var n={ps:s("#find-posts-input").val(),action:"find_posts",_ajax_nonce:s("#_ajax_nonce").val()},e=s(".find-box-search .spinner");e.addClass("is-active"),s.ajax(ajaxurl,{type:"POST",data:n,dataType:"json"}).always(function(){e.removeClass("is-active")}).done(function(n){n.success||s("#find-posts-response").text(wp.i18n.__("An error has occurred. Please reload the page and try again.")),s("#find-posts-response").html(n.data)}).fail(function(){s("#find-posts-response").text(wp.i18n.__("An error has occurred. Please reload the page and try again."))})}},s(document).ready(function(){var n,e=s("#wp-media-grid");e.length&&window.wp&&window.wp.media&&(n=_wpMediaGridSettings,n=window.wp.media({frame:"manage",container:e,library:n.queryVars}).open(),e.trigger("wp-media-grid-ready",n)),s("#find-posts-submit").click(function(n){s('#find-posts-response input[type="radio"]:checked').length||n.preventDefault()}),s("#find-posts .find-box-search :input").keypress(function(n){if(13==n.which)return findPosts.send(),!1}),s("#find-posts-search").click(findPosts.send),s("#find-posts-close").click(findPosts.close),s("#doaction").click(function(e){s('select[name="action"]').each(function(){var n=s(this).val();"attach"===n?(e.preventDefault(),findPosts.open()):"delete"===n&&(showNotice.warn()||e.preventDefault())})}),s(".find-box-inside").on("click","tr",function(){s(this).find(".found-radio input").prop("checked",!0)})})}(jQuery);

View File

@ -140,12 +140,7 @@ if ( $action ) {
case 'promote': case 'promote':
check_admin_referer( 'bulk-users' ); check_admin_referer( 'bulk-users' );
$editable_roles = get_editable_roles(); $editable_roles = get_editable_roles();
$role = false; $role = $_REQUEST['new_role'];
if ( ! empty( $_REQUEST['new_role2'] ) ) {
$role = $_REQUEST['new_role2'];
} elseif ( ! empty( $_REQUEST['new_role'] ) ) {
$role = $_REQUEST['new_role'];
}
if ( empty( $editable_roles[ $role ] ) ) { if ( empty( $editable_roles[ $role ] ) ) {
wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 ); wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );

View File

@ -177,8 +177,8 @@ if ( isset( $_GET['action'] ) ) {
break; break;
case 'allblogs': case 'allblogs':
if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) { if ( isset( $_POST['action'] ) && isset( $_POST['allblogs'] ) ) {
$doaction = -1 != $_POST['action'] ? $_POST['action'] : $_POST['action2']; $doaction = $_POST['action'];
foreach ( (array) $_POST['allblogs'] as $key => $val ) { foreach ( (array) $_POST['allblogs'] as $key => $val ) {
if ( '0' != $val && get_network()->site_id != $val ) { if ( '0' != $val && get_network()->site_id != $val ) {

View File

@ -46,10 +46,10 @@ if ( isset( $_GET['action'] ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); 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' ); check_admin_referer( 'bulk-users-network' );
$doaction = -1 != $_POST['action'] ? $_POST['action'] : $_POST['action2']; $doaction = $_POST['action'];
$userfunction = ''; $userfunction = '';
foreach ( (array) $_POST['allusers'] as $user_id ) { foreach ( (array) $_POST['allusers'] as $user_id ) {

View File

@ -112,12 +112,7 @@ switch ( $wp_list_table->current_action() ) {
} }
$editable_roles = get_editable_roles(); $editable_roles = get_editable_roles();
$role = false; $role = $_REQUEST['new_role'];
if ( ! empty( $_REQUEST['new_role2'] ) ) {
$role = $_REQUEST['new_role2'];
} elseif ( ! empty( $_REQUEST['new_role'] ) ) {
$role = $_REQUEST['new_role'];
}
if ( ! $role || empty( $editable_roles[ $role ] ) ) { if ( ! $role || empty( $editable_roles[ $role ] ) ) {
wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 ); wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.7-alpha-49943'; $wp_version = '5.7-alpha-49944';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.