當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。