Skip to content

Commit

Permalink
bump required PHP version to 5.6 and get rid of dependency on Compose…
Browse files Browse the repository at this point in the history
…r autoloader
  • Loading branch information
dannyvankooten committed May 6, 2024
1 parent 357a023 commit 50573b3
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 63 deletions.
74 changes: 74 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

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',
);

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

});
15 changes: 1 addition & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"source": "https://github.com/ibericode/mailchimp-for-wordpress"
},
"require": {
"php": ">=5.3"
"php": ">=5.6"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
Expand All @@ -31,19 +31,6 @@
"test": "phpunit tests/",
"codestyle": "phpcs -n -s"
},
"autoload": {
"classmap": [
"includes/",
"integrations/"
],
"files": [
"includes/functions.php",
"includes/deprecated-functions.php",
"includes/forms/functions.php",
"includes/forms/admin-functions.php",
"includes/integrations/functions.php"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
Expand Down
35 changes: 0 additions & 35 deletions includes/forms/admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,3 @@ function mc4wp_get_add_form_url()
return $url;
}

/**
* @param $key
* @param $label
* @param $value
* @param string $help_text
*
* @return string
*/
//function mc4wp_form_message_setting_row( $key, $label, $value = '', $help_text = '' ) {
//
//
// $id = 'mc4wp_form_message_' . $key;
// echo $name = sprintf( 'mc4wp_form[messages][%s]', $key );
//
// echo '<tr valign="top">';
//
// # Label
// echo '<th scope="row">';
// echo sprintf( '<label for="%s">%s</label>', $id, $label );
// echo '</th>';
//
// # Input
// echo '<td>';
// echo sprintf( '<input type="text" class="widefat" id="%s" name="%s" value="%s" />', $id, $name, esc_attr( $value ) );
//
// # Help text
// if( ! empty( $help_text ) ) {
// echo sprintf( '<p class="description">%s</p>', $help_text );
// }
//
// echo '</td>';
// echo '</tr>';
//
// return '';
//}
28 changes: 14 additions & 14 deletions mailchimp-for-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
License: GPL v3
Mailchimp for WordPress
Copyright (C) 2012-2024, Danny van Kooten, [email protected]
Copyright (C) 2012 - 2024, Danny van Kooten, [email protected]
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -41,27 +41,27 @@ function _mc4wp_load_plugin()
return;
}

// don't run if PHP version is lower than 5.3
if (! function_exists('array_replace')) {
return;
// don't run if PHP version is lower than 5.6
if (PHP_VERSION_ID < 50600) {
return;
}

// bootstrap the core plugin
define('MC4WP_VERSION', '4.9.13');
define('MC4WP_PLUGIN_DIR', __DIR__);
define('MC4WP_PLUGIN_FILE', __FILE__);

// load autoloader if function not yet exists (for compat with sitewide autoloader)
if (! function_exists('mc4wp')) {
require_once MC4WP_PLUGIN_DIR . '/vendor/autoload.php';
}

require MC4WP_PLUGIN_DIR . '/includes/default-actions.php';
require MC4WP_PLUGIN_DIR . '/includes/default-filters.php';
require __DIR__ . '/autoload.php';
require __DIR__ . '/includes/functions.php';
require __DIR__ . '/includes/deprecated-functions.php';
require __DIR__ . '/includes/forms/functions.php';
require __DIR__ . '/includes/forms/admin-functions.php';
require __DIR__ . '/includes/integrations/functions.php';
require __DIR__ . '/includes/default-actions.php';
require __DIR__ . '/includes/default-filters.php';

// require API class manually because Composer's classloader is case-sensitive
// but we need it to pass class_exists condition
require MC4WP_PLUGIN_DIR . '/includes/api/class-api-v3.php';
require __DIR__ . '/includes/api/class-api-v3.php';

/**
* @global MC4WP_Container $GLOBALS['mc4wp']
Expand Down Expand Up @@ -98,7 +98,7 @@ function _mc4wp_load_plugin()
$forms_admin = new MC4WP_Forms_Admin($messages);
$forms_admin->add_hooks();

$integrations_admin = new MC4WP_Integration_Admin($mc4wp['integrations'], $messages);
$integrations_admin = new MC4WP_Integration_Admin($integration_manager, $messages);
$integrations_admin->add_hooks();
}
}
Expand Down

0 comments on commit 50573b3

Please sign in to comment.