function mc4wp_show_checkbox() { $mc4wp = MC4WP_Lite::get_instance(); if ($mc4wp->checkbox) { $mc4wp->checkbox->output_checkbox(); } }
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(); }
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); }
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 : ''; }