ControlledChaos
4/20/2018 - 10:27 PM

[WordPress] Customizing the WordPress Administration Menu (For User Experience)

[WordPress] Customizing the WordPress Administration Menu (For User Experience)

<?php

add_filter('custom_menu_order', 'acme_reorder_admin_menu', 10, 1);
add_filter('menu_order', 'acme_reorder_admin_menu', 10, 1);
/**
 * Reorders and cleans up the administration menu to make it more user-friendly.
 *
 * @param  array $menuOrder The current array of menu items.
 * @return array            An updated order of the items that correspond to the menu.
 *
 * @link   https://codex.wordpress.org/Plugin_API/Filter_Reference/custom_menu_order
 */
function acme_reorder_admin_menu($menuOrder)
{
    if (!$menuOrder) {
        return true;
    }

    return array(
        'index.php',
        'separator1',
        'edit.php?post_type=page',
        'edit.php?post_type=acme_homepage',
        'edit.php?post_type=acme_about',
        'edit.php?post_type=acme_profile',
        'separator2',
        'upload.php',
        'separator3',
        'themes.php',
        'plugins.php',
        'users.php',
        'tools.php',
        'options-general.php',
        'separator-last',
    );
}