Include script files for admin submenu page

You must have created submenu page using add_submenu_page() hook, so you can use wp_enqueue_script inside callback function of add_submenu_page hook. It will load script only on your submenu page. add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug,’callback’); function callback() { //enqueue script } Or if you want to enqueue script in dashboard(all pages) then you can enqueue … Read more

sub-page settings saving in NETWORK DASHBOARD

The easiest thing to do is to set the form’s action=” and use the global $plugin_page; as described in the Notes section of add_submenu_page(). For example: add_action (‘network_admin_menu’, ‘add_network_menus’) ; function add_network_menus () { add_menu_page (‘My Page Title’, ‘My Menu Title’, ‘manage_network’, ‘my_menu_slug’, ‘my_network_admin_page’) ; add_submenu_page (‘my_menu_slug’, ‘Some Subpage Title’, ‘My Submeny Title’, ‘manage_network’, ‘my_submenu_slug’, … Read more

add submenu page doesn’t display

The fourth parameter in add_submenu_page function is a capability. Try changing it to manage_options so your code looks like this: add_submenu_page(‘tictac_admin_menu’, ‘Sous menu Opening’, ‘Options Opening’, ‘manage_options’, ‘tictac_scripts_menu’, ‘tictac_opening_submenu’ ); Hope it helps

WordPress add page under admin submenu and retaining the active status of the parent submenu page in the menu

If I understand it correctly — you want the “Plans” sub-menu to be highlighted when on the “Add/edit plans” (pxmag-plans-edit) page, then you can do it like so: Use the add_menu_classes hook to highlight the pxmag-menu menu: function my_add_menu_classes( $menu ) { // Do nothing if not on the “Add/edit plans” page. global $plugin_page; if … Read more

Visiting a console submenu page does not expand its parent menu item

You can use the parent_file hook to ensure the TDLRM menu is expanded when viewing the “Store users” or “Categories” page. add_filter( ‘parent_file’, ‘wpse_398962_parent_file’ ); function wpse_398962_parent_file( $parent_file ) { global $submenu_file, $typenow; // 1: This is for highlighting the TDLRM » “Store users” submenu. if ( ‘users.php’ === $parent_file && ! $submenu_file && isset( … Read more

add_submenu_page() issue

edit.php?post_type=weather isn’t a valid PHP function name. If you’re trying to set the menu up as a submenu of your custom post screens, I think edit.php?post_type=weather—the $parent_slug—should be the first parameter, not the last. ie, add_submenu_page( ‘edit.php?post_type=weather’, ‘Weather Information’, ‘Weathers’, ‘manage_options’, ‘weathers’, [$this, ‘weathers’] ); References add_submenu_page()

Change order of custom submenu link in WP Admin?

Take a look at this function. function my_submenu_order($menu_ord) { global $submenu; // echo ‘<pre>’.print_r($submenu,true).'</pre>’; $arr = array(); $arr[] = $submenu[‘users.php’][15]; // Your Profile $arr[] = $submenu[‘users.php’][10]; // Add New $arr[] = $submenu[‘users.php’][5]; // All Users $submenu[‘users.php’] = $arr; return $menu_ord; } add_filter(‘custom_menu_order’, ‘my_submenu_order’); Add that to your functions.php. It changes the default order of the … Read more