Changeset 27670 for trunk/src/wp-admin/includes/menu.php
- Timestamp:
- 03/24/2014 02:34:14 AM (12 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/menu.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/menu.php
r24455 r27670 1 1 <?php 2 3 2 /** 4 3 * Build Administration Menu. … … 8 7 */ 9 8 10 if ( is_network_admin() ) 11 do_action('_network_admin_menu'); 12 elseif ( is_user_admin() ) 13 do_action('_user_admin_menu'); 14 else 15 do_action('_admin_menu'); 9 if ( is_network_admin() ) { 10 11 /** 12 * Fires before the administration menu loads in the Network Admin. 13 * 14 * The hook fires before menus and sub-menus are removed based on user privileges. 15 * 16 * @private 17 * @since 3.1.0 18 */ 19 do_action( '_network_admin_menu' ); 20 } elseif ( is_user_admin() ) { 21 22 /** 23 * Fires before the administration menu loads in the User Admin. 24 * 25 * The hook fires before menus and sub-menus are removed based on user privileges. 26 * 27 * @private 28 * @since 3.1.0 29 */ 30 do_action( '_user_admin_menu' ); 31 } else { 32 33 /** 34 * Fires before the administration menu loads in the admin. 35 * 36 * The hook fires before menus and sub-menus are removed based on user privileges. 37 * 38 * @private 39 * @since 2.2.0 40 */ 41 do_action( '_admin_menu' ); 42 } 16 43 17 44 // Create list of page plugin hook names. … … 62 89 unset($sub_loop); 63 90 64 // Loop over the top-level menu. 65 // Menus for which the original parent is not accessible due to lack of privs will have the next 66 // submenu in line be assigned as the new menu parent. 91 /* 92 * Loop over the top-level menu. 93 * Menus for which the original parent is not accessible due to lack of privileges 94 * will have the next submenu in line be assigned as the new menu parent. 95 */ 67 96 foreach ( $menu as $id => $data ) { 68 97 if ( empty($submenu[$data[2]]) ) … … 90 119 unset($id, $data, $subs, $first_sub, $old_parent, $new_parent); 91 120 92 if ( is_network_admin() ) 93 do_action('network_admin_menu', ''); 94 elseif ( is_user_admin() ) 95 do_action('user_admin_menu', ''); 96 else 97 do_action('admin_menu', ''); 98 99 // Remove menus that have no accessible submenus and require privs that the user does not have. 100 // Run re-parent loop again. 121 if ( is_network_admin() ) { 122 123 /** 124 * Fires before the administration menu loads in the Network Admin. 125 * 126 * @since 3.1.0 127 * 128 * @param string $context Empty context. 129 */ 130 do_action( 'network_admin_menu', '' ); 131 } elseif ( is_user_admin() ) { 132 133 /** 134 * Fires before the administration menu loads in the User Admin. 135 * 136 * @since 3.1.0 137 * 138 * @param string $context Empty context. 139 */ 140 do_action( 'user_admin_menu', '' ); 141 } else { 142 143 /** 144 * Fires before the administration menu loads in the admin. 145 * 146 * @since 1.5.0 147 * 148 * @param string $context Empty context. 149 */ 150 do_action( 'admin_menu', '' ); 151 } 152 153 /* 154 * Remove menus that have no accessible submenus and require privileges 155 * that the user does not have. Run re-parent loop again. 156 */ 101 157 foreach ( $menu as $id => $data ) { 102 158 if ( ! current_user_can($data[1]) ) 103 159 $_wp_menu_nopriv[$data[2]] = true; 104 160 105 // If there is only one submenu and it is has same destination as the parent, 106 // remove the submenu. 161 /* 162 * If there is only one submenu and it is has same destination as the parent, 163 * remove the submenu. 164 */ 107 165 if ( ! empty( $submenu[$data[2]] ) && 1 == count ( $submenu[$data[2]] ) ) { 108 166 $subs = $submenu[$data[2]]; … … 178 236 } 179 237 238 /** 239 * Filter administration menus array with classes added for top-level items. 240 * 241 * @since 2.7.0 242 * 243 * @param array $menu Associative array of administration menu items. 244 */ 180 245 return apply_filters( 'add_menu_classes', $menu ); 181 246 } … … 183 248 uksort($menu, "strnatcasecmp"); // make it all pretty 184 249 185 if ( apply_filters('custom_menu_order', false) ) { 250 /** 251 * Filter whether to enable custom ordering of the administration menu. 252 * 253 * See the 'menu_order' filter for reordering menu items. 254 * 255 * @since 2.8.0 256 * 257 * @param bool $custom Whether custom ordering is enabled. Default false. 258 */ 259 if ( apply_filters( 'custom_menu_order', false ) ) { 260 log_it( 'false is true' ); 186 261 $menu_order = array(); 187 262 foreach ( $menu as $menu_item ) { … … 190 265 unset($menu_item); 191 266 $default_menu_order = $menu_order; 192 $menu_order = apply_filters('menu_order', $menu_order); 267 268 /** 269 * Filter the order of administration menu items. 270 * 271 * A truthy value must first be passed to the 'custom_menu_order' filter 272 * for this filter to work. Use the following to enable custom menu ordering: 273 * 274 * add_filter( 'custom_menu_order', '__return_true' ); 275 * 276 * @since 2.8.0 277 * 278 * @param array $menu_order An ordered array of menu items. 279 */ 280 $menu_order = apply_filters( 'menu_order', $menu_order ); 193 281 $menu_order = array_flip($menu_order); 194 282 $default_menu_order = array_flip($default_menu_order); … … 223 311 224 312 if ( !user_can_access_admin_page() ) { 225 do_action('admin_page_access_denied'); 313 314 /** 315 * Fires when access to an admin page is denied. 316 * 317 * @since 2.5.0 318 */ 319 do_action( 'admin_page_access_denied' ); 320 226 321 wp_die( __('You do not have sufficient permissions to access this page.') ); 227 322 }
Note: See TracChangeset
for help on using the changeset viewer.