本文整理汇总了PHP中WP_Customize_Manager::changeset_uuid方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Customize_Manager::changeset_uuid方法的具体用法?PHP WP_Customize_Manager::changeset_uuid怎么用?PHP WP_Customize_Manager::changeset_uuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Customize_Manager
的用法示例。
在下文中一共展示了WP_Customize_Manager::changeset_uuid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Test writing changesets and publishing with users who can unfiltered_html and those who cannot.
*
* @ticket 38705
* @covers WP_Customize_Manager::save_changeset_post()
*/
function test_save_changeset_post_with_varying_unfiltered_html_cap()
{
global $wp_customize;
grant_super_admin(self::$admin_user_id);
$this->assertTrue(user_can(self::$admin_user_id, 'unfiltered_html'));
$this->assertFalse(user_can(self::$subscriber_user_id, 'unfiltered_html'));
wp_set_current_user(0);
add_action('customize_register', array($this, 'register_scratchpad_setting'));
// Attempt scratchpad with user who has unfiltered_html.
update_option('scratchpad', '');
$wp_customize = new WP_Customize_Manager();
do_action('customize_register', $wp_customize);
$wp_customize->set_post_value('scratchpad', 'Unfiltered<script>evil</script>');
$wp_customize->save_changeset_post(array('status' => 'auto-draft', 'user_id' => self::$admin_user_id));
$wp_customize = new WP_Customize_Manager(array('changeset_uuid' => $wp_customize->changeset_uuid()));
do_action('customize_register', $wp_customize);
$wp_customize->save_changeset_post(array('status' => 'publish'));
$this->assertEquals('Unfiltered<script>evil</script>', get_option('scratchpad'));
// Attempt scratchpad with user who doesn't have unfiltered_html.
update_option('scratchpad', '');
$wp_customize = new WP_Customize_Manager();
do_action('customize_register', $wp_customize);
$wp_customize->set_post_value('scratchpad', 'Unfiltered<script>evil</script>');
$wp_customize->save_changeset_post(array('status' => 'auto-draft', 'user_id' => self::$subscriber_user_id));
$wp_customize = new WP_Customize_Manager(array('changeset_uuid' => $wp_customize->changeset_uuid()));
do_action('customize_register', $wp_customize);
$wp_customize->save_changeset_post(array('status' => 'publish'));
$this->assertEquals('Unfilteredevil', get_option('scratchpad'));
// Attempt publishing scratchpad as anonymous user when changeset was set by privileged user.
update_option('scratchpad', '');
$wp_customize = new WP_Customize_Manager();
do_action('customize_register', $wp_customize);
$wp_customize->set_post_value('scratchpad', 'Unfiltered<script>evil</script>');
$wp_customize->save_changeset_post(array('status' => 'auto-draft', 'user_id' => self::$admin_user_id));
$changeset_post_id = $wp_customize->changeset_post_id();
wp_set_current_user(0);
$wp_customize = null;
unset($GLOBALS['wp_actions']['customize_register']);
$this->assertEquals('Unfilteredevil', apply_filters('content_save_pre', 'Unfiltered<script>evil</script>'));
wp_publish_post($changeset_post_id);
// @todo If wp_update_post() is used here, then kses will corrupt the post_content.
$this->assertEquals('Unfiltered<script>evil</script>', get_option('scratchpad'));
}