| 595 | * Add the whole default admin menu. |
| 596 | * |
| 597 | * @since 3.3.0 |
| 598 | */ |
| 599 | function wp_admin_bar_adminmenu_menu( $wp_admin_bar ) { |
| 600 | |
| 601 | $menu = $submenu = array(); |
| 602 | |
| 603 | $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', 'menu-posts' ); |
| 604 | $submenu['edit.php'][5] = array( __('All Posts'), 'edit_posts', 'edit.php' ); |
| 605 | /* translators: add new post */ |
| 606 | $submenu['edit.php'][10] = array( _x('Add New', 'post'), 'edit_posts', 'post-new.php' ); |
| 607 | |
| 608 | $i = 15; |
| 609 | foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { |
| 610 | if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) ) |
| 611 | continue; |
| 612 | |
| 613 | $submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name ); |
| 614 | } |
| 615 | unset($tax); |
| 616 | |
| 617 | $menu[10] = array( __('Media'), 'upload_files', 'upload.php', 'menu-media' ); |
| 618 | $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php'); |
| 619 | /* translators: add new file */ |
| 620 | $submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php'); |
| 621 | |
| 622 | $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', 'menu-links' ); |
| 623 | $submenu['link-manager.php'][5] = array( __('All Links'), 'manage_links', 'link-manager.php' ); |
| 624 | /* translators: add new links */ |
| 625 | $submenu['link-manager.php'][10] = array( _x('Add New', 'link'), 'manage_links', 'link-add.php' ); |
| 626 | $submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-tags.php?taxonomy=link_category' ); |
| 627 | |
| 628 | $menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', 'menu-pages' ); |
| 629 | $submenu['edit.php?post_type=page'][5] = array( __('All Pages'), 'edit_pages', 'edit.php?post_type=page' ); |
| 630 | /* translators: add new page */ |
| 631 | $submenu['edit.php?post_type=page'][10] = array( _x('Add New', 'page'), 'edit_pages', 'post-new.php?post_type=page' ); |
| 632 | $i = 15; |
| 633 | foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { |
| 634 | if ( ! $tax->show_ui || ! in_array('page', (array) $tax->object_type, true) ) |
| 635 | continue; |
| 636 | |
| 637 | $submenu['edit.php?post_type=page'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&post_type=page' ); |
| 638 | } |
| 639 | unset($tax); |
| 640 | |
| 641 | $menu[25] = array( __('Comments'), 'edit_posts', 'edit-comments.php', 'menu-comments' ); |
| 642 | |
| 643 | //$submenu[ 'edit-comments.php' ][0] = array( __('All Comments'), 'edit_posts', 'edit-comments.php' ); |
| 644 | |
| 645 | if ( current_user_can( 'switch_themes') ) { // special case, calls wp_admin_bar_appearance_menu() |
| 646 | $menu[60] = array( '', '', '', 'menu-appearance' ); |
| 647 | } |
| 648 | |
| 649 | $menu[65] = array( __('Plugins'), 'activate_plugins', 'plugins.php', 'menu-plugins' ); |
| 650 | |
| 651 | $submenu['plugins.php'][5] = array( __('Installed Plugins'), 'activate_plugins', 'plugins.php' ); |
| 652 | |
| 653 | if ( ! is_multisite() ) { |
| 654 | /* translators: add new plugin */ |
| 655 | $submenu['plugins.php'][10] = array( _x('Add New', 'plugin'), 'install_plugins', 'plugin-install.php' ); |
| 656 | } |
| 657 | |
| 658 | if ( current_user_can('list_users') ) |
| 659 | $menu[70] = array( __('Users'), 'list_users', 'users.php', 'menu-users' ); |
| 660 | else |
| 661 | $menu[70] = array( __('Profile'), 'read', 'profile.php', 'menu-users' ); |
| 662 | |
| 663 | if ( current_user_can('list_users') ) { |
| 664 | $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php. |
| 665 | $submenu['users.php'][5] = array(__('All Users'), 'list_users', 'users.php'); |
| 666 | if ( current_user_can('create_users') ) |
| 667 | $submenu['users.php'][10] = array(_x('Add New', 'user'), 'create_users', 'user-new.php'); |
| 668 | else |
| 669 | $submenu['users.php'][10] = array(_x('Add New', 'user'), 'promote_users', 'user-new.php'); |
| 670 | |
| 671 | $submenu['users.php'][15] = array(__('Your Profile'), 'read', 'profile.php'); |
| 672 | } else { |
| 673 | $_wp_real_parent_file['users.php'] = 'profile.php'; |
| 674 | $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php'); |
| 675 | if ( current_user_can('create_users') ) |
| 676 | $submenu['profile.php'][10] = array(__('Add New User'), 'create_users', 'user-new.php'); |
| 677 | else |
| 678 | $submenu['profile.php'][10] = array(__('Add New User'), 'promote_users', 'user-new.php'); |
| 679 | } |
| 680 | |
| 681 | $menu[75] = array( __('Tools'), 'edit_posts', 'tools.php', 'menu-tools' ); |
| 682 | $submenu['tools.php'][5] = array( __('Available Tools'), 'edit_posts', 'tools.php' ); |
| 683 | $submenu['tools.php'][10] = array( __('Import'), 'import', 'import.php' ); |
| 684 | $submenu['tools.php'][15] = array( __('Export'), 'export', 'export.php' ); |
| 685 | if ( is_multisite() && !is_main_site() ) |
| 686 | $submenu['tools.php'][25] = array( __('Delete Site'), 'manage_options', 'ms-delete-site.php' ); |
| 687 | if ( ! is_multisite() && defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) |
| 688 | $submenu['tools.php'][50] = array(__('Network Setup'), 'manage_options', 'network.php'); |
| 689 | |
| 690 | $menu[80] = array( __('Settings'), 'manage_options', 'options-general.php', 'menu-settings' ); |
| 691 | $submenu['options-general.php'][10] = array(_x('General', 'settings screen'), 'manage_options', 'options-general.php'); |
| 692 | $submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php'); |
| 693 | $submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php'); |
| 694 | $submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php'); |
| 695 | $submenu['options-general.php'][30] = array(__('Media'), 'manage_options', 'options-media.php'); |
| 696 | $submenu['options-general.php'][35] = array(__('Privacy'), 'manage_options', 'options-privacy.php'); |
| 697 | $submenu['options-general.php'][40] = array(__('Permalinks'), 'manage_options', 'options-permalink.php'); |
| 698 | |
| 699 | foreach ( $menu as $item ) { |
| 700 | if ( 'menu-appearance' == $item[3] ) { |
| 701 | wp_admin_bar_appearance_menu( $wp_admin_bar ); |
| 702 | continue; |
| 703 | } |
| 704 | |
| 705 | if ( !current_user_can($item[1]) ) |
| 706 | continue; |
| 707 | |
| 708 | $wp_admin_bar->add_menu( array('id' => $item[3], 'title' => $item[0], 'href' => admin_url($item[2]), 'parent' => 'site-name') ); |
| 709 | |
| 710 | if ( !empty($submenu[$item[2]]) ) { |
| 711 | foreach ( $submenu[$item[2]] as $name => $value ) { |
| 712 | if ( !current_user_can($value[1]) ) |
| 713 | continue; |
| 714 | |
| 715 | $id = preg_replace( '/[^a-z0-9-]+/', '-', str_replace('.php', '', "{$item[3]}-$name") ); |
| 716 | $wp_admin_bar->add_menu( array( 'parent' => $item[3], 'id' => $id, 'title' => $value[0], 'href' => admin_url($value[2]) ) ); |
| 717 | } |
| 718 | } |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | /** |