MailMunch – Grow your Email List - Version 3.0.0

Version Description

  • Landing pages
Download this release

Release Info

Developer mailmunch
Plugin Icon 128x128 MailMunch – Grow your Email List
Version 3.0.0
Comparing to
See all releases

Code changes from version 2.0.4 to 3.0.0

admin/class-mailmunch-admin.php CHANGED
@@ -144,7 +144,8 @@ class Mailmunch_Admin {
144
  add_menu_page( $this->integration_name, $this->integration_name, 'manage_options', MAILMUNCH_SLUG, array($this, 'get_dashboard_html'), plugins_url( 'img/icon.png', __FILE__ ), 105.786);
145
 
146
  add_submenu_page( MAILMUNCH_SLUG, $this->integration_name, 'Forms', 'manage_options', MAILMUNCH_SLUG, array($this, 'get_dashboard_html') );
147
- add_submenu_page( MAILMUNCH_SLUG, $this->integration_name. ' Settings', 'Settings', 'manage_options', MAILMUNCH_SLUG. '-settings', array($this, 'settings_page') );
 
148
  }
149
 
150
  /**
@@ -259,6 +260,33 @@ class Mailmunch_Admin {
259
  wp_redirect($url);
260
  }
261
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
 
263
  /**
264
  * Get Dashboard HTML
144
  add_menu_page( $this->integration_name, $this->integration_name, 'manage_options', MAILMUNCH_SLUG, array($this, 'get_dashboard_html'), plugins_url( 'img/icon.png', __FILE__ ), 105.786);
145
 
146
  add_submenu_page( MAILMUNCH_SLUG, $this->integration_name, 'Forms', 'manage_options', MAILMUNCH_SLUG, array($this, 'get_dashboard_html') );
147
+ add_submenu_page( MAILMUNCH_SLUG, $this->integration_name. 'Landing Pages', 'Landing Pages', 'manage_options', 'edit.php?post_type='. MAILMUNCH_POST_TYPE );
148
+ add_submenu_page( MAILMUNCH_SLUG, $this->integration_name. 'Settings', 'Settings', 'manage_options', MAILMUNCH_SLUG. '-settings', array($this, 'settings_page') );
149
  }
150
 
151
  /**
260
  wp_redirect($url);
261
  }
262
  }
263
+
264
+ /**
265
+ * Dashboard Widget
266
+ *
267
+ * @since 3.0.0
268
+ */
269
+ public function dashboard_setup() {
270
+ add_meta_box( 'mailmunch_dashboard_widget', 'MailMunch', array($this , 'dashboard_widget'), 'dashboard', 'normal', 'high');
271
+ }
272
+
273
+ /**
274
+ * Dashboard Widget
275
+ *
276
+ * @since 3.0.0
277
+ */
278
+ public function dashboard_widget() {
279
+ $html = '<div class="mailmunch-dash-widget">';
280
+ $html .= '<div class="mailmunch-dash-widget-inner">';
281
+ $html .= '<p>Welcome to MailMunch! The #1 plugin to grow your email list.</p>';
282
+ $html .= '<div>';
283
+ $html .= '<a class="mailmunch-dash-option" href="'. admin_url('admin.php?page='.MAILMUNCH_SLUG) .'"><span class="dashicons dashicons-editor-table"></span><span class="mailmunch-dash-text">Forms</span></a>';
284
+ $html .= '<a class="mailmunch-dash-option" href="'. admin_url('edit.php?post_type='.MAILMUNCH_POST_TYPE) .'"><span class="dashicons dashicons-admin-page"></span><span class="mailmunch-dash-text">Landing Pages</span></a>';
285
+ $html .= '</div>';
286
+ $html .= '</div>';
287
+ $html .= '</div>';
288
+ echo $html;
289
+ }
290
 
