$_wp_submenu_nopriv = array();
$_wp_menu_nopriv = array();
// Loop over submenus and remove pages for which the user does not have privs.
-foreach ( array( 'submenu' ) as $sub_loop ) {
- foreach ($$sub_loop as $parent => $sub) {
- foreach ($sub as $index => $data) {
- if ( ! current_user_can($data[1]) ) {
- unset(${$sub_loop}[$parent][$index]);
- $_wp_submenu_nopriv[$parent][$data[2]] = true;
- }
+foreach ($submenu as $parent => $sub) {
+ foreach ($sub as $index => $data) {
+ if ( ! current_user_can($data[1]) ) {
+ unset($submenu[$parent][$index]);
+ $_wp_submenu_nopriv[$parent][$data[2]] = true;
}
- unset($index, $data);
-
- if ( empty(${$sub_loop}[$parent]) )
- unset(${$sub_loop}[$parent]);
}
- unset($sub, $parent);
+ unset($index, $data);
+
+ if ( empty($submenu[$parent]) )
+ unset($submenu[$parent]);
}
-unset($sub_loop);
+unset($sub, $parent);
/*
* Loop over the top-level menu.
if ( empty($submenu[$data[2]]) )
continue;
$subs = $submenu[$data[2]];
- $first_sub = array_shift($subs);
+ $first_sub = reset( $subs );
$old_parent = $data[2];
$new_parent = $first_sub[2];
- // If the first submenu is not the same as the assigned parent,
- // make the first submenu the new parent.
+ /*
+ * If the first submenu is not the same as the assigned parent,
+ * make the first submenu the new parent.
+ */
if ( $new_parent != $old_parent ) {
$_wp_real_parent_file[$old_parent] = $new_parent;
$menu[$id][2] = $new_parent;
*/
if ( ! empty( $submenu[$data[2]] ) && 1 == count ( $submenu[$data[2]] ) ) {
$subs = $submenu[$data[2]];
- $first_sub = array_shift($subs);
+ $first_sub = reset( $subs );
if ( $data[2] == $first_sub[2] )
unset( $submenu[$data[2]] );
}
$separator_found = false;
foreach ( $menu as $id => $data ) {
if ( 0 == strcmp('wp-menu-separator', $data[4] ) ) {
- if (false == $separator_found) {
+ if ( ! $separator_found ) {
$separator_found = true;
} else {
unset($menu[$id]);
}
unset($id, $data);
+/**
+ *
+ * @param string $add
+ * @param string $class
+ * @return string
+ */
function add_cssclass($add, $class) {
$class = empty($class) ? $add : $class .= ' ' . $add;
return $class;
}
+/**
+ *
+ * @param array $menu
+ * @return array
+ */
function add_menu_classes($menu) {
-
$first = $lastorder = false;
$i = 0;
$mc = count($menu);
$menu_order = array_flip($menu_order);
$default_menu_order = array_flip($default_menu_order);
+ /**
+ *
+ * @global array $menu_order
+ * @global array $default_menu_order
+ *
+ * @param array $a
+ * @param array $b
+ * @return int
+ */
function sort_menu($a, $b) {
global $menu_order, $default_menu_order;
$a = $a[2];
*/
do_action( 'admin_page_access_denied' );
- wp_die( __('You do not have sufficient permissions to access this page.') );
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ), 403 );
}
$menu = add_menu_classes($menu);