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


PHP WP_Customize_Manager::set_preview_url方法代码示例

本文整理汇总了PHP中WP_Customize_Manager::set_preview_url方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Customize_Manager::set_preview_url方法的具体用法?PHP WP_Customize_Manager::set_preview_url怎么用?PHP WP_Customize_Manager::set_preview_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Customize_Manager的用法示例。


在下文中一共展示了WP_Customize_Manager::set_preview_url方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

	/**
	 * Test get_return_url()/set_return_url() methods.
	 *
	 * @see WP_Customize_Manager::get_return_url()
	 * @see WP_Customize_Manager::set_return_url()
	 */
	function test_return_url() {
		wp_set_current_user( self::factory()->user->create( array( 'role' => 'author' ) ) );
		$this->assertEquals( home_url( '/' ), $this->manager->get_return_url() );

		wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
		$this->assertTrue( current_user_can( 'edit_theme_options' ) );
		$this->assertEquals( home_url( '/' ), $this->manager->get_return_url() );

		$preview_url = home_url( '/foo/' );
		$this->manager->set_preview_url( $preview_url );
		$this->assertEquals( $preview_url, $this->manager->get_return_url() );

		$_SERVER['HTTP_REFERER'] = wp_slash( admin_url( 'customize.php' ) );
		$this->assertEquals( $preview_url, $this->manager->get_return_url() );

		// See #35355.
		$_SERVER['HTTP_REFERER'] = wp_slash( admin_url( 'wp-login.php' ) );
		$this->assertEquals( $preview_url, $this->manager->get_return_url() );

		$url = home_url( '/referred/' );
		$_SERVER['HTTP_REFERER'] = wp_slash( $url );
		$this->assertEquals( $url, $this->manager->get_return_url() );

		$url = 'http://badreferer.example.com/';
		$_SERVER['HTTP_REFERER'] = wp_slash( $url );
		$this->assertNotEquals( $url, $this->manager->get_return_url() );
		$this->assertEquals( $preview_url, $this->manager->get_return_url() );

		$this->manager->set_return_url( admin_url( 'edit.php?trashed=1' ) );
		$this->assertEquals( admin_url( 'edit.php' ), $this->manager->get_return_url() );
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:37,代码来源:manager.php

示例2:

 /**
  * Test get_return_url()/set_return_url() methods.
  *
  * @see WP_Customize_Manager::get_return_url()
  * @see WP_Customize_Manager::set_return_url()
  */
 function test_return_url()
 {
     wp_set_current_user($this->factory->user->create(array('role' => 'author')));
     $this->assertEquals(get_admin_url(), $this->manager->get_return_url());
     wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
     $this->assertTrue(current_user_can('edit_theme_options'));
     $this->assertEquals(admin_url('themes.php'), $this->manager->get_return_url());
     $preview_url = home_url('/foo/');
     $this->manager->set_preview_url($preview_url);
     $this->assertEquals($preview_url, $this->manager->get_return_url());
     $this->manager->set_return_url(admin_url('edit.php?trashed=1'));
     $this->assertEquals(admin_url('edit.php'), $this->manager->get_return_url());
 }
开发者ID:plis197715,项目名称:wordpress-develop,代码行数:19,代码来源:manager.php

示例3: init

 /**
  * Initialize the template Customizer feature class.
  *
  * @static
  * @since 0.4
  * @access public
  *
  * @param WP_Customize_Manager $wp_customize Customizer instance.
  */
 public static function init($wp_customize)
 {
     $self = new self();
     $self->wp_customize = $wp_customize;
     do_action('amp_customizer_init', $self);
     // Settings need to be registered for regular customize requests as well (since save is handled there)
     $self->register_settings();
     // Our custom panels only need to go for AMP Customizer requests though
     if (self::is_amp_customizer()) {
         if (empty($_GET['url'])) {
             $wp_customize->set_preview_url(amp_admin_get_preview_permalink());
         }
         $self->_unregister_core_ui();
         $self->register_ui();
     } elseif (is_customize_preview()) {
         // Delay preview-specific actions until we're sure we're rendering an AMP page, since it's too early for `is_amp_endpoint()` here.
         add_action('pre_amp_render_post', array($self, 'init_preview'));
     }
 }
开发者ID:thenextweb,项目名称:amp-wp,代码行数:28,代码来源:class-amp-customizer.php


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