291
  /**
292
  * Get Dashboard HTML
admin/css/mailmunch-admin.css CHANGED
@@ -389,4 +389,145 @@ label.mailmunch-form-label {
389
 
390
  .mailmunch-review-notice .mailmunch-buttons a {
391
  margin-right: 10px;
392
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
 
390
  .mailmunch-review-notice .mailmunch-buttons a {
391
  margin-right: 10px;
392
+ }
393
+
394
+ .mailmunch-landing-page {
395
+ padding: 3px 3px 0px;
396
+ border: 1px solid #CCC;
397
+ display: inline-block;
398
+ cursor: pointer;
399
+ margin-right: 10px;
400
+ margin-bottom: 10px;
401
+ opacity: 0.7;
402
+ width: 250px;
403
+ height: 278px;
404
+ text-decoration: none;
405
+ }
406
+
407
+ .mailmunch-landing-page .page-image img {
408
+ cursor: pointer;
409
+ }
410
+
411
+ .mailmunch-landing-page .page-image {
412
+ position: relative;
413
+ line-height: 0;
414
+ width: 250px;
415
+ height: 250px;
416
+ text-align: center;
417
+ }
418
+
419
+ .mailmunch-landing-page .page-name {
420
+ color: #444;
421
+ text-align: center;
422
+ padding: 5px;
423
+ font-size: 13px;
424
+ max-height: 18px;
425
+ white-space: nowrap;
426
+ text-overflow: ellipsis;
427
+ overflow: hidden;
428
+ }
429
+
430
+ .mailmunch-landing-page.active {
431
+ background-color: #0085ba;
432
+ opacity: 1;
433
+ }
434
+
435
+ .mailmunch-landing-page.active .page-name {
436
+ color: #FFF;
437
+ font-weight: bold;
438
+ }
439
+
440
+ .mailmunch-landing-page:not(.active):hover {
441
+ background-color: #EEE;
442
+ opacity: 1;
443
+ }
444
+
445
+ .mailmunch-landing-page .page-hover {
446
+ display: none;
447
+ width: 100%;
448
+ height: 100%;
449
+ background-color: rgba(0,0,0,0.7);
450
+ position: absolute;
451
+ left: 0px;
452
+ top: 0px;
453
+ }
454
+
455
+ .mailmunch-landing-page.active:hover .page-hover {
456
+ display: block;
457
+ }
458
+
459
+ .mailmunch-landing-page.active .page-hover .mailmunch-edit-page {
460
+ margin-top: 100px;
461
+ }
462
+
463
+ .mailmunch-landing-page img {
464
+ width: 250px;
465
+ height: 250px;
466
+ }
467
+
468
+ .mailmunch-landing-page.new-landing-page .page-image .dashicons-plus-alt {
469
+ font-size: 50px;
470
+ width: 50px;
471
+ height: 50px;
472
+ color: #999;
473
+ margin-top: 95px;
474
+ }
475
+
476
+ .mailmunch-landing-page.new-landing-page .new-page-title {
477
+ color: #999;
478
+ margin-top: 15px;
479
+ }
480
+
481
+
482
+ /* Dashboard Widget */
483
+ .mailmunch-dash-widget {
484
+ color: #FFF;
485
+ background: url('../img/dashboard.jpg');
486
+ background-size: cover;
487
+ }
488
+
489
+ .mailmunch-dash-widget-inner {
490
+ padding: 20px 20px 30px;
491
+ background: rgba(0,0,0,0.5);
492
+ text-align: center;
493
+ }
494
+
495
+ .mailmunch-dash-widget-inner p {
496
+ font-size: 16px;
497
+ font-weight: bold;
498
+ }
499
+
500
+ .mailmunch-dash-option {
501
+ display: inline-block;
502
+ width: 100px;
503
+ height: 80px;
504
+ vertical-align: middle;
505
+ border: 1px solid #EEE;
506
+ border-radius: 10px;
507
+ background-color: #FFF;
508
+ text-align: center;
509
+ padding: 20px;
510
+ margin-right: 15px;
511
+ margin-bottom: 15px;
512
+ cursor: pointer;
513
+ font-size: 14px;
514
+ }
515
+
516
+ .mailmunch-dash-option:hover {
517
+ border: 1px solid #CCC;
518
+ }
519
+
520
+ .mailmunch-dash-option .dashicons {
521
+ font-size: 60px;
522
+ width: 60px;
523
+ height: 60px;
524
+ display: block;
525
+ margin: 0 auto;
526
+ text-align: center;
527
+ }
528
+
529
+ .mailmunch-dash-option .mailmunch-dash-text {
530
+ display: block;
531
+ margin: 0 auto;
532
+ text-align: center;
533
+ }
admin/img/dashboard.jpg ADDED
Binary file
admin/js/mailmunch-admin.js CHANGED
@@ -114,8 +114,15 @@
114
  }
115
  })
116
  return false;
117
- })
118
-
 
 
 
 
 
 
 
119
  });
120
 
121
  })( jQuery );
114
  }
115
  })
116
  return false;
117
+ });
118
+
119
+
120
+ $(".mailmunch-landing-page").click(function() {
121
+ if ($(this).hasClass("new-landing-page")) return;
122
+ $(".mailmunch-landing-page").removeClass("active");
123
+ $(this).addClass("active");
124
+ $("#mailmunch_landing_page_id").val($(this).data("landing-page-id"));
125
+ });
126
  });
127
 
128
  })( jQuery );
admin/partials/mailmunch-settings.php CHANGED
@@ -3,9 +3,11 @@
3
  <div id="poststuff" class="wrap">
4
  <div id="post-body" class="metabox-holder columns-2">
5
  <div id="post-body-content">
6
- <h2>
7
- Settings | <?php echo $this->plugin_name; ?>
8
- </h2>
 
 
9
 
10
  <table class="wp-list-table widefat fixed posts settings-table">
11
  <tbody>
@@ -49,4 +51,4 @@
49
  </div>
50
  </div>
51
  </div>
52
- </form>
3
  <div id="poststuff" class="wrap">
4
  <div id="post-body" class="metabox-holder columns-2">
5
  <div id="post-body-content">
6
+ <div style="margin-bottom: 10px;">
7
+ <h1 class="wp-heading-inline">
8
+ Settings | <?php echo $this->plugin_name; ?>
9
+ </h1>
10
+ </div>
11
 
12
  <table class="wp-list-table widefat fixed posts settings-table">
13
  <tbody>
51
  </div>
52
  </div>
53
  </div>
54
+ </form>
includes/class-mailmunch-api.php CHANGED
@@ -93,6 +93,17 @@
93
 
94
  return json_decode($request['body']);
95
  }
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  function findOrCreateSite() {
98
  $site = $this->getSite();
93
 
94
  return json_decode($request['body']);
95
  }
96
+
97
+ function getLandingPages($siteId=null) {
98
+ if (empty($siteId)) { $siteId = $this->getSiteId(); }
99
+ $this->requestType = 'get';
100
+ $request = $this->ping('/sites/'. $siteId. '/landing_pages');
101
+ if( is_wp_error( $request ) ) {
102
+ return new WP_Error( 'broke', "Unable to get landing pages. Please try again later." );
103
+ }
104
+
105
+ return json_decode($request['body']);
106
+ }
107
 
