Closed dualjack closed 6 years ago
I have found a bug, when creating root menu page while using namespacing. When namespace occurs, some things are broken.
The simplest code to reproduce it:
<?php namespace tmc\newsletter\src\Controllers; class apf_mainPluginPages extends \ns_tmcAdminPageFramework { function setUp() { $this->setRootMenuPage( 'I am broken' ); $this->addSubMenuItems( array( 'title' => __( 'Emails', 'ns_tmc' ), 'page_slug' => 'ns_tm_emails' ) ); } } new apf_mainPluginPages( 'ns_tmc_options', $this->mainPluginFile, 'manage_options', 'ns_tmc' );
As you can see, it creates root menu but also sub menu with broken link. The broken link follows namespace structure.
When namespaceing is gone, everything works fine.
<?php class apf_mainPluginPages extends ns_tmcAdminPageFramework { function setUp() { $this->setRootMenuPage( 'I am broken' ); $this->addSubMenuItems( array( 'title' => __( 'Emails', 'ns_tmc' ), 'page_slug' => 'ns_tm_emails' ) ); } } new apf_mainPluginPages( 'ns_tmc_options', $this->mainPluginFile, 'manage_options', 'ns_tmc' );
I am not sure for now, but maybe transforming className, used in scripts, to some safe string without backslashes will fix it.
I think this problem occurs, because wordpress method add_menu_page() returns slug with "/" not "\".
Don't mind $this->mainPluginFile I just moved it from upper file for simplicity.
$this->mainPluginFile
I could confirm this problem. Thanks for the report.
I have found a bug, when creating root menu page while using namespacing. When namespace occurs, some things are broken.
The simplest code to reproduce it:
As you can see, it creates root menu but also sub menu with broken link. The broken link follows namespace structure.
When namespaceing is gone, everything works fine.
I am not sure for now, but maybe transforming className, used in scripts, to some safe string without backslashes will fix it.
I think this problem occurs, because wordpress method add_menu_page() returns slug with "/" not "\".