WP_Customize_Manager::is_cross_domain PHP Method

is_cross_domain() public method

Determines whether the admin and the frontend are on different domains.
Since: 4.7.0
public is_cross_domain ( ) : boolean
return boolean Whether cross-domain.
    public function is_cross_domain()
    {
        $admin_origin = wp_parse_url(admin_url());
        $home_origin = wp_parse_url(home_url());
        $cross_domain = strtolower($admin_origin['host']) !== strtolower($home_origin['host']);
        return $cross_domain;
    }

Usage Example

 /**
  * Test WP_Customize_Manager::get_allowed_urls().
  *
  * @ticket 30937
  * @covers WP_Customize_Manager::get_allowed_urls()
  */
 function test_get_allowed_urls()
 {
     $wp_customize = new WP_Customize_Manager();
     $this->assertFalse(is_ssl());
     $this->assertFalse($wp_customize->is_cross_domain());
     $allowed = $wp_customize->get_allowed_urls();
     $this->assertEquals($allowed, array(home_url('/', 'http')));
     add_filter('customize_allowed_urls', array($this, 'filter_customize_allowed_urls'));
     $allowed = $wp_customize->get_allowed_urls();
     $this->assertEqualSets($allowed, array('http://headless.example.com/', home_url('/', 'http')));
 }
WP_Customize_Manager