From b7671538b4d9ab233fcbcbdf7030a4b7b438364a Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Tue, 29 Oct 2024 23:48:51 +0530 Subject: [PATCH] syntax improvements. --- lib/mailchimp/mailchimp.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/mailchimp/mailchimp.php b/lib/mailchimp/mailchimp.php index 0611618..212b97c 100644 --- a/lib/mailchimp/mailchimp.php +++ b/lib/mailchimp/mailchimp.php @@ -196,10 +196,9 @@ public function post( $endpoint, $body, $method = 'POST' ) { $field_name = $merge['name']; } } - $message = $body['errors'][0]['message']; - if ( ! empty ( $field_name ) ) { - $message = $field_name . ': ' . $body['errors'][0]['message']; - } + $message = $body['errors'][0]['message'] ?? esc_html__( 'Something went wrong, Please try again later.', 'mailchimp' ); + $message = ( ! empty( $field_name ) ) ? $field_name . ': ' . $message : $message; + return new WP_Error( 'mc-subscribe-error-api', $message ); } }