Skip to content

Commit 2061a52

Browse files
committed
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
1 parent c20224b commit 2061a52

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

src/js/_enqueues/admin/inline-edit-post.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,16 @@ window.wp = window.wp || {};
128128
inlineEditPost.edit( this );
129129
});
130130

131+
// Clone quick edit categories for the bulk editor.
132+
var beCategories = $( '#inline-edit fieldset.inline-edit-categories' ).clone();
133+
134+
// Make "id" attributes globally unique.
135+
beCategories.find( '*[id]' ).each( function() {
136+
this.id = 'bulk-edit-' + this.id;
137+
});
138+
131139
$('#bulk-edit').find('fieldset:first').after(
132-
$('#inline-edit fieldset.inline-edit-categories').clone()
140+
beCategories
133141
).siblings( 'fieldset:last' ).prepend(
134142
$( '#inline-edit .inline-edit-tags-wrap' ).clone()
135143
);

src/wp-admin/css/list-tables.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ tr.inline-edit-row td {
11311131
width: 75%;
11321132
}
11331133

1134-
.inline-edit-row #post_parent,
1134+
.inline-edit-row select[name="post_parent"],
11351135
.inline-edit-row select[name="page_template"] {
11361136
max-width: 80%;
11371137
}

src/wp-admin/includes/class-walker-category-checklist.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,13 @@ public function start_el( &$output, $data_object, $depth = 0, $args = array(), $
107107
/** This filter is documented in wp-includes/category-template.php */
108108
esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>';
109109
} else {
110-
$is_selected = in_array( $category->term_id, $args['selected_cats'], true );
111-
$is_disabled = ! empty( $args['disabled'] );
110+
$is_selected = in_array( $category->term_id, $args['selected_cats'], true );
111+
$is_disabled = ! empty( $args['disabled'] );
112+
$li_element_id = wp_unique_prefixed_id( "in-{$taxonomy}-{$category->term_id}-" );
113+
$checkbox_element_id = wp_unique_prefixed_id( "in-{$taxonomy}-{$category->term_id}-" );
112114

113-
$output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
114-
'<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
115+
$output .= "\n<li id='" . esc_attr( $li_element_id ) . "'$class>" .
116+
'<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="' . esc_attr( $checkbox_element_id ) . '"' .
115117
checked( $is_selected, true, false ) .
116118
disabled( $is_disabled, true, false ) . ' /> ' .
117119
/** This filter is documented in wp-includes/category-template.php */

src/wp-admin/includes/class-wp-posts-list-table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,7 @@ public function inline_edit() {
18421842

18431843
if ( $bulk ) {
18441844
$dropdown_args['show_option_no_change'] = __( '&mdash; No Change &mdash;' );
1845+
$dropdown_args['id'] = 'bulk_edit_post_parent';
18451846
}
18461847

18471848
/**

0 commit comments

Comments
 (0)