Genesis eNews Extended - Version 0.1.1

Version Description

  • Adds "Hidden Fields" widget setting to make widget compatible with more mailing services.

=

Download this release

Release Info

Developer kraftbj
Plugin Icon wp plugin Genesis eNews Extended
Version 0.1.1
Comparing to
See all releases

Code changes from version 0.1 to 0.1.1

Files changed (2) hide show
  1. plugin.php +167 -160
  2. readme.txt +42 -36
plugin.php CHANGED
@@ -1,161 +1,168 @@
1
- <?php
2
- /**
3
- * Plugin Name: Genesis eNews Extended
4
- * Plugin URI: http://www.brandonkraft.com/contrib/plugins/genesis-enews-extended/
5
- * Description: Replaces the Genesis eNews Widget to allow easier use of additional mailing services.
6
- * Version: 0.1
7
- * Author: Brandon Kraft
8
- * Author URI: http://www.brandonkraft.com
9
- *
10
- * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
11
- * General Public License version 2, as published by the Free Software Foundation. You may NOT assume
12
- * that you can use any other version of the GPL.
13
- *
14
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
15
- * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
- *
17
- * @package BJGK_Genesis_enews_extended
18
- * @version 0.1
19
- * @author Brandon Kraft <bk@kraft.im>
20
- * @copyright Copyright (c) 2012, Brandon Kraft
21
- * @link http://www.brandonkraft.com
22
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23
- */
24
-
25
- class BJGK_Genesis_eNews_Extended extends WP_Widget {
26
-
27
- /**
28
- * Holds widget settings defaults, populated in constructor.
29
- *
30
- * @var array
31
- */
32
- protected $defaults;
33
-
34
- /**
35
- * Constructor. Set the default widget options and create widget.
36
- */
37
- function __construct() {
38
-
39
- $this->defaults = array(
40
- 'title' => '',
41
- 'text' => '',
42
- 'id' => '',
43
- 'input_text' => '',
44
- 'button_text' => '',
45
- );
46
-
47
- $widget_ops = array(
48
- 'classname' => 'enews-extended-widget',
49
- 'description' => __( 'Displays subscribe form', 'genesis' ),
50
- );
51
-
52
- $this->WP_Widget( 'enews-ext', __( 'Genesis - eNews Extended', 'genesis' ), $widget_ops );
53
-
54
- }
55
-
56
- /**
57
- * Echo the widget content.
58
- *
59
- * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
60
- * @param array $instance The settings for the particular instance of the widget
61
- */
62
- function widget( $args, $instance ) {
63
-
64
- extract( $args );
65
-
66
- /** Merge with defaults */
67
- $instance = wp_parse_args( (array) $instance, $this->defaults );
68
-
69
- echo $before_widget . '<div class="enews">';
70
-
71
- if ( ! empty( $instance['title'] ) )
72
- echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
73
-
74
- echo wpautop( $instance['text'] ); // We run KSES on update
75
-
76
- if ( ! empty( $instance['action'] ) ) : ?>
77
- <form id="subscribe" action="<?php echo esc_js( $instance['action'] ); ?>" method="post" target="_blank">
78
- <input type="text" value="<?php echo esc_attr( $instance['input_text'] ); ?>" id="subbox" onfocus="if ( this.value == '<?php echo esc_js( $instance['input_text'] ); ?>') { this.value = ''; }" onblur="if ( this.value == '' ) { this.value = '<?php echo esc_js( $instance['input_text'] ); ?>'; }" name="<?php echo esc_js( $instance['email-field'] ); ?>" />
79
- <input type="hidden" name="uri" value="<?php echo esc_attr( $instance['id'] ); ?>" />
80
- <input type="hidden" name="loc" value="<?php echo esc_attr( get_locale() ); ?>" />
81
- <input type="submit" value="<?php echo esc_attr( $instance['button_text'] ); ?>" id="subbutton" />
82
- </form>
83
- <?php endif;
84
-
85
- echo '</div>' . $after_widget;
86
-
87
- }
88
-
89
- /**
90
- * Update a particular instance.
91
- *
92
- * This function should check that $new_instance is set correctly.
93
- * The newly calculated value of $instance should be returned.
94
- * If "false" is returned, the instance won't be saved/updated.
95
- *
96
- * @param array $new_instance New settings for this instance as input by the user via form()
97
- * @param array $old_instance Old settings for this instance
98
- * @return array Settings to save or bool false to cancel saving
99
- */
100
- function update( $new_instance, $old_instance ) {
101
-
102
- $new_instance['title'] = strip_tags( $new_instance['title'] );
103
- $new_instance['text'] = wp_kses( $new_instance['text'], genesis_formatting_allowedtags() );
104
- return $new_instance;
105
-
106
- }
107
-
108
- /**
109
- * Echo the settings update form.
110
- *
111
- * @param array $instance Current settings
112
- */
113
- function form( $instance ) {
114
-
115
- /** Merge with defaults */
116
- $instance = wp_parse_args( (array) $instance, $this->defaults );
117
-
118
- ?>
119
- <p>
120
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'genesis' ); ?>:</label><br />
121
- <input type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" />
122
- </p>
123
-
124
- <p>
125
- <label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Text To Show', 'genesis' ); ?>:</label><br />
126
- <textarea id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" class="widefat" rows="6" cols="4"><?php echo htmlspecialchars( $instance['text'] ); ?></textarea>
127
- </p>
128
-
129
- <p>
130
- <label for="<?php echo $this->get_field_id( 'action' ); ?>"><?php _e( 'Form Action', 'genesis' ); ?>:</label>
131
- <input type="text" id="<?php echo $this->get_field_id( 'action' ); ?>" name="<?php echo $this->get_field_name( 'action' ); ?>" value="<?php echo esc_attr( $instance['action'] ); ?>" class="widefat" />
132
- </p>
133
-
134
- <p>
135
- <label for="<?php echo $this->get_field_id( 'email-field' ); ?>"><?php _e( 'E-Mail Field', 'genesis' ); ?>:</label>
136
- <input type="text" id="<?php echo $this->get_field_id( 'email-field' ); ?>" name="<?php echo $this->get_field_name( 'email-field' ); ?>" value="<?php echo esc_attr( $instance['email-field'] ); ?>" class="widefat" />
137
- </p>
138
-
139
- <p>
140
- <?php $input_text = empty( $instance['input_text'] ) ? __( 'Enter your email address...', 'genesis' ) : $instance['input_text']; ?>
141
- <label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php _e( 'Input Text', 'genesis' ); ?>:</label>
142
- <input type="text" id="<?php echo $this->get_field_id( 'input_text' ); ?>" name="<?php echo $this->get_field_name( 'input_text' ); ?>" value="<?php echo esc_attr( $input_text ); ?>" class="widefat" />
143
- </p>
144
-
145
- <p>
146
- <?php $button_text = empty( $instance['button_text'] ) ? __( 'Go', 'genesis' ) : $instance['button_text']; ?>
147
- <label for="<?php echo $this->get_field_id( 'button_text' ); ?>"><?php _e( 'Button Text', 'genesis' ); ?>:</label>
148
- <input type="text" id="<?php echo $this->get_field_id( 'button_text' ); ?>" name="<?php echo $this->get_field_name( 'button_text' ); ?>" value="<?php echo esc_attr( $button_text ); ?>" class="widefat" />
149
- </p>
150
-
151
- <?php
152
- }
153
-
154
- }
155
- add_action( 'widgets_init', 'bjgk_genesis_enews_load_widgets' );
156
-
157
- function bjgk_genesis_enews_load_widgets() {
158
-
159
- register_widget( 'BJGK_Genesis_eNews_Extended' );
160
-
 
 
 
 
 
 
 
161
  }
