Make WordPress Core

Ticket #35895: 35895.0.diff

File 35895.0.diff, 2.7 KB (added by westonruter, 9 years ago)
  • src/wp-includes/class-wp-customize-nav-menus.php

    diff --git src/wp-includes/class-wp-customize-nav-menus.php src/wp-includes/class-wp-customize-nav-menus.php
    index 2438432..b4bd0fd 100644
    final class WP_Customize_Nav_Menus { 
    4848                $this->previewed_menus = array();
    4949                $this->manager         = $manager;
    5050
     51                // Skip useless hooks when the user can't manage nav menus anyway.
     52                if ( ! current_user_can( 'edit_theme_options' ) ) {
     53                        return;
     54                }
     55
    5156                add_filter( 'customize_refresh_nonces', array( $this, 'filter_nonces' ) );
    5257                add_action( 'wp_ajax_load-available-menu-items-customizer', array( $this, 'ajax_load_available_items' ) );
    5358                add_action( 'wp_ajax_search-available-menu-items-customizer', array( $this, 'ajax_search_available_items' ) );
  • src/wp-includes/class-wp-customize-widgets.php

    diff --git src/wp-includes/class-wp-customize-widgets.php src/wp-includes/class-wp-customize-widgets.php
    index 28eaf12..ca171b2 100644
    final class WP_Customize_Widgets { 
    8484        public function __construct( $manager ) {
    8585                $this->manager = $manager;
    8686
     87                // Skip useless hooks when the user can't manage widgets anyway.
     88                if ( ! current_user_can( 'edit_theme_options' ) ) {
     89                        return;
     90                }
     91
    8792                add_filter( 'customize_dynamic_setting_args',          array( $this, 'filter_customize_dynamic_setting_args' ), 10, 2 );
    8893                add_action( 'after_setup_theme',                       array( $this, 'register_settings' ) );
    8994                add_action( 'wp_loaded',                               array( $this, 'override_sidebars_widgets_for_theme_switch' ) );
  • tests/phpunit/tests/customize/widgets.php

    diff --git tests/phpunit/tests/customize/widgets.php tests/phpunit/tests/customize/widgets.php
    index bcb24b2..c485b36 100644
    class Tests_WP_Customize_Widgets extends WP_UnitTestCase { 
    2323        function setUp() {
    2424                parent::setUp();
    2525                require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
     26
     27                $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
     28                wp_set_current_user( $user_id );
    2629                $GLOBALS['wp_customize'] = new WP_Customize_Manager();
    2730                $this->manager = $GLOBALS['wp_customize'];
    2831
    class Tests_WP_Customize_Widgets extends WP_UnitTestCase { 
    4144                remove_action( 'after_setup_theme', 'twentysixteen_setup' );
    4245                remove_action( 'customize_register', 'twentysixteen_customize_register', 11 );
    4346
    44                 $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    45                 wp_set_current_user( $user_id );
    46 
    4747                $this->backup_registered_sidebars = $GLOBALS['wp_registered_sidebars'];
    4848        }
    4949