Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Remove Accordion Script #205

Merged
merged 9 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/wp-admin/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -3543,7 +3543,6 @@ img {
}

.accordion-section-content {
display: none;
padding: 10px 20px 15px;
overflow: hidden;
background: #fff;
Expand Down
2 changes: 0 additions & 2 deletions src/wp-admin/includes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1417,8 +1417,6 @@ function remove_meta_box( $id, $screen, $context ) {
function do_accordion_sections( $screen, $context, $data_object ) {
global $wp_meta_boxes;

wp_enqueue_script( 'accordion' );

if ( empty( $screen ) ) {
$screen = get_current_screen();
} elseif ( is_string( $screen ) ) {
Expand Down
94 changes: 0 additions & 94 deletions src/wp-admin/js/accordion.js

This file was deleted.

118 changes: 55 additions & 63 deletions src/wp-includes/class-wp-customize-nav-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ public function print_templates() {
*/
public function available_items_template() {
?>
<div id="available-menu-items" class="accordion-container">
<ul id="available-menu-items" class="accordion-container">
<div class="customize-section-title">
<button type="button" class="customize-section-back" tabindex="-1">
<span class="screen-reader-text">
Expand All @@ -1161,7 +1161,7 @@ public function available_items_template() {
<?php _e( 'Add Menu Items' ); ?>
</h3>
</div>
<div id="available-menu-items-search" class="accordion-section cannot-expand">
<li id="available-menu-items-search" class="accordion-section cannot-expand">
<div class="accordion-section-title">
<label class="screen-reader-text" for="menu-items-search">
<?php
Expand All @@ -1186,7 +1186,7 @@ public function available_items_template() {
?>
</span></button>
<ul class="accordion-section-content available-menu-items-list" data-type="search"></ul>
</div>
</li>
<?php

// Ensure the page post type comes first in the list.
Expand All @@ -1208,7 +1208,7 @@ public function available_items_template() {
$this->print_post_type_container( $item_type );
}
?>
</div><!-- #available-menu-items -->
</ul><!-- #available-menu-items -->
<?php
}

Expand All @@ -1218,82 +1218,74 @@ public function available_items_template() {
* To be used in the template #available-menu-items.
*
* @since 4.7.0
* @since CP-2.0.0 - Implement HTML5 <details> tag
*
* Details and summary tags added for accessibility
*
* @param array $available_item_type Menu item data to output, including title, type, and label.
*/
protected function print_post_type_container( $available_item_type ) {
$id = sprintf( 'available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object'] );
?>
<div id="<?php echo esc_attr( $id ); ?>" class="accordion-section">
<h4 class="accordion-section-title" role="presentation">
<?php echo esc_html( $available_item_type['title'] ); ?>
<span class="spinner"></span>
<span class="no-items"><?php _e( 'No items' ); ?></span>
<button type="button" class="button-link" aria-expanded="false">
<span class="screen-reader-text">
<?php
/* translators: %s: Title of a section with menu items. */
printf( __( 'Toggle section: %s' ), esc_html( $available_item_type['title'] ) );
?>
</span>
<span class="toggle-indicator" aria-hidden="true"></span>
</button>
</h4>
<div class="accordion-section-content">
<?php if ( 'post_type' === $available_item_type['type'] ) : ?>
<?php $post_type_obj = get_post_type_object( $available_item_type['object'] ); ?>
<?php if ( current_user_can( $post_type_obj->cap->create_posts ) && current_user_can( $post_type_obj->cap->publish_posts ) ) : ?>
<div class="new-content-item">
<label for="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>" class="screen-reader-text"><?php echo esc_html( $post_type_obj->labels->add_new_item ); ?></label>
<input type="text" id="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>" class="create-item-input" placeholder="<?php echo esc_attr( $post_type_obj->labels->add_new_item ); ?>">
<button type="button" class="button add-content"><?php _e( 'Add' ); ?></button>
</div>
<li id="<?php echo esc_attr( $id ); ?>" class="accordion-section">
<details>
<summary class="accordion-section-title">
<?php echo esc_html( $available_item_type['title'] ); ?>
<span class="no-items"><?php _e( 'No items' ); ?></span>
</summary>
<div class="accordion-section-content">
<?php if ( 'post_type' === $available_item_type['type'] ) : ?>
<?php $post_type_obj = get_post_type_object( $available_item_type['object'] ); ?>
<?php if ( current_user_can( $post_type_obj->cap->create_posts ) && current_user_can( $post_type_obj->cap->publish_posts ) ) : ?>
<div class="new-content-item">
<label for="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>" class="screen-reader-text"><?php echo esc_html( $post_type_obj->labels->add_new_item ); ?></label>
<input type="text" id="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>" class="create-item-input" placeholder="<?php echo esc_attr( $post_type_obj->labels->add_new_item ); ?>">
<button type="button" class="button add-content"><?php _e( 'Add' ); ?></button>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( isset( $available_item_type['type_label'] ) ? $available_item_type['type_label'] : $available_item_type['type'] ); ?>"></ul>
</div>
</div>
<ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( isset( $available_item_type['type_label'] ) ? $available_item_type['type_label'] : $available_item_type['type'] ); ?>"></ul>
</div>
</details>
</li>
<?php
}

/**
* Prints the markup for available menu item custom links.
*
* @since 4.7.0
* @since CP-2.0.0 - Implement HTML5 <details> tag
*
* Details and summary tags added for accessibility
*
*/
protected function print_custom_links_available_menu_item() {
?>
<div id="new-custom-menu-item" class="accordion-section">
<h4 class="accordion-section-title" role="presentation">
<?php _e( 'Custom Links' ); ?>
<button type="button" class="button-link" aria-expanded="false">
<span class="screen-reader-text">
<?php
/* translators: Hidden accessibility text. */
_e( 'Toggle section: Custom Links' );
?>
</span>
<span class="toggle-indicator" aria-hidden="true"></span>
</button>
</h4>
<div class="accordion-section-content customlinkdiv">
<input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[-1][menu-item-type]" />
<p id="menu-item-url-wrap" class="wp-clearfix">
<label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
<input id="custom-menu-item-url" name="menu-item[-1][menu-item-url]" type="text" class="code menu-item-textbox" placeholder="https://">
</p>
<p id="menu-item-name-wrap" class="wp-clearfix">
<label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
<input id="custom-menu-item-name" name="menu-item[-1][menu-item-title]" type="text" class="regular-text menu-item-textbox">
</p>
<p class="button-controls">
<span class="add-to-menu">
<input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-custom-menu-item" id="custom-menu-item-submit">
<span class="spinner"></span>
</span>
</p>
</div>
</div>
<li id="new-custom-menu-item" class="accordion-section">
<details>
<summary class="accordion-section-title">
<?php _e( 'Custom Links' ); ?>
</summary>
<div class="accordion-section-content customlinkdiv">
<input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[-1][menu-item-type]" />
<p id="menu-item-url-wrap" class="wp-clearfix">
<label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
<input id="custom-menu-item-url" name="menu-item[-1][menu-item-url]" type="text" class="code menu-item-textbox" placeholder="https://">
</p>
<p id="menu-item-name-wrap" class="wp-clearfix">
<label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
<input id="custom-menu-item-name" name="menu-item[-1][menu-item-title]" type="text" class="regular-text menu-item-textbox">
</p>
<p class="button-controls">
<span class="add-to-menu">
<input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-custom-menu-item" id="custom-menu-item-submit">
<span class="spinner"></span>
</span>
</p>
</div>
</details>
</li>
<?php
}

Expand Down
4 changes: 1 addition & 3 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -1125,13 +1125,11 @@ function wp_default_scripts( $scripts ) {
$scripts->add( 'customize-widgets', "/wp-admin/js/customize-widgets$suffix.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-backbone', 'customize-controls' ), false, 1 );
$scripts->add( 'customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 );

$scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu', 'wp-sanitize' ), false, 1 );
$scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'nav-menu', 'wp-sanitize' ), false, 1 );
$scripts->add( 'customize-preview-nav-menus', "/wp-includes/js/customize-preview-nav-menus$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 );

$scripts->add( 'wp-custom-header', "/wp-includes/js/wp-custom-header$suffix.js", array( 'wp-a11y' ), false, 1 );

$scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 );

$scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 );
$scripts->add( 'media-models', "/wp-includes/js/media-models$suffix.js", array( 'wp-backbone' ), false, 1 );
did_action( 'init' ) && $scripts->localize(
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/tests/customize/nav-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ public function test_available_items_template() {
if ( $post_types ) {
foreach ( $post_types as $type ) {
$this->assertStringContainsString( 'available-menu-items-post_type-' . esc_attr( $type->name ), $template );
$this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $type->labels->name ) . '#', $template );
$this->assertMatchesRegularExpression( '#<summary class="accordion-section-title".*>\s*' . esc_html( $type->labels->name ) . '#', $template );
$this->assertStringContainsString( 'data-type="post_type"', $template );
$this->assertStringContainsString( 'data-object="' . esc_attr( $type->name ) . '"', $template );
$this->assertStringContainsString( 'data-type_label="' . esc_attr( $type->labels->singular_name ) . '"', $template );
Expand All @@ -780,15 +780,15 @@ public function test_available_items_template() {
if ( $taxonomies ) {
foreach ( $taxonomies as $tax ) {
$this->assertStringContainsString( 'available-menu-items-taxonomy-' . esc_attr( $tax->name ), $template );
$this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $tax->labels->name ) . '#', $template );
$this->assertMatchesRegularExpression( '#<summary class="accordion-section-title".*>\s*' . esc_html( $tax->labels->name ) . '#', $template );
$this->assertStringContainsString( 'data-type="taxonomy"', $template );
$this->assertStringContainsString( 'data-object="' . esc_attr( $tax->name ) . '"', $template );
$this->assertStringContainsString( 'data-type_label="' . esc_attr( $tax->labels->singular_name ) . '"', $template );
}
}

$this->assertStringContainsString( 'available-menu-items-custom_type', $template );
$this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*Custom#', $template );
$this->assertMatchesRegularExpression( '#<summary class="accordion-section-title".*>\s*Custom#', $template );
$this->assertStringContainsString( 'data-type="custom_type"', $template );
$this->assertStringContainsString( 'data-object="custom_object"', $template );
$this->assertStringContainsString( 'data-type_label="Custom Type"', $template );
Expand Down
Loading