check_capabilities() final public method

Returns false if the user cannot manipulate one of the associated settings, or if one of the associated settings does not exist. Also returns false if the associated section does not exist or if its capability check returns false.
Since: 3.4.0
final public check_capabilities ( ) : boolean
return boolean False if theme doesn't support the control or user doesn't have the required permissions, otherwise true.
 /**
  * Test WP_Customize_Control::check_capabilities().
  *
  * @see WP_Customize_Control::check_capabilities()
  */
 function test_check_capabilities()
 {
     do_action('customize_register', $this->wp_customize);
     $control = new WP_Customize_Control($this->wp_customize, 'blogname', array('settings' => array('blogname')));
     $this->assertTrue($control->check_capabilities());
     $control = new WP_Customize_Control($this->wp_customize, 'blogname', array('settings' => array('blogname', 'non_existing')));
     $this->assertFalse($control->check_capabilities());
     $this->wp_customize->add_setting('top_secret_message', array('capability' => 'top_secret_clearance'));
     $control = new WP_Customize_Control($this->wp_customize, 'blogname', array('settings' => array('blogname', 'top_secret_clearance')));
     $this->assertFalse($control->check_capabilities());
     $control = new WP_Customize_Control($this->wp_customize, 'no_setting', array('settings' => array()));
     $this->assertTrue($control->check_capabilities());
     $control = new WP_Customize_Control($this->wp_customize, 'no_setting', array('settings' => array(), 'capability' => 'top_secret_clearance'));
     $this->assertFalse($control->check_capabilities());
     $control = new WP_Customize_Control($this->wp_customize, 'no_setting', array('settings' => array(), 'capability' => 'edit_theme_options'));
     $this->assertTrue($control->check_capabilities());
 }
 /**
  * Test WP_Customize_Control::check_capabilities().
  *
  * @see WP_Customize_Control::check_capabilities()
  */
 function test_check_capabilities()
 {
     wp_set_current_user(self::factory()->user->create(array('role' => 'administrator')));
     do_action('customize_register', $this->wp_customize);
     $control = new WP_Customize_Control($this->wp_customize, 'blogname', array('settings' => array('blogname')));
     $this->assertTrue($control->check_capabilities());
     $control = new WP_Customize_Control($this->wp_customize, 'blogname', array('settings' => array('blogname', 'non_existing')));
     $this->assertFalse($control->check_capabilities());
     $this->wp_customize->add_setting('top_secret_message', array('capability' => 'top_secret_clearance'));
     $control = new WP_Customize_Control($this->wp_customize, 'blogname', array('settings' => array('blogname', 'top_secret_clearance')));
     $this->assertFalse($control->check_capabilities());
     $control = new WP_Customize_Control($this->wp_customize, 'no_setting', array('settings' => array()));
     $this->assertTrue($control->check_capabilities());
     $control = new WP_Customize_Control($this->wp_customize, 'no_setting', array('settings' => array(), 'capability' => 'top_secret_clearance'));
     $this->assertFalse($control->check_capabilities());
     $control = new WP_Customize_Control($this->wp_customize, 'no_setting', array('settings' => array(), 'capability' => 'edit_theme_options'));
     $this->assertTrue($control->check_capabilities());
 }