Remove theme support for 'menus' in unregister_nav_menu() when there are no more menus.

props kovshenin.
fixes #26900.


git-svn-id: https://develop.svn.wordpress.org/trunk@27220 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2014-02-21 18:13:52 +00:00
parent 4cfcdabdd8
commit b74f222d33
2 changed files with 30 additions and 0 deletions

View File

@@ -156,4 +156,31 @@ class Tests_Theme_Support extends WP_UnitTestCase {
remove_theme_support( 'foobar' );
$this->assertFalse( current_theme_supports( 'foobar', 'bar' ) );
}
/**
* @ticket 26900
*/
function test_supports_menus() {
// Start fresh
_remove_theme_support( 'menus' );
$this->assertFalse( current_theme_supports( 'menus' ) );
// Registering a nav menu automatically adds support.
register_nav_menu( 'primary', 'Primary Navigation' );
register_nav_menu( 'secondary', 'Secondary Navigation' );
$this->assertTrue( current_theme_supports( 'menus' ) );
// Support added internally, can't be removed.
remove_theme_support( 'menus' );
$this->assertTrue( current_theme_supports( 'menus' ) );
// Still supports because of secondary.
unregister_nav_menu( 'primary' );
$this->assertTrue( current_theme_supports( 'menus' ) );
// No longer support because we have no menus.
unregister_nav_menu( 'secondary' );
$this->assertEmpty( get_registered_nav_menus() );
$this->assertFalse( current_theme_supports( 'menus' ) );
}
}