Skip to content

Block Theme Previews: Add query param - #51412

Closed
scruffian wants to merge 1 commit into
trunkfrom
update/block-theme-preview-links
Closed

scruffian wants to merge 1 commit into
trunkfrom
update/block-theme-preview-links

Conversation

@scruffian

@scruffian scruffian commented Jun 12, 2023 •

Copy link
Copy Markdown
Contributor

What?

Persists the block theme preview query parameter on every link.

Related: #50919

Why?

So that users can browse their site when previewing a block theme.

How?

Using the tag processor to update every link on the page.

Testing Instructions

TBD

Testing Instructions for Keyboard

Screenshots or screencast

@scruffian scruffian self-assigned this Jun 12, 2023

@getdave getdave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a nice use of the Tag Processor 👏

I guess my only concern is the performance impact. You might need to loop in someone who has expertise in that area for review.

<?php
}

function gutenberg_render_block_block_theme_previews( $block_content, $parsed_block, $block_class ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

badge

Would it be better to limit the execution of this function to only when previewing the front of the site (or not)? What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check for permissions as we do in gutenberg_get_theme_preview_path so that the whole string manipulaiton only happens for logged is users previewing thiemes, otherwise we could just hit the site with bogus requests.

@draganescu

Copy link
Copy Markdown
Contributor

I like this solution. Its definitely impactful in terms of performance to do this on the fly string manipulation but given it's specific to when previewing it should be all right.

@Mamaduka

Copy link
Copy Markdown
Member

I'm doing some old PR cleanup. Since there has been no activity in the last two years, I'm going to close this as "stale."

@Mamaduka Mamaduka closed this May 29, 2025
@Mamaduka
Mamaduka deleted the update/block-theme-preview-links branch May 29, 2025 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants