customize_preview_init() public method

Print JavaScript settings.
Since: 3.4.0
 /**
  * Do Customizer boot actions.
  */
 function do_customize_boot_actions()
 {
     $_SERVER['REQUEST_METHOD'] = 'POST';
     do_action('setup_theme');
     do_action('after_setup_theme');
     do_action('init');
     do_action('customize_register', $this->wp_customize);
     $this->wp_customize->customize_preview_init();
     do_action('wp', $GLOBALS['wp']);
 }
 /**
  * Do Customizer boot actions.
  */
 function do_customize_boot_actions()
 {
     // Remove actions that call add_theme_support( 'title-tag' ).
     remove_action('after_setup_theme', 'twentyfifteen_setup');
     remove_action('after_setup_theme', 'twentysixteen_setup');
     $_SERVER['REQUEST_METHOD'] = 'POST';
     do_action('setup_theme');
     do_action('after_setup_theme');
     do_action('init');
     do_action('customize_register', $this->wp_customize);
     $this->wp_customize->customize_preview_init();
     do_action('wp', $GLOBALS['wp']);
 }
 /**
  * Test WP_Customize_Manager::customize_preview_init().
  *
  * @ticket 30937
  * @covers WP_Customize_Manager::customize_preview_init()
  */
 function test_customize_preview_init()
 {
     // Test authorized admin user.
     wp_set_current_user(self::$admin_user_id);
     $did_action_customize_preview_init = did_action('customize_preview_init');
     $wp_customize = new WP_Customize_Manager();
     $wp_customize->customize_preview_init();
     $this->assertEquals($did_action_customize_preview_init + 1, did_action('customize_preview_init'));
     $this->assertEquals(10, has_action('wp_head', 'wp_no_robots'));
     $this->assertEquals(10, has_action('wp_head', array($wp_customize, 'remove_frameless_preview_messenger_channel')));
     $this->assertEquals(10, has_filter('wp_headers', array($wp_customize, 'filter_iframe_security_headers')));
     $this->assertEquals(10, has_filter('wp_redirect', array($wp_customize, 'add_state_query_params')));
     $this->assertTrue(wp_script_is('customize-preview', 'enqueued'));
     $this->assertEquals(10, has_action('wp_head', array($wp_customize, 'customize_preview_loading_style')));
     $this->assertEquals(20, has_action('wp_footer', array($wp_customize, 'customize_preview_settings')));
     // Test unauthorized user outside preview (no messenger_channel).
     wp_set_current_user(self::$subscriber_user_id);
     $wp_customize = new WP_Customize_Manager();
     $wp_customize->register_controls();
     $this->assertNotEmpty($wp_customize->controls());
     $wp_customize->customize_preview_init();
     $this->assertEmpty($wp_customize->controls());
     // Test unauthorized user inside preview (with messenger_channel).
     wp_set_current_user(self::$subscriber_user_id);
     $wp_customize = new WP_Customize_Manager(array('messenger_channel' => 'preview-0'));
     $exception = null;
     try {
         $wp_customize->customize_preview_init();
     } catch (WPDieException $e) {
         $exception = $e;
     }
     $this->assertNotNull($exception);
     $this->assertContains('Unauthorized', $exception->getMessage());
 }