Version Description
Download this release
Release Info
Developer | mailmunch |
Plugin | MailChimp Forms by MailMunch |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
- inc/mailmunchapi.php +6 -2
- inc/sidebar_widget.php +117 -0
- mailchimp-mailmunch.php +9 -4
- readme.txt +1 -1
- uninstall.php +9 -0
inc/mailmunchapi.php
CHANGED
@@ -17,9 +17,13 @@
|
|
17 |
return $this->ping('/sites');
|
18 |
}
|
19 |
|
20 |
-
function widgets($site_id) {
|
21 |
$this->requestType = 'get';
|
22 |
-
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
function getWidgetsHtml($site_id) {
|
17 |
return $this->ping('/sites');
|
18 |
}
|
19 |
|
20 |
+
function widgets($site_id, $widget_type_name) {
|
21 |
$this->requestType = 'get';
|
22 |
+
if (!empty($widget_type_name)) {
|
23 |
+
return $this->ping('/sites/'.$site_id.'/widgets?widget_type_name='.$widget_type_name);
|
24 |
+
} else {
|
25 |
+
return $this->ping('/sites/'.$site_id.'/widgets');
|
26 |
+
}
|
27 |
}
|
28 |
|
29 |
function getWidgetsHtml($site_id) {
|
inc/sidebar_widget.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class MC_MM_Sidebar_Widget extends WP_Widget {
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Register widget with WordPress.
|
6 |
+
*/
|
7 |
+
function __construct() {
|
8 |
+
parent::__construct(
|
9 |
+
'mc_mm_widget', // Base ID
|
10 |
+
__('Sidebar MailChimp Form', 'text_domain'), // Name
|
11 |
+
array( 'description' => __( 'Displays a MailMunch optin form in Sidebar', 'text_domain' ), ) // Args
|
12 |
+
);
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Front-end display of widget.
|
17 |
+
*
|
18 |
+
* @see WP_Widget::widget()
|
19 |
+
*
|
20 |
+
* @param array $args Widget arguments.
|
21 |
+
* @param array $instance Saved values from database.
|
22 |
+
*/
|
23 |
+
public function widget( $args, $instance ) {
|
24 |
+
if ( isset( $instance[ 'form_id' ] ) ) {
|
25 |
+
$form_id = $instance[ 'form_id' ];
|
26 |
+
}
|
27 |
+
|
28 |
+
if (!empty($form_id)) {
|
29 |
+
echo $args['before_widget'];
|
30 |
+
if ( ! empty( $instance['title'] ) ) {
|
31 |
+
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
|
32 |
+
}
|
33 |
+
echo "<div class='mailmunch-wordpress-widget mailmunch-wordpress-widget-".$form_id."' style='display: none !important;'></div>";
|
34 |
+
echo $args['after_widget'];
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Back-end widget form.
|
40 |
+
*
|
41 |
+
* @see WP_Widget::form()
|
42 |
+
*
|
43 |
+
* @param array $instance Previously saved values from database.
|
44 |
+
*/
|
45 |
+
public function form( $instance ) {
|
46 |
+
if ( isset( $instance[ 'title' ] ) ) {
|
47 |
+
$title = $instance[ 'title' ];
|
48 |
+
}
|
49 |
+
else {
|
50 |
+
$title = __( 'Optin Form', 'text_domain' );
|
51 |
+
}
|
52 |
+
|
53 |
+
if ( isset( $instance[ 'form_id' ] ) ) {
|
54 |
+
$form_id = $instance[ 'form_id' ];
|
55 |
+
}
|
56 |
+
|
57 |
+
$mc_mm_data = unserialize(get_option("mc_mm_data"));
|
58 |
+
$mc_mm_user_email = get_option("mc_mm_user_email");
|
59 |
+
$mc_mm_user_password = get_option("mc_mm_user_password");
|
60 |
+
if (!empty($mc_mm_user_email) && !empty($mc_mm_user_password) && !empty($mc_mm_data["site_id"])) {
|
61 |
+
$mc_mm_email = get_option("mc_mm_user_email");
|
62 |
+
$mc_mm_password = get_option("mc_mm_user_password");
|
63 |
+
$mc_mm_site_id = $mc_mm_data["site_id"];
|
64 |
+
$mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
|
65 |
+
$result = $mm->widgets($mc_mm_site_id, "Sidebar");
|
66 |
+
if ( !is_wp_error( $result ) ) {
|
67 |
+
$widgets = json_decode($result['body']);
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
if (sizeof($widgets) > 0) {
|
72 |
+
?>
|
73 |
+
<p>
|
74 |
+
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
|
75 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
|
76 |
+
</p>
|
77 |
+
|
78 |
+
<p>
|
79 |
+
<label for="<?php echo $this->get_field_id( 'form_id' ); ?>"><?php _e( 'Optin Form:' ); ?></label>
|
80 |
+
<select class="widefat" id="<?php echo $this->get_field_id( 'form_id' ); ?>" name="<?php echo $this->get_field_name( 'form_id' ); ?>">
|
81 |
+
<?php
|
82 |
+
foreach ($widgets as $widget) {
|
83 |
+
echo "<option value='".$widget->id."'";
|
84 |
+
if ($form_id == $widget->id) { echo " selected"; };
|
85 |
+
echo ">".$widget->name."</option>";
|
86 |
+
}
|
87 |
+
?>
|
88 |
+
</select>
|
89 |
+
</p>
|
90 |
+
<?php
|
91 |
+
} else {
|
92 |
+
?>
|
93 |
+
<p>No optin forms found. <a href="<?php echo admin_url( 'admin.php?page='.MAILCHIMP_MAILMUNCH_SLUG ); ?>">Create First One</a></p>
|
94 |
+
<?php
|
95 |
+
}
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Sanitize widget form values as they are saved.
|
101 |
+
*
|
102 |
+
* @see WP_Widget::update()
|
103 |
+
*
|
104 |
+
* @param array $new_instance Values just sent to be saved.
|
105 |
+
* @param array $old_instance Previously saved values from database.
|
106 |
+
*
|
107 |
+
* @return array Updated safe values to be saved.
|
108 |
+
*/
|
109 |
+
public function update( $new_instance, $old_instance ) {
|
110 |
+
$instance = array();
|
111 |
+
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
|
112 |
+
$instance['form_id'] = ( ! empty( $new_instance['form_id'] ) ) ? strip_tags( $new_instance['form_id'] ) : '';
|
113 |
+
|
114 |
+
return $instance;
|
115 |
+
}
|
116 |
+
|
117 |
+
}
|
mailchimp-mailmunch.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: MailChimp Forms by MailMunch
|
4 |
Plugin URI: http://connect.mailchimp.com/integrations/mailmunch-email-list-builder
|
5 |
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.
|
6 |
-
Version: 1.0.
|
7 |
Author: MailMunch
|
8 |
Author URI: http://www.mailmunch.co
|
9 |
License: GPL2
|
@@ -11,9 +11,10 @@
|
|
11 |
|
12 |
require_once( plugin_dir_path( __FILE__ ) . 'inc/mailmunchapi.php' );
|
13 |
require_once( plugin_dir_path( __FILE__ ) . 'inc/common.php' );
|
|
|
14 |
|
15 |
define( 'MAILCHIMP_MAILMUNCH_SLUG', "mailchimp-mailmunch");
|
16 |
-
define( 'MAILCHIMP_MAILMUNCH_VER', "1.0.
|
17 |
define( 'MAILCHIMP_MAILMUNCH_URL', "www.mailmunch.co");
|
18 |
|
19 |
// Create unique WordPress instance ID
|
@@ -95,6 +96,11 @@
|
|
95 |
return $content;
|
96 |
}
|
97 |
|
|
|
|
|
|
|
|
|
|
|
98 |
function mc_mm_insert_form_after_paragraph($insertion, $paragraph_id, $content) {
|
99 |
$closing_p = '</p>';
|
100 |
$paragraphs = explode($closing_p, $content);
|
@@ -414,5 +420,4 @@ jQuery(window).load(function() {
|
|
414 |
<?php
|
415 |
}
|
416 |
}
|
417 |
-
}
|
418 |
-
?>
|
3 |
Plugin Name: MailChimp Forms by MailMunch
|
4 |
Plugin URI: http://connect.mailchimp.com/integrations/mailmunch-email-list-builder
|
5 |
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.
|
6 |
+
Version: 1.0.2
|
7 |
Author: MailMunch
|
8 |
Author URI: http://www.mailmunch.co
|
9 |
License: GPL2
|
11 |
|
12 |
require_once( plugin_dir_path( __FILE__ ) . 'inc/mailmunchapi.php' );
|
13 |
require_once( plugin_dir_path( __FILE__ ) . 'inc/common.php' );
|
14 |
+
require_once( plugin_dir_path( __FILE__ ) . 'inc/sidebar_widget.php' );
|
15 |
|
16 |
define( 'MAILCHIMP_MAILMUNCH_SLUG', "mailchimp-mailmunch");
|
17 |
+
define( 'MAILCHIMP_MAILMUNCH_VER', "1.0.2");
|
18 |
define( 'MAILCHIMP_MAILMUNCH_URL', "www.mailmunch.co");
|
19 |
|
20 |
// Create unique WordPress instance ID
|
96 |
return $content;
|
97 |
}
|
98 |
|
99 |
+
function mc_mm_register_sidebar_widget() {
|
100 |
+
register_widget( 'MC_MM_Sidebar_Widget' );
|
101 |
+
}
|
102 |
+
add_action( 'widgets_init', 'mc_mm_register_sidebar_widget' );
|
103 |
+
|
104 |
function mc_mm_insert_form_after_paragraph($insertion, $paragraph_id, $content) {
|
105 |
$closing_p = '</p>';
|
106 |
$paragraphs = explode($closing_p, $content);
|
420 |
<?php
|
421 |
}
|
422 |
}
|
423 |
+
}
|
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: mailmunch
|
|
3 |
Tags: mailchimp, MailChimp form, MailChimp Newsletter form, MailChimp plugin, newsletter, newsletter form, newsletter form plugin, optin form, form, signup, signup forms, signup form, widget, email form, leads
|
4 |
Requires at least: 3.0.1
|
5 |
Tested up to: 4.0
|
6 |
-
Stable tag: 1.0.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
3 |
Tags: mailchimp, MailChimp form, MailChimp Newsletter form, MailChimp plugin, newsletter, newsletter form, newsletter form plugin, optin form, form, signup, signup forms, signup form, widget, email form, leads
|
4 |
Requires at least: 3.0.1
|
5 |
Tested up to: 4.0
|
6 |
+
Stable tag: 1.0.2
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
uninstall.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
|
3 |
+
exit();
|
4 |
+
|
5 |
+
delete_option("mc_mm_data");
|
6 |
+
delete_option("mc_mm_user_email");
|
7 |
+
delete_option("mc_mm_user_password");
|
8 |
+
delete_option("mc_mm_guest_user");
|
9 |
+
?>
|