refining admin menu orders and displays
This commit is contained in:
parent
20f9eff0b9
commit
43409893b3
|
|
@ -1,4 +1,15 @@
|
|||
<?php
|
||||
|
||||
/* ---------------------------
|
||||
REMOVING POSTS FROM ADMIN MENU
|
||||
---------------------------*/
|
||||
function post_remove()
|
||||
{
|
||||
remove_menu_page('edit.php');
|
||||
}
|
||||
|
||||
add_action('admin_menu', 'post_remove');
|
||||
|
||||
/* ---------------------------
|
||||
ADMIN STYLES
|
||||
---------------------------*/
|
||||
|
|
@ -128,3 +139,48 @@ function add_custom_post_status($post_states, $post)
|
|||
return $post_states;
|
||||
}
|
||||
add_filter('display_post_states', 'add_custom_post_status', 10, 2);
|
||||
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
REORDER ADMIN MENU & POST TYPE ORDER ON MENU BAR
|
||||
------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Activates the 'menu_order' filter and then hooks into 'menu_order'
|
||||
*/
|
||||
|
||||
/**
|
||||
* Filters WordPress' default menu order
|
||||
*/
|
||||
function metiers_new_admin_menu_order($menu_order)
|
||||
{
|
||||
// define your new desired menu positions here
|
||||
// for example, move 'upload.php' to position #9 and built-in pages to position #1
|
||||
$new_positions = array(
|
||||
'edit.php?post_type=chantiers' => 3,
|
||||
'edit.php?post_type=artisans' => 4,
|
||||
'edit.php?post_type=page' => 5,
|
||||
'upload.php' => 7,
|
||||
'theme-general-settings' => 11,
|
||||
'rank-math' => 20,
|
||||
);
|
||||
// helper function to move an element inside an array
|
||||
function metiers_move_element(&$array, $a, $b)
|
||||
{
|
||||
$out = array_splice($array, $a, 1);
|
||||
array_splice($array, $b, 0, $out);
|
||||
}
|
||||
// traverse through the new positions and move
|
||||
// the items if found in the original menu_positions
|
||||
foreach ($new_positions as $value => $new_index) {
|
||||
// write_log($value);
|
||||
if ($current_index = array_search($value, $menu_order)) {
|
||||
metiers_move_element($menu_order, $current_index, $new_index);
|
||||
}
|
||||
}
|
||||
return $menu_order;
|
||||
};
|
||||
add_action('admin_menu', function () {
|
||||
add_filter('menu_order', 'metiers_new_admin_menu_order');
|
||||
add_filter('custom_menu_order', '__return_true');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user