108
  function findOrCreateSite() {
109
  $site = $this->getSite();
includes/class-mailmunch-post-type.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mailmunch_Post_Type {
3
+ /**
4
+ * Register custom post type for Landing Pages
5
+ *
6
+ * @since 3.0.0
7
+ */
8
+
9
+ public function initiate_api() {
10
+ if (empty($this->mailmunch_api)) {
11
+ $this->mailmunch_api = new Mailmunch_Api();
12
+ }
13
+ return $this->mailmunch_api;
14
+ }
15
+
16
+ public function create_post_type() {
17
+ // Register Custom Post Type
18
+ $labels = array(
19
+ 'name' => __( 'Landing Pages by MailMunch'),
20
+ 'singular_name' => __( 'MailMunch Page' ),
21
+ 'menu_name' => __( 'Landing Pages' ),
22
+ 'name_admin_bar' => __( 'Landing Page' ),
23
+ 'add_new' => __( 'Add New Page' ),
24
+ 'add_new_item' => __( 'Add New Page' ),
25
+ 'new_item' => __( 'New Page' ),
26
+ 'edit_item' => __( 'Edit Page' ),
27
+ 'view_item' => __( 'View Page' ),
28
+ 'all_items' => __( 'All Pages' ),
29
+ 'search_items' => __( 'Search Pages' ),
30
+ 'parent_item_colon' => __( 'Parent Pages:' ),
31
+ 'not_found' => __( 'No pages found.' ),
32
+ 'not_found_in_trash' => __( 'No pages found in Trash.' )
33
+ );
34
+
35
+ $args = array(
36
+ 'labels' => $labels,
37
+ 'menu_icon' => 'dashicons-admin-page',
38
+ 'public' => true,
39
+ 'publicly_queryable' => true,
40
+ 'show_ui' => true,
41
+ 'show_in_menu' => true,
42
+ 'query_var' => true,
43
+ 'rewrite' => array('with_front' => false, 'slug' => MAILMUNCH_POST_TYPE ),
44
+ 'capability_type' => 'post',
45
+ 'has_archive' => false,
46
+ 'hierarchical' => false,
47
+ 'menu_position' => 5,
48
+ 'supports' => array( 'title', 'author' )
49
+ );
50
+ register_post_type( MAILMUNCH_POST_TYPE, $args );
51
+ }
52
+
53
+ /**
54
+ * Template
55
+ */
56
+ public function post_type_template( $template ) {
57
+ global $post;
58
+ if ($post->post_type == MAILMUNCH_POST_TYPE) {
59
+ return plugin_dir_path( dirname( __FILE__ ) ) . 'public/mailmunch-landing-page.php';
60
+ }
61
+ return $template;
62
+ }
63
+
64
+ public function post_meta_box($postType, $post) {
65
+ if ($postType == MAILMUNCH_POST_TYPE) {
66
+ add_meta_box(
67
+ 'mailmunch_meta_choose_page',
68
+ 'Choose or Create New Page',
69
+ array($this, 'get_landing_pages_dropdown'),
70
+ array('post', MAILMUNCH_POST_TYPE),
71
+ 'normal',
72
+ 'high'
73
+ );
74
+ }
75
+ }
76
+
77
+ public function get_landing_pages_dropdown($post) {
78
+ $this->initiate_api();
79
+ $landing_pages = $this->mailmunch_api->getLandingPages();
80
+ $html = '<input type="hidden" name="mailmunch_landing_page_noncename" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
81
+ $key = '_mailmunch_landing_page_id';
82
+ $selected_landing_page_id = get_post_meta( $post->ID, $key, true );
83
+ $selected_landing_page_id = intval($selected_landing_page_id);
84
+ if (!$selected_landing_page_id) $selected_landing_page_id = $landing_pages[0]->id;
85
+ $html .= '<p>Create or choose the landing page that you want to activate here.</p>';
86
+ $html .= '<input id="mailmunch_landing_page_id" name="mailmunch_landing_page_id" type="hidden" value="'. $selected_landing_page_id .'" />';
87
+ foreach ($landing_pages as $key => $landing_page) {
88
+ $html .= '<div class="mailmunch-landing-page'. ($selected_landing_page_id == $landing_page->id ? ' active' : '') .'" data-landing-page-id="'. $landing_page->id .'">';
89
+ $html .= '<div class="page-image">';
90
+ $html .= '<img src="'. $landing_page->preview_url .'" />';
91
+ $html .= '<div class="page-hover">';
92
+ $html .= '<a href="'. MAILMUNCH_URL. "/sso?token=". get_option(MAILMUNCH_PREFIX."_user_token"). "&next_url=". urlencode(MAILMUNCH_LANDING_PAGE_URL. "/sites/". get_option(MAILMUNCH_PREFIX."_site_id")."/landing_pages/". $landing_page->id ."/edit") .'" target="_blank" class="mailmunch-edit-page button button-primary button-large">Edit Page</a>';
93
+ $html .= '</div>';
94
+ $html .= '</div>';
95
+ $html .= '<div class="page-name">'. ($landing_page->name ? $landing_page->name : "Untitled") .'</div>';
96
+ $html .= '</div>';
97
+ }
98
+ $html .= '<a href="'. MAILMUNCH_URL. "/sso?token=". get_option(MAILMUNCH_PREFIX."_user_token"). "&next_url=". urlencode(MAILMUNCH_LANDING_PAGE_URL. "/sites/". get_option(MAILMUNCH_PREFIX."_site_id")."/landing_pages/new") .'" class="mailmunch-landing-page new-landing-page" target="_blank">';
99
+ $html .= '<div class="page-image">';
100
+ $html .= '<span class="dashicons dashicons-plus-alt"></span>';
101
+ $html .= '<div class="new-page-title">Create New Page</div>';
102
+ $html .= '</div>';
103
+ $html .= '<div class="page-name">&nbsp;</div>';
104
+ $html .= '</a>';
105
+
106
+ echo $html;
107
+ }
108
+
109
+ public function landing_page_save_meta($post_id, $post) {
110
+ /*
111
+ * We need to verify this came from our screen and with proper authorization,
112
+ * because the save_post action can be triggered at other times.
113
+ */
114
+
115
+ if ( ! isset( $_POST['mailmunch_landing_page_noncename'] ) ) { // Check if our nonce is set.
116
+ return;
117
+ }
118
+
119
+ // verify this came from the our screen and with proper authorization,
120
+ // because save_post can be triggered at other times
121
+ if( !wp_verify_nonce( $_POST['mailmunch_landing_page_noncename'], plugin_basename(__FILE__) ) ) {
122
+ return $post->ID;
123
+ }
124
+
125
+ // is the user allowed to edit the post or page?
126
+ if( ! current_user_can( 'edit_post', $post->ID )){
127
+ return $post->ID;
128
+ }
129
+
130
+ $key = '_mailmunch_landing_page_id';
131
+ $value = $_POST['mailmunch_landing_page_id'];
132
+ if( get_post_meta( $post->ID, $key, true ) ) { // if the custom field already has a value
133
+ update_post_meta($post->ID, $key, $value);
134
+ } else { // if the custom field doesn't have a value
135
+ add_post_meta( $post->ID, $key, $value );
136
+ }
137
+ if( !$value ) { // delete if blank
138
+ delete_post_meta( $post->ID, $key );
139
+ }
140
+ }
141
+
142
+
143
+ }
includes/class-mailmunch-rewrite.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The file that defines the rewrite rules for MailMunch lanidng pages
5
+ *
6
+ * @link http://www.mailmunch.co
7
+ * @since 3.0.0
8
+ *
9
+ */
10
+
11
+ class Mailmunch_Rewrite {
12
+
13
+ public function __construct() {
14
+
15
+ }
16
+
17
+ public function init() {
18
+ $this->generateRewriteRules();
19
+ }
20
+
21
+ public function on_save_post($postId) {
22
+ if (get_post_type($postId) == MAILMUNCH_POST_TYPE) {
23
+ $this->regenerateRewriteRules();
24
+ }
25
+ }
26
+
27
+ public function on_wp_insert_post($postId) {
28
+ if (get_post_type($postId) == MAILMUNCH_POST_TYPE) {
29
+ $this->regenerateRewriteRules();
30
+ }
31
+ }
32
+
33
+ public function on_post_type_link($permalink) {
34
+ $customPostTypes = get_post_types(array('_builtin' => false), 'objects');
35
+ foreach ($customPostTypes as $type => $postType) {
36
+ if ($type == MAILMUNCH_POST_TYPE) {
37
+ $slug = trim($postType->rewrite['slug'], '/');
38
+ $permalink = str_replace(get_bloginfo('url') . '/' . $slug . '/', get_bloginfo('url') . '/', $permalink);
39
+ }
40
+ }
41
+ return $permalink;
42
+
43
+ }
44
+
45
+ public function on_wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent) {
46
+ global $wpdb, $wp_rewrite;
47
+
48
+ // Don't touch hierarchical post types
49
+ $hierarchical_post_types = get_post_types(array('hierarchical' => true));
50
+ if (in_array( $post_type, $hierarchical_post_types)) return $slug;
51
+
52
+ if ('attachment' == $post_type) {
53
+ // These will be unique anyway
54
+ return $slug;
55
+ }
56
+
57
+ $feeds = $wp_rewrite->feeds;
58
+ if (!is_array($feeds)) $feeds = array();
59
+
60
+ // Lets make sure the slug is really unique:
61
+ $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
62
+ $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_ID));
63
+
64
+ if ($post_name_check || in_array($slug, $feeds)) {
65
+ $suffix = 2;
66
+
67
+ do {
68
+ $alt_post_name = substr($slug, 0, 200 - (strlen($suffix) + 1)) . "-$suffix";
69
+ $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_ID));
70
+ $suffix++;
71
+ } while ($post_name_check);
72
+
73
+ $slug = $alt_post_name;
74
+ }
75
+
76
+ return $slug;
77
+ }
78
+
79
+ /**
80
+ * Regenerate rewrite rules for each custom page
81
+ *
82
+ * @return void
83
+ */
84
+ public function regenerateRewriteRules() {
85
+ $this->generateRewriteRules();
86
+ flush_rewrite_rules(false);
87
+ }
88
+
89
+ /**
90
+ * Generate rewrite rules for each custom page
91
+ *
92
+ * @return void
93
+ */
94
+ public function generateRewriteRules() {
95
+ global $wpdb;
96
+ $customPostTypes = get_post_types(array('_builtin' => false), 'objects');
97
+
98
+ foreach ($customPostTypes as $type => $postType) {
99
+ if ($type == MAILMUNCH_POST_TYPE) {
100
+ $posts = $wpdb->get_results($wpdb->prepare("SELECT id, post_name FROM ". $wpdb->posts. " WHERE post_name != '' AND post_type = %s", $type), OBJECT);
101
+ foreach ($posts as $post) {
102
+ add_rewrite_rule($post->post_name . '$', 'index.php?' . $postType->query_var . '=' . $post->post_name, 'top');
103
+ }
104
+ }
105
+ }
106
+ }
107
+ }
includes/class-mailmunch.php CHANGED
@@ -16,10 +16,13 @@
16
  // Define some class constants.
17
  define( 'MAILMUNCH_URL', "http://wordpress.mailmunch.co" );
18
  define( 'MAILMUNCH_HOME_URL', "http://app.mailmunch.co" );
 
 
19
  define( 'MAILMUNCH_SLUG', "mailmunch" );
20
  define( 'MAILMUNCH_PREFIX', 'mailmunch' );
 
21
  define( 'MAILMUNCH_PLUGIN_DIRECTORY', 'mailmunch' );
22
- define( 'MAILMUNCH_VERSION', '2.0.4' );
23
 
24
  /**
25
  * The core plugin class.
@@ -104,8 +107,7 @@ class Mailmunch {
104
  $this->define_admin_hooks();
105
  }
106
  $this->define_public_hooks();
107
-
108
-
109
  }
110
 
111
  /**
@@ -158,6 +160,12 @@ class Mailmunch {
158
  * side of the site.
159
  */
160
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-mailmunch-public.php';
 
 
 
 
 
 
161
 
162
  $this->loader = new Mailmunch_Loader();
163
 
@@ -207,13 +215,15 @@ class Mailmunch {
207
  $this->loader->add_action( 'wp_ajax_sign_up', $plugin_admin, 'sign_up' );
208
  $this->loader->add_action( 'wp_ajax_sign_in', $plugin_admin, 'sign_in' );
209
  $this->loader->add_action( 'wp_ajax_delete_widget', $plugin_admin, 'delete_widget' );
 
 
 
210
 
211
  // Settings link
212
  $pluginBaseName = plugin_basename(__FILE__);
213
  $exploded = explode('/', $pluginBaseName);
214
  $pluginFilePath = $exploded[0]. '/mailmunch.php';
215
  $this->loader->add_filter( 'plugin_action_links_'. $pluginFilePath, $plugin_admin, 'settings_link');
216
-
217
  }
218
 
219
  /**
@@ -238,7 +248,29 @@ class Mailmunch {
238
 
239
  // Sidebar widget
240
  $this->loader->add_action( 'widgets_init', $plugin_public, 'sidebar_widget' );
241
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  }
243
 
244
  /**
16
  // Define some class constants.
17
  define( 'MAILMUNCH_URL', "http://wordpress.mailmunch.co" );
18
  define( 'MAILMUNCH_HOME_URL', "http://app.mailmunch.co" );
19
+ define( 'MAILMUNCH_LANDING_PAGE_URL', "http://wordpress.mailmunch.co" );
20
+ define( 'MAILMUNCH_PAGE_SERVICE_URL', "http://wordpress.page.co" );
21
  define( 'MAILMUNCH_SLUG', "mailmunch" );
22
  define( 'MAILMUNCH_PREFIX', 'mailmunch' );
23
+ define( 'MAILMUNCH_POST_TYPE', 'mailmunch_page' );
24
  define( 'MAILMUNCH_PLUGIN_DIRECTORY', 'mailmunch' );
25
+ define( 'MAILMUNCH_VERSION', '3.0.0' );
26
 
27
  /**
28
  * The core plugin class.
107
  $this->define_admin_hooks();
108
  }
109
  $this->define_public_hooks();
110
+ $this->define_post_type();
 
111
  }
112
 
113
  /**
160
  * side of the site.
161
  */
162
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-mailmunch-public.php';
163
+
164
+ /**
165
+ * The class responsible for defining landing page post type
166
+ */
167
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-mailmunch-post-type.php';
168
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-mailmunch-rewrite.php';
169
 
170
  $this->loader = new Mailmunch_Loader();
171
 
215
  $this->loader->add_action( 'wp_ajax_sign_up', $plugin_admin, 'sign_up' );
216
  $this->loader->add_action( 'wp_ajax_sign_in', $plugin_admin, 'sign_in' );
217
  $this->loader->add_action( 'wp_ajax_delete_widget', $plugin_admin, 'delete_widget' );
218
+
219
+ // Dashboard
220
+ $this->loader->add_action( 'wp_dashboard_setup', $plugin_admin, 'dashboard_setup' );
221
 
