WordPress.org

Make WordPress Core

Ticket #40442: 40442.diff

File 40442.diff, 11.8 KB (added by ChrisHardie, 2 years ago)

Refreshed patch for Custom Menu -> Navigation Menu change

  • src/wp-admin/js/customize-nav-menus.js

    diff --git src/wp-admin/js/customize-nav-menus.js src/wp-admin/js/customize-nav-menus.js
    index 6736b56bc3..84a5447ed4 100644
     
    24592459                        this._setupAddition();
    24602460                        this._setupTitle();
    24612461
    2462                         // Add menu to Custom Menu widgets.
     2462                        // Add menu to Navigation Menu widgets.
    24632463                        if ( menu ) {
    24642464                                name = displayNavMenuName( menu.name );
    24652465
     
    25092509                                if ( false === to ) {
    25102510                                        control._handleDeletion();
    25112511                                } else {
    2512                                         // Update names in the Custom Menu widgets.
     2512                                        // Update names in the Navigation Menu widgets.
    25132513                                        name = displayNavMenuName( to.name );
    25142514                                        api.control.each( function( widgetControl ) {
    25152515                                                if ( ! widgetControl.extended( api.controlConstructor.widget_form ) || 'nav_menu' !== widgetControl.params.widget_id_base ) {
     
    26512651                                }
    26522652                        });
    26532653
    2654                         // Remove the menu from any Custom Menu widgets.
     2654                        // Remove the menu from any Navigation Menu widgets.
    26552655                        api.control.each(function( widgetControl ) {
    26562656                                if ( ! widgetControl.extended( api.controlConstructor.widget_form ) || 'nav_menu' !== widgetControl.params.widget_id_base ) {
    26572657                                        return;
     
    30633063                                // Add new control for the new menu.
    30643064                                api.section.add( newSection );
    30653065
    3066                                 // Update the values for nav menus in Custom Menu controls.
     3066                                // Update the values for nav menus in Navigation Menu controls.
    30673067                                api.control.each( function( setting ) {
    30683068                                        if ( ! setting.extended( api.controlConstructor.widget_form ) || 'nav_menu' !== setting.params.widget_id_base ) {
    30693069                                                return;
  • src/wp-admin/nav-menus.php

    diff --git src/wp-admin/nav-menus.php src/wp-admin/nav-menus.php
    index d8fc77f01d..88485d0f6b 100644
    wp_nav_menu_setup(); 
    514514wp_initial_nav_menu_meta_boxes();
    515515
    516516if ( ! current_theme_supports( 'menus' ) && ! $num_locations )
    517         $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( 'Your theme does not natively support menus, but you can use them in sidebars by adding a &#8220;Custom Menu&#8221; widget on the <a href="%s">Widgets</a> screen.' ), admin_url( 'widgets.php' ) ) . '</p></div>';
     517        $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( 'Your theme does not natively support menus, but you can use them in sidebars by adding a &#8220;Navigation Menu&#8221; widget on the <a href="%s">Widgets</a> screen.' ), admin_url( 'widgets.php' ) ) . '</p></div>';
    518518
    519519if ( ! $locations_screen ) : // Main tab
    520         $overview  = '<p>' . __( 'This screen is used for managing your custom navigation menus.' ) . '</p>';
     520        $overview  = '<p>' . __( 'This screen is used for managing your navigation menus.' ) . '</p>';
    521521        /* translators: 1: Widgets admin screen URL, 2 and 3: The name of the default themes */
    522         $overview .= '<p>' . sprintf( __( 'Menus can be displayed in locations defined by your theme, even used in sidebars by adding a &#8220;Custom Menu&#8221; widget on the <a href="%1$s">Widgets</a> screen. If your theme does not support the custom menus feature (the default themes, %2$s and %3$s, do), you can learn about adding this support by following the Documentation link to the side.' ), admin_url( 'widgets.php' ), 'Twenty Sixteen', 'Twenty Seventeen' ) . '</p>';
     522        $overview .= '<p>' . sprintf( __( 'Menus can be displayed in locations defined by your theme, even used in sidebars by adding a &#8220;Navigation Menu&#8221; widget on the <a href="%1$s">Widgets</a> screen. If your theme does not support the navigation menus feature (the default themes, %2$s and %3$s, do), you can learn about adding this support by following the Documentation link to the side.' ), admin_url( 'widgets.php' ), 'Twenty Sixteen', 'Twenty Seventeen' ) . '</p>';
    523523        $overview .= '<p>' . __( 'From this screen you can:' ) . '</p>';
    524524        $overview .= '<ul><li>' . __( 'Create, edit, and delete menus' ) . '</li>';
    525525        $overview .= '<li>' . __( 'Add, organize, and modify individual menu items' ) . '</li></ul>';
    if ( ! $locations_screen ) : // Main tab 
    541541                'content' => $menu_management
    542542        ) );
    543543
    544         $editing_menus  = '<p>' . __( 'Each custom menu may contain a mix of links to pages, categories, custom URLs or other content types. Menu links are added by selecting items from the expanding boxes in the left-hand column below.' ) . '</p>';
     544        $editing_menus  = '<p>' . __( 'Each navigation menu may contain a mix of links to pages, categories, custom URLs or other content types. Menu links are added by selecting items from the expanding boxes in the left-hand column below.' ) . '</p>';
    545545        $editing_menus .= '<p>' . __( '<strong>Clicking the arrow to the right of any menu item</strong> in the editor will reveal a standard group of settings. Additional settings such as link target, CSS classes, link relationships, and link descriptions can be enabled and disabled via the Screen Options tab.' ) . '</p>';
    546546        $editing_menus .= '<ul><li>' . __( 'Add one or several items at once by <strong>selecting the checkbox next to each item and clicking Add to Menu</strong>' ) . '</li>';
    547547        $editing_menus .= '<li>' . __( 'To add a custom link, <strong>expand the Custom Links section, enter a URL and link text, and click Add to Menu</strong>' ) .'</li>';
  • src/wp-includes/class-wp-customize-nav-menus.php

    diff --git src/wp-includes/class-wp-customize-nav-menus.php src/wp-includes/class-wp-customize-nav-menus.php
    index 39459ec57d..7b14412780 100644
    final class WP_Customize_Nav_Menus { 
    556556                $description = '<p>' . __( 'This panel is used for managing navigation menus for content you have already published on your site. You can create menus and add items for existing content such as pages, posts, categories, tags, formats, or custom links.' ) . '</p>';
    557557                if ( current_theme_supports( 'widgets' ) ) {
    558558                        /* translators: URL to the widgets panel of the customizer */
    559                         $description .= '<p>' . sprintf( __( 'Menus can be displayed in locations defined by your theme or in <a href="%s">widget areas</a> by adding a &#8220;Custom Menu&#8221; widget.' ), "javascript:wp.customize.panel( 'widgets' ).focus();" ) . '</p>';
     559                        $description .= '<p>' . sprintf( __( 'Menus can be displayed in locations defined by your theme or in <a href="%s">widget areas</a> by adding a &#8220;Navigation Menu&#8221; widget.' ), "javascript:wp.customize.panel( 'widgets' ).focus();" ) . '</p>';
    560560                } else {
    561561                        $description .= '<p>' . __( 'Menus can be displayed in locations defined by your theme.' ) . '</p>';
    562562                }
    final class WP_Customize_Nav_Menus { 
    580580
    581581                if ( current_theme_supports( 'widgets' ) ) {
    582582                        /* translators: URL to the widgets panel of the customizer */
    583                         $description .= '<p>' . sprintf( __( 'If your theme has widget areas, you can also add menus there. Visit the <a href="%s">Widgets panel</a> and add a &#8220;Custom Menu widget&#8221; to display a menu in a sidebar or footer.' ), "javascript:wp.customize.panel( 'widgets' ).focus();" ) . '</p>';
     583                        $description .= '<p>' . sprintf( __( 'If your theme has widget areas, you can also add menus there. Visit the <a href="%s">Widgets panel</a> and add a &#8220;Navigation Menu widget&#8221; to display a menu in a sidebar or footer.' ), "javascript:wp.customize.panel( 'widgets' ).focus();" ) . '</p>';
    584584                }
    585585
    586586                $this->manager->add_section( 'menu_locations', array(
    final class WP_Customize_Nav_Menus { 
    761761                 * @since 4.3.0
    762762                 * @since 4.7.0  Each array item now includes a `$type_label` in addition to `$title`, `$type`, and `$object`.
    763763                 *
    764                  * @param array $item_types Custom menu item types.
     764                 * @param array $item_types Navigation menu item types.
    765765                 */
    766766                $item_types = apply_filters( 'customize_nav_menu_available_item_types', $item_types );
    767767
  • src/wp-includes/class-wp-customize-widgets.php

    diff --git src/wp-includes/class-wp-customize-widgets.php src/wp-includes/class-wp-customize-widgets.php
    index d723358173..a54794b06d 100644
    final class WP_Customize_Widgets { 
    13651365
    13661366                /*
    13671367                 * Make sure that other setting changes have previewed since this widget
    1368                  * may depend on them (e.g. Menus being present for Custom Menu widget).
     1368                 * may depend on them (e.g. Menus being present for Navigation Menu widget).
    13691369                 */
    13701370                if ( ! did_action( 'customize_preview_init' ) ) {
    13711371                        foreach ( $this->manager->settings() as $setting ) {
  • src/wp-includes/js/customize-selective-refresh.js

    diff --git src/wp-includes/js/customize-selective-refresh.js src/wp-includes/js/customize-selective-refresh.js
    index 3da7c0a237..9f78161511 100644
    wp.customize.selectiveRefresh = ( function( $, api ) { 
    883883                        /*
    884884                         * Only trigger renders on (nested) partials that have been not been
    885885                         * handled yet. An example where this would apply is a nav menu
    886                          * embedded inside of a custom menu widget. When the widget's title
     886                         * embedded inside of a navigation menu widget. When the widget's title
    887887                         * is updated, the entire widget will re-render and then the event
    888888                         * will be triggered for the nested nav menu to do any initialization.
    889889                         */
  • src/wp-includes/widgets/class-wp-nav-menu-widget.php

    diff --git src/wp-includes/widgets/class-wp-nav-menu-widget.php src/wp-includes/widgets/class-wp-nav-menu-widget.php
    index 1674fa8606..3886476500 100644
     
    88 */
    99
    1010/**
    11  * Core class used to implement the Custom Menu widget.
     11 * Core class used to implement the Navigation Menu widget.
    1212 *
    1313 * @since 3.0.0
    1414 *
     
    1717class WP_Nav_Menu_Widget extends WP_Widget {
    1818
    1919        /**
    20          * Sets up a new Custom Menu widget instance.
     20         * Sets up a new Navigation Menu widget instance.
    2121         *
    2222         * @since 3.0.0
    2323         */
    2424        public function __construct() {
    2525                $widget_ops = array(
    26                         'description' => __( 'Add a custom menu to your sidebar.' ),
     26                        'description' => __( 'Add a navigation menu to your sidebar.' ),
    2727                        'customize_selective_refresh' => true,
    2828                );
    29                 parent::__construct( 'nav_menu', __('Custom Menu'), $widget_ops );
     29                parent::__construct( 'nav_menu', __('Navigation Menu'), $widget_ops );
    3030        }
    3131
    3232        /**
    33          * Outputs the content for the current Custom Menu widget instance.
     33         * Outputs the content for the current Navigation Menu widget instance.
    3434         *
    3535         * @since 3.0.0
    3636         *
    3737         * @param array $args     Display arguments including 'before_title', 'after_title',
    3838         *                        'before_widget', and 'after_widget'.
    39          * @param array $instance Settings for the current Custom Menu widget instance.
     39         * @param array $instance Settings for the current Navigation Menu widget instance.
    4040         */
    4141        public function widget( $args, $instance ) {
    4242                // Get menu
    class WP_Nav_Menu_Widget extends WP_Widget { 
    5959                );
    6060
    6161                /**
    62                  * Filters the arguments for the Custom Menu widget.
     62                 * Filters the arguments for the Navigation Menu widget.
    6363                 *
    6464                 * @since 4.2.0
    6565                 * @since 4.4.0 Added the `$instance` parameter.
    6666                 *
    6767                 * @param array    $nav_menu_args {
    68                  *     An array of arguments passed to wp_nav_menu() to retrieve a custom menu.
     68                 *     An array of arguments passed to wp_nav_menu() to retrieve a navigation menu.
    6969                 *
    7070                 *     @type callable|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty.
    7171                 *     @type mixed         $menu        Menu ID, slug, or name.
    class WP_Nav_Menu_Widget extends WP_Widget { 
    8080        }
    8181
    8282        /**
    83          * Handles updating settings for the current Custom Menu widget instance.
     83         * Handles updating settings for the current Navigation Menu widget instance.
    8484         *
    8585         * @since 3.0.0
    8686         *
    class WP_Nav_Menu_Widget extends WP_Widget { 
    101101        }
    102102
    103103        /**
    104          * Outputs the settings form for the Custom Menu widget.
     104         * Outputs the settings form for the Navigation Menu widget.
    105105         *
    106106         * @since 3.0.0
    107107         *