Make WordPress Core

Changeset 58894


Ignore:
Timestamp:
08/13/2024 11:35:51 PM (8 weeks ago)
Author:
peterwilsoncc
Message:

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.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/inline-edit-post.js

    r57745 r58894  
    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()
  • trunk/src/wp-admin/css/list-tables.css

    r58567 r58894  
    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%;
  • trunk/src/wp-admin/includes/class-walker-category-checklist.php

    r56434 r58894  
    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 ) . ' /> ' .
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r58745 r58894  
    18431843                            if ( $bulk ) {
    18441844                                $dropdown_args['show_option_no_change'] = __( '&mdash; No Change &mdash;' );
     1845                                $dropdown_args['id']                    = 'bulk_edit_post_parent';
    18451846                            }
    18461847
Note: See TracChangeset for help on using the changeset viewer.