Make WordPress Core

Ticket #28605: 28605.diff

File 28605.diff, 9.1 KB (added by westonruter, 11 years ago)

Introduce customize capability for access to Customizer. Commit: https://github.com/x-team/wordpress-develop/commit/c4058b5c36ed60a784dd53ce1059e65b4f3e51bd Part of PR: https://github.com/x-team/wordpress-develop/pull/20

  • src/wp-admin/customize.php

    diff --git src/wp-admin/customize.php src/wp-admin/customize.php
    index 1faf371..46ec67b 100644
    define( 'IFRAME_REQUEST', true ); 
    1212/** Load WordPress Administration Bootstrap */
    1313require_once( dirname( __FILE__ ) . '/admin.php' );
    1414
    15 if ( ! current_user_can( 'edit_theme_options' ) )
     15if ( ! current_user_can( 'customize' ) ) {
    1616        wp_die( __( 'Cheatin’ uh?' ) );
     17}
    1718
    1819wp_reset_vars( array( 'url', 'return' ) );
    1920$url = urldecode( $url );
  • src/wp-admin/includes/class-wp-upgrader-skins.php

    diff --git src/wp-admin/includes/class-wp-upgrader-skins.php src/wp-admin/includes/class-wp-upgrader-skins.php
    index c5d1d3f..cd5c68b 100644
    class Theme_Upgrader_Skin extends WP_Upgrader_Skin { 
    594594                        $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
    595595
    596596                        if ( get_stylesheet() == $stylesheet ) {
    597                                 if ( current_user_can( 'edit_theme_options' ) )
     597                                if ( current_user_can( 'customize' ) )
    598598                                        $update_actions['preview']  = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Customize &#8220;%s&#8221;'), $name ) ) . '">' . __('Customize') . '</a>';
    599599                        } elseif ( current_user_can( 'switch_themes' ) ) {
    600600                                $update_actions['preview']  = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Preview') . '</a>';
  • src/wp-admin/includes/schema.php

    diff --git src/wp-admin/includes/schema.php src/wp-admin/includes/schema.php
    index b88a7ab..495e1b6 100644
    function populate_roles() { 
    584584        populate_roles_270();
    585585        populate_roles_280();
    586586        populate_roles_300();
     587        populate_roles_400();
    587588}
    588589
    589590/**
    function populate_roles_160() { 
    633634        $role->add_cap('publish_posts');
    634635        $role->add_cap('edit_pages');
    635636        $role->add_cap('read');
     637        $role->add_cap('customize');
    636638        $role->add_cap('level_10');
    637639        $role->add_cap('level_9');
    638640        $role->add_cap('level_8');
    function populate_roles_300() { 
    830832}
    831833
    832834/**
     835 * Create and modify WordPress roles for WordPress 4.0.
     836 *
     837 * @since 4.0.0
     838 */
     839function populate_roles_400() {
     840        $role = get_role( 'administrator' );
     841
     842        if ( ! empty( $role ) ) {
     843                $role->add_cap( 'customize' );
     844        }
     845}
     846
     847/**
    833848 * Install Network.
    834849 *
    835850 * @since 3.0.0
  • src/wp-admin/includes/upgrade.php

    diff --git src/wp-admin/includes/upgrade.php src/wp-admin/includes/upgrade.php
    index 9e9441e..e105eee 100644
    function upgrade_all() { 
    435435        if ( $wp_current_db_version < 26691 )
    436436                upgrade_380();
    437437
     438        if ( $wp_current_db_version < 27917 )
     439                upgrade_400();
     440
    438441        maybe_disable_link_manager();
    439442
    440443        maybe_disable_automattic_widgets();
    function upgrade_380() { 
    12961299                deactivate_plugins( array( 'mp6/mp6.php' ), true );
    12971300        }
    12981301}
     1302
     1303/**
     1304 * Execute changes made in WordPress 4.0.0.
     1305 *
     1306 * @since 4.0.0
     1307 */
     1308function upgrade_400() {
     1309        global $wp_current_db_version;
     1310        if ( $wp_current_db_version < 27917 ) {
     1311                populate_roles_400();
     1312        }
     1313}
     1314
    12991315/**
    13001316 * Execute network level changes
    13011317 *
  • src/wp-admin/menu.php

    diff --git src/wp-admin/menu.php src/wp-admin/menu.php
    index 4008a09..ca76360 100644
    $appearance_cap = current_user_can( 'switch_themes') ? 'switch_themes' : 'edit_t 
    146146
    147147$menu[60] = array( __('Appearance'), $appearance_cap, 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'dashicons-admin-appearance' );
    148148        $submenu['themes.php'][5] = array( __( 'Themes' ), $appearance_cap, 'themes.php' );
    149         $submenu['themes.php'][6] = array( __( 'Customize' ), 'edit_theme_options', 'customize.php', 'hide-if-no-customize' );
     149        $submenu['themes.php'][6] = array( __( 'Customize' ), 'customize', 'customize.php', 'hide-if-no-customize' );
    150150        if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
    151151                $submenu['themes.php'][10] = array(__( 'Menus' ), 'edit_theme_options', 'nav-menus.php');
    152152
  • src/wp-admin/themes.php

    diff --git src/wp-admin/themes.php src/wp-admin/themes.php
    index 0117c0d..55057b9 100644
    foreach ( $themes as $theme ) : 
    212212        <div class="theme-actions">
    213213
    214214        <?php if ( $theme['active'] ) { ?>
    215                 <?php if ( $theme['actions']['customize'] ) { ?>
     215                <?php if ( $theme['actions']['customize'] && current_user_can( 'customize' ) ) { ?>
    216216                        <a class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
    217217                <?php } ?>
    218218        <?php } else { ?>
    219219                <a class="button button-primary activate" href="<?php echo $theme['actions']['activate']; ?>"><?php _e( 'Activate' ); ?></a>
    220                 <a class="button button-secondary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
    221                 <a class="button button-secondary hide-if-customize" href="<?php echo $theme['actions']['preview']; ?>"><?php _e( 'Preview' ); ?></a>
     220                <?php if ( current_user_can( 'customize' ) ) { ?>
     221                        <a class="button button-secondary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
     222                        <a class="button button-secondary hide-if-customize" href="<?php echo $theme['actions']['preview']; ?>"><?php _e( 'Preview' ); ?></a>
     223                <?php } ?>
    222224        <?php } ?>
    223225
    224226        </div>
  • src/wp-includes/admin-bar.php

    diff --git src/wp-includes/admin-bar.php src/wp-includes/admin-bar.php
    index 2a5c3b1..f4ea1c5 100644
    function wp_admin_bar_appearance_menu( $wp_admin_bar ) { 
    645645        if ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
    646646                $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'themes', 'title' => __('Themes'), 'href' => admin_url('themes.php') ) );
    647647
    648         if ( ! current_user_can( 'edit_theme_options' ) )
    649                 return;
    650 
    651         $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    652         $wp_admin_bar->add_menu( array(
    653                 'parent' => 'appearance',
    654                 'id'     => 'customize',
    655                 'title'  => __('Customize'),
    656                 'href'   => add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ),
    657                 'meta'   => array(
    658                         'class' => 'hide-if-no-customize',
    659                 ),
    660         ) );
    661         add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
     648        if ( current_user_can( 'customize' ) ) {
     649                $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     650                $wp_admin_bar->add_menu( array(
     651                        'parent' => 'appearance',
     652                        'id'     => 'customize',
     653                        'title'  => __( 'Customize' ),
     654                        'href'   => add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ),
     655                        'meta'   => array(
     656                                'class' => 'hide-if-no-customize',
     657                        ),
     658                ) );
     659                add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
     660        }
    662661
    663         if ( current_theme_supports( 'widgets' )  )
    664                 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'widgets', 'title' => __('Widgets'), 'href' => admin_url('widgets.php') ) );
     662        if ( current_user_can( 'edit_theme_options' ) ) {
     663                if ( current_theme_supports( 'widgets' )  ) {
     664                        $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'widgets', 'title' => __( 'Widgets' ), 'href' => admin_url( 'widgets.php' ) ) );
     665                }
    665666
    666         if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
    667                 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) );
     667                if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) {
     668                        $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __( 'Menus' ), 'href' => admin_url( 'nav-menus.php' ) ) );
     669                }
    668670
    669         if ( current_theme_supports( 'custom-background' ) )
    670                 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'background', 'title' => __('Background'), 'href' => admin_url('themes.php?page=custom-background') ) );
     671                if ( current_theme_supports( 'custom-background' ) ) {
     672                        $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'background', 'title' => __( 'Background' ), 'href' => admin_url( 'themes.php?page=custom-background' ) ) );
     673                }
    671674
    672         if ( current_theme_supports( 'custom-header' ) )
    673                 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'header', 'title' => __('Header'), 'href' => admin_url('themes.php?page=custom-header') ) );
     675                if ( current_theme_supports( 'custom-header' ) ) {
     676                        $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'header', 'title' => __( 'Header' ), 'href' => admin_url( 'themes.php?page=custom-header' ) ) );
     677                }
     678        }
    674679}
    675680
    676681/**
  • src/wp-includes/version.php

    diff --git src/wp-includes/version.php src/wp-includes/version.php
    index 9ed4297..7df42a4 100644
    $wp_version = '4.0-alpha-28611-src'; 
    1111 *
    1212 * @global int $wp_db_version
    1313 */
    14 $wp_db_version = 27916;
     14$wp_db_version = 27917;
    1515
    1616/**
    1717 * Holds the TinyMCE version