From 2061a52da3d9d6d3994b0a60b2df07037d95e3d8 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Tue, 13 Aug 2024 23:35:51 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@58894 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/admin/inline-edit-post.js | 10 +++++++++- src/wp-admin/css/list-tables.css | 2 +- .../includes/class-walker-category-checklist.php | 10 ++++++---- src/wp-admin/includes/class-wp-posts-list-table.php | 1 + 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/js/_enqueues/admin/inline-edit-post.js b/src/js/_enqueues/admin/inline-edit-post.js index 65cd342c284b2..9d6f66c3b0034 100644 --- a/src/js/_enqueues/admin/inline-edit-post.js +++ b/src/js/_enqueues/admin/inline-edit-post.js @@ -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() ); diff --git a/src/wp-admin/css/list-tables.css b/src/wp-admin/css/list-tables.css index de36190b51e4c..e06793ea6b12b 100644 --- a/src/wp-admin/css/list-tables.css +++ b/src/wp-admin/css/list-tables.css @@ -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%; } diff --git a/src/wp-admin/includes/class-walker-category-checklist.php b/src/wp-admin/includes/class-walker-category-checklist.php index 1deb3f9206932..7960d06114c3a 100644 --- a/src/wp-admin/includes/class-walker-category-checklist.php +++ b/src/wp-admin/includes/class-walker-category-checklist.php @@ -107,11 +107,13 @@ public function start_el( &$output, $data_object, $depth = 0, $args = array(), $ /** This filter is documented in wp-includes/category-template.php */ esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . ''; } 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
  • " . - '