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?
- How to remove admin menu pages inserted by plugins?
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How do i best handle custom plugin page actions?
- body_class hook for admin pages
- Wp-admin Custom User Management
- Admin Subpages without Menu entry
- I am trying to make a page in the admin section similar to the appearance of the Profile page for users
- creating a plug in that would tap into save/update action of posts [closed]
- Admin top level menu, pointing to an external url
- 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
- Data not insert and update through ajax and jQuery in admin page?
- Catching Form Submission in WordPress Admin Panel
- Redirect in WordPress plugin
- How to add custom view links to wp-admin/post.php?
- Does is_admin() really provide a plugin performance improvement?
- 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?
- How to remove a CPT Menu from the Root Admin only
- jQuery UI tab does not work in the plugin page
- 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
- Use options to control jQuery plugin
- Restrict certain actions to plugin-specific admin menu pages only
- Remove Permalink Meta Box not working?
- How do I duplicate a single post, with all its properties, and save it as a different post?
- Remove Meta-boxes (Yoast SEO plugin) [duplicate]
- using admin functions on frontend
- Pause plugin option page until all data manipulation is complete
- Get cat parameter from admin-ajax
- check_admin_referer()
- Google Web Core Vitals – management, how to in wordpress and advice
- WordPress admin panel not working
- Add two button to page and post admin to redirect to : add new & list of (posts – pages) just after saving post or page
- WordPress Admin Panel Left Sidebar No showing on Post create page
- Add New Button in Admin Panel
- I cant add is_admin control to plugin
- 400 Bad Request and illegal invocation in wp_ajax based on processData set to false or true
- How to add admin.php to WP Admin Menu Link
- Admin menu hilighting wrong item for CPT
- Change Label of custom post type
- How to create plugin settings page for each admin user?
- Stop unauthorised file access
- How to enable or disable check boxes in custom post type
- Redirect with message after admin_post.php
- How to display properly exception or echo string after posting in plugin?
- Convert each new line in the textfield as a new value in an array
- How to return a blank page
- Same header/footer in Admin, across all network sites in multisite
- Get (eventual) permalink from post within Edit Post in Admin panel
- How put the correct URL to sub-menu plugin?
- Adding admin for specific users
- Developing a plugin where users can edit entries saved in database
- Plugin dev: How to multiply instances of a plugin in the same metabox?
- How do I control the list of Pages an author can see?
- wp_is_mobile() inside js
- 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
- Issue with iframe in TinyMCE
- What happens when you create/edit a menu
- Link to a admin submenu item using a custom link
- 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
- admin page passing $_POST variables to itself
- Change Admin menu placement using hooks
- WordPress multiple user roles accessing on their information on one site?
- loop and in admin header problem
- Menu_slug used for creating options page
- Loading jQuery library from WordPress admin
- How to design WooCommerce-like admin tabs for plugin settings page?
- How to change the headline title for an admin page in a plugin?
- How do I display and edit other posts within the ‘Edit Post’ area of Wp-Admin Dashboard
- Show Admin Menu
- How to prepend a header section to all pages related to my WordPress Plugin
- Submitting form to admin-post.php WordPress
- Update Cache on Save Instead of Clearing It?
- Create a menu and a submenu
- Create child of child custom page in wp-admin