WP_REST_Widget_Types_Controller::render_legacy_widget_preview_iframe() – Renders a page containing a preview of the requested Legacy Widget block.

You appear to be a bot. Output may be restricted

Description

Renders a page containing a preview of the requested Legacy Widget block.

Usage

$string = WP_REST_Widget_Types_Controller::render_legacy_widget_preview_iframe( $id_base, $instance );

Parameters

$id_base
( string ) required – The id base of the requested widget.
$instance
( array ) required – The widget instance attributes.

Returns

string Rendered Legacy Widget block preview.

Source

File name: wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php


Lines:

1 to 44 of 44
  private function render_legacy_widget_preview_iframe( $id_base, $instance ) {
    if ( ! defined( 'IFRAME_REQUEST' ) ) {
      define( 'IFRAME_REQUEST', true );
    }

    ob_start();
    ?>
		<!doctype html>
		<html <?php language_attributes(); ?>>
		<head>
			<meta charset="<?php bloginfo( 'charset' ); ?>" />
			<meta name="viewport" content="width=device-width, initial-scale=1" />
			<link rel="profile" href="https://gmpg.org/xfn/11" />
			<?php wp_head(); ?>
			<style>
				/* Reset theme styles */
				html, body, #page, #content {
					padding: 0 !important;
					margin: 0 !important;
				}
			</style>
		</head>
		<body <?php body_class(); ?>>
		<div id="page" class="site">
			<div id="content" class="site-content">
				<?php
        $registry = WP_Block_Type_Registry::WP_Block_Type_Registry::get_instance();
        $block    = $registry->get_registered( 'core/legacy-widget' );
        echo $block->render(
          array(
            'idBase'   => $id_base,
            'instance' => $instance,
          )
        );
        ?>
			</div><!-- #content -->
		</div><!-- #page -->
		<?php wp_footer(); ?>
		</body>
		</html>
		<?php
    return ob_get_clean();
  }
 

 View on GitHub View on Trac