本文整理汇总了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() );
}
示例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());
}
示例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'));
}
}