PluginProbe
Mailchimp List Subscribe Form / 1.8.0
Mailchimp List Subscribe Form v1.8.0
1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 All 55 releases
mailchimp / views / setup_page.php

setup_page.php in Mailchimp List Subscribe Form 1.8.0, at views/setup_page.php

397 lines 16.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * View file for the setup page.
4 *
5 * @package Mailchimp
6 */
7
8 use function Mailchimp\WordPress\Includes\Admin\admin_notice_error;
9
10 $user = get_option( 'mc_user' );
11
12 // If we have an API Key, see if we need to change the lists and its options
13 mailchimp_sf_change_list_if_necessary();
14
15 $is_list_selected = false;
16 ?>
17 <div class="wrap">
18 <hr class="wp-header-end" />
19 <table class="mc-user" cellspacing="0">
20 <tr>
21 <td><h3><?php esc_html_e( 'Logged in as', 'mailchimp' ); ?>: <?php echo esc_html( $user['username'] ); ?></h3>
22 </td>
23 <td>
24 <form method="post" action="" onsubmit="return confirm('<?php echo esc_js( __( 'Are you sure you want to log out?', 'mailchimp' ) ); ?>');">
25 <input type="hidden" name="mcsf_action" value="logout"/>
26 <input type="submit" name="Submit" value="<?php esc_attr_e( 'Logout', 'mailchimp' ); ?>" class="button button-secondary mailchimp-sf-button small" />
27 <?php wp_nonce_field( 'mc_logout', '_mcsf_nonce_action' ); ?>
28 </form>
29 </td>
30 </tr>
31 </table>
32 <?php
33 // Just get out if nothing else matters...
34 $api = mailchimp_sf_get_api();
35 if ( ! $api ) {
36 return;
37 }
38 ?>
39 <h3 class="mc-h2"><?php esc_html_e( 'Your Lists', 'mailchimp' ); ?></h3>
40
41 <div>
42 <p class="mc-p"><?php esc_html_e( 'Please select the Mailchimp list you\'d like to connect to your form.', 'mailchimp' ); ?></p>
43 <p class="mc-list-note"><strong><?php esc_html_e( 'Note:', 'mailchimp' ); ?></strong> <?php esc_html_e( 'Updating your list will not remove list settings in this plugin, but changing lists will.', 'mailchimp' ); ?></p>
44
45 <form method="post" action="<?php echo esc_url( add_query_arg( array( 'page' => 'mailchimp_sf_options' ), admin_url( 'admin.php' ) ) ); ?>">
46 <?php
47 // we *could* support paging, but few users have that many lists (and shouldn't)
48 $lists = $api->get( 'lists', 100, array( 'fields' => 'lists.id,lists.name,lists.email_type_option' ) );
49 if ( is_wp_error( $lists ) ) {
50 $msg = sprintf(
51 /* translators: %s: error message */
52 esc_html__( 'Uh-oh, we couldn\'t get your lists from Mailchimp! Error: %s', 'mailchimp' ),
53 esc_html( $lists->get_error_message() )
54 );
55 admin_notice_error( $msg );
56 } elseif ( isset( $lists['lists'] ) && count( $lists['lists'] ) === 0 ) {
57 $msg = sprintf(
58 /* translators: %s: link to Mailchimp */
59 esc_html__( 'Uh-oh, you don\'t have any lists defined! Please visit %s, login, and setup a list before using this tool!', 'mailchimp' ),
60 "<a href='http://www.mailchimp.com/'>Mailchimp</a>"
61 );
62 admin_notice_error( $msg );
63 } else {
64 $lists = $lists['lists'];
65 $option = get_option( 'mc_list_id' );
66 $list_ids = array_map(
67 function ( $ele ) {
68 return $ele['id'];
69 },
70 $lists
71 );
72 $is_list_selected = in_array( $option, $list_ids, true );
73 ?>
74 <table class="mc-list-select" cellspacing="0">
75 <tr class="mc-list-row">
76 <td>
77 <label class="screen-reader-text" for="mc_list_id"><?php esc_html_e( 'Select a list', 'mailchimp' ); ?></label>
78 <select id="mc_list_id" name="mc_list_id" style="min-width:200px;">
79 <option value=""> &mdash; <?php esc_html_e( 'Select A List', 'mailchimp' ); ?> &mdash; </option>
80 <?php
81 foreach ( $lists as $list ) {
82 ?>
83 <option value="<?php echo esc_attr( $list['id'] ); ?>"<?php selected( $list['id'], $option ); ?>><?php echo esc_html( $list['name'] ); ?></option>
84 <?php
85 }
86 ?>
87 </select>
88 </td>
89 <td>
90 <input type="hidden" name="mcsf_action" value="update_mc_list_id" />
91 <input type="submit" name="Submit" value="<?php esc_attr_e( 'Update List', 'mailchimp' ); ?>" class="button mailchimp-sf-button small" />
92 </td>
93 </tr>
94 </table>
95 <?php
96 } //end select list
97 ?>
98 </form>
99 </div>
100
101 <br/>
102
103 <?php
104 // Just get out if nothing else matters...
105 if ( ! $is_list_selected ) {
106 return;
107 }
108
109 // The main Settings form
110 ?>
111 <div>
112 <form method="post" action="<?php echo esc_url( add_query_arg( array( 'page' => 'mailchimp_sf_options' ), admin_url( 'admin.php' ) ) ); ?>">
113 <div class="mc-section">
114 <input type="hidden" name="mcsf_action" value="change_form_settings">
115 <?php wp_nonce_field( 'update_general_form_settings', '_mcsf_nonce_action' ); ?>
116
117 <table class="widefat mc-widefat mc-label-options">
118 <tr><th colspan="2"><?php esc_html_e( 'Content Options', 'mailchimp' ); ?></th></tr>
119 <tr valign="top">
120 <th scope="row">
121 <label for="mc_header_content"><?php esc_html_e( 'Header', 'mailchimp' ); ?></label>
122 </th>
123 <td>
124 <textarea class="widefat" id="mc_header_content" name="mc_header_content" rows="2"><?php echo wp_kses_post( get_option( 'mc_header_content' ) ); ?></textarea><br/>
125 <?php esc_html_e( 'Add your own text, HTML markup (including image links), or keep it blank.', 'mailchimp' ); ?>
126 </td>
127 </tr>
128
129 <tr valign="top">
130 <th scope="row">
131 <label for="mc_subheader_content"><?php esc_html_e( 'Sub-header', 'mailchimp' ); ?></label>
132 </th>
133 <td>
134 <textarea class="widefat" id="mc_subheader_content" name="mc_subheader_content" rows="2"><?php echo wp_kses_post( get_option( 'mc_subheader_content' ) ); ?></textarea><br/>
135 <?php esc_html_e( 'Add your own text, HTML markup (including image links), or keep it blank.', 'mailchimp' ); ?><br/>
136 <?php esc_html_e( 'This will be displayed under the heading and above the form.', 'mailchimp' ); ?>
137 </td>
138 </tr>
139
140 <tr valign="top" class="last-row">
141 <th scope="row">
142 <label for="mc_submit_text"><?php esc_html_e( 'Submit Button', 'mailchimp' ); ?></label>
143 </th>
144 <td>
145 <input class="widefat" type="text" id="mc_submit_text" name="mc_submit_text" size="70" value="<?php echo esc_attr( get_option( 'mc_submit_text' ) ); ?>"/>
146 </td>
147 </tr>
148 </table>
149 <input type="submit" value="<?php esc_attr_e( 'Update Subscribe Form Settings', 'mailchimp' ); ?>" class="button mailchimp-sf-button small mc-submit" /><br/>
150
151 <?php
152 if ( get_option( 'mc_nuke_all_styles' ) === '1' ) {
153 ?>
154 <table class="widefat mc-widefat mc-nuke-styling">
155 <tr><th colspan="2"><?php esc_html_e( 'Remove Mailchimp CSS', 'mailchimp' ); ?></th></tr>
156 <tr><th><label for="mc_nuke_all_styles"><?php esc_html_e( 'Remove CSS' ); ?></label></th><td><span class="mc-pre-input"></span><input type="checkbox" name="mc_nuke_all_styles" id="mc_nuke_all_styles" <?php checked( get_option( 'mc_nuke_all_styles' ), true ); ?> onclick="showMe('mc-custom-styling')"/><?php esc_html_e( 'This will disable all Mailchimp CSS, so it\'s recommended for WordPress experts only.' ); ?></td></tr>
157 </table>
158 <?php
159 }
160
161 if ( 'on' === get_option( 'mc_custom_style' ) ) {
162 ?>
163 <table class="widefat mc-widefat mc-custom-styling" id="mc-custom-styling" style="<?php echo esc_attr( ( get_option( 'mc_nuke_all_styles' ) === '1' ? 'display:none;' : '' ) ); ?>">
164 <tr>
165 <th colspan="2"><?php esc_html_e( 'Custom Styling', 'mailchimp' ); ?></th>
166 </tr>
167 <tr>
168 <th>
169 <label for="mc_custom_style"><?php esc_html_e( 'Enabled?', 'mailchimp' ); ?></label>
170 </th>
171 <td>
172 <span class="mc-pre-input"></span>
173 <input type="checkbox" name="mc_custom_style" id="mc_custom_style"<?php checked( get_option( 'mc_custom_style' ), 'on' ); ?> />
174 <em><?php esc_html_e( 'Edit the default Mailchimp CSS style.' ); ?></em>
175 </td>
176 </tr>
177 <tr>
178 <th>
179 <label for="mc_form_border_width"><?php esc_html_e( 'Border Width (px)', 'mailchimp' ); ?></label>
180 </th>
181 <td>
182 <input type="text" id="mc_form_border_width" name="mc_form_border_width" size="3" maxlength="3" value="<?php echo esc_attr( get_option( 'mc_form_border_width' ) ); ?>"/>
183 <em><?php esc_html_e( 'Set to 0 for no border, do not enter', 'mailchimp' ); ?> px</em>
184 </td>
185 </tr>
186 <tr>
187 <th>
188 <label for="mc_form_border_color"><?php esc_html_e( 'Border Color', 'mailchimp' ); ?></label>
189 </th>
190 <td>
191 <span class="mc-pre-input">#</span>
192 <input type="text" id="mc_form_border_color" name="mc_form_border_color" size="7" maxlength="6" value="<?php echo esc_attr( get_option( 'mc_form_border_color' ) ); ?>"/>
193 <em><?php esc_html_e( 'Do not enter initial', 'mailchimp' ); ?> <strong>#</strong></em>
194 </td>
195 </tr>
196 <tr>
197 <th>
198 <label for="mc_form_text_color"><?php esc_html_e( 'Text Color', 'mailchimp' ); ?></label>
199 </th>
200 <td>
201 <span class="mc-pre-input">#</span>
202 <input type="text" id="mc_form_text_color" name="mc_form_text_color" size="7" maxlength="6" value="<?php echo esc_attr( get_option( 'mc_form_text_color' ) ); ?>"/>
203 <em><?php esc_html_e( 'Do not enter initial', 'mailchimp' ); ?> <strong>#</strong></em>
204 </td>
205 </tr>
206 <tr class="last-row">
207 <th>
208 <label for="mc_form_background"><?php esc_html_e( 'Background Color', 'mailchimp' ); ?></label>
209 </th>
210 <td>
211 <span class="mc-pre-input">#</span>
212 <input type="text" id="mc_form_background" name="mc_form_background" size="7" maxlength="6" value="<?php echo esc_attr( get_option( 'mc_form_background' ) ); ?>"/>
213 <em><?php esc_html_e( 'Do not enter initial', 'mailchimp' ); ?> <strong>#</strong></em>
214 </td>
215 </tr>
216 </table>
217 <input type="submit" value="<?php esc_attr_e( 'Update Subscribe Form Settings', 'mailchimp' ); ?>" class="button mailchimp-sf-button small mc-submit" /><br/>
218 <?php
219 }
220 ?>
221
222 <table class="widefat mc-widefat">
223 <tr><th colspan="2"><?php esc_html_e( 'List Options', 'mailchimp' ); ?></th></tr>
224
225 <tr valign="top">
226 <th scope="row"><?php esc_html_e( 'Use Double Opt-In (Recommended)?', 'mailchimp' ); ?></th>
227 <td><input name="mc_double_optin" type="checkbox" <?php checked( get_option( 'mc_double_optin' ), true ); ?> id="mc_double_optin" class="code" />
228 <em><label for="mc_double_optin"><?php esc_html_e( 'Before new your subscribers are added via the plugin, they\'ll need to confirm their email address.', 'mailchimp' ); ?></label></em>
229 </td>
230 </tr>
231 <tr valign="top">
232 <th scope="row"><?php esc_html_e( 'Update existing subscribers?', 'mailchimp' ); ?></th>
233 <td><input name="mc_update_existing" type="checkbox" <?php checked( get_option( 'mc_update_existing' ), true ); ?> id="mc_update_existing" class="code" />
234 <em><label for="mc_update_existing"><?php esc_html_e( 'If an existing subscriber fills out this form, we will update their information with what\'s provided.', 'mailchimp' ); ?></label></em>
235 </td>
236 </tr>
237
238 <tr valign="top" class="last-row">
239 <th scope="row"><?php esc_html_e( 'Include Unsubscribe link?', 'mailchimp' ); ?></th>
240 <td><input name="mc_use_unsub_link" type="checkbox"<?php checked( get_option( 'mc_use_unsub_link' ), 'on' ); ?> id="mc_use_unsub_link" class="code" />
241 <em><label for="mc_use_unsub_link"><?php esc_html_e( 'We\'ll automatically add a link to your list\'s unsubscribe form.', 'mailchimp' ); ?></label></em>
242 </td>
243 </tr>
244 <tr valign="top">
245 <td colspan="2">
246 <?php
247 echo wp_kses(
248 sprintf(
249 /* translators: %s: link to Mailchimp */
250 __( '<strong>Note:</strong> If you haven\'t already, please <a href="%s" target="_blank" rel="noopener noreferrer">add</a> your website URL to your Mailchimp Audience account settings so users can properly return to your site after subscribing.', 'mailchimp' ),
251 'https://mailchimp.com/help/change-or-update-the-return-to-our-website-button/'
252 ),
253 [
254 'a' => [
255 'href' => [],
256 'target' => [],
257 'rel' => [],
258 ],
259 'strong' => [],
260 ]
261 )
262 ?>
263 </td>
264 </tr>
265 </table>
266 <input type="submit" value="<?php esc_attr_e( 'Update Subscribe Form Settings', 'mailchimp' ); ?>" class="button mailchimp-sf-button small mc-submit" /><br/>
267 </div>
268
269 <?php
270 $mv = get_option( 'mc_merge_vars' );
271
272 if ( ! is_array( $mv ) || count( $mv ) === 0 ) {
273 ?>
274 <div class="mc-section">
275 <table class='widefat mc-widefat'>
276 <tr><th><?php esc_html_e( 'Merge Fields Included', 'mailchimp' ); ?></th></tr>
277 <tr><td><em><?php esc_html_e( 'No Merge Fields found.', 'mailchimp' ); ?></em></td></tr>
278 </table>
279 </div>
280 <?php
281 } else {
282 ?>
283 <div class="mc-section">
284 <table class='widefat mc-widefat'>
285 <tr>
286 <th colspan="4">
287 <?php esc_html_e( 'Merge Fields Included', 'mailchimp' ); ?>
288 </th>
289 </tr>
290 <tr valign="top">
291 <th><?php esc_html_e( 'Name', 'mailchimp' ); ?></th>
292 <th><?php esc_html_e( 'Tag', 'mailchimp' ); ?></th>
293 <th><?php esc_html_e( 'Required?', 'mailchimp' ); ?></th>
294 <th><?php esc_html_e( 'Include?', 'mailchimp' ); ?></th>
295 </tr>
296 <?php
297 foreach ( $mv as $mv_var ) {
298 ?>
299 <tr valign="top">
300 <td><?php echo esc_html( $mv_var['name'] ); ?></td>
301 <td><?php echo esc_html( $mv_var['tag'] ); ?></td>
302 <td><?php echo esc_html( ( 1 === intval( $mv_var['required'] ) ) ? 'Y' : 'N' ); ?></td>
303 <td>
304 <?php
305 if ( ! $mv_var['required'] ) {
306 $opt = 'mc_mv_' . $mv_var['tag'];
307 ?>
308 <label class="screen-reader-text" for="<?php echo esc_attr( $opt ); ?>">
309 <?php
310 echo esc_html(
311 sprintf(
312 /* translators: %s: name of field */
313 __( 'Include merge field %s?', 'mailchimp' ),
314 $mv_var['name']
315 )
316 );
317 ?>
318 </label>
319 <input name="<?php echo esc_attr( $opt ); ?>" type="checkbox" id="<?php echo esc_attr( $opt ); ?>" class="code"<?php checked( get_option( $opt ), 'on' ); ?> />
320 <?php
321 } else {
322 ?>
323 &nbsp;&mdash;&nbsp;
324 <?php
325 }
326 ?>
327 </td>
328 </tr>
329 <?php
330 }
331 ?>
332 </table>
333 <input type="submit" value="<?php esc_attr_e( 'Update Subscribe Form Settings', 'mailchimp' ); ?>" class="button mailchimp-sf-button small mc-submit" /><br/>
334 </div>
335
336 <?php
337 // Interest Groups Table
338 $igs = get_option( 'mc_interest_groups' );
339 if ( is_array( $igs ) && ! empty( $igs ) ) {
340 ?>
341 <div class="mc-section">
342 <h3 class="mc-h3"><?php esc_html_e( 'Group Settings', 'mailchimp' ); ?></h3>
343 </div>
344 <?php
345 // Determines whether or not to continue processing. Only false if there was an error.
346 $continue = true;
347 foreach ( $igs as $ig ) {
348 if ( $continue ) {
349 if ( ! is_array( $ig ) || empty( $ig ) || 'N' === $ig ) {
350 ?>
351 <em><?php esc_html_e( 'No Interest Groups Setup for this List', 'mailchimp' ); ?></em>
352 <?php
353 $continue = false;
354 } else {
355 ?>
356 <table class='mc-widefat' width="450px" cellspacing="0">
357 <tr valign="top">
358 <th colspan="2"><?php echo esc_html( $ig['title'] ); ?></th>
359 </tr>
360 <tr valign="top">
361 <th>
362 <label for="<?php echo esc_attr( 'mc_show_interest_groups_' . $ig['id'] ); ?>"><?php esc_html_e( 'Show?', 'mailchimp' ); ?></label>
363 </th>
364 <td>
365 <input name="<?php echo esc_attr( 'mc_show_interest_groups_' . $ig['id'] ); ?>" id="<?php echo esc_attr( 'mc_show_interest_groups_' . $ig['id'] ); ?>" type="checkbox" class="code"<?php checked( 'on', get_option( 'mc_show_interest_groups_' . $ig['id'] ) ); ?> />
366 </td>
367 </tr>
368 <tr valign="top">
369 <th><?php esc_html_e( 'Input Type', 'mailchimp' ); ?></th>
370 <td><?php echo esc_html( $ig['type'] ); ?></td>
371 </tr>
372 <tr valign="top" class="last-row">
373 <th><?php esc_html_e( 'Options', 'mailchimp' ); ?></th>
374 <td>
375 <ul>
376 <?php
377 foreach ( $ig['groups'] as $interest ) {
378 ?>
379 <li><?php echo esc_html( $interest['name'] ); ?></li>
380 <?php
381 }
382 ?>
383 </ul>
384 </td>
385 </tr>
386 </table>
387 <?php
388 }
389 }
390 }
391 }
392 }
393 ?>
394 </form>
395 </div>
396 </div>
397