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 thepxmag-menu
menu:function my_add_menu_classes( $menu ) { // Do nothing if not on the "Add/edit plans" page. global $plugin_page; if ( 'pxmag-plans-edit' !== $plugin_page ) { return $menu; } foreach ( $menu as $i => $item ) { if ( 'pxmag-menu' === $item[2] ) { $menu[ $i ][4] = add_cssclass( 'wp-has-current-submenu wp-menu-open', $item[4] ); } } return $menu; } add_filter( 'add_menu_classes', 'my_add_menu_classes' );
-
Use the
submenu_file
hook to highlight the “Plans” (pxmag-plans
) sub-menu:function my_submenu_file( $submenu_file, $parent_file ) { global $plugin_page; return ( 'pxmag-plans-edit' === $plugin_page ) ? 'pxmag-plans' : $submenu_file; } add_filter( 'submenu_file', 'my_submenu_file', 10, 2 );