MailChimp Forms by MailMunch - Version 3.0.7

Version Description

Download this release

Release Info

Developer mailmunch
Plugin Icon 128x128 MailChimp Forms by MailMunch
Version 3.0.7
Comparing to
See all releases

Code changes from version 3.0.6 to 3.0.7

admin/class-mailchimp-mailmunch-admin.php CHANGED
@@ -133,6 +133,18 @@ class Mailchimp_Mailmunch_Admin {
133
  echo json_encode($this->mailmunch_api->deleteWidget($_POST['widget_id']));
134
  exit;
135
  }
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
  /**
138
  * Register menu for the admin area
@@ -150,6 +162,7 @@ class Mailchimp_Mailmunch_Admin {
150
  add_submenu_page( MAILCHIMP_MAILMUNCH_SLUG, $this->integration_name. ' Landing Pages', 'Landing Pages', 'manage_options', 'edit.php?post_type='. MAILCHIMP_MAILMUNCH_POST_TYPE );
151
  }
152
 
 
153
  add_submenu_page( MAILCHIMP_MAILMUNCH_SLUG, $this->integration_name. ' Settings', 'Settings', 'manage_options', MAILCHIMP_MAILMUNCH_SLUG. '-settings', array($this, 'settings_page') );
154
  }
155
 
@@ -284,6 +297,16 @@ class Mailchimp_Mailmunch_Admin {
284
  require_once(plugin_dir_path(__FILE__) . 'partials/mailchimp-mailmunch-settings.php');
285
  }
286
 
 
 
 
 
 
 
 
 
 
 
287
  /**
288
  * Dashboard Widget
289
  *
@@ -303,8 +326,9 @@ class Mailchimp_Mailmunch_Admin {
303
  $html .= '<div class="mailmunch-dash-widget-inner">';
304
  $html .= '<p>Welcome to MailChimp Forms by MailMunch! The #1 plugin to grow your MailChimp email list.</p>';
305
  $html .= '<div>';
306
- $html .= '<a class="mailmunch-dash-option" href="'. admin_url('admin.php?page='.MAILCHIMP_MAILMUNCH_SLUG) .'"><span class="dashicons dashicons-editor-table"></span><span class="mailmunch-dash-text">Forms</span></a>';
307
  $html .= '<a class="mailmunch-dash-option" href="'. admin_url('edit.php?post_type='.MAILCHIMP_MAILMUNCH_POST_TYPE) .'"><span class="dashicons dashicons-admin-page"></span><span class="mailmunch-dash-text">Landing Pages</span></a>';
 
308
  $html .= '</div>';
309
  $html .= '</div>';
310
  $html .= '</div>';
133
  echo json_encode($this->mailmunch_api->deleteWidget($_POST['widget_id']));
134
  exit;
135
  }
136
+
137
+ public function change_email_status() {
138
+ $this->initiate_api();
139
+ echo json_encode($this->mailmunch_api->changeEmailStatus($_POST['email_id'], $_POST['email_status']));
140
+ exit;
141
+ }
142
+
143
+ public function delete_email() {
144
+ $this->initiate_api();
145
+ echo json_encode($this->mailmunch_api->deleteEmail($_POST['email_id']));
146
+ exit;
147
+ }
148
 
149
  /**
150
  * Register menu for the admin area
162
  add_submenu_page( MAILCHIMP_MAILMUNCH_SLUG, $this->integration_name. ' Landing Pages', 'Landing Pages', 'manage_options', 'edit.php?post_type='. MAILCHIMP_MAILMUNCH_POST_TYPE );
163
  }
164
 
165
+ add_submenu_page( MAILCHIMP_MAILMUNCH_SLUG, $this->integration_name. ' Autoresponders', 'Autoresponders', 'manage_options', MAILCHIMP_MAILMUNCH_SLUG. '-autoresponders', array($this, 'autoresponders_page') );
166
  add_submenu_page( MAILCHIMP_MAILMUNCH_SLUG, $this->integration_name. ' Settings', 'Settings', 'manage_options', MAILCHIMP_MAILMUNCH_SLUG. '-settings', array($this, 'settings_page') );
167
  }
168
 
297
  require_once(plugin_dir_path(__FILE__) . 'partials/mailchimp-mailmunch-settings.php');
298
  }
299
 
300
+ /**
301
+ * Autoresponders Page
302
+ *
303
+ * @since 3.0.7
304
+ */
305
+ public function autoresponders_page() {
306
+ $this->initiate_api();
307
+ require_once(plugin_dir_path(__FILE__) . 'partials/mailchimp-mailmunch-autoresponders.php');
308
+ }
309
+
310
  /**
311
  * Dashboard Widget
312
  *
326
  $html .= '<div class="mailmunch-dash-widget-inner">';
327
  $html .= '<p>Welcome to MailChimp Forms by MailMunch! The #1 plugin to grow your MailChimp email list.</p>';
328
  $html .= '<div>';
329
+ $html .= '<a class="mailmunch-dash-option" href="'. admin_url('admin.php?page='.MAILCHIMP_MAILMUNCH_SLUG) .'"><span class="dashicons dashicons-editor-table"></span><span class="mailmunch-dash-text">Forms & Popups</span></a>';
330
  $html .= '<a class="mailmunch-dash-option" href="'. admin_url('edit.php?post_type='.MAILCHIMP_MAILMUNCH_POST_TYPE) .'"><span class="dashicons dashicons-admin-page"></span><span class="mailmunch-dash-text">Landing Pages</span></a>';
331
+ $html .= '<a class="mailmunch-dash-option" href="'. admin_url('admin.php?page='.MAILCHIMP_MAILMUNCH_SLUG.'-autoresponders') .'"><span class="dashicons dashicons-email-alt"></span><span class="mailmunch-dash-text">Autoresponders</span></a>';
332
  $html .= '</div>';
333
  $html .= '</div>';
334
  $html .= '</div>';
admin/css/mailchimp-mailmunch-admin.css CHANGED
@@ -511,19 +511,18 @@ label.mailmunch-form-label {
511
  }
512
 
513
  .mailmunch-dash-option {
514
- display: inline-block;
515
- width: 100px;
516
- height: 80px;
517
  vertical-align: middle;
518
  border: 1px solid #EEE;
519
  border-radius: 10px;
520
  background-color: #FFF;
521
- text-align: center;
522
- padding: 20px;
523
- margin-right: 15px;
524
- margin-bottom: 15px;
525
  cursor: pointer;
526
- font-size: 14px;
527
  }
528
 
529
  .mailmunch-dash-option:hover {
@@ -531,16 +530,14 @@ label.mailmunch-form-label {
531
  }
532
 
533
  .mailmunch-dash-option .dashicons {
534
- font-size: 60px;
535
- width: 60px;
536
- height: 60px;
537
- display: block;
538
- margin: 0 auto;
539
- text-align: center;
540
  }
541
 
542
  .mailmunch-dash-option .mailmunch-dash-text {
543
- display: block;
544
- margin: 0 auto;
545
- text-align: center;
546
  }
511
  }
512
 
513
  .mailmunch-dash-option {
514
+ display: block;
515
+ width: 200px;
516
+ height: 35px;
517
  vertical-align: middle;
518
  border: 1px solid #EEE;
519
  border-radius: 10px;
520
  background-color: #FFF;
521
+ text-align: left;
522
+ padding: 10px 20px;
523
+ margin: 0 auto 15px;
 
524
  cursor: pointer;
525
+ font-size: 16px;
526
  }
527
 
528
  .mailmunch-dash-option:hover {
530
  }
531
 
532
  .mailmunch-dash-option .dashicons {
533
+ font-size: 35px;
534
+ width: 35px;
535
+ height: 35px;
536
+ display: inline-block;
537
+ vertical-align: middle;
538
+ margin-right: 5px;
539
  }
540
 
541
  .mailmunch-dash-option .mailmunch-dash-text {
542
+
 
 
543
  }
admin/js/mailchimp-mailmunch-admin.js CHANGED
@@ -77,6 +77,50 @@
77
  })
78
  return false;
79
  })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  $('#signup_form').submit(function(e) {
82
  e.preventDefault();
77
  })
78
  return false;
79
  })
80
+
81
+ $('.change-email-status').click(function() {
82
+ if (!confirm('Are you sure you want to change the status for this email?')) return false;
83
+ $.ajax({
84
+ url: ajaxurl,
85
+ type: 'POST',
86
+ data: {action: 'change_email_status', email_status: $(this).data('email-status'), email_id: $(this).data('email-id')},
87
+ dataType: 'json',
88
+ success: function(data) {
89
+ if (data.success) {
90
+ window.location.reload();
91
+ }
92
+ else {
93
+ alert('There was an error. Please try again later.');
94
+ }
95
+ }.bind(this),
96
+ error: function(data) {
97
+ alert('There was an error. Please try again later.');
98
+ }
99
+ })
100
+ return false;
101
+ })
102
+
103
+ $('.delete-email').click(function() {
104
+ if (!confirm('Are you sure you want to delete this email?')) return false;
105
+ $.ajax({
106
+ url: ajaxurl,
107
+ type: 'POST',
108
+ data: {action: 'delete_email', email_id: $(this).data('email-id')},
109
+ dataType: 'json',
110
+ success: function(data) {
111
+ if (data.success) {
112
+ $(this).parents('tr').slideUp();
113
+ }
114
+ else {
115
+ alert('There was an error. Please try again later.');
116
+ }
117
+ }.bind(this),
118
+ error: function(data) {
119
+ alert('There was an error. Please try again later.');
120
+ }
121
+ })
122
+ return false;
123
+ })
124
 
125
  $('#signup_form').submit(function(e) {
126
  e.preventDefault();
admin/partials/mailchimp-mailmunch-autoresponders.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a autoresponders admin area view for the plugin
5
+ *
6
+ * @link http://www.mailmunch.co
7
+ * @since 3.0.7
8
+ *
9
+ * @package Mailchimp_Mailmunch
10
+ * @subpackage Mailchimp_Mailmunch/admin/partials
11
+ */
12
+ ?>
13
+
14
+ <?php echo $this->mailmunch_api->getAutorespondersHtml(); ?>
includes/class-mailchimp-mailmunch.php CHANGED
@@ -22,7 +22,7 @@ define( 'MAILCHIMP_MAILMUNCH_SLUG', "mailchimp-mailmunch" );
22
  define( 'MAILCHIMP_MAILMUNCH_PREFIX', 'mc_mm' );
23
  define( 'MAILCHIMP_MAILMUNCH_POST_TYPE', 'mailmunch_page' );
24
  define( 'MAILCHIMP_MAILMUNCH_PLUGIN_DIRECTORY', 'mailchimp-forms-by-mailmunch' );
25
- define( 'MAILCHIMP_MAILMUNCH_VERSION', '3.0.6' );
26
 
27
  /**
28
  * The core plugin class.
@@ -217,6 +217,8 @@ class Mailchimp_Mailmunch {
217
  $this->loader->add_action( 'wp_ajax_sign_up', $plugin_admin, 'sign_up' );
218
  $this->loader->add_action( 'wp_ajax_sign_in', $plugin_admin, 'sign_in' );
219
  $this->loader->add_action( 'wp_ajax_delete_widget', $plugin_admin, 'delete_widget' );
 
 
220
 
221
  // Dashboard
222
  $this->loader->add_action( 'wp_dashboard_setup', $plugin_admin, 'dashboard_setup' );
22
  define( 'MAILCHIMP_MAILMUNCH_PREFIX', 'mc_mm' );
23
  define( 'MAILCHIMP_MAILMUNCH_POST_TYPE', 'mailmunch_page' );
24
  define( 'MAILCHIMP_MAILMUNCH_PLUGIN_DIRECTORY', 'mailchimp-forms-by-mailmunch' );
25
+ define( 'MAILCHIMP_MAILMUNCH_VERSION', '3.0.7' );
26
 
27
  /**
28
  * The core plugin class.
217
  $this->loader->add_action( 'wp_ajax_sign_up', $plugin_admin, 'sign_up' );
218
  $this->loader->add_action( 'wp_ajax_sign_in', $plugin_admin, 'sign_in' );
219
  $this->loader->add_action( 'wp_ajax_delete_widget', $plugin_admin, 'delete_widget' );
220
+ $this->loader->add_action( 'wp_ajax_delete_email', $plugin_admin, 'delete_email' );
221
+ $this->loader->add_action( 'wp_ajax_change_email_status', $plugin_admin, 'change_email_status' );
222
 
223
  // Dashboard
224
  $this->loader->add_action( 'wp_dashboard_setup', $plugin_admin, 'dashboard_setup' );
includes/class-mailmunch-api.php CHANGED
@@ -277,6 +277,19 @@
277
  $body = str_replace('{{TOKEN}}', $this->getUserToken(), $request['body']);
278
  return $body;
279
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
280
 
281
  function getSiteId() {
282
  return get_option($this->getPrefix(). 'site_id');
@@ -302,6 +315,28 @@
302
  }
303
  return array('success' => true);
304
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
 
306
  function signInUser($email, $password) {
307
  $this->requestType = 'post';
@@ -379,13 +414,21 @@
379
  'timeout' => 120,
380
  );
381
 
382
- if ($type != 'post') {
383
- $request = wp_remote_get($url, $args);
384
- }
385
- else {
386
  $args = array_merge($args, array('method' => 'POST', 'body' => $options));
387
  $request = wp_remote_post($url, $args);
388
  }
 
 
 
 
 
 
 
 
 
 
 
389
 
390
  if ( !is_wp_error( $request ) && ( $request['response']['code'] == 500 || $request['response']['code'] == 503 ) ) {
391
  return new WP_Error( 'broke', "Internal Server Error" );
277
  $body = str_replace('{{TOKEN}}', $this->getUserToken(), $request['body']);
278
  return $body;
279
  }
280
+
281
+ function getAutorespondersHtml($siteId=null) {
282
+ if (empty($siteId)) { $siteId = $this->getSiteId(); }
283
+
284
+ $this->requestType = 'get';
285
+ $request = $this->ping('/sites/'.$siteId.'/autoresponders/wordpress?plugin=mailchimp');
286
+ if( is_wp_error( $request ) ) {
287
+ return $request->get_error_message();
288
+ }
289
+
290
+ $body = str_replace('{{TOKEN}}', $this->getUserToken(), $request['body']);
291
+ return $body;
292
+ }
293
 
294
  function getSiteId() {
295
  return get_option($this->getPrefix(). 'site_id');
315
  }
316
  return array('success' => true);
317
  }
318
+
319
+ function changeEmailStatus($emailId, $emailStatus) {
320
+ $this->requestType = 'put';
321
+ $request = $this->ping('/sites/'.$this->getSiteId().'/emails/'.$emailId, array(
322
+ 'email' => array(
323
+ 'status' => $emailStatus
324
+ )
325
+ ));
326
+ if ( is_wp_error( $request ) ) {
327
+ return array('success' => false);
328
+ }
329
+ return array('success' => true);
330
+ }
331
+
332
+ function deleteEmail($emailId) {
333
+ $this->requestType = 'delete';
334
+ $request = $this->ping('/sites/'.$this->getSiteId().'/emails/'.$emailId);
335
+ if ( is_wp_error( $request ) ) {
336
+ return array('success' => false);
337
+ }
338
+ return array('success' => true);
339
+ }
340
 
341
  function signInUser($email, $password) {
342
  $this->requestType = 'post';
414
  'timeout' => 120,
415
  );
416
 
417
+ if ($type == 'post') {
 
 
 
418
  $args = array_merge($args, array('method' => 'POST', 'body' => $options));
419
  $request = wp_remote_post($url, $args);
420
  }
421
+ else if ($type == 'put') {
422
+ $args = array_merge($args, array('method' => 'PUT', 'body' => $options));
423
+ $request = wp_remote_request($url, $args);
424
+ }
425
+ else if ($type == 'delete') {
426
+ $args = array_merge($args, array('method' => 'DELETE', 'body' => $options));
427
+ $request = wp_remote_request($url, $args);
428
+ }
429
+ else {
430
+ $request = wp_remote_get($url, $args);
431
+ }
432
 
433
  if ( !is_wp_error( $request ) && ( $request['response']['code'] == 500 || $request['response']['code'] == 503 ) ) {
434
  return new WP_Error( 'broke', "Internal Server Error" );
mailchimp-mailmunch.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: MailChimp Forms by MailMunch
17
  * Plugin URI: http://connect.mailchimp.com/integrations/mailmunch-email-list-builder
18
  * Description: The MailChimp plugin allows you to quickly and easily add signup forms for your MailChimp lists. Popup, Embedded, Top Bar and a variety of different options available.
19
- * Version: 3.0.6
20
  * Author: MailMunch
21
  * Author URI: http://www.mailmunch.co
22
  * License: GPL-2.0+
16
  * Plugin Name: MailChimp Forms by MailMunch
17
  * Plugin URI: http://connect.mailchimp.com/integrations/mailmunch-email-list-builder
18
  * Description: The MailChimp plugin allows you to quickly and easily add signup forms for your MailChimp lists. Popup, Embedded, Top Bar and a variety of different options available.
19
+ * Version: 3.0.7
20
  * Author: MailMunch
21
  * Author URI: http://www.mailmunch.co
22
  * License: GPL-2.0+
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: mailmunch, lizgannes, mailchimpzain, adeelraza, jessicabrownmm
3
  Donate link: https://www.mailmunch.co/pricing/?utm_source=wp-plugin-repo&utm_medium=mailchimp-mailmunch&utm_campaign=donate-link
4
  Tags: MailChimp, MailChimp forms, MailChimp lists, opt-in forms, sign up form, MailChimp, email, forms, mailing lists, marketing, newsletter, sign up
5
  Requires at least: 4.0
6
- Tested up to: 4.8
7
- Stable tag: 3.0.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
3
  Donate link: https://www.mailmunch.co/pricing/?utm_source=wp-plugin-repo&utm_medium=mailchimp-mailmunch&utm_campaign=donate-link
4
  Tags: MailChimp, MailChimp forms, MailChimp lists, opt-in forms, sign up form, MailChimp, email, forms, mailing lists, marketing, newsletter, sign up
5
  Requires at least: 4.0
6
+ Tested up to: 4.9
7
+ Stable tag: 3.0.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10