I see two options here – override the CSS, or remove the “active” classes with JavaScript (sadly there is no action/filter that we can do this server-side) – I opted for the JS approach, it’s cleaner, leaner and meaner:
function wpse_227037_remove_menu_classes() {
echo '<script>jQuery( ".wp-has-current-submenu.wp-menu-open" ).removeClass( "wp-has-current-submenu wp-menu-open" ).addClass( "wp-not-current-submenu" );</script>';
}
add_action( 'adminmenu', 'wpse_227037_remove_menu_classes' );
The adminmenu action fires right after the menu HTML, so the code will execute the moment all admin nodes are in the DOM.
Related Posts:
- How to put placeholder text in the main post input area?
- How to Add a Third Level Sub Menu to the WordPress Admin Menu
- Is it possible to add an admin page using add_submenu_page() and pass a var in the query string?
- maintaing consistent layout wordpress dashboard
- Global State During an Admin Post
- Admin – Handle data before creating or updating a post, page or custom post
- How can I replace content in the WP Admin area before an admin page is rendered?
- Creating Admin Plugin – Content of a page is displayed at global scope as well
- Add a page in admin without adding menu item
- Best practice for plugin: always detect admin-ajax call?
- Plugin Development – Get Admin Url (Including cases where wp-admin is not used)
- Proper way to create an administration page without adding it to the menu
- How to add text editor in plugin menu?
- How to make an admin plugin menu page go full screen?
- Forcing ALL plugin Admin menus into a separate menu
- modify buddpress adminbar only in admin pages
- How to remove admin menu pages inserted by plugins?
- body_class hook for admin pages
- Placing a Custom Post Type Menu Above the Posts Menu Using menu_position?
- Passing arguments to a admin menu page callback?
- Plugin API for easy admin list table generation, handling & exporting of MySQL tables?
- What is the real intention for admin-post.php?
- Completely remove WP_Admin_Bar for specific user roles
- What’s the best method for emptying an option created with the Settings API?
- API to trigger prompt on leaving page
- Show message on wordpress admin dashboard
- How to add a new plugin page under desired Options page?
- how to use thickbox in admin?
- Add a jQuery function to admin pages
- Appearance->Editor not visible
- Is it save to require plugin.php early to be able to use get_plugin_data() earlier?
- WP Cron doesn’t save or in post body
- Admin account only shows Profile and Dashboard with no activity
- why don’t I get error messages in admin when developing?
- Naming Admin Menus and Submenus
- Current class on admin menu using add_submenu_page()
- Why adding Categories does not auto refresh in Backend while using my custom theme?
- Problems with removing admin bar
- Hook event for upload image in the menu
- Check if I am in the Admin Panel (wp-admin)?
- How to add Font Awesome 5 icons in WP Admin dashboard menu?
- Is it possible to modify the media library admin screen?
- How to redirect to action on custom page within admin section
- Change the Default Pages Menu View in wp-admin
- Get user id for delete and update selected user
- Hide Theme options and Customize Admin menu
- Add notification bubble notice in navigation using transients
- Can I individually style items in the backend widget list?
- Associating custom submenu item with post type of top level menu item
- Where should I put “run once” plugin pages?
- Including a JS source with an admin page
- WordPress not working on localhost
- Issue plugin commands in admin settings page
- Programmatically modify an admin page UI of a WordPress site from my WordPress plugin
- Sub Menu content is being duplicated
- Render content after post title in wp-admin
- Adding (blog-specific) links to “My Sites” admin page
- Change the look and feel of admin pages
- Add column to pages table
- What should happen when a WordPress Plugin is activated across the network (Network Wide Activation)
- Is it possible to restrict all admin pages except theme customisation and storefront using plugin?
- is it recommended to use WP_List_Table?
- Including comments meta box on a plugin page
- Issue with contextual help overwriting existing content
- How do I link to a php file in my plugin directory?
- How to create custom settings page for custom plugin
- WordPress theme options Menu
- I am trying to make a page in the admin section similar to the appearance of the Profile page for users
- Unable to get a simple plugin admin page to work
- Filter for admin (back end) ‘reply to’ comment
- How to break line / add to ADMIN menu
- Redirect in WordPress plugin
- How to add custom view links to wp-admin/post.php?
- Does is_admin() really provide a plugin performance improvement?
- How to remove a CPT Menu from the Root Admin only
- jQuery UI tab does not work in the plugin page
- Use options to control jQuery plugin
- Restrict certain actions to plugin-specific admin menu pages only
- How do I duplicate a single post, with all its properties, and save it as a different post?
- check_admin_referer()
- Google Web Core Vitals – management, how to in wordpress and advice
- WordPress Admin Panel Left Sidebar No showing on Post create page
- 400 Bad Request and illegal invocation in wp_ajax based on processData set to false or true
- Admin menu hilighting wrong item for CPT
- Stop unauthorised file access
- Redirect with message after admin_post.php
- How put the correct URL to sub-menu plugin?
- Plugin dev: How to multiply instances of a plugin in the same metabox?
- wp_is_mobile() inside js
- Issue with iframe in TinyMCE
- What happens when you create/edit a menu
- admin page passing $_POST variables to itself
- Menu_slug used for creating options page
- How to change the headline title for an admin page in a plugin?
- How to prepend a header section to all pages related to my WordPress Plugin
- Load specific CSS file
- adding an options menu that allows saving multiple sets of said options
- How can I catch WordPress custom settings page slug has already changed?
- Select a Text for CSS
- WordPress – Filter users list count