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