mailchimp-for-wp
Last commit date
assets
9 years ago
config
9 years ago
includes
9 years ago
integrations
9 years ago
languages
9 years ago
vendor
9 years ago
CHANGELOG.md
9 years ago
LICENSE
11 years ago
mailchimp-for-wp.php
9 years ago
readme.txt
9 years ago
wpml-config.xml
10 years ago
mailchimp-for-wp.php
141 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: MailChimp for WordPress |
| 4 | Plugin URI: https://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.0.13 |
| 7 | Author: ibericode |
| 8 | Author URI: https://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-2017, 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 | /** |
| 34 | * Bootstrap the MailChimp for WordPress plugin |
| 35 | * |
| 36 | * @ignore |
| 37 | * @access private |
| 38 | * @return bool |
| 39 | */ |
| 40 | function _mc4wp_load_plugin() { |
| 41 | |
| 42 | global $mc4wp; |
| 43 | |
| 44 | // Don't run if MailChimp for WP Pro 2.x is activated |
| 45 | if( defined( 'MC4WP_VERSION' ) ) { |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | // bootstrap the core plugin |
| 50 | define( 'MC4WP_VERSION', '4.0.13' ); |
| 51 | define( 'MC4WP_PLUGIN_DIR', dirname( __FILE__ ) . '/' ); |
| 52 | define( 'MC4WP_PLUGIN_URL', plugins_url( '/' , __FILE__ ) ); |
| 53 | define( 'MC4WP_PLUGIN_FILE', __FILE__ ); |
| 54 | |
| 55 | // load autoloader if function not yet exists (for compat with sitewide autoloader) |
| 56 | if( ! function_exists( 'mc4wp' ) ) { |
| 57 | require_once MC4WP_PLUGIN_DIR . 'vendor/autoload_52.php'; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * @global MC4WP_Container $GLOBALS['mc4wp'] |
| 62 | * @name $mc4wp |
| 63 | */ |
| 64 | $mc4wp = mc4wp(); |
| 65 | $mc4wp['api'] = 'mc4wp_get_api_v3'; |
| 66 | $mc4wp['request'] = array( 'MC4WP_Request', 'create_from_globals' ); |
| 67 | $mc4wp['log'] = 'mc4wp_get_debug_log'; |
| 68 | |
| 69 | // forms |
| 70 | $mc4wp['forms'] = new MC4WP_Form_Manager(); |
| 71 | $mc4wp['forms']->add_hooks(); |
| 72 | |
| 73 | // integration core |
| 74 | $mc4wp['integrations'] = new MC4WP_Integration_Manager(); |
| 75 | $mc4wp['integrations']->add_hooks(); |
| 76 | |
| 77 | // bootstrap custom integrations |
| 78 | require_once MC4WP_PLUGIN_DIR . 'integrations/bootstrap.php'; |
| 79 | |
| 80 | // Doing cron? Load Usage Tracking class. |
| 81 | if( defined( 'DOING_CRON' ) && DOING_CRON ) { |
| 82 | MC4WP_Usage_Tracking::instance()->add_hooks(); |
| 83 | } |
| 84 | |
| 85 | // Initialize admin section of plugin |
| 86 | if( is_admin() ) { |
| 87 | |
| 88 | $admin_tools = new MC4WP_Admin_Tools(); |
| 89 | |
| 90 | if( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 91 | $ajax = new MC4WP_Admin_Ajax( $admin_tools ); |
| 92 | $ajax->add_hooks(); |
| 93 | } else { |
| 94 | $messages = new MC4WP_Admin_Messages(); |
| 95 | $mc4wp['admin.messages'] = $messages; |
| 96 | |
| 97 | $mailchimp = new MC4WP_MailChimp(); |
| 98 | |
| 99 | $admin = new MC4WP_Admin( $admin_tools, $messages, $mailchimp ); |
| 100 | $admin->add_hooks(); |
| 101 | |
| 102 | $forms_admin = new MC4WP_Forms_Admin( $messages, $mailchimp ); |
| 103 | $forms_admin->add_hooks(); |
| 104 | |
| 105 | $integrations_admin = new MC4WP_Integration_Admin( $mc4wp['integrations'], $messages, $mailchimp ); |
| 106 | $integrations_admin->add_hooks(); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | return true; |
| 111 | } |
| 112 | |
| 113 | add_action( 'plugins_loaded', '_mc4wp_load_plugin', 20 ); |
| 114 | |
| 115 | /** |
| 116 | * Flushes transient cache & schedules refresh hook. |
| 117 | * |
| 118 | * @ignore |
| 119 | * @since 3.0 |
| 120 | */ |
| 121 | function _mc4wp_on_plugin_activation() { |
| 122 | delete_transient( 'mc4wp_mailchimp_lists_v3' ); |
| 123 | delete_transient( 'mc4wp_mailchimp_lists_v3_fallback' ); |
| 124 | delete_transient( 'mc4wp_list_counts' ); |
| 125 | |
| 126 | wp_schedule_event( strtotime('tomorrow 3 am'), 'daily', 'mc4wp_refresh_mailchimp_lists' ); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Clears scheduled hook for refreshing MailChimp lists. |
| 131 | * |
| 132 | * @ignore |
| 133 | * @since 4.0.3 |
| 134 | */ |
| 135 | function _mc4wp_on_plugin_deactivation() { |
| 136 | wp_clear_scheduled_hook( 'mc4wp_refresh_mailchimp_lists' ); |
| 137 | } |
| 138 | |
| 139 | register_activation_hook( __FILE__, '_mc4wp_on_plugin_activation' ); |
| 140 | register_deactivation_hook( __FILE__, '_mc4wp_on_plugin_deactivation' ); |
| 141 |