Skip to content

Commit

Permalink
fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvankooten committed May 6, 2024
1 parent 50573b3 commit f81c8ce
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 98 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ vendor/
npm-debug.log
yarn.lock
*.swp

assets/*
!assets/src
129 changes: 64 additions & 65 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -1,74 +1,73 @@
<?php

spl_autoload_register(function($class) {
spl_autoload_register(function ($class) {
static $classmap = array(
'MC4WP_API_Connection_Exception' => __DIR__ . '/includes/api/class-connection-exception.php',
'MC4WP_API_Exception' => __DIR__ . '/includes/api/class-exception.php',
'MC4WP_API_Resource_Not_Found_Exception' => __DIR__ . '/includes/api/class-resource-not-found-exception.php',
'MC4WP_API_V3' => __DIR__ . '/includes/api/class-api-v3.php',
'MC4WP_API_V3_Client' => __DIR__ . '/includes/api/class-api-v3-client.php',
'MC4WP_Admin' => __DIR__ . '/includes/admin/class-admin.php',
'MC4WP_Admin_Ads' => __DIR__ . '/includes/admin/class-ads.php',
'MC4WP_Admin_Ajax' => __DIR__ . '/includes/admin/class-admin-ajax.php',
'MC4WP_Admin_Messages' => __DIR__ . '/includes/admin/class-admin-messages.php',
'MC4WP_Admin_Review_Notice' => __DIR__ . '/includes/admin/class-review-notice.php',
'MC4WP_Admin_Texts' => __DIR__ . '/includes/admin/class-admin-texts.php',
'MC4WP_Admin_Tools' => __DIR__ . '/includes/admin/class-admin-tools.php',
'MC4WP_AffiliateWP_Integration' => __DIR__ . '/integrations/affiliatewp/class-affiliatewp.php',
'MC4WP_BuddyPress_Integration' => __DIR__ . '/integrations/buddypress/class-buddypress.php',
'MC4WP_Comment_Form_Integration' => __DIR__ . '/integrations/wp-comment-form/class-comment-form.php',
'MC4WP_Contact_Form_7_Integration' => __DIR__ . '/integrations/contact-form-7/class-contact-form-7.php',
'MC4WP_Container' => __DIR__ . '/includes/class-container.php',
'MC4WP_Custom_Integration' => __DIR__ . '/integrations/custom/class-custom.php',
'MC4WP_Debug_Log' => __DIR__ . '/includes/class-debug-log.php',
'MC4WP_Debug_Log_Reader' => __DIR__ . '/includes/class-debug-log-reader.php',
'MC4WP_Dynamic_Content_Tags' => __DIR__ . '/includes/class-dynamic-content-tags.php',
'MC4WP_Easy_Digital_Downloads_Integration' => __DIR__ . '/integrations/easy-digital-downloads/class-easy-digital-downloads.php',
'MC4WP_Events_Manager_Integration' => __DIR__ . '/integrations/events-manager/class-events-manager.php',
'MC4WP_Field_Formatter' => __DIR__ . '/includes/class-field-formatter.php',
'MC4WP_Field_Guesser' => __DIR__ . '/includes/class-field-guesser.php',
'MC4WP_Form' => __DIR__ . '/includes/forms/class-form.php',
'MC4WP_Form_AMP' => __DIR__ . '/includes/forms/class-form-amp.php',
'MC4WP_Form_Asset_Manager' => __DIR__ . '/includes/forms/class-asset-manager.php',
'MC4WP_Form_Element' => __DIR__ . '/includes/forms/class-form-element.php',
'MC4WP_Form_Listener' => __DIR__ . '/includes/forms/class-form-listener.php',
'MC4WP_Form_Manager' => __DIR__ . '/includes/forms/class-form-manager.php',
'MC4WP_Form_Notice' => __DIR__ . '/includes/forms/class-form-message.php',
'MC4WP_Form_Output_Manager' => __DIR__ . '/includes/forms/class-output-manager.php',
'MC4WP_Form_Previewer' => __DIR__ . '/includes/forms/class-form-previewer.php',
'MC4WP_Form_Tags' => __DIR__ . '/includes/forms/class-form-tags.php',
'MC4WP_Form_Widget' => __DIR__ . '/includes/forms/class-widget.php',
'MC4WP_Forms_Admin' => __DIR__ . '/includes/forms/class-admin.php',
'MC4WP_Give_Integration' => __DIR__ . '/integrations/give/class-give.php',
'MC4WP_Gravity_Forms_Field' => __DIR__ . '/integrations/gravity-forms/class-field.php',
'MC4WP_Gravity_Forms_Integration' => __DIR__ . '/integrations/gravity-forms/class-gravity-forms.php',
'MC4WP_Integration' => __DIR__ . '/includes/integrations/class-integration.php',
'MC4WP_Integration_Admin' => __DIR__ . '/includes/integrations/class-admin.php',
'MC4WP_Integration_Fixture' => __DIR__ . '/includes/integrations/class-integration-fixture.php',
'MC4WP_Integration_Manager' => __DIR__ . '/includes/integrations/class-integration-manager.php',
'MC4WP_Integration_Tags' => __DIR__ . '/includes/integrations/class-integration-tags.php',
'MC4WP_List_Data_Mapper' => __DIR__ . '/includes/class-list-data-mapper.php',
'MC4WP_MailChimp' => __DIR__ . '/includes/class-mailchimp.php',
'MC4WP_MailChimp_Subscriber' => __DIR__ . '/includes/class-mailchimp-subscriber.php',
'MC4WP_MemberPress_Integration' => __DIR__ . '/integrations/memberpress/class-memberpress.php',
'MC4WP_Ninja_Forms_Action' => __DIR__ . '/integrations/ninja-forms/class-action.php',
'MC4WP_Ninja_Forms_Field' => __DIR__ . '/integrations/ninja-forms/class-field.php',
'MC4WP_Ninja_Forms_Integration' => __DIR__ . '/integrations/ninja-forms/class-ninja-forms.php',
'MC4WP_Ninja_Forms_V2_Integration' => __DIR__ . '/integrations/ninja-forms-2/class-ninja-forms.php',
'MC4WP_Plugin' => __DIR__ . '/includes/class-plugin.php',
'MC4WP_Queue' => __DIR__ . '/includes/class-queue.php',
'MC4WP_Queue_Job' => __DIR__ . '/includes/class-queue-job.php',
'MC4WP_Registration_Form_Integration' => __DIR__ . '/integrations/wp-registration-form/class-registration-form.php',
'MC4WP_Tools' => __DIR__ . '/includes/class-tools.php',
'MC4WP_Upgrade_Routines' => __DIR__ . '/includes/admin/class-upgrade-routines.php',
'MC4WP_User_Integration' => __DIR__ . '/includes/integrations/class-user-integration.php',
'MC4WP_WPForms_Field' => __DIR__ . '/integrations/wpforms/class-field.php',
'MC4WP_WPForms_Integration' => __DIR__ . '/integrations/wpforms/class-wpforms.php',
'MC4WP_WooCommerce_Integration' => __DIR__ . '/integrations/woocommerce/class-woocommerce.php',
'MC4WP_API_Connection_Exception' => __DIR__ . '/includes/api/class-connection-exception.php',
'MC4WP_API_Exception' => __DIR__ . '/includes/api/class-exception.php',
'MC4WP_API_Resource_Not_Found_Exception' => __DIR__ . '/includes/api/class-resource-not-found-exception.php',
'MC4WP_API_V3' => __DIR__ . '/includes/api/class-api-v3.php',
'MC4WP_API_V3_Client' => __DIR__ . '/includes/api/class-api-v3-client.php',
'MC4WP_Admin' => __DIR__ . '/includes/admin/class-admin.php',
'MC4WP_Admin_Ads' => __DIR__ . '/includes/admin/class-ads.php',
'MC4WP_Admin_Ajax' => __DIR__ . '/includes/admin/class-admin-ajax.php',
'MC4WP_Admin_Messages' => __DIR__ . '/includes/admin/class-admin-messages.php',
'MC4WP_Admin_Review_Notice' => __DIR__ . '/includes/admin/class-review-notice.php',
'MC4WP_Admin_Texts' => __DIR__ . '/includes/admin/class-admin-texts.php',
'MC4WP_Admin_Tools' => __DIR__ . '/includes/admin/class-admin-tools.php',
'MC4WP_AffiliateWP_Integration' => __DIR__ . '/integrations/affiliatewp/class-affiliatewp.php',
'MC4WP_BuddyPress_Integration' => __DIR__ . '/integrations/buddypress/class-buddypress.php',
'MC4WP_Comment_Form_Integration' => __DIR__ . '/integrations/wp-comment-form/class-comment-form.php',
'MC4WP_Contact_Form_7_Integration' => __DIR__ . '/integrations/contact-form-7/class-contact-form-7.php',
'MC4WP_Container' => __DIR__ . '/includes/class-container.php',
'MC4WP_Custom_Integration' => __DIR__ . '/integrations/custom/class-custom.php',
'MC4WP_Debug_Log' => __DIR__ . '/includes/class-debug-log.php',
'MC4WP_Debug_Log_Reader' => __DIR__ . '/includes/class-debug-log-reader.php',
'MC4WP_Dynamic_Content_Tags' => __DIR__ . '/includes/class-dynamic-content-tags.php',
'MC4WP_Easy_Digital_Downloads_Integration' => __DIR__ . '/integrations/easy-digital-downloads/class-easy-digital-downloads.php',
'MC4WP_Events_Manager_Integration' => __DIR__ . '/integrations/events-manager/class-events-manager.php',
'MC4WP_Field_Formatter' => __DIR__ . '/includes/class-field-formatter.php',
'MC4WP_Field_Guesser' => __DIR__ . '/includes/class-field-guesser.php',
'MC4WP_Form' => __DIR__ . '/includes/forms/class-form.php',
'MC4WP_Form_AMP' => __DIR__ . '/includes/forms/class-form-amp.php',
'MC4WP_Form_Asset_Manager' => __DIR__ . '/includes/forms/class-asset-manager.php',
'MC4WP_Form_Element' => __DIR__ . '/includes/forms/class-form-element.php',
'MC4WP_Form_Listener' => __DIR__ . '/includes/forms/class-form-listener.php',
'MC4WP_Form_Manager' => __DIR__ . '/includes/forms/class-form-manager.php',
'MC4WP_Form_Notice' => __DIR__ . '/includes/forms/class-form-message.php',
'MC4WP_Form_Output_Manager' => __DIR__ . '/includes/forms/class-output-manager.php',
'MC4WP_Form_Previewer' => __DIR__ . '/includes/forms/class-form-previewer.php',
'MC4WP_Form_Tags' => __DIR__ . '/includes/forms/class-form-tags.php',
'MC4WP_Form_Widget' => __DIR__ . '/includes/forms/class-widget.php',
'MC4WP_Forms_Admin' => __DIR__ . '/includes/forms/class-admin.php',
'MC4WP_Give_Integration' => __DIR__ . '/integrations/give/class-give.php',
'MC4WP_Gravity_Forms_Field' => __DIR__ . '/integrations/gravity-forms/class-field.php',
'MC4WP_Gravity_Forms_Integration' => __DIR__ . '/integrations/gravity-forms/class-gravity-forms.php',
'MC4WP_Integration' => __DIR__ . '/includes/integrations/class-integration.php',
'MC4WP_Integration_Admin' => __DIR__ . '/includes/integrations/class-admin.php',
'MC4WP_Integration_Fixture' => __DIR__ . '/includes/integrations/class-integration-fixture.php',
'MC4WP_Integration_Manager' => __DIR__ . '/includes/integrations/class-integration-manager.php',
'MC4WP_Integration_Tags' => __DIR__ . '/includes/integrations/class-integration-tags.php',
'MC4WP_List_Data_Mapper' => __DIR__ . '/includes/class-list-data-mapper.php',
'MC4WP_MailChimp' => __DIR__ . '/includes/class-mailchimp.php',
'MC4WP_MailChimp_Subscriber' => __DIR__ . '/includes/class-mailchimp-subscriber.php',
'MC4WP_MemberPress_Integration' => __DIR__ . '/integrations/memberpress/class-memberpress.php',
'MC4WP_Ninja_Forms_Action' => __DIR__ . '/integrations/ninja-forms/class-action.php',
'MC4WP_Ninja_Forms_Field' => __DIR__ . '/integrations/ninja-forms/class-field.php',
'MC4WP_Ninja_Forms_Integration' => __DIR__ . '/integrations/ninja-forms/class-ninja-forms.php',
'MC4WP_Ninja_Forms_V2_Integration' => __DIR__ . '/integrations/ninja-forms-2/class-ninja-forms.php',
'MC4WP_Plugin' => __DIR__ . '/includes/class-plugin.php',
'MC4WP_Queue' => __DIR__ . '/includes/class-queue.php',
'MC4WP_Queue_Job' => __DIR__ . '/includes/class-queue-job.php',
'MC4WP_Registration_Form_Integration' => __DIR__ . '/integrations/wp-registration-form/class-registration-form.php',
'MC4WP_Tools' => __DIR__ . '/includes/class-tools.php',
'MC4WP_Upgrade_Routines' => __DIR__ . '/includes/admin/class-upgrade-routines.php',
'MC4WP_User_Integration' => __DIR__ . '/includes/integrations/class-user-integration.php',
'MC4WP_WPForms_Field' => __DIR__ . '/integrations/wpforms/class-field.php',
'MC4WP_WPForms_Integration' => __DIR__ . '/integrations/wpforms/class-wpforms.php',
'MC4WP_WooCommerce_Integration' => __DIR__ . '/integrations/woocommerce/class-woocommerce.php',
);

if (isset($classmap[$class])) {
require $classmap[$class];
}

});
4 changes: 2 additions & 2 deletions includes/admin/class-admin-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public function get_list_details()
}

if (isset($_GET['format']) && $_GET['format'] === 'html') {
$merge_fields = $data[0]->merge_fields;
$interest_categories = $data[0]->interest_categories;
$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 {
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function enqueue_assets()
// js
wp_register_script('mc4wp-admin', mc4wp_plugin_url('assets/js/admin.js'), array(), MC4WP_VERSION, true);
wp_enqueue_script('mc4wp-admin');
$connected = ! empty($opts['api_key']);
$connected = ! empty($opts['api_key']);
$mailchimp_lists = $connected ? $mailchimp->get_lists() : array();
wp_localize_script(
'mc4wp-admin',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// if old file exists, move it to new location
if (is_file($old_filename)) {
$new_filename = $upload_dir['basedir'] . '/mailchimp-for-wp/debug-log.php';
$dir = dirname($new_filename);
$dir = dirname($new_filename);
if (! is_dir($dir)) {
mkdir($dir, 0755, true);
}
Expand Down
6 changes: 3 additions & 3 deletions includes/class-list-data-mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ protected function map_list($list_id)

// add GDPR marketing permissions
if (! empty($this->data['MARKETING_PERMISSIONS'])) {
$values = $this->data['MARKETING_PERMISSIONS'];
$values = is_array($values) ? $values : explode(',', $values);
$values = array_map('trim', $values);
$values = $this->data['MARKETING_PERMISSIONS'];
$values = is_array($values) ? $values : explode(',', $values);
$values = array_map('trim', $values);
$marketing_permissions = $this->mailchimp->get_list_marketing_permissions($list_id);
foreach ($marketing_permissions as $mp) {
if (in_array($mp->marketing_permission_id, $values, true) || in_array($mp->text, $values, true)) {
Expand Down
2 changes: 1 addition & 1 deletion includes/class-mailchimp-subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MC4WP_MailChimp_Subscriber
*/
public function to_array()
{
$all = get_object_vars($this);
$all = get_object_vars($this);
$array = array();

foreach ($all as $key => $value) {
Expand Down
16 changes: 8 additions & 8 deletions includes/class-mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,10 @@ public function get_lists($skip_cache = false)

private function fetch_lists()
{
$client = $this->get_api()->get_client();
$lists_data = array();
$offset = 0;
$count = 10;
$client = $this->get_api()->get_client();
$lists_data = array();
$offset = 0;
$count = 10;
$exceptions_skipped = 0;

// increase total time limit to 3 minutes
Expand All @@ -416,7 +416,7 @@ function ($args) {
// collect all lists in separate HTTP requests
do {
try {
$data = $client->get(
$data = $client->get(
'/lists',
array(
'count' => $count,
Expand All @@ -426,12 +426,12 @@ function ($args) {
);

$lists_data = array_merge($lists_data, $data->lists);
$offset += $count;
$offset += $count;
} catch (MC4WP_API_Connection_Exception $e) {
// ignore timeout errors as this is likely due to mailchimp being slow to calculate the lists.stats.member_count property
// keep going so we can at least pull-in all other lists
$offset += $count;
$exceptions_skipped++;
++$exceptions_skipped;

// failsafe against infinite loop
// bail after 5 skipped exceptions
Expand Down Expand Up @@ -520,7 +520,7 @@ public function get_subscriber_count($list_ids)
continue;
}

$list = $lists["$list_id"];
$list = $lists["$list_id"];
$count += $list->stats->member_count;
}

Expand Down
1 change: 0 additions & 1 deletion includes/forms/admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ function mc4wp_get_add_form_url()
$url = admin_url('admin.php?page=mailchimp-for-wp-forms&view=add-form');
return $url;
}

4 changes: 2 additions & 2 deletions includes/forms/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ public function process_save_form()
}

// update form, settings and messages
$form_id = (int) $_POST['mc4wp_form_id'];
$form_data = $_POST['mc4wp_form'];
$form_id = (int) $_POST['mc4wp_form_id'];
$form_data = $_POST['mc4wp_form'];
$this->save_form($form_id, $form_data);
$this->set_default_form_id($form_id);
$this->messages->flash(esc_html__('Form saved.', 'mailchimp-for-wp'));
Expand Down
2 changes: 1 addition & 1 deletion includes/forms/class-asset-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function load_stylesheets()
}

$handle = 'mc4wp-form-' . $stylesheet;
$url = $this->get_stylesheet_url($stylesheet);
$url = $this->get_stylesheet_url($stylesheet);
wp_enqueue_style($handle, $url, array(), MC4WP_VERSION);
add_editor_style($url);
}
Expand Down
8 changes: 4 additions & 4 deletions includes/forms/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ function mc4wp_get_form($form_id = 0)
function mc4wp_get_forms(array $args = array())
{
// parse function arguments
$default_args = array(
$default_args = array(
'post_status' => 'publish',
'posts_per_page' => -1,
'ignore_sticky_posts' => true,
'no_found_rows' => true,
);
$args = array_merge($default_args, $args);
$args = array_merge($default_args, $args);

// set post_type here so it can't be overwritten using function arguments
$args['post_type'] = 'mc4wp-form';

$q = new WP_Query();
$posts = $q->query($args);
$q = new WP_Query();
$posts = $q->query($args);
$forms = array();
foreach ($posts as $post) {
try {
Expand Down
4 changes: 2 additions & 2 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ function mc4wp_get_debug_log()
$opts = mc4wp_get_options();

// get default log file location
$upload_dir = wp_upload_dir(null, false);
$file = $upload_dir['basedir'] . '/mailchimp-for-wp/debug-log.php';
$upload_dir = wp_upload_dir(null, false);
$file = $upload_dir['basedir'] . '/mailchimp-for-wp/debug-log.php';
$default_file = $file;

/**
Expand Down
4 changes: 2 additions & 2 deletions includes/integrations/class-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function get_label_text()

if (empty($label)) {
$default_options = $this->get_default_options();
$label = $default_options['label'];
$label = $default_options['label'];
}

/**
Expand Down Expand Up @@ -294,7 +294,7 @@ public function get_checkbox_html()
/** @ignore */
do_action('mc4wp_integration_' . $this->slug . '_before_checkbox_wrapper', $this);

$wrapper_tag = $this->options['wrap_p'] ? 'p' : 'span';
$wrapper_tag = $this->options['wrap_p'] ? 'p' : 'span';
$wrapper_attrs = $this->get_wrapper_attributes();

// Hidden field to make sure "0" is sent to server
Expand Down
4 changes: 2 additions & 2 deletions integrations/woocommerce/admin-after.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

if (defined('CFW_NAME')) {
$position_options['cfw_checkout_before_payment_method_tab_nav'] = __('Checkout for WooCommerce: Before complete order button', 'mailchimp-for-wp');
$position_options['cfw_after_customer_info_account_details'] = __('Checkout for WooCommerce: After account info', 'mailchimp-for-wp');
$position_options['cfw_checkout_after_customer_info_address'] = __('Checkout for WooCommerce: After customer info', 'mailchimp-for-wp');
$position_options['cfw_after_customer_info_account_details'] = __('Checkout for WooCommerce: After account info', 'mailchimp-for-wp');
$position_options['cfw_checkout_after_customer_info_address'] = __('Checkout for WooCommerce: After customer info', 'mailchimp-for-wp');
}

/** @var MC4WP_Integration $integration */
Expand Down
4 changes: 2 additions & 2 deletions mailchimp-for-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function _mc4wp_load_plugin()
* @global MC4WP_Container $GLOBALS['mc4wp']
* @name $mc4wp
*/
$mc4wp = mc4wp();
$mc4wp = mc4wp();
$mc4wp['api'] = 'mc4wp_get_api_v3';
$mc4wp['log'] = 'mc4wp_get_debug_log';

Expand All @@ -89,7 +89,7 @@ function _mc4wp_load_plugin()
$ajax = new MC4WP_Admin_Ajax($admin_tools);
$ajax->add_hooks();
} else {
$messages = new MC4WP_Admin_Messages();
$messages = new MC4WP_Admin_Messages();
$mc4wp['admin.messages'] = $messages;

$admin = new MC4WP_Admin($admin_tools, $messages);
Expand Down

0 comments on commit f81c8ce

Please sign in to comment.