Commit cecd746ea7a for woocommerce
commit cecd746ea7a011108f35df892340e0591799dd6c
Author: Allison Levine <1689238+allilevine@users.noreply.github.com>
Date: Tue Nov 24 17:06:57 2026 -0500
Email Editor: render blocks whose style attribute is a string instead of failing the email (#71388)
* Email Editor: treat a non-array block style attribute as absent
A block can save a string `style` attribute (Calendly's "style":"inline").
Styles_Helper, the Typography preprocessor and the Quote preprocessor
assumed an array and threw, so the whole email fell back to the legacy design.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Email Editor: also treat a non-array style.typography as absent for font size presets
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Email Editor: treat a quote's non-array style.typography as absent
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
diff --git a/packages/php/email-editor/changelog/fix-nl-1193-string-style-attribute b/packages/php/email-editor/changelog/fix-nl-1193-string-style-attribute
new file mode 100644
index 00000000000..90ca2924a07
--- /dev/null
+++ b/packages/php/email-editor/changelog/fix-nl-1193-string-style-attribute
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Render emails containing a block whose style attribute is a string, such as a Calendly embed, instead of failing.
diff --git a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-quote-preprocessor.php b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-quote-preprocessor.php
index 415f6cdbfe0..8e6f1c769cb 100644
--- a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-quote-preprocessor.php
+++ b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-quote-preprocessor.php
@@ -39,6 +39,7 @@ class Quote_Preprocessor implements Preprocessor {
if ( 'core/quote' === $block['blockName'] ) {
$quote_align = $block['attrs']['textAlign'] ?? null;
$quote_typography = $block['attrs']['style']['typography'] ?? array();
+ $quote_typography = is_array( $quote_typography ) ? $quote_typography : array();
// Apply quote's text alignment to its children.
$block['innerBlocks'] = $this->apply_alignment_to_children( $block['innerBlocks'], $quote_align );
@@ -102,10 +103,11 @@ class Quote_Preprocessor implements Preprocessor {
if ( ! isset( $block['attrs'] ) ) {
$block['attrs'] = array();
}
- if ( ! isset( $block['attrs']['style'] ) ) {
+ // A string style (e.g. Calendly's "style":"inline") is not a style object, so treat it as absent.
+ if ( ! isset( $block['attrs']['style'] ) || ! is_array( $block['attrs']['style'] ) ) {
$block['attrs']['style'] = array();
}
- if ( ! isset( $block['attrs']['style']['typography'] ) ) {
+ if ( ! isset( $block['attrs']['style']['typography'] ) || ! is_array( $block['attrs']['style']['typography'] ) ) {
$block['attrs']['style']['typography'] = array();
}
diff --git a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-typography-preprocessor.php b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-typography-preprocessor.php
index b1bb0cae558..e9a817f96ea 100644
--- a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-typography-preprocessor.php
+++ b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-typography-preprocessor.php
@@ -102,6 +102,13 @@ class Typography_Preprocessor implements Preprocessor {
// In case the fontSize is set via a slug (small, medium, large, etc.) we translate it to a number
// The font size slug is set in $block['attrs']['fontSize'] and value in $block['attrs']['style']['typography']['fontSize'].
if ( isset( $block['attrs']['fontSize'] ) && is_string( $block['attrs']['fontSize'] ) ) {
+ // A string style (e.g. Calendly's "style":"inline") is not a style object, so treat it as absent.
+ if ( isset( $block['attrs']['style'] ) && ! is_array( $block['attrs']['style'] ) ) {
+ $block['attrs']['style'] = array();
+ }
+ if ( isset( $block['attrs']['style']['typography'] ) && ! is_array( $block['attrs']['style']['typography'] ) ) {
+ $block['attrs']['style']['typography'] = array();
+ }
$block['attrs']['style']['typography']['fontSize'] = $this->settings_controller->translate_slug_to_font_size( $block['attrs']['fontSize'] );
}
// Pass font size to email_attrs.
diff --git a/packages/php/email-editor/src/Integrations/Utils/class-styles-helper.php b/packages/php/email-editor/src/Integrations/Utils/class-styles-helper.php
index ce1e4b56fc1..19fec9260ab 100644
--- a/packages/php/email-editor/src/Integrations/Utils/class-styles-helper.php
+++ b/packages/php/email-editor/src/Integrations/Utils/class-styles-helper.php
@@ -220,9 +220,12 @@ class Styles_Helper {
)
);
+ $block_style = $block_attributes['style'] ?? array();
+
+ // Some third-party blocks store a string here (e.g. Calendly's "style":"inline"), which is not a style object.
return array_replace_recursive(
$normalized_colors,
- $block_attributes['style'] ?? array()
+ is_array( $block_style ) ? $block_style : array()
);
}
diff --git a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Renderer_Test.php b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Renderer_Test.php
index 9fb0015a59b..b233bc6c942 100644
--- a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Renderer_Test.php
+++ b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Renderer_Test.php
@@ -407,6 +407,56 @@ class Renderer_Test extends \Email_Editor_Integration_Test_Case {
$this->assertStringContainsString( 'color: #ffffff', $button_style );
}
+ /**
+ * A block can carry a string `style` attribute instead of a style object (Calendly saves "style":"inline").
+ * The renderer treats it as absent, so the email renders instead of throwing and falling back to the legacy design.
+ *
+ * @dataProvider string_style_attribute_provider
+ *
+ * @param string $post_content Block markup with a paragraph that has a string `style` attribute.
+ * @param string $expected_style A declaration the paragraph still gets from its other attributes.
+ */
+ public function testItRendersAParagraphWithAStringStyleAttribute( string $post_content, string $expected_style ): void {
+ $email_post_id = $this->factory->post->create( array( 'post_content' => $post_content ) );
+ $this->assertIsInt( $email_post_id );
+ $email_post = get_post( $email_post_id );
+ $this->assertInstanceOf( WP_Post::class, $email_post );
+
+ $rendered = $this->renderer->render( $email_post, 'Subject', '', 'en' );
+
+ $this->assertStringContainsString( $expected_style, $this->extractBlockStyle( $rendered['html'], 'string-style', 'td' ) );
+ }
+
+ /**
+ * One case per reader that merges or writes to the block's style.
+ *
+ * @return array<string, array{0: string, 1: string}>
+ */
+ public function string_style_attribute_provider(): array {
+ return array(
+ 'text color (Styles_Helper)' => array(
+ '<!-- wp:paragraph {"style":"inline","textColor":"luminous-vivid-orange"} --><p class="string-style has-luminous-vivid-orange-color has-text-color">Book a call</p><!-- /wp:paragraph -->',
+ 'color: #ff6900',
+ ),
+ 'font size preset (Typography_Preprocessor)' => array(
+ '<!-- wp:paragraph {"style":"inline","fontSize":"large"} --><p class="string-style has-large-font-size">Book a call</p><!-- /wp:paragraph -->',
+ 'font-size: 24px',
+ ),
+ 'string typography with a font size preset' => array(
+ '<!-- wp:paragraph {"style":{"typography":"inline"},"fontSize":"large"} --><p class="string-style has-large-font-size">Book a call</p><!-- /wp:paragraph -->',
+ 'font-size: 24px',
+ ),
+ 'quote with string typography' => array(
+ '<!-- wp:quote {"style":{"typography":"inline"}} --><blockquote class="wp-block-quote"><!-- wp:paragraph {"fontSize":"large"} --><p class="string-style has-large-font-size">Book a call</p><!-- /wp:paragraph --></blockquote><!-- /wp:quote -->',
+ 'font-size: 24px',
+ ),
+ 'paragraph in a quote (Quote_Preprocessor)' => array(
+ '<!-- wp:quote {"style":{"typography":{"fontSize":"18px"}}} --><blockquote class="wp-block-quote" style="font-size:18px"><!-- wp:paragraph {"style":"inline"} --><p class="string-style">Book a call</p><!-- /wp:paragraph --></blockquote><!-- /wp:quote -->',
+ 'font-size: 18px',
+ ),
+ );
+ }
+
/**
* Extracts the HTML of a block
*