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


PHP WP_Customize_Manager::set_return_url方法代码示例

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


在下文中一共展示了WP_Customize_Manager::set_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() );
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:37,代码来源:manager.php

示例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);
     }
 }
开发者ID:xwp,项目名称:wp-customize-snapshots,代码行数:14,代码来源:class-customize-snapshot-manager.php

示例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());
 }
开发者ID:plis197715,项目名称:wordpress-develop,代码行数:19,代码来源:manager.php


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