I am trying to create an admin menu separator that allows you to put them in with code. This is the function:
function add_admin_menu_separator($position) {
global $menu;
$index = 0;
foreach($menu as $offset => $section) {
if (substr($section[2],0,9)=='separator')
$index++;
if ($offset>=$position) {
$menu[$position] = array('','read',"separator{$index}",'','wp-menu-separator');
break;
}
}
ksort( $menu );
}
The add action bit is below
add_action('admin_init','admin_menu_separator');
function admin_menu_separator() {
add_admin_menu_separator(220);
}
It works okay but it produces the following errors in WordPress when rearranging menus:
> Warning: Invalid argument supplied for foreach() in /home/user/public_html/wp-creation.com/wp-content/themes/liquid_theme_0.4_licensed/functions.php on line 174
> Warning: ksort() expects parameter 1 to be array, null given in /home/user/public_html/wp-creation.com/wp-content/themes/liquid_theme_0.4_licensed/functions.php on line 182
ksort()
is reporting that anull
has been given.. Since no array has been processed by the foreach loop, it will generate the warning – Vadavaden