Skip to content

Commit

Permalink
Merge comflicts, and wp-themes support.
Browse files Browse the repository at this point in the history
  • Loading branch information
dd32 committed Jun 19, 2024
1 parent 63c0834 commit 54c6c58
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
return;
}

$using_playground = $_REQUEST['playground'] ?? false;

$theme_post = get_post( $block->context['postId'] );
$theme = wporg_themes_theme_information( $theme_post->post_name );

Expand Down Expand Up @@ -89,12 +91,15 @@ class="wp-block-button__link wp-element-button"
</section>
<iframe
title="<?php esc_attr_e( 'Theme preview', 'wporg-themes' ); ?>"
src="<?php echo esc_url_raw( $url ); ?>"
data-wp-bind--src="wporg/themes/preview::context.url"
data-wp-style--width="state.iframeWidthCSS"
data-wp-style--height="state.iframeHeightCSS"
data-wp-on--load="wporg/themes/preview::actions.onLoad"
data-wp-init="wporg/themes/preview::actions.startPlayground"
<?php if ( $using_playground ) { ?>
data-wp-init="wporg/themes/preview::actions.startPlayground"
<?php } else { ?>
src="<?php echo esc_url_raw( $url ); ?>"
data-wp-bind--src="wporg/themes/preview::context.url"
data-wp-on--load="wporg/themes/preview::actions.onLoad"
<?php } ?>
/>
<?php endif; ?>
</div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { getContext, store } from '@wordpress/interactivity';
import { getContext, getElement, store } from '@wordpress/interactivity';
import { startPlaygroundWeb } from 'https://playground.wordpress.net/client/index.js'; // or '@wp-playground/client';

let playgroundClient = false;
Expand All @@ -26,8 +26,11 @@ store( 'wporg/themes/preview', {
const isSelected = 'wporg-select' === event.type;
if ( ! ref?.dataset ) {
return;
}

context.isLoaded = false;
if ( ! playgroundClient ) {
context.isLoaded = false;
}
if ( ref.dataset.style_variation ) {
context.selected.style_variation = isSelected ? ref.dataset.style_variation : null;
}
Expand Down Expand Up @@ -62,6 +65,9 @@ store( 'wporg/themes/preview', {
const context = getContext();
const { ref } = getElement();

// Set it as immediately loaded..
context.isLoaded = true;

fetch( 'https://wordpress.org/themes/wp-json/themes/v1/preview-blueprint/' + context.theme )
.then( ( response ) => response.json() )
.then( ( blueprint ) => {
Expand Down

0 comments on commit 54c6c58

Please sign in to comment.