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/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" 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..5e18821 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 @@ -69,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(); } @@ -126,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; @@ -644,6 +645,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 +708,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(); @@ -984,7 +989,7 @@ function mailchimp_sf_merge_submit( $mv ) { $opt_val = isset( $_POST[ $opt ] ) ? map_deep( stripslashes_deep( $_POST[ $opt ] ), 'sanitize_text_field' ) : ''; // Handle phone number logic - if ( 'phone' === $mv_var['type'] && 'US' === $mv_var['options']['phone_format'] ) { + if ( isset( $mv_var['options']['phone_format'] ) && 'phone' === $mv_var['type'] && 'US' === $mv_var['options']['phone_format'] ) { $opt_val = mailchimp_sf_merge_validate_phone( $opt_val, $mv_var ); if ( is_wp_error( $opt_val ) ) { return $opt_val; @@ -1265,7 +1270,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..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' ) { ?>