php - How can I call server side file of my plugin (wordpress) with menu? -
i have plugin in wordpress contain 2 php files. in main file , added 2 menus , want call second php file when user click on second menu. have public method name list_table_page on second file.
add_menu_page( 'tm-plug', 'test.php', 'manage_options', plugins_url( 'tm_plug/test.php' ), 'list_table_page' );
as it's cited in wp code reference, add_menu_page defined as:
add_menu_page ( string $page_title, //required string $menu_title, //required string $capability, /required string $menu_slug, //required callback $function = '', //optional string $icon_url = '', //option int $position = null //option );
and example given is:
add_menu_page( __( 'custom menu title', 'textdomain' ), 'custom menu', 'manage_options', 'myplugin/myplugin-admin.php', '', plugins_url( 'myplugin/images/icon.png' ), 6 );
which, looking @ code, you're defining values , parameters wrong. have @ below:
add_menu_page ( 'tm-plug', //string $page_title 'tm-plug', //string $menu_title 'manage_options', //string $capability 'list_table_page', //string $menu_slug 'tm_plug/test.php', //callback $function = '' '', //string $icon_url = '' (you haven't defined any) 1 //int $position = null(you haven't defined any) );
hope looking @ comments you'd able see have gone wrong.
Comments
Post a Comment