Add mailchimp_sf_list_limit filter to allow modifying the list limit.#210
Conversation
There was a problem hiding this comment.
Pull request overview
This PR centralizes Mailchimp list retrieval behind a new mailchimp_sf_get_lists() helper and introduces a mailchimp_sf_list_limit filter so integrators can adjust how many lists are fetched, replacing several direct $api->get( 'lists', ... ) calls across admin UI, blocks, and token verification.
Changes:
- Added
mailchimp_sf_get_lists()inmailchimp.php, including themailchimp_sf_list_limitfilter. - Replaced direct Mailchimp API list-fetch calls with
mailchimp_sf_get_lists()in admin settings, block list loading, OAuth token verification, and list-change handling. - Removed old inline comments around the hard-coded 100-list limit in multiple locations.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
mailchimp.php |
Adds mailchimp_sf_get_lists() + filter, and refactors list-change logic to use the helper. |
includes/class-mailchimp-admin.php |
Uses the helper when validating/refreshing saved list data during OAuth token verification. |
includes/blocks/class-mailchimp-list-subscribe-form-blocks.php |
Uses the helper when populating block list data (and caching it to options). |
includes/admin/templates/settings.php |
Uses the helper to populate the settings-page list dropdown. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
… and maximum values.
|
@iamdharmesh, let's resolve the failing test before continuing |
QA/Test Status: Approved ✅Test Results:Tested the new Verified that:
This confirms the centralized list fetching logic and configurable list limit functionality work as expected. Functional Demo / Screencast:Recording.1844.mp4🐛 Issues Found:None. 🖥 Testing Environment:Details
🔁 Next Step: ready to merge. |
Description of the Change
This pull request refactors how Mailchimp lists are fetched throughout the codebase by introducing a new helper function,
mailchimp_sf_get_lists(). This change centralizes the logic for retrieving lists, making it easier to maintain and allowing for customization of the fetch limit via a filter. The update replaces direct API calls in several locations with the new helper function.Centralization and Reusability:
mailchimp_sf_get_lists(), inmailchimp.phpto encapsulate the logic for fetching Mailchimp lists, including support for customizing the fetch limit through themailchimp_sf_list_limitfilter.Codebase Refactoring:
$api->get('lists', ...)with calls to the newmailchimp_sf_get_lists()function in the following places:includes/admin/templates/settings.phpincludes/blocks/class-mailchimp-list-subscribe-form-blocks.php(get_listsmethod)includes/class-mailchimp-admin.php(verify_and_save_oauth_tokenmethod)mailchimp.php(mailchimp_sf_change_list_if_necessaryfunction)Closes #186
How to test the Change
functions.phpfile:Changelog Entry
Credits
Props @jonjennings @iamdharmesh
Checklist: