Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .monorepo-source.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
58 changes: 19 additions & 39 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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' );

/*
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading