Conversation
…er displayed in selection dropdown
…ds prev/next buttons to paginate between
…s of lists Not QUITE the same - has to fetch all lists up front, but still provides pagination between shorter dropdowns
|
Thanks a lot for the PR, @jonjennings. I will try to look into this next week. I really appreciate your contribution here. Thank you! |
|
Hi @jonjennings, Thanks a lot for your contribution, and apologies for the delay. The PR looks really solid. We’ve been discussing different approaches internally, and the general consensus is that only a small number of users are likely to have 100+ lists. Instead of introducing changes for everyone, one idea is to add a filter that allows users to adjust the page limit as needed for example, setting it to 150 in your case. This keeps things lightweight while still solving the problem for those who need it. If we see more demand in the future, we can also consider enhancing the select dropdown into a searchable one. What are your thoughts? Thanks. cc: @builtbytay |
Description of the Change
Prior to this PR, accounts with >100 lists were hard-capped — only 100 lists were fetched via the API and only 100 appeared in the dropdown in the admin UI
Now the dropdowns in the admin UI and the block editor display 50 lists at a time with prev/next controls to fetch and display additional lists (number displayed is controlled by MCSF_LISTS_PER_PAGE)
[Actually the Mailchimp block has to fetch all lists up-front but mimics the admin UI with pagination across dropdowns of 50 lists]
The API get() method now accepts an $offset parameter enabling fetching lists in blocks
When the plugin needs to fetch ALL lists, it issues multiple API calls in batches of 100 (controlled by MCSF_LISTS_API_FETCH_LIMIT)
Admin list section UI:

Mailchimp Block list selection UI:

Closes #186 - "Plugin limited to 100 lists"
How to test the Change
Mailchimp form:
2. Navigate to the site's admin page at /wp-admin/admin.php?page=mailchimp_sf_options
3. Observe only 50 lists shown in list selection dropdown and text underneath reads "1-50 of xxx lists"
4. Click next/prev buttons as appropriate and observe status text changes and contents of dropdown list changes
Block editor:
5. Create a page
6. Add a Mailchimp block
7. Observe "select a list" dropdown in block settings contains only 50 lists
8. Functionality and navigation duplicates the Mailchimp form UI
Changelog Entry
Credits
Props @jonjennings
Checklist: