Skip to content

Commit

Permalink
PHP Compat to 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nateconley committed Jun 10, 2024
1 parent ddcdcf7 commit b864b8c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"prefer-stable": true,
"require": {
"php": ">=5.6"
"php": ">=7.0"
},
"require-dev": {
"10up/phpcs-composer": "^3.0",
Expand Down
5 changes: 3 additions & 2 deletions lib/mailchimp/mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ) ) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 ) {
Expand Down
4 changes: 2 additions & 2 deletions mailchimp_widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ function mailchimp_sf_signup_form( $args = array() ) {
<div class="field-group groups mc_email_options">
<ul class="mc_list">
<li><input type="radio" name="email_type" id="email_type_html" value="html" checked="checked"><label for="email_type_html" class="mc_email_type"><?php esc_html_e( 'HTML', 'mailchimp_i18n' ); ?></label></li>
<li><input type="radio" name="email_type" id="email_type_text" value="text"><label for="email_type_text" class="mc_email_type"><?php esc_html_( 'Text', 'mailchimp_i18n' ); ?></label></li>
<li><input type="radio" name="email_type" id="email_type_text" value="text"><label for="email_type_text" class="mc_email_type"><?php esc_html_e( 'Text', 'mailchimp_i18n' ); ?></label></li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -465,7 +465,7 @@ function mailchimp_form_field( $data, $num_fields ) {
<input type="text" size="18" maxlength="5" value="" name="' . esc_attr( $opt ) . '" id="' . esc_attr( $opt ) . '" class="mc_input" />';
break;
case 'phone':
if ( 'US' === $data['options']['phone_format'] ) {
if ( isset( $data['options']['phone_format'] ) && 'US' === $data['options']['phone_format'] ) {
$html .= '
<input type="text" size="2" maxlength="3" value="" name="' . esc_attr( $opt . '[area]' ) . '" id="' . esc_attr( $opt . '-area' ) . '" class="mc_input mc_phone" />
<input type="text" size="2" maxlength="3" value="" name="' . esc_attr( $opt . '[detail1]' ) . '" id="' . esc_attr( $opt . '-detail1' ) . '" class="mc_input mc_phone" />
Expand Down
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit b864b8c

Please sign in to comment.