Ticket #32678: 32678.diff
File 32678.diff, 8.6 KB (added by , 10 years ago) |
---|
-
src/wp-includes/admin-bar.php
313 313 'href' => admin_url(), 314 314 ) ); 315 315 316 // Add the a ppearancesubmenu items.317 wp_admin_bar_a ppearance_menu( $wp_admin_bar );316 // Add the admin submenu items. 317 wp_admin_bar_admin_menu( $wp_admin_bar ); 318 318 } 319 319 } 320 320 … … 655 655 } 656 656 657 657 /** 658 * Add appearance submenu items to the "Site Name" menu.658 * Add "Customize" menu. 659 659 * 660 * @since 3.1.0660 * @since 4.3.0 661 661 * 662 662 * @param WP_Admin_Bar $wp_admin_bar 663 663 */ 664 function wp_admin_bar_appearance_menu( $wp_admin_bar ) { 665 $wp_admin_bar->add_group( array( 'parent' => 'site-name', 'id' => 'appearance' ) ); 666 667 $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 668 $customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ); 669 670 if ( current_user_can( 'switch_themes' ) ) { 671 $wp_admin_bar->add_menu( array( 672 'parent' => 'appearance', 673 'id' => 'themes', 674 'title' => __( 'Themes' ), 675 'href' => admin_url( 'themes.php' ), 676 'meta' => array( 677 'class' => 'hide-if-customize', 678 ), 679 ) ); 680 681 if ( current_user_can( 'customize' ) ) { 682 $wp_admin_bar->add_menu( array( 683 'parent' => 'appearance', 684 'id' => 'customize-themes', 685 'title' => __( 'Themes' ), 686 'href' => add_query_arg( urlencode( 'autofocus[section]' ), 'themes', $customize_url ), // urlencode() needed due to #16859 687 'meta' => array( 688 'class' => 'hide-if-no-customize', 689 ), 690 ) ); 691 } 692 } 693 664 function wp_admin_bar_customize_menu( $wp_admin_bar ) { 694 665 if ( current_user_can( 'customize' ) ) { 666 $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 667 $customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ); 668 $title = '<span class="ab-icon"></span><span class="ab-label">' . __( 'Customize' ) . '</span>'; 695 669 $wp_admin_bar->add_menu( array( 696 'parent' => 'appearance',697 670 'id' => 'customize', 698 'title' => __('Customize'),671 'title' => $title, 699 672 'href' => $customize_url, 700 673 'meta' => array( 701 674 'class' => 'hide-if-no-customize', … … 703 676 ) ); 704 677 add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' ); 705 678 } 679 } 706 680 707 if ( ! current_user_can( 'edit_theme_options' ) ) { 708 return; 681 /** 682 * Add admin submenu items to the "Site Name" menu. 683 * 684 * @since 4.3.0 685 * 686 * @param WP_Admin_Bar $wp_admin_bar 687 */ 688 function wp_admin_bar_admin_menu( $wp_admin_bar ) { 689 $wp_admin_bar->add_group( array( 'parent' => 'site-name', 'id' => 'admin' ) ); 690 691 // Post types. 692 $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ); 693 694 if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->edit_posts ) ) { 695 $actions[ 'edit.php' ] = array( $cpts['post']->labels->name, 'edit-posts' ); 709 696 } 710 697 711 if ( current_theme_supports( 'widgets' ) ) { 712 $wp_admin_bar->add_menu( array( 713 'parent' => 'appearance', 714 'id' => 'widgets', 715 'title' => __( 'Widgets' ), 716 'href' => admin_url( 'widgets.php' ), 717 'meta' => array( 718 'class' => 'hide-if-customize', 719 ), 720 ) ); 698 if ( isset( $cpts['attachment'] ) && current_user_can( 'edit_posts' ) ) { 699 $actions[ 'upload.php' ] = array( $cpts['attachment']->labels->name, 'edit-media' ); 700 } 721 701 722 if ( current_user_can( 'customize' ) ) { 723 $wp_admin_bar->add_menu( array( 724 'parent' => 'appearance', 725 'id' => 'customize-widgets', 726 'title' => __( 'Widgets' ), 727 'href' => add_query_arg( urlencode( 'autofocus[panel]' ), 'widgets', $customize_url ), // urlencode() needed due to #16859 728 'meta' => array( 729 'class' => 'hide-if-no-customize', 730 ), 731 ) ); 732 } 702 if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->edit_posts ) ) { 703 $actions[ 'edit.php?post_type=page' ] = array( $cpts['page']->labels->name, 'edit-pages' ); 733 704 } 734 705 735 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) 736 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) ); 706 unset( $cpts['post'], $cpts['page'], $cpts['attachment'] ); 737 707 738 if ( current_theme_supports( 'custom-background' ) ) { 739 $wp_admin_bar->add_menu( array( 740 'parent' => 'appearance', 741 'id' => 'background', 742 'title' => __( 'Background' ), 743 'href' => admin_url( 'themes.php?page=custom-background' ), 744 'meta' => array( 745 'class' => 'hide-if-customize', 746 ), 747 ) ); 708 // Add any additional custom post types. 709 foreach ( $cpts as $cpt ) { 710 if ( ! current_user_can( $cpt->cap->edit_posts ) ) 711 continue; 748 712 749 if ( current_user_can( 'customize' ) ) { 713 $key = 'edit.php?post_type=' . $cpt->name; 714 $actions[ $key ] = array( $cpt->labels->name, 'edit-' . $cpt->name ); 715 } 716 717 if ( $actions ) { 718 foreach ( $actions as $link => $action ) { 719 list( $title, $id ) = $action; 720 750 721 $wp_admin_bar->add_menu( array( 751 'parent' => 'appearance', 752 'id' => 'customize-background', 753 'title' => __( 'Background' ), 754 'href' => add_query_arg( urlencode( 'autofocus[control]' ), 'background_image', $customize_url ), // urlencode() needed due to #16859 755 'meta' => array( 756 'class' => 'hide-if-no-customize', 757 ), 722 'parent' => 'admin', 723 'id' => $id, 724 'title' => $title, 725 'href' => admin_url( $link ) 758 726 ) ); 759 727 } 760 728 } 761 729 762 if ( current_theme_supports( 'custom-header' ) ) { 730 // Appearance. 731 if ( current_user_can( 'switch_themes' ) ) { 763 732 $wp_admin_bar->add_menu( array( 764 'parent' => 'appearance', 765 'id' => 'header', 766 'title' => __( 'Header' ), 767 'href' => admin_url( 'themes.php?page=custom-header' ), 768 'meta' => array( 769 'class' => 'hide-if-customize', 770 ), 733 'parent' => 'admin', 734 'id' => 'themes', 735 'title' => __( 'Appearance' ), // @todo should we just say themes here since there isn't a submenu? 736 'href' => admin_url( 'themes.php' ) 771 737 ) ); 738 } 739 740 // Plugins. 741 if ( current_user_can( 'activate_plugins' ) ) { 742 $wp_admin_bar->add_menu( array( 743 'parent' => 'admin', 744 'id' => 'plugins', 745 'title' => __( 'Plugins' ), 746 'href' => admin_url( 'plugins.php' ) 747 ) ); 748 } 772 749 773 if ( current_user_can( 'customize' ) ) { 774 $wp_admin_bar->add_menu( array( 775 'parent' => 'appearance', 776 'id' => 'customize-header', 777 'title' => __( 'Header' ), 778 'href' => add_query_arg( urlencode( 'autofocus[control]' ), 'header_image', $customize_url ), // urlencode() needed due to #16859 779 'meta' => array( 780 'class' => 'hide-if-no-customize', 781 ), 782 ) ); 783 } 750 // Users. 751 if ( current_user_can( 'edit_users' ) ) { 752 $wp_admin_bar->add_menu( array( 753 'parent' => 'admin', 754 'id' => 'edit-users', 755 'title' => __( 'Users' ), 756 'href' => admin_url( 'users.php' ) 757 ) ); 784 758 } 785 759 760 // Settings. 761 if ( current_user_can( 'manage_options' ) ) { 762 $wp_admin_bar->add_menu( array( 763 'parent' => 'admin', 764 'id' => 'settings', 765 'title' => __( 'Settings' ), 766 'href' => admin_url( 'options.php' ) 767 ) ); 768 } 786 769 } 787 770 788 771 /** -
src/wp-includes/class-wp-admin-bar.php
557 557 add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 ); 558 558 add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 ); 559 559 add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 40 ); 560 add_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 75 ); 560 561 561 562 // Content related. 562 563 if ( ! is_network_admin() && ! is_user_admin() ) { -
src/wp-includes/css/admin-bar.css
501 501 margin: 6px 8px 0 -2px; 502 502 } 503 503 504 #wpadminbar #wp-admin-bar- appearance{505 margin-top: -12px;504 #wpadminbar #wp-admin-bar-site-name-default { 505 padding-bottom: 2px; 506 506 } 507 507 508 #wpadminbar #wp-admin-bar-themes { 509 margin-top: 8px; 510 } 511 508 512 #wpadminbar #wp-admin-bar-my-sites > .ab-item:before, 509 513 #wpadminbar #wp-admin-bar-site-name > .ab-item:before { 510 514 content: '\f112'; … … 551 555 } 552 556 553 557 /** 558 * Customize 559 */ 560 #wpadminbar #wp-admin-bar-customize .ab-icon { 561 margin-right: 6px; 562 } 563 564 #wpadminbar #wp-admin-bar-customize .ab-icon:before { 565 content: '\f180'; 566 top: 2px; 567 } 568 569 /** 554 570 * Updates 555 571 */ 556 572 #wpadminbar #wp-admin-bar-updates .ab-icon:before {