Make WordPress Core


Ignore:
Timestamp:
11/08/2023 11:23:10 PM (3 years ago)
Author:
peterwilsoncc
Message:

Quick/Bulk Edit: Prevent assigning posts to default categories during bulk edit.

During a bulk edit of posts with different categories, the categories for the edited posts would be reset to the default category: uncategorized by default.

This reverts [56712] to resolve the issue.

Merges [57093] to the 6.4 branch.

Props peterwilsoncc, hellofromtonya, jorbin.
Fixes #59837.
See #11302.

Location:
branches/6.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.4

  • branches/6.4/src/wp-admin/includes/post.php

    r56802 r57094  
    650650
    651651                if ( isset( $new_cats ) && in_array( 'category', $tax_names, true ) ) {
    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 
     652                        $cats                       = (array) wp_get_post_categories( $post_id );
     653                        $post_data['post_category'] = array_unique( array_merge( $cats, $new_cats ) );
    667654                        unset( $post_data['tax_input']['category'] );
    668655                }
Note: See TracChangeset for help on using the changeset viewer.