Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions public_html/wp-content/plugins/pattern-creator/pattern-creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,26 @@ function inject_editor_template( $template ) {
*
* Mirroring the fix proposed for WordPress core (_wp_get_iframed_editor_assets should loop
* over style_handles too), we enqueue them here so they are captured in the same window.
*
* enqueue_block_assets also fires on the outer creator page's normal front-end render.
* Enqueuing there would print every block's frontend stylesheet into the outer <head>,
* where Gutenberg's iframe onLoad clones each one into the canvas and logs a
* "<handle> was added to the iframe incorrectly" warning. The outer page renders no
* blocks, so those styles are pure leakage. _wp_get_iframed_editor_assets() brackets its
* enqueue_block_assets dispatch with a `should_load_block_editor_scripts_and_styles` =>
* __return_false filter; its presence is what distinguishes the capture from the outer
* render, so we only enqueue when that filter is active.
*/
function enqueue_block_frontend_styles_for_canvas() {
if ( ! should_load_creator() ) {
return;
}

// Only run inside the iframed-editor asset capture, not on the outer page.
if ( false === has_filter( 'should_load_block_editor_scripts_and_styles', '__return_false' ) ) {
return;
}

$block_registry = \WP_Block_Type_Registry::get_instance();
foreach ( $block_registry->get_all_registered() as $block_type ) {
if ( isset( $block_type->style_handles ) && is_array( $block_type->style_handles ) ) {
Expand Down
Loading