Version Description
WP 3.8 compatibility, better scroll to form and huge settings page performance improvement
Download this release
Release Info
Developer | DvanKooten |
Plugin | MailChimp for WordPress |
Version | 1.4.8 |
Comparing to | |
See all releases |
Code changes from version 1.4.7 to 1.4.8
- assets/css/admin.css +47 -20
- assets/css/checkbox.css +3 -2
- assets/css/css.php +6 -5
- assets/css/form.css +23 -0
- assets/css/index.php +4 -1
- assets/img/index.php +4 -1
- assets/index.php +4 -1
- assets/js/admin.js +6 -1
- assets/js/index.php +4 -1
- includes/MC4WP_Lite.php +0 -218
- includes/{MC4WP_Lite_Admin.php → class-admin.php} +31 -12
- includes/{MC4WP_Lite_API.php → class-api.php} +0 -0
- includes/{MC4WP_Lite_Checkbox.php → class-checkbox.php} +18 -11
- includes/{MC4WP_Lite_Form.php → class-form.php} +56 -35
- includes/class-plugin.php +131 -0
- includes/{MC4WP_Lite_Widget.php → class-widget.php} +0 -0
- includes/functions.php +71 -0
- includes/index.php +4 -1
- includes/template-functions.php +3 -3
- includes/views/api-settings.php +5 -4
- includes/views/checkbox-settings.php +5 -5
- includes/views/form-settings.php +52 -54
- includes/views/index.php +4 -1
- includes/views/parts/admin-field-wizard.php +5 -1
- includes/views/parts/admin-footer.php +3 -3
- includes/views/parts/admin-need-support.php +4 -4
- includes/views/parts/index.php +4 -1
- index.php +4 -1
- mailchimp-for-wp.php +27 -11
- readme.txt +13 -2
- uninstall.php +4 -2
assets/css/admin.css
CHANGED
@@ -1,9 +1,19 @@
|
|
1 |
-
#mc4wp-content{ float:left; width:65%;
|
2 |
-
#mc4wp-sidebar{
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
#mc4wp-upgrade-box { background:#222; color:#ddd; padding:20px; }
|
6 |
-
#mc4wp-upgrade-box h3{ margin:0; }
|
7 |
|
8 |
#mc4wp-fw h4{ margin-top:0; }
|
9 |
#mc4wp-fw p{ margin-bottom: 1em; }
|
@@ -12,37 +22,54 @@
|
|
12 |
#mc4wp-lists{ margin:0; }
|
13 |
#mc4wp-lists input{ margin-right:5px; }
|
14 |
|
15 |
-
|
16 |
.pro-feature, .mc4wp-settings tr.pro-feature th, .mc4wp-settings tr.pro-feature td{ color:#aaa; }
|
17 |
|
18 |
-
.mc4wp-settings h3{ margin-top:2em;}
|
19 |
.mc4wp-settings span.status{ display:inline-block; padding:3px 6px; color:white; font-size:12px; font-weight:bold; }
|
20 |
.mc4wp-settings span.positive{ background-color:green; }
|
21 |
.mc4wp-settings span.negative{ background-color:lightGrey; }
|
22 |
.mc4wp-settings table th{ text-align:left; }
|
23 |
.mc4wp-settings table.form-table tr td:first-child, .mc4wp-settings table.form-table tr th:first-child{ padding-left:0; }
|
24 |
-
.mc4wp-settings p.copyright-notice{ font-style:italic; }
|
25 |
.mc4wp-settings td.nowrap{ white-space: nowrap }
|
26 |
.mc4wp-settings td.desc{ font-style:italic; font-size:11px; }
|
27 |
|
28 |
-
.mc4wp-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
border:1px solid #ccc;
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
.mc4wp-title{ font-size: 1.25em; margin-bottom: 1em; }
|
40 |
|
41 |
table.mc4wp-help, table.mc4wp-help th, table.mc4wp-help td { border: 1px solid #ddd; border-collapse: collapse; font-size: 12px; }
|
42 |
table.mc4wp-help th, table.mc4wp-help td { vertical-align: text-top; text-align: left; padding: 5px 10px; }
|
43 |
table.mc4wp-help tr:hover { background-color: #ddd; }
|
44 |
|
45 |
-
@media(max-width:
|
46 |
-
#mc4wp-sidebar, #mc4wp-content{ float: none; width: 100%; }
|
47 |
-
#mc4wp-sidebar{
|
48 |
}
|
1 |
+
#mc4wp-content{ float:left; width:65%; }
|
2 |
+
#mc4wp-sidebar{
|
3 |
+
float:left;
|
4 |
+
width:33%;
|
5 |
+
margin-left:2%;
|
6 |
+
border-left:1px solid #ccc;
|
7 |
+
padding:0 0 0 2%;
|
8 |
+
box-sizing: border-box;
|
9 |
+
}
|
10 |
+
|
11 |
+
.valigntop{ vertical-align: top !important; }
|
12 |
+
|
13 |
+
.mc4wp-box{ margin-bottom:20px; }
|
14 |
|
15 |
#mc4wp-upgrade-box { background:#222; color:#ddd; padding:20px; }
|
16 |
+
#mc4wp-upgrade-box h3{ margin:0; color:white; }
|
17 |
|
18 |
#mc4wp-fw h4{ margin-top:0; }
|
19 |
#mc4wp-fw p{ margin-bottom: 1em; }
|
22 |
#mc4wp-lists{ margin:0; }
|
23 |
#mc4wp-lists input{ margin-right:5px; }
|
24 |
|
|
|
25 |
.pro-feature, .mc4wp-settings tr.pro-feature th, .mc4wp-settings tr.pro-feature td{ color:#aaa; }
|
26 |
|
|
|
27 |
.mc4wp-settings span.status{ display:inline-block; padding:3px 6px; color:white; font-size:12px; font-weight:bold; }
|
28 |
.mc4wp-settings span.positive{ background-color:green; }
|
29 |
.mc4wp-settings span.negative{ background-color:lightGrey; }
|
30 |
.mc4wp-settings table th{ text-align:left; }
|
31 |
.mc4wp-settings table.form-table tr td:first-child, .mc4wp-settings table.form-table tr th:first-child{ padding-left:0; }
|
|
|
32 |
.mc4wp-settings td.nowrap{ white-space: nowrap }
|
33 |
.mc4wp-settings td.desc{ font-style:italic; font-size:11px; }
|
34 |
|
35 |
+
.mc4wp-notice{
|
36 |
+
padding:5px;
|
37 |
+
color: #31708f;
|
38 |
+
background-color: #d9edf7;
|
39 |
+
border:1px solid #bce8f1;
|
40 |
+
}
|
41 |
+
|
42 |
+
.mc4wp-col {
|
43 |
+
float:left;
|
44 |
+
-webkit-box-sizing: border-box;
|
45 |
+
box-sizing: border-box;
|
46 |
+
-moz-box-sizing:border-box;
|
47 |
+
width:50%;
|
48 |
+
padding:0 5px;
|
49 |
+
}
|
50 |
+
|
51 |
+
.mc4wp-first{ padding-left:0; }
|
52 |
+
.mc4wp-last{ padding-right:0; }
|
53 |
+
|
54 |
+
.mc4wp-well{
|
55 |
+
background:white;
|
56 |
+
padding:10px;
|
57 |
border:1px solid #ccc;
|
58 |
+
}
|
59 |
+
|
60 |
+
.mc4wp-title{
|
61 |
+
font-size: 1.4em;
|
62 |
+
margin:1.6em 0 1em;
|
63 |
+
padding:0 0 6px 0;
|
64 |
+
border-bottom:1px solid #ddd;
|
65 |
+
}
|
66 |
|
|
|
67 |
|
68 |
table.mc4wp-help, table.mc4wp-help th, table.mc4wp-help td { border: 1px solid #ddd; border-collapse: collapse; font-size: 12px; }
|
69 |
table.mc4wp-help th, table.mc4wp-help td { vertical-align: text-top; text-align: left; padding: 5px 10px; }
|
70 |
table.mc4wp-help tr:hover { background-color: #ddd; }
|
71 |
|
72 |
+
@media(max-width: 1279px) {
|
73 |
+
#mc4wp-sidebar, #mc4wp-content{ float: none; width: 100%; padding:0; margin:0; }
|
74 |
+
#mc4wp-sidebar{ border-left:0; border-top: 1px solid #ccc; margin-top:25px; padding-top: 25px; }
|
75 |
}
|
assets/css/checkbox.css
CHANGED
@@ -10,12 +10,13 @@
|
|
10 |
padding:0;
|
11 |
vertical-align: middle;
|
12 |
display:inline-block !important;
|
13 |
-
-
|
14 |
-
width: auto;
|
15 |
}
|
16 |
|
17 |
#mc4wp-checkbox label{
|
|
|
18 |
cursor:pointer;
|
|
|
19 |
}
|
20 |
|
21 |
#registerform #mc4wp-checkbox{
|
10 |
padding:0;
|
11 |
vertical-align: middle;
|
12 |
display:inline-block !important;
|
13 |
+
max-width: 20px;
|
|
|
14 |
}
|
15 |
|
16 |
#mc4wp-checkbox label{
|
17 |
+
display:block;
|
18 |
cursor:pointer;
|
19 |
+
width: auto;
|
20 |
}
|
21 |
|
22 |
#registerform #mc4wp-checkbox{
|
assets/css/css.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
// Set headers to serve CSS and encourage browser caching
|
3 |
-
$expires =
|
4 |
header('Content-Type: text/css; charset: UTF-8');
|
5 |
header("Cache-Control: public, max-age=" . $expires);
|
6 |
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
|
@@ -16,13 +16,14 @@ if(isset($_GET['form'])) {
|
|
16 |
|
17 |
// should we load a form theme?
|
18 |
if(isset($_GET['form-theme'])) {
|
19 |
-
$form_theme = $_GET['form-theme'];
|
20 |
-
|
21 |
-
// load theme base file
|
22 |
-
readfile(dirname(__FILE__) . '/form-theme-base.css');
|
23 |
|
24 |
// only load themes we actually have
|
25 |
if(in_array($form_theme, array('blue', 'green', 'dark', 'light', 'red'))) {
|
|
|
|
|
|
|
|
|
26 |
readfile(dirname(__FILE__) . '/form-theme-'. $form_theme .'.css');
|
27 |
}
|
28 |
|
1 |
<?php
|
2 |
// Set headers to serve CSS and encourage browser caching
|
3 |
+
$expires = 31536000; // cache time: 1 year
|
4 |
header('Content-Type: text/css; charset: UTF-8');
|
5 |
header("Cache-Control: public, max-age=" . $expires);
|
6 |
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
|
16 |
|
17 |
// should we load a form theme?
|
18 |
if(isset($_GET['form-theme'])) {
|
19 |
+
$form_theme = strtolower( trim( $_GET['form-theme'] ) );
|
|
|
|
|
|
|
20 |
|
21 |
// only load themes we actually have
|
22 |
if(in_array($form_theme, array('blue', 'green', 'dark', 'light', 'red'))) {
|
23 |
+
// load theme base file
|
24 |
+
readfile(dirname(__FILE__) . '/form-theme-base.css');
|
25 |
+
|
26 |
+
// load theme file
|
27 |
readfile(dirname(__FILE__) . '/form-theme-'. $form_theme .'.css');
|
28 |
}
|
29 |
|
assets/css/form.css
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
/* MailChimp for WP - Default Form Styles */
|
3 |
+
.mc4wp-form{ margin:1em 0; }
|
4 |
+
.mc4wp-form p{ text-align:left; }
|
5 |
+
.mc4wp-form label{ display:block; font-weight:bold; margin-bottom:3px; text-align:left; }
|
6 |
+
.mc4wp-form label > span, .mc4wp-form li > label{ font-weight: normal; }
|
7 |
+
|
8 |
+
.mc4wp-form input[type="text"],
|
9 |
+
.mc4wp-form input[type="email"],
|
10 |
+
.mc4wp-form input[type="tel"],
|
11 |
+
.mc4wp-form input[type="url"] { display:inline-block; width:100%; height:auto; box-sizing:border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; }
|
12 |
+
|
13 |
+
.mc4wp-form input[type="checkbox"] { margin:0 10px 0 0; padding:0; height:13px; width:13px;
|
14 |
+
display:inline-block; -webkit-appearance: checkbox; border:0; }
|
15 |
+
.mc4wp-form input[type="radio"] { margin:0 10px 0 0; padding:0; height:13px; width:13px;
|
16 |
+
display:inline-block; -webkit-appearance: radio; border:0; }
|
17 |
+
.mc4wp-form select, .mc4wp-form input[type="date"] { min-width:35%; }
|
18 |
+
.mc4wp-form input[type="submit"], .mc4wp-form button{ display:inline-block; }
|
19 |
+
|
20 |
+
.mc4wp-alert{ margin:1em 0; padding: 10px 15px; color: #c09853; background-color: #fcf8e3; border: 1px solid #fbeed5; border-radius: 2px; -moz-border-radius:2px; -webkit-border-radius:2px; display:block; position:relative;}
|
21 |
+
.mc4wp-success { color: #468847; background-color: #dff0d8; border-color: #d6e9c6; }
|
22 |
+
.mc4wp-notice { color: #3a87ad; background-color: #d9edf7; border-color: #bce8f1; }
|
23 |
+
.mc4wp-error { color: #b94a48; background-color: #f2dede; border-color: #eed3d7;; }
|
assets/css/index.php
CHANGED
@@ -1,3 +1,6 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
|
|
|
|
1 |
<?php
|
2 |
+
// prevent directory listing
|
3 |
|
4 |
+
header('HTTP/1.0 403 Forbidden');
|
5 |
+
header("X-Robots-Tag: noindex");
|
6 |
+
exit;
|
assets/img/index.php
CHANGED
@@ -1,3 +1,6 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
|
|
|
|
1 |
<?php
|
2 |
+
// prevent directory listing
|
3 |
|
4 |
+
header('HTTP/1.0 403 Forbidden');
|
5 |
+
header("X-Robots-Tag: noindex");
|
6 |
+
exit;
|
assets/index.php
CHANGED
@@ -1,3 +1,6 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
|
|
|
|
1 |
<?php
|
2 |
+
// prevent directory listing
|
3 |
|
4 |
+
header('HTTP/1.0 403 Forbidden');
|
5 |
+
header("X-Robots-Tag: noindex");
|
6 |
+
exit;
|
assets/js/admin.js
CHANGED
@@ -48,11 +48,16 @@
|
|
48 |
// set the fields the user can choose from
|
49 |
function setFields()
|
50 |
{
|
|
|
|
|
|
|
|
|
|
|
51 |
// empty field select
|
52 |
$mailchimpFields.find('option').not('.default').remove();
|
53 |
|
54 |
// loop through checked lists
|
55 |
-
$
|
56 |
var fields = $(this).data('fields');
|
57 |
var groupings = $(this).data('groupings');
|
58 |
|
48 |
// set the fields the user can choose from
|
49 |
function setFields()
|
50 |
{
|
51 |
+
// show notice if no lists selecteed
|
52 |
+
var $selectedLists = $lists.filter(':checked');
|
53 |
+
$(".no-lists-selected").toggle(($selectedLists.length == 0));
|
54 |
+
|
55 |
+
|
56 |
// empty field select
|
57 |
$mailchimpFields.find('option').not('.default').remove();
|
58 |
|
59 |
// loop through checked lists
|
60 |
+
$selectedLists.each(function() {
|
61 |
var fields = $(this).data('fields');
|
62 |
var groupings = $(this).data('groupings');
|
63 |
|
assets/js/index.php
CHANGED
@@ -1,3 +1,6 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
|
|
|
|
1 |
<?php
|
2 |
+
// prevent directory listing
|
3 |
|
4 |
+
header('HTTP/1.0 403 Forbidden');
|
5 |
+
header("X-Robots-Tag: noindex");
|
6 |
+
exit;
|
includes/MC4WP_Lite.php
DELETED
@@ -1,218 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class MC4WP_Lite {
|
4 |
-
private $options = array();
|
5 |
-
private static $instance, $checkbox = null, $form = null, $api = null, $admin = null;
|
6 |
-
|
7 |
-
public static function instance() {
|
8 |
-
return self::$instance;
|
9 |
-
}
|
10 |
-
|
11 |
-
public static function checkbox() {
|
12 |
-
if ( !self::$checkbox ) {
|
13 |
-
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/MC4WP_Lite_Checkbox.php';
|
14 |
-
self::$checkbox = new MC4WP_Lite_Checkbox();
|
15 |
-
}
|
16 |
-
return self::$checkbox;
|
17 |
-
}
|
18 |
-
|
19 |
-
public static function form() {
|
20 |
-
if ( !self::$form ) {
|
21 |
-
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/MC4WP_Lite_Form.php';
|
22 |
-
self::$form = new MC4WP_Lite_Form();
|
23 |
-
}
|
24 |
-
return self::$form;
|
25 |
-
}
|
26 |
-
|
27 |
-
public static function api() {
|
28 |
-
if ( !self::$api ) {
|
29 |
-
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/MC4WP_Lite_API.php';
|
30 |
-
$opts = self::instance()->get_options();
|
31 |
-
self::$api = new MC4WP_Lite_API( $opts['general']['api_key'] );
|
32 |
-
}
|
33 |
-
return self::$api;
|
34 |
-
}
|
35 |
-
|
36 |
-
public static function admin() {
|
37 |
-
if ( !self::$admin ) {
|
38 |
-
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/MC4WP_Lite_Admin.php';
|
39 |
-
self::$admin = new MC4WP_Lite_Admin();
|
40 |
-
}
|
41 |
-
return self::$admin;
|
42 |
-
}
|
43 |
-
|
44 |
-
public function __construct() {
|
45 |
-
self::$instance = $this;
|
46 |
-
|
47 |
-
$this->backwards_compatibility();
|
48 |
-
$opts = $this->get_options();
|
49 |
-
|
50 |
-
// checkbox
|
51 |
-
self::checkbox();
|
52 |
-
|
53 |
-
// form
|
54 |
-
self::form();
|
55 |
-
|
56 |
-
// widget
|
57 |
-
add_action( 'widgets_init', array($this, 'register_widget') );
|
58 |
-
|
59 |
-
if ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) {
|
60 |
-
if ( is_admin() ) {
|
61 |
-
// backend only
|
62 |
-
self::admin();
|
63 |
-
} else {
|
64 |
-
// frontend only
|
65 |
-
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/template-functions.php';
|
66 |
-
|
67 |
-
// load css
|
68 |
-
add_action( 'wp_enqueue_scripts', array($this, 'load_stylesheets'), 90);
|
69 |
-
add_action( 'login_enqueue_scripts', array($this, 'load_stylesheets') );
|
70 |
-
}
|
71 |
-
}
|
72 |
-
}
|
73 |
-
|
74 |
-
private function get_default_options() {
|
75 |
-
return array(
|
76 |
-
'general' => array(
|
77 |
-
'api_key' => ''
|
78 |
-
),
|
79 |
-
'checkbox' => array(
|
80 |
-
'label' => 'Sign me up for the newsletter!',
|
81 |
-
'precheck' => 1,
|
82 |
-
'css' => 1,
|
83 |
-
'show_at_comment_form' => 0,
|
84 |
-
'show_at_registration_form' => 0,
|
85 |
-
'show_at_multisite_form' => 0,
|
86 |
-
'show_at_buddypress_form' => 0,
|
87 |
-
'show_at_bbpress_forms' => 0,
|
88 |
-
'lists' => array(),
|
89 |
-
'double_optin' => 1
|
90 |
-
),
|
91 |
-
'form' => array(
|
92 |
-
'css' => 'default',
|
93 |
-
'markup' => "<p>\n\t<label for=\"mc4wp_email\">Email address: </label>\n\t<input type=\"email\" id=\"mc4wp_email\" name=\"EMAIL\" required placeholder=\"Your email address\" />\n</p>\n\n<p>\n\t<input type=\"submit\" value=\"Sign up\" />\n</p>",
|
94 |
-
'text_success' => 'Thank you, your sign-up request was successful! Please check your e-mail inbox.',
|
95 |
-
'text_error' => 'Oops. Something went wrong. Please try again later.',
|
96 |
-
'text_invalid_email' => 'Please provide a valid email address.',
|
97 |
-
'text_already_subscribed' => "Given email address is already subscribed, thank you!",
|
98 |
-
'redirect' => '',
|
99 |
-
'lists' => array(),
|
100 |
-
'double_optin' => 1,
|
101 |
-
'hide_after_success' => 0
|
102 |
-
)
|
103 |
-
);
|
104 |
-
}
|
105 |
-
|
106 |
-
public function get_options() {
|
107 |
-
if ( empty( $this->options ) ) {
|
108 |
-
|
109 |
-
$defaults = $this->get_default_options();
|
110 |
-
$db_keys_option_keys = array(
|
111 |
-
'mc4wp_lite' => 'general',
|
112 |
-
'mc4wp_lite_checkbox' => 'checkbox',
|
113 |
-
'mc4wp_lite_form' => 'form'
|
114 |
-
);
|
115 |
-
|
116 |
-
foreach ( $db_keys_option_keys as $db_key => $option_key ) {
|
117 |
-
$option = get_option( $db_key );
|
118 |
-
|
119 |
-
// add option to database to prevent query on every pageload
|
120 |
-
if ( $option == false ) { add_option( $db_key, $defaults[$option_key] ); }
|
121 |
-
|
122 |
-
$this->options[$option_key] = array_merge( $defaults[$option_key], (array) $option );
|
123 |
-
}
|
124 |
-
}
|
125 |
-
|
126 |
-
return $this->options;
|
127 |
-
}
|
128 |
-
|
129 |
-
private function backwards_compatibility() {
|
130 |
-
$options = get_option( 'mc4wp_lite' );
|
131 |
-
|
132 |
-
// transfer widget to new id?
|
133 |
-
if(get_option('mc4wp_transfered_old_widgets', false) == false) {
|
134 |
-
$sidebars_widgets = get_option('sidebars_widgets');
|
135 |
-
|
136 |
-
if($sidebars_widgets && is_array($sidebars_widgets)) {
|
137 |
-
foreach($sidebars_widgets as $key => $widgets)
|
138 |
-
{
|
139 |
-
if(!is_array($widgets)) { continue; }
|
140 |
-
foreach($widgets as $subkey => $widget_name) {
|
141 |
-
|
142 |
-
if(substr($widget_name, 0, 17) == 'mc4wp_lite_widget') {
|
143 |
-
|
144 |
-
$new_widget_name = str_replace('mc4wp_lite_widget', 'mc4wp_widget', $widget_name);
|
145 |
-
// active widget found, just change name?
|
146 |
-
$sidebars_widgets[$key][$subkey] = $new_widget_name;
|
147 |
-
update_option('sidebars_widgets', $sidebars_widgets);
|
148 |
-
update_option('widget_mc4wp_widget', get_option('widget_mc4wp_lite_widget') );
|
149 |
-
break;
|
150 |
-
}
|
151 |
-
}
|
152 |
-
}
|
153 |
-
}
|
154 |
-
|
155 |
-
update_option('mc4wp_transfered_old_widgets', true);
|
156 |
-
}
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
// transfer old options to new options format
|
162 |
-
if (isset( $options['mailchimp_api_key'] )) {
|
163 |
-
|
164 |
-
$new_options = array(
|
165 |
-
'general' => array(),
|
166 |
-
'checkbox' => array(),
|
167 |
-
'form' => array()
|
168 |
-
);
|
169 |
-
|
170 |
-
$new_options['general']['api_key'] = $options['mailchimp_api_key'];
|
171 |
-
|
172 |
-
foreach ( $options as $key => $value ) {
|
173 |
-
$_pos = strpos( $key, '_' );
|
174 |
-
|
175 |
-
$first_key = substr( $key, 0, $_pos );
|
176 |
-
$second_key = substr( $key, $_pos + 1 );
|
177 |
-
|
178 |
-
if ( isset( $new_options[$first_key] ) ) {
|
179 |
-
|
180 |
-
// change option name
|
181 |
-
if ( $second_key == 'show_at_bp_form' ) {
|
182 |
-
$second_key = 'show_at_buddypress_form';
|
183 |
-
}
|
184 |
-
|
185 |
-
// change option name
|
186 |
-
if ( $second_key == 'show_at_ms_form' ) {
|
187 |
-
$second_key = 'show_at_multisite_form';
|
188 |
-
}
|
189 |
-
|
190 |
-
// set value into new option name
|
191 |
-
$new_options[$first_key][$second_key] = $value;
|
192 |
-
}
|
193 |
-
|
194 |
-
}
|
195 |
-
|
196 |
-
update_option( 'mc4wp_lite', $new_options['general'] );
|
197 |
-
update_option( 'mc4wp_lite_checkbox', $new_options['checkbox'] );
|
198 |
-
update_option( 'mc4wp_lite_form', $new_options['form'] );
|
199 |
-
} // end transfer options
|
200 |
-
}
|
201 |
-
|
202 |
-
public function register_widget()
|
203 |
-
{
|
204 |
-
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/MC4WP_Lite_Widget.php';
|
205 |
-
register_widget( 'MC4WP_Lite_Widget' );
|
206 |
-
}
|
207 |
-
|
208 |
-
public function load_stylesheets()
|
209 |
-
{
|
210 |
-
$stylesheets = apply_filters('mc4wp_stylesheets', array());
|
211 |
-
|
212 |
-
if(!empty($stylesheets)) {
|
213 |
-
$stylesheet_url = add_query_arg($stylesheets, plugins_url('mailchimp-for-wp/assets/css/css.php'));
|
214 |
-
wp_enqueue_style( 'mailchimp-for-wp', $stylesheet_url, array(), MC4WP_LITE_VERSION);
|
215 |
-
}
|
216 |
-
}
|
217 |
-
|
218 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/{MC4WP_Lite_Admin.php → class-admin.php}
RENAMED
@@ -2,12 +2,18 @@
|
|
2 |
|
3 |
class MC4WP_Lite_Admin
|
4 |
{
|
5 |
-
private $
|
6 |
|
7 |
-
public function
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
10 |
|
|
|
|
|
11 |
add_action('admin_init', array($this, 'register_settings'));
|
12 |
add_action('admin_menu', array($this, 'build_menu'));
|
13 |
add_action( 'admin_enqueue_scripts', array($this, 'load_css_and_js') );
|
@@ -56,7 +62,7 @@ class MC4WP_Lite_Admin
|
|
56 |
|
57 |
public function register_settings()
|
58 |
{
|
59 |
-
register_setting('mc4wp_lite_settings', 'mc4wp_lite');
|
60 |
register_setting('mc4wp_lite_checkbox_settings', 'mc4wp_lite_checkbox');
|
61 |
register_setting('mc4wp_lite_form_settings', 'mc4wp_lite_form');
|
62 |
}
|
@@ -68,7 +74,15 @@ class MC4WP_Lite_Admin
|
|
68 |
add_submenu_page('mc4wp-lite', 'Checkbox Settings - MailChimp for WP Lite', 'Checkboxes', 'manage_options', 'mc4wp-lite-checkbox-settings', array($this, 'show_checkbox_settings'));
|
69 |
add_submenu_page('mc4wp-lite', 'Form Settings - MailChimp for WP Lite', 'Forms', 'manage_options', 'mc4wp-lite-form-settings', array($this, 'show_form_settings'));
|
70 |
add_submenu_page('mc4wp-lite', 'Upgrade to Pro - MailChimp for WP Lite', 'Upgrade to Pro', 'manage_options', 'mc4wp-lite-upgrade', array($this, 'redirect_to_pro'));
|
|
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
}
|
73 |
|
74 |
public function load_css_and_js($hook)
|
@@ -107,13 +121,13 @@ class MC4WP_Lite_Admin
|
|
107 |
|
108 |
public function show_api_settings()
|
109 |
{
|
110 |
-
$opts =
|
111 |
$tab = 'api-settings';
|
112 |
|
113 |
if(empty($opts['api_key'])) {
|
114 |
$connected = false;
|
115 |
} else {
|
116 |
-
$connected = (
|
117 |
}
|
118 |
|
119 |
$lists = $this->get_mailchimp_lists();
|
@@ -122,7 +136,7 @@ class MC4WP_Lite_Admin
|
|
122 |
|
123 |
public function show_checkbox_settings()
|
124 |
{
|
125 |
-
$opts =
|
126 |
$lists = $this->get_mailchimp_lists();
|
127 |
$tab = 'checkbox-settings';
|
128 |
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/views/checkbox-settings.php';
|
@@ -130,7 +144,7 @@ class MC4WP_Lite_Admin
|
|
130 |
|
131 |
public function show_form_settings()
|
132 |
{
|
133 |
-
$opts =
|
134 |
$lists = $this->get_mailchimp_lists();
|
135 |
$tab = 'form-settings';
|
136 |
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/views/form-settings.php';
|
@@ -146,13 +160,18 @@ class MC4WP_Lite_Admin
|
|
146 |
$refresh_cache = (isset($_REQUEST['renew-cached-data']));
|
147 |
|
148 |
// force cache refresh if merge_vars are not set
|
149 |
-
if(
|
150 |
-
$
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
152 |
|
153 |
if($refresh_cache || !$cached_lists) {
|
154 |
// make api request for lists
|
155 |
-
$api =
|
156 |
$lists = array();
|
157 |
$lists_data = $api->get_lists();
|
158 |
|
2 |
|
3 |
class MC4WP_Lite_Admin
|
4 |
{
|
5 |
+
private static $instance = null;
|
6 |
|
7 |
+
public static function init() {
|
8 |
+
if(!self::$instance) {
|
9 |
+
self::$instance = new self();
|
10 |
+
} else {
|
11 |
+
throw new Exception("Already initalized.");
|
12 |
+
}
|
13 |
+
}
|
14 |
|
15 |
+
private function __construct()
|
16 |
+
{
|
17 |
add_action('admin_init', array($this, 'register_settings'));
|
18 |
add_action('admin_menu', array($this, 'build_menu'));
|
19 |
add_action( 'admin_enqueue_scripts', array($this, 'load_css_and_js') );
|
62 |
|
63 |
public function register_settings()
|
64 |
{
|
65 |
+
register_setting('mc4wp_lite_settings', 'mc4wp_lite', array($this, 'validate_settings') );
|
66 |
register_setting('mc4wp_lite_checkbox_settings', 'mc4wp_lite_checkbox');
|
67 |
register_setting('mc4wp_lite_form_settings', 'mc4wp_lite_form');
|
68 |
}
|
74 |
add_submenu_page('mc4wp-lite', 'Checkbox Settings - MailChimp for WP Lite', 'Checkboxes', 'manage_options', 'mc4wp-lite-checkbox-settings', array($this, 'show_checkbox_settings'));
|
75 |
add_submenu_page('mc4wp-lite', 'Form Settings - MailChimp for WP Lite', 'Forms', 'manage_options', 'mc4wp-lite-form-settings', array($this, 'show_form_settings'));
|
76 |
add_submenu_page('mc4wp-lite', 'Upgrade to Pro - MailChimp for WP Lite', 'Upgrade to Pro', 'manage_options', 'mc4wp-lite-upgrade', array($this, 'redirect_to_pro'));
|
77 |
+
}
|
78 |
|
79 |
+
public function validate_settings( $settings ) {
|
80 |
+
|
81 |
+
if( isset( $settings['api_key'] ) ) {
|
82 |
+
$settings['api_key'] = trim( $settings['api_key'] );
|
83 |
+
}
|
84 |
+
|
85 |
+
return $settings;
|
86 |
}
|
87 |
|
88 |
public function load_css_and_js($hook)
|
121 |
|
122 |
public function show_api_settings()
|
123 |
{
|
124 |
+
$opts = mc4wp_get_options('general');
|
125 |
$tab = 'api-settings';
|
126 |
|
127 |
if(empty($opts['api_key'])) {
|
128 |
$connected = false;
|
129 |
} else {
|
130 |
+
$connected = (mc4wp_get_api()->is_connected());
|
131 |
}
|
132 |
|
133 |
$lists = $this->get_mailchimp_lists();
|
136 |
|
137 |
public function show_checkbox_settings()
|
138 |
{
|
139 |
+
$opts = mc4wp_get_options('checkbox');
|
140 |
$lists = $this->get_mailchimp_lists();
|
141 |
$tab = 'checkbox-settings';
|
142 |
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/views/checkbox-settings.php';
|
144 |
|
145 |
public function show_form_settings()
|
146 |
{
|
147 |
+
$opts = mc4wp_get_options('form');
|
148 |
$lists = $this->get_mailchimp_lists();
|
149 |
$tab = 'form-settings';
|
150 |
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/views/form-settings.php';
|
160 |
$refresh_cache = (isset($_REQUEST['renew-cached-data']));
|
161 |
|
162 |
// force cache refresh if merge_vars are not set
|
163 |
+
if(!$refresh_cache && $cached_lists) {
|
164 |
+
if(!is_array($cached_lists)) {
|
165 |
+
$refresh_cache = true;
|
166 |
+
} else {
|
167 |
+
$first_list = reset($cached_lists);
|
168 |
+
$refresh_cache = !isset($first_list->merge_vars);
|
169 |
+
}
|
170 |
}
|
171 |
|
172 |
if($refresh_cache || !$cached_lists) {
|
173 |
// make api request for lists
|
174 |
+
$api = mc4wp_get_api();
|
175 |
$lists = array();
|
176 |
$lists_data = $api->get_lists();
|
177 |
|
includes/{MC4WP_Lite_API.php → class-api.php}
RENAMED
File without changes
|
includes/{MC4WP_Lite_Checkbox.php → class-checkbox.php}
RENAMED
@@ -3,10 +3,23 @@
|
|
3 |
class MC4WP_Lite_Checkbox
|
4 |
{
|
5 |
private $showed_checkbox = false;
|
|
|
6 |
|
7 |
-
public function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
{
|
9 |
-
$opts =
|
10 |
|
11 |
add_action('init', array($this, 'on_init'));
|
12 |
|
@@ -63,12 +76,6 @@ class MC4WP_Lite_Checkbox
|
|
63 |
|
64 |
}
|
65 |
|
66 |
-
public function get_options()
|
67 |
-
{
|
68 |
-
$options = MC4WP_Lite::instance()->get_options();
|
69 |
-
return $options['checkbox'];
|
70 |
-
}
|
71 |
-
|
72 |
public function on_init()
|
73 |
{
|
74 |
if(function_exists("wpcf7_add_shortcode")) {
|
@@ -79,7 +86,7 @@ class MC4WP_Lite_Checkbox
|
|
79 |
|
80 |
public function get_checkbox($args = array())
|
81 |
{
|
82 |
-
$opts =
|
83 |
$label = isset($args['labels'][0]) ? $args['labels'][0] : $opts['label'];
|
84 |
$checked = $opts['precheck'] ? "checked" : '';
|
85 |
$content = "\n<!-- Checkbox by MailChimp for WordPress plugin v". MC4WP_LITE_VERSION ." - http://dannyvankooten.com/mailchimp-for-wordpress/ -->\n";
|
@@ -349,8 +356,8 @@ class MC4WP_Lite_Checkbox
|
|
349 |
|
350 |
public function subscribe($email, array $merge_vars = array())
|
351 |
{
|
352 |
-
$api =
|
353 |
-
$opts =
|
354 |
|
355 |
$lists = $opts['lists'];
|
356 |
|
3 |
class MC4WP_Lite_Checkbox
|
4 |
{
|
5 |
private $showed_checkbox = false;
|
6 |
+
private static $instance = null;
|
7 |
|
8 |
+
public static function init() {
|
9 |
+
if(self::$instance) {
|
10 |
+
throw new Exception("Already initialized");
|
11 |
+
} else {
|
12 |
+
self::$instance = new self;
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
public static function instance() {
|
17 |
+
return self::$instance;
|
18 |
+
}
|
19 |
+
|
20 |
+
private function __construct()
|
21 |
{
|
22 |
+
$opts = mc4wp_get_options('checkbox');
|
23 |
|
24 |
add_action('init', array($this, 'on_init'));
|
25 |
|
76 |
|
77 |
}
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
public function on_init()
|
80 |
{
|
81 |
if(function_exists("wpcf7_add_shortcode")) {
|
86 |
|
87 |
public function get_checkbox($args = array())
|
88 |
{
|
89 |
+
$opts = mc4wp_get_options('checkbox');
|
90 |
$label = isset($args['labels'][0]) ? $args['labels'][0] : $opts['label'];
|
91 |
$checked = $opts['precheck'] ? "checked" : '';
|
92 |
$content = "\n<!-- Checkbox by MailChimp for WordPress plugin v". MC4WP_LITE_VERSION ." - http://dannyvankooten.com/mailchimp-for-wordpress/ -->\n";
|
356 |
|
357 |
public function subscribe($email, array $merge_vars = array())
|
358 |
{
|
359 |
+
$api = mc4wp_get_api();
|
360 |
+
$opts = mc4wp_get_options('checkbox');
|
361 |
|
362 |
$lists = $opts['lists'];
|
363 |
|
includes/{MC4WP_Lite_Form.php → class-form.php}
RENAMED
@@ -1,13 +1,26 @@
|
|
1 |
<?php
|
2 |
|
3 |
class MC4WP_Lite_Form {
|
|
|
4 |
private $form_instance_number = 1;
|
5 |
private $error = null;
|
6 |
private $success = false;
|
7 |
private $submitted_form_instance = 0;
|
8 |
|
9 |
-
public function
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
if($opts['css']) {
|
13 |
add_filter('mc4wp_stylesheets', array($this, 'add_stylesheets'));
|
@@ -34,13 +47,8 @@ class MC4WP_Lite_Form {
|
|
34 |
wp_register_script( 'mc4wp-placeholders', plugins_url('mailchimp-for-wp/assets/js/placeholders.min.js'), array(), MC4WP_LITE_VERSION, true );
|
35 |
}
|
36 |
|
37 |
-
public function get_options() {
|
38 |
-
$options = MC4WP_Lite::instance()->get_options();
|
39 |
-
return $options['form'];
|
40 |
-
}
|
41 |
-
|
42 |
public function add_stylesheets($stylesheets) {
|
43 |
-
$opts =
|
44 |
|
45 |
$stylesheets['form'] = 1;
|
46 |
|
@@ -53,7 +61,7 @@ class MC4WP_Lite_Form {
|
|
53 |
}
|
54 |
|
55 |
public function output_form( $atts, $content = null ) {
|
56 |
-
$opts =
|
57 |
|
58 |
if ( !function_exists( 'mc4wp_replace_variables' ) ) {
|
59 |
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/template-functions.php';
|
@@ -65,7 +73,7 @@ class MC4WP_Lite_Form {
|
|
65 |
if ( $this->success ) $css_classes .= 'mc4wp-form-success ';
|
66 |
|
67 |
$content = "\n<!-- Form by MailChimp for WordPress plugin v". MC4WP_LITE_VERSION ." - http://dannyvankooten.com/mailchimp-for-wordpress/ -->\n";
|
68 |
-
$content .= '<form method="post" action="'. mc4wp_get_current_url() .'
|
69 |
|
70 |
// maybe hide the form
|
71 |
if ( !( $this->success && $opts['hide_after_success'] ) ) {
|
@@ -90,7 +98,7 @@ class MC4WP_Lite_Form {
|
|
90 |
$content .= '<div class="mc4wp-alert mc4wp-success">' . __( $opts['text_success'] ) . '</div>';
|
91 |
} elseif ( $this->error ) {
|
92 |
|
93 |
-
$api =
|
94 |
$e = $this->error;
|
95 |
|
96 |
if ( $e == 'already_subscribed' ) {
|
@@ -131,7 +139,7 @@ class MC4WP_Lite_Form {
|
|
131 |
}
|
132 |
|
133 |
public function submit() {
|
134 |
-
$opts =
|
135 |
$this->submitted_form_instance = (int) $_POST['mc4wp_form_instance'];
|
136 |
|
137 |
if ( !isset( $_POST['mc4wp_form_nonce'] ) || !wp_verify_nonce( $_POST['mc4wp_form_nonce'], '_mc4wp_form_nonce' ) ) {
|
@@ -273,8 +281,8 @@ class MC4WP_Lite_Form {
|
|
273 |
}
|
274 |
|
275 |
public function subscribe( $email, array $merge_vars = array() ) {
|
276 |
-
$api =
|
277 |
-
$opts =
|
278 |
|
279 |
$lists = $opts['lists'];
|
280 |
|
@@ -327,28 +335,41 @@ class MC4WP_Lite_Form {
|
|
327 |
}
|
328 |
|
329 |
public function print_scroll_js() {
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
|
|
|
|
|
|
|
|
|
|
346 |
|
347 |
-
|
348 |
-
|
349 |
-
}
|
350 |
-
|
351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
}
|
353 |
|
354 |
}
|
1 |
<?php
|
2 |
|
3 |
class MC4WP_Lite_Form {
|
4 |
+
private static $instance = null;
|
5 |
private $form_instance_number = 1;
|
6 |
private $error = null;
|
7 |
private $success = false;
|
8 |
private $submitted_form_instance = 0;
|
9 |
|
10 |
+
public static function init() {
|
11 |
+
if(self::$instance) {
|
12 |
+
throw new Exception("Already initialized");
|
13 |
+
} else {
|
14 |
+
self::$instance = new self;
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
public static function instance() {
|
19 |
+
return self::$instance;
|
20 |
+
}
|
21 |
+
|
22 |
+
private function __construct() {
|
23 |
+
$opts = mc4wp_get_options('form');
|
24 |
|
25 |
if($opts['css']) {
|
26 |
add_filter('mc4wp_stylesheets', array($this, 'add_stylesheets'));
|
47 |
wp_register_script( 'mc4wp-placeholders', plugins_url('mailchimp-for-wp/assets/js/placeholders.min.js'), array(), MC4WP_LITE_VERSION, true );
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
|
|
50 |
public function add_stylesheets($stylesheets) {
|
51 |
+
$opts = mc4wp_get_options('form');
|
52 |
|
53 |
$stylesheets['form'] = 1;
|
54 |
|
61 |
}
|
62 |
|
63 |
public function output_form( $atts, $content = null ) {
|
64 |
+
$opts = mc4wp_get_options('form');
|
65 |
|
66 |
if ( !function_exists( 'mc4wp_replace_variables' ) ) {
|
67 |
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/template-functions.php';
|
73 |
if ( $this->success ) $css_classes .= 'mc4wp-form-success ';
|
74 |
|
75 |
$content = "\n<!-- Form by MailChimp for WordPress plugin v". MC4WP_LITE_VERSION ." - http://dannyvankooten.com/mailchimp-for-wordpress/ -->\n";
|
76 |
+
$content .= '<form method="post" action="'. mc4wp_get_current_url() .'" id="mc4wp-form-'.$this->form_instance_number.'" class="mc4wp-form form'.$css_classes.'">';
|
77 |
|
78 |
// maybe hide the form
|
79 |
if ( !( $this->success && $opts['hide_after_success'] ) ) {
|
98 |
$content .= '<div class="mc4wp-alert mc4wp-success">' . __( $opts['text_success'] ) . '</div>';
|
99 |
} elseif ( $this->error ) {
|
100 |
|
101 |
+
$api = mc4wp_get_api();
|
102 |
$e = $this->error;
|
103 |
|
104 |
if ( $e == 'already_subscribed' ) {
|
139 |
}
|
140 |
|
141 |
public function submit() {
|
142 |
+
$opts = mc4wp_get_options('form');
|
143 |
$this->submitted_form_instance = (int) $_POST['mc4wp_form_instance'];
|
144 |
|
145 |
if ( !isset( $_POST['mc4wp_form_nonce'] ) || !wp_verify_nonce( $_POST['mc4wp_form_nonce'], '_mc4wp_form_nonce' ) ) {
|
281 |
}
|
282 |
|
283 |
public function subscribe( $email, array $merge_vars = array() ) {
|
284 |
+
$api = mc4wp_get_api();
|
285 |
+
$opts = mc4wp_get_options('form');
|
286 |
|
287 |
$lists = $opts['lists'];
|
288 |
|
335 |
}
|
336 |
|
337 |
public function print_scroll_js() {
|
338 |
+
$form_id = $_POST['mc4wp_form_instance'];
|
339 |
+
?><script type="text/javascript">(function(){var e=document.getElementById("mc4wp-form-<?php echo esc_js($form_id); ?>");if(!e){return}var t=0;var n=e;var r=window.innerHeight;if(n.offsetParent){do{t+=n.offsetTop}while(n=n.offsetParent)}else{t=e.offsetTop}if(r>e.clientHeight){t=t-(r-e.clientHeight)/2}if(window.jQuery!==undefined){var i=500+t;jQuery("html, body").animate({scrollTop:t},i)}else{window.scrollTo(0,t)}})()</script><?php
|
340 |
+
/*?><script>
|
341 |
+
(function() {
|
342 |
+
var element = document.getElementById('mc4wp-form-<?php echo esc_js($form_id); ?>');
|
343 |
+
|
344 |
+
if(!element) {
|
345 |
+
return;
|
346 |
+
}
|
347 |
+
|
348 |
+
var scrollToHeight = 0;
|
349 |
+
var obj = element;
|
350 |
+
var windowHeight = window.innerHeight;
|
351 |
+
|
352 |
+
if (obj.offsetParent) {
|
353 |
+
do {
|
354 |
+
scrollToHeight += obj.offsetTop;
|
355 |
+
} while (obj = obj.offsetParent);
|
356 |
+
} else {
|
357 |
+
scrollToHeight = element.offsetTop;
|
358 |
+
}
|
359 |
|
360 |
+
if(windowHeight > element.clientHeight) {
|
361 |
+
scrollToHeight = scrollToHeight - ((windowHeight - element.clientHeight) / 2);
|
362 |
+
}
|
363 |
+
|
364 |
+
if(window.jQuery !== undefined) {
|
365 |
+
var animationTime = (500 + scrollToHeight);
|
366 |
+
jQuery('html, body').animate({ scrollTop: scrollToHeight }, animationTime);
|
367 |
+
} else {
|
368 |
+
window.scrollTo(0, scrollToHeight);
|
369 |
+
}
|
370 |
+
})();
|
371 |
+
</script>
|
372 |
+
<?php*/
|
373 |
}
|
374 |
|
375 |
}
|
includes/class-plugin.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MC4WP_Lite {
|
4 |
+
private static $instance;
|
5 |
+
|
6 |
+
public static function instance() {
|
7 |
+
return self::$instance;
|
8 |
+
}
|
9 |
+
|
10 |
+
public static function init() {
|
11 |
+
if(self::$instance) {
|
12 |
+
throw new Exception("ALready initialized.");
|
13 |
+
} else {
|
14 |
+
self::$instance = new self;
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
private function __construct() {
|
19 |
+
$this->backwards_compatibility();
|
20 |
+
|
21 |
+
// checkbox
|
22 |
+
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-checkbox.php';
|
23 |
+
MC4WP_Lite_Checkbox::init();
|
24 |
+
|
25 |
+
// form
|
26 |
+
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-form.php';
|
27 |
+
MC4WP_Lite_Form::init();
|
28 |
+
|
29 |
+
// widget
|
30 |
+
add_action( 'widgets_init', array($this, 'register_widget') );
|
31 |
+
|
32 |
+
if (!is_admin()) {
|
33 |
+
// frontend only
|
34 |
+
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/template-functions.php';
|
35 |
+
|
36 |
+
// load css
|
37 |
+
add_action( 'wp_enqueue_scripts', array($this, 'load_stylesheets'), 90);
|
38 |
+
add_action( 'login_enqueue_scripts', array($this, 'load_stylesheets') );
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
private function backwards_compatibility() {
|
43 |
+
$options = get_option( 'mc4wp_lite' );
|
44 |
+
|
45 |
+
// transfer widget to new id?
|
46 |
+
if(get_option('mc4wp_transfered_old_widgets', false) == false) {
|
47 |
+
$sidebars_widgets = get_option('sidebars_widgets');
|
48 |
+
|
49 |
+
if($sidebars_widgets && is_array($sidebars_widgets)) {
|
50 |
+
foreach($sidebars_widgets as $key => $widgets)
|
51 |
+
{
|
52 |
+
if(!is_array($widgets)) { continue; }
|
53 |
+
foreach($widgets as $subkey => $widget_name) {
|
54 |
+
|
55 |
+
if(substr($widget_name, 0, 17) == 'mc4wp_lite_widget') {
|
56 |
+
|
57 |
+
$new_widget_name = str_replace('mc4wp_lite_widget', 'mc4wp_widget', $widget_name);
|
58 |
+
// active widget found, just change name?
|
59 |
+
$sidebars_widgets[$key][$subkey] = $new_widget_name;
|
60 |
+
update_option('sidebars_widgets', $sidebars_widgets);
|
61 |
+
update_option('widget_mc4wp_widget', get_option('widget_mc4wp_lite_widget') );
|
62 |
+
break;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
update_option('mc4wp_transfered_old_widgets', true);
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
|
74 |
+
// transfer old options to new options format
|
75 |
+
if (isset( $options['mailchimp_api_key'] )) {
|
76 |
+
|
77 |
+
$new_options = array(
|
78 |
+
'general' => array(),
|
79 |
+
'checkbox' => array(),
|
80 |
+
'form' => array()
|
81 |
+
);
|
82 |
+
|
83 |
+
$new_options['general']['api_key'] = $options['mailchimp_api_key'];
|
84 |
+
|
85 |
+
foreach ( $options as $key => $value ) {
|
86 |
+
$_pos = strpos( $key, '_' );
|
87 |
+
|
88 |
+
$first_key = substr( $key, 0, $_pos );
|
89 |
+
$second_key = substr( $key, $_pos + 1 );
|
90 |
+
|
91 |
+
if ( isset( $new_options[$first_key] ) ) {
|
92 |
+
|
93 |
+
// change option name
|
94 |
+
if ( $second_key == 'show_at_bp_form' ) {
|
95 |
+
$second_key = 'show_at_buddypress_form';
|
96 |
+
}
|
97 |
+
|
98 |
+
// change option name
|
99 |
+
if ( $second_key == 'show_at_ms_form' ) {
|
100 |
+
$second_key = 'show_at_multisite_form';
|
101 |
+
}
|
102 |
+
|
103 |
+
// set value into new option name
|
104 |
+
$new_options[$first_key][$second_key] = $value;
|
105 |
+
}
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
update_option( 'mc4wp_lite', $new_options['general'] );
|
110 |
+
update_option( 'mc4wp_lite_checkbox', $new_options['checkbox'] );
|
111 |
+
update_option( 'mc4wp_lite_form', $new_options['form'] );
|
112 |
+
} // end transfer options
|
113 |
+
}
|
114 |
+
|
115 |
+
public function register_widget()
|
116 |
+
{
|
117 |
+
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-widget.php';
|
118 |
+
register_widget( 'MC4WP_Lite_Widget' );
|
119 |
+
}
|
120 |
+
|
121 |
+
public function load_stylesheets()
|
122 |
+
{
|
123 |
+
$stylesheets = apply_filters('mc4wp_stylesheets', array());
|
124 |
+
|
125 |
+
if(!empty($stylesheets)) {
|
126 |
+
$stylesheet_url = add_query_arg($stylesheets, plugins_url('mailchimp-for-wp/assets/css/css.php'));
|
127 |
+
wp_enqueue_style( 'mailchimp-for-wp', $stylesheet_url, array(), MC4WP_LITE_VERSION);
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
}
|
includes/{MC4WP_Lite_Widget.php → class-widget.php}
RENAMED
File without changes
|
includes/functions.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function mc4wp_get_options($key = null) {
|
4 |
+
static $options;
|
5 |
+
|
6 |
+
if(!$options) {
|
7 |
+
$defaults = array(
|
8 |
+
'general' => array(
|
9 |
+
'api_key' => ''
|
10 |
+
),
|
11 |
+
'checkbox' => array(
|
12 |
+
'label' => 'Sign me up for the newsletter!',
|
13 |
+
'precheck' => 1,
|
14 |
+
'css' => 1,
|
15 |
+
'show_at_comment_form' => 0,
|
16 |
+
'show_at_registration_form' => 0,
|
17 |
+
'show_at_multisite_form' => 0,
|
18 |
+
'show_at_buddypress_form' => 0,
|
19 |
+
'show_at_bbpress_forms' => 0,
|
20 |
+
'lists' => array(),
|
21 |
+
'double_optin' => 1
|
22 |
+
),
|
23 |
+
'form' => array(
|
24 |
+
'css' => 'default',
|
25 |
+
'markup' => "<p>\n\t<label for=\"mc4wp_email\">Email address: </label>\n\t<input type=\"email\" id=\"mc4wp_email\" name=\"EMAIL\" required placeholder=\"Your email address\" />\n</p>\n\n<p>\n\t<input type=\"submit\" value=\"Sign up\" />\n</p>",
|
26 |
+
'text_success' => 'Thank you, your sign-up request was successful! Please check your e-mail inbox.',
|
27 |
+
'text_error' => 'Oops. Something went wrong. Please try again later.',
|
28 |
+
'text_invalid_email' => 'Please provide a valid email address.',
|
29 |
+
'text_already_subscribed' => "Given email address is already subscribed, thank you!",
|
30 |
+
'redirect' => '',
|
31 |
+
'lists' => array(),
|
32 |
+
'double_optin' => 1,
|
33 |
+
'hide_after_success' => 0
|
34 |
+
)
|
35 |
+
);
|
36 |
+
|
37 |
+
$db_keys_option_keys = array(
|
38 |
+
'mc4wp_lite' => 'general',
|
39 |
+
'mc4wp_lite_checkbox' => 'checkbox',
|
40 |
+
'mc4wp_lite_form' => 'form'
|
41 |
+
);
|
42 |
+
|
43 |
+
$options = array();
|
44 |
+
foreach ( $db_keys_option_keys as $db_key => $option_key ) {
|
45 |
+
$option = get_option( $db_key );
|
46 |
+
|
47 |
+
// add option to database to prevent query on every pageload
|
48 |
+
if ( $option == false ) { add_option( $db_key, $defaults[$option_key] ); }
|
49 |
+
|
50 |
+
$options[$option_key] = array_merge( $defaults[$option_key], (array) $option );
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
if($key) {
|
55 |
+
return $options[$key];
|
56 |
+
}
|
57 |
+
|
58 |
+
return $options;
|
59 |
+
}
|
60 |
+
|
61 |
+
function mc4wp_get_api() {
|
62 |
+
static $api;
|
63 |
+
|
64 |
+
if(!$api) {
|
65 |
+
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-api.php';
|
66 |
+
$opts = mc4wp_get_options();
|
67 |
+
$api = new MC4WP_Lite_API( $opts['general']['api_key'] );
|
68 |
+
}
|
69 |
+
|
70 |
+
return $api;
|
71 |
+
}
|
includes/index.php
CHANGED
@@ -1,3 +1,6 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
|
|
|
|
1 |
<?php
|
2 |
+
// prevent directory listing
|
3 |
|
4 |
+
header('HTTP/1.0 403 Forbidden');
|
5 |
+
header("X-Robots-Tag: noindex");
|
6 |
+
exit;
|
includes/template-functions.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Echoes a sign-up checkbox.
|
5 |
*/
|
6 |
function mc4wp_checkbox() {
|
7 |
-
|
8 |
}
|
9 |
|
10 |
/**
|
@@ -22,7 +22,7 @@ function mc4wp_form( $id = 0 ) {
|
|
22 |
* @return string HTML of given form_id.
|
23 |
*/
|
24 |
function mc4wp_get_form( $id = 0 ) {
|
25 |
-
return
|
26 |
}
|
27 |
|
28 |
|
@@ -69,7 +69,7 @@ function mc4wp_get_subscriber_count( $list_ids ) {
|
|
69 |
|
70 |
if ( !$list_counts ) {
|
71 |
// make api call
|
72 |
-
$api =
|
73 |
$lists = $api->get_lists();
|
74 |
$list_counts = array();
|
75 |
|
4 |
* Echoes a sign-up checkbox.
|
5 |
*/
|
6 |
function mc4wp_checkbox() {
|
7 |
+
MC4WP_Lite_Checkbox::instance()->output_checkbox();
|
8 |
}
|
9 |
|
10 |
/**
|
22 |
* @return string HTML of given form_id.
|
23 |
*/
|
24 |
function mc4wp_get_form( $id = 0 ) {
|
25 |
+
return MC4WP_Lite_Form::instance()->output_form( array( 'id' => $id ) );
|
26 |
}
|
27 |
|
28 |
|
69 |
|
70 |
if ( !$list_counts ) {
|
71 |
// make api call
|
72 |
+
$api = mc4wp_get_api();
|
73 |
$lists = $api->get_lists();
|
74 |
$list_counts = array();
|
75 |
|
includes/views/api-settings.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php defined("ABSPATH") or exit; ?>
|
2 |
<div id="mc4wp-<?php echo $tab; ?>" class="wrap mc4wp-settings">
|
3 |
|
4 |
-
<h2
|
5 |
|
6 |
<div id="mc4wp-content">
|
7 |
|
@@ -28,8 +28,9 @@
|
|
28 |
</form>
|
29 |
|
30 |
<?php if($connected) { ?>
|
31 |
-
<h3 class="mc4wp-title">MailChimp
|
32 |
-
<p>The table below shows your cached MailChimp lists configuration
|
|
|
33 |
|
34 |
<table class="wp-list-table widefat">
|
35 |
<thead>
|
@@ -53,7 +54,7 @@
|
|
53 |
}
|
54 |
?>
|
55 |
</td>
|
56 |
-
<td
|
57 |
</tr>
|
58 |
<?php } // endforeach ?>
|
59 |
<?php } else { ?>
|
1 |
<?php defined("ABSPATH") or exit; ?>
|
2 |
<div id="mc4wp-<?php echo $tab; ?>" class="wrap mc4wp-settings">
|
3 |
|
4 |
+
<h2><img src="<?php echo plugins_url('mailchimp-for-wp/assets/img/menu-icon.png'); ?>" /> MailChimp for WordPress: MailChimp Settings</h2>
|
5 |
|
6 |
<div id="mc4wp-content">
|
7 |
|
28 |
</form>
|
29 |
|
30 |
<?php if($connected) { ?>
|
31 |
+
<h3 class="mc4wp-title">Cached MailChimp Settings</h3>
|
32 |
+
<p>The table below shows your cached MailChimp lists configuration.</p>
|
33 |
+
<p>Made changes to your lists? Please renew the cache manually by hitting the "renew cached data" button.</p>
|
34 |
|
35 |
<table class="wp-list-table widefat">
|
36 |
<thead>
|
54 |
}
|
55 |
?>
|
56 |
</td>
|
57 |
+
<td class="pro-feature">Pro Only</td>
|
58 |
</tr>
|
59 |
<?php } // endforeach ?>
|
60 |
<?php } else { ?>
|
includes/views/checkbox-settings.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
<?php defined("ABSPATH") or exit; ?>
|
2 |
<div id="mc4wp-<?php echo $tab; ?>" class="wrap mc4wp-settings">
|
3 |
|
4 |
-
<h2
|
5 |
-
|
6 |
<div id="mc4wp-content">
|
7 |
|
8 |
<?php settings_errors(); ?>
|
9 |
<p>To use the MailChimp for WP sign-up checkboxes, select at least one list and one form to add the checkbox to.</p>
|
10 |
|
11 |
-
<h3 class="mc4wp-title">MailChimp settings</h3>
|
12 |
<form action="options.php" method="post">
|
13 |
<?php settings_fields( 'mc4wp_lite_checkbox_settings' ); ?>
|
14 |
|
@@ -23,7 +23,7 @@
|
|
23 |
}
|
24 |
else
|
25 |
{ ?>
|
26 |
-
<td>
|
27 |
<?php foreach($lists as $list) {
|
28 |
?><label><input type="checkbox" name="mc4wp_lite_checkbox[lists][<?php echo $list->id; ?>]" value="<?php echo esc_attr($list->id); ?>" <?php if(array_key_exists($list->id, $opts['lists'])) echo 'checked="checked"'; ?>> <?php echo $list->name; ?></label><br /><?php
|
29 |
} ?>
|
@@ -45,7 +45,7 @@
|
|
45 |
|
46 |
<tr valign="top">
|
47 |
<th scope="row">Add the checkbox to these forms</th>
|
48 |
-
<td colspan="2">
|
49 |
<?php foreach($this->get_checkbox_compatible_plugins() as $code => $name) {
|
50 |
|
51 |
if($code[0] != '_') {
|
1 |
<?php defined("ABSPATH") or exit; ?>
|
2 |
<div id="mc4wp-<?php echo $tab; ?>" class="wrap mc4wp-settings">
|
3 |
|
4 |
+
<h2><img src="<?php echo plugins_url('mailchimp-for-wp/assets/img/menu-icon.png'); ?>" /> MailChimp for WordPress: Checkbox Settings</h2>
|
5 |
+
|
6 |
<div id="mc4wp-content">
|
7 |
|
8 |
<?php settings_errors(); ?>
|
9 |
<p>To use the MailChimp for WP sign-up checkboxes, select at least one list and one form to add the checkbox to.</p>
|
10 |
|
11 |
+
<h3 class="mc4wp-title">MailChimp settings for checkboxes</h3>
|
12 |
<form action="options.php" method="post">
|
13 |
<?php settings_fields( 'mc4wp_lite_checkbox_settings' ); ?>
|
14 |
|
23 |
}
|
24 |
else
|
25 |
{ ?>
|
26 |
+
<td class="nowrap">
|
27 |
<?php foreach($lists as $list) {
|
28 |
?><label><input type="checkbox" name="mc4wp_lite_checkbox[lists][<?php echo $list->id; ?>]" value="<?php echo esc_attr($list->id); ?>" <?php if(array_key_exists($list->id, $opts['lists'])) echo 'checked="checked"'; ?>> <?php echo $list->name; ?></label><br /><?php
|
29 |
} ?>
|
45 |
|
46 |
<tr valign="top">
|
47 |
<th scope="row">Add the checkbox to these forms</th>
|
48 |
+
<td colspan="2" class="nowrap">
|
49 |
<?php foreach($this->get_checkbox_compatible_plugins() as $code => $name) {
|
50 |
|
51 |
if($code[0] != '_') {
|
includes/views/form-settings.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php defined("ABSPATH") or exit; ?>
|
2 |
<div id="mc4wp-<?php echo $tab; ?>" class="wrap mc4wp-settings">
|
3 |
|
4 |
-
<h2
|
5 |
|
6 |
<div id="mc4wp-content">
|
7 |
|
@@ -17,7 +17,7 @@
|
|
17 |
|
18 |
<tr valign="top">
|
19 |
<th scope="row"><label for="mc4wp_load_stylesheet_select">Load styles or theme?</label></th>
|
20 |
-
<td class="nowrap">
|
21 |
<select name="mc4wp_lite_form[css]" id="mc4wp_load_stylesheet_select">
|
22 |
<option value="0" <?php selected($opts['css'], 0); ?>>No</option>
|
23 |
<option value="default" <?php selected($opts['css'], 'default'); ?><?php selected($opts['css'], 1); ?>>Yes, load basic formatting styles</option>
|
@@ -57,7 +57,7 @@
|
|
57 |
<td colspan="3">
|
58 |
<h4>Form mark-up</h4>
|
59 |
<div class="mc4wp-wrapper">
|
60 |
-
<div class="mc4wp-col mc4wp-
|
61 |
<?php
|
62 |
if(function_exists('wp_editor')) {
|
63 |
wp_editor( esc_textarea($opts['markup']), 'mc4wpformmarkup', array('tinymce' => false, 'media_buttons' => false, 'textarea_name' => 'mc4wp_lite_form[markup]'));
|
@@ -68,7 +68,7 @@
|
|
68 |
|
69 |
</div>
|
70 |
|
71 |
-
<div class="mc4wp-col mc4wp-
|
72 |
<?php include('parts/admin-field-wizard.php'); ?>
|
73 |
</div>
|
74 |
</div>
|
@@ -172,64 +172,62 @@
|
|
172 |
<?php include 'parts/admin-upgrade-to-pro.php'; ?>
|
173 |
|
174 |
<div class="mc4wp-box" id="mc4wp-info-tabs">
|
175 |
-
<h3>Building your sign-up form</h3>
|
176 |
<p>At a minimum, your form should include just an <strong>EMAIL</strong> field and a submit button.</p>
|
177 |
<p>Add more fields to your form if your list requires more fields. Field names should match your MailChimp list field tags. Use the "Add a new field" tool to have the correct HTML generated for you.</p>
|
178 |
|
179 |
-
<h3>Form Styling</h3>
|
180 |
<p>Alter the visual appearance of the form by applying CSS rules to <b>.mc4wp-form</b> and its child elements.</p>
|
181 |
<p>You should add the CSS rules to your theme stylesheet using the <a href="<?php echo admin_url('theme-editor.php?file=style.css'); ?>">Theme Editor</a> or by editing <em><?php echo get_stylesheet_directory(); ?>/style.css</em> over FTP.</p>
|
182 |
|
183 |
<p>The <a href="http://wordpress.org/plugins/mailchimp-for-wp/faq/" target="_blank">FAQ</a> lists the various CSS selectors you can use to target the different elements.</p>
|
|
|
|
|
|
|
184 |
|
185 |
-
<
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
<
|
191 |
-
<
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
<
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
<
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
<
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
<
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
<
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
<
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
<
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
<
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
<th>{current_url}</th>
|
229 |
-
<td>Current URL</td>
|
230 |
-
</tr>
|
231 |
-
</table>
|
232 |
-
</div>
|
233 |
|
234 |
<?php include 'parts/admin-need-support.php'; ?>
|
235 |
</div>
|
1 |
<?php defined("ABSPATH") or exit; ?>
|
2 |
<div id="mc4wp-<?php echo $tab; ?>" class="wrap mc4wp-settings">
|
3 |
|
4 |
+
<h2><img src="<?php echo plugins_url('mailchimp-for-wp/assets/img/menu-icon.png'); ?>" /> MailChimp for WordPress: Form settings</h2>
|
5 |
|
6 |
<div id="mc4wp-content">
|
7 |
|
17 |
|
18 |
<tr valign="top">
|
19 |
<th scope="row"><label for="mc4wp_load_stylesheet_select">Load styles or theme?</label></th>
|
20 |
+
<td class="nowrap valigntop">
|
21 |
<select name="mc4wp_lite_form[css]" id="mc4wp_load_stylesheet_select">
|
22 |
<option value="0" <?php selected($opts['css'], 0); ?>>No</option>
|
23 |
<option value="default" <?php selected($opts['css'], 'default'); ?><?php selected($opts['css'], 1); ?>>Yes, load basic formatting styles</option>
|
57 |
<td colspan="3">
|
58 |
<h4>Form mark-up</h4>
|
59 |
<div class="mc4wp-wrapper">
|
60 |
+
<div class="mc4wp-col mc4wp-first">
|
61 |
<?php
|
62 |
if(function_exists('wp_editor')) {
|
63 |
wp_editor( esc_textarea($opts['markup']), 'mc4wpformmarkup', array('tinymce' => false, 'media_buttons' => false, 'textarea_name' => 'mc4wp_lite_form[markup]'));
|
68 |
|
69 |
</div>
|
70 |
|
71 |
+
<div class="mc4wp-col mc4wp-last">
|
72 |
<?php include('parts/admin-field-wizard.php'); ?>
|
73 |
</div>
|
74 |
</div>
|
172 |
<?php include 'parts/admin-upgrade-to-pro.php'; ?>
|
173 |
|
174 |
<div class="mc4wp-box" id="mc4wp-info-tabs">
|
175 |
+
<h3 class="mc4wp-title">Building your sign-up form</h3>
|
176 |
<p>At a minimum, your form should include just an <strong>EMAIL</strong> field and a submit button.</p>
|
177 |
<p>Add more fields to your form if your list requires more fields. Field names should match your MailChimp list field tags. Use the "Add a new field" tool to have the correct HTML generated for you.</p>
|
178 |
|
179 |
+
<h3 class="mc4wp-title">Form Styling</h3>
|
180 |
<p>Alter the visual appearance of the form by applying CSS rules to <b>.mc4wp-form</b> and its child elements.</p>
|
181 |
<p>You should add the CSS rules to your theme stylesheet using the <a href="<?php echo admin_url('theme-editor.php?file=style.css'); ?>">Theme Editor</a> or by editing <em><?php echo get_stylesheet_directory(); ?>/style.css</em> over FTP.</p>
|
182 |
|
183 |
<p>The <a href="http://wordpress.org/plugins/mailchimp-for-wp/faq/" target="_blank">FAQ</a> lists the various CSS selectors you can use to target the different elements.</p>
|
184 |
+
|
185 |
+
<h3 class="mc4wp-title">Form variables</h3>
|
186 |
+
<p>Use the following variables to add some dynamic content to your form.</p>
|
187 |
|
188 |
+
<table class="mc4wp-help">
|
189 |
+
<tr>
|
190 |
+
<th>{subscriber_count}</th>
|
191 |
+
<td>Replaced with the number of subscribers on the selected list(s).</td>
|
192 |
+
</tr>
|
193 |
+
<tr>
|
194 |
+
<th>{ip}</th>
|
195 |
+
<td>Replaced with the visitor's IP address.</td>
|
196 |
+
</tr>
|
197 |
+
<tr>
|
198 |
+
<th>{date}</th>
|
199 |
+
<td>Replaced with the current date (yyyy/mm/dd eg: <?php echo date("Y/m/d"); ?>)</td>
|
200 |
+
</tr>
|
201 |
+
<tr>
|
202 |
+
<th>{time}</th>
|
203 |
+
<td>Replaced with the current time (hh:mm:ss eg: <?php echo date("H:i:s"); ?>)</td>
|
204 |
+
</tr>
|
205 |
+
<tr>
|
206 |
+
<th>{user_email}</th>
|
207 |
+
<td>Replaced with the logged in user's email (or nothing, if there is no logged in user).</td>
|
208 |
+
</tr>
|
209 |
+
<tr>
|
210 |
+
<th>{user_name}</th>
|
211 |
+
<td>Display name of the current user</td>
|
212 |
+
</tr>
|
213 |
+
<tr>
|
214 |
+
<th>{user_firstname}</th>
|
215 |
+
<td>First name of the current user</td>
|
216 |
+
</tr>
|
217 |
+
<tr>
|
218 |
+
<th>{user_lastname}</th>
|
219 |
+
<td>Last name of the current user</td>
|
220 |
+
</tr>
|
221 |
+
<tr>
|
222 |
+
<th>{user_id}</th>
|
223 |
+
<td>Current user ID</td>
|
224 |
+
</tr>
|
225 |
+
<tr>
|
226 |
+
<th>{current_url}</th>
|
227 |
+
<td>Current URL</td>
|
228 |
+
</tr>
|
229 |
+
</table>
|
230 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
231 |
|
232 |
<?php include 'parts/admin-need-support.php'; ?>
|
233 |
</div>
|
includes/views/index.php
CHANGED
@@ -1,3 +1,6 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
|
|
|
|
1 |
<?php
|
2 |
+
// prevent directory listing
|
3 |
|
4 |
+
header('HTTP/1.0 403 Forbidden');
|
5 |
+
header("X-Robots-Tag: noindex");
|
6 |
+
exit;
|
includes/views/parts/admin-field-wizard.php
CHANGED
@@ -1,7 +1,11 @@
|
|
1 |
<?php defined("ABSPATH") or exit; ?>
|
2 |
<div id="mc4wp-fw" class="mc4wp-well">
|
3 |
|
4 |
-
<h4>Add a new field</h4>
|
|
|
|
|
|
|
|
|
5 |
<p>Use the tool below to generate the HTML for your form fields.</p>
|
6 |
<p>
|
7 |
<select class="widefat" id="mc4wp-fw-mailchimp-fields">
|
1 |
<?php defined("ABSPATH") or exit; ?>
|
2 |
<div id="mc4wp-fw" class="mc4wp-well">
|
3 |
|
4 |
+
<h4 class="mc4wp-title">Add a new field</h4>
|
5 |
+
|
6 |
+
|
7 |
+
<p class="mc4wp-notice no-lists-selected" <?php if(!empty($opts['lists'])) { ?>style="display: none;" <?php } ?>>Select at least one list first.</p>
|
8 |
+
|
9 |
<p>Use the tool below to generate the HTML for your form fields.</p>
|
10 |
<p>
|
11 |
<select class="widefat" id="mc4wp-fw-mailchimp-fields">
|
includes/views/parts/admin-footer.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php defined("ABSPATH") or exit; ?>
|
2 |
<br style="clear:both;" />
|
3 |
-
<p class="
|
4 |
-
<p class="help">
|
5 |
-
<p class="
|
1 |
<?php defined("ABSPATH") or exit; ?>
|
2 |
<br style="clear:both;" />
|
3 |
+
<p class="help">Enjoying this plugin? <a href="http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=lite-plugin&utm_medium=link&utm_campaign=footer-link">Upgrade to MailChimp for WordPress Pro now</a> for an even better plugin, you will love it.</p>
|
4 |
+
<p class="help">Submit your feature requests or vote for new features <a href="http://www.google.com/moderator/#15/e=20c6b7&t=20c6b7.40">here</a>.</p>
|
5 |
+
<p class="help">This plugin is not developed by or affiliated with MailChimp in any way.</p>
|
includes/views/parts/admin-need-support.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
<?php defined("ABSPATH") or exit; ?>
|
2 |
<div class="mc4wp-box">
|
3 |
-
<
|
4 |
-
<p>
|
5 |
<p>If you need priority support, please <a href="http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=lite-plugin&utm_medium=link&utm_campaign=support-link">upgrade to the premium version</a>.</p>
|
6 |
</div>
|
7 |
|
8 |
<div class="mc4wp-box">
|
9 |
-
<
|
10 |
<ul class="ul-square">
|
11 |
<li><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/mailchimp-for-wp?rate=5#postform">Leave a review on WordPress.org</a></li>
|
12 |
<li><a target="_blank" href="http://twitter.com/?status=Showing%20my%20appreciation%20to%20%40DannyvanKooten%20for%20his%20WordPress%20plugin%3A%20MailChimp%20for%20WP%20%20-%20check%20it%20out!%20http%3A%2F%2Fwordpress.org%2Fplugins%2Fmailchimp-for-wp%2F">Tweet about MailChimp for WP</a></li>
|
@@ -15,7 +15,7 @@
|
|
15 |
</ul>
|
16 |
</div>
|
17 |
<div class="mc4wp-box">
|
18 |
-
<
|
19 |
<p>My name is <a href="http://dannyvankooten.com/">Danny van Kooten</a>. I develop WordPress plugins which help you build your websites. I love simplicity, happy customers and clean code.</p>
|
20 |
<p>Take a look at my other <a href="http://dannyvankooten.com/wordpress-plugins/">plugins for WordPress</a> or <em>like</em> my Facebook page to stay updated.</p>
|
21 |
<p><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2FCodeToTheChase&width&layout=standard&action=like&show_faces=true&share=false&appId=225994527565061" scrolling="no" frameborder="0" style="border:none; width: 100%; overflow:hidden; height: 80px;" allowTransparency="true"></iframe></p>
|
1 |
<?php defined("ABSPATH") or exit; ?>
|
2 |
<div class="mc4wp-box">
|
3 |
+
<h4 class="mc4wp-title">Looking for support?</h4>
|
4 |
+
<p>Use the <a href="http://wordpress.org/support/plugin/mailchimp-for-wp">support forums</a> on WordPress.org.</p>
|
5 |
<p>If you need priority support, please <a href="http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=lite-plugin&utm_medium=link&utm_campaign=support-link">upgrade to the premium version</a>.</p>
|
6 |
</div>
|
7 |
|
8 |
<div class="mc4wp-box">
|
9 |
+
<h4 class="mc4wp-title">Show a token of your appreciation</h4>
|
10 |
<ul class="ul-square">
|
11 |
<li><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/mailchimp-for-wp?rate=5#postform">Leave a review on WordPress.org</a></li>
|
12 |
<li><a target="_blank" href="http://twitter.com/?status=Showing%20my%20appreciation%20to%20%40DannyvanKooten%20for%20his%20WordPress%20plugin%3A%20MailChimp%20for%20WP%20%20-%20check%20it%20out!%20http%3A%2F%2Fwordpress.org%2Fplugins%2Fmailchimp-for-wp%2F">Tweet about MailChimp for WP</a></li>
|
15 |
</ul>
|
16 |
</div>
|
17 |
<div class="mc4wp-box">
|
18 |
+
<h4 class="mc4wp-title">About the developer</h4>
|
19 |
<p>My name is <a href="http://dannyvankooten.com/">Danny van Kooten</a>. I develop WordPress plugins which help you build your websites. I love simplicity, happy customers and clean code.</p>
|
20 |
<p>Take a look at my other <a href="http://dannyvankooten.com/wordpress-plugins/">plugins for WordPress</a> or <em>like</em> my Facebook page to stay updated.</p>
|
21 |
<p><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2FCodeToTheChase&width&layout=standard&action=like&show_faces=true&share=false&appId=225994527565061" scrolling="no" frameborder="0" style="border:none; width: 100%; overflow:hidden; height: 80px;" allowTransparency="true"></iframe></p>
|
includes/views/parts/index.php
CHANGED
@@ -1,3 +1,6 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
|
|
|
|
1 |
<?php
|
2 |
+
// prevent directory listing
|
3 |
|
4 |
+
header('HTTP/1.0 403 Forbidden');
|
5 |
+
header("X-Robots-Tag: noindex");
|
6 |
+
exit;
|
index.php
CHANGED
@@ -1,3 +1,6 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
|
|
|
|
1 |
<?php
|
2 |
+
// prevent directory listing
|
3 |
|
4 |
+
header( 'HTTP/1.0 403 Forbidden' );
|
5 |
+
header( 'X-Robots-Tag: noindex' );
|
6 |
+
exit;
|
mailchimp-for-wp.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
3 |
Plugin Name: MailChimp for WordPress Lite
|
4 |
Plugin URI: http://dannyvankooten.com/mailchimp-for-wordpress/
|
5 |
-
Description: Lite version of MailChimp for WordPress.
|
6 |
-
Version: 1.4.
|
7 |
Author: Danny van Kooten
|
8 |
Author URI: http://dannyvanKooten.com
|
9 |
License: GPL v3
|
@@ -25,18 +25,34 @@ You should have received a copy of the GNU General Public License
|
|
25 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
26 |
*/
|
27 |
|
28 |
-
defined( 'ABSPATH' )
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
32 |
|
33 |
if(!function_exists('is_plugin_active')) {
|
34 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
35 |
}
|
36 |
|
37 |
-
//
|
38 |
-
if(!is_plugin_active('mailchimp-for-wp-pro/mailchimp-for-wp-pro.php')
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/*
|
3 |
Plugin Name: MailChimp for WordPress Lite
|
4 |
Plugin URI: http://dannyvankooten.com/mailchimp-for-wordpress/
|
5 |
+
Description: Lite version of MailChimp for WordPress. Adds various sign-up methods to your website.
|
6 |
+
Version: 1.4.8
|
7 |
Author: Danny van Kooten
|
8 |
Author URI: http://dannyvanKooten.com
|
9 |
License: GPL v3
|
25 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
26 |
*/
|
27 |
|
28 |
+
if( !defined( 'ABSPATH' ) ) {
|
29 |
+
header( 'HTTP/1.0 403 Forbidden' );
|
30 |
+
header( 'X-Robots-Tag: noindex' );
|
31 |
+
exit;
|
32 |
+
}
|
33 |
|
34 |
if(!function_exists('is_plugin_active')) {
|
35 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
36 |
}
|
37 |
|
38 |
+
// only load lite version if Pro is not active or being activated
|
39 |
+
if(!is_plugin_active('mailchimp-for-wp-pro/mailchimp-for-wp-pro.php')
|
40 |
+
&& !(is_admin() && isset($_GET['action']) && $_GET['action'] == 'activate' && isset($_GET['plugin']) && $_GET['plugin'] == 'mailchimp-for-wp-pro/mailchimp-for-wp-pro.php') ) {
|
41 |
+
|
42 |
+
define("MC4WP_LITE_VERSION", "1.4.8");
|
43 |
+
define("MC4WP_LITE_PLUGIN_DIR", plugin_dir_path(__FILE__));
|
44 |
|
45 |
+
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions.php';
|
46 |
+
|
47 |
+
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-plugin.php';
|
48 |
+
MC4WP_Lite::init();
|
49 |
+
|
50 |
+
if(is_admin() && (!defined("DOING_AJAX") || !DOING_AJAX)) {
|
51 |
+
|
52 |
+
// ADMIN
|
53 |
+
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-admin.php';
|
54 |
+
MC4WP_Lite_Admin::init();
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: DvanKooten
|
|
3 |
Donate link: http://dannyvankooten.com/donate/
|
4 |
Tags: mailchimp, widget, form, checkbox, sign-up form, mandrill, buddypress, multisite, bbpress, contact form 7, newsletter, mailinglist, cf7
|
5 |
Requires at least: 3.1
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.4.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -186,6 +186,14 @@ Your theme folder can be found by browsing to `/wp-content/themes/your-theme-nam
|
|
186 |
|
187 |
== Changelog ==
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
= 1.4.7 - December 4, 2013 =
|
190 |
* Fixed: Checkbox width not being reset when loading default CSS.
|
191 |
* Improved: Minor security improvement to prevent some plugin files from being accessed directly.
|
@@ -405,6 +413,9 @@ Your theme folder can be found by browsing to `/wp-content/themes/your-theme-nam
|
|
405 |
|
406 |
== Upgrade Notice ==
|
407 |
|
|
|
|
|
|
|
408 |
= 1.4.5 =
|
409 |
Bugfix: fixed invalid email address message after updating to 1.4.4
|
410 |
|
3 |
Donate link: http://dannyvankooten.com/donate/
|
4 |
Tags: mailchimp, widget, form, checkbox, sign-up form, mandrill, buddypress, multisite, bbpress, contact form 7, newsletter, mailinglist, cf7
|
5 |
Requires at least: 3.1
|
6 |
+
Tested up to: 3.8
|
7 |
+
Stable tag: 1.4.8
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
186 |
|
187 |
== Changelog ==
|
188 |
|
189 |
+
= 1.4.8 - 10 December 2013 =
|
190 |
+
* Fixed: "bug" that fetched lists again on every plugin settings page - huge performance improvements on the settings pages.
|
191 |
+
* Improved: Longer cache time for combined CSS file.
|
192 |
+
* Improved: Prevented indexing of plugin directories
|
193 |
+
* Improved: Improved default checkbox CSS for themes that have custom checkbox styling.
|
194 |
+
* Improved: Better scroll to form element after form submit. Vertically centers form element with and without jQuery now. No ugly page jump.
|
195 |
+
* Improved: WP 3.8 Admin CSS compatibility and other improvements to settings pages, especially for small(er) screens.
|
196 |
+
|
197 |
= 1.4.7 - December 4, 2013 =
|
198 |
* Fixed: Checkbox width not being reset when loading default CSS.
|
199 |
* Improved: Minor security improvement to prevent some plugin files from being accessed directly.
|
413 |
|
414 |
== Upgrade Notice ==
|
415 |
|
416 |
+
= 1.4.8 =
|
417 |
+
WP 3.8 compatibility, better scroll to form and huge settings page performance improvement
|
418 |
+
|
419 |
= 1.4.5 =
|
420 |
Bugfix: fixed invalid email address message after updating to 1.4.4
|
421 |
|
uninstall.php
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
//if uninstall not called from WordPress exit
|
4 |
-
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
|
5 |
-
|
|
|
|
|
6 |
|
7 |
delete_option('mc4wp_lite');
|
8 |
delete_option('mc4wp_lite_checkbox');
|
1 |
<?php
|
2 |
|
3 |
//if uninstall not called from WordPress exit
|
4 |
+
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
5 |
+
exit();
|
6 |
+
}
|
7 |
+
|
8 |
|
9 |
delete_option('mc4wp_lite');
|
10 |
delete_option('mc4wp_lite_checkbox');
|