mailchimp-for-wp
Last commit date
assets
2 years ago
config
6 years ago
includes
2 years ago
integrations
2 years ago
languages
2 years ago
vendor
2 years ago
CHANGELOG.md
2 years ago
LICENSE
11 years ago
mailchimp-for-wp.php
2 years ago
readme.txt
1 year ago
wpml-config.xml
4 years ago
mailchimp-for-wp.php
119 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: MC4WP: Mailchimp for WordPress |
| 4 | Plugin URI: https://www.mc4wp.com/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=plugins-page |
| 5 | Description: Mailchimp for WordPress by ibericode. Adds various highly effective sign-up methods to your site. |
| 6 | Version: 4.9.13 |
| 7 | Author: ibericode |
| 8 | Author URI: https://www.ibericode.com/ |
| 9 | Text Domain: mailchimp-for-wp |
| 10 | Domain Path: /languages |
| 11 | License: GPL v3 |
| 12 | |
| 13 | Mailchimp for WordPress |
| 14 | Copyright (C) 2012-2024, Danny van Kooten, hi@dannyvankooten.com |
| 15 | |
| 16 | This program is free software: you can redistribute it and/or modify |
| 17 | it under the terms of the GNU General Public License as published by |
| 18 | the Free Software Foundation, either version 3 of the License, or |
| 19 | (at your option) any later version. |
| 20 | |
| 21 | This program is distributed in the hope that it will be useful, |
| 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | GNU General Public License for more details. |
| 25 | |
| 26 | You should have received a copy of the GNU General Public License |
| 27 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 28 | */ |
| 29 | |
| 30 | // Prevent direct file access |
| 31 | defined( 'ABSPATH' ) or exit; |
| 32 | |
| 33 | /** @ignore */ |
| 34 | function _mc4wp_load_plugin() { |
| 35 | global $mc4wp; |
| 36 | |
| 37 | // don't run if Mailchimp for WP Pro 2.x is activated |
| 38 | if ( defined( 'MC4WP_VERSION' ) ) { |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | // don't run if PHP version is lower than 5.3 |
| 43 | if ( ! function_exists( 'array_replace' ) ) { |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | // bootstrap the core plugin |
| 48 | define( 'MC4WP_VERSION', '4.9.13' ); |
| 49 | define( 'MC4WP_PLUGIN_DIR', __DIR__ ); |
| 50 | define( 'MC4WP_PLUGIN_FILE', __FILE__ ); |
| 51 | |
| 52 | // load autoloader if function not yet exists (for compat with sitewide autoloader) |
| 53 | if ( ! function_exists( 'mc4wp' ) ) { |
| 54 | require_once MC4WP_PLUGIN_DIR . '/vendor/autoload.php'; |
| 55 | } |
| 56 | |
| 57 | require MC4WP_PLUGIN_DIR . '/includes/default-actions.php'; |
| 58 | require MC4WP_PLUGIN_DIR . '/includes/default-filters.php'; |
| 59 | |
| 60 | // require API class manually because Composer's classloader is case-sensitive |
| 61 | // but we need it to pass class_exists condition |
| 62 | require MC4WP_PLUGIN_DIR . '/includes/api/class-api-v3.php'; |
| 63 | |
| 64 | /** |
| 65 | * @global MC4WP_Container $GLOBALS['mc4wp'] |
| 66 | * @name $mc4wp |
| 67 | */ |
| 68 | $mc4wp = mc4wp(); |
| 69 | $mc4wp['api'] = 'mc4wp_get_api_v3'; |
| 70 | $mc4wp['log'] = 'mc4wp_get_debug_log'; |
| 71 | |
| 72 | // forms |
| 73 | $form_manager = new MC4WP_Form_Manager(); |
| 74 | $form_manager->add_hooks(); |
| 75 | $mc4wp['forms'] = $form_manager; |
| 76 | |
| 77 | // integration core |
| 78 | $integration_manager = new MC4WP_Integration_Manager(); |
| 79 | $integration_manager->add_hooks(); |
| 80 | $mc4wp['integrations'] = $integration_manager; |
| 81 | |
| 82 | // Initialize admin section of plugin |
| 83 | if ( is_admin() ) { |
| 84 | $admin_tools = new MC4WP_Admin_Tools(); |
| 85 | |
| 86 | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 87 | $ajax = new MC4WP_Admin_Ajax( $admin_tools ); |
| 88 | $ajax->add_hooks(); |
| 89 | } else { |
| 90 | $messages = new MC4WP_Admin_Messages(); |
| 91 | $mc4wp['admin.messages'] = $messages; |
| 92 | |
| 93 | $admin = new MC4WP_Admin( $admin_tools, $messages ); |
| 94 | $admin->add_hooks(); |
| 95 | |
| 96 | $forms_admin = new MC4WP_Forms_Admin( $messages ); |
| 97 | $forms_admin->add_hooks(); |
| 98 | |
| 99 | $integrations_admin = new MC4WP_Integration_Admin( $mc4wp['integrations'], $messages ); |
| 100 | $integrations_admin->add_hooks(); |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | function _mc4wp_on_plugin_activation() { |
| 106 | // schedule the action hook to refresh the stored Mailchimp lists on a daily basis |
| 107 | $time_string = sprintf( 'tomorrow %d:%d am', rand( 0, 7 ), rand( 0, 59 ) ); |
| 108 | wp_schedule_event( strtotime( $time_string ), 'daily', 'mc4wp_refresh_mailchimp_lists' ); |
| 109 | } |
| 110 | |
| 111 | // bootstrap custom integrations |
| 112 | function _mc4wp_bootstrap_integrations() { |
| 113 | require_once MC4WP_PLUGIN_DIR . '/integrations/bootstrap.php'; |
| 114 | } |
| 115 | |
| 116 | add_action( 'plugins_loaded', '_mc4wp_load_plugin', 8 ); |
| 117 | add_action( 'plugins_loaded', '_mc4wp_bootstrap_integrations', 90 ); |
| 118 | register_activation_hook( __FILE__, '_mc4wp_on_plugin_activation' ); |
| 119 |