1
+ <?php
2
+ /**
3
+ * Plugin Name: Genesis eNews Extended
4
+ * Plugin URI: http://www.brandonkraft.com/contrib/plugins/genesis-enews-extended/
5
+ * Description: Replaces the Genesis eNews Widget to allow easier use of additional mailing services.
6
+ * Version: 0.1.1
7
+ * Author: Brandon Kraft
8
+ * Author URI: http://www.brandonkraft.com
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
11
+ * General Public License version 2, as published by the Free Software Foundation. You may NOT assume
12
+ * that you can use any other version of the GPL.
13
+ *
14
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
15
+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
+ *
17
+ * @package BJGK_Genesis_enews_extended
18
+ * @version 0.1.1
19
+ * @author Brandon Kraft <bk@kraft.im>
20
+ * @copyright Copyright (c) 2012, Brandon Kraft
21
+ * @link http://www.brandonkraft.com
22
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23
+ */
24
+
25
+ class BJGK_Genesis_eNews_Extended extends WP_Widget {
26
+
27
+ /**
28
+ * Holds widget settings defaults, populated in constructor.
29
+ *
30
+ * @var array
31
+ */
32
+ protected $defaults;
33
+
34
+ /**
35
+ * Constructor. Set the default widget options and create widget.
36
+ */
37
+ function __construct() {
38
+
39
+ $this->defaults = array(
40
+ 'title' => '',
41
+ 'text' => '',
42
+ 'hidden_fields' => '',
43
+ 'input_text' => '',
44
+ 'button_text' => '',
45
+ 'action' => '',
46
+ );
47
+
48
+ $widget_ops = array(
49
+ 'classname' => 'enews-extended-widget',
50
+ 'description' => __( 'Displays subscribe form', 'genesis' ),
51
+ );
52
+
53
+ $this->WP_Widget( 'enews-ext', __( 'Genesis - eNews Extended', 'genesis' ), $widget_ops );
54
+
55
+ }
56
+
57
+ /**
58
+ * Echo the widget content.
59
+ *
60
+ * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
61
+ * @param array $instance The settings for the particular instance of the widget
62
+ */
63
+ function widget( $args, $instance ) {
64
+
65
+ extract( $args );
66
+
67
+ /** Merge with defaults */
68
+ $instance = wp_parse_args( (array) $instance, $this->defaults );
69
+
70
+ echo $before_widget . '<div class="enews">';
71
+
72
+ if ( ! empty( $instance['title'] ) )
73
+ echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
74
+
75
+ echo wpautop( $instance['text'] ); // We run KSES on update
76
+
77
+ if ( ! empty( $instance['action'] ) ) : ?>
78
+ <form id="subscribe" action="<?php echo esc_js( $instance['action'] ); ?>" method="post" target="_blank">
79
+ <input type="text" value="<?php echo esc_attr( $instance['input_text'] ); ?>" id="subbox" onfocus="if ( this.value == '<?php echo esc_js( $instance['input_text'] ); ?>') { this.value = ''; }" onblur="if ( this.value == '' ) { this.value = '<?php echo esc_js( $instance['input_text'] ); ?>'; }" name="<?php echo esc_js( $instance['email-field'] ); ?>" />
80
+ <?php echo $instance['hidden_fields']; ?>
81
+ <input type="submit" value="<?php echo esc_attr( $instance['button_text'] ); ?>" id="subbutton" />
82
+ </form>
83
+ <?php endif;
84
+
85
+ echo '</div>' . $after_widget;
86
+
87
+ }
88
+
89
+ /**
90
+ * Update a particular instance.
91
+ *
92
+ * This function should check that $new_instance is set correctly.
93
+ * The newly calculated value of $instance should be returned.
94
+ * If "false" is returned, the instance won't be saved/updated.
95
+ *
96
+ * @param array $new_instance New settings for this instance as input by the user via form()
97
+ * @param array $old_instance Old settings for this instance
98
+ * @return array Settings to save or bool false to cancel saving
99
+ */
100
+ function update( $new_instance, $old_instance ) {
101
+
102
+ $new_instance['title'] = strip_tags( $new_instance['title'] );
103
+ $new_instance['text'] = wp_kses( $new_instance['text'], genesis_formatting_allowedtags() );
104
+ /** $new_instance['hidden_fields'] = strip_tags( $new_instance['hidden_fields'], "input" ); */
105
+ return $new_instance;
106
+
107
+ }
108
+
109
+ /**
110
+ * Echo the settings update form.
111
+ *
112
+ * @param array $instance Current settings
113
+ */
114
+ function form( $instance ) {
115
+
116
+ /** Merge with defaults */
117
+ $instance = wp_parse_args( (array) $instance, $this->defaults );
118
+
119
+ ?>
120
+ <p>
121
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'genesis' ); ?>:</label><br />
122
+ <input type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" />
123
+ </p>
124
+
125
+ <p>
126
+ <label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Text To Show', 'genesis' ); ?>:</label><br />
127
+ <textarea id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" class="widefat" rows="6" cols="4"><?php echo htmlspecialchars( $instance['text'] ); ?></textarea>
128
+ </p>
129
+
130
+ <p>
131
+ <label for="<?php echo $this->get_field_id( 'action' ); ?>"><?php _e( 'Form Action', 'genesis' ); ?>:</label>
132
+ <input type="text" id="<?php echo $this->get_field_id( 'action' ); ?>" name="<?php echo $this->get_field_name( 'action' ); ?>" value="<?php echo esc_attr( $instance['action'] ); ?>" class="widefat" />
133
+ </p>
134
+
135
+ <p>
136
+ <label for="<?php echo $this->get_field_id( 'email-field' ); ?>"><?php _e( 'E-Mail Field', 'genesis' ); ?>:</label>
137
+ <input type="text" id="<?php echo $this->get_field_id( 'email-field' ); ?>" name="<?php echo $this->get_field_name( 'email-field' ); ?>" value="<?php echo esc_attr( $instance['email-field'] ); ?>" class="widefat" />
138
+ </p>
139
+
140
+ <p>
141
+ <label for="<?php echo $this->get_field_id( 'hidden_fields' ); ?>"><?php _e( 'Hidden Fields', 'genesis' ); ?>:</label>
142
+ <textarea id="<?php echo $this->get_field_id( 'hidden_fields' ); ?>" name="<?php echo $this->get_field_name( 'hidden_fields' ); ?>" class="widefat"><?php echo esc_attr( $instance['hidden_fields'] ); ?></textarea>
143
+ <br><small>Not all services use hidden fields.</small>
144
+ </p>
145
+
146
+ <p>
147
+ <?php $input_text = empty( $instance['input_text'] ) ? __( 'Enter your email address...', 'genesis' ) : $instance['input_text']; ?>
148
+ <label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php _e( 'Input Text', 'genesis' ); ?>:</label>
149
+ <input type="text" id="<?php echo $this->get_field_id( 'input_text' ); ?>" name="<?php echo $this->get_field_name( 'input_text' ); ?>" value="<?php echo esc_attr( $input_text ); ?>" class="widefat" />
150
+ </p>
151
+
152
+ <p>
153
+ <?php $button_text = empty( $instance['button_text'] ) ? __( 'Go', 'genesis' ) : $instance['button_text']; ?>
154
+ <label for="<?php echo $this->get_field_id( 'button_text' ); ?>"><?php _e( 'Button Text', 'genesis' ); ?>:</label>
155
+ <input type="text" id="<?php echo $this->get_field_id( 'button_text' ); ?>" name="<?php echo $this->get_field_name( 'button_text' ); ?>" value="<?php echo esc_attr( $button_text ); ?>" class="widefat" />
156
+ </p>
157
+
158
+ <?php
159
+ }
160
+
161
+ }
162
+ add_action( 'widgets_init', 'bjgk_genesis_enews_load_widgets' );
163
+
164
+ function bjgk_genesis_enews_load_widgets() {
165
+
166
+ register_widget( 'BJGK_Genesis_eNews_Extended' );
167
+
168
  }
