Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mailchimp): avoid duplicate audiences in Mailchimp UIs #1685

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -618,14 +618,15 @@ public function retrieve( $post_id ) {
* @return array|WP_Error List of subscription lists or error.
*/
public function get_lists( $audiences_only = false ) {
$lists = Newspack_Newsletters_Mailchimp_Cached_Data::get_lists();
if ( $audiences_only || is_wp_error( $lists ) ) {
return $lists;
$audiences = Newspack_Newsletters_Mailchimp_Cached_Data::get_lists();
if ( $audiences_only || is_wp_error( $audiences ) ) {
return $audiences;
}
$lists = [];

// In addition to Audiences, we also automatically fetch all groups and tags and offer them as Subscription Lists.
// Build the final list inside the loop so groups are added after the list they belong to and we can then represent the hierarchy in the UI.
foreach ( $lists as $list ) {
foreach ( $audiences as $list ) {

$lists[] = $list;
$all_categories = Newspack_Newsletters_Mailchimp_Cached_Data::get_interest_categories( $list['id'] );
Expand Down