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@531e554e57237adb670e5e07edbdf0878e1764cc",
"source": "coded-letter/coded-letter-monorepo@86177b0c8ca2c1e1d68cb68f3809a5b9fb0a5d67",
"sourcePath": "workspace/backend/wordpress/themes/free/funkycommerce-headless",
"installSlug": "funkycommerce-headless",
"kind": "theme",
Expand Down
55 changes: 52 additions & 3 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.11' );
define( 'FUNKYCOMMERCE_HEADLESS_VERSION', '1.2.12' );

/**
* Whether Superfunky Pro is active and licensed.
Expand Down Expand Up @@ -1095,16 +1095,63 @@ function funkycommerce_with_headless_shortcode_markers( $callback ) {
}
}

/**
* Remove WordPress paragraph formatting accidentally stored inside CSS blocks.
*/
function funkycommerce_normalize_headless_style_content( $content ) {
$normalized = preg_replace_callback(
'#(<style\b[^>]*>)(.*?)(</style\s*>)#is',
static function ( $matches ) {
$style = $matches[2];

if (
! preg_match( '#<br\s*/?>#i', $style )
|| ! preg_match( '#</p>\s*<p(?:\s[^>]*)?>#i', $style )
) {
return $matches[0];
}

$style = preg_replace( '#<br\s*/?>#i', "\n", $style );
$style = preg_replace( '#</?p(?:\s[^>]*)?>#i', "\n", $style );

return $matches[1] . $style . $matches[3];
},
$content
);

return is_string( $normalized ) ? $normalized : $content;
}

/**
* Remove paragraph wrappers that content filters add around protected code placeholders.
*/
function funkycommerce_unwrap_headless_code_placeholders( $content ) {
$placeholder = '<pre data-funkycommerce-preserved-code="fc-preserved-code-\d+"></pre>';
$patterns = array(
'#<p(?:\s[^>]*)?>\s*(' . $placeholder . ')\s*</p>#i',
'#<p(?:\s[^>]*)?>\s*(' . $placeholder . ')#i',
'#(' . $placeholder . ')\s*</p>#i',
);

foreach ( $patterns as $pattern ) {
$unwrapped = preg_replace( $pattern, '$1', $content );
$content = is_string( $unwrapped ) ? $unwrapped : $content;
}

return $content;
}

/**
* Run content filters without allowing paragraph formatting inside code tags.
*/
function funkycommerce_filter_headless_content( $content, $filter = 'the_content' ) {
$preserved = array();
$content = funkycommerce_normalize_headless_style_content( $content );
$protected = preg_replace_callback(
'#<(script|style)\b[^>]*>.*?</\1\s*>#is',
static function ( $matches ) use ( &$preserved ) {
$key = 'fc-preserved-code-' . count( $preserved );
$placeholder = '<div data-funkycommerce-preserved-code="' . $key . '"></div>';
$placeholder = '<pre data-funkycommerce-preserved-code="' . $key . '"></pre>';
$preserved[ $placeholder ] = $matches[0];
return $placeholder;
},
Expand All @@ -1116,8 +1163,10 @@ static function () use ( $filter, $protected ) {
return apply_filters( $filter, $protected );
}
);
$filtered = funkycommerce_unwrap_headless_code_placeholders( $filtered );
$filtered = strtr( $filtered, $preserved );

return strtr( $filtered, $preserved );
return funkycommerce_normalize_headless_style_content( $filtered );
}

/**
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.11",
"version": "1.2.12",
"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.11
Stable tag: 1.2.12
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.12 highlights ==

* Repairs legacy paragraph and line-break markup injected into Custom HTML CSS blocks.
* Prevents content filters from leaving paragraph wrappers around preserved script and style blocks.

== 1.2.11 highlights ==

* Restores Control Center tab switching after settings were split into safe per-section forms.
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.11
Version: 1.2.12
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