Bulk/Quick Edit: Remove duplicate HTML IDs from post list tables.

Removes duplicate IDs on the post list admin pages affecting various list items, selects and checkboxes:

* JavaScript duplication of the inline editing HTML for bulk editing renames various IDs to include the prefix `bulk-edit-`,
* IDs in the Category Checkbox Walker make use of `wp_unique_prefixed_id()` to avoid duplicates, resulting in a numeric suffix, and,
* the post parent dropdown for the bulk editor is given a custom ID `bulk_edit_post_parent`.

Props peterwilsoncc, sergeybiryukov, azaozz, joedolson, siliconforks, zodiac1978, rcreators.
Fixes #61014.


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


git-svn-id: http://core.svn.wordpress.org/trunk@58290 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2024-08-13 23:37:16 +00:00
parent f957219299
commit c1af99e7e6
9 changed files with 22 additions and 11 deletions

View File

@ -1132,7 +1132,7 @@ tr.inline-edit-row td {
width: 75%;
}
.inline-edit-row #post_parent,
.inline-edit-row select[name="post_parent"],
.inline-edit-row select[name="page_template"] {
max-width: 80%;
}

File diff suppressed because one or more lines are too long

View File

@ -1131,7 +1131,7 @@ tr.inline-edit-row td {
width: 75%;
}
.inline-edit-row #post_parent,
.inline-edit-row select[name="post_parent"],
.inline-edit-row select[name="page_template"] {
max-width: 80%;
}

File diff suppressed because one or more lines are too long

View File

@ -107,11 +107,13 @@ class Walker_Category_Checklist extends Walker {
/** This filter is documented in wp-includes/category-template.php */
esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>';
} else {
$is_selected = in_array( $category->term_id, $args['selected_cats'], true );
$is_disabled = ! empty( $args['disabled'] );
$is_selected = in_array( $category->term_id, $args['selected_cats'], true );
$is_disabled = ! empty( $args['disabled'] );
$li_element_id = wp_unique_prefixed_id( "in-{$taxonomy}-{$category->term_id}-" );
$checkbox_element_id = wp_unique_prefixed_id( "in-{$taxonomy}-{$category->term_id}-" );
$output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
'<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
$output .= "\n<li id='" . esc_attr( $li_element_id ) . "'$class>" .
'<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="' . esc_attr( $checkbox_element_id ) . '"' .
checked( $is_selected, true, false ) .
disabled( $is_disabled, true, false ) . ' /> ' .
/** This filter is documented in wp-includes/category-template.php */

View File

@ -1842,6 +1842,7 @@ class WP_Posts_List_Table extends WP_List_Table {
if ( $bulk ) {
$dropdown_args['show_option_no_change'] = __( '&mdash; No Change &mdash;' );
$dropdown_args['id'] = 'bulk_edit_post_parent';
}
/**

View File

@ -128,8 +128,16 @@ window.wp = window.wp || {};
inlineEditPost.edit( this );
});
// Clone quick edit categories for the bulk editor.
var beCategories = $( '#inline-edit fieldset.inline-edit-categories' ).clone();
// Make "id" attributes globally unique.
beCategories.find( '*[id]' ).each( function() {
this.id = 'bulk-edit-' + this.id;
});
$('#bulk-edit').find('fieldset:first').after(
$('#inline-edit fieldset.inline-edit-categories').clone()
beCategories
).siblings( 'fieldset:last' ).prepend(
$( '#inline-edit .inline-edit-tags-wrap' ).clone()
);

File diff suppressed because one or more lines are too long

View File

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