From b864b8cd45a6bc07c7a11a5b31723560218e175b Mon Sep 17 00:00:00 2001 From: Nate Conley Date: Mon, 10 Jun 2024 13:40:11 -1000 Subject: [PATCH] PHP Compat to 8.3 --- composer.json | 2 +- lib/mailchimp/mailchimp.php | 5 +++-- mailchimp.php | 8 ++++++-- mailchimp_widget.php | 4 ++-- readme.txt | 2 ++ 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index f940e16..2f2b77a 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ ], "prefer-stable": true, "require": { - "php": ">=5.6" + "php": ">=7.0" }, "require-dev": { "10up/phpcs-composer": "^3.0", diff --git a/lib/mailchimp/mailchimp.php b/lib/mailchimp/mailchimp.php index 478572e..07f9273 100644 --- a/lib/mailchimp/mailchimp.php +++ b/lib/mailchimp/mailchimp.php @@ -141,8 +141,9 @@ public function post( $endpoint, $body, $method = 'POST' ) { return new WP_Error( 'mc-subscribe-error', $request->get_error_message() ); } - $body = json_decode( $request['body'], true ); - $merges = get_option( 'mc_merge_vars' ); + $body = json_decode( $request['body'], true ); + $merges = get_option( 'mc_merge_vars' ); + $field_name = ''; foreach ( $merges as $merge ) { if ( empty( $body['errors'] ) ) { // Email address doesn't come back from the API, so if something's wrong, it's that. diff --git a/mailchimp.php b/mailchimp.php index d9b5768..146a5db 100644 --- a/mailchimp.php +++ b/mailchimp.php @@ -644,6 +644,10 @@ function mailchimp_sf_change_list_if_necessary() { // we *could* support paging, but few users have that many lists (and shouldn't) $lists = $api->get( 'lists', 100, array( 'fields' => 'lists.id,lists.name,lists.email_type_option' ) ); + if ( ! isset( $lists['lists'] ) || is_wp_error( $lists['lists'] ) ) { + return; + } + $lists = $lists['lists']; if ( is_array( $lists ) && ! empty( $lists ) && isset( $_POST['mc_list_id'] ) ) { @@ -703,7 +707,7 @@ function mailchimp_sf_change_list_if_necessary() { * * @param string $list_id List ID * @param bool $new_list Whether this is a new list - * @return void + * @return array */ function mailchimp_sf_get_merge_vars( $list_id, $new_list ) { $api = mailchimp_sf_get_api(); @@ -1265,7 +1269,7 @@ function mailchimp_sf_where_am_i() { // Set defaults $mscf_dirbase = trailingslashit( basename( __DIR__ ) ); // Typically wp-mailchimp/ or mailchimp/ $mscf_dir = trailingslashit( plugin_dir_path( __FILE__ ) ); - $mscf_url = trailingslashit( plugins_url( null, __FILE__ ) ); + $mscf_url = trailingslashit( plugins_url( '', __FILE__ ) ); // Try our hands at finding the real location foreach ( $locations as $key => $loc ) { diff --git a/mailchimp_widget.php b/mailchimp_widget.php index 50abc7c..f04e834 100644 --- a/mailchimp_widget.php +++ b/mailchimp_widget.php @@ -235,7 +235,7 @@ function mailchimp_sf_signup_form( $args = array() ) {
@@ -465,7 +465,7 @@ function mailchimp_form_field( $data, $num_fields ) { '; break; case 'phone': - if ( 'US' === $data['options']['phone_format'] ) { + if ( isset( $data['options']['phone_format'] ) && 'US' === $data['options']['phone_format'] ) { $html .= ' diff --git a/readme.txt b/readme.txt index 72dce61..174e39e 100644 --- a/readme.txt +++ b/readme.txt @@ -2,6 +2,7 @@ Contributors: Mailchimp Tags: mailchimp, email, newsletter, signup, marketing Tested up to: 4.5 +PHP tested up to: 7.0 Stable tag: 1.5.8 License: GPL-2.0-or-later License URI: https://spdx.org/licenses/GPL-2.0-or-later.html @@ -100,6 +101,7 @@ If your language is not listed above, feel free to create a translation. Here ar = 1.6.0 = * Deprecated function `mailchimpSF_signup_form`. Function `mailchimp_sf_signup_form` should be used instead. +* Bumps minimum PHP version to 7.0 = 1.5.8 = * Fix PHP warning for merge tags.