function mc4wp_show_checkbox()
 {
     $mc4wp = MC4WP_Lite::get_instance();
     if ($mc4wp->checkbox) {
         $mc4wp->checkbox->output_checkbox();
     }
 }
/**
* Loads the MailChimp for WP plugin files
*
* @return boolean True if the plugin files were loaded, false otherwise.
*/
function mc4wp_load_plugin()
{
    // don't load plugin if user has the premium version installed and activated
    if (defined('MC4WP_VERSION')) {
        return false;
    }
    // bootstrap the lite plugin
    define('MC4WP_LITE_VERSION', '2.3.15');
    define('MC4WP_LITE_PLUGIN_DIR', dirname(__FILE__) . '/');
    define('MC4WP_LITE_PLUGIN_URL', plugins_url('/', __FILE__));
    define('MC4WP_LITE_PLUGIN_FILE', __FILE__);
    require_once MC4WP_LITE_PLUGIN_DIR . 'vendor/autoload_52.php';
    require_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions/general.php';
    require_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions/template.php';
    // Initialize admin section of plugin
    if (is_admin() && (!defined('DOING_AJAX') || !DOING_AJAX)) {
        new MC4WP_Lite_Admin();
    }
    // Initialize the plugin and store an instance in the global scope
    MC4WP_Lite::init();
    $GLOBALS['mc4wp'] = MC4WP_Lite::instance();
    // Doing cron?
    if (defined('DOING_CRON') && DOING_CRON) {
        MC4WP_Usage_Tracking::instance()->add_hooks();
    }
    return true;
}
示例#3
0
 /**
  * Instantiates the plugin
  *
  * @return bool
  */
 public static function init()
 {
     if (self::$instance instanceof MC4WP_Lite) {
         return false;
     }
     self::$instance = new MC4WP_Lite();
     return true;
 }
 public function get_mc_api()
 {
     if (!isset(self::$mc_api)) {
         // Only load MailChimp API if it has not been loaded yet
         // other plugins may have already at this point.
         if (!class_exists("MCAPI")) {
             require_once 'class-MCAPI.php';
         }
         self::$mc_api = new MCAPI($this->options['mailchimp_api_key']);
     }
     return self::$mc_api;
 }