readme.txt CHANGED
@@ -1,36 +1,42 @@
1
- === Genesis eNews Extended ===
2
- Contributors: kraftbj
3
- Tags: genesis
4
- Requires at least: 3.0
5
- Tested up to: 3.3
6
- Stable tag: 0.1
7
-
8
- Creates a new widget to replace the Genesis eNews Widget to allow easier use of non-Feedburner mailing lists.
9
-
10
- == Description ==
11
-
12
- Creates a new widget to replace the Genesis eNews Widget to allow easier use of non-Feedburner mailing lists.
13
-
14
- == Installation ==
15
-
16
- 1. Upload contents of the directory to /wp-content/plugins/ (or use the automatic installer)
17
- 1. Activate the plugin through the 'Plugins' menu in WordPress
18
- 1. In Appearance->Widgerts, add Genesis eNews Extended widget to any sidebar.
19
- 1. Using the mailing list contact form code provided by your vendor, add the form action URL and the form field name for the e-mail field into the widget options.
20
- 1. Verify it works!
21
-
22
- == Frequently Asked Questions ==
23
-
24
- = What services work with this plugin? =
25
-
26
- I've only tested this with MailChimp. If you have tested this with other services, please [contact me](http://brandonkraft.com/contact/)
27
-
28
- == Changelog ==
29
-
30
- = 0.1 =
31
- * Inital release.
32
-
33
- == Upgrade Notice ==
34
-
35
- = 0.1 =
36
- Initial stable release. Please update from alpha now.
 
 
 
 
 
 
1
+ === Genesis eNews Extended ===
2
+ Contributors: kraftbj
3
+ Tags: genesis
4
+ Requires at least: 3.0
5
+ Tested up to: 3.4-beta1
6
+ Stable tag: 0.1.1
7
+
8
+ Creates a new widget to replace the Genesis eNews Widget to allow easier use of non-Feedburner mailing lists.
9
+
10
+ == Description ==
11
+
12
+ Creates a new widget to replace the Genesis eNews Widget to allow easier use of non-Feedburner mailing lists. The widget allows the site administrator to set the form action, e-mail form field and hidden fields to mimic the subscribe form of other mailing list services.
13
+
14
+ == Installation ==
15
+
16
+ 1. Upload contents of the directory to /wp-content/plugins/ (or use the automatic installer)
17
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
18
+ 1. In Appearance->Widgerts, add Genesis eNews Extended widget to any sidebar.
19
+ 1. Using the mailing list contact form code provided by your vendor, add the form action URL, the form field ID for the e-mail field and any hidden fields (not all services use them) into the widget options.
20
+ 1. Verify it works!
21
+
22
+ == Frequently Asked Questions ==
23
+
24
+ = What services work with this plugin? =
25
+
26
+ I've only tested this with MailChimp, but should work with most mailing list services. If you have tested this with other services, please [contact me](http://brandonkraft.com/contact/)
27
+
28
+ == Changelog ==
29
+
30
+ = 0.1 =
31
+ * Inital release.
32
+
33
+ = 0.1.1 =
34
+ * Adds "Hidden Fields" widget setting to make widget compatible with more mailing services.
35
+
36
+ == Upgrade Notice ==
37
+
38
+ = 0.1 =
39
+ Initial stable release. Please update from alpha now.
40
+
41
+ = 0.1.1 =
42
+ * Adds "Hidden Fields" widget setting to make widget compatible with more mailing services. Upgrade if you want to use AWeber or other services that require one or more hidden fields.