Make WordPress Core


Ignore:
Timestamp:
07/29/2015 04:02:08 PM (9 years ago)
Author:
westonruter
Message:

Customizer: Ensure that all existing menus are shown in the Custom Menu widget's dropdown.

  • Ensure that a Custom Menu widget selecting a newly-inserted menu gets updated to use the new menu ID upon Save & Publish.
  • Dynamically update the visibility of the Custom Menu widget's "no menus" message when the number of menus changes between 0 and 1+.
  • Send all dirty Customized settings in update-widget Ajax request and preview() them so that the widget update/form callbacks have access to any data dependencies in the current Customizer session (such as newly created unsaved menus).
  • Update link in Custom Menu widget to point to Menus panel as opposed to Menus admin page, when in the Customizer.
  • Fix an issue with extra space at top immediately after creating new menu.
  • Fix doubled update-widget Ajax requests when changing select dropdown; prevent initial from being aborted.
  • Add missing wp_get_nav_menus() hooks to preview Customizer updates/inserts for nav_menu settings; includes tests.
  • Update wp_get_nav_menu_object() to allow a menu object to be passed in (and thus passed through).

Props westonruter, adamsilverstein.
Fixes #32814.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/customize/nav-menu-setting.php

    r33071 r33488  
    212212        $nav_menu_options = get_option( 'nav_menu_options', array( 'auto_add' => array() ) );
    213213        $this->assertContains( $menu_id, $nav_menu_options['auto_add'] );
     214
     215        $menus = wp_get_nav_menus();
     216        $menus_ids = wp_list_pluck( $menus, 'term_id' );
     217        $i = array_search( $menu_id, $menus_ids );
     218        $this->assertNotFalse( $i, 'Update-previewed menu does not appear in wp_get_nav_menus()' );
     219        $filtered_menu = $menus[ $i ];
     220        $this->assertEquals( 'Name 2', $filtered_menu->name );
    214221    }
    215222
     
    250257        $nav_menu_options = $this->get_nav_menu_items_option();
    251258        $this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
     259
     260        $menus = wp_get_nav_menus();
     261        $menus_ids = wp_list_pluck( $menus, 'term_id' );
     262        $i = array_search( $menu_id, $menus_ids );
     263        $this->assertNotFalse( $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()' );
     264        $filtered_menu = $menus[ $i ];
     265        $this->assertEquals( 'New Menu Name 1', $filtered_menu->name );
    252266    }
    253267
Note: See TracChangeset for help on using the changeset viewer.