[ Index ]
 

Code source de WordPress 2.1.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/wp-admin/ -> menu.php (source)

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


Généré le : Fri Mar 30 19:41:27 2007 par Balluche grâce à PHPXref 0.7