222
  // Settings link
223
  $pluginBaseName = plugin_basename(__FILE__);
224
  $exploded = explode('/', $pluginBaseName);
225
  $pluginFilePath = $exploded[0]. '/mailmunch.php';
226
  $this->loader->add_filter( 'plugin_action_links_'. $pluginFilePath, $plugin_admin, 'settings_link');
 
227
  }
228
 
229
  /**
248
 
249
  // Sidebar widget
250
  $this->loader->add_action( 'widgets_init', $plugin_public, 'sidebar_widget' );
251
+ }
252
+
253
+ /**
254
+ * Register custom post type for Landing Pages
255
+ *
256
+ * @since 3.0.0
257
+ * @access private
258
+ */
259
+ private function define_post_type() {
260
+ // Landing Page
261
+ $plugin_post_type = new 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
+
268
+ $plugin_rewrite = new Mailmunch_Rewrite();
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
  }
275
 
276
  /**
mailmunch.php CHANGED
@@ -13,10 +13,10 @@
13
  * @package Mailmunch
14
  *
15
  * @wordpress-plugin
16
- * Plugin Name: MailMunch - Increase your Email Subscribers by over 500%
17
  * Plugin URI: http://www.mailmunch.co
18
- * Description: Collect email addresses from website visitors and grow your subscribers with our attention grabbing optin-forms, entry/exit intent technology, and other effective lead-generation forms.
19
- * Version: 2.0.4
20
  * Author: MailMunch
21
  * Author URI: http://www.mailmunch.co
22
  * License: GPL-2.0+
13
  * @package Mailmunch
14
  *
15
  * @wordpress-plugin
16
+ * Plugin Name: MailMunch - Grow Your Email List
17
  * Plugin URI: http://www.mailmunch.co
18
+ * Description: The best free plugin to get more email subscribers. Beautiful signup forms and landing pages that integrate with MailChimp, Constant Contact, AWeber, Campaign Monitor and more.
19
+ * Version: 3.0.0
20
  * Author: MailMunch
21
  * Author URI: http://www.mailmunch.co
22
  * License: GPL-2.0+
public/mailmunch-landing-page.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $landing_page_id = get_post_meta( get_the_ID(), '_mailmunch_landing_page_id', true );
3
+ $response = wp_remote_get(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
+ }
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: mailmunch, lizgannes
3
  Tags: signup form, newsletter, newsletters, subscribe, popup, exit popup, exit intent, subscribers, subscription, popover, lightbox, analytics, collect email, optin, optin form, optin forms, double optin, list builder, email form, lead, leads, mailchimp, mailchimp form, mailchimp newsletter, mailchimp plugin, mailchimp signup, mailchimp signup forms, mailchimp signup form, mailchimp widget, mailchimp subscribe, constant contact, contact contact form, constant contact newsletter, constant contact plugin, constant contact signup, constant contact signup forms, constant contact signup form, constant contact widget, constant contact subscribe, aweber, aweber form, aweber forms, aweber signup form, aweber plugin
4
  Requires at least: 3.0.1
5
- Tested up to: 4.6
6
- Stable tag: 2.0.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -163,6 +163,9 @@ Why people use AWeber
163
 
164
  == Changelog ==
165
 
 
 
 
166
  = 1.3.6 =
167
  * Fatal activation bug fix
168
 
2
  Contributors: mailmunch, lizgannes
3
  Tags: signup form, newsletter, newsletters, subscribe, popup, exit popup, exit intent, subscribers, subscription, popover, lightbox, analytics, collect email, optin, optin form, optin forms, double optin, list builder, email form, lead, leads, mailchimp, mailchimp form, mailchimp newsletter, mailchimp plugin, mailchimp signup, mailchimp signup forms, mailchimp signup form, mailchimp widget, mailchimp subscribe, constant contact, contact contact form, constant contact newsletter, constant contact plugin, constant contact signup, constant contact signup forms, constant contact signup form, constant contact widget, constant contact subscribe, aweber, aweber form, aweber forms, aweber signup form, aweber plugin
4
  Requires at least: 3.0.1
5
+ Tested up to: 4.7
6
+ Stable tag: 3.0.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
163
 
164
  == Changelog ==
165
 
166
+ = 3.0.0 =
167
+ * Landing pages
168
+
169
  = 1.3.6 =
170
  * Fatal activation bug fix
171