feat: Add Mailchimp Campaign Archive block and shortcode (#811)#829
Open
faisalahammad wants to merge 3 commits intoibericode:mainfrom
Open
feat: Add Mailchimp Campaign Archive block and shortcode (#811)#829faisalahammad wants to merge 3 commits intoibericode:mainfrom
faisalahammad wants to merge 3 commits intoibericode:mainfrom
Conversation
3b58b21 to
47b316b
Compare
4e7ee98 to
fb9b13a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new shortcode
[mc4wp_campaigns]and a native Gutenberg block to display an archive of sent Mailchimp campaigns directly on a WordPress site.Fixes #811
Problem
Users currently lack an official, built-in way to display their Mailchimp campaign history on their sites without relying on third-party plugins or manual embeds.
Solution
Implemented a WordPress shortcode and a Gutenberg block that fetch and render the user's sent campaigns. We use the existing
MC4WP_API_V3wrapper and transient caching to ensure performance and prevent rate-limiting.Changes
includes/campaigns/class-archive.phpBefore:
// File didn't existAfter:
Why: Centralized logic for both the shortcode and server-side block rendering. It correctly extracts the campaigns array from the API response object and leverages transient caching.
assets/src/js/campaigns-block.jsBefore:
// File didn't existAfter:
Why: Registers editor UI that aligns with
mailchimp-for-wpstandards. It is explicitly wrapped in standard<div>instead of React Fragment<>syntax to guarantee@babel/preset-envcompatibility during compilation.Testing
Test 1: Shortcode Rendering
Steps:
[mc4wp_campaigns]Result: Works as expected
Test 2: Transient Caching & API Errors
Steps:
Result: Handled correctly
Automated:
$ composer run-script test OK (62 tests, 190 assertions) $ vendor/bin/phpcs -n -s Exit code: 0Build
mailchimp-for-wp-feature-811.zip available for manual testing
Install: WP Admin → Plugins → Upload
Screenshot