diff --git a/.monorepo-source.json b/.monorepo-source.json index 35f4216..5852bda 100644 --- a/.monorepo-source.json +++ b/.monorepo-source.json @@ -1,7 +1,7 @@ { "productId": "funkycommerce-headless", "repository": "coded-letter/superfunky-theme", - "source": "coded-letter/coded-letter-monorepo@86177b0c8ca2c1e1d68cb68f3809a5b9fb0a5d67", + "source": "coded-letter/coded-letter-monorepo@b321c043c982e26fc7975a54026e44285961962d", "sourcePath": "workspace/backend/wordpress/themes/free/funkycommerce-headless", "installSlug": "funkycommerce-headless", "kind": "theme", diff --git a/functions.php b/functions.php index 7c1e24e..a57f589 100644 --- a/functions.php +++ b/functions.php @@ -9,7 +9,7 @@ exit; } -define( 'FUNKYCOMMERCE_HEADLESS_VERSION', '1.2.12' ); +define( 'FUNKYCOMMERCE_HEADLESS_VERSION', '1.2.13' ); /** * Whether Superfunky Pro is active and licensed. @@ -968,44 +968,21 @@ function funkycommerce_graphql_content_database_id( $node ) { } /** - * Remove blocks implemented by the React application while retaining editor content. + * Render content while omitting blocks implemented by the React application. */ -function funkycommerce_filter_headless_blocks( $blocks ) { - $filtered = array(); - $mapped = funkycommerce_headless_component_blocks(); - - foreach ( $blocks as $block ) { - if ( in_array( $block['blockName'], $mapped, true ) ) { - continue; - } - if ( ! empty( $block['innerBlocks'] ) ) { - $inner_blocks = array(); - $inner_content = array(); - $child_index = 0; - - foreach ( $block['innerContent'] as $content_part ) { - if ( null !== $content_part ) { - $inner_content[] = $content_part; - continue; - } - - $child = $block['innerBlocks'][ $child_index ] ?? null; - $filtered_child = $child ? funkycommerce_filter_headless_blocks( array( $child ) ) : array(); - ++$child_index; - - if ( $filtered_child ) { - $inner_blocks[] = $filtered_child[0]; - $inner_content[] = null; - } - } - - $block['innerBlocks'] = $inner_blocks; - $block['innerContent'] = $inner_content; - } - $filtered[] = $block; +function funkycommerce_without_headless_component_blocks( $callback ) { + $mapped = funkycommerce_headless_component_blocks(); + $filter = static function ( $block_content, $block ) use ( $mapped ) { + $block_name = is_array( $block ) ? ( $block['blockName'] ?? null ) : null; + return in_array( $block_name, $mapped, true ) ? '' : $block_content; + }; + + add_filter( 'pre_render_block', $filter, PHP_INT_MAX, 2 ); + try { + return call_user_func( $callback ); + } finally { + remove_filter( 'pre_render_block', $filter, PHP_INT_MAX ); } - - return $filtered; } /** @@ -1174,8 +1151,11 @@ static function () use ( $filter, $protected ) { */ function funkycommerce_render_headless_page_content( $page_id ) { $content = (string) get_post_field( 'post_content', $page_id ); - $content = serialize_blocks( funkycommerce_filter_headless_blocks( parse_blocks( $content ) ) ); - $content = funkycommerce_filter_headless_content( $content ); + $content = funkycommerce_without_headless_component_blocks( + static function () use ( $content ) { + return funkycommerce_filter_headless_content( $content ); + } + ); $content = funkycommerce_security_mark_content_scripts( $content, 'page' ); /* diff --git a/package-lock.json b/package-lock.json index 2d5fdb4..3e558d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "funkycommerce-headless-theme", - "version": "1.2.12", + "version": "1.2.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "funkycommerce-headless-theme", - "version": "1.2.12", + "version": "1.2.13", "devDependencies": { "autoprefixer": "^10.4.20", "esbuild": "^0.28.2", diff --git a/package.json b/package.json index 92ee3c8..3fb4955 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "funkycommerce-headless-theme", "private": true, - "version": "1.2.12", + "version": "1.2.13", "description": "Tailwind/build tooling for the FunkyCommerce Headless WordPress theme's native frontend assets (block templates, template parts, loader, and Spotify slot).", "scripts": { "build:css": "tailwindcss -i ./assets/css/theme-source.css -o ./assets/dist/theme.css --minify", diff --git a/readme.txt b/readme.txt index 4458d0e..8ea93c2 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: headless, woocommerce, wpgraphql, full-site-editing Requires at least: 6.7 Tested up to: 6.8 Requires PHP: 7.4 -Stable tag: 1.2.12 +Stable tag: 1.2.13 License: GPL-2.0-or-later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -15,6 +15,11 @@ Control Center, the theme also ships a complete native WordPress rendering path "Native frontend theme" below) with accessible header/footer/navigation templates and core front/home/singular/archive/search/404 routes styled to match the storefront. +== 1.2.13 highlights == + +* Preserves Custom HTML element structure while omitting blocks rendered by the headless application. +* Prevents generated paragraphs and line breaks from separating interactive HTML controls from their content. + == 1.2.12 highlights == * Repairs legacy paragraph and line-break markup injected into Custom HTML CSS blocks. diff --git a/style.css b/style.css index 27a54f9..0a09b34 100644 --- a/style.css +++ b/style.css @@ -7,7 +7,7 @@ Description: A minimal, content-first block theme for polished WordPress preview Requires at least: 6.7 Tested up to: 6.8 Requires PHP: 7.4 -Version: 1.2.12 +Version: 1.2.13 Update URI: https://github.com/coded-letter/superfunky-theme License: GPL-2.0-or-later License URI: https://www.gnu.org/licenses/gpl-2.0.html