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.

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

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


git-svn-id: http://core.svn.wordpress.org/trunk@56604 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2023-11-08 23:22:25 +00:00
parent 77a83f38d9
commit c4b64359d6
8 changed files with 6 additions and 83 deletions

View File

@ -1148,17 +1148,6 @@ ul.cat-checklist {
overflow-y: scroll;
}
ul.cat-checklist input[name="post_category[]"]:indeterminate::before {
content: '';
border-top: 2px solid grey;
width: 65%;
height: 2px;
position: absolute;
top: calc( 50% + 1px );
right: 50%;
transform: translate( 50%, -50% );
}
#bulk-titles .ntdelbutton,
#bulk-titles .ntdeltitle,
.inline-edit-row fieldset ul.cat-checklist label {

File diff suppressed because one or more lines are too long

View File

@ -1147,17 +1147,6 @@ ul.cat-checklist {
overflow-y: scroll;
}
ul.cat-checklist input[name="post_category[]"]:indeterminate::before {
content: '';
border-top: 2px solid grey;
width: 65%;
height: 2px;
position: absolute;
top: calc( 50% + 1px );
left: 50%;
transform: translate( -50%, -50% );
}
#bulk-titles .ntdelbutton,
#bulk-titles .ntdeltitle,
.inline-edit-row fieldset ul.cat-checklist label {

File diff suppressed because one or more lines are too long

View File

@ -649,21 +649,8 @@ function bulk_edit_posts( $post_data = null ) {
}
if ( isset( $new_cats ) && in_array( 'category', $tax_names, true ) ) {
$cats = (array) wp_get_post_categories( $post_id );
if (
isset( $post_data['indeterminate_post_category'] )
&& is_array( $post_data['indeterminate_post_category'] )
) {
$indeterminate_post_category = $post_data['indeterminate_post_category'];
} else {
$indeterminate_post_category = array();
}
$indeterminate_cats = array_intersect( $cats, $indeterminate_post_category );
$determinate_cats = array_diff( $new_cats, $indeterminate_post_category );
$post_data['post_category'] = array_unique( array_merge( $indeterminate_cats, $determinate_cats ) );
$cats = (array) wp_get_post_categories( $post_id );
$post_data['post_category'] = array_unique( array_merge( $cats, $new_cats ) );
unset( $post_data['tax_input']['category'] );
}

View File

@ -178,9 +178,6 @@ window.wp = window.wp || {};
*/
setBulk : function(){
var te = '', type = this.type, c = true;
var checkedPosts = $( 'tbody th.check-column input[type="checkbox"]:checked' );
var categories = {};
var indeterminatePostCategoryField = $( '<input type="hidden" name="indeterminate_post_category[]">' );
this.revert();
$( '#bulk-edit td' ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
@ -220,45 +217,6 @@ window.wp = window.wp || {};
// Populate the list of items to bulk edit.
$( '#bulk-titles' ).html( '<ul id="bulk-titles-list" role="list">' + te + '</ul>' );
// Gather up some statistics on which of these checked posts are in which categories.
checkedPosts.each( function() {
var id = $( this ).val();
var checked = $( '#category_' + id ).text().split( ',' );
checked.map( function( cid ) {
categories[ cid ] || ( categories[ cid ] = 0 );
// Just record that this category is checked.
categories[ cid ]++;
} );
} );
// Compute initial states.
$( '.inline-edit-categories input[name="post_category[]"]' ).each( function() {
// Clear indeterminate states.
$( '<input type="hidden" name="indeterminate_post_category[]">' ).remove();
if ( categories[ $( this ).val() ] == checkedPosts.length ) {
// If the number of checked categories matches the number of selected posts, then all posts are in this category.
$( this ).prop( 'checked', true );
} else if ( categories[ $( this ).val() ] > 0 ) {
// If the number is less than the number of selected posts, then it's indeterminate.
$( this ).prop( 'indeterminate', true );
// Set indeterminate states for the backend.
indeterminatePostCategoryField.val( $( this ).val() );
$( this ).after( indeterminatePostCategoryField );
}
} );
$( '.inline-edit-categories input[name="post_category[]"]' ).on( 'change', function() {
// Remove the indeterminate flags as there was a specific state change.
$( this ).parent().find( 'input[name="indeterminate_post_category[]"]' ).remove();
} );
$( '.inline-edit-save button' ).on( 'click', function() {
$( '.inline-edit-categories input[name="post_category[]"]' ).prop( 'indeterminate', false );
} );
/**
* Binds on click events to handle the list of items to bulk edit.
*

File diff suppressed because one or more lines are too long

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.5-alpha-57089';
$wp_version = '6.5-alpha-57093';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.