[wp-trac] [WordPress Trac] #11302: Bulk editing posts should pre-fill fields with the same value / allow for removal
WordPress Trac
noreply at wordpress.org
Wed Nov 8 23:38:02 UTC 2023
#11302: Bulk editing posts should pre-fill fields with the same value / allow for
removal
-----------------------------+-----------------------------------------
Reporter: pavelevap | Owner: francina
Type: enhancement | Status: reopened
Priority: normal | Milestone: 6.5
Component: Quick/Bulk Edit | Version: 2.9
Severity: normal | Resolution:
Keywords: | Focuses: javascript, administration
-----------------------------+-----------------------------------------
Comment (by joedolson):
The problem with the patch originally committed is that the variable
`indeterminatePostCategoryField` is overwritten each time it's used, so it
only ever applies to the list listed indeterminate input. Declaring the
variable inside the conditional fixes this issue.
{{{
// 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 );
var indeterminatePostCategoryField = $( '<input
type="hidden" name="indeterminate_post_category[]">' );
// Set indeterminate states for the backend.
indeterminatePostCategoryField.val( $( this ).val() );
$( this ).after( indeterminatePostCategoryField );
}
} );
}}}
There are probably other methods to solve this; but this is the cause of
the issue that required the revert.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/11302#comment:88>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list