本文整理汇总了PHP中WP_Customize_Manager::get_return_url方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Customize_Manager::get_return_url方法的具体用法?PHP WP_Customize_Manager::get_return_url怎么用?PHP WP_Customize_Manager::get_return_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Customize_Manager
的用法示例。
在下文中一共展示了WP_Customize_Manager::get_return_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: add_snapshot_uuid_to_return_url
/**
* Add snapshot UUID the Customizer return URL.
*
* If the Customizer was loaded with a snapshot UUID, let the return URL include this snapshot.
*/
public function add_snapshot_uuid_to_return_url()
{
$should_add_snapshot_uuid = $this->current_snapshot_uuid && $this->is_theme_active() && false === strpos($this->customize_manager->get_return_url(), '/wp-admin/');
if ($should_add_snapshot_uuid) {
$args = array('customize_snapshot_uuid' => $this->current_snapshot_uuid);
$return_url = add_query_arg(array_map('rawurlencode', $args), $this->customize_manager->get_return_url());
$this->customize_manager->set_return_url($return_url);
}
}
示例3:
/**
* 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());
}