Make WordPress Core

Ticket #32924: 32924.diff

File 32924.diff, 6.5 KB (added by helen, 8 years ago)
  • src/wp-includes/admin-bar.php

     
    319319}
    320320
    321321/**
     322 * Add the "Customize" link.
     323 *
     324 * @since 4.3.0
     325 *
     326 * @param WP_Admin_Bar $wp_admin_bar
     327 */
     328function wp_admin_bar_customize_menu( $wp_admin_bar ) {
     329        // Don't show for users who can't access the customizer.
     330        if ( ! current_user_can( 'customize' ) ) {
     331                return;
     332        }
     333
     334        $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     335        $customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() );
     336
     337        $wp_admin_bar->add_menu( array(
     338                'id'     => 'customize',
     339                'title'  => __('Customize'),
     340                'href'   => $customize_url,
     341                'meta'   => array(
     342                        'class' => 'hide-if-no-customize',
     343                ),
     344        ) );
     345        add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
     346}
     347
     348/**
    322349 * Add the "My Sites/[Site Name]" menu and all submenus.
    323350 *
    324351 * @since 3.1.0
     
    664691function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
    665692        $wp_admin_bar->add_group( array( 'parent' => 'site-name', 'id' => 'appearance' ) );
    666693
    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 
    670694        if ( current_user_can( 'switch_themes' ) ) {
    671695                $wp_admin_bar->add_menu( array(
    672696                        'parent' => 'appearance',
    673697                        'id'     => 'themes',
    674698                        'title'  => __( 'Themes' ),
    675699                        'href'   => admin_url( 'themes.php' ),
    676                         'meta'   => array(
    677                                 'class' => 'hide-if-customize',
    678                         ),
    679700                ) );
    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                 }
    692701        }
    693702
    694         if ( current_user_can( 'customize' ) ) {
    695                 $wp_admin_bar->add_menu( array(
    696                         'parent' => 'appearance',
    697                         'id'     => 'customize',
    698                         'title'  => __('Customize'),
    699                         'href'   => $customize_url,
    700                         'meta'   => array(
    701                                 'class' => 'hide-if-no-customize',
    702                         ),
    703                 ) );
    704                 add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
    705         }
    706 
    707703        if ( ! current_user_can( 'edit_theme_options' ) ) {
    708704                return;
    709705        }
     
    714710                        'id'     => 'widgets',
    715711                        'title'  => __( 'Widgets' ),
    716712                        'href'   => admin_url( 'widgets.php' ),
    717                         'meta'   => array(
    718                                 'class' => 'hide-if-customize',
    719                         ),
    720713                ) );
    721 
    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                 }
    733714        }
    734715
    735716        if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
     
    745726                                'class' => 'hide-if-customize',
    746727                        ),
    747728                ) );
    748 
    749                 if ( current_user_can( 'customize' ) ) {
    750                         $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                                 ),
    758                         ) );
    759                 }
    760729        }
    761730
    762731        if ( current_theme_supports( 'custom-header' ) ) {
     
    769738                                'class' => 'hide-if-customize',
    770739                        ),
    771740                ) );
    772 
    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                 }
    784741        }
    785742
    786743}
  • src/wp-includes/class-wp-admin-bar.php

     
    556556                add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
    557557                add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
    558558                add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 );
    559                 add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 40 );
     559                add_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 40 );
     560                add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 50 );
    560561
    561562                // Content related.
    562563                if ( ! is_network_admin() && ! is_user_admin() ) {
  • src/wp-includes/css/admin-bar.css

     
    521521        top: 2px;
    522522}
    523523
     524#wpadminbar #wp-admin-bar-customize > .ab-item:before {
     525        content: '\f540';
     526        top: 2px;
     527}
     528
     529
    524530#wpadminbar #wp-admin-bar-edit > .ab-item:before {
    525531        content: '\f464';
    526532        top: 2px;
     
    882888        /* My Sites and "Site Title" menu */
    883889        #wpadminbar #wp-admin-bar-my-sites > .ab-item,
    884890        #wpadminbar #wp-admin-bar-site-name > .ab-item,
     891        #wpadminbar #wp-admin-bar-customize > .ab-item,
    885892        #wpadminbar #wp-admin-bar-edit > .ab-item,
    886893        #wpadminbar #wp-admin-bar-my-account > .ab-item {
    887894                text-indent: 100%;
     
    903910        #wpadminbar #wp-admin-bar-edit > .ab-item:before,
    904911        #wpadminbar #wp-admin-bar-my-sites > .ab-item:before,
    905912        #wpadminbar #wp-admin-bar-site-name > .ab-item:before,
     913        #wpadminbar #wp-admin-bar-customize > .ab-item:before,
    906914        #wpadminbar #wp-admin-bar-my-account > .ab-item:before {
    907915                display: block;
    908916                text-indent: 0;
     
    10161024        #wpadminbar li#wp-admin-bar-my-sites,
    10171025        #wpadminbar li#wp-admin-bar-updates,
    10181026        #wpadminbar li#wp-admin-bar-site-name,
     1027        #wpadminbar li#wp-admin-bar-customize,
    10191028        #wpadminbar li#wp-admin-bar-new-content,
    10201029        #wpadminbar li#wp-admin-bar-edit,
    10211030        #wpadminbar li#wp-admin-bar-comments,
     
    11301139                box-shadow: none;
    11311140        }
    11321141}
     1142
     1143/* Very narrow screens */
     1144@media screen and (max-width: 400px) {
     1145        #wpadminbar li#wp-admin-bar-new-content {
     1146                display: none;
     1147        }
     1148}