Add mailchimp_sf_list_limit filter to allow modifying the list limit.#210
Open
iamdharmesh wants to merge 5 commits intodevelopfrom
Open
Add mailchimp_sf_list_limit filter to allow modifying the list limit.#210iamdharmesh wants to merge 5 commits intodevelopfrom
mailchimp_sf_list_limit filter to allow modifying the list limit.#210iamdharmesh wants to merge 5 commits intodevelopfrom
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.
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.
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: