Version Description
Download this release
Release Info
Developer | mailmunch |
Plugin | MailChimp Forms by MailMunch |
Version | 3.0.0 |
Comparing to | |
See all releases |
Code changes from version 2.1.7 to 3.0.0
- admin/class-mailchimp-mailmunch-admin.php +28 -0
- admin/css/mailchimp-mailmunch-admin.css +142 -1
- admin/img/dashboard.jpg +0 -0
- admin/js/mailchimp-mailmunch-admin.js +6 -0
- admin/partials/mailchimp-mailmunch-settings.php +6 -4
- includes/class-mailchimp-mailmunch-post-type.php +143 -0
- includes/class-mailchimp-mailmunch-rewrite.php +107 -0
- includes/class-mailchimp-mailmunch.php +37 -4
- includes/class-mailmunch-api.php +11 -0
- mailchimp-mailmunch.php +1 -1
- public/mailchimp-mailmunch-landing-page.php +11 -0
- readme.txt +5 -2
admin/class-mailchimp-mailmunch-admin.php
CHANGED
@@ -144,6 +144,7 @@ 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. ' Settings', 'Settings', 'manage_options', MAILCHIMP_MAILMUNCH_SLUG. '-settings', array($this, 'settings_page') );
|
148 |
}
|
149 |
|
@@ -276,6 +277,33 @@ class Mailchimp_Mailmunch_Admin {
|
|
276 |
}
|
277 |
require_once(plugin_dir_path(__FILE__) . 'partials/mailchimp-mailmunch-settings.php');
|
278 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
|
280 |
/**
|
281 |
* Get Dashboard HTML
|
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 |
|
277 |
}
|
278 |
require_once(plugin_dir_path(__FILE__) . 'partials/mailchimp-mailmunch-settings.php');
|
279 |
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Dashboard Widget
|
283 |
+
*
|
284 |
+
* @since 3.0.0
|
285 |
+
*/
|
286 |
+
public function dashboard_setup() {
|
287 |
+
add_meta_box( MAILCHIMP_MAILMUNCH_PREFIX. '_dashboard_widget', 'MailChimp Forms by MailMunch', array($this , 'dashboard_widget'), 'dashboard', 'normal', 'high');
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Dashboard Widget
|
292 |
+
*
|
293 |
+
* @since 3.0.0
|
294 |
+
*/
|
295 |
+
public function dashboard_widget() {
|
296 |
+
$html = '<div class="mailmunch-dash-widget">';
|
297 |
+
$html .= '<div class="mailmunch-dash-widget-inner">';
|
298 |
+
$html .= '<p>Welcome to MailChimp Forms by MailMunch! The #1 plugin to grow your MailChimp email list.</p>';
|
299 |
+
$html .= '<div>';
|
300 |
+
$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>';
|
301 |
+
$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>';
|
302 |
+
$html .= '</div>';
|
303 |
+
$html .= '</div>';
|
304 |
+
$html .= '</div>';
|
305 |
+
echo $html;
|
306 |
+
}
|
307 |
|
308 |
/**
|
309 |
* Get Dashboard HTML
|
admin/css/mailchimp-mailmunch-admin.css
CHANGED
@@ -402,4 +402,145 @@ label.mailmunch-form-label {
|
|
402 |
|
403 |
.mailmunch-review-notice .mailmunch-buttons a {
|
404 |
margin-right: 10px;
|
405 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
|
403 |
.mailmunch-review-notice .mailmunch-buttons a {
|
404 |
margin-right: 10px;
|
405 |
+
}
|
406 |
+
|
407 |
+
.mailmunch-landing-page {
|
408 |
+
padding: 3px 3px 0px;
|
409 |
+
border: 1px solid #CCC;
|
410 |
+
display: inline-block;
|
411 |
+
cursor: pointer;
|
412 |
+
margin-right: 10px;
|
413 |
+
margin-bottom: 10px;
|
414 |
+
opacity: 0.7;
|
415 |
+
width: 250px;
|
416 |
+
height: 278px;
|
417 |
+
text-decoration: none;
|
418 |
+
}
|
419 |
+
|
420 |
+
.mailmunch-landing-page .page-image img {
|
421 |
+
cursor: pointer;
|
422 |
+
}
|
423 |
+
|
424 |
+
.mailmunch-landing-page .page-image {
|
425 |
+
position: relative;
|
426 |
+
line-height: 0;
|
427 |
+
width: 250px;
|
428 |
+
height: 250px;
|
429 |
+
text-align: center;
|
430 |
+
}
|
431 |
+
|
432 |
+
.mailmunch-landing-page .page-name {
|
433 |
+
color: #444;
|
434 |
+
text-align: center;
|
435 |
+
padding: 5px;
|
436 |
+
font-size: 13px;
|
437 |
+
max-height: 18px;
|
438 |
+
white-space: nowrap;
|
439 |
+
text-overflow: ellipsis;
|
440 |
+
overflow: hidden;
|
441 |
+
}
|
442 |
+
|
443 |
+
.mailmunch-landing-page.active {
|
444 |
+
background-color: #0085ba;
|
445 |
+
opacity: 1;
|
446 |
+
}
|
447 |
+
|
448 |
+
.mailmunch-landing-page.active .page-name {
|
449 |
+
color: #FFF;
|
450 |
+
font-weight: bold;
|
451 |
+
}
|
452 |
+
|
453 |
+
.mailmunch-landing-page:not(.active):hover {
|
454 |
+
background-color: #EEE;
|
455 |
+
opacity: 1;
|
456 |
+
}
|
457 |
+
|
458 |
+
.mailmunch-landing-page .page-hover {
|
459 |
+
display: none;
|
460 |
+
width: 100%;
|
461 |
+
height: 100%;
|
462 |
+
background-color: rgba(0,0,0,0.7);
|
463 |
+
position: absolute;
|
464 |
+
left: 0px;
|
465 |
+
top: 0px;
|
466 |
+
}
|
467 |
+
|
468 |
+
.mailmunch-landing-page.active:hover .page-hover {
|
469 |
+
display: block;
|
470 |
+
}
|
471 |
+
|
472 |
+
.mailmunch-landing-page.active .page-hover .mailmunch-edit-page {
|
473 |
+
margin-top: 100px;
|
474 |
+
}
|
475 |
+
|
476 |
+
.mailmunch-landing-page img {
|
477 |
+
width: 250px;
|
478 |
+
height: 250px;
|
479 |
+
}
|
480 |
+
|
481 |
+
.mailmunch-landing-page.new-landing-page .page-image .dashicons-plus-alt {
|
482 |
+
font-size: 50px;
|
483 |
+
width: 50px;
|
484 |
+
height: 50px;
|
485 |
+
color: #999;
|
486 |
+
margin-top: 95px;
|
487 |
+
}
|
488 |
+
|
489 |
+
.mailmunch-landing-page.new-landing-page .new-page-title {
|
490 |
+
color: #999;
|
491 |
+
margin-top: 15px;
|
492 |
+
}
|
493 |
+
|
494 |
+
|
495 |
+
/* Dashboard Widget */
|
496 |
+
.mailmunch-dash-widget {
|
497 |
+
color: #FFF;
|
498 |
+
background: url('../img/dashboard.jpg');
|
499 |
+
background-size: cover;
|
500 |
+
}
|
501 |
+
|
502 |
+
.mailmunch-dash-widget-inner {
|
503 |
+
padding: 20px 20px 30px;
|
504 |
+
background: rgba(0,0,0,0.5);
|
505 |
+
text-align: center;
|
506 |
+
}
|
507 |
+
|
508 |
+
.mailmunch-dash-widget-inner p {
|
509 |
+
font-size: 16px;
|
510 |
+
font-weight: bold;
|
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 {
|
530 |
+
border: 1px solid #CCC;
|
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 |
+
}
|
admin/img/dashboard.jpg
ADDED
Binary file
|
admin/js/mailchimp-mailmunch-admin.js
CHANGED
@@ -142,6 +142,12 @@
|
|
142 |
return false;
|
143 |
})
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
});
|
146 |
|
147 |
})( jQuery );
|
142 |
return false;
|
143 |
})
|
144 |
|
145 |
+
$(".mailmunch-landing-page").click(function() {
|
146 |
+
if ($(this).hasClass("new-landing-page")) return;
|
147 |
+
$(".mailmunch-landing-page").removeClass("active");
|
148 |
+
$(this).addClass("active");
|
149 |
+
$("#mailmunch_landing_page_id").val($(this).data("landing-page-id"));
|
150 |
+
});
|
151 |
});
|
152 |
|
153 |
})( jQuery );
|
admin/partials/mailchimp-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 |
-
<
|
7 |
-
|
8 |
-
|
|
|
|
|
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-mailchimp-mailmunch-post-type.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Mailchimp_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 Mailchimp_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' => MAILCHIMP_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( MAILCHIMP_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 == MAILCHIMP_MAILMUNCH_POST_TYPE) {
|
59 |
+
return plugin_dir_path( dirname( __FILE__ ) ) . 'public/mailchimp-mailmunch-landing-page.php';
|
60 |
+
}
|
61 |
+
return $template;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function post_meta_box($postType, $post) {
|
65 |
+
if ($postType == MAILCHIMP_MAILMUNCH_POST_TYPE) {
|
66 |
+
add_meta_box(
|
67 |
+
'mailchimp_mailmunch_meta_choose_page',
|
68 |
+
'Choose or Create New Page',
|
69 |
+
array($this, 'get_landing_pages_dropdown'),
|
70 |
+
MAILCHIMP_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="'. MAILCHIMP_MAILMUNCH_URL. "/sso?token=". get_option(MAILCHIMP_MAILMUNCH_PREFIX."_user_token"). "&next_url=". urlencode(MAILCHIMP_MAILMUNCH_LANDING_PAGE_URL. "/sites/". get_option(MAILCHIMP_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="'.MAILCHIMP_MAILMUNCH_URL. "/sso?token=". get_option(MAILCHIMP_MAILMUNCH_PREFIX."_user_token"). "&next_url=". urlencode(MAILCHIMP_MAILMUNCH_LANDING_PAGE_URL. "/sites/". get_option(MAILCHIMP_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"> </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-mailchimp-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 Mailchimp_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) == MAILCHIMP_MAILMUNCH_POST_TYPE) {
|
23 |
+
$this->regenerateRewriteRules();
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
public function on_wp_insert_post($postId) {
|
28 |
+
if (get_post_type($postId) == MAILCHIMP_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 == MAILCHIMP_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 == MAILCHIMP_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-mailchimp-mailmunch.php
CHANGED
@@ -16,10 +16,13 @@
|
|
16 |
// Define some class constants.
|
17 |
define( 'MAILCHIMP_MAILMUNCH_URL', "http://wordpress.mailmunch.co" );
|
18 |
define( 'MAILCHIMP_MAILMUNCH_HOME_URL', "http://app.mailmunch.co" );
|
|
|
|
|
19 |
define( 'MAILCHIMP_MAILMUNCH_SLUG', "mailchimp-mailmunch" );
|
20 |
define( 'MAILCHIMP_MAILMUNCH_PREFIX', 'mc_mm' );
|
|
|
21 |
define( 'MAILCHIMP_MAILMUNCH_PLUGIN_DIRECTORY', 'mailchimp-forms-by-mailmunch' );
|
22 |
-
define( 'MAILCHIMP_MAILMUNCH_VERSION', '
|
23 |
|
24 |
/**
|
25 |
* The core plugin class.
|
@@ -104,8 +107,7 @@ class Mailchimp_Mailmunch {
|
|
104 |
$this->define_admin_hooks();
|
105 |
}
|
106 |
$this->define_public_hooks();
|
107 |
-
|
108 |
-
|
109 |
}
|
110 |
|
111 |
/**
|
@@ -158,6 +160,12 @@ class Mailchimp_Mailmunch {
|
|
158 |
* side of the site.
|
159 |
*/
|
160 |
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-mailchimp-mailmunch-public.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
$this->loader = new Mailchimp_Mailmunch_Loader();
|
163 |
|
@@ -206,6 +214,9 @@ class Mailchimp_Mailmunch {
|
|
206 |
$this->loader->add_action( 'wp_ajax_sign_up', $plugin_admin, 'sign_up' );
|
207 |
$this->loader->add_action( 'wp_ajax_sign_in', $plugin_admin, 'sign_in' );
|
208 |
$this->loader->add_action( 'wp_ajax_delete_widget', $plugin_admin, 'delete_widget' );
|
|
|
|
|
|
|
209 |
|
210 |
// Settings link
|
211 |
$pluginBaseName = plugin_basename(__FILE__);
|
@@ -237,7 +248,29 @@ class Mailchimp_Mailmunch {
|
|
237 |
|
238 |
// Sidebar widget
|
239 |
$this->loader->add_action( 'widgets_init', $plugin_public, 'sidebar_widget' );
|
240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
}
|
242 |
|
243 |
/**
|
16 |
// Define some class constants.
|
17 |
define( 'MAILCHIMP_MAILMUNCH_URL', "http://wordpress.mailmunch.co" );
|
18 |
define( 'MAILCHIMP_MAILMUNCH_HOME_URL', "http://app.mailmunch.co" );
|
19 |
+
define( 'MAILCHIMP_MAILMUNCH_LANDING_PAGE_URL', "http://wordpress.mailmunch.co" );
|
20 |
+
define( 'MAILCHIMP_MAILMUNCH_PAGE_SERVICE_URL', "http://wordpress.page.co" );
|
21 |
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 |
$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-mailchimp-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-mailchimp-mailmunch-post-type.php';
|
168 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-mailchimp-mailmunch-rewrite.php';
|
169 |
|
170 |
$this->loader = new Mailchimp_Mailmunch_Loader();
|
171 |
|
214 |
$this->loader->add_action( 'wp_ajax_sign_up', $plugin_admin, 'sign_up' );
|
215 |
$this->loader->add_action( 'wp_ajax_sign_in', $plugin_admin, 'sign_in' );
|
216 |
$this->loader->add_action( 'wp_ajax_delete_widget', $plugin_admin, 'delete_widget' );
|
217 |
+
|
218 |
+
// Dashboard
|
219 |
+
$this->loader->add_action( 'wp_dashboard_setup', $plugin_admin, 'dashboard_setup' );
|
220 |
|
221 |
// Settings link
|
222 |
$pluginBaseName = plugin_basename(__FILE__);
|
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 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 |
+
|
268 |
+
$plugin_rewrite = new Mailchimp_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 |
/**
|
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();
|
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:
|
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.0
|
20 |
* Author: MailMunch
|
21 |
* Author URI: http://www.mailmunch.co
|
22 |
* License: GPL-2.0+
|
public/mailchimp-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(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 |
+
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: mailmunch, lizgannes
|
|
3 |
Tags: mailchimp, MailChimp form, MailChimp plugin, mailchimp popup, mailchimp newsletter, mailchimp widget, mailchimp wordpress
|
4 |
|
5 |
Requires at least: 3.8
|
6 |
-
Tested up to: 4.7
|
7 |
-
Stable tag:
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -189,6 +189,9 @@ If you have been looking for the best email marketing software programs, look no
|
|
189 |
|
190 |
== Changelog ==
|
191 |
|
|
|
|
|
|
|
192 |
= MailChimp Forms 2.1.7 =
|
193 |
* Updated to use MailChimp API v3
|
194 |
|
3 |
Tags: mailchimp, MailChimp form, MailChimp plugin, mailchimp popup, mailchimp newsletter, mailchimp widget, mailchimp wordpress
|
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 |
|
190 |
== Changelog ==
|
191 |
|
192 |
+
= MailChimp Forms 3.0.0 =
|
193 |
+
* Landing Pages with MailChimp forms
|
194 |
+
|
195 |
= MailChimp Forms 2.1.7 =
|
196 |
* Updated to use MailChimp API v3
|
197 |
|