MailChimp Forms by MailMunch - Version 3.0.1

Version Description

Download this release

Release Info

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

Code changes from version 3.0.0 to 3.0.1

admin/class-mailchimp-mailmunch-admin.php CHANGED
@@ -144,7 +144,12 @@ class Mailchimp_Mailmunch_Admin {
144
  add_menu_page( $this->integration_name, $this->integration_name, 'manage_options', MAILCHIMP_MAILMUNCH_SLUG, array($this, 'get_dashboard_html'), plugins_url( 'img/icon.png', __FILE__ ), 103.786);
145
 
146
  add_submenu_page( MAILCHIMP_MAILMUNCH_SLUG, $this->integration_name, 'Forms', 'manage_options', MAILCHIMP_MAILMUNCH_SLUG, array($this, 'get_dashboard_html') );
147
- add_submenu_page( MAILCHIMP_MAILMUNCH_SLUG, $this->integration_name. ' Landing Pages', 'Landing Pages', 'manage_options', 'edit.php?post_type='. MAILCHIMP_MAILMUNCH_POST_TYPE );
 
 
 
 
 
148
  add_submenu_page( MAILCHIMP_MAILMUNCH_SLUG, $this->integration_name. ' Settings', 'Settings', 'manage_options', MAILCHIMP_MAILMUNCH_SLUG. '-settings', array($this, 'settings_page') );
149
  }
150
 
@@ -274,6 +279,7 @@ class Mailchimp_Mailmunch_Admin {
274
  $this->initiate_api();
275
  if ($_POST) {
276
  $this->mailmunch_api->setSetting('auto_embed', $_POST['auto_embed']);
 
277
  }
278
  require_once(plugin_dir_path(__FILE__) . 'partials/mailchimp-mailmunch-settings.php');
279
  }
144
  add_menu_page( $this->integration_name, $this->integration_name, 'manage_options', MAILCHIMP_MAILMUNCH_SLUG, array($this, 'get_dashboard_html'), plugins_url( 'img/icon.png', __FILE__ ), 103.786);
145
 
146
  add_submenu_page( MAILCHIMP_MAILMUNCH_SLUG, $this->integration_name, 'Forms', 'manage_options', MAILCHIMP_MAILMUNCH_SLUG, array($this, 'get_dashboard_html') );
147
+
148
+ $landingPagesEnabled = get_option(MAILCHIMP_MAILMUNCH_PREFIX. '_landing_pages_enabled');
149
+ if (empty($landingPagesEnabled) || $landingPagesEnabled == 'yes') {
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
 
279
  $this->initiate_api();
280
  if ($_POST) {
281
  $this->mailmunch_api->setSetting('auto_embed', $_POST['auto_embed']);
282
+ $this->mailmunch_api->setSetting('landing_pages_enabled', $_POST['landing_pages_enabled']);
283
  }
284
  require_once(plugin_dir_path(__FILE__) . 'partials/mailchimp-mailmunch-settings.php');
285
  }
admin/partials/mailchimp-mailmunch-settings.php CHANGED
@@ -1,5 +1,8 @@
1
  <form method="POST" id="mailchimp-settings">
2
- <?php $autoEmbed = $this->mailmunch_api->getSetting('auto_embed'); ?>
 
 
 
3
  <div id="poststuff" class="wrap">
4
  <div id="post-body" class="metabox-holder columns-2">
5
  <div id="post-body-content">
@@ -23,6 +26,18 @@
23
  </select>
24
  </td>
25
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
26
  <tr>
27
  <td colspan="2">
28
  <input type="submit" name="Save" value="Save Settings" class="button button-primary" />
1
  <form method="POST" id="mailchimp-settings">
2
+ <?php
3
+ $autoEmbed = $this->mailmunch_api->getSetting('auto_embed');
4
+ $landingPagesEnabled = $this->mailmunch_api->getSetting('landing_pages_enabled');
5
+ ?>
6
  <div id="poststuff" class="wrap">
7
  <div id="post-body" class="metabox-holder columns-2">
8
  <div id="post-body-content">
26
  </select>
27
  </td>
28
  </tr>
29
+ <tr>
30
+ <td class="inside-container" width="30%">
31
+ <h3>Enable Landing Pages</h3>
32
+ <p>If enabled, you will be able to use MailMunch landing pages and create pages from within your Wordpress admin.</p>
33
+ </td>
34
+ <td class="setting">
35
+ <select name="landing_pages_enabled">
36
+ <option value="yes"<?php if ($landingPagesEnabled == 'yes' || empty($landingPagesEnabled)) echo "selected=\"selected\""; ?>>Yes</option>
37
+ <option value="no"<?php if ($landingPagesEnabled == 'no') echo "selected=\"selected\""; ?>>No</option>
38
+ </select>
39
+ </td>
40
+ </tr>
41
  <tr>
42
  <td colspan="2">
43
  <input type="submit" name="Save" value="Save Settings" class="button button-primary" />
includes/class-mailchimp-mailmunch-post-type.php CHANGED
@@ -139,5 +139,13 @@ class Mailchimp_Mailmunch_Post_Type {
139
  }
140
  }
141
 
142
-
 
 
 
 
 
 
 
 
143
  }
139
  }
140
  }
141
 
142
+ public function add_pages_to_dropdown($pages, $r) {
143
+ if ('page_on_front' == $r['name']) {
144
+ $args = array('post_type' => MAILCHIMP_MAILMUNCH_POST_TYPE);
145
+ $stacks = get_posts($args);
146
+ $pages = array_merge($pages, $stacks);
147
+ }
148
+
149
+ return $pages;
150
+ }
151
  }
includes/class-mailchimp-mailmunch-rewrite.php CHANGED
@@ -76,6 +76,16 @@ class Mailchimp_Mailmunch_Rewrite {
76
  return $slug;
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
79
  /**
80
  * Regenerate rewrite rules for each custom page
81
  *
76
  return $slug;
77
  }
78
 
79
+ public function enable_front_page_landing_pages($query) {
80
+ if (array_key_exists('post_type', $query->query_vars)) {
81
+ $postType = $query->query_vars['post_type'];
82
+ }
83
+
84
+ if ('' == $postType && 0 != $query->query_vars['page_id']) {
85
+ $query->query_vars['post_type'] = array('page', MAILCHIMP_MAILMUNCH_POST_TYPE);
86
+ }
87
+ }
88
+
89
  /**
90
  * Regenerate rewrite rules for each custom page
91
  *
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.0' );
26
 
27
  /**
28
  * The core plugin class.
@@ -107,7 +107,10 @@ class Mailchimp_Mailmunch {
107
  $this->define_admin_hooks();
108
  }
109
  $this->define_public_hooks();
110
- $this->define_post_type();
 
 
 
111
  }
112
 
113
  /**
@@ -259,9 +262,9 @@ class Mailchimp_Mailmunch {
259
  private function define_post_type() {
260
  // Landing Page
261
  $plugin_post_type = new Mailchimp_Mailmunch_Post_Type();
262
- $this->loader->add_action( 'init', $plugin_post_type, 'create_post_type' );
263
- $this->loader->add_filter( 'template_include', $plugin_post_type, 'post_type_template' );
264
-
265
  $this->loader->add_action('add_meta_boxes', $plugin_post_type, 'post_meta_box', 10, 2);
266
  $this->loader->add_action('save_post', $plugin_post_type, 'landing_page_save_meta', 10, 2 );
267
 
@@ -269,6 +272,7 @@ class Mailchimp_Mailmunch {
269
  $this->loader->add_action('init', $plugin_rewrite, 'init');
270
  $this->loader->add_action('save_post', $plugin_rewrite, 'on_save_post');
271
  $this->loader->add_action('wp_insert_post', $plugin_rewrite, 'on_wp_insert_post');
 
272
  $this->loader->add_filter('post_type_link', $plugin_rewrite, 'on_post_type_link');
273
  $this->loader->add_filter('wp_unique_post_slug', $plugin_rewrite, 'on_wp_unique_post_slug', 10, 6);
274
  }
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.1' );
26
 
27
  /**
28
  * The core plugin class.
107
  $this->define_admin_hooks();
108
  }
109
  $this->define_public_hooks();
110
+ $landingPagesEnabled = get_option(MAILCHIMP_MAILMUNCH_PREFIX. '_landing_pages_enabled');
111
+ if (empty($landingPagesEnabled) || $landingPagesEnabled == 'yes') {
112
+ $this->define_post_type();
113
+ }
114
  }
115
 
116
  /**
262
  private function define_post_type() {
263
  // Landing Page
264
  $plugin_post_type = new Mailchimp_Mailmunch_Post_Type();
265
+ $this->loader->add_action('init', $plugin_post_type, 'create_post_type');
266
+ $this->loader->add_filter('template_include', $plugin_post_type, 'post_type_template');
267
+ $this->loader->add_filter('get_pages', $plugin_post_type, 'add_pages_to_dropdown', 10, 2);
268
  $this->loader->add_action('add_meta_boxes', $plugin_post_type, 'post_meta_box', 10, 2);
269
  $this->loader->add_action('save_post', $plugin_post_type, 'landing_page_save_meta', 10, 2 );
270
 
272
  $this->loader->add_action('init', $plugin_rewrite, 'init');
273
  $this->loader->add_action('save_post', $plugin_rewrite, 'on_save_post');
274
  $this->loader->add_action('wp_insert_post', $plugin_rewrite, 'on_wp_insert_post');
275
+ $this->loader->add_action('pre_get_posts', $plugin_rewrite, 'enable_front_page_landing_pages', 11);
276
  $this->loader->add_filter('post_type_link', $plugin_rewrite, 'on_post_type_link');
277
  $this->loader->add_filter('wp_unique_post_slug', $plugin_rewrite, 'on_wp_unique_post_slug', 10, 6);
278
  }
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.0
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.1
20
  * Author: MailMunch
21
  * Author URI: http://www.mailmunch.co
22
  * License: GPL-2.0+
public/mailchimp-mailmunch-landing-page.php CHANGED
@@ -1,11 +1,43 @@
1
  <?php
2
  $landing_page_id = get_post_meta( get_the_ID(), '_mailmunch_landing_page_id', true );
3
- $response = wp_remote_get(MAILCHIMP_MAILMUNCH_PAGE_SERVICE_URL. '/'. $landing_page_id);
 
 
 
 
4
  if ( is_array( $response ) && ! is_wp_error( $response ) ) {
5
- echo $response['body'];
 
 
 
 
6
  } else {
7
  status_header( 404 );
8
  nocache_headers();
9
  include( get_query_template( '404' ) );
10
  die();
11
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  $landing_page_id = get_post_meta( get_the_ID(), '_mailmunch_landing_page_id', true );
3
+ $response = wp_remote_get(MAILCHIMP_MAILMUNCH_PAGE_SERVICE_URL. '/'. $landing_page_id, array(
4
+ 'headers' => array(
5
+ 'X-MailMunch-JSON' => 1
6
+ )
7
+ ));
8
  if ( is_array( $response ) && ! is_wp_error( $response ) ) {
9
+ $landingPageJson = json_decode($response['body']);
10
+ $pageHead = $landingPageJson->head;
11
+ $pageBody = $landingPageJson->body;
12
+ $pageTitle = $landingPageJson->title;
13
+ $pageScreenshotUrl = $landingPageJson->screenshotUrl;
14
  } else {
15
  status_header( 404 );
16
  nocache_headers();
17
  include( get_query_template( '404' ) );
18
  die();
19
  }
20
+ ?>
21
+ <!DOCTYPE html>
22
+ <html lang="en">
23
+ <head>
24
+ <meta charset="UTF-8">
25
+ <meta name=viewport content="width=device-width, initial-scale=1">
26
+ <meta property="og:type" content="website" />
27
+ <meta property="og:image" content="<?php echo $pageScreenshotUrl ?>" />
28
+ <meta property="og:image:width" content="600" />
29
+ <meta property="og:image:height" content="600" />
30
+ <title><?php echo wp_title(''); ?></title>
31
+ <?php echo wp_head(); ?>
32
+
33
+ <style type="text/css" media="screen">
34
+ html { margin-top: 0px !important; }
35
+ * html body { margin-top: 0px !important; }
36
+ </style>
37
+
38
+ <?php echo $pageHead; ?>
39
+ </head>
40
+ <body>
41
+ <?php echo $pageBody; ?>
42
+ </body>
43
+ </html>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: mailchimp, MailChimp form, MailChimp plugin, mailchimp popup, mailchimp ne
4
 
5
  Requires at least: 3.8
6
  Tested up to: 4.7.3
7
- Stable tag: 3.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -189,6 +189,10 @@ If you have been looking for the best email marketing software programs, look no
189
 
190
  == Changelog ==
191
 
 
 
 
 
192
  = MailChimp Forms 3.0.0 =
193
  * Landing Pages with MailChimp forms
194
 
4
 
5
  Requires at least: 3.8
6
  Tested up to: 4.7.3
7
+ Stable tag: 3.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
189
 
190
  == Changelog ==
191
 
192
+ = MailChimp Forms 3.0.1 =
193
+ * Use landing pages as home page
194
+ * Fixed SEO plugins
195
+
196
  = MailChimp Forms 3.0.0 =
197
  * Landing Pages with MailChimp forms
198