As stated in the title, I try to perpetually move the "Collapse Menu" button which is normally the very last entry in the admin sidebar (backend) to the top. I googled but can't find any working solution.
I found that it is printed through wp-admin/menu-header.php
.
So I thought I could override this file with my child theme. But then, when a theme update changes the menu-header.php
file, I would need to realize and reproduce these changes in the child theme as well. Not very practical...
Anybody got an ideas?
As stated in the title, I try to perpetually move the "Collapse Menu" button which is normally the very last entry in the admin sidebar (backend) to the top. I googled but can't find any working solution.
I found that it is printed through wp-admin/menu-header.php
.
So I thought I could override this file with my child theme. But then, when a theme update changes the menu-header.php
file, I would need to realize and reproduce these changes in the child theme as well. Not very practical...
Anybody got an ideas?
Share Improve this question edited Sep 20, 2019 at 14:34 Howdy_McGee♦ 20.9k24 gold badges91 silver badges177 bronze badges asked Sep 18, 2019 at 22:04 McYodaMcYoda 11 Answer
Reset to default 0Rule of thumb is do not modify any core WordPress files. Those in the root, wp-includes, wp-admin. You could do this easily with JavaScript:
/**
* Move the 'Collapse menu' item to the top of the admin menu
*
* @return void
*/
function wpse348570_move_collapse_menu() {
?>
<script>
if( jQuery( '#collapse-menu' ).length ) {
jQuery( '#collapse-menu' ).prependTo( '#adminmenu' );
}
</script>
<?php
}
add_action( 'admin_footer', 'wpse348570_move_collapse_menu' );
You can add the above as a plugin or place it into the child theme.