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 can I add an image upload field directly to a custom write panel?
- Creating a table in the admin-style?
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How do i best handle custom plugin page actions?
- How do I improve this admin query snippet to avoid generating duplicate results on non-meta searches?
- Change admin language based on user (in single-site)
- Export data as CSV in back end with proper HTTP headers
- Admin settings update updating every time home page is hit?
- What’s the best method for emptying an option created with the Settings API?
- What is the recommended way to create plugin administration forms?
- Hook the Keydown Event in the TinyMCE Post Editor
- How do you create a custom edit.php / edit pages page
- Cancel post save
- How to add HTML / Form to an Admin Bar Menu
- Create a clickable name in WP_List_Table for Plugin Admin
- Add column to pages table
- Error with Custom Admin Screen in iframe Thickbox
- Add Admin Menu Inside Construct or Init
- Menu Error in Admin Console with Custom Plugin: You do not have sufficient permissions to access this page
- How to add custom content under plugin row in WordPress admin plugin list?
- How to prevent parent admin page from appearring as a child admin page
- JS / JQuery form validation in backend admin menus
- Unified Approach for Placing Option Pages
- How to load the plugin only when logged in?
- Add tab to profile.php wordpress plugin development
- WordPress Ajax callback function from plugin – OOP
- OOP Plugin and Menu – Call to undefined function register_setting()
- WP AJAX is not working, always returns 0
- Change top level menu item to point to custom submenu item
- Admin auto-refresh is interfering with Firebug — how to prevent it?
- add a class when login
- Add a panel to edit post
- Using the default wordpress uploader inside plugin
- Modify users.php page to create page/post on button clicked
- Problems with: manage_${post_type}_posts_columns
- Howto: Use Custom Post Types as Submenu Items in Admin
- Correct check for any admin page with editor
- Set different custom menu items for different user roles
- Show/Hide ‘add new user’ custom fields in wordpress admin panel by click another field
- Prevent third party plugin’s admin page access based on user type
- Bootstrap doesn’t work on admin menu page-How to override wp-admin style?
- How to add WordPress Admin “Insert Link” UI (searches through existing posts for URL) and functionality into a custom plugin?
- wp_filesystem put_contents issue with owner/group
- 500 internal server error on wp-admin only
- Enqueue script globally
- How to Move the Comments Bubble to the Right Side of the Toolbar
- How do I add a favicon that only shows during viewing of my plugin’s admin panel?
- Silently register plugin pages
- 400 Bad Request, in wordpress theme development, wp_ajax
- How to import the css in the plugin admin area?
- Creating multiple wp_editer() text fields in for loop — the text/visual switch only works for first editor
- Displaying “One Time” Notification in Plugins
- Print Dashboard submenu name and filename
- How to group navigation items in the admin panel
- Admin Subpages without Menu entry
- Data not insert and update through ajax and jQuery in admin page?
- Catching Form Submission in WordPress Admin Panel
- Is it possible to load the css just on my plugin admin page?
- AJAX button with success callback. (Titan Framework)
- Creating custom admin panel pages without making a plugin?
- in_array function Problem
- How do I force a download in the admin area?
- Submit form to a different PHP file in the same plugin folder
- Remove Permalink Meta Box not working?
- using admin functions on frontend
- Pause plugin option page until all data manipulation is complete
- Get cat parameter from admin-ajax
- WordPress admin panel not working
- Change Label of custom post type
- How to create plugin settings page for each admin user?
- How to enable or disable check boxes in custom post type
- How to display properly exception or echo string after posting in plugin?
- How to return a blank page
- Same header/footer in Admin, across all network sites in multisite
- How to add conent (text) to Add New pages form of admin in WordPress
- Add a description/hint field in the admin page of a plugin
- Getting 404 page not found error while trying to access add new plugin / themes
- Plugin admin list pages as submenu
- Post data in wp-admin to external database
- WordPress multiple user roles accessing on their information on one site?
- Loading jQuery library from WordPress admin
- How to design WooCommerce-like admin tabs for plugin settings page?
- Show Admin Menu
- Submitting form to admin-post.php WordPress