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): fatal error with invalid API keys #1690

Merged
merged 9 commits into from
Nov 11, 2024
5 changes: 5 additions & 0 deletions includes/class-newspack-newsletters-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ private static function render_oauth_authorization() {
private static function render_lists_table() {
$lists = Newspack_Newsletters_Subscription::get_lists();
if ( is_wp_error( $lists ) || empty( $lists ) ) {
?>
<div class="notice notice-error">
<p><?php echo esc_html( is_wp_error( $lists ) ? $lists->get_error_message() : __( 'No list data found.', 'newspack-newsletters' ) ); ?></p>
</div>
<?php
return;
}
?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ public function validate( $result, $preferred_error = null ) {
throw new Exception( esc_html__( 'A Mailchimp error has occurred.', 'newspack-newsletters' ) );
}
}
if ( ! empty( $result['status'] ) && in_array( $result['status'], [ 400, 404 ] ) ) {
if ( ! empty( $result['status'] ) && 400 <= (int) $result['status'] ) {
if ( $preferred_error && ! Newspack_Newsletters::debug_mode() ) {
if ( ! empty( $result['detail'] ) ) {
$preferred_error .= ' ' . $result['detail'];
Expand Down