framework
framework copied to clipboard
Page API submenu that overrides parent route failure
- Themosis Version: 2.0.5
- WordPress Version: 5.3.2
- PHP Version: 7.3.0
Description
In Wordpress if I have multiple sub pages using add_submenu_page, but the first one has the same menu_slug as the parent (so the menu_slug and the parent_slug values are identical), this causes Wordpress to remove the duplicate of the parent that would appear in the sub menu (this is documented, it's not some weird hack).
If I do the same thing with Page::make, the duplicate submenu is removed as expected, but every submenu page after the first does not obey the route that is defined and displays the default page view instead.
$main = Page::make( 'main', 'Main' )
->set();
$foo = Page::make( 'main', 'Foo' )
->setParent( $main->getSlug() )
->set();
$foo->route( '/', 'App\Http\Controllers\MenuController@foo' );
$bar = Page::make( 'bar', 'Bar' )
->setParent( $main->getSlug() )
->set();
$bar->route( '/', 'App\Http\Controllers\MenuController@bar' );
In this example, Main will not appear in the sub menu, Foo will function as expected, but Bar will just display the default Page view as the route will be ignored