Make WordPress Core

Changeset 49944


Ignore:
Timestamp:
01/07/2021 04:21:09 PM (21 months ago)
Author:
johnbillion
Message:

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

Location:
trunk/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/common.js

    r49625 r49944  
    12211221
    12221222    /**
     1223     * Marries a secondary control to its primary control.
     1224     *
     1225     * @param {jQuery} topSelector    The top selector element.
     1226     * @param {jQuery} topSubmit      The top submit element.
     1227     * @param {jQuery} bottomSelector The bottom selector element.
     1228     * @param {jQuery} bottomSubmit   The bottom submit element.
     1229     * @return {void}
     1230     */
     1231    function marryControls( topSelector, topSubmit, bottomSelector, bottomSubmit ) {
     1232        /**
     1233         * Updates the primary selector when the secondary selector is changed.
     1234         *
     1235         * @since 5.7.0
     1236         *
     1237         * @return {void}
     1238         */
     1239        function updateTopSelector() {
     1240            topSelector.val($(this).val());
     1241        }
     1242        bottomSelector.on('change', updateTopSelector);
     1243
     1244        /**
     1245         * Updates the secondary selector when the primary selector is changed.
     1246         *
     1247         * @since 5.7.0
     1248         *
     1249         * @return {void}
     1250         */
     1251        function updateBottomSelector() {
     1252            bottomSelector.val($(this).val());
     1253        }
     1254        topSelector.on('change', updateBottomSelector);
     1255
     1256        /**
     1257         * Triggers the primary submit when then secondary submit is clicked.
     1258         *
     1259         * @since 5.7.0
     1260         *
     1261         * @return {void}
     1262         */
     1263        function triggerSubmitClick(e) {
     1264            e.preventDefault();
     1265            e.stopPropagation();
     1266
     1267            topSubmit.trigger('click');
     1268        }
     1269        bottomSubmit.on('click', triggerSubmitClick);
     1270    }
     1271
     1272    // Marry the secondary "Bulk actions" controls to the primary controls:
     1273    marryControls( $('#bulk-action-selector-top'), $('#doaction'), $('#bulk-action-selector-bottom'), $('#doaction2') );
     1274
     1275    // Marry the secondary "Change role to" controls to the primary controls:
     1276    marryControls( $('#new_role'), $('#changeit'), $('#new_role2'), $('#changeit2') );
     1277
     1278    /**
    12231279     * Shows row actions on focus of its parent container element or any other elements contained within.
    12241280     *
     
    13221378            /*
    13231379             * action = bulk action dropdown at the top of the table
    1324              * action2 = bulk action dropdow at the bottom of the table
    13251380             */
    1326             if ( $('select[name="action"]').val() == -1 && $('select[name="action2"]').val() == -1 && pageInput.val() == currentPage )
     1381            if ( $('select[name="action"]').val() == -1 && pageInput.val() == currentPage )
    13271382                pageInput.val('1');
    13281383        });
  • trunk/src/js/_enqueues/admin/edit-comments.js

    r48650 r49944  
    809809        });
    810810
    811         $('#doaction, #doaction2, #post-query-submit').click(function(){
     811        $('#doaction, #post-query-submit').click(function(){
    812812            if ( $('#the-comment-list #replyrow').length > 0 )
    813813                commentReply.close();
  • trunk/src/js/_enqueues/admin/inline-edit-post.js

    r49703 r49944  
    140140         * Adds onclick events to the apply buttons.
    141141         */
    142         $('#doaction, #doaction2').click(function(e){
     142        $('#doaction').click(function(e){
    143143            var n;
    144144
  • trunk/src/js/_enqueues/admin/media.js

    r48384 r49944  
    179179
    180180        // Binds the bulk action events to the submit buttons.
    181         $( '#doaction, #doaction2' ).click( function( event ) {
     181        $( '#doaction' ).click( function( event ) {
    182182
    183183            /*
    184              * Retrieves all select elements for bulk actions that have a name starting with `action`
    185              * and handle its action based on its value.
     184             * Handle the bulk action based on its value.
    186185             */
    187             $( 'select[name^="action"]' ).each( function() {
     186            $( 'select[name="action"]' ).each( function() {
    188187                var optionValue = $( this ).val();
    189188
  • trunk/src/wp-admin/css/forms.css

    r49921 r49944  
    493493}
    494494
     495/* @since 5.7.0 secondary bulk action controls require JS. */
     496.no-js label[for="bulk-action-selector-bottom"],
     497.no-js select#bulk-action-selector-bottom,
     498.no-js input#doaction2,
     499.no-js label[for="new_role2"],
     500.no-js select#new_role2,
     501.no-js input#changeit2 {
     502    display: none;
     503}
     504
    495505.tablenav .actions select {
    496506    float: left;
  • trunk/src/wp-admin/edit-comments.php

    r49705 r49944  
    3232    } elseif ( isset( $_REQUEST['delete_comments'] ) ) {
    3333        $comment_ids = $_REQUEST['delete_comments'];
    34         $doaction    = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2'];
     34        $doaction    = $_REQUEST['action'];
    3535    } elseif ( isset( $_REQUEST['ids'] ) ) {
    3636        $comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) );
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r49942 r49944  
    525525        if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) {
    526526            return $_REQUEST['action'];
    527         }
    528 
    529         if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) {
    530             return $_REQUEST['action2'];
    531527        }
    532528
  • trunk/src/wp-admin/includes/class-wp-terms-list-table.php

    r48840 r49944  
    172172     */
    173173    public function current_action() {
    174         if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) {
     174        if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && 'delete' === $_REQUEST['action'] ) {
    175175            return 'bulk-delete';
    176176        }
  • trunk/src/wp-admin/includes/class-wp-users-list-table.php

    r49190 r49944  
    336336     */
    337337    public function current_action() {
    338         if ( ( isset( $_REQUEST['changeit'] ) || isset( $_REQUEST['changeit2'] ) ) &&
    339             ( ! empty( $_REQUEST['new_role'] ) || ! empty( $_REQUEST['new_role2'] ) ) ) {
     338        if ( isset( $_REQUEST['changeit'] ) && ! empty( $_REQUEST['new_role'] ) ) {
    340339            return 'promote';
    341340        }
  • trunk/src/wp-admin/network/site-users.php

    r49384 r49944  
    141141            check_admin_referer( 'bulk-users' );
    142142            $editable_roles = get_editable_roles();
    143             $role           = false;
    144             if ( ! empty( $_REQUEST['new_role2'] ) ) {
    145                 $role = $_REQUEST['new_role2'];
    146             } elseif ( ! empty( $_REQUEST['new_role'] ) ) {
    147                 $role = $_REQUEST['new_role'];
    148             }
     143            $role           = $_REQUEST['new_role'];
    149144
    150145            if ( empty( $editable_roles[ $role ] ) ) {
  • trunk/src/wp-admin/network/sites.php

    r49286 r49944  
    178178
    179179        case 'allblogs':
    180             if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
    181                 $doaction = -1 != $_POST['action'] ? $_POST['action'] : $_POST['action2'];
     180            if ( isset( $_POST['action'] ) && isset( $_POST['allblogs'] ) ) {
     181                $doaction = $_POST['action'];
    182182
    183183                foreach ( (array) $_POST['allblogs'] as $key => $val ) {
  • trunk/src/wp-admin/network/users.php

    r49286 r49944  
    4747            }
    4848
    49             if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) {
     49            if ( isset( $_POST['action'] ) && isset( $_POST['allusers'] ) ) {
    5050                check_admin_referer( 'bulk-users-network' );
    5151
    52                 $doaction     = -1 != $_POST['action'] ? $_POST['action'] : $_POST['action2'];
     52                $doaction     = $_POST['action'];
    5353                $userfunction = '';
    5454
  • trunk/src/wp-admin/users.php

    r49286 r49944  
    113113
    114114        $editable_roles = get_editable_roles();
    115         $role           = false;
    116         if ( ! empty( $_REQUEST['new_role2'] ) ) {
    117             $role = $_REQUEST['new_role2'];
    118         } elseif ( ! empty( $_REQUEST['new_role'] ) ) {
    119             $role = $_REQUEST['new_role'];
    120         }
     115        $role           = $_REQUEST['new_role'];
    121116
    122117        if ( ! $role || empty( $editable_roles[ $role ] ) ) {
Note: See TracChangeset for help on using the changeset viewer.