当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_Customize_Manager::changeset_uuid方法代码示例

本文整理汇总了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'));
 }
开发者ID:CompositeUK,项目名称:clone.WordPress-Develop,代码行数:49,代码来源:manager.php


注:本文中的WP_Customize_Manager::changeset_uuid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。