Skip to content

fix(block-theme): remove MJML image-caption filter moved to newsletters plugin#2680

Open
chickenn00dle wants to merge 1 commit intotrunkfrom
fix/newsletter-editor-block-theme-adjustments
Open

fix(block-theme): remove MJML image-caption filter moved to newsletters plugin#2680
chickenn00dle wants to merge 1 commit intotrunkfrom
fix/newsletter-editor-block-theme-adjustments

Conversation

@chickenn00dle
Copy link
Copy Markdown
Contributor

@chickenn00dle chickenn00dle commented Apr 14, 2026

All Submissions:

Changes proposed in this Pull Request:

The MJML image-caption component attributes filter (setting align=left and padding=0) was duplicated identically in both the classic theme and block theme. This code has been moved into the newsletters plugin renderer as a default in Automattic/newspack-newsletters#2078, so the duplicate in this theme is no longer needed.

Depends on Automattic/newspack-newsletters#2078

Addresses https://linear.app/a8c/issue/NPPD-1316

How to test the changes in this Pull Request:

  1. Apply fix(block-theme): override theme.json styles in the newsletter editor newspack-newsletters#2078 first
  2. Activate the Newspack Classic Theme
  3. Create a Newsletter post with all of the non-RDB blocks (I decided not to tackle these here as this one is already quite hairy) listed in this comment
  4. Send a test email and verify the image caption is left-aligned with no extra padding — same as before this change

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

🤖 Generated with Claude Code

…rs plugin

The image-caption MJML component attributes filter is now applied as a
default in the newsletters plugin renderer, so the duplicate in the
theme is no longer needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@chickenn00dle chickenn00dle marked this pull request as ready for review April 15, 2026 17:33
@chickenn00dle chickenn00dle requested a review from a team as a code owner April 15, 2026 17:33
Copilot AI review requested due to automatic review settings April 15, 2026 17:33
@chickenn00dle chickenn00dle added the [Status] Needs Review The issue or pull request needs to be reviewed label Apr 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes a now-duplicated MJML image-caption attribute filter from the theme, since the same default behavior has been moved into the Newspack Newsletters plugin renderer (per Automattic/newspack-newsletters#2078).

Changes:

  • Removes the newspack_newsletters_mjml_component_attributes filter callback that forced align=left and padding=0 for the image-caption MJML component.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -12,19 +12,3 @@ function newspack_newsletters_enqueue_editor_styles() {
add_editor_style( 'styles/newspack-newsletters-editor.css' );
}
add_action( 'newspack_newsletters_enqueue_block_editor_assets', 'newspack_newsletters_enqueue_editor_styles' );
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the newspack_newsletters_mjml_component_attributes filter means sites running an older newspack-newsletters plugin (without the change from Automattic/newspack-newsletters#2078) will lose the left-aligned / zero-padding styling for image-caption in MJML output. Since the theme currently only checks class_exists( '\\Newspack_Newsletters' ) (no minimum version gating), consider keeping a small backward-compat shim: add the filter but only set align/padding when those attributes are not already present, so updated plugin versions are unaffected while older ones retain the previous behavior.

Suggested change
add_action( 'newspack_newsletters_enqueue_block_editor_assets', 'newspack_newsletters_enqueue_editor_styles' );
add_action( 'newspack_newsletters_enqueue_block_editor_assets', 'newspack_newsletters_enqueue_editor_styles' );
/**
* Backward-compatibility shim for older Newspack Newsletters versions.
*
* Ensures image captions keep the legacy left alignment and zero padding
* when the plugin has not already provided those MJML attributes.
*
* @param array $attributes MJML component attributes.
* @param string $component MJML component name.
* @param null|mixed $block Optional block data passed by the filter.
* @return array
*/
function newspack_newsletters_mjml_component_attributes_compat( $attributes, $component, $block = null ) {
if ( 'image-caption' !== $component ) {
return $attributes;
}
if ( empty( $attributes['align'] ) ) {
$attributes['align'] = 'left';
}
if ( empty( $attributes['padding'] ) ) {
$attributes['padding'] = '0px';
}
return $attributes;
}
add_filter( 'newspack_newsletters_mjml_component_attributes', 'newspack_newsletters_mjml_component_attributes_compat', 10, 3 );

Copilot uses AI. Check for mistakes.
@laurelfulford laurelfulford self-requested a review April 15, 2026 18:07
Copy link
Copy Markdown
Contributor

@laurelfulford laurelfulford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one also looks good - this makes more sense than splitting this over both themes, given that both themes have left-aligned captions. Thanks @chickenn00dle!

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants