Skip to content

Commit

Permalink
update cs to adhere to PSR-12
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvankooten committed May 6, 2024
1 parent c9b99d0 commit d4d2234
Show file tree
Hide file tree
Showing 120 changed files with 14,059 additions and 13,582 deletions.
6 changes: 3 additions & 3 deletions config/default-form-content.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

$email_label = esc_html__( 'Email address', 'mailchimp-for-wp' );
$email_placeholder = esc_html__( 'Your email address', 'mailchimp-for-wp' );
$signup_button = esc_html__( 'Sign up', 'mailchimp-for-wp' );
$email_label = esc_html__('Email address', 'mailchimp-for-wp');
$email_placeholder = esc_html__('Your email address', 'mailchimp-for-wp');
$signup_button = esc_html__('Sign up', 'mailchimp-for-wp');

$content = "<p>\n\t<label>{$email_label}: \n";
$content .= "\t\t<input type=\"email\" name=\"EMAIL\" placeholder=\"{$email_placeholder}\" required />\n</label>\n</p>\n\n";
Expand Down
73 changes: 37 additions & 36 deletions config/default-form-messages.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
<?php

return array(
'subscribed' => array(
'type' => 'success',
'text' => esc_html__( 'Thank you, your sign-up request was successful! Please check your email inbox to confirm.', 'mailchimp-for-wp' ),
),
'updated' => array(
'type' => 'success',
'text' => esc_html__( 'Thank you, your records have been updated!', 'mailchimp-for-wp' ),
),
'unsubscribed' => array(
'type' => 'success',
'text' => esc_html__( 'You were successfully unsubscribed.', 'mailchimp-for-wp' ),
),
'not_subscribed' => array(
'type' => 'notice',
'text' => esc_html__( 'Given email address is not subscribed.', 'mailchimp-for-wp' ),
),
'error' => array(
'type' => 'error',
'text' => esc_html__( 'Oops. Something went wrong. Please try again later.', 'mailchimp-for-wp' ),
),
'invalid_email' => array(
'type' => 'error',
'text' => esc_html__( 'Please provide a valid email address.', 'mailchimp-for-wp' ),
),
'already_subscribed' => array(
'type' => 'notice',
'text' => esc_html__( 'Given email address is already subscribed, thank you!', 'mailchimp-for-wp' ),
),
'required_field_missing' => array(
'type' => 'error',
'text' => esc_html__( 'Please fill in the required fields.', 'mailchimp-for-wp' ),
),
'no_lists_selected' => array(
'type' => 'error',
'text' => esc_html__( 'Please select at least one list.', 'mailchimp-for-wp' ),
),
'subscribed' => array(
'type' => 'success',
'text' => esc_html__('Thank you, your sign-up request was successful! Please check your email inbox to confirm.', 'mailchimp-for-wp'),
),
'updated' => array(
'type' => 'success',
'text' => esc_html__('Thank you, your records have been updated!', 'mailchimp-for-wp'),
),
'unsubscribed' => array(
'type' => 'success',
'text' => esc_html__('You were successfully unsubscribed.', 'mailchimp-for-wp'),
),
'not_subscribed' => array(
'type' => 'notice',
'text' => esc_html__('Given email address is not subscribed.', 'mailchimp-for-wp'),
),
'error' => array(
'type' => 'error',
'text' => esc_html__('Oops. Something went wrong. Please try again later.', 'mailchimp-for-wp'),
),
'invalid_email' => array(
'type' => 'error',
'text' => esc_html__('Please provide a valid email address.', 'mailchimp-for-wp'),
),
'already_subscribed' => array(
'type' => 'notice',
'text' => esc_html__('Given email address is already subscribed, thank you!', 'mailchimp-for-wp'),
),
'required_field_missing' => array(
'type' => 'error',
'text' => esc_html__('Please fill in the required fields.', 'mailchimp-for-wp'),
),
'no_lists_selected' => array(
'type' => 'error',
'text' => esc_html__('Please select at least one list.', 'mailchimp-for-wp'),
),
);
19 changes: 10 additions & 9 deletions config/default-form-settings.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

return array(
'css' => 0,
'double_optin' => 1,
'hide_after_success' => 0,
'lists' => array(),
'redirect' => '',
'replace_interests' => 1,
'required_fields' => '',
'update_existing' => 0,
'subscriber_tags' => '',
'css' => 0,
'double_optin' => 1,
'hide_after_success' => 0,
'lists' => array(),
'redirect' => '',
'replace_interests' => 1,
'required_fields' => '',
'update_existing' => 0,
'subscriber_tags' => '',
);
7 changes: 4 additions & 3 deletions config/default-settings.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

return array(
'api_key' => '',
'allow_usage_tracking' => 0,
'debug_log_level' => 'warning',
'api_key' => '',
'allow_usage_tracking' => 0,
'debug_log_level' => 'warning',
);
132 changes: 68 additions & 64 deletions includes/admin/class-admin-ajax.php
Original file line number Diff line number Diff line change
@@ -1,75 +1,79 @@
<?php

class MC4WP_Admin_Ajax {
class MC4WP_Admin_Ajax
{
/**
* @var MC4WP_Admin_Tools
*/
protected $tools;

/**
* @var MC4WP_Admin_Tools
*/
protected $tools;
/**
* MC4WP_Admin_Ajax constructor.
*
* @param MC4WP_Admin_Tools $tools
*/
public function __construct(MC4WP_Admin_Tools $tools)
{
$this->tools = $tools;
}

/**
* MC4WP_Admin_Ajax constructor.
*
* @param MC4WP_Admin_Tools $tools
*/
public function __construct( MC4WP_Admin_Tools $tools ) {
$this->tools = $tools;
}
/**
* Hook AJAX actions
*/
public function add_hooks()
{
add_action('wp_ajax_mc4wp_renew_mailchimp_lists', array( $this, 'refresh_mailchimp_lists' ));
add_action('wp_ajax_mc4wp_get_list_details', array( $this, 'get_list_details' ));
}

/**
* Hook AJAX actions
*/
public function add_hooks() {
add_action( 'wp_ajax_mc4wp_renew_mailchimp_lists', array( $this, 'refresh_mailchimp_lists' ) );
add_action( 'wp_ajax_mc4wp_get_list_details', array( $this, 'get_list_details' ) );
}
/**
* Empty lists cache & fetch lists again.
*/
public function refresh_mailchimp_lists()
{
if (! $this->tools->is_user_authorized()) {
wp_send_json_error();
return;
}

/**
* Empty lists cache & fetch lists again.
*/
public function refresh_mailchimp_lists() {
if ( ! $this->tools->is_user_authorized() ) {
wp_send_json_error();
return;
}
check_ajax_referer('mc4wp-ajax');

check_ajax_referer( 'mc4wp-ajax' );
$mailchimp = new MC4WP_MailChimp();
$success = $mailchimp->refresh_lists();
wp_send_json($success);
}

$mailchimp = new MC4WP_MailChimp();
$success = $mailchimp->refresh_lists();
wp_send_json( $success );
}
/**
* Retrieve details (merge fields and interest categories) for one or multiple lists in Mailchimp
* @throws MC4WP_API_Exception
*/
public function get_list_details()
{
if (! $this->tools->is_user_authorized()) {
wp_send_json_error();
return;
}

/**
* Retrieve details (merge fields and interest categories) for one or multiple lists in Mailchimp
* @throws MC4WP_API_Exception
*/
public function get_list_details() {
if ( ! $this->tools->is_user_authorized() ) {
wp_send_json_error();
return;
}
$list_ids = (array) explode(',', $_GET['ids']);
$data = array();
$mailchimp = new MC4WP_MailChimp();
foreach ($list_ids as $list_id) {
$data[] = (object) array(
'id' => $list_id,
'merge_fields' => $mailchimp->get_list_merge_fields($list_id),
'interest_categories' => $mailchimp->get_list_interest_categories($list_id),
'marketing_permissions' => $mailchimp->get_list_marketing_permissions($list_id),
);
}

$list_ids = (array) explode( ',', $_GET['ids'] );
$data = array();
$mailchimp = new MC4WP_MailChimp();
foreach ( $list_ids as $list_id ) {
$data[] = (object) array(
'id' => $list_id,
'merge_fields' => $mailchimp->get_list_merge_fields( $list_id ),
'interest_categories' => $mailchimp->get_list_interest_categories( $list_id ),
'marketing_permissions' => $mailchimp->get_list_marketing_permissions( $list_id ),
);
}

if ( isset( $_GET['format'] ) && $_GET['format'] === 'html' ) {
$merge_fields = $data[0]->merge_fields;
$interest_categories = $data[0]->interest_categories;
$marketing_permissions = $data[0]->marketing_permissions;
require MC4WP_PLUGIN_DIR . '/includes/views/parts/lists-overview-details.php';
} else {
wp_send_json( $data );
}
exit;
}
if (isset($_GET['format']) && $_GET['format'] === 'html') {
$merge_fields = $data[0]->merge_fields;
$interest_categories = $data[0]->interest_categories;
$marketing_permissions = $data[0]->marketing_permissions;
require MC4WP_PLUGIN_DIR . '/includes/views/parts/lists-overview-details.php';
} else {
wp_send_json($data);
}
exit;
}
}
Loading

0 comments on commit d4d2234

Please sign in to comment.