fix(block-theme): remove MJML image-caption filter moved to newsletters plugin#2680
fix(block-theme): remove MJML image-caption filter moved to newsletters plugin#2680chickenn00dle wants to merge 1 commit intotrunkfrom
Conversation
…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>
There was a problem hiding this comment.
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_attributesfilter callback that forcedalign=leftandpadding=0for theimage-captionMJML 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' ); | |||
There was a problem hiding this comment.
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.
| 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 ); |
laurelfulford
left a comment
There was a problem hiding this comment.
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!
All Submissions:
Changes proposed in this Pull Request:
The MJML image-caption component attributes filter (setting
align=leftandpadding=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:
Other information:
🤖 Generated with Claude Code