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 { |
48 | 48 | $this->previewed_menus = array(); |
49 | 49 | $this->manager = $manager; |
50 | 50 | |
| 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 | |
51 | 56 | add_filter( 'customize_refresh_nonces', array( $this, 'filter_nonces' ) ); |
52 | 57 | add_action( 'wp_ajax_load-available-menu-items-customizer', array( $this, 'ajax_load_available_items' ) ); |
53 | 58 | add_action( 'wp_ajax_search-available-menu-items-customizer', array( $this, 'ajax_search_available_items' ) ); |
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 { |
84 | 84 | public function __construct( $manager ) { |
85 | 85 | $this->manager = $manager; |
86 | 86 | |
| 87 | // Skip useless hooks when the user can't manage widgets anyway. |
| 88 | if ( ! current_user_can( 'edit_theme_options' ) ) { |
| 89 | return; |
| 90 | } |
| 91 | |
87 | 92 | add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_customize_dynamic_setting_args' ), 10, 2 ); |
88 | 93 | add_action( 'after_setup_theme', array( $this, 'register_settings' ) ); |
89 | 94 | add_action( 'wp_loaded', array( $this, 'override_sidebars_widgets_for_theme_switch' ) ); |
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 { |
23 | 23 | function setUp() { |
24 | 24 | parent::setUp(); |
25 | 25 | 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 ); |
26 | 29 | $GLOBALS['wp_customize'] = new WP_Customize_Manager(); |
27 | 30 | $this->manager = $GLOBALS['wp_customize']; |
28 | 31 | |
… |
… |
class Tests_WP_Customize_Widgets extends WP_UnitTestCase { |
41 | 44 | remove_action( 'after_setup_theme', 'twentysixteen_setup' ); |
42 | 45 | remove_action( 'customize_register', 'twentysixteen_customize_register', 11 ); |
43 | 46 | |
44 | | $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
45 | | wp_set_current_user( $user_id ); |
46 | | |
47 | 47 | $this->backup_registered_sidebars = $GLOBALS['wp_registered_sidebars']; |
48 | 48 | } |
49 | 49 | |