From b864b8cd45a6bc07c7a11a5b31723560218e175b Mon Sep 17 00:00:00 2001 From: Nate Conley Date: Mon, 10 Jun 2024 13:40:11 -1000 Subject: [PATCH 1/6] 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. From 3ef9654c19fad18bf3280c2dd684b736998a7e07 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Tue, 11 Jun 2024 11:31:29 -0600 Subject: [PATCH 2/6] Update plugin header values --- mailchimp.php | 3 ++- readme.txt | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mailchimp.php b/mailchimp.php index 146a5db..1e1d208 100644 --- a/mailchimp.php +++ b/mailchimp.php @@ -5,7 +5,8 @@ * Description: Add a Mailchimp signup form widget to your WordPress site. * Version: 1.5.8 * Requires at least: 2.8 - * Requires PHP: 5.6 + * Requires PHP: 7.0 + * PHP tested up to: 8.3 * Author: Mailchimp * Author URI: https://mailchimp.com/ * License: GPL-2.0-or-later diff --git a/readme.txt b/readme.txt index 174e39e..e680f1a 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,6 @@ 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 @@ -11,7 +10,7 @@ Add a Mailchimp signup form widget to your WordPress site. == Description == -Use the Mailchimp List Subscribe plugin to quickly add a Mailchimp signup form widget to your WordPress 2.8 or higher site. +Use the Mailchimp List Subscribe plugin to quickly add a Mailchimp signup form widget to your WordPress 2.8 or higher site. After installation, you’ll log in with your API key, select your Mailchimp list, choose merge fields and groups, and add the widget to your site. Typically, installation and setup will take about 5-10 minutes, and absolutely everything can be done via the WordPress Setting GUI, with no file editing at all. @@ -35,7 +34,7 @@ This section describes how to install the plugin and get started using it. If you have a custom coded sidebar or bells and whistles that prevent enabling widgets through the WordPress GUI, complete these steps instead. -WordPress v2.8 or higher: +WordPress v2.8 or higher: ` [mailchimpsf_form] ` If you are adding it inside a php code block, pop this in: From a623e4329dbb5a2ef5de1dcb4c9899a15901d1bb Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Tue, 11 Jun 2024 11:31:42 -0600 Subject: [PATCH 3/6] Update minimum version of PHP we run tests on --- phpcs-compat.xml | 2 +- phpcs.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpcs-compat.xml b/phpcs-compat.xml index 343c7f3..0169949 100644 --- a/phpcs-compat.xml +++ b/phpcs-compat.xml @@ -14,5 +14,5 @@ */po/* - + diff --git a/phpcs.xml b/phpcs.xml index 5d56154..4bed1da 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -7,7 +7,7 @@ */tests/* - + From b8c91f31fe0c825bd28d0d955c6ae7050d2ece75 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Tue, 11 Jun 2024 11:32:10 -0600 Subject: [PATCH 4/6] Run composer update --- composer.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.lock b/composer.lock index 31791cb..a2b433e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9c39d58a367b0054a205ffd85162eb2f", + "content-hash": "b4631e7ae4a2f6a3795a92a813440087", "packages": [], "packages-dev": [ { @@ -814,7 +814,7 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=5.6" + "php": ">=7.0" }, "platform-dev": [], "plugin-api-version": "2.6.0" From 44358b8d736a8cb4d7d883ce6e414eb73acc4dd2 Mon Sep 17 00:00:00 2001 From: Nate Conley Date: Tue, 11 Jun 2024 08:30:10 -1000 Subject: [PATCH 5/6] Resolve boolean comparison for options --- mailchimp.php | 4 ++-- mailchimp_widget.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mailchimp.php b/mailchimp.php index 1e1d208..b909a5e 100644 --- a/mailchimp.php +++ b/mailchimp.php @@ -70,7 +70,7 @@ function mailchimp_sf_plugin_init() { // Remove Sopresto check. If user does not have API key, make them authenticate. - if ( get_option( 'mc_list_id' ) && get_option( 'mc_merge_field_migrate' ) !== true && mailchimp_sf_get_api() !== false ) { + if ( get_option( 'mc_list_id' ) && get_option( 'mc_merge_field_migrate' ) !== '1' && mailchimp_sf_get_api() !== false ) { mailchimp_sf_update_merge_fields(); } @@ -127,7 +127,7 @@ function mailchimp_sf_load_resources() { wp_enqueue_script( 'jquery-ui-datepicker' ); } - if ( get_option( 'mc_nuke_all_styles' ) !== true ) { + if ( get_option( 'mc_nuke_all_styles' ) !== '1' ) { wp_enqueue_style( 'mailchimp_sf_main_css', home_url( '?mcsf_action=main_css&ver=' . MCSF_VER, 'relative' ), array(), MCSF_VER ); wp_enqueue_style( 'mailchimp_sf_ie_css', MCSF_URL . 'css/ie.css', array(), MCSF_VER ); global $wp_styles; diff --git a/mailchimp_widget.php b/mailchimp_widget.php index f04e834..f799df0 100644 --- a/mailchimp_widget.php +++ b/mailchimp_widget.php @@ -63,7 +63,7 @@ function mailchimp_sf_signup_form( $args = array() ) { $sub_heading = trim( get_option( 'mc_subheader_content' ) ); - if ( get_option( 'mc_nuke_all_styles' ) !== true ) { + if ( get_option( 'mc_nuke_all_styles' ) !== '1' ) { ?>