示例#5
0
/**
* Loads the MailChimp for WP plugin files
*
* @return boolean True if the plugin files were loaded, false otherwise.
*/
function mc4wp_load_plugin()
{
    // don't load plugin if user has the premium version installed and activated
    if (defined('MC4WP_VERSION')) {
        return false;
    }
    // bootstrap the lite plugin
    define('MC4WP_LITE_VERSION', '2.2.9');
    define('MC4WP_LITE_PLUGIN_DIR', plugin_dir_path(__FILE__));
    define('MC4WP_LITE_PLUGIN_URL', plugins_url('/', __FILE__));
    define('MC4WP_LITE_PLUGIN_FILE', __FILE__);
    require_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions/general.php';
    require_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions/template.php';
    require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-plugin.php';
    // Initialize the plugin and store an instance in the global scope
    MC4WP_Lite::init();
    $GLOBALS['mc4wp'] = MC4WP_Lite::instance();
    if (is_admin() && (false === defined('DOING_AJAX') || false === DOING_AJAX)) {
        // ADMIN
        require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-admin.php';
        new MC4WP_Lite_Admin();
    }
    return true;
}
 public function subscribe_from_whatever()
 {
     if (!isset($_POST['mc4wp-do-subscribe']) || !$_POST['mc4wp-do-subscribe']) {
         return false;
     }
     // check if not coming from a comment form, registration form, buddypress form or multisite form.
     $script_filename = basename($_SERVER["SCRIPT_FILENAME"]);
     if (in_array($script_filename, array('wp-comments-post.php', 'wp-login.php', 'wp-signup.php'))) {
         return false;
     }
     if (isset($_POST['signup_submit'])) {
         return false;
     }
     // start running..
     $opts = $this->options;
     $mc4wp = MC4WP_Lite::get_instance();
     $email = $name = null;
     // Smart field guessing
     $possibilities = array('email', 'your-email', 'e-mail', 'emailaddress', 'user_email', 'signup_email', 'emailadres', 'your_email');
     foreach ($possibilities as $key) {
         if (isset($_POST[$key]) && !empty($_POST[$key])) {
             $email = $_POST[$key];
             break;
         }
     }
     $possibilities = array('name', 'your-name', 'username', 'fname', 'user_login', 'lname', 'first_name', 'last_name', 'firstname', 'lastname', 'fullname', 'naam');
     foreach ($possibilities as $key) {
         if (isset($_POST[$key]) && !empty($_POST[$key])) {
             $name = $_POST[$key];
             break;
         }
     }
     // if email has not been found by the smart field guessing, return false.. sorry
     if (!$email) {
         if (current_user_can('manage_options')) {
             die("\n\t\t\t\t\t<h3>MailChimp for WP error</h3>\n\t\t\t\t\t<p>MailChimp for WP detected a subscribe attempt but had some trouble determining the email value. Make sure the other form contains an e-mail field with\n\t\t\t\t\t one of the following name attributes: 'email', 'e-mail', 'emailaddress', 'user_email', 'signup_email' or 'emailadres'.</p>\n\t\t\t\t");
         }
         return false;
     }
     // subscribe
     $result = $mc4wp->subscribe('checkbox', $email, array(), array('name' => $name));
     // do something with the result... later
     return true;
 }
 private function get_mailchimp_api()
 {
     return MC4WP_Lite::get_instance()->get_mc_api();
 }
/**
* Gets the MailChimp for WP API class and injects it with the given API key
* @since 1.0
* @return MC4WP_API
*/
function mc4wp_get_api()
{
    return MC4WP_Lite::instance()->get_api();
}
Description: Complete MailChimp integration for WordPress. Sign-up forms, widgets, comment checkboxes, etc..
Version: 0.8.2
Author: Danny van Kooten
Author URI: http://dannyvanKooten.com
License: GPL v3

MailChimp for WordPress
Copyright (C) 2012-2013, Danny van Kooten, hi@dannyvankooten.com

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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
// frontend AND backend
require_once 'includes/class-mc4wp-lite.php';
require_once 'includes/functions.php';
$MC4WP = MC4WP_Lite::get_instance();
if (is_admin()) {
    // frontend only
    require_once 'includes/class-mc4wp-lite-admin.php';
    $MC4WP_Admin = new MC4WP_Lite_Admin($MC4WP);
}
示例#10
0
/**
* Returns HTML for sign-up form with the given $form_id.
*
* @param    int     $form_id.
* @return   string  HTML of given form_id.
*/
function mc4wp_get_form($id = 0)
{
    $form_manager = MC4WP_Lite::instance()->get_form_manager();
    return $form_manager->output_form(array('id' => $id));
}
 private function get_admin_notice($error)
 {
     $api = MC4WP_Lite::get_instance()->get_mc_api();
     $notices = array();
     $notices['merge_field_error'] = 'There seems to be a problem with your merge fields. Make sure all required merge fields are present in your sign-up form.';
     $notices['no_lists_selected'] = 'No lists have been selected. <a href="' . get_admin_url(null, "admin.php?page=mailchimp-for-wp&tab=form-settings") . '">Edit your form settings</a> and select at least one list.';
     $notice = '<br /><br /><strong>Admins only: </strong>';
     if (isset($notices[$error])) {
         $has_notice = true;
         $notice .= $notices[$error];
     }
     if ($api->errorMessage && !empty($api->errorMessage)) {
         $has_notice = true;
         $notice .= '<br /><br />MailChimp returned the following error message: ' . $api->errorMessage;
     }
     return $has_notice ? $notice : '';
 }