home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Blogs / wordpress2.6.exe / wordpress2.6 / wp-admin / menu.php < prev    next >
Encoding:
PHP Script  |  2008-07-10  |  6.5 KB  |  149 lines

  1. <?php
  2. // This array constructs the admin menu bar.
  3. //
  4. // Menu item name
  5. // The minimum level the user needs to access the item: between 0 and 10
  6. // The URL of the item's file
  7. $menu[0] = array(__('Dashboard'), 'read', 'index.php');
  8.  
  9. if (strpos($_SERVER['REQUEST_URI'], 'edit-pages.php') !== false)
  10.     $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php');
  11. elseif (strpos($_SERVER['REQUEST_URI'], 'link-manager.php') !== false)
  12.     $menu[5] = array(__('Write'), 'manage_links', 'link-add.php');
  13. else
  14.     $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php');
  15.  
  16. if (strpos($_SERVER['REQUEST_URI'], 'page-new.php') !== false)
  17.     $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php');
  18. elseif (strpos($_SERVER['REQUEST_URI'], 'link-add.php') !== false)
  19.     $menu[10] = array(__('Manage'), 'manage_links', 'link-manager.php');
  20. else
  21.     $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
  22.  
  23. $awaiting_mod = wp_count_comments();
  24. $awaiting_mod = $awaiting_mod->moderated;
  25. $menu[15] = array(__('Design'), 'switch_themes', 'themes.php');
  26. $menu[20] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='comment-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php');
  27. $menu[30] = array(__('Settings'), 'manage_options', 'options-general.php');
  28.  
  29. $update_plugins = get_option( 'update_plugins' );
  30. $update_count = count( $update_plugins->response );
  31. $menu[35] = array( sprintf( __('Plugins %s'), "<span id='update-plugins' class='count-$update_count'><span class='plugin-count'>" . number_format_i18n($update_count) . "</span></span>" ), 'activate_plugins', 'plugins.php');
  32. if ( current_user_can('edit_users') )
  33.     $menu[40] = array(__('Users'), 'edit_users', 'users.php');
  34. else
  35.     $menu[40] = array(__('Profile'), 'read', 'profile.php');
  36.  
  37. $_wp_real_parent_file['post.php'] = 'post-new.php'; // Back-compat
  38. $submenu['post-new.php'][5] = array(__('Post'), 'edit_posts', 'post-new.php');
  39. $submenu['post-new.php'][10] = array(__('Page'), 'edit_pages', 'page-new.php');
  40. $submenu['post-new.php'][15] = array(__('Link'), 'manage_links', 'link-add.php');
  41.  
  42. $submenu['edit-comments.php'][5] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
  43.  
  44. $submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php');
  45. $submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php');
  46. $submenu['edit.php'][15] = array(__('Links'), 'manage_links', 'link-manager.php');
  47. $submenu['edit.php'][20] = array(__('Categories'), 'manage_categories', 'categories.php');
  48. $submenu['edit.php'][25] = array(__('Tags'), 'manage_categories', 'edit-tags.php');
  49. $submenu['edit.php'][30] = array(__('Link Categories'), 'manage_categories', 'edit-link-categories.php');
  50. $submenu['edit.php'][35] = array(__('Media Library'), 'upload_files', 'upload.php');
  51. $submenu['edit.php'][40] = array(__('Import'), 'import', 'import.php');
  52. $submenu['edit.php'][45] = array(__('Export'), 'import', 'export.php');
  53.  
  54. if ( current_user_can('edit_users') ) {
  55.     $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.
  56.     $submenu['users.php'][5] = array(__('Authors & Users'), 'edit_users', 'users.php');
  57.     $submenu['users.php'][10] = array(__('Your Profile'), 'read', 'profile.php');
  58. } else {
  59.     $_wp_real_parent_file['users.php'] = 'profile.php';
  60.     $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
  61. }
  62.  
  63. $submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php');
  64. $submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php');
  65. $submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php');
  66. $submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php');
  67. $submenu['options-general.php'][30] = array(__('Privacy'), 'manage_options', 'options-privacy.php');
  68. $submenu['options-general.php'][35] = array(__('Permalinks'), 'manage_options', 'options-permalink.php');
  69. $submenu['options-general.php'][40] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php');
  70.  
  71. $submenu['plugins.php'][5] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
  72. $submenu['plugins.php'][10] = array(__('Plugin Editor'), 'edit_plugins', 'plugin-editor.php');
  73.  
  74. $submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
  75. $submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php');
  76.  
  77. do_action('_admin_menu');
  78.  
  79. // Create list of page plugin hook names.
  80. foreach ($menu as $menu_page) {
  81.     $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]);
  82. }
  83.  
  84. $_wp_submenu_nopriv = array();
  85. $_wp_menu_nopriv = array();
  86. // Loop over submenus and remove pages for which the user does not have privs.
  87. foreach ($submenu as $parent => $sub) {
  88.     foreach ($sub as $index => $data) {
  89.         if ( ! current_user_can($data[1]) ) {
  90.             unset($submenu[$parent][$index]);
  91.             $_wp_submenu_nopriv[$parent][$data[2]] = true;
  92.         }
  93.     }
  94.  
  95.     if ( empty($submenu[$parent]) )
  96.         unset($submenu[$parent]);
  97. }
  98.  
  99. // Loop over the top-level menu.
  100. // Menus for which the original parent is not acessible due to lack of privs will have the next
  101. // submenu in line be assigned as the new menu parent.
  102. foreach ( $menu as $id => $data ) {
  103.     if ( empty($submenu[$data[2]]) )
  104.         continue;
  105.     $subs = $submenu[$data[2]];
  106.     $first_sub = array_shift($subs);
  107.     $old_parent = $data[2];
  108.     $new_parent = $first_sub[2];
  109.     // If the first submenu is not the same as the assigned parent,
  110.     // make the first submenu the new parent.
  111.     if ( $new_parent != $old_parent ) {
  112.         $_wp_real_parent_file[$old_parent] = $new_parent;
  113.         $menu[$id][2] = $new_parent;
  114.  
  115.         foreach ($submenu[$old_parent] as $index => $data) {
  116.             $submenu[$new_parent][$index] = $submenu[$old_parent][$index];
  117.             unset($submenu[$old_parent][$index]);
  118.         }
  119.         unset($submenu[$old_parent]);
  120.         $_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent];
  121.     }
  122. }
  123.  
  124. do_action('admin_menu', '');
  125.  
  126. // Remove menus that have no accessible submenus and require privs that the user does not have.
  127. // Run re-parent loop again.
  128. foreach ( $menu as $id => $data ) {
  129.     // If submenu is empty...
  130.     if ( empty($submenu[$data[2]]) ) {
  131.         // And user doesn't have privs, remove menu.
  132.         if ( ! current_user_can($data[1]) ) {
  133.             $_wp_menu_nopriv[$data[2]] = true;
  134.             unset($menu[$id]);
  135.         }
  136.     }
  137. }
  138.  
  139. unset($id);
  140.  
  141. uksort($menu, "strnatcasecmp"); // make it all pretty
  142.  
  143. if (! user_can_access_admin_page()) {
  144.     do_action('admin_page_access_denied');
  145.     wp_die( __('You do not have sufficient permissions to access this page.') );
  146. }
  147.  
  148. ?>
  149.