/ / Impossibile aggiungere il sottomenu nel menu del plugin in wordpress - php, wordpress-plugin, wordpress

Impossibile aggiungere il sottomenu nel menu del plugin in wordpress - php, wordpress-plugin, wordpress

Sto aggiungendo un menu plugin (questo viene aggiunto correttamente) e un sottomenu sotto di esso (questo non compare mai) in questo modo:

//We"ll call the action to add the menu when the plugin is loaded
add_action( "plugins_loaded", "load" );

function load()
{
//Add us to the menu
add_action( "admin_menu", "addToMenu" );
}

function addToMenu()
{
//Main menu
add_plugins_page( "My Plugin", "My Plugin", "administrator", "my-plugin", "handlePlugin" );

//Sub Menu
add_submenu_page( "my-plugin", "test", "test", "administrator", "my-sub-slug", "handleSub" );
}

Quanto sopra aggiunge il "My Plugin" ma non il sottomenu "test". Che cosa sto facendo di sbagliato?

risposte:

0 per risposta № 1

Wordpress non consente gli elementi di menu di terzo livello per impostazione predefinita. Il codice sarebbe necessario per modificare il modo in cui il menu Wordpress funziona per consentire ciò. La soluzione è mettere il tuo oggetto non sotto plugin ma al livello più alto.