Make WordPress Core

Changeset 57580

Timestamp:
02/09/2024 07:48:41 PM (6 months ago)
Author:
joedolson
Message:

Quick/Bulk Edit: Pre-fill category fields with their status.

Pre-fill category fields in the Quick/Bulk Edit form with their current status.

When bulk editing, if only some of the selected items are in a given category, the category's checkbox will display a line to indicate an indeterminate status.

Originally committed in [56172], but reverted due to a bug that removed all categories. Updated commit fixes the bug, adds unit tests, and improves the accessibility of the indeterminate state checkboxes.

Props pavelevap, scribu, chasedsiedu, helen, joshcanhelp, ubernaut, Cyberchicken, laumindproductscomau, SergeyBiryukov, Marcoevich, tomybyte, thinkluke, virtality-marketing-solutions, Michalooki, dmsnell, itecrs, pannelars, WHSajid, samba45, Mte90, johnbillion, tomluckies, soulseekah, francina, oglekler, ajmcfadyen, mukesh27, costdev, hellofromTonya, peterwilsoncc, joedolson, pbiron, oglekler, webcommsat, jorbin, ajmcfadyen, huzaifaalmesbah.
Fixes #11302.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/inline-edit-post.js

    r57093 r57580  
    179179    setBulk : function(){
    180180        var te = '', type = this.type, c = true;
     181
     182
    181183        this.revert();
    182184
     
    217219        // Populate the list of items to bulk edit.
    218220        $( '#bulk-titles' ).html( '<ul id="bulk-titles-list" role="list">' + te + '</ul>' );
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
    219259
    220260        /**
  • trunk/src/wp-admin/css/list-tables.css

    r57553 r57580  
    11501150}
    11511151
     1152
     1153
     1154
     1155
     1156
     1157
     1158
     1159
     1160
     1161
     1162
    11521163#bulk-titles .ntdelbutton,
    11531164#bulk-titles .ntdeltitle,
  • trunk/src/wp-admin/includes/post.php

    r57521 r57580  
    650650
    651651        if ( isset( $new_cats ) && in_array( 'category', $tax_names, true ) ) {
    652             $cats                       = (array) wp_get_post_categories( $post_id );
    653             $post_data['post_category'] = array_unique( array_merge( $cats, $new_cats ) );
     652            $cats = (array) wp_get_post_categories( $post_id );
     653
     654            if (
     655                isset( $post_data['indeterminate_post_category'] )
     656                && is_array( $post_data['indeterminate_post_category'] )
     657            ) {
     658                $indeterminate_post_category = $post_data['indeterminate_post_category'];
     659            } else {
     660                $indeterminate_post_category = array();
     661            }
     662
     663            $indeterminate_cats         = array_intersect( $cats, $indeterminate_post_category );
     664            $determinate_cats           = array_diff( $new_cats, $indeterminate_post_category );
     665            $post_data['post_category'] = array_unique( array_merge( $indeterminate_cats, $determinate_cats ) );
     666
    654667            unset( $post_data['tax_input']['category'] );
    655668        }
  • trunk/tests/phpunit/tests/admin/includesPost.php

    r57068 r57580  
    383383            $this->assertSame( 'aside', get_post_format( $post_id ) );
    384384        }
     385
     386
     387
     388
     389
     390
     391
     392
     393
     394
     395
     396
     397
     398
     399
     400
     401
     402
     403
     404
     405
     406
     407
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
     475
     476
     477
     478
     479
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
     495
     496
     497
     498
     499
     500
     501
     502
     503
     504
     505
     506
     507
     508
     509
    385510    }
    386511
Note: See TracChangeset for help on using the changeset viewer.