File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
tests/phpunit/tests/theme Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,9 @@ function unregister_nav_menu( $location ) {
9090
9191 if ( is_array ( $ _wp_registered_nav_menus ) && isset ( $ _wp_registered_nav_menus [$ location ] ) ) {
9292 unset( $ _wp_registered_nav_menus [$ location ] );
93+ if ( empty ( $ _wp_registered_nav_menus ) ) {
94+ _remove_theme_support ( 'menus ' );
95+ }
9396 return true ;
9497 }
9598 return false ;
Original file line number Diff line number Diff line change @@ -156,4 +156,31 @@ function test_plugin_hook() {
156156 remove_theme_support ( 'foobar ' );
157157 $ this ->assertFalse ( current_theme_supports ( 'foobar ' , 'bar ' ) );
158158 }
159+
160+ /**
161+ * @ticket 26900
162+ */
163+ function test_supports_menus () {
164+ // Start fresh
165+ _remove_theme_support ( 'menus ' );
166+ $ this ->assertFalse ( current_theme_supports ( 'menus ' ) );
167+
168+ // Registering a nav menu automatically adds support.
169+ register_nav_menu ( 'primary ' , 'Primary Navigation ' );
170+ register_nav_menu ( 'secondary ' , 'Secondary Navigation ' );
171+ $ this ->assertTrue ( current_theme_supports ( 'menus ' ) );
172+
173+ // Support added internally, can't be removed.
174+ remove_theme_support ( 'menus ' );
175+ $ this ->assertTrue ( current_theme_supports ( 'menus ' ) );
176+
177+ // Still supports because of secondary.
178+ unregister_nav_menu ( 'primary ' );
179+ $ this ->assertTrue ( current_theme_supports ( 'menus ' ) );
180+
181+ // No longer support because we have no menus.
182+ unregister_nav_menu ( 'secondary ' );
183+ $ this ->assertEmpty ( get_registered_nav_menus () );
184+ $ this ->assertFalse ( current_theme_supports ( 'menus ' ) );
185+ }
159186}
You can’t perform that action at this time.
0 commit comments