本文整理汇总了PHP中WP_Customize_Control::check_capabilities方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Customize_Control::check_capabilities方法的具体用法?PHP WP_Customize_Control::check_capabilities怎么用?PHP WP_Customize_Control::check_capabilities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Customize_Control
的用法示例。
在下文中一共展示了WP_Customize_Control::check_capabilities方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* 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());
}
示例2: array
/**
* 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());
}