Version Description
Download this release
Release Info
Developer | DvanKooten |
Plugin | MailChimp for WordPress |
Version | 4.7.1 |
Comparing to | |
See all releases |
Code changes from version 4.7 to 4.7.1
- CHANGELOG.md +12 -2
- config/default-form-content.php +4 -4
- config/default-form-messages.php +36 -36
- config/default-form-settings.php +9 -9
- config/default-settings.php +3 -3
- includes/admin/class-admin-ajax.php +57 -60
- includes/admin/class-admin-messages.php +61 -67
- includes/admin/class-admin-texts.php +78 -79
- includes/admin/class-admin-tools.php +60 -64
- includes/admin/class-admin.php +514 -541
- includes/admin/class-ads.php +144 -153
- includes/admin/class-review-notice.php +71 -76
- includes/admin/class-update-optin.php +174 -181
- includes/admin/class-upgrade-routines.php +59 -63
- includes/admin/class-usage-tracking.php +185 -200
- includes/admin/migrations/3.0.0-form-1-post-type.php +48 -48
- includes/admin/migrations/3.0.0-form-2-options.php +42 -42
- includes/admin/migrations/3.0.0-form-3-messages.php +26 -26
- includes/admin/migrations/3.0.0-general-options.php +6 -6
- includes/admin/migrations/3.0.0-integration-options.php +41 -41
- includes/admin/migrations/3.0.0-styles-builder.php +20 -20
- includes/admin/migrations/3.0.0-widget-base-id.php +25 -25
- includes/admin/migrations/3.0.3-usage-tracking-schedule.php +13 -14
- includes/admin/migrations/3.1.6-woocommerce-position-prefix.php +5 -5
- includes/admin/migrations/4.0.0-groupings-to-interests.php +73 -75
- includes/admin/migrations/4.0.0-hidden-fields-value-delimiter.php +20 -16
- includes/admin/migrations/4.0.7-rename-debug-log-file.php +19 -19
- includes/admin/migrations/4.1.2-flush-list-cache.php +6 -6
- includes/admin/migrations/4.1.3-reschedule-event.php +4 -4
- includes/admin/migrations/4.6.0-remove-lists-from-options.php +1 -1
- includes/api/class-api-v3-client.php +237 -250
- includes/api/class-api-v3.php +1250 -1332
- includes/api/class-api.php +567 -590
- includes/api/class-connection-exception.php +2 -2
- includes/api/class-exception.php +106 -109
- includes/api/class-resource-not-found-exception.php +3 -3
- includes/class-container.php +100 -106
- includes/class-debug-log-reader.php +150 -156
- includes/class-debug-log.php +242 -218
- includes/class-dynamic-content-tags.php +241 -254
- includes/class-field-formatter.php +139 -144
- includes/class-field-guesser.php +121 -126
- includes/class-list-data-mapper.php +152 -153
- includes/class-mailchimp-subscriber.php +50 -51
- includes/class-mailchimp.php +409 -385
- includes/class-plugin.php +58 -63
- includes/class-queue-job.php +27 -28
- includes/class-queue.php +171 -180
- includes/class-tools.php +274 -276
- includes/default-actions.php +2 -2
- includes/default-filters.php +8 -8
- includes/deprecated-functions.php +13 -17
- includes/forms/admin-functions.php +9 -11
- includes/forms/class-admin.php +464 -472
- includes/forms/class-asset-manager.php +227 -239
- includes/forms/class-form-element.php +355 -366
- includes/forms/class-form-listener.php +310 -318
- includes/forms/class-form-manager.php +139 -146
- includes/forms/class-form-message.php +26 -28
- includes/forms/class-form-previewer.php +29 -32
- includes/forms/class-form-tags.php +112 -120
- includes/forms/class-form.php +748 -777
- includes/forms/class-google-recaptcha.php +208 -197
- includes/forms/class-output-manager.php +114 -132
- includes/forms/class-widget.php +115 -118
- includes/forms/functions.php +47 -53
- includes/forms/views/add-form.php +26 -22
- includes/forms/views/edit-form.php +90 -86
- includes/forms/views/js/date-fields.js +7 -8
- includes/forms/views/js/dummy-api.js +7 -5
- includes/forms/views/js/general-form-enhancements.js +5 -5
- includes/forms/views/js/url-fields.js +6 -6
- includes/forms/views/parts/add-fields-help.php +19 -17
- includes/forms/views/parts/dynamic-content-tags.php +13 -10
- includes/forms/views/preview.php +36 -36
- includes/forms/views/tabs/form-appearance.php +33 -31
- includes/forms/views/tabs/form-fields.php +13 -13
- includes/forms/views/tabs/form-messages.php +43 -38
- includes/forms/views/tabs/form-settings.php +81 -70
- includes/functions.php +252 -271
- includes/integrations/class-admin.php +175 -185
- includes/integrations/class-integration-fixture.php +78 -82
- includes/integrations/class-integration-manager.php +168 -180
- includes/integrations/class-integration-tags.php +44 -48
- includes/integrations/class-integration.php +116 -134
- includes/integrations/class-user-integration.php +39 -40
- includes/integrations/functions.php +8 -12
- includes/integrations/views/integration-settings.php +197 -149
- includes/integrations/views/integrations.php +83 -77
- includes/views/extensions.php +5 -5
- includes/views/general-settings.php +42 -38
- includes/views/other-settings.php +69 -69
- includes/views/parts/admin-footer.php +25 -28
- includes/views/parts/admin-sidebar.php +30 -32
- includes/views/parts/lists-overview.php +45 -42
- integrations/affiliatewp/class-affiliatewp.php +76 -80
- integrations/bootstrap.php +27 -29
- integrations/buddypress/class-buddypress.php +169 -175
- integrations/contact-form-7/admin-before.php +2 -2
- integrations/contact-form-7/class-contact-form-7.php +160 -170
- integrations/custom/admin-before.php +3 -3
- integrations/custom/class-custom.php +102 -108
- integrations/easy-digital-downloads/class-easy-digital-downloads.php +107 -112
- integrations/events-manager/class-events-manager.php +69 -72
- integrations/give/class-give.php +39 -42
- integrations/gravity-forms/admin-before.php +5 -2
- integrations/gravity-forms/bootstrap.php +4 -4
- integrations/gravity-forms/class-field.php +122 -122
- integrations/gravity-forms/class-gravity-forms.php +155 -157
- integrations/memberpress/class-memberpress.php +53 -49
- integrations/ninja-forms-2/admin-before.php +2 -2
- integrations/ninja-forms-2/class-ninja-forms.php +143 -136
- integrations/ninja-forms/admin-before.php +2 -2
- integrations/ninja-forms/bootstrap.php +9 -9
- integrations/ninja-forms/class-action.php +143 -147
- integrations/ninja-forms/class-field.php +89 -92
- integrations/ninja-forms/class-ninja-forms.php +50 -55
- integrations/woocommerce/admin-after.php +23 -13
- integrations/woocommerce/class-woocommerce.php +153 -153
- integrations/wp-comment-form/class-comment-form.php +107 -113
- integrations/wp-registration-form/class-registration-form.php +84 -88
- integrations/wpforms/admin-before.php +2 -2
- integrations/wpforms/bootstrap.php +7 -8
- integrations/wpforms/class-field.php +249 -263
- integrations/wpforms/class-wpforms.php +56 -62
- languages/index.php +7 -0
- languages/mailchimp-for-wp-af_ZA.mo +0 -0
- languages/mailchimp-for-wp-af_ZA.po +0 -1634
- languages/mailchimp-for-wp-bg_BG.mo +0 -0
- languages/mailchimp-for-wp-bg_BG.po +0 -1094
- languages/mailchimp-for-wp-ca_ES.mo +0 -0
- languages/mailchimp-for-wp-ca_ES.po +0 -1054
CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1 |
Changelog
|
2 |
=========
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
#### 4.7 - Nov 7, 2019
|
6 |
|
@@ -1252,7 +1262,7 @@ Before upgrading, please go through the [upgrade guide](https://mc4wp.com/kb/upg
|
|
1252 |
|
1253 |
**Improvements**
|
1254 |
|
1255 |
-
- Updated Italian, Russian & Turkish translations.
|
1256 |
|
1257 |
#### 2.2.8 - March 24, 2015
|
1258 |
|
@@ -1342,7 +1352,7 @@ A huge thank you to [Stefan Oderbolz](http://metaodi.ch/) for various fixed and
|
|
1342 |
|
1343 |
- Moved third-party scripts to their own directory for easier exclusion
|
1344 |
- All code is now adhering to the WP Code Standards
|
1345 |
-
- Updated
|
1346 |
|
1347 |
**Additions**
|
1348 |
|
1 |
Changelog
|
2 |
=========
|
3 |
|
4 |
+
#### 4.7.1 - Nov 26, 2019
|
5 |
+
|
6 |
+
**Improvements**
|
7 |
+
|
8 |
+
- Update MemberPress hook names. Thanks [Ian Heggaton](https://github.com/pixelated-au)!
|
9 |
+
- Use WordPress.org translations instead of bundling translation files in plugin itself.
|
10 |
+
- Write .htaccess to directory of debug log file, to prevent file access.
|
11 |
+
- Add some convenient hooks for Checkout for WooCommerce.
|
12 |
+
- Stop parsing shortcodes in text widgets as WordPress core does this since version 4.9.
|
13 |
+
|
14 |
|
15 |
#### 4.7 - Nov 7, 2019
|
16 |
|
1262 |
|
1263 |
**Improvements**
|
1264 |
|
1265 |
+
- Updated Italian, Russian & Turkish translations.
|
1266 |
|
1267 |
#### 2.2.8 - March 24, 2015
|
1268 |
|
1352 |
|
1353 |
- Moved third-party scripts to their own directory for easier exclusion
|
1354 |
- All code is now adhering to the WP Code Standards
|
1355 |
+
- Updated Dutch, German, Spanish, Hungarian, French, Italian and Turkish translations.
|
1356 |
|
1357 |
**Additions**
|
1358 |
|
config/default-form-content.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
$email_label
|
4 |
-
$email_placeholder
|
5 |
-
$signup_button
|
6 |
|
7 |
-
$content
|
8 |
$content .= "\t\t<input type=\"email\" name=\"EMAIL\" placeholder=\"{$email_placeholder}\" required />\n</label>\n</p>\n\n";
|
9 |
$content .= "<p>\n\t<input type=\"submit\" value=\"{$signup_button}\" />\n</p>";
|
10 |
|
1 |
<?php
|
2 |
|
3 |
+
$email_label = __( 'Email address', 'mailchimp-for-wp' );
|
4 |
+
$email_placeholder = __( 'Your email address', 'mailchimp-for-wp' );
|
5 |
+
$signup_button = __( 'Sign up', 'mailchimp-for-wp' );
|
6 |
|
7 |
+
$content = "<p>\n\t<label>{$email_label}: \n";
|
8 |
$content .= "\t\t<input type=\"email\" name=\"EMAIL\" placeholder=\"{$email_placeholder}\" required />\n</label>\n</p>\n\n";
|
9 |
$content .= "<p>\n\t<input type=\"submit\" value=\"{$signup_button}\" />\n</p>";
|
10 |
|
config/default-form-messages.php
CHANGED
@@ -1,39 +1,39 @@
|
|
1 |
<?php
|
2 |
return array(
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
);
|
1 |
<?php
|
2 |
return array(
|
3 |
+
'subscribed' => array(
|
4 |
+
'type' => 'success',
|
5 |
+
'text' => __( 'Thank you, your sign-up request was successful! Please check your email inbox to confirm.', 'mailchimp-for-wp' ),
|
6 |
+
),
|
7 |
+
'updated' => array(
|
8 |
+
'type' => 'success',
|
9 |
+
'text' => __( 'Thank you, your records have been updated!', 'mailchimp-for-wp' ),
|
10 |
+
),
|
11 |
+
'unsubscribed' => array(
|
12 |
+
'type' => 'success',
|
13 |
+
'text' => __( 'You were successfully unsubscribed.', 'mailchimp-for-wp' ),
|
14 |
+
),
|
15 |
+
'not_subscribed' => array(
|
16 |
+
'type' => 'notice',
|
17 |
+
'text' => __( 'Given email address is not subscribed.', 'mailchimp-for-wp' ),
|
18 |
+
),
|
19 |
+
'error' => array(
|
20 |
+
'type' => 'error',
|
21 |
+
'text' => __( 'Oops. Something went wrong. Please try again later.', 'mailchimp-for-wp' ),
|
22 |
+
),
|
23 |
+
'invalid_email' => array(
|
24 |
+
'type' => 'error',
|
25 |
+
'text' => __( 'Please provide a valid email address.', 'mailchimp-for-wp' ),
|
26 |
+
),
|
27 |
+
'already_subscribed' => array(
|
28 |
+
'type' => 'notice',
|
29 |
+
'text' => __( 'Given email address is already subscribed, thank you!', 'mailchimp-for-wp' ),
|
30 |
+
),
|
31 |
+
'required_field_missing' => array(
|
32 |
+
'type' => 'error',
|
33 |
+
'text' => __( 'Please fill in the required fields.', 'mailchimp-for-wp' ),
|
34 |
+
),
|
35 |
+
'no_lists_selected' => array(
|
36 |
+
'type' => 'error',
|
37 |
+
'text' => __( 'Please select at least one list.', 'mailchimp-for-wp' ),
|
38 |
+
),
|
39 |
);
|
config/default-form-settings.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
<?php
|
2 |
return array(
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
);
|
1 |
<?php
|
2 |
return array(
|
3 |
+
'css' => 0,
|
4 |
+
'double_optin' => 1,
|
5 |
+
'hide_after_success' => 0,
|
6 |
+
'lists' => array(),
|
7 |
+
'redirect' => '',
|
8 |
+
'replace_interests' => 1,
|
9 |
+
'required_fields' => '',
|
10 |
+
'update_existing' => 0,
|
11 |
+
'subscriber_tags' => '',
|
12 |
);
|
config/default-settings.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
return array(
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
);
|
1 |
<?php
|
2 |
return array(
|
3 |
+
'api_key' => '',
|
4 |
+
'allow_usage_tracking' => 0,
|
5 |
+
'debug_log_level' => 'warning',
|
6 |
);
|
includes/admin/class-admin-ajax.php
CHANGED
@@ -1,63 +1,60 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class MC4WP_Admin_Ajax
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
$
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
}
|
61 |
-
wp_send_json($data);
|
62 |
-
}
|
63 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class MC4WP_Admin_Ajax {
|
4 |
+
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @var MC4WP_Admin_Tools
|
8 |
+
*/
|
9 |
+
protected $tools;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* MC4WP_Admin_Ajax constructor.
|
13 |
+
*
|
14 |
+
* @param MC4WP_Admin_Tools $tools
|
15 |
+
*/
|
16 |
+
public function __construct( MC4WP_Admin_Tools $tools ) {
|
17 |
+
$this->tools = $tools;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Hook AJAX actions
|
22 |
+
*/
|
23 |
+
public function add_hooks() {
|
24 |
+
add_action( 'wp_ajax_mc4wp_renew_mailchimp_lists', array( $this, 'refresh_mailchimp_lists' ) );
|
25 |
+
add_action( 'wp_ajax_mc4wp_get_list_details', array( $this, 'get_list_details' ) );
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Empty lists cache & fetch lists again.
|
30 |
+
*/
|
31 |
+
public function refresh_mailchimp_lists() {
|
32 |
+
if ( ! $this->tools->is_user_authorized() ) {
|
33 |
+
wp_send_json( false );
|
34 |
+
}
|
35 |
+
|
36 |
+
$mailchimp = new MC4WP_MailChimp();
|
37 |
+
$success = $mailchimp->refresh_lists();
|
38 |
+
wp_send_json( $success );
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Retrieve details (merge fields and interest categories) for one or multiple lists in Mailchimp
|
43 |
+
* @throws MC4WP_API_Exception
|
44 |
+
*/
|
45 |
+
public function get_list_details() {
|
46 |
+
$list_ids = (array) explode( ',', $_GET['ids'] );
|
47 |
+
$data = array();
|
48 |
+
$mailchimp = new MC4WP_MailChimp();
|
49 |
+
foreach ( $list_ids as $list_id ) {
|
50 |
+
$merge_fields = $mailchimp->get_list_merge_fields( $list_id );
|
51 |
+
$interest_categories = $mailchimp->get_list_interest_categories( $list_id );
|
52 |
+
$data[] = (object) array(
|
53 |
+
'id' => $list_id,
|
54 |
+
'merge_fields' => $merge_fields,
|
55 |
+
'interest_categories' => $interest_categories,
|
56 |
+
);
|
57 |
+
}
|
58 |
+
wp_send_json( $data );
|
59 |
+
}
|
|
|
|
|
|
|
60 |
}
|
includes/admin/class-admin-messages.php
CHANGED
@@ -6,83 +6,77 @@
|
|
6 |
* @ignore
|
7 |
* @since 3.0
|
8 |
*/
|
9 |
-
class MC4WP_Admin_Messages
|
10 |
-
{
|
11 |
|
12 |
-
/**
|
13 |
-
* @var array
|
14 |
-
*/
|
15 |
-
protected $bag;
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
{
|
27 |
-
add_action('admin_notices', array( $this, 'show' ));
|
28 |
-
register_shutdown_function(array( $this, 'save' ));
|
29 |
-
}
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
}
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
*/
|
51 |
-
public function flash($message, $type = 'success')
|
52 |
-
{
|
53 |
-
$this->load();
|
54 |
-
$this->bag[] = array(
|
55 |
-
'text' => $message,
|
56 |
-
'type' => $type
|
57 |
-
);
|
58 |
-
$this->dirty = true;
|
59 |
-
}
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
|
63 |
-
/**
|
64 |
-
* Show queued flash messages
|
65 |
-
*/
|
66 |
-
public function show()
|
67 |
-
{
|
68 |
-
$this->load();
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
73 |
|
74 |
-
|
75 |
-
|
|
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
88 |
}
|
6 |
* @ignore
|
7 |
* @since 3.0
|
8 |
*/
|
9 |
+
class MC4WP_Admin_Messages {
|
|
|
10 |
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
/**
|
13 |
+
* @var array
|
14 |
+
*/
|
15 |
+
protected $bag;
|
16 |
|
17 |
+
/**
|
18 |
+
* @var bool
|
19 |
+
*/
|
20 |
+
protected $dirty = false;
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
/**
|
23 |
+
* Add hooks
|
24 |
+
*/
|
25 |
+
public function add_hooks() {
|
26 |
+
add_action( 'admin_notices', array( $this, 'show' ) );
|
27 |
+
register_shutdown_function( array( $this, 'save' ) );
|
28 |
+
}
|
29 |
|
30 |
+
private function load() {
|
31 |
+
if ( is_null( $this->bag ) ) {
|
32 |
+
$this->bag = get_option( 'mc4wp_flash_messages', array() );
|
33 |
+
}
|
34 |
+
}
|
|
|
35 |
|
36 |
+
// empty flash bag
|
37 |
+
private function reset() {
|
38 |
+
$this->bag = array();
|
39 |
+
$this->dirty = true;
|
40 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
/**
|
43 |
+
* Flash a message (shows on next pageload)
|
44 |
+
*
|
45 |
+
* @param $message
|
46 |
+
* @param string $type
|
47 |
+
*/
|
48 |
+
public function flash( $message, $type = 'success' ) {
|
49 |
+
$this->load();
|
50 |
+
$this->bag[] = array(
|
51 |
+
'text' => $message,
|
52 |
+
'type' => $type,
|
53 |
+
);
|
54 |
+
$this->dirty = true;
|
55 |
+
}
|
56 |
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
+
/**
|
60 |
+
* Show queued flash messages
|
61 |
+
*/
|
62 |
+
public function show() {
|
63 |
+
$this->load();
|
64 |
|
65 |
+
foreach ( $this->bag as $message ) {
|
66 |
+
echo sprintf( '<div class="notice notice-%s is-dismissible"><p>%s</p></div>', $message['type'], $message['text'] );
|
67 |
+
}
|
68 |
|
69 |
+
$this->reset();
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Save queued messages
|
74 |
+
*
|
75 |
+
* @hooked `shutdown`
|
76 |
+
*/
|
77 |
+
public function save() {
|
78 |
+
if ( $this->dirty ) {
|
79 |
+
update_option( 'mc4wp_flash_messages', $this->bag, false );
|
80 |
+
}
|
81 |
+
}
|
82 |
}
|
includes/admin/class-admin-texts.php
CHANGED
@@ -6,95 +6,94 @@
|
|
6 |
* @ignore
|
7 |
* @since 3.0
|
8 |
*/
|
9 |
-
class MC4WP_Admin_Texts
|
10 |
-
{
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
{
|
17 |
-
$this->plugin_file = $plugin_file;
|
18 |
-
}
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
30 |
-
if ($pagenow === 'plugins.php') {
|
31 |
-
add_filter('plugin_action_links_' . $this->plugin_file, array( $this, 'add_plugin_settings_link' ), 10, 2);
|
32 |
-
add_filter('plugin_row_meta', array( $this, 'add_plugin_meta_links'), 10, 2);
|
33 |
-
}
|
34 |
-
}
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
*/
|
43 |
-
public function footer_text($text)
|
44 |
-
{
|
45 |
-
if (! empty($_GET['page']) && strpos($_GET['page'], 'mailchimp-for-wp') === 0) {
|
46 |
-
$text = sprintf('If you enjoy using <strong>Mailchimp for WordPress</strong>, please <a href="%s" target="_blank">leave us a ★★★★★ rating</a>. A <strong style="text-decoration: underline;">huge</strong> thank you in advance!', 'https://wordpress.org/support/view/plugin-reviews/mailchimp-for-wp?rate=5#postform');
|
47 |
-
}
|
48 |
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
*
|
55 |
-
* @param array $links
|
56 |
-
* @param $file
|
57 |
-
*
|
58 |
-
* @return array
|
59 |
-
*/
|
60 |
-
public function add_plugin_settings_link($links, $file)
|
61 |
-
{
|
62 |
-
if ($file !== $this->plugin_file) {
|
63 |
-
return $links;
|
64 |
-
}
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
* @param string $file
|
76 |
-
*
|
77 |
-
* @return array
|
78 |
-
*/
|
79 |
-
public function add_plugin_meta_links($links, $file)
|
80 |
-
{
|
81 |
-
if ($file !== $this->plugin_file) {
|
82 |
-
return $links;
|
83 |
-
}
|
84 |
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
-
|
88 |
-
* Filters meta links shown on the Plugins overview page
|
89 |
-
*
|
90 |
-
* This takes an array of strings
|
91 |
-
*
|
92 |
-
* @since 3.0
|
93 |
-
* @param array $links
|
94 |
-
* @ignore
|
95 |
-
*/
|
96 |
-
$links = (array) apply_filters('mc4wp_admin_plugin_meta_links', $links);
|
97 |
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
6 |
* @ignore
|
7 |
* @since 3.0
|
8 |
*/
|
9 |
+
class MC4WP_Admin_Texts {
|
|
|
10 |
|
11 |
+
/**
|
12 |
+
* @var string
|
13 |
+
*/
|
14 |
+
protected $plugin_file;
|
|
|
|
|
|
|
15 |
|
16 |
+
/**
|
17 |
+
* @param string $plugin_file
|
18 |
+
*/
|
19 |
+
public function __construct( $plugin_file ) {
|
20 |
+
$this->plugin_file = $plugin_file;
|
21 |
+
}
|
22 |
|
23 |
+
/**
|
24 |
+
* Add hooks
|
25 |
+
*/
|
26 |
+
public function add_hooks() {
|
27 |
+
global $pagenow;
|
28 |
|
29 |
+
add_filter( 'admin_footer_text', array( $this, 'footer_text' ) );
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
// Hooks for Plugins overview page
|
32 |
+
if ( $pagenow === 'plugins.php' ) {
|
33 |
+
add_filter( 'plugin_action_links_' . $this->plugin_file, array( $this, 'add_plugin_settings_link' ), 10, 2 );
|
34 |
+
add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2 );
|
35 |
+
}
|
36 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
+
/**
|
39 |
+
* Ask for a plugin review in the WP Admin footer, if this is one of the plugin pages.
|
40 |
+
*
|
41 |
+
* @param $text
|
42 |
+
*
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
public function footer_text( $text ) {
|
46 |
+
if ( ! empty( $_GET['page'] ) && strpos( $_GET['page'], 'mailchimp-for-wp' ) === 0 ) {
|
47 |
+
$text = sprintf( 'If you enjoy using <strong>Mailchimp for WordPress</strong>, please <a href="%s" target="_blank">leave us a ★★★★★ rating</a>. A <strong style="text-decoration: underline;">huge</strong> thank you in advance!', 'https://wordpress.org/support/view/plugin-reviews/mailchimp-for-wp?rate=5#postform' );
|
48 |
+
}
|
49 |
|
50 |
+
return $text;
|
51 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
+
/**
|
54 |
+
* Add the settings link to the Plugins overview
|
55 |
+
*
|
56 |
+
* @param array $links
|
57 |
+
* @param $file
|
58 |
+
*
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
public function add_plugin_settings_link( $links, $file ) {
|
62 |
+
if ( $file !== $this->plugin_file ) {
|
63 |
+
return $links;
|
64 |
+
}
|
65 |
|
66 |
+
$settings_link = '<a href="' . admin_url( 'admin.php?page=mailchimp-for-wp' ) . '">' . __( 'Settings', 'mailchimp-for-wp' ) . '</a>';
|
67 |
+
array_unshift( $links, $settings_link );
|
68 |
+
return $links;
|
69 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
+
/**
|
72 |
+
* Adds meta links to the plugin in the WP Admin > Plugins screen
|
73 |
+
*
|
74 |
+
* @param array $links
|
75 |
+
* @param string $file
|
76 |
+
*
|
77 |
+
* @return array
|
78 |
+
*/
|
79 |
+
public function add_plugin_meta_links( $links, $file ) {
|
80 |
+
if ( $file !== $this->plugin_file ) {
|
81 |
+
return $links;
|
82 |
+
}
|
83 |
|
84 |
+
$links[] = '<a href="https://kb.mc4wp.com/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=plugins-page">' . __( 'Documentation', 'mailchimp-for-wp' ) . '</a>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
+
/**
|
87 |
+
* Filters meta links shown on the Plugins overview page
|
88 |
+
*
|
89 |
+
* This takes an array of strings
|
90 |
+
*
|
91 |
+
* @since 3.0
|
92 |
+
* @param array $links
|
93 |
+
* @ignore
|
94 |
+
*/
|
95 |
+
$links = (array) apply_filters( 'mc4wp_admin_plugin_meta_links', $links );
|
96 |
+
|
97 |
+
return $links;
|
98 |
+
}
|
99 |
}
|
includes/admin/class-admin-tools.php
CHANGED
@@ -1,76 +1,72 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class MC4WP_Admin_Tools
|
4 |
-
{
|
5 |
|
6 |
-
/**
|
7 |
-
* @return string
|
8 |
-
*/
|
9 |
-
public function get_plugin_page()
|
10 |
-
{
|
11 |
-
if (empty($_GET['page'])) {
|
12 |
-
return '';
|
13 |
-
}
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
*/
|
25 |
-
public function on_plugin_page($page = null)
|
26 |
-
{
|
27 |
-
// any settings page
|
28 |
-
if (is_null($page)) {
|
29 |
-
return isset($_GET['page']) && strpos($_GET['page'], 'mailchimp-for-wp') === 0;
|
30 |
-
}
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
* @return bool
|
40 |
-
*/
|
41 |
-
public function is_user_authorized()
|
42 |
-
{
|
43 |
-
return current_user_can($this->get_required_capability());
|
44 |
-
}
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
* @see https://codex.wordpress.org/Roles_and_Capabilities
|
71 |
-
*/
|
72 |
-
$capability = (string) apply_filters('mc4wp_admin_required_capability', $capability);
|
73 |
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class MC4WP_Admin_Tools {
|
|
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
/**
|
7 |
+
* @return string
|
8 |
+
*/
|
9 |
+
public function get_plugin_page() {
|
10 |
+
if ( empty( $_GET['page'] ) ) {
|
11 |
+
return '';
|
12 |
+
}
|
13 |
|
14 |
+
$prefix = 'mailchimp-for-wp';
|
15 |
+
$page = ltrim( substr( $_GET['page'], strlen( $prefix ) ), '-' );
|
16 |
+
return $page;
|
17 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
/**
|
20 |
+
* @param string $page
|
21 |
+
*
|
22 |
+
* @return bool
|
23 |
+
*/
|
24 |
+
public function on_plugin_page( $page = null ) {
|
25 |
+
// any settings page
|
26 |
+
if ( is_null( $page ) ) {
|
27 |
+
return isset( $_GET['page'] ) && strpos( $_GET['page'], 'mailchimp-for-wp' ) === 0;
|
28 |
+
}
|
29 |
|
30 |
+
// specific page
|
31 |
+
return $this->get_plugin_page() === $page;
|
32 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
+
/**
|
35 |
+
* Does the logged-in user have the required capability?
|
36 |
+
*
|
37 |
+
* @return bool
|
38 |
+
*/
|
39 |
+
public function is_user_authorized() {
|
40 |
+
return current_user_can( $this->get_required_capability() );
|
41 |
+
}
|
42 |
|
43 |
+
/**
|
44 |
+
* Get required capability to access settings page and view dashboard widgets.
|
45 |
+
*
|
46 |
+
* @return string
|
47 |
+
*/
|
48 |
+
public function get_required_capability() {
|
49 |
+
$capability = 'manage_options';
|
50 |
|
51 |
+
/**
|
52 |
+
* Filters the required user capability to access the settings pages & dashboard widgets.
|
53 |
+
*
|
54 |
+
* @ignore
|
55 |
+
* @deprecated 3.0
|
56 |
+
*/
|
57 |
+
$capability = apply_filters( 'mc4wp_settings_cap', $capability );
|
|
|
|
|
|
|
58 |
|
59 |
+
/**
|
60 |
+
* Filters the required user capability to access the Mailchimp for WordPress' settings pages, view the dashboard widgets.
|
61 |
+
*
|
62 |
+
* Defaults to `manage_options`
|
63 |
+
*
|
64 |
+
* @since 3.0
|
65 |
+
* @param string $capability
|
66 |
+
* @see https://codex.wordpress.org/Roles_and_Capabilities
|
67 |
+
*/
|
68 |
+
$capability = (string) apply_filters( 'mc4wp_admin_required_capability', $capability );
|
69 |
+
|
70 |
+
return $capability;
|
71 |
+
}
|
72 |
}
|
includes/admin/class-admin.php
CHANGED
@@ -6,545 +6,518 @@
|
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
-
class MC4WP_Admin
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
echo '<form method="post"><input type="hidden" name="_mc4wp_action" value="dismiss_api_key_notice" /><button type="submit" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></form>';
|
524 |
-
echo '</div>';
|
525 |
-
}
|
526 |
-
|
527 |
-
/**
|
528 |
-
* Dismisses the API key notice for 1 week
|
529 |
-
*/
|
530 |
-
public function dismiss_api_key_notice()
|
531 |
-
{
|
532 |
-
set_transient('mc4wp_api_key_notice_dismissed', 1, 3600 * 24 * 7);
|
533 |
-
}
|
534 |
-
|
535 |
-
/**
|
536 |
-
* @return MC4WP_Debug_Log
|
537 |
-
*/
|
538 |
-
protected function get_log()
|
539 |
-
{
|
540 |
-
return mc4wp('log');
|
541 |
-
}
|
542 |
-
|
543 |
-
/**
|
544 |
-
* @return MC4WP_API_v3
|
545 |
-
*/
|
546 |
-
protected function get_api()
|
547 |
-
{
|
548 |
-
return mc4wp('api');
|
549 |
-
}
|
550 |
}
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
+
class MC4WP_Admin {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var string The relative path to the main plugin file from the plugins dir
|
14 |
+
*/
|
15 |
+
protected $plugin_file;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var MC4WP_Admin_Messages
|
19 |
+
*/
|
20 |
+
protected $messages;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @var MC4WP_Admin_Ads
|
24 |
+
*/
|
25 |
+
protected $ads;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var MC4WP_Admin_Tools
|
29 |
+
*/
|
30 |
+
protected $tools;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @var MC4WP_Admin_Review_Notice
|
34 |
+
*/
|
35 |
+
protected $review_notice;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Constructor
|
39 |
+
*
|
40 |
+
* @param MC4WP_Admin_Tools $tools
|
41 |
+
* @param MC4WP_Admin_Messages $messages
|
42 |
+
*/
|
43 |
+
public function __construct( MC4WP_Admin_Tools $tools, MC4WP_Admin_Messages $messages ) {
|
44 |
+
$this->tools = $tools;
|
45 |
+
$this->messages = $messages;
|
46 |
+
$this->plugin_file = plugin_basename( MC4WP_PLUGIN_FILE );
|
47 |
+
$this->ads = new MC4WP_Admin_Ads();
|
48 |
+
$this->review_notice = new MC4WP_Admin_Review_Notice( $tools );
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Registers all hooks
|
53 |
+
*/
|
54 |
+
public function add_hooks() {
|
55 |
+
|
56 |
+
// Actions used globally throughout WP Admin
|
57 |
+
add_action( 'admin_menu', array( $this, 'build_menu' ) );
|
58 |
+
add_action( 'admin_init', array( $this, 'initialize' ) );
|
59 |
+
|
60 |
+
add_action( 'current_screen', array( $this, 'customize_admin_texts' ) );
|
61 |
+
add_action( 'wp_dashboard_setup', array( $this, 'register_dashboard_widgets' ) );
|
62 |
+
add_action( 'mc4wp_admin_empty_lists_cache', array( $this, 'renew_lists_cache' ) );
|
63 |
+
add_action( 'mc4wp_admin_empty_debug_log', array( $this, 'empty_debug_log' ) );
|
64 |
+
|
65 |
+
add_action( 'admin_notices', array( $this, 'show_api_key_notice' ) );
|
66 |
+
add_action( 'mc4wp_admin_dismiss_api_key_notice', array( $this, 'dismiss_api_key_notice' ) );
|
67 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
|
68 |
+
|
69 |
+
$this->ads->add_hooks();
|
70 |
+
$this->messages->add_hooks();
|
71 |
+
$this->review_notice->add_hooks();
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Initializes various stuff used in WP Admin
|
76 |
+
*
|
77 |
+
* - Registers settings
|
78 |
+
*/
|
79 |
+
public function initialize() {
|
80 |
+
|
81 |
+
// register settings
|
82 |
+
register_setting( 'mc4wp_settings', 'mc4wp', array( $this, 'save_general_settings' ) );
|
83 |
+
|
84 |
+
// Load upgrader
|
85 |
+
$this->init_upgrade_routines();
|
86 |
+
|
87 |
+
// listen for custom actions
|
88 |
+
$this->listen_for_actions();
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Listen for `_mc4wp_action` requests
|
94 |
+
*/
|
95 |
+
public function listen_for_actions() {
|
96 |
+
|
97 |
+
// listen for any action (if user is authorised)
|
98 |
+
if ( ! $this->tools->is_user_authorized() || ! isset( $_REQUEST['_mc4wp_action'] ) ) {
|
99 |
+
return false;
|
100 |
+
}
|
101 |
+
|
102 |
+
$action = (string) $_REQUEST['_mc4wp_action'];
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Allows you to hook into requests containing `_mc4wp_action` => action name.
|
106 |
+
*
|
107 |
+
* The dynamic portion of the hook name, `$action`, refers to the action name.
|
108 |
+
*
|
109 |
+
* By the time this hook is fired, the user is already authorized. After processing all the registered hooks,
|
110 |
+
* the request is redirected back to the referring URL.
|
111 |
+
*
|
112 |
+
* @since 3.0
|
113 |
+
*/
|
114 |
+
do_action( 'mc4wp_admin_' . $action );
|
115 |
+
|
116 |
+
// redirect back to where we came from
|
117 |
+
$redirect_url = isset( $_REQUEST['_redirect_to'] ) ? $_REQUEST['_redirect_to'] : remove_query_arg( '_mc4wp_action' );
|
118 |
+
if ( $redirect_url ) {
|
119 |
+
wp_redirect( $redirect_url );
|
120 |
+
exit;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Register dashboard widgets
|
126 |
+
*/
|
127 |
+
public function register_dashboard_widgets() {
|
128 |
+
if ( ! $this->tools->is_user_authorized() ) {
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Setup dashboard widget, users are authorized by now.
|
134 |
+
*
|
135 |
+
* Use this hook to register your own dashboard widgets for users with the required capability.
|
136 |
+
*
|
137 |
+
* @since 3.0
|
138 |
+
* @ignore
|
139 |
+
*/
|
140 |
+
do_action( 'mc4wp_dashboard_setup' );
|
141 |
+
|
142 |
+
return true;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Upgrade routine
|
147 |
+
*/
|
148 |
+
private function init_upgrade_routines() {
|
149 |
+
|
150 |
+
// upgrade routine for upgrade routine....
|
151 |
+
$previous_version = get_option( 'mc4wp_lite_version', 0 );
|
152 |
+
if ( $previous_version ) {
|
153 |
+
delete_option( 'mc4wp_lite_version' );
|
154 |
+
update_option( 'mc4wp_version', $previous_version );
|
155 |
+
}
|
156 |
+
|
157 |
+
$previous_version = get_option( 'mc4wp_version', 0 );
|
158 |
+
|
159 |
+
// allow setting migration version from URL, to easily re-run previous migrations.
|
160 |
+
if ( isset( $_GET['mc4wp_run_migration'] ) ) {
|
161 |
+
$previous_version = $_GET['mc4wp_run_migration'];
|
162 |
+
}
|
163 |
+
|
164 |
+
// Ran upgrade routines before?
|
165 |
+
if ( empty( $previous_version ) ) {
|
166 |
+
update_option( 'mc4wp_version', MC4WP_VERSION );
|
167 |
+
|
168 |
+
// if we have at least one form, we're going to run upgrade routine for v3 => v4 anyway.
|
169 |
+
// TODO: Remove this once we hit 4.2.x
|
170 |
+
$posts = get_posts(
|
171 |
+
array(
|
172 |
+
'post_type' => 'mc4wp-form',
|
173 |
+
'numberposts' => 1,
|
174 |
+
)
|
175 |
+
);
|
176 |
+
if ( empty( $posts ) ) {
|
177 |
+
return false;
|
178 |
+
}
|
179 |
+
|
180 |
+
$previous_version = '3.9';
|
181 |
+
}
|
182 |
+
|
183 |
+
// Rollback'ed?
|
184 |
+
if ( version_compare( $previous_version, MC4WP_VERSION, '>' ) ) {
|
185 |
+
update_option( 'mc4wp_version', MC4WP_VERSION );
|
186 |
+
return false;
|
187 |
+
}
|
188 |
+
|
189 |
+
// This means we're good!
|
190 |
+
if ( version_compare( $previous_version, MC4WP_VERSION ) > -1 ) {
|
191 |
+
return false;
|
192 |
+
}
|
193 |
+
|
194 |
+
define( 'MC4WP_DOING_UPGRADE', true );
|
195 |
+
$upgrade_routines = new MC4WP_Upgrade_Routines( $previous_version, MC4WP_VERSION, dirname( __FILE__ ) . '/migrations' );
|
196 |
+
$upgrade_routines->run();
|
197 |
+
update_option( 'mc4wp_version', MC4WP_VERSION );
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Renew Mailchimp lists cache
|
202 |
+
*/
|
203 |
+
public function renew_lists_cache() {
|
204 |
+
// try getting new lists to fill cache again
|
205 |
+
$mailchimp = new MC4WP_MailChimp();
|
206 |
+
$lists = $mailchimp->refresh_lists();
|
207 |
+
|
208 |
+
if ( ! empty( $lists ) ) {
|
209 |
+
$this->messages->flash( __( 'Success! The cached configuration for your Mailchimp lists has been renewed.', 'mailchimp-for-wp' ) );
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Customize texts throughout WP Admin
|
215 |
+
*/
|
216 |
+
public function customize_admin_texts() {
|
217 |
+
$texts = new MC4WP_Admin_Texts( $this->plugin_file );
|
218 |
+
$texts->add_hooks();
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Validates the General settings
|
223 |
+
* @param array $settings
|
224 |
+
* @return array
|
225 |
+
*/
|
226 |
+
public function save_general_settings( array $settings ) {
|
227 |
+
$current = mc4wp_get_options();
|
228 |
+
|
229 |
+
// merge with current settings to allow passing partial arrays to this method
|
230 |
+
$settings = array_merge( $current, $settings );
|
231 |
+
|
232 |
+
// toggle usage tracking
|
233 |
+
if ( $settings['allow_usage_tracking'] !== $current['allow_usage_tracking'] ) {
|
234 |
+
MC4WP_Usage_Tracking::instance()->toggle( $settings['allow_usage_tracking'] );
|
235 |
+
}
|
236 |
+
|
237 |
+
// Make sure not to use obfuscated key
|
238 |
+
if ( strpos( $settings['api_key'], '*' ) !== false ) {
|
239 |
+
$settings['api_key'] = $current['api_key'];
|
240 |
+
}
|
241 |
+
|
242 |
+
// Sanitize API key
|
243 |
+
$settings['api_key'] = sanitize_text_field( $settings['api_key'] );
|
244 |
+
|
245 |
+
// if API key changed, empty Mailchimp cache
|
246 |
+
if ( $settings['api_key'] !== $current['api_key'] ) {
|
247 |
+
$mailchimp = new MC4WP_MailChimp();
|
248 |
+
$mailchimp->refresh_lists();
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Runs right before general settings are saved.
|
253 |
+
*
|
254 |
+
* @param array $settings The updated settings array
|
255 |
+
* @param array $current The old settings array
|
256 |
+
*/
|
257 |
+
do_action( 'mc4wp_save_settings', $settings, $current );
|
258 |
+
|
259 |
+
return $settings;
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Load scripts and stylesheet on Mailchimp for WP Admin pages
|
264 |
+
*
|
265 |
+
* @return bool
|
266 |
+
*/
|
267 |
+
public function enqueue_assets() {
|
268 |
+
global $wp_scripts;
|
269 |
+
|
270 |
+
if ( ! $this->tools->on_plugin_page() ) {
|
271 |
+
return false;
|
272 |
+
}
|
273 |
+
|
274 |
+
$opts = mc4wp_get_options();
|
275 |
+
$page = $this->tools->get_plugin_page();
|
276 |
+
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
277 |
+
$mailchimp = new MC4WP_MailChimp();
|
278 |
+
|
279 |
+
// css
|
280 |
+
wp_register_style( 'mc4wp-admin', MC4WP_PLUGIN_URL . 'assets/css/admin-styles' . $suffix . '.css', array(), MC4WP_VERSION );
|
281 |
+
wp_enqueue_style( 'mc4wp-admin' );
|
282 |
+
|
283 |
+
// js
|
284 |
+
wp_register_script( 'es5-shim', MC4WP_PLUGIN_URL . 'assets/js/third-party/es5-shim.min.js', array(), MC4WP_VERSION );
|
285 |
+
$wp_scripts->add_data( 'es5-shim', 'conditional', 'lt IE 9' );
|
286 |
+
|
287 |
+
wp_register_script( 'mc4wp-admin', MC4WP_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'es5-shim' ), MC4WP_VERSION, true );
|
288 |
+
wp_enqueue_script( 'mc4wp-admin' );
|
289 |
+
wp_localize_script(
|
290 |
+
'mc4wp-admin',
|
291 |
+
'mc4wp_vars',
|
292 |
+
array(
|
293 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
294 |
+
'mailchimp' => array(
|
295 |
+
'api_connected' => ! empty( $opts['api_key'] ),
|
296 |
+
'lists' => $mailchimp->get_lists(),
|
297 |
+
),
|
298 |
+
'countries' => MC4WP_Tools::get_countries(),
|
299 |
+
'i18n' => array(
|
300 |
+
'invalid_api_key' => __( 'The given value does not look like a valid Mailchimp API key.', 'mailchimp-for-wp' ),
|
301 |
+
'pro_only' => __( 'This is a premium feature. Please upgrade to Mailchimp for WordPress Premium to be able to use it.', 'mailchimp-for-wp' ),
|
302 |
+
'renew_mailchimp_lists' => __( 'Renew Mailchimp lists', 'mailchimp-for-wp' ),
|
303 |
+
'fetching_mailchimp_lists' => __( 'Fetching Mailchimp lists', 'mailchimp-for-wp' ),
|
304 |
+
'fetching_mailchimp_lists_done' => __( 'Done! Mailchimp lists renewed.', 'mailchimp-for-wp' ),
|
305 |
+
'fetching_mailchimp_lists_error' => __( 'Failed to renew your lists. An error occured.', 'mailchimp-for-wp' ),
|
306 |
+
),
|
307 |
+
)
|
308 |
+
);
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Hook to enqueue your own custom assets on the Mailchimp for WordPress setting pages.
|
312 |
+
*
|
313 |
+
* @since 3.0
|
314 |
+
*
|
315 |
+
* @param string $suffix
|
316 |
+
* @param string $page
|
317 |
+
*/
|
318 |
+
do_action( 'mc4wp_admin_enqueue_assets', $suffix, $page );
|
319 |
+
|
320 |
+
return true;
|
321 |
+
}
|
322 |
+
|
323 |
+
|
324 |
+
|
325 |
+
/**
|
326 |
+
* Register the setting pages and their menu items
|
327 |
+
*/
|
328 |
+
public function build_menu() {
|
329 |
+
$required_cap = $this->tools->get_required_capability();
|
330 |
+
|
331 |
+
$menu_items = array(
|
332 |
+
array(
|
333 |
+
'title' => __( 'Mailchimp API Settings', 'mailchimp-for-wp' ),
|
334 |
+
'text' => __( 'Mailchimp', 'mailchimp-for-wp' ),
|
335 |
+
'slug' => '',
|
336 |
+
'callback' => array( $this, 'show_generals_setting_page' ),
|
337 |
+
'position' => 0,
|
338 |
+
),
|
339 |
+
array(
|
340 |
+
'title' => __( 'Other Settings', 'mailchimp-for-wp' ),
|
341 |
+
'text' => __( 'Other', 'mailchimp-for-wp' ),
|
342 |
+
'slug' => 'other',
|
343 |
+
'callback' => array( $this, 'show_other_setting_page' ),
|
344 |
+
'position' => 90,
|
345 |
+
),
|
346 |
+
|
347 |
+
);
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Filters the menu items to appear under the main menu item.
|
351 |
+
*
|
352 |
+
* To add your own item, add an associative array in the following format.
|
353 |
+
*
|
354 |
+
* $menu_items[] = array(
|
355 |
+
* 'title' => 'Page title',
|
356 |
+
* 'text' => 'Menu text',
|
357 |
+
* 'slug' => 'Page slug',
|
358 |
+
* 'callback' => 'my_page_function',
|
359 |
+
* 'position' => 50
|
360 |
+
* );
|
361 |
+
*
|
362 |
+
* @param array $menu_items
|
363 |
+
* @since 3.0
|
364 |
+
*/
|
365 |
+
$menu_items = (array) apply_filters( 'mc4wp_admin_menu_items', $menu_items );
|
366 |
+
|
367 |
+
// add top menu item
|
368 |
+
$icon = file_get_contents( MC4WP_PLUGIN_DIR . 'assets/img/icon.svg' );
|
369 |
+
add_menu_page( 'Mailchimp for WP', 'MC4WP', $required_cap, 'mailchimp-for-wp', array( $this, 'show_generals_setting_page' ), 'data:image/svg+xml;base64,' . base64_encode( $icon ), '99.68491' );
|
370 |
+
|
371 |
+
// sort submenu items by 'position'
|
372 |
+
usort( $menu_items, array( $this, 'sort_menu_items_by_position' ) );
|
373 |
+
|
374 |
+
// add sub-menu items
|
375 |
+
foreach ( $menu_items as $item ) {
|
376 |
+
$this->add_menu_item( $item );
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* @param array $item
|
382 |
+
*/
|
383 |
+
public function add_menu_item( array $item ) {
|
384 |
+
|
385 |
+
// generate menu slug
|
386 |
+
$slug = 'mailchimp-for-wp';
|
387 |
+
if ( ! empty( $item['slug'] ) ) {
|
388 |
+
$slug .= '-' . $item['slug'];
|
389 |
+
}
|
390 |
+
|
391 |
+
// provide some defaults
|
392 |
+
$parent_slug = ! empty( $item['parent_slug'] ) ? $item['parent_slug'] : 'mailchimp-for-wp';
|
393 |
+
$capability = ! empty( $item['capability'] ) ? $item['capability'] : $this->tools->get_required_capability();
|
394 |
+
|
395 |
+
// register page
|
396 |
+
$hook = add_submenu_page( $parent_slug, $item['title'] . ' - Mailchimp for WordPress', $item['text'], $capability, $slug, $item['callback'] );
|
397 |
+
|
398 |
+
// register callback for loading this page, if given
|
399 |
+
if ( array_key_exists( 'load_callback', $item ) ) {
|
400 |
+
add_action( 'load-' . $hook, $item['load_callback'] );
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* Show the API Settings page
|
406 |
+
*/
|
407 |
+
public function show_generals_setting_page() {
|
408 |
+
$opts = mc4wp_get_options();
|
409 |
+
$api_key = mc4wp_get_api_key();
|
410 |
+
$lists = array();
|
411 |
+
$connected = ! empty( $api_key );
|
412 |
+
|
413 |
+
if ( $connected ) {
|
414 |
+
try {
|
415 |
+
$connected = $this->get_api()->is_connected();
|
416 |
+
$mailchimp = new MC4WP_MailChimp();
|
417 |
+
$lists = $mailchimp->get_lists();
|
418 |
+
} catch ( MC4WP_API_Connection_Exception $e ) {
|
419 |
+
$message = sprintf( '<strong>%s</strong> %s %s ', __( 'Error connecting to Mailchimp:', 'mailchimp-for-wp' ), $e->getCode(), $e->getMessage() );
|
420 |
+
|
421 |
+
if ( is_object( $e->data ) && ! empty( $e->data->ref_no ) ) {
|
422 |
+
$message .= '<br />' . sprintf( __( 'Looks like your server is blocked by Mailchimp\'s firewall. Please contact Mailchimp support and include the following reference number: %s', 'mailchimp-for-wp' ), $e->data->ref_no );
|
423 |
+
}
|
424 |
+
|
425 |
+
$message .= '<br /><br />' . sprintf( '<a href="%s">' . __( 'Here\'s some info on solving common connectivity issues.', 'mailchimp-for-wp' ) . '</a>', 'https://kb.mc4wp.com/solving-connectivity-issues/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=settings-notice' );
|
426 |
+
|
427 |
+
$this->messages->flash( $message, 'error' );
|
428 |
+
$connected = false;
|
429 |
+
} catch ( MC4WP_API_Exception $e ) {
|
430 |
+
$this->messages->flash( sprintf( '<strong>%s</strong><br /> %s', __( 'Mailchimp returned the following error:', 'mailchimp-for-wp' ), $e ), 'error' );
|
431 |
+
$connected = false;
|
432 |
+
}
|
433 |
+
}
|
434 |
+
|
435 |
+
$obfuscated_api_key = mc4wp_obfuscate_string( $api_key );
|
436 |
+
require MC4WP_PLUGIN_DIR . 'includes/views/general-settings.php';
|
437 |
+
}
|
438 |
+
|
439 |
+
/**
|
440 |
+
* Show the Other Settings page
|
441 |
+
*/
|
442 |
+
public function show_other_setting_page() {
|
443 |
+
$opts = mc4wp_get_options();
|
444 |
+
$log = $this->get_log();
|
445 |
+
$log_reader = new MC4WP_Debug_Log_Reader( $log->file );
|
446 |
+
require MC4WP_PLUGIN_DIR . 'includes/views/other-settings.php';
|
447 |
+
}
|
448 |
+
|
449 |
+
/**
|
450 |
+
* @param $a
|
451 |
+
* @param $b
|
452 |
+
*
|
453 |
+
* @return int
|
454 |
+
*/
|
455 |
+
public function sort_menu_items_by_position( $a, $b ) {
|
456 |
+
$pos_a = isset( $a['position'] ) ? $a['position'] : 80;
|
457 |
+
$pos_b = isset( $b['position'] ) ? $b['position'] : 90;
|
458 |
+
return $pos_a < $pos_b ? -1 : 1;
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Empties the log file
|
463 |
+
*/
|
464 |
+
public function empty_debug_log() {
|
465 |
+
$log = $this->get_log();
|
466 |
+
file_put_contents( $log->file, '' );
|
467 |
+
|
468 |
+
$this->messages->flash( __( 'Log successfully emptied.', 'mailchimp-for-wp' ) );
|
469 |
+
}
|
470 |
+
|
471 |
+
/**
|
472 |
+
* Shows a notice when API key is not set.
|
473 |
+
*/
|
474 |
+
public function show_api_key_notice() {
|
475 |
+
|
476 |
+
// don't show if on settings page already
|
477 |
+
if ( $this->tools->on_plugin_page( '' ) ) {
|
478 |
+
return;
|
479 |
+
}
|
480 |
+
|
481 |
+
// only show to user with proper permissions
|
482 |
+
if ( ! $this->tools->is_user_authorized() ) {
|
483 |
+
return;
|
484 |
+
}
|
485 |
+
|
486 |
+
// don't show if dismissed
|
487 |
+
if ( get_transient( 'mc4wp_api_key_notice_dismissed' ) ) {
|
488 |
+
return;
|
489 |
+
}
|
490 |
+
|
491 |
+
// don't show if api key is set already
|
492 |
+
$api_key = mc4wp_get_api_key();
|
493 |
+
if ( ! empty( $api_key ) ) {
|
494 |
+
return;
|
495 |
+
}
|
496 |
+
|
497 |
+
echo '<div class="notice notice-warning mc4wp-is-dismissible">';
|
498 |
+
echo '<p>' . sprintf( __( 'To get started with Mailchimp for WordPress, please <a href="%s">enter your Mailchimp API key on the settings page of the plugin</a>.', 'mailchimp-for-wp' ), admin_url( 'admin.php?page=mailchimp-for-wp' ) ) . '</p>';
|
499 |
+
echo '<form method="post"><input type="hidden" name="_mc4wp_action" value="dismiss_api_key_notice" /><button type="submit" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></form>';
|
500 |
+
echo '</div>';
|
501 |
+
}
|
502 |
+
|
503 |
+
/**
|
504 |
+
* Dismisses the API key notice for 1 week
|
505 |
+
*/
|
506 |
+
public function dismiss_api_key_notice() {
|
507 |
+
set_transient( 'mc4wp_api_key_notice_dismissed', 1, 3600 * 24 * 7 );
|
508 |
+
}
|
509 |
+
|
510 |
+
/**
|
511 |
+
* @return MC4WP_Debug_Log
|
512 |
+
*/
|
513 |
+
protected function get_log() {
|
514 |
+
return mc4wp( 'log' );
|
515 |
+
}
|
516 |
+
|
517 |
+
/**
|
518 |
+
* @return MC4WP_API_V3
|
519 |
+
*/
|
520 |
+
protected function get_api() {
|
521 |
+
return mc4wp( 'api' );
|
522 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
523 |
}
|
includes/admin/class-ads.php
CHANGED
@@ -6,145 +6,138 @@
|
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
-
class MC4WP_Admin_Ads
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
{
|
121 |
-
echo '<div class="mc4wp-box">';
|
122 |
-
echo '<div style="border: 5px dotted #cc4444; padding: 0 20px; background: white;">';
|
123 |
-
echo '<h3>Mailchimp for WordPress Premium</h3>';
|
124 |
-
echo '<p>This plugin has a Premium add-on, unlocking several powerful features. <a href="https://mc4wp.com/premium-features/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=upgrade-box">Have a look at its benefits</a>!</p>';
|
125 |
-
echo '</div>';
|
126 |
-
echo '</div>'; ?>
|
127 |
<div class="mc4wp-box" id="mc4wp-optin-box">
|
128 |
|
129 |
<?php $user = wp_get_current_user(); ?>
|
130 |
<!-- Begin Mailchimp Signup Form -->
|
131 |
<div id="mc_embed_signup">
|
132 |
-
<h4 class="mc4wp-title"><?php _e('More subscribers, better newsletters.', 'mailchimp-for-wp'); ?></h4>
|
133 |
-
<p><?php _e('Learn how to best grow your lists & write better emails by subscribing to our monthly tips.', 'mailchimp-for-wp'); ?></p>
|
134 |
<form action="//mc4wp.us1.list-manage.com/subscribe/post?u=a2d08947dcd3683512ce174c5&id=a940232df9" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" target="_blank">
|
135 |
<p>
|
136 |
-
<label for="mc4wp-email"><?php _e('Email Address', 'mailchimp-for-wp'); ?></label>
|
137 |
-
<input type="email" value="<?php echo esc_attr($user->user_email); ?>" name="EMAIL" class="regular-text" id="mc4wp-email" required>
|
138 |
</p>
|
139 |
<p>
|
140 |
-
<label for="mc4wp-fname"><?php _e('First Name', 'mailchimp-for-wp'); ?></label>
|
141 |
-
<input type="text" value="<?php echo esc_attr($user->user_firstname); ?>" name="FNAME" class="regular-text" id="mc4wp-fname">
|
142 |
</p>
|
143 |
<div style="position: absolute; left: -5000px;">
|
144 |
<input type="text" name="b_a2d08947dcd3683512ce174c5_a940232df9" tabindex="-1" value="" autocomplete="off" />
|
145 |
</div>
|
146 |
<p>
|
147 |
-
<input type="submit" value="<?php esc_attr_e('Subscribe', 'mailchimp-for-wp'); ?>" name="subscribe" class="button">
|
148 |
</p>
|
149 |
|
150 |
<input type="hidden" name="SOURCE" value="free-plugin" />
|
@@ -152,32 +145,30 @@ class MC4WP_Admin_Ads
|
|
152 |
</div>
|
153 |
</div>
|
154 |
<?php
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
require MC4WP_PLUGIN_DIR . 'includes/views/extensions.php';
|
182 |
-
}
|
183 |
}
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
+
class MC4WP_Admin_Ads {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return bool Adds hooks
|
14 |
+
*/
|
15 |
+
public function add_hooks() {
|
16 |
+
|
17 |
+
// don't hook if Premium is activated
|
18 |
+
if ( defined( 'MC4WP_PREMIUM_VERSION' ) ) {
|
19 |
+
return false;
|
20 |
+
}
|
21 |
+
|
22 |
+
add_filter( 'mc4wp_admin_plugin_meta_links', array( $this, 'plugin_meta_links' ) );
|
23 |
+
add_action( 'mc4wp_admin_form_after_behaviour_settings_rows', array( $this, 'after_form_settings_rows' ) );
|
24 |
+
add_action( 'mc4wp_admin_form_after_appearance_settings_rows', array( $this, 'after_form_appearance_settings_rows' ) );
|
25 |
+
add_action( 'mc4wp_admin_sidebar', array( $this, 'admin_sidebar' ) );
|
26 |
+
add_action( 'mc4wp_admin_footer', array( $this, 'admin_footer' ) );
|
27 |
+
add_action( 'mc4wp_admin_other_settings', array( $this, 'ecommerce' ), 90 );
|
28 |
+
|
29 |
+
add_filter( 'mc4wp_admin_menu_items', array( $this, 'add_menu_item' ) );
|
30 |
+
|
31 |
+
add_action( 'mc4wp_admin_after_woocommerce_integration_settings', array( $this, 'ecommerce' ) );
|
32 |
+
return true;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function add_menu_item( $items ) {
|
36 |
+
$items['extensions'] = array(
|
37 |
+
'title' => __( 'Add-ons', 'mailchimp-for-wp' ),
|
38 |
+
'text' => __( 'Add-ons', 'mailchimp-for-wp' ),
|
39 |
+
'slug' => 'extensions',
|
40 |
+
'callback' => array( $this, 'show_extensions_page' ),
|
41 |
+
'position' => 100,
|
42 |
+
);
|
43 |
+
|
44 |
+
return $items;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Add text row to "Form > Appearance" tab.
|
49 |
+
*/
|
50 |
+
public function after_form_appearance_settings_rows() {
|
51 |
+
echo '<tr valign="top">';
|
52 |
+
echo '<td colspan="2">';
|
53 |
+
echo '<p class="help">';
|
54 |
+
echo sprintf( __( 'Want to customize the style of your form? <a href="%s">Try our Styles Builder</a> & edit the look of your forms with just a few clicks.', 'mailchimp-for-wp' ), 'https://mc4wp.com/premium-features/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=form-settings-link' );
|
55 |
+
echo '</p>';
|
56 |
+
echo '</td>';
|
57 |
+
echo '</tr>';
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Add text row to "Form > Settings" tab.
|
62 |
+
*/
|
63 |
+
public function after_form_settings_rows() {
|
64 |
+
echo '<tr valign="top">';
|
65 |
+
echo '<td colspan="2">';
|
66 |
+
echo '<p class="help">';
|
67 |
+
|
68 |
+
if ( rand( 1, 2 ) === 1 ) {
|
69 |
+
echo sprintf( __( 'Be notified whenever someone subscribes? <a href="%s">Mailchimp for WordPress Premium</a> allows you to set up email notifications for your forms.', 'mailchimp-for-wp' ), 'https://mc4wp.com/premium-features/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=footer-link' );
|
70 |
+
} else {
|
71 |
+
echo sprintf( __( 'Increased conversions? <a href="%s">Mailchimp for WordPress Premium</a> submits forms without reloading the entire page, resulting in a much better experience for your visitors.', 'mailchimp-for-wp' ), 'https://mc4wp.com/premium-features/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=form-settings-link' );
|
72 |
+
}
|
73 |
+
|
74 |
+
echo '</p>';
|
75 |
+
echo '</td>';
|
76 |
+
echo '</tr>';
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @param array $links
|
81 |
+
*
|
82 |
+
* @return array
|
83 |
+
*/
|
84 |
+
public function plugin_meta_links( $links ) {
|
85 |
+
$links[] = '<a href="https://mc4wp.com/premium-features/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=plugins-upgrade-link">' . __( 'Upgrade to Premium', 'mailchimp-for-wp' ) . '</a>';
|
86 |
+
return $links;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Add several texts to admin footer.
|
91 |
+
*/
|
92 |
+
public function admin_footer() {
|
93 |
+
if ( isset( $_GET['view'] ) && $_GET['view'] === 'edit-form' ) {
|
94 |
+
|
95 |
+
// WPML & Polylang specific message
|
96 |
+
if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
|
97 |
+
echo '<p class="help">' . sprintf( __( 'Do you want translated forms for all of your languages? <a href="%s">Try Mailchimp for WordPress Premium</a>, which does just that plus more.', 'mailchimp-for-wp' ), 'https://mc4wp.com/premium-features/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=footer-link' ) . '</p>';
|
98 |
+
return;
|
99 |
+
}
|
100 |
+
|
101 |
+
// General "edit form" message
|
102 |
+
echo '<p class="help">' . sprintf( __( 'Do you want to create more than one form? Our Premium add-on does just that! <a href="%s">Have a look at all Premium benefits</a>.', 'mailchimp-for-wp' ), 'https://mc4wp.com/premium-features/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=footer-link' ) . '</p>';
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
|
106 |
+
// General message
|
107 |
+
echo '<p class="help">' . sprintf( __( 'Are you enjoying this plugin? The Premium add-on unlocks several powerful features. <a href="%s">Find out about all benefits now</a>.', 'mailchimp-for-wp' ), 'https://mc4wp.com/premium-features/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=footer-link' ) . '</p>';
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Add email opt-in form to sidebar
|
112 |
+
*/
|
113 |
+
public function admin_sidebar() {
|
114 |
+
echo '<div class="mc4wp-box">';
|
115 |
+
echo '<div style="border: 5px dotted #cc4444; padding: 0 20px; background: white;">';
|
116 |
+
echo '<h3>Mailchimp for WordPress Premium</h3>';
|
117 |
+
echo '<p>This plugin has a Premium add-on, unlocking several powerful features. <a href="https://mc4wp.com/premium-features/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=upgrade-box">Have a look at its benefits</a>!</p>';
|
118 |
+
echo '</div>';
|
119 |
+
echo '</div>'; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
<div class="mc4wp-box" id="mc4wp-optin-box">
|
121 |
|
122 |
<?php $user = wp_get_current_user(); ?>
|
123 |
<!-- Begin Mailchimp Signup Form -->
|
124 |
<div id="mc_embed_signup">
|
125 |
+
<h4 class="mc4wp-title"><?php _e( 'More subscribers, better newsletters.', 'mailchimp-for-wp' ); ?></h4>
|
126 |
+
<p><?php _e( 'Learn how to best grow your lists & write better emails by subscribing to our monthly tips.', 'mailchimp-for-wp' ); ?></p>
|
127 |
<form action="//mc4wp.us1.list-manage.com/subscribe/post?u=a2d08947dcd3683512ce174c5&id=a940232df9" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" target="_blank">
|
128 |
<p>
|
129 |
+
<label for="mc4wp-email"><?php _e( 'Email Address', 'mailchimp-for-wp' ); ?></label>
|
130 |
+
<input type="email" value="<?php echo esc_attr( $user->user_email ); ?>" name="EMAIL" class="regular-text" id="mc4wp-email" required>
|
131 |
</p>
|
132 |
<p>
|
133 |
+
<label for="mc4wp-fname"><?php _e( 'First Name', 'mailchimp-for-wp' ); ?></label>
|
134 |
+
<input type="text" value="<?php echo esc_attr( $user->user_firstname ); ?>" name="FNAME" class="regular-text" id="mc4wp-fname">
|
135 |
</p>
|
136 |
<div style="position: absolute; left: -5000px;">
|
137 |
<input type="text" name="b_a2d08947dcd3683512ce174c5_a940232df9" tabindex="-1" value="" autocomplete="off" />
|
138 |
</div>
|
139 |
<p>
|
140 |
+
<input type="submit" value="<?php esc_attr_e( 'Subscribe', 'mailchimp-for-wp' ); ?>" name="subscribe" class="button">
|
141 |
</p>
|
142 |
|
143 |
<input type="hidden" name="SOURCE" value="free-plugin" />
|
145 |
</div>
|
146 |
</div>
|
147 |
<?php
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Show notice about E-Commerce integration in Premium.
|
152 |
+
*/
|
153 |
+
public function ecommerce() {
|
154 |
+
|
155 |
+
// detect whether WooCommerce is installed & activated.
|
156 |
+
if ( ! class_exists( 'WooCommerce' ) ) {
|
157 |
+
return;
|
158 |
+
}
|
159 |
+
|
160 |
+
echo '<div class="medium-margin">';
|
161 |
+
echo '<h3>Advanced WooCommerce integration for Mailchimp</h3>';
|
162 |
+
echo '<p>';
|
163 |
+
echo __( 'Do you want to track all WooCommerce orders in Mailchimp so you can send emails based on the purchase activity of your subscribers?', 'mailchimp-for-wp' );
|
164 |
+
echo '</p>';
|
165 |
+
echo '<p>';
|
166 |
+
echo sprintf( __( '<a href="%1$s">Upgrade to Mailchimp for WordPress Premium</a> or <a href="%2$s">read more about Mailchimp\'s E-Commerce features</a>.', 'mailchimp-for-wp' ) . '</p>', 'https://mc4wp.com/premium-features/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=other-settings-link', 'https://kb.mc4wp.com/what-is-ecommerce360/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=other-settings-link' );
|
167 |
+
echo '</p>';
|
168 |
+
echo '</div>';
|
169 |
+
}
|
170 |
+
|
171 |
+
public function show_extensions_page() {
|
172 |
+
require MC4WP_PLUGIN_DIR . 'includes/views/extensions.php';
|
173 |
+
}
|
|
|
|
|
174 |
}
|
includes/admin/class-review-notice.php
CHANGED
@@ -5,92 +5,87 @@
|
|
5 |
*
|
6 |
* @ignore
|
7 |
*/
|
8 |
-
class MC4WP_Admin_Review_Notice
|
9 |
-
{
|
10 |
|
11 |
-
/**
|
12 |
-
* @var MC4WP_Admin_Tools
|
13 |
-
*/
|
14 |
-
protected $tools;
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
*/
|
26 |
-
public function __construct(MC4WP_Admin_Tools $tools)
|
27 |
-
{
|
28 |
-
$this->tools = $tools;
|
29 |
-
}
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
}
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
return false;
|
57 |
-
}
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
echo '<form method="POST" id="mc4wp-dismiss-review-form"><button type="submit" class="notice-dismiss"><span class="screen-reader-text">'. __('Dismiss this notice.', 'mailchimp-for-wp') .'</span></button><input type="hidden" name="_mc4wp_action" value="dismiss_review_notice"/></form>';
|
77 |
-
echo '</div>';
|
78 |
-
return true;
|
79 |
-
}
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
5 |
*
|
6 |
* @ignore
|
7 |
*/
|
8 |
+
class MC4WP_Admin_Review_Notice {
|
|
|
9 |
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
/**
|
12 |
+
* @var MC4WP_Admin_Tools
|
13 |
+
*/
|
14 |
+
protected $tools;
|
15 |
|
16 |
+
/**
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
protected $meta_key_dismissed = '_mc4wp_review_notice_dismissed';
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
/**
|
22 |
+
* MC4WP_Admin_Review_Notice constructor.
|
23 |
+
*
|
24 |
+
* @param MC4WP_Admin_Tools $tools
|
25 |
+
*/
|
26 |
+
public function __construct( MC4WP_Admin_Tools $tools ) {
|
27 |
+
$this->tools = $tools;
|
28 |
+
}
|
29 |
|
30 |
+
/**
|
31 |
+
* Add action & filter hooks.
|
32 |
+
*/
|
33 |
+
public function add_hooks() {
|
34 |
+
add_action( 'admin_notices', array( $this, 'show' ) );
|
35 |
+
add_action( 'mc4wp_admin_dismiss_review_notice', array( $this, 'dismiss' ) );
|
36 |
+
}
|
|
|
37 |
|
38 |
+
/**
|
39 |
+
* Set flag in user meta so notice won't be shown.
|
40 |
+
*/
|
41 |
+
public function dismiss() {
|
42 |
+
$user = wp_get_current_user();
|
43 |
+
update_user_meta( $user->ID, $this->meta_key_dismissed, 1 );
|
44 |
+
}
|
|
|
|
|
45 |
|
46 |
+
/**
|
47 |
+
* @return bool
|
48 |
+
*/
|
49 |
+
public function show() {
|
50 |
+
// only show on Mailchimp for WordPress' pages.
|
51 |
+
if ( ! $this->tools->on_plugin_page() ) {
|
52 |
+
return false;
|
53 |
+
}
|
54 |
|
55 |
+
// only show if 2 weeks have passed since first use.
|
56 |
+
$two_weeks_in_seconds = ( 60 * 60 * 24 * 14 );
|
57 |
+
if ( $this->time_since_first_use() <= $two_weeks_in_seconds ) {
|
58 |
+
return false;
|
59 |
+
}
|
60 |
|
61 |
+
// only show if user did not dismiss before
|
62 |
+
$user = wp_get_current_user();
|
63 |
+
if ( get_user_meta( $user->ID, $this->meta_key_dismissed, true ) ) {
|
64 |
+
return false;
|
65 |
+
}
|
|
|
|
|
|
|
|
|
66 |
|
67 |
+
echo '<div class="notice notice-info mc4wp-is-dismissible" id="mc4wp-review-notice">';
|
68 |
+
echo '<p>';
|
69 |
+
echo __( 'You\'ve been using Mailchimp for WordPress for some time now; we hope you love it!', 'mailchimp-for-wp' ) . ' <br />';
|
70 |
+
echo sprintf( __( 'If you do, please <a href="%s">leave us a 5★ rating on WordPress.org</a>. It would be of great help to us.', 'mailchimp-for-wp' ), 'https://wordpress.org/support/view/plugin-reviews/mailchimp-for-wp?rate=5#new-post' );
|
71 |
+
echo '</p>';
|
72 |
+
echo '<form method="POST" id="mc4wp-dismiss-review-form"><button type="submit" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'mailchimp-for-wp' ) . '</span></button><input type="hidden" name="_mc4wp_action" value="dismiss_review_notice"/></form>';
|
73 |
+
echo '</div>';
|
74 |
+
return true;
|
75 |
+
}
|
76 |
|
77 |
+
/**
|
78 |
+
* @return int
|
79 |
+
*/
|
80 |
+
private function time_since_first_use() {
|
81 |
+
$options = get_option( 'mc4wp' );
|
82 |
|
83 |
+
// option was never added before, do it now.
|
84 |
+
if ( empty( $options['first_activated_on'] ) ) {
|
85 |
+
$options['first_activated_on'] = time();
|
86 |
+
update_option( 'mc4wp', $options );
|
87 |
+
}
|
88 |
+
|
89 |
+
return time() - $options['first_activated_on'];
|
90 |
+
}
|
91 |
}
|
includes/admin/class-update-optin.php
CHANGED
@@ -1,184 +1,177 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class MC4WP_Update_Optin
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
// only show to users with required capability
|
178 |
-
if (! current_user_can(self::CAPABILITY)) {
|
179 |
-
return false;
|
180 |
-
}
|
181 |
-
|
182 |
-
return true;
|
183 |
-
}
|
184 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class MC4WP_Update_Optin {
|
4 |
+
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @const string
|
8 |
+
*/
|
9 |
+
const CAPABILITY = 'install_plugins';
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @var string
|
13 |
+
*/
|
14 |
+
protected $plugin_file = '';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
protected $to_version;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
protected $view_file;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @var string
|
28 |
+
*/
|
29 |
+
protected $option_enable;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @var string
|
33 |
+
*/
|
34 |
+
protected $option_notice;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @var bool
|
38 |
+
*/
|
39 |
+
protected $active = false;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @param string $to_version
|
43 |
+
* @param string $plugin_file
|
44 |
+
* @param string $view_file
|
45 |
+
*/
|
46 |
+
public function __construct( $to_version, $plugin_file, $view_file ) {
|
47 |
+
$this->to_version = $to_version;
|
48 |
+
$this->plugin_file = $plugin_file;
|
49 |
+
$this->view_file = $view_file;
|
50 |
+
|
51 |
+
$this->option_enable = 'mc4wp_enable_' . sanitize_key( $this->to_version );
|
52 |
+
$this->option_notice = 'mc4wp_notice_' . sanitize_key( $this->to_version );
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Add hooks
|
57 |
+
*/
|
58 |
+
public function add_hooks() {
|
59 |
+
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'maybe_hide_update' ) );
|
60 |
+
add_action( 'init', array( $this, 'listen' ) );
|
61 |
+
|
62 |
+
global $pagenow;
|
63 |
+
$on_settings_page = isset( $_GET['page'] ) && stristr( $_GET['page'], dirname( $this->plugin_file ) ) !== false;
|
64 |
+
if ( $pagenow === 'plugins.php' || $pagenow === 'update-core.php' || $on_settings_page ) {
|
65 |
+
add_action( 'admin_notices', array( $this, 'show_update_optin' ) );
|
66 |
+
}
|
67 |
+
}
|
68 |
+
/**
|
69 |
+
* Listen for actions
|
70 |
+
*/
|
71 |
+
public function listen() {
|
72 |
+
|
73 |
+
// only show to users with required capability
|
74 |
+
if ( ! current_user_can( self::CAPABILITY ) ) {
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
|
78 |
+
if ( isset( $_GET[ $this->option_enable ] ) ) {
|
79 |
+
$this->enable_major_updates();
|
80 |
+
}
|
81 |
+
}
|
82 |
+
/**
|
83 |
+
* Prevents updates from showing
|
84 |
+
*
|
85 |
+
* @param array $data
|
86 |
+
* @return array
|
87 |
+
*/
|
88 |
+
public function maybe_hide_update( $data ) {
|
89 |
+
if ( empty( $data->response ) ) {
|
90 |
+
return $data;
|
91 |
+
}
|
92 |
+
|
93 |
+
// do nothing if the specified version is not out there yet..
|
94 |
+
if ( empty( $data->response[ $this->plugin_file ]->new_version )
|
95 |
+
|| version_compare( $data->response[ $this->plugin_file ]->new_version, $this->to_version, '<' ) ) {
|
96 |
+
|
97 |
+
// reset flags here in case we revert the update
|
98 |
+
if ( ! $this->active ) {
|
99 |
+
delete_option( $this->option_notice );
|
100 |
+
delete_option( $this->option_enable );
|
101 |
+
}
|
102 |
+
|
103 |
+
return $data;
|
104 |
+
}
|
105 |
+
|
106 |
+
// return unmodified data if already opted-in
|
107 |
+
$opted_in = get_option( $this->option_enable, false );
|
108 |
+
if ( $opted_in ) {
|
109 |
+
return $data;
|
110 |
+
}
|
111 |
+
|
112 |
+
// set a flag to start showing "update to x.x" notice
|
113 |
+
update_option( $this->option_notice, 1 );
|
114 |
+
|
115 |
+
// unset update data
|
116 |
+
unset( $data->response[ $this->plugin_file ] );
|
117 |
+
|
118 |
+
// set flag because this filter runs multiple times..
|
119 |
+
$this->active = true;
|
120 |
+
|
121 |
+
return $data;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Enables major updates (opts-in to 3.x update)
|
126 |
+
*/
|
127 |
+
public function enable_major_updates() {
|
128 |
+
|
129 |
+
// update option
|
130 |
+
update_option( $this->option_enable, 1 );
|
131 |
+
|
132 |
+
// delete site transient so wp core will fetch latest version
|
133 |
+
delete_site_transient( 'update_plugins' );
|
134 |
+
|
135 |
+
// redirect to updates page
|
136 |
+
wp_safe_redirect( admin_url( 'update-core.php' ) );
|
137 |
+
exit;
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Shows update opt-in
|
142 |
+
*/
|
143 |
+
public function show_update_optin() {
|
144 |
+
if ( ! $this->should_show_update_optin() ) {
|
145 |
+
return;
|
146 |
+
}
|
147 |
+
|
148 |
+
// prepare link URL
|
149 |
+
$update_link = add_query_arg( array( $this->option_enable => 1 ) );
|
150 |
+
|
151 |
+
// show!
|
152 |
+
include $this->view_file;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* @return bool
|
157 |
+
*/
|
158 |
+
public function should_show_update_optin() {
|
159 |
+
|
160 |
+
// don't show if flag is not set
|
161 |
+
if ( ! get_option( $this->option_notice, false ) ) {
|
162 |
+
return false;
|
163 |
+
}
|
164 |
+
|
165 |
+
// stop showing if opted-in already
|
166 |
+
if ( get_option( $this->option_enable, false ) ) {
|
167 |
+
return false;
|
168 |
+
}
|
169 |
+
|
170 |
+
// only show to users with required capability
|
171 |
+
if ( ! current_user_can( self::CAPABILITY ) ) {
|
172 |
+
return false;
|
173 |
+
}
|
174 |
+
|
175 |
+
return true;
|
176 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
}
|
includes/admin/class-upgrade-routines.php
CHANGED
@@ -8,79 +8,75 @@
|
|
8 |
*
|
9 |
* @ignore
|
10 |
*/
|
11 |
-
class MC4WP_Upgrade_Routines
|
12 |
-
{
|
13 |
|
14 |
-
/**
|
15 |
-
* @var float
|
16 |
-
*/
|
17 |
-
protected $version_from = 0;
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
public function __construct($from, $to, $migrations_dir)
|
34 |
-
{
|
35 |
-
$this->version_from = $from;
|
36 |
-
$this->version_to = $to;
|
37 |
-
$this->migrations_dir = $migrations_dir;
|
38 |
-
}
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
public function find_migrations()
|
55 |
-
{
|
56 |
-
$files = glob(rtrim($this->migrations_dir, '/') . '/*.php');
|
57 |
-
$migrations = array();
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
|
74 |
-
|
75 |
-
|
|
|
|
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
86 |
}
|
8 |
*
|
9 |
* @ignore
|
10 |
*/
|
11 |
+
class MC4WP_Upgrade_Routines {
|
|
|
12 |
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
/**
|
15 |
+
* @var float
|
16 |
+
*/
|
17 |
+
protected $version_from = 0;
|
18 |
|
19 |
+
/**
|
20 |
+
* @var float
|
21 |
+
*/
|
22 |
+
protected $version_to = 0;
|
23 |
|
24 |
+
/**
|
25 |
+
* @var string
|
26 |
+
*/
|
27 |
+
protected $migrations_dir = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
/**
|
30 |
+
* @param float $from
|
31 |
+
* @param float $to
|
32 |
+
*/
|
33 |
+
public function __construct( $from, $to, $migrations_dir ) {
|
34 |
+
$this->version_from = $from;
|
35 |
+
$this->version_to = $to;
|
36 |
+
$this->migrations_dir = $migrations_dir;
|
37 |
+
}
|
38 |
|
39 |
+
/**
|
40 |
+
* Run the various upgrade routines, all the way up to the latest version
|
41 |
+
*/
|
42 |
+
public function run() {
|
43 |
+
$migrations = $this->find_migrations();
|
44 |
|
45 |
+
// run in sub-function for scope
|
46 |
+
array_map( array( $this, 'run_migration' ), $migrations );
|
47 |
+
}
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
/**
|
50 |
+
* @return array
|
51 |
+
*/
|
52 |
+
public function find_migrations() {
|
53 |
+
$files = glob( rtrim( $this->migrations_dir, '/' ) . '/*.php' );
|
54 |
+
$migrations = array();
|
55 |
|
56 |
+
// return empty array when glob returns non-array value.
|
57 |
+
if ( ! is_array( $files ) ) {
|
58 |
+
return $migrations;
|
59 |
+
}
|
60 |
|
61 |
+
foreach ( $files as $file ) {
|
62 |
+
$migration = basename( $file );
|
63 |
+
$parts = explode( '-', $migration );
|
64 |
+
$version = $parts[0];
|
65 |
|
66 |
+
if ( version_compare( $this->version_from, $version, '<' ) ) {
|
67 |
+
$migrations[] = $file;
|
68 |
+
}
|
69 |
+
}
|
70 |
|
71 |
+
return $migrations;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Include a migration file and runs it.
|
76 |
+
*
|
77 |
+
* @param string $file
|
78 |
+
*/
|
79 |
+
protected function run_migration( $file ) {
|
80 |
+
include $file;
|
81 |
+
}
|
82 |
}
|
includes/admin/class-usage-tracking.php
CHANGED
@@ -7,204 +7,189 @@
|
|
7 |
* @since 2.3
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_Usage_Tracking
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
$site_url = site_url();
|
196 |
-
return stripos($site_url, 'https') === 0;
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* @return string
|
201 |
-
*/
|
202 |
-
protected function get_server_software()
|
203 |
-
{
|
204 |
-
if (! isset($_SERVER['SERVER_SOFTWARE'])) {
|
205 |
-
return null;
|
206 |
-
}
|
207 |
-
|
208 |
-
return $_SERVER['SERVER_SOFTWARE'];
|
209 |
-
}
|
210 |
}
|
7 |
* @since 2.3
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_Usage_Tracking {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
protected $tracking_url = 'https://mc4wp.com/api/usage-tracking';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var MC4WP_Usage_Tracking The One True Instance
|
20 |
+
*/
|
21 |
+
protected static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @return MC4WP_Usage_Tracking
|
25 |
+
*/
|
26 |
+
public static function instance() {
|
27 |
+
if ( ! self::$instance instanceof MC4WP_Usage_Tracking ) {
|
28 |
+
self::$instance = new MC4WP_Usage_Tracking();
|
29 |
+
}
|
30 |
+
|
31 |
+
return self::$instance;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Add hooks
|
36 |
+
*/
|
37 |
+
public function add_hooks() {
|
38 |
+
add_action( 'mc4wp_usage_tracking', array( $this, 'track' ) );
|
39 |
+
add_filter( 'cron_schedules', array( $this, 'cron_schedules' ) );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Registers a new schedule with WP Cron
|
44 |
+
*
|
45 |
+
* @param array $schedules
|
46 |
+
*
|
47 |
+
* @return array
|
48 |
+
*/
|
49 |
+
public function cron_schedules( $schedules ) {
|
50 |
+
$schedules['monthly'] = array(
|
51 |
+
'interval' => 30 * DAY_IN_SECONDS,
|
52 |
+
'display' => __( 'Once a month', 'mailchimp-for-wp' ),
|
53 |
+
);
|
54 |
+
return $schedules;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Enable usage tracking
|
59 |
+
*
|
60 |
+
* @return bool
|
61 |
+
*/
|
62 |
+
public function enable() {
|
63 |
+
// only schedule if not yet scheduled
|
64 |
+
if ( ! wp_next_scheduled( 'mc4wp_usage_tracking' ) ) {
|
65 |
+
return wp_schedule_event( time(), 'monthly', 'mc4wp_usage_tracking' );
|
66 |
+
}
|
67 |
+
|
68 |
+
return true;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Disable usage tracking
|
73 |
+
*/
|
74 |
+
public function disable() {
|
75 |
+
wp_clear_scheduled_hook( 'mc4wp_usage_tracking' );
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Toggle tracking (clears & sets the scheduled tracking event)
|
80 |
+
*
|
81 |
+
* @param bool $enable
|
82 |
+
*/
|
83 |
+
public function toggle( $enable ) {
|
84 |
+
$enable ? $this->enable() : $this->disable();
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Sends the tracking request. Non-blocking.
|
89 |
+
*
|
90 |
+
* @return bool
|
91 |
+
*/
|
92 |
+
public function track() {
|
93 |
+
$data = $this->get_tracking_data();
|
94 |
+
|
95 |
+
// send non-blocking request and be done with it
|
96 |
+
wp_remote_post(
|
97 |
+
$this->tracking_url,
|
98 |
+
array(
|
99 |
+
'body' => json_encode( $data ),
|
100 |
+
'headers' => array(
|
101 |
+
'Content-Type' => 'application/json',
|
102 |
+
'Accept' => 'application/json',
|
103 |
+
),
|
104 |
+
'blocking' => false,
|
105 |
+
)
|
106 |
+
);
|
107 |
+
|
108 |
+
return true;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @return array
|
113 |
+
*/
|
114 |
+
protected function get_tracking_data() {
|
115 |
+
$data = array(
|
116 |
+
// use md5 hash of home_url, we don't need/want to know the actual site url
|
117 |
+
'site' => md5( home_url() ),
|
118 |
+
'number_of_mailchimp_lists' => $this->get_mailchimp_lists_count(),
|
119 |
+
'mc4wp_version' => $this->get_mc4wp_version(),
|
120 |
+
'mc4wp_premium_version' => $this->get_mc4wp_premium_version(),
|
121 |
+
'plugins' => (array) get_option( 'active_plugins', array() ),
|
122 |
+
'php_version' => $this->get_php_version(),
|
123 |
+
'curl_version' => $this->get_curl_version(),
|
124 |
+
'wp_version' => $GLOBALS['wp_version'],
|
125 |
+
'wp_language' => get_locale(),
|
126 |
+
'server_software' => $this->get_server_software(),
|
127 |
+
'using_https' => $this->is_site_using_https(),
|
128 |
+
);
|
129 |
+
|
130 |
+
return $data;
|
131 |
+
}
|
132 |
+
|
133 |
+
public function get_php_version() {
|
134 |
+
if ( ! defined( 'PHP_MAJOR_VERSION' ) ) { // defined since PHP 5.2.7
|
135 |
+
return null;
|
136 |
+
}
|
137 |
+
|
138 |
+
return PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @return string
|
143 |
+
*/
|
144 |
+
public function get_mc4wp_premium_version() {
|
145 |
+
return defined( 'MC4WP_PREMIUM_VERSION' ) ? MC4WP_PREMIUM_VERSION : null;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Returns the Mailchimp for WordPress version
|
150 |
+
*
|
151 |
+
* @return string
|
152 |
+
*/
|
153 |
+
protected function get_mc4wp_version() {
|
154 |
+
return MC4WP_VERSION;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* @return int
|
159 |
+
*/
|
160 |
+
protected function get_mailchimp_lists_count() {
|
161 |
+
$mailchimp = new MC4WP_MailChimp();
|
162 |
+
return count( $mailchimp->get_lists() );
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* @return string
|
167 |
+
*/
|
168 |
+
protected function get_curl_version() {
|
169 |
+
if ( ! function_exists( 'curl_version' ) ) {
|
170 |
+
return null;
|
171 |
+
}
|
172 |
+
|
173 |
+
$curl_version_info = curl_version();
|
174 |
+
return $curl_version_info['version'];
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* @return bool
|
179 |
+
*/
|
180 |
+
protected function is_site_using_https() {
|
181 |
+
$site_url = site_url();
|
182 |
+
return stripos( $site_url, 'https' ) === 0;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* @return string
|
187 |
+
*/
|
188 |
+
protected function get_server_software() {
|
189 |
+
if ( ! isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
|
190 |
+
return null;
|
191 |
+
}
|
192 |
+
|
193 |
+
return $_SERVER['SERVER_SOFTWARE'];
|
194 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
}
|
includes/admin/migrations/3.0.0-form-1-post-type.php
CHANGED
@@ -1,89 +1,89 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
// get options
|
6 |
-
$form_options = get_option('mc4wp_lite_form', array());
|
7 |
|
8 |
// bail if there are no previous options
|
9 |
-
if (empty($form_options)) {
|
10 |
-
|
11 |
}
|
12 |
|
13 |
// bail if there are Pro forms already
|
14 |
$has_forms = get_posts(
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
);
|
21 |
|
22 |
// There are forms already, don't continue.
|
23 |
-
if (! empty($has_forms)) {
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
}
|
29 |
|
30 |
// create post type for form
|
31 |
$id = wp_insert_post(
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
);
|
39 |
|
40 |
// set default_form_id
|
41 |
-
update_option('mc4wp_default_form_id', $id);
|
42 |
|
43 |
// set form settings
|
44 |
$setting_keys = array(
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
);
|
54 |
|
55 |
$settings = array();
|
56 |
|
57 |
-
foreach ($setting_keys as $setting_key) {
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
}
|
63 |
|
64 |
// get only keys of lists setting
|
65 |
-
if (isset($form_options['lists'])) {
|
66 |
-
|
67 |
}
|
68 |
|
69 |
-
update_post_meta($id, '_mc4wp_settings', $settings);
|
70 |
|
71 |
// set form message texts
|
72 |
$message_keys = array(
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
);
|
81 |
|
82 |
-
foreach ($message_keys as $message_key) {
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
}
|
87 |
|
88 |
// delete old option
|
89 |
-
delete_option('mc4wp_lite_form');
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
// get options
|
6 |
+
$form_options = get_option( 'mc4wp_lite_form', array() );
|
7 |
|
8 |
// bail if there are no previous options
|
9 |
+
if ( empty( $form_options ) ) {
|
10 |
+
return;
|
11 |
}
|
12 |
|
13 |
// bail if there are Pro forms already
|
14 |
$has_forms = get_posts(
|
15 |
+
array(
|
16 |
+
'post_type' => 'mc4wp-form',
|
17 |
+
'post_status' => 'publish',
|
18 |
+
'numberposts' => 1,
|
19 |
+
)
|
20 |
);
|
21 |
|
22 |
// There are forms already, don't continue.
|
23 |
+
if ( ! empty( $has_forms ) ) {
|
24 |
|
25 |
+
// delete option as it apparently exists.
|
26 |
+
delete_option( 'mc4wp_lite_form' );
|
27 |
+
return;
|
28 |
}
|
29 |
|
30 |
// create post type for form
|
31 |
$id = wp_insert_post(
|
32 |
+
array(
|
33 |
+
'post_type' => 'mc4wp-form',
|
34 |
+
'post_status' => 'publish',
|
35 |
+
'post_title' => __( 'Default sign-up form', 'mailchimp-for-wp' ),
|
36 |
+
'post_content' => ( empty( $form_options['markup'] ) ) ? '' : $form_options['markup'],
|
37 |
+
)
|
38 |
);
|
39 |
|
40 |
// set default_form_id
|
41 |
+
update_option( 'mc4wp_default_form_id', $id );
|
42 |
|
43 |
// set form settings
|
44 |
$setting_keys = array(
|
45 |
+
'css',
|
46 |
+
'custom_theme_color',
|
47 |
+
'double_optin',
|
48 |
+
'update_existing',
|
49 |
+
'replace_interests',
|
50 |
+
'send_welcome',
|
51 |
+
'redirect',
|
52 |
+
'hide_after_success',
|
53 |
);
|
54 |
|
55 |
$settings = array();
|
56 |
|
57 |
+
foreach ( $setting_keys as $setting_key ) {
|
58 |
+
// use isset to account for "0" settings
|
59 |
+
if ( isset( $form_options[ $setting_key ] ) ) {
|
60 |
+
$settings[ $setting_key ] = $form_options[ $setting_key ];
|
61 |
+
}
|
62 |
}
|
63 |
|
64 |
// get only keys of lists setting
|
65 |
+
if ( isset( $form_options['lists'] ) ) {
|
66 |
+
$settings['lists'] = array_keys( $form_options['lists'] );
|
67 |
}
|
68 |
|
69 |
+
update_post_meta( $id, '_mc4wp_settings', $settings );
|
70 |
|
71 |
// set form message texts
|
72 |
$message_keys = array(
|
73 |
+
'text_subscribed',
|
74 |
+
'text_error',
|
75 |
+
'text_invalid_email',
|
76 |
+
'text_already_subscribed',
|
77 |
+
'text_required_field_missing',
|
78 |
+
'text_unsubscribed',
|
79 |
+
'text_not_subscribed',
|
80 |
);
|
81 |
|
82 |
+
foreach ( $message_keys as $message_key ) {
|
83 |
+
if ( ! empty( $form_options[ $message_key ] ) ) {
|
84 |
+
update_post_meta( $id, $message_key, $form_options[ $message_key ] );
|
85 |
+
}
|
86 |
}
|
87 |
|
88 |
// delete old option
|
89 |
+
delete_option( 'mc4wp_lite_form' );
|
includes/admin/migrations/3.0.0-form-2-options.php
CHANGED
@@ -1,65 +1,65 @@
|
|
1 |
<?php
|
2 |
-
defined('ABSPATH') or exit;
|
3 |
|
4 |
-
$global_options = (array) get_option('mc4wp_form', array());
|
5 |
|
6 |
// find all form posts
|
7 |
$posts = get_posts(
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
);
|
14 |
|
15 |
$css_map = array(
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
);
|
25 |
|
26 |
$stylesheets = array();
|
27 |
|
28 |
-
foreach ($posts as $post) {
|
29 |
|
30 |
-
|
31 |
-
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
|
58 |
-
|
59 |
}
|
60 |
|
61 |
// update stylesheets option
|
62 |
-
update_option('mc4wp_form_stylesheets', $stylesheets);
|
63 |
|
64 |
// delete old options
|
65 |
-
delete_option('mc4wp_form');
|
1 |
<?php
|
2 |
+
defined( 'ABSPATH' ) or exit;
|
3 |
|
4 |
+
$global_options = (array) get_option( 'mc4wp_form', array() );
|
5 |
|
6 |
// find all form posts
|
7 |
$posts = get_posts(
|
8 |
+
array(
|
9 |
+
'post_type' => 'mc4wp-form',
|
10 |
+
'post_status' => 'publish',
|
11 |
+
'numberposts' => -1,
|
12 |
+
)
|
13 |
);
|
14 |
|
15 |
$css_map = array(
|
16 |
+
'default' => 'basic',
|
17 |
+
'custom' => 'styles-builder',
|
18 |
+
'light' => 'theme-light',
|
19 |
+
'dark' => 'theme-dark',
|
20 |
+
'red' => 'theme-red',
|
21 |
+
'green' => 'theme-green',
|
22 |
+
'blue' => 'theme-blue',
|
23 |
+
'custom-color' => 'theme-custom-color',
|
24 |
);
|
25 |
|
26 |
$stylesheets = array();
|
27 |
|
28 |
+
foreach ( $posts as $post ) {
|
29 |
|
30 |
+
// get form options from post meta directly
|
31 |
+
$options = (array) get_post_meta( $post->ID, '_mc4wp_settings', true );
|
32 |
|
33 |
+
// store all global options in scoped form settings
|
34 |
+
// do this BEFORE changing css key, so we take that as well.
|
35 |
+
foreach ( $global_options as $key => $value ) {
|
36 |
+
if ( strlen( $value ) > 0 && ( ! isset( $options[ $key ] ) || strlen( $options[ $key ] ) == 0 ) ) {
|
37 |
+
$options[ $key ] = $value;
|
38 |
+
}
|
39 |
+
}
|
40 |
|
41 |
+
// update "css" option value
|
42 |
+
if ( isset( $options['css'] ) && isset( $css_map[ $options['css'] ] ) ) {
|
43 |
+
$options['css'] = $css_map[ $options['css'] ];
|
44 |
+
}
|
45 |
|
46 |
+
// create stylesheets option
|
47 |
+
if ( ! empty( $options['css'] ) ) {
|
48 |
+
$stylesheet = $options['css'];
|
49 |
+
if ( strpos( $stylesheet, 'theme-' ) === 0 ) {
|
50 |
+
$stylesheet = 'themes';
|
51 |
+
}
|
52 |
|
53 |
+
if ( ! in_array( $stylesheet, $stylesheets ) ) {
|
54 |
+
$stylesheets[] = $stylesheet;
|
55 |
+
}
|
56 |
+
}
|
57 |
|
58 |
+
update_post_meta( $post->ID, '_mc4wp_settings', $options );
|
59 |
}
|
60 |
|
61 |
// update stylesheets option
|
62 |
+
update_option( 'mc4wp_form_stylesheets', $stylesheets );
|
63 |
|
64 |
// delete old options
|
65 |
+
delete_option( 'mc4wp_form' );
|
includes/admin/migrations/3.0.0-form-3-messages.php
CHANGED
@@ -1,41 +1,41 @@
|
|
1 |
<?php
|
2 |
-
defined('ABSPATH') or exit;
|
3 |
|
4 |
// find all form posts
|
5 |
$posts = get_posts(
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
);
|
12 |
|
13 |
// set form message texts
|
14 |
$message_keys = array(
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
);
|
23 |
|
24 |
-
foreach ($posts as $post) {
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
|
32 |
-
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
|
39 |
-
|
40 |
-
|
41 |
}
|
1 |
<?php
|
2 |
+
defined( 'ABSPATH' ) or exit;
|
3 |
|
4 |
// find all form posts
|
5 |
$posts = get_posts(
|
6 |
+
array(
|
7 |
+
'post_type' => 'mc4wp-form',
|
8 |
+
'post_status' => 'publish',
|
9 |
+
'numberposts' => -1,
|
10 |
+
)
|
11 |
);
|
12 |
|
13 |
// set form message texts
|
14 |
$message_keys = array(
|
15 |
+
'text_subscribed',
|
16 |
+
'text_error',
|
17 |
+
'text_invalid_email',
|
18 |
+
'text_already_subscribed',
|
19 |
+
'text_required_field_missing',
|
20 |
+
'text_unsubscribed',
|
21 |
+
'text_not_subscribed',
|
22 |
);
|
23 |
|
24 |
+
foreach ( $posts as $post ) {
|
25 |
+
$settings = get_post_meta( $post->ID, '_mc4wp_settings', true );
|
26 |
|
27 |
+
foreach ( $message_keys as $key ) {
|
28 |
+
if ( empty( $settings[ $key ] ) ) {
|
29 |
+
continue;
|
30 |
+
}
|
31 |
|
32 |
+
$message = $settings[ $key ];
|
33 |
|
34 |
+
// move message setting over to post meta
|
35 |
+
update_post_meta( $post->ID, $key, $message );
|
36 |
+
unset( $settings[ $key ] );
|
37 |
+
}
|
38 |
|
39 |
+
// update post meta with unset message keys
|
40 |
+
update_post_meta( $post->ID, '_mc4wp_settings', $settings );
|
41 |
}
|
includes/admin/migrations/3.0.0-general-options.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
// transfer option
|
6 |
-
$options = (array) get_option('mc4wp_lite', array());
|
7 |
|
8 |
// merge options, with Pro options taking precedence
|
9 |
-
$pro_options = (array) get_option('mc4wp', array());
|
10 |
-
$options
|
11 |
|
12 |
// update options
|
13 |
-
update_option('mc4wp', $options);
|
14 |
|
15 |
// delete old option
|
16 |
-
delete_option('mc4wp_lite');
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
// transfer option
|
6 |
+
$options = (array) get_option( 'mc4wp_lite', array() );
|
7 |
|
8 |
// merge options, with Pro options taking precedence
|
9 |
+
$pro_options = (array) get_option( 'mc4wp', array() );
|
10 |
+
$options = array_merge( $options, $pro_options );
|
11 |
|
12 |
// update options
|
13 |
+
update_option( 'mc4wp', $options );
|
14 |
|
15 |
// delete old option
|
16 |
+
delete_option( 'mc4wp_lite' );
|
includes/admin/migrations/3.0.0-integration-options.php
CHANGED
@@ -1,65 +1,65 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
-
$old_options = get_option('mc4wp_lite_checkbox', array());
|
6 |
-
$pro_options = get_option('mc4wp_checkbox', array());
|
7 |
-
if (! empty($pro_options)) {
|
8 |
-
|
9 |
}
|
10 |
|
11 |
// do we have to do something?
|
12 |
-
if (empty($old_options)) {
|
13 |
-
|
14 |
}
|
15 |
|
16 |
// find activated integrations (show_at_xxx options)
|
17 |
$new_options = array();
|
18 |
-
$map
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
);
|
26 |
|
27 |
$option_keys = array(
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
);
|
37 |
|
38 |
-
foreach ($map as $old_integration_slug => $new_integration_slug) {
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
|
56 |
-
|
57 |
-
|
58 |
}
|
59 |
|
60 |
// save new settings
|
61 |
-
update_option('mc4wp_integrations', $new_options);
|
62 |
|
63 |
// delete old options
|
64 |
-
delete_option('mc4wp_lite_checkbox');
|
65 |
-
delete_option('mc4wp_checkbox');
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
+
$old_options = get_option( 'mc4wp_lite_checkbox', array() );
|
6 |
+
$pro_options = get_option( 'mc4wp_checkbox', array() );
|
7 |
+
if ( ! empty( $pro_options ) ) {
|
8 |
+
$old_options = array_merge( $old_options, $pro_options );
|
9 |
}
|
10 |
|
11 |
// do we have to do something?
|
12 |
+
if ( empty( $old_options ) ) {
|
13 |
+
return;
|
14 |
}
|
15 |
|
16 |
// find activated integrations (show_at_xxx options)
|
17 |
$new_options = array();
|
18 |
+
$map = array(
|
19 |
+
'comment_form' => 'wp-comment-form',
|
20 |
+
'registration_form' => 'wp-registration-form',
|
21 |
+
'buddypress_form' => 'buddypress',
|
22 |
+
'bbpres_forms' => 'bbpress',
|
23 |
+
'woocommerce_checkout' => 'woocommerce',
|
24 |
+
'edd_checkout' => 'easy-digital-downloads',
|
25 |
);
|
26 |
|
27 |
$option_keys = array(
|
28 |
+
'label',
|
29 |
+
'precheck',
|
30 |
+
'css',
|
31 |
+
'lists',
|
32 |
+
'double_optin',
|
33 |
+
'update_existing',
|
34 |
+
'replace_interests',
|
35 |
+
'send_welcome',
|
36 |
);
|
37 |
|
38 |
+
foreach ( $map as $old_integration_slug => $new_integration_slug ) {
|
39 |
|
40 |
+
// check if integration is enabled using its old slug
|
41 |
+
$show_key = sprintf( 'show_at_%s', $old_integration_slug );
|
42 |
+
if ( empty( $old_options[ $show_key ] ) ) {
|
43 |
+
continue;
|
44 |
+
}
|
45 |
|
46 |
+
$options = array(
|
47 |
+
'enabled' => 1,
|
48 |
+
);
|
49 |
|
50 |
+
foreach ( $option_keys as $option_key ) {
|
51 |
+
if ( isset( $old_options[ $option_key ] ) ) {
|
52 |
+
$options[ $option_key ] = $old_options[ $option_key ];
|
53 |
+
}
|
54 |
+
}
|
55 |
|
56 |
+
// add to new options
|
57 |
+
$new_options[ $new_integration_slug ] = $options;
|
58 |
}
|
59 |
|
60 |
// save new settings
|
61 |
+
update_option( 'mc4wp_integrations', $new_options );
|
62 |
|
63 |
// delete old options
|
64 |
+
delete_option( 'mc4wp_lite_checkbox' );
|
65 |
+
delete_option( 'mc4wp_checkbox' );
|
includes/admin/migrations/3.0.0-styles-builder.php
CHANGED
@@ -1,42 +1,42 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
// move stylebuilders file to bundle
|
6 |
-
$file = (string) get_option('mc4wp_custom_css_file', '');
|
7 |
-
if (empty($file)) {
|
8 |
-
|
9 |
}
|
10 |
|
11 |
$uploads = wp_upload_dir();
|
12 |
|
13 |
// figure out absolute file path
|
14 |
-
$prefix
|
15 |
-
$relative_path = str_replace($prefix, '', $file);
|
16 |
|
17 |
// get part before ?
|
18 |
-
if (strpos($relative_path, '?') !== false) {
|
19 |
-
|
20 |
-
|
21 |
}
|
22 |
|
23 |
// This is the absolute path to the file, he he..
|
24 |
$file = $uploads['basedir'] . $relative_path;
|
25 |
|
26 |
-
if (file_exists($file)) {
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
}
|
40 |
|
41 |
// remove old option
|
42 |
-
delete_option('mc4wp_custom_css_file');
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
// move stylebuilders file to bundle
|
6 |
+
$file = (string) get_option( 'mc4wp_custom_css_file', '' );
|
7 |
+
if ( empty( $file ) ) {
|
8 |
+
return;
|
9 |
}
|
10 |
|
11 |
$uploads = wp_upload_dir();
|
12 |
|
13 |
// figure out absolute file path
|
14 |
+
$prefix = str_replace( 'http:', '', $uploads['baseurl'] );
|
15 |
+
$relative_path = str_replace( $prefix, '', $file );
|
16 |
|
17 |
// get part before ?
|
18 |
+
if ( strpos( $relative_path, '?' ) !== false ) {
|
19 |
+
$parts = explode( '?', $relative_path );
|
20 |
+
$relative_path = array_shift( $parts );
|
21 |
}
|
22 |
|
23 |
// This is the absolute path to the file, he he..
|
24 |
$file = $uploads['basedir'] . $relative_path;
|
25 |
|
26 |
+
if ( file_exists( $file ) ) {
|
27 |
|
28 |
+
// create directory, if necessary
|
29 |
+
$dir = $uploads['basedir'] . '/mc4wp-stylesheets';
|
30 |
+
if ( ! file_exists( $dir ) ) {
|
31 |
+
@mkdir( $dir, 0755 );
|
32 |
+
}
|
33 |
|
34 |
+
@chmod( $dir, 0755 );
|
35 |
|
36 |
+
// Move file to new location
|
37 |
+
$new_file = $dir . '/bundle.css';
|
38 |
+
$success = rename( $file, $new_file );
|
39 |
}
|
40 |
|
41 |
// remove old option
|
42 |
+
delete_option( 'mc4wp_custom_css_file' );
|
includes/admin/migrations/3.0.0-widget-base-id.php
CHANGED
@@ -1,42 +1,42 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
-
$section_widgets = get_option('sidebars_widgets', array());
|
6 |
-
$replaced
|
7 |
|
8 |
-
foreach ($section_widgets as $section => $widgets) {
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
}
|
28 |
|
29 |
|
30 |
// update option if we made changes
|
31 |
-
if ($replaced) {
|
32 |
-
|
33 |
}
|
34 |
|
35 |
// update widget options
|
36 |
-
$options = get_option('widget_mc4wp_widget', false);
|
37 |
-
if ($options) {
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
+
$section_widgets = get_option( 'sidebars_widgets', array() );
|
6 |
+
$replaced = false;
|
7 |
|
8 |
+
foreach ( $section_widgets as $section => $widgets ) {
|
9 |
|
10 |
+
// WP has an "array_version" key that is not an array...
|
11 |
+
if ( ! is_array( $widgets ) ) {
|
12 |
+
continue;
|
13 |
+
}
|
14 |
|
15 |
+
// loop through widget ID's
|
16 |
+
foreach ( $widgets as $key => $widget_id ) {
|
17 |
|
18 |
+
// does this widget ID start with "mc4wp_widget"?
|
19 |
+
if ( strpos( $widget_id, 'mc4wp_widget' ) === 0 ) {
|
20 |
|
21 |
+
// replace "mc4wp_widget" with "mc4wp_form_widget"
|
22 |
+
$new_widget_id = str_replace( 'mc4wp_widget', 'mc4wp_form_widget', $widget_id );
|
23 |
+
$section_widgets[ $section ][ $key ] = $new_widget_id;
|
24 |
+
$replaced = true;
|
25 |
+
}
|
26 |
+
}
|
27 |
}
|
28 |
|
29 |
|
30 |
// update option if we made changes
|
31 |
+
if ( $replaced ) {
|
32 |
+
update_option( 'sidebars_widgets', $section_widgets );
|
33 |
}
|
34 |
|
35 |
// update widget options
|
36 |
+
$options = get_option( 'widget_mc4wp_widget', false );
|
37 |
+
if ( $options ) {
|
38 |
+
update_option( 'widget_mc4wp_form_widget', $options );
|
39 |
|
40 |
+
// delete old option
|
41 |
+
delete_option( 'widget_mc4wp_widget' );
|
42 |
}
|
includes/admin/migrations/3.0.3-usage-tracking-schedule.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
-
defined('ABSPATH') or exit;
|
3 |
|
4 |
-
$options = (array) get_option('mc4wp', array());
|
5 |
-
if (empty($options['allow_usage_tracking'])) {
|
6 |
-
|
7 |
}
|
8 |
|
9 |
// usage tracking is enabled, reschedule it so it uses new cron schedule.
|
@@ -12,18 +12,17 @@ if (empty($options['allow_usage_tracking'])) {
|
|
12 |
/**
|
13 |
* @ignore
|
14 |
*/
|
15 |
-
function _mc4wp_303_add_monthly_cron_schedule($schedules)
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
);
|
21 |
|
22 |
-
|
23 |
}
|
24 |
|
25 |
-
add_filter('cron_schedules', '_mc4wp_303_add_monthly_cron_schedule', 1);
|
26 |
|
27 |
// reschedule usage tracking event
|
28 |
-
wp_clear_scheduled_hook('mc4wp_usage_tracking');
|
29 |
-
wp_schedule_event(time(), 'monthly', 'mc4wp_usage_tracking');
|
1 |
<?php
|
2 |
+
defined( 'ABSPATH' ) or exit;
|
3 |
|
4 |
+
$options = (array) get_option( 'mc4wp', array() );
|
5 |
+
if ( empty( $options['allow_usage_tracking'] ) ) {
|
6 |
+
return;
|
7 |
}
|
8 |
|
9 |
// usage tracking is enabled, reschedule it so it uses new cron schedule.
|
12 |
/**
|
13 |
* @ignore
|
14 |
*/
|
15 |
+
function _mc4wp_303_add_monthly_cron_schedule( $schedules ) {
|
16 |
+
$schedules['monthly'] = array(
|
17 |
+
'interval' => 30 * DAY_IN_SECONDS,
|
18 |
+
'display' => 'Once a month',
|
19 |
+
);
|
|
|
20 |
|
21 |
+
return $schedules;
|
22 |
}
|
23 |
|
24 |
+
add_filter( 'cron_schedules', '_mc4wp_303_add_monthly_cron_schedule', 1 );
|
25 |
|
26 |
// reschedule usage tracking event
|
27 |
+
wp_clear_scheduled_hook( 'mc4wp_usage_tracking' );
|
28 |
+
wp_schedule_event( time(), 'monthly', 'mc4wp_usage_tracking' );
|
includes/admin/migrations/3.1.6-woocommerce-position-prefix.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
-
$options = get_option('mc4wp_integrations', array());
|
6 |
|
7 |
-
if (! empty($options['woocommerce']) && ! empty($options['woocommerce']['position'])) {
|
8 |
-
|
9 |
}
|
10 |
|
11 |
-
update_option('mc4wp_integrations', $options);
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
+
$options = get_option( 'mc4wp_integrations', array() );
|
6 |
|
7 |
+
if ( ! empty( $options['woocommerce'] ) && ! empty( $options['woocommerce']['position'] ) ) {
|
8 |
+
$options['woocommerce']['position'] = sprintf( 'checkout_%s', $options['woocommerce']['position'] );
|
9 |
}
|
10 |
|
11 |
+
update_option( 'mc4wp_integrations', $options );
|
includes/admin/migrations/4.0.0-groupings-to-interests.php
CHANGED
@@ -1,114 +1,112 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* @ignore
|
7 |
* @return object
|
8 |
*/
|
9 |
-
function _mc4wp_400_find_grouping_for_interest_category($groupings, $interest_category)
|
10 |
-
{
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
return null;
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
* @ignore
|
25 |
* @return object
|
26 |
*/
|
27 |
-
function _mc4wp_400_find_group_for_interest($groups, $interest)
|
28 |
-
{
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
return null;
|
39 |
}
|
40 |
|
41 |
// in case the migration is _very_ late to the party
|
42 |
-
if (! class_exists('
|
43 |
-
|
44 |
}
|
45 |
|
46 |
-
$options = get_option('mc4wp', array());
|
47 |
-
if (empty($options['api_key'])) {
|
48 |
-
|
49 |
}
|
50 |
|
51 |
// get current state from transient
|
52 |
-
$lists = get_transient('mc4wp_mailchimp_lists_fallback');
|
53 |
-
if (empty($lists)) {
|
54 |
-
|
55 |
}
|
56 |
|
57 |
-
@set_time_limit(600);
|
58 |
-
$api_v3 = new
|
59 |
-
$map
|
60 |
|
61 |
-
foreach ($lists as $list) {
|
62 |
|
63 |
-
|
64 |
-
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
|
78 |
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
|
95 |
-
|
96 |
-
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
}
|
110 |
|
111 |
|
112 |
-
if (! empty($map)) {
|
113 |
-
|
114 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* @ignore
|
7 |
* @return object
|
8 |
*/
|
9 |
+
function _mc4wp_400_find_grouping_for_interest_category( $groupings, $interest_category ) {
|
10 |
+
foreach ( $groupings as $grouping ) {
|
11 |
+
// cast to stdClass because of missing class
|
12 |
+
$grouping = (object) (array) $grouping;
|
13 |
+
|
14 |
+
if ( $grouping->name === $interest_category->title ) {
|
15 |
+
return $grouping;
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
return null;
|
|
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
* @ignore
|
24 |
* @return object
|
25 |
*/
|
26 |
+
function _mc4wp_400_find_group_for_interest( $groups, $interest ) {
|
27 |
+
foreach ( $groups as $group_id => $group_name ) {
|
28 |
+
if ( $group_name === $interest->name ) {
|
29 |
+
return (object) array(
|
30 |
+
'name' => $group_name,
|
31 |
+
'id' => $group_id,
|
32 |
+
);
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
return null;
|
|
|
37 |
}
|
38 |
|
39 |
// in case the migration is _very_ late to the party
|
40 |
+
if ( ! class_exists( 'MC4WP_API_V3' ) ) {
|
41 |
+
return;
|
42 |
}
|
43 |
|
44 |
+
$options = get_option( 'mc4wp', array() );
|
45 |
+
if ( empty( $options['api_key'] ) ) {
|
46 |
+
return;
|
47 |
}
|
48 |
|
49 |
// get current state from transient
|
50 |
+
$lists = get_transient( 'mc4wp_mailchimp_lists_fallback' );
|
51 |
+
if ( empty( $lists ) ) {
|
52 |
+
return;
|
53 |
}
|
54 |
|
55 |
+
@set_time_limit( 600 );
|
56 |
+
$api_v3 = new MC4WP_API_V3( $options['api_key'] );
|
57 |
+
$map = array();
|
58 |
|
59 |
+
foreach ( $lists as $list ) {
|
60 |
|
61 |
+
// cast to stdClass because of missing classes
|
62 |
+
$list = (object) (array) $list;
|
63 |
|
64 |
+
// no groupings? easy!
|
65 |
+
if ( empty( $list->groupings ) ) {
|
66 |
+
continue;
|
67 |
+
}
|
68 |
|
69 |
+
// fetch (new) interest categories for this list
|
70 |
+
try {
|
71 |
+
$interest_categories = $api_v3->get_list_interest_categories( $list->id );
|
72 |
+
} catch ( MC4WP_API_Exception $e ) {
|
73 |
+
continue;
|
74 |
+
}
|
75 |
|
76 |
|
77 |
+
foreach ( $interest_categories as $interest_category ) {
|
78 |
|
79 |
+
// compare interest title with grouping name, if it matches, get new id.
|
80 |
+
$grouping = _mc4wp_400_find_grouping_for_interest_category( $list->groupings, $interest_category );
|
81 |
+
if ( ! $grouping ) {
|
82 |
+
continue;
|
83 |
+
}
|
84 |
|
85 |
+
$groups = array();
|
86 |
|
87 |
+
try {
|
88 |
+
$interests = $api_v3->get_list_interest_category_interests( $list->id, $interest_category->id );
|
89 |
+
} catch ( MC4WP_API_Exception $e ) {
|
90 |
+
continue;
|
91 |
+
}
|
92 |
|
93 |
+
foreach ( $interests as $interest ) {
|
94 |
+
$group = _mc4wp_400_find_group_for_interest( $grouping->groups, $interest );
|
95 |
|
96 |
+
if ( $group ) {
|
97 |
+
$groups[ $group->id ] = $interest->id;
|
98 |
+
$groups[ $group->name ] = $interest->id;
|
99 |
+
}
|
100 |
+
}
|
101 |
|
102 |
+
$map[ (string) $grouping->id ] = array(
|
103 |
+
'id' => $interest_category->id,
|
104 |
+
'groups' => $groups,
|
105 |
+
);
|
106 |
+
}
|
107 |
}
|
108 |
|
109 |
|
110 |
+
if ( ! empty( $map ) ) {
|
111 |
+
update_option( 'mc4wp_groupings_map', $map );
|
112 |
}
|
includes/admin/migrations/4.0.0-hidden-fields-value-delimiter.php
CHANGED
@@ -1,27 +1,31 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/** @ignore */
|
6 |
-
function _mc4wp_400_replace_comma_with_pipe($matches)
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
return str_replace($old, $new, $matches[0]);
|
11 |
}
|
12 |
|
13 |
// get all forms
|
14 |
-
$posts = get_posts(
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
foreach ($posts as $post) {
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/** @ignore */
|
6 |
+
function _mc4wp_400_replace_comma_with_pipe( $matches ) {
|
7 |
+
$old = $matches[1];
|
8 |
+
$new = str_replace( ',', '|', $old );
|
9 |
+
return str_replace( $old, $new, $matches[0] );
|
|
|
10 |
}
|
11 |
|
12 |
// get all forms
|
13 |
+
$posts = get_posts(
|
14 |
+
array(
|
15 |
+
'post_type' => 'mc4wp-form',
|
16 |
+
'numberposts' => -1,
|
17 |
+
)
|
18 |
+
);
|
19 |
|
20 |
+
foreach ( $posts as $post ) {
|
21 |
|
22 |
+
// find hidden field values in form and pass through replace function
|
23 |
+
$old = $post->post_content;
|
24 |
+
$new = preg_replace_callback( '/type="hidden" .* value="(.*)"/i', '_mc4wp_400_replace_comma_with_pipe', $old );
|
25 |
|
26 |
+
// update post if we replaced something
|
27 |
+
if ( $new != $old ) {
|
28 |
+
$post->post_content = $new;
|
29 |
+
wp_update_post( $post );
|
30 |
+
}
|
31 |
}
|
includes/admin/migrations/4.0.7-rename-debug-log-file.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
// get old log filename
|
6 |
-
$upload_dir
|
7 |
-
$old_filename = trailingslashit($upload_dir['basedir']) . 'mc4wp-debug.log';
|
8 |
-
$new_filename = trailingslashit($upload_dir['basedir']) . 'mc4wp-debug-log.php';
|
9 |
|
10 |
// check if old default log file exists
|
11 |
-
if (! file_exists($old_filename)) {
|
12 |
-
|
13 |
}
|
14 |
|
15 |
// rename to new file.
|
16 |
-
@rename($old_filename, $new_filename);
|
17 |
|
18 |
// if success, insert php exit tag as first line
|
19 |
-
if (file_exists($new_filename)) {
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
// get old log filename
|
6 |
+
$upload_dir = wp_upload_dir( null, false );
|
7 |
+
$old_filename = trailingslashit( $upload_dir['basedir'] ) . 'mc4wp-debug.log';
|
8 |
+
$new_filename = trailingslashit( $upload_dir['basedir'] ) . 'mc4wp-debug-log.php';
|
9 |
|
10 |
// check if old default log file exists
|
11 |
+
if ( ! file_exists( $old_filename ) ) {
|
12 |
+
return;
|
13 |
}
|
14 |
|
15 |
// rename to new file.
|
16 |
+
@rename( $old_filename, $new_filename );
|
17 |
|
18 |
// if success, insert php exit tag as first line
|
19 |
+
if ( file_exists( $new_filename ) ) {
|
20 |
+
$handle = fopen( $new_filename, 'r+' );
|
21 |
|
22 |
+
if ( is_resource( $handle ) ) {
|
23 |
+
// make sure first line of log file is a PHP tag + exit statement (to prevent direct file access)
|
24 |
+
$line = fgets( $handle );
|
25 |
+
$php_exit_string = '<?php exit; ?>';
|
26 |
+
if ( strpos( $line, $php_exit_string ) !== 0 ) {
|
27 |
+
rewind( $handle );
|
28 |
+
fwrite( $handle, $php_exit_string . PHP_EOL . $line );
|
29 |
+
}
|
30 |
|
31 |
+
fclose( $handle );
|
32 |
+
}
|
33 |
}
|
includes/admin/migrations/4.1.2-flush-list-cache.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
-
if (function_exists('mc4wp_refresh_mailchimp_lists')) {
|
6 |
-
|
7 |
}
|
8 |
|
9 |
-
delete_transient('mc4wp_mailchimp_lists_v3');
|
10 |
-
delete_option('mc4wp_mailchimp_lists_v3_fallback');
|
11 |
|
12 |
-
wp_schedule_event(strtotime('tomorrow 3 am'), 'daily', 'mc4wp_refresh_mailchimp_lists');
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
+
if ( function_exists( 'mc4wp_refresh_mailchimp_lists' ) ) {
|
6 |
+
mc4wp_refresh_mailchimp_lists();
|
7 |
}
|
8 |
|
9 |
+
delete_transient( 'mc4wp_mailchimp_lists_v3' );
|
10 |
+
delete_option( 'mc4wp_mailchimp_lists_v3_fallback' );
|
11 |
|
12 |
+
wp_schedule_event( strtotime( 'tomorrow 3 am' ), 'daily', 'mc4wp_refresh_mailchimp_lists' );
|
includes/admin/migrations/4.1.3-reschedule-event.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
-
wp_clear_scheduled_hook('mc4wp_refresh_mailchimp_lists');
|
6 |
|
7 |
-
$time_string = sprintf(
|
8 |
-
wp_schedule_event(strtotime($time_string), 'daily', 'mc4wp_refresh_mailchimp_lists');
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
+
wp_clear_scheduled_hook( 'mc4wp_refresh_mailchimp_lists' );
|
6 |
|
7 |
+
$time_string = sprintf( 'tomorrow %d:%d%d am', rand( 1, 6 ), rand( 0, 5 ), rand( 0, 9 ) );
|
8 |
+
wp_schedule_event( strtotime( $time_string ), 'daily', 'mc4wp_refresh_mailchimp_lists' );
|
includes/admin/migrations/4.6.0-remove-lists-from-options.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
<?php
|
2 |
|
3 |
global $wpdb;
|
4 |
-
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'mc4wp_mailchimp_list_%'");
|
1 |
<?php
|
2 |
|
3 |
global $wpdb;
|
4 |
+
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'mc4wp_mailchimp_list_%'" );
|
includes/api/class-api-v3-client.php
CHANGED
@@ -1,253 +1,240 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
*/
|
241 |
-
public function get_last_response_headers()
|
242 |
-
{
|
243 |
-
return wp_remote_retrieve_headers($this->last_response);
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* @return array|WP_Error
|
248 |
-
*/
|
249 |
-
public function get_last_response()
|
250 |
-
{
|
251 |
-
return $this->last_response;
|
252 |
-
}
|
253 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class MC4WP_API_V3_Client {
|
4 |
+
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @var string
|
8 |
+
*/
|
9 |
+
private $api_key;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @var string
|
13 |
+
*/
|
14 |
+
private $api_url = 'https://api.mailchimp.com/3.0/';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var array
|
18 |
+
*/
|
19 |
+
private $last_response;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @var array
|
23 |
+
*/
|
24 |
+
private $last_request;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Constructor
|
28 |
+
*
|
29 |
+
* @param string $api_key
|
30 |
+
*/
|
31 |
+
public function __construct( $api_key ) {
|
32 |
+
$this->api_key = $api_key;
|
33 |
+
|
34 |
+
$dash_position = strpos( $api_key, '-' );
|
35 |
+
if ( $dash_position !== false ) {
|
36 |
+
$this->api_url = str_replace( '//api.', '//' . substr( $api_key, $dash_position + 1 ) . '.api.', $this->api_url );
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @param string $resource
|
43 |
+
* @param array $args
|
44 |
+
*
|
45 |
+
* @return mixed
|
46 |
+
* @throws MC4WP_API_Exception
|
47 |
+
*/
|
48 |
+
public function get( $resource, array $args = array() ) {
|
49 |
+
return $this->request( 'GET', $resource, $args );
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @param string $resource
|
54 |
+
* @param array $data
|
55 |
+
*
|
56 |
+
* @return mixed
|
57 |
+
* @throws MC4WP_API_Exception
|
58 |
+
*/
|
59 |
+
public function post( $resource, array $data ) {
|
60 |
+
return $this->request( 'POST', $resource, $data );
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @param string $resource
|
65 |
+
* @param array $data
|
66 |
+
* @return mixed
|
67 |
+
* @throws MC4WP_API_Exception
|
68 |
+
*/
|
69 |
+
public function put( $resource, array $data ) {
|
70 |
+
return $this->request( 'PUT', $resource, $data );
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @param string $resource
|
75 |
+
* @param array $data
|
76 |
+
* @return mixed
|
77 |
+
* @throws MC4WP_API_Exception
|
78 |
+
*/
|
79 |
+
public function patch( $resource, array $data ) {
|
80 |
+
return $this->request( 'PATCH', $resource, $data );
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @param string $resource
|
85 |
+
* @return mixed
|
86 |
+
* @throws MC4WP_API_Exception
|
87 |
+
*/
|
88 |
+
public function delete( $resource ) {
|
89 |
+
return $this->request( 'DELETE', $resource );
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* @param string $method
|
94 |
+
* @param string $resource
|
95 |
+
* @param array $data
|
96 |
+
*
|
97 |
+
* @return mixed
|
98 |
+
*
|
99 |
+
* @throws MC4WP_API_Exception
|
100 |
+
*/
|
101 |
+
private function request( $method, $resource, array $data = array() ) {
|
102 |
+
$this->reset();
|
103 |
+
|
104 |
+
// don't bother if no API key was given.
|
105 |
+
if ( empty( $this->api_key ) ) {
|
106 |
+
throw new MC4WP_API_Exception( 'Missing API key', 001 );
|
107 |
+
}
|
108 |
+
|
109 |
+
$method = strtoupper( trim( $method ) );
|
110 |
+
$url = $this->api_url . ltrim( $resource, '/' );
|
111 |
+
$args = array(
|
112 |
+
'method' => $method,
|
113 |
+
'headers' => $this->get_headers(),
|
114 |
+
'timeout' => 15,
|
115 |
+
'sslverify' => apply_filters( 'mc4wp_use_sslverify', true ),
|
116 |
+
);
|
117 |
+
|
118 |
+
if ( ! empty( $data ) ) {
|
119 |
+
if ( in_array( $method, array( 'GET', 'DELETE' ), true ) ) {
|
120 |
+
$url = add_query_arg( $data, $url );
|
121 |
+
} else {
|
122 |
+
$args['headers']['Content-Type'] = 'application/json';
|
123 |
+
$args['body'] = json_encode( $data );
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Filter the request arguments for all requests generated by this class
|
129 |
+
*
|
130 |
+
* @param array $args
|
131 |
+
*/
|
132 |
+
$args = apply_filters( 'mc4wp_http_request_args', $args, $url );
|
133 |
+
|
134 |
+
// perform request
|
135 |
+
$response = wp_remote_request( $url, $args );
|
136 |
+
|
137 |
+
// store request & response
|
138 |
+
$args['url'] = $url;
|
139 |
+
$this->last_request = $args;
|
140 |
+
$this->last_response = $response;
|
141 |
+
|
142 |
+
// parse response
|
143 |
+
$data = $this->parse_response( $response );
|
144 |
+
|
145 |
+
return $data;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* @return array
|
150 |
+
*/
|
151 |
+
private function get_headers() {
|
152 |
+
global $wp_version;
|
153 |
+
|
154 |
+
$headers = array();
|
155 |
+
$headers['Authorization'] = 'Basic ' . base64_encode( 'mc4wp:' . $this->api_key );
|
156 |
+
$headers['User-Agent'] = 'mc4wp/' . MC4WP_VERSION . '; WordPress/' . $wp_version . '; ' . home_url();
|
157 |
+
|
158 |
+
// Copy Accept-Language from browser headers
|
159 |
+
if ( ! empty( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
|
160 |
+
$headers['Accept-Language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
161 |
+
}
|
162 |
+
|
163 |
+
return $headers;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* @param array|WP_Error $response
|
168 |
+
*
|
169 |
+
* @return mixed
|
170 |
+
*
|
171 |
+
* @throws MC4WP_API_Connection_Exception|MC4WP_API_Resource_Not_Found_Exception|MC4WP_API_Exception
|
172 |
+
*/
|
173 |
+
private function parse_response( $response ) {
|
174 |
+
if ( $response instanceof WP_Error ) {
|
175 |
+
throw new MC4WP_API_Connection_Exception( $response->get_error_message(), (int) $response->get_error_code(), $this->last_request );
|
176 |
+
}
|
177 |
+
|
178 |
+
// decode response body
|
179 |
+
$code = (int) wp_remote_retrieve_response_code( $response );
|
180 |
+
$message = wp_remote_retrieve_response_message( $response );
|
181 |
+
$body = wp_remote_retrieve_body( $response );
|
182 |
+
|
183 |
+
// set body to "true" in case Mailchimp returned No Content
|
184 |
+
if ( $code < 300 && empty( $body ) ) {
|
185 |
+
$body = 'true';
|
186 |
+
}
|
187 |
+
|
188 |
+
$data = json_decode( $body );
|
189 |
+
if ( $code >= 400 ) {
|
190 |
+
// check for akamai errors
|
191 |
+
// {"type":"akamai_error_message","title":"akamai_503","status":503,"ref_no":"Reference Number: 00.950e16c3.1498559813.1450dbe2"}
|
192 |
+
if ( is_object( $data ) && isset( $data->type ) && $data->type === 'akamai_error_message' ) {
|
193 |
+
throw new MC4WP_API_Connection_Exception( $message, $code, $this->last_request, $this->last_response, $data );
|
194 |
+
}
|
195 |
+
|
196 |
+
if ( $code === 404 ) {
|
197 |
+
throw new MC4WP_API_Resource_Not_Found_Exception( $message, $code, $this->last_request, $this->last_response, $data );
|
198 |
+
}
|
199 |
+
|
200 |
+
// mailchimp returned an error..
|
201 |
+
throw new MC4WP_API_Exception( $message, $code, $this->last_request, $this->last_response, $data );
|
202 |
+
}
|
203 |
+
|
204 |
+
// throw exception if unable to decode response
|
205 |
+
if ( $data === null ) {
|
206 |
+
throw new MC4WP_API_Exception( $message, $code, $this->last_request, $this->last_response );
|
207 |
+
}
|
208 |
+
|
209 |
+
return $data;
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Empties all data from previous response
|
214 |
+
*/
|
215 |
+
private function reset() {
|
216 |
+
$this->last_response = null;
|
217 |
+
$this->last_request = null;
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* @return string
|
222 |
+
*/
|
223 |
+
public function get_last_response_body() {
|
224 |
+
return wp_remote_retrieve_body( $this->last_response );
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* @return array
|
229 |
+
*/
|
230 |
+
public function get_last_response_headers() {
|
231 |
+
return wp_remote_retrieve_headers( $this->last_response );
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* @return array|WP_Error
|
236 |
+
*/
|
237 |
+
public function get_last_response() {
|
238 |
+
return $this->last_response;
|
239 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
}
|
includes/api/class-api-v3.php
CHANGED
@@ -1,1337 +1,1255 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Class
|
5 |
*/
|
6 |
-
class
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
public function update_campaign($campaign_id, array $args)
|
1256 |
-
{
|
1257 |
-
$resource = sprintf('/campaigns/%s', $campaign_id);
|
1258 |
-
return $this->client->patch($resource, $args);
|
1259 |
-
}
|
1260 |
-
|
1261 |
-
/**
|
1262 |
-
* Remove a campaign from the Mailchimp account
|
1263 |
-
*
|
1264 |
-
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/#delete-delete_campaigns_campaign_id
|
1265 |
-
* @param string $campaign_id
|
1266 |
-
* @return bool
|
1267 |
-
* @throws MC4WP_API_Exception
|
1268 |
-
*/
|
1269 |
-
public function delete_campaign($campaign_id)
|
1270 |
-
{
|
1271 |
-
$resource = sprintf('/campaigns/%s', $campaign_id);
|
1272 |
-
return !! $this->client->delete($resource);
|
1273 |
-
}
|
1274 |
-
|
1275 |
-
/**
|
1276 |
-
* Perform an action on a Mailchimp campaign
|
1277 |
-
*
|
1278 |
-
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/#action-post_campaigns
|
1279 |
-
*
|
1280 |
-
* @param string $campaign_id
|
1281 |
-
* @param string $action
|
1282 |
-
* @param array $args
|
1283 |
-
* @return object
|
1284 |
-
* @throws MC4WP_API_Exception
|
1285 |
-
*/
|
1286 |
-
public function campaign_action($campaign_id, $action, array $args = array())
|
1287 |
-
{
|
1288 |
-
$resource = sprintf('/campaigns/%s/actions/%s', $campaign_id, $action);
|
1289 |
-
return $this->client->post($resource, $args);
|
1290 |
-
}
|
1291 |
-
|
1292 |
-
/**
|
1293 |
-
* Get the HTML and plain-text content for a campaign
|
1294 |
-
*
|
1295 |
-
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/content/#read-get_campaigns_campaign_id_content
|
1296 |
-
* @param string $campaign_id
|
1297 |
-
* @param array $args
|
1298 |
-
* @return object
|
1299 |
-
* @throws MC4WP_API_Exception
|
1300 |
-
*/
|
1301 |
-
public function get_campaign_content($campaign_id, array $args = array())
|
1302 |
-
{
|
1303 |
-
$resource = sprintf('/campaigns/%s/content', $campaign_id);
|
1304 |
-
return $this->client->get($resource, $args);
|
1305 |
-
}
|
1306 |
-
|
1307 |
-
/**
|
1308 |
-
* Set the content for a campaign
|
1309 |
-
*
|
1310 |
-
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/content/#edit-put_campaigns_campaign_id_content
|
1311 |
-
* @param string $campaign_id
|
1312 |
-
* @param array $args
|
1313 |
-
* @return object
|
1314 |
-
* @throws MC4WP_API_Exception
|
1315 |
-
*/
|
1316 |
-
public function update_campaign_content($campaign_id, array $args)
|
1317 |
-
{
|
1318 |
-
$resource = sprintf('/campaigns/%s/content', $campaign_id);
|
1319 |
-
return $this->client->put($resource, $args);
|
1320 |
-
}
|
1321 |
-
|
1322 |
-
/**
|
1323 |
-
* @return string
|
1324 |
-
*/
|
1325 |
-
public function get_last_response_body()
|
1326 |
-
{
|
1327 |
-
return $this->client->get_last_response_body();
|
1328 |
-
}
|
1329 |
-
|
1330 |
-
/**
|
1331 |
-
* @return array
|
1332 |
-
*/
|
1333 |
-
public function get_last_response_headers()
|
1334 |
-
{
|
1335 |
-
return $this->client->get_last_response_headers();
|
1336 |
-
}
|
1337 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Class MC4WP_API_V3
|
5 |
*/
|
6 |
+
class MC4WP_API_V3 {
|
7 |
+
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @var MC4WP_API_V3_Client
|
11 |
+
*/
|
12 |
+
protected $client;
|
13 |
+
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Constructor
|
17 |
+
*
|
18 |
+
* @param string $api_key
|
19 |
+
*/
|
20 |
+
public function __construct( $api_key ) {
|
21 |
+
$this->client = new MC4WP_API_V3_Client( $api_key );
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Gets the API client to perform raw API calls.
|
26 |
+
*
|
27 |
+
* @return MC4WP_API_V3_Client
|
28 |
+
*/
|
29 |
+
public function get_client() {
|
30 |
+
return $this->client;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Pings the Mailchimp API to see if we're connected
|
35 |
+
*
|
36 |
+
* @return boolean
|
37 |
+
* @throws MC4WP_API_Exception
|
38 |
+
*/
|
39 |
+
public function is_connected() {
|
40 |
+
$data = $this->client->get( '/', array( 'fields' => 'account_id' ) );
|
41 |
+
$connected = is_object( $data ) && isset( $data->account_id );
|
42 |
+
return $connected;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @param $email_address
|
47 |
+
*
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
public function get_subscriber_hash( $email_address ) {
|
51 |
+
return md5( strtolower( trim( $email_address ) ) );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Get recent daily, aggregated activity stats for a list.
|
56 |
+
*
|
57 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/activity/#read-get_lists_list_id_activity
|
58 |
+
*
|
59 |
+
* @param string $list_id
|
60 |
+
* @param array $args
|
61 |
+
*
|
62 |
+
* @return array
|
63 |
+
* @throws MC4WP_API_Exception
|
64 |
+
*/
|
65 |
+
public function get_list_activity( $list_id, array $args = array() ) {
|
66 |
+
$resource = sprintf( '/lists/%s/activity', $list_id );
|
67 |
+
$data = $this->client->get( $resource, $args );
|
68 |
+
|
69 |
+
if ( is_object( $data ) && isset( $data->activity ) ) {
|
70 |
+
return $data->activity;
|
71 |
+
}
|
72 |
+
|
73 |
+
return array();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Gets the interest categories for a given List
|
78 |
+
*
|
79 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/interest-categories/#read-get_lists_list_id_interest_categories
|
80 |
+
*
|
81 |
+
* @param string $list_id
|
82 |
+
* @param array $args
|
83 |
+
*
|
84 |
+
* @return array
|
85 |
+
* @throws MC4WP_API_Exception
|
86 |
+
*/
|
87 |
+
public function get_list_interest_categories( $list_id, array $args = array() ) {
|
88 |
+
$resource = sprintf( '/lists/%s/interest-categories', $list_id );
|
89 |
+
$data = $this->client->get( $resource, $args );
|
90 |
+
|
91 |
+
if ( is_object( $data ) && isset( $data->categories ) ) {
|
92 |
+
return $data->categories;
|
93 |
+
}
|
94 |
+
|
95 |
+
return array();
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/interest-categories/interests/#read-get_lists_list_id_interest_categories_interest_category_id_interests
|
100 |
+
*
|
101 |
+
* @param string $list_id
|
102 |
+
* @param string $interest_category_id
|
103 |
+
* @param array $args
|
104 |
+
*
|
105 |
+
* @return array
|
106 |
+
* @throws MC4WP_API_Exception
|
107 |
+
*/
|
108 |
+
public function get_list_interest_category_interests( $list_id, $interest_category_id, array $args = array() ) {
|
109 |
+
$resource = sprintf( '/lists/%s/interest-categories/%s/interests', $list_id, $interest_category_id );
|
110 |
+
$data = $this->client->get( $resource, $args );
|
111 |
+
|
112 |
+
if ( is_object( $data ) && isset( $data->interests ) ) {
|
113 |
+
return $data->interests;
|
114 |
+
}
|
115 |
+
|
116 |
+
return array();
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get merge vars for a given list
|
121 |
+
*
|
122 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/merge-fields/#read-get_lists_list_id_merge_fields
|
123 |
+
*
|
124 |
+
* @param string $list_id
|
125 |
+
* @param array $args
|
126 |
+
*
|
127 |
+
* @return array
|
128 |
+
* @throws MC4WP_API_Exception
|
129 |
+
*/
|
130 |
+
public function get_list_merge_fields( $list_id, array $args = array() ) {
|
131 |
+
$resource = sprintf( '/lists/%s/merge-fields', $list_id );
|
132 |
+
$data = $this->client->get( $resource, $args );
|
133 |
+
|
134 |
+
if ( is_object( $data ) && isset( $data->merge_fields ) ) {
|
135 |
+
return $data->merge_fields;
|
136 |
+
}
|
137 |
+
|
138 |
+
return array();
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists_list_id
|
143 |
+
*
|
144 |
+
* @param string $list_id
|
145 |
+
* @param array $args
|
146 |
+
*
|
147 |
+
* @return object
|
148 |
+
* @throws MC4WP_API_Exception
|
149 |
+
*/
|
150 |
+
public function get_list( $list_id, array $args = array() ) {
|
151 |
+
$resource = sprintf( '/lists/%s', $list_id );
|
152 |
+
$data = $this->client->get( $resource, $args );
|
153 |
+
return $data;
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists
|
158 |
+
*
|
159 |
+
* @param array $args
|
160 |
+
*
|
161 |
+
* @return array
|
162 |
+
* @throws MC4WP_API_Exception
|
163 |
+
*/
|
164 |
+
public function get_lists( array $args = array() ) {
|
165 |
+
$resource = '/lists';
|
166 |
+
$data = $this->client->get( $resource, $args );
|
167 |
+
|
168 |
+
if ( is_object( $data ) && isset( $data->lists ) ) {
|
169 |
+
return $data->lists;
|
170 |
+
}
|
171 |
+
|
172 |
+
return array();
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/
|
177 |
+
*
|
178 |
+
* @param string $list_id
|
179 |
+
* @param string $email_address
|
180 |
+
* @param array $args
|
181 |
+
*
|
182 |
+
* @return object
|
183 |
+
* @throws MC4WP_API_Exception
|
184 |
+
*/
|
185 |
+
public function get_list_member( $list_id, $email_address, array $args = array() ) {
|
186 |
+
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
187 |
+
$resource = sprintf( '/lists/%s/members/%s', $list_id, $subscriber_hash );
|
188 |
+
$data = $this->client->get( $resource, $args );
|
189 |
+
return $data;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Batch subscribe / unsubscribe list members.
|
194 |
+
*
|
195 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/#create-post_lists_list_id
|
196 |
+
*
|
197 |
+
* @param string $list_id
|
198 |
+
* @param array $args
|
199 |
+
* @return object
|
200 |
+
* @throws MC4WP_API_Exception
|
201 |
+
*/
|
202 |
+
public function add_list_members( $list_id, array $args ) {
|
203 |
+
$resource = sprintf( '/lists/%s', $list_id );
|
204 |
+
return $this->client->post( $resource, $args );
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Add a new member to a Mailchimp list.
|
209 |
+
*
|
210 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#create-post_lists_list_id_members
|
211 |
+
*
|
212 |
+
* @param string $list_id
|
213 |
+
* @param array $args
|
214 |
+
*
|
215 |
+
* @return object
|
216 |
+
* @throws MC4WP_API_Exception
|
217 |
+
*/
|
218 |
+
public function add_new_list_member( $list_id, array $args ) {
|
219 |
+
$resource = sprintf( '/lists/%s/members', $list_id );
|
220 |
+
|
221 |
+
// make sure we're sending an object as the Mailchimp schema requires this
|
222 |
+
if ( isset( $args['merge_fields'] ) ) {
|
223 |
+
$args['merge_fields'] = (object) $args['merge_fields'];
|
224 |
+
}
|
225 |
+
|
226 |
+
if ( isset( $args['interests'] ) ) {
|
227 |
+
$args['interests'] = (object) $args['interests'];
|
228 |
+
}
|
229 |
+
|
230 |
+
// "put" updates the member if it's already on the list... take notice
|
231 |
+
$data = $this->client->post( $resource, $args );
|
232 |
+
return $data;
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Add or update (!) a member to a Mailchimp list.
|
237 |
+
*
|
238 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#create-post_lists_list_id_members
|
239 |
+
*
|
240 |
+
* @param string $list_id
|
241 |
+
* @param array $args
|
242 |
+
*
|
243 |
+
* @return object
|
244 |
+
* @throws MC4WP_API_Exception
|
245 |
+
*/
|
246 |
+
public function add_list_member( $list_id, array $args ) {
|
247 |
+
$subscriber_hash = $this->get_subscriber_hash( $args['email_address'] );
|
248 |
+
$resource = sprintf( '/lists/%s/members/%s', $list_id, $subscriber_hash );
|
249 |
+
|
250 |
+
// make sure we're sending an object as the Mailchimp schema requires this
|
251 |
+
if ( isset( $args['merge_fields'] ) ) {
|
252 |
+
$args['merge_fields'] = (object) $args['merge_fields'];
|
253 |
+
}
|
254 |
+
|
255 |
+
if ( isset( $args['interests'] ) ) {
|
256 |
+
$args['interests'] = (object) $args['interests'];
|
257 |
+
}
|
258 |
+
|
259 |
+
// "put" updates the member if it's already on the list... take notice
|
260 |
+
$data = $this->client->put( $resource, $args );
|
261 |
+
return $data;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#edit-patch_lists_list_id_members_subscriber_hash
|
266 |
+
*
|
267 |
+
* @param $list_id
|
268 |
+
* @param $email_address
|
269 |
+
* @param array $args
|
270 |
+
*
|
271 |
+
* @return object
|
272 |
+
* @throws MC4WP_API_Exception
|
273 |
+
*/
|
274 |
+
public function update_list_member( $list_id, $email_address, array $args ) {
|
275 |
+
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
276 |
+
$resource = sprintf( '/lists/%s/members/%s', $list_id, $subscriber_hash );
|
277 |
+
|
278 |
+
// make sure we're sending an object as the Mailchimp schema requires this
|
279 |
+
if ( isset( $args['merge_fields'] ) ) {
|
280 |
+
$args['merge_fields'] = (object) $args['merge_fields'];
|
281 |
+
}
|
282 |
+
|
283 |
+
if ( isset( $args['interests'] ) ) {
|
284 |
+
$args['interests'] = (object) $args['interests'];
|
285 |
+
}
|
286 |
+
|
287 |
+
$data = $this->client->patch( $resource, $args );
|
288 |
+
return $data;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/
|
293 |
+
*
|
294 |
+
* @param string $list_id
|
295 |
+
* @param string $email_address
|
296 |
+
*
|
297 |
+
* @return bool
|
298 |
+
* @throws MC4WP_API_Exception
|
299 |
+
*/
|
300 |
+
public function delete_list_member( $list_id, $email_address ) {
|
301 |
+
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
302 |
+
$resource = sprintf( '/lists/%s/members/%s', $list_id, $subscriber_hash );
|
303 |
+
$data = $this->client->delete( $resource );
|
304 |
+
return ! ! $data;
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Get the tags on a list member.
|
309 |
+
*
|
310 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/tags/#create-post_lists_list_id_members_subscriber_hash_tags
|
311 |
+
* @param string $list_id
|
312 |
+
* @param string $email_address
|
313 |
+
* @return object
|
314 |
+
* @throws MC4WP_API_Exception
|
315 |
+
*/
|
316 |
+
public function get_list_member_tags( $list_id, $email_address ) {
|
317 |
+
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
318 |
+
$resource = sprintf( '/lists/%s/members/%s/tags', $list_id, $subscriber_hash );
|
319 |
+
return $this->client->get( $resource );
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Add or remove tags from a list member. If a tag that does not exist is passed in and set as ‘active’, a new tag will be created.
|
324 |
+
*
|
325 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/tags/#read-get_lists_list_id_members_subscriber_hash_tags
|
326 |
+
* @param string $list_id
|
327 |
+
* @param string $email_address
|
328 |
+
* @param array $data
|
329 |
+
* @return object
|
330 |
+
* @throws MC4WP_API_Exception
|
331 |
+
*/
|
332 |
+
public function update_list_member_tags( $list_id, $email_address, array $data ) {
|
333 |
+
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
334 |
+
$resource = sprintf( '/lists/%s/members/%s/tags', $list_id, $subscriber_hash );
|
335 |
+
return $this->client->post( $resource, $data );
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Get information about all available segments for a specific list.
|
340 |
+
*
|
341 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/segments/#read-get_lists_list_id_segments
|
342 |
+
* @param string $list_id
|
343 |
+
* @param array $args
|
344 |
+
* @return object
|
345 |
+
* @throws MC4WP_API_Exception
|
346 |
+
*/
|
347 |
+
public function get_list_segments( $list_id, array $args = array() ) {
|
348 |
+
$resource = sprintf( '/lists/%s/segments', $list_id );
|
349 |
+
return $this->client->get( $resource, $args );
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/#read-get_ecommerce_stores
|
354 |
+
*
|
355 |
+
* @param array $args
|
356 |
+
*
|
357 |
+
* @return object
|
358 |
+
* @throws MC4WP_API_Exception
|
359 |
+
*/
|
360 |
+
public function get_ecommerce_stores( array $args = array() ) {
|
361 |
+
$resource = '/ecommerce/stores';
|
362 |
+
return $this->client->get( $resource, $args );
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/#read-get_ecommerce_stores_store_id
|
367 |
+
*
|
368 |
+
* @param string $store_id
|
369 |
+
* @param array $args
|
370 |
+
*
|
371 |
+
* @return object
|
372 |
+
* @throws MC4WP_API_Exception
|
373 |
+
*/
|
374 |
+
public function get_ecommerce_store( $store_id, array $args = array() ) {
|
375 |
+
$resource = sprintf( '/ecommerce/stores/%s', $store_id );
|
376 |
+
return $this->client->get( $resource, $args );
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/#create-post_ecommerce_stores
|
381 |
+
*
|
382 |
+
* @param array $args
|
383 |
+
*
|
384 |
+
* @return object
|
385 |
+
* @throws MC4WP_API_Exception
|
386 |
+
*/
|
387 |
+
public function add_ecommerce_store( array $args ) {
|
388 |
+
$resource = '/ecommerce/stores';
|
389 |
+
return $this->client->post( $resource, $args );
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/#edit-patch_ecommerce_stores_store_id
|
394 |
+
*
|
395 |
+
* @param string $store_id
|
396 |
+
* @param array $args
|
397 |
+
*
|
398 |
+
* @return object
|
399 |
+
* @throws MC4WP_API_Exception
|
400 |
+
*/
|
401 |
+
public function update_ecommerce_store( $store_id, array $args ) {
|
402 |
+
$resource = sprintf( '/ecommerce/stores/%s', $store_id );
|
403 |
+
return $this->client->patch( $resource, $args );
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/#delete-delete_ecommerce_stores_store_id
|
408 |
+
*
|
409 |
+
* @param string $store_id
|
410 |
+
*
|
411 |
+
* @return boolean
|
412 |
+
* @throws MC4WP_API_Exception
|
413 |
+
*/
|
414 |
+
public function delete_ecommerce_store( $store_id ) {
|
415 |
+
$resource = sprintf( '/ecommerce/stores/%s', $store_id );
|
416 |
+
return ! ! $this->client->delete( $resource );
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/customers/#read-get_ecommerce_stores_store_id_customers
|
421 |
+
*
|
422 |
+
* @param string $store_id
|
423 |
+
* @param array $args
|
424 |
+
*
|
425 |
+
* @return object
|
426 |
+
* @throws MC4WP_API_Exception
|
427 |
+
*/
|
428 |
+
public function get_ecommerce_store_customers( $store_id, array $args = array() ) {
|
429 |
+
$resource = sprintf( '/ecommerce/stores/%s/customers', $store_id );
|
430 |
+
return $this->client->get( $resource, $args );
|
431 |
+
}
|
432 |
+
|
433 |
+
/**
|
434 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/customers/#read-get_ecommerce_stores_store_id_customers_customer_id
|
435 |
+
*
|
436 |
+
* @param string $store_id
|
437 |
+
* @param string $customer_id
|
438 |
+
* @param array $args
|
439 |
+
*
|
440 |
+
* @return object
|
441 |
+
* @throws MC4WP_API_Exception
|
442 |
+
*/
|
443 |
+
public function get_ecommerce_store_customer( $store_id, $customer_id, array $args = array() ) {
|
444 |
+
$resource = sprintf( '/ecommerce/stores/%s/customers/%s', $store_id, $customer_id );
|
445 |
+
return $this->client->get( $resource, $args );
|
446 |
+
}
|
447 |
+
|
448 |
+
/**
|
449 |
+
* Add OR update a store customer
|
450 |
+
*
|
451 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/customers/#edit-put_ecommerce_stores_store_id_customers_customer_id
|
452 |
+
*
|
453 |
+
* @param $store_id
|
454 |
+
* @param array $args
|
455 |
+
*
|
456 |
+
* @return object
|
457 |
+
* @throws MC4WP_API_Exception
|
458 |
+
*/
|
459 |
+
public function add_ecommerce_store_customer( $store_id, array $args ) {
|
460 |
+
$resource = sprintf( '/ecommerce/stores/%s/customers/%s', $store_id, $args['id'] );
|
461 |
+
return $this->client->put( $resource, $args );
|
462 |
+
}
|
463 |
+
|
464 |
+
/**
|
465 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/customers/#edit-patch_ecommerce_stores_store_id_customers_customer_id
|
466 |
+
*
|
467 |
+
* @param string $store_id
|
468 |
+
* @param string $customer_id
|
469 |
+
* @param array $args
|
470 |
+
*
|
471 |
+
* @return object
|
472 |
+
* @throws MC4WP_API_Exception
|
473 |
+
*/
|
474 |
+
public function update_ecommerce_store_customer( $store_id, $customer_id, array $args ) {
|
475 |
+
$resource = sprintf( '/ecommerce/stores/%s/customers/%s', $store_id, $customer_id );
|
476 |
+
return $this->client->patch( $resource, $args );
|
477 |
+
}
|
478 |
+
|
479 |
+
/**
|
480 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/customers/#delete-delete_ecommerce_stores_store_id_customers_customer_id
|
481 |
+
*
|
482 |
+
* @param string $store_id
|
483 |
+
* @param string $customer_id
|
484 |
+
*
|
485 |
+
* @return bool
|
486 |
+
* @throws MC4WP_API_Exception
|
487 |
+
*/
|
488 |
+
public function delete_ecommerce_store_customer( $store_id, $customer_id ) {
|
489 |
+
$resource = sprintf( '/ecommerce/stores/%s/customers/%s', $store_id, $customer_id );
|
490 |
+
return ! ! $this->client->delete( $resource );
|
491 |
+
}
|
492 |
+
|
493 |
+
/**
|
494 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/#read-get_ecommerce_stores_store_id_products
|
495 |
+
*
|
496 |
+
* @param string $store_id
|
497 |
+
* @param array $args
|
498 |
+
*
|
499 |
+
* @return object
|
500 |
+
* @throws MC4WP_API_Exception
|
501 |
+
*/
|
502 |
+
public function get_ecommerce_store_products( $store_id, array $args = array() ) {
|
503 |
+
$resource = sprintf( '/ecommerce/stores/%s/products', $store_id );
|
504 |
+
return $this->client->get( $resource, $args );
|
505 |
+
}
|
506 |
+
|
507 |
+
/**
|
508 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/#read-get_ecommerce_stores_store_id_products_product_id
|
509 |
+
*
|
510 |
+
* @param string $store_id
|
511 |
+
* @param string $product_id
|
512 |
+
* @param array $args
|
513 |
+
*
|
514 |
+
* @return object
|
515 |
+
* @throws MC4WP_API_Exception
|
516 |
+
*/
|
517 |
+
public function get_ecommerce_store_product( $store_id, $product_id, array $args = array() ) {
|
518 |
+
$resource = sprintf( '/ecommerce/stores/%s/products/%s', $store_id, $product_id );
|
519 |
+
return $this->client->get( $resource, $args );
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Add a product to a store
|
524 |
+
*
|
525 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/#create-post_ecommerce_stores_store_id_products
|
526 |
+
*
|
527 |
+
* @param string $store_id
|
528 |
+
* @param array $args
|
529 |
+
*
|
530 |
+
* @return object
|
531 |
+
* @throws MC4WP_API_Exception
|
532 |
+
*/
|
533 |
+
public function add_ecommerce_store_product( $store_id, array $args ) {
|
534 |
+
$resource = sprintf( '/ecommerce/stores/%s/products', $store_id );
|
535 |
+
return $this->client->post( $resource, $args );
|
536 |
+
}
|
537 |
+
|
538 |
+
/**
|
539 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/#edit-patch_ecommerce_stores_store_id_products_product_id
|
540 |
+
*
|
541 |
+
* @param string $store_id
|
542 |
+
* @param string $product_id
|
543 |
+
* @param array $args
|
544 |
+
*
|
545 |
+
* @return object
|
546 |
+
* @throws MC4WP_API_Exception
|
547 |
+
*/
|
548 |
+
public function update_ecommerce_store_product( $store_id, $product_id, array $args ) {
|
549 |
+
$resource = sprintf( '/ecommerce/stores/%s/products/%s', $store_id, $product_id );
|
550 |
+
return $this->client->patch( $resource, $args );
|
551 |
+
}
|
552 |
+
|
553 |
+
/**
|
554 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/#delete-delete_ecommerce_stores_store_id_products_product_id
|
555 |
+
*
|
556 |
+
* @param string $store_id
|
557 |
+
* @param string $product_id
|
558 |
+
*
|
559 |
+
* @return boolean
|
560 |
+
* @throws MC4WP_API_Exception
|
561 |
+
*/
|
562 |
+
public function delete_ecommerce_store_product( $store_id, $product_id ) {
|
563 |
+
$resource = sprintf( '/ecommerce/stores/%s/products/%s', $store_id, $product_id );
|
564 |
+
return ! ! $this->client->delete( $resource );
|
565 |
+
}
|
566 |
+
|
567 |
+
/**
|
568 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/variants/#read-get_ecommerce_stores_store_id_products_product_id_variants
|
569 |
+
*
|
570 |
+
* @param string $store_id
|
571 |
+
* @param string $product_id
|
572 |
+
* @param array $args
|
573 |
+
*
|
574 |
+
* @return object
|
575 |
+
* @throws MC4WP_API_Exception
|
576 |
+
*/
|
577 |
+
public function get_ecommerce_store_product_variants( $store_id, $product_id, array $args = array() ) {
|
578 |
+
$resource = sprintf( '/ecommerce/stores/%s/products/%s/variants', $store_id, $product_id );
|
579 |
+
return $this->client->get( $resource, $args );
|
580 |
+
}
|
581 |
+
|
582 |
+
/**
|
583 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/variants/#read-get_ecommerce_stores_store_id_products_product_id_variants_variant_id
|
584 |
+
*
|
585 |
+
* @param string $store_id
|
586 |
+
* @param string $product_id
|
587 |
+
* @param string $variant_id
|
588 |
+
* @param array $args
|
589 |
+
*
|
590 |
+
* @return object
|
591 |
+
* @throws MC4WP_API_Exception
|
592 |
+
*/
|
593 |
+
public function get_ecommerce_store_product_variant( $store_id, $product_id, $variant_id, array $args = array() ) {
|
594 |
+
$resource = sprintf( '/ecommerce/stores/%s/products/%s/variants/%s', $store_id, $product_id, $variant_id );
|
595 |
+
return $this->client->get( $resource, $args );
|
596 |
+
}
|
597 |
+
|
598 |
+
/**
|
599 |
+
* Add OR update a product variant.
|
600 |
+
*
|
601 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/variants/#edit-put_ecommerce_stores_store_id_products_product_id_variants_variant_id
|
602 |
+
*
|
603 |
+
* @param string $store_id
|
604 |
+
* @param string $product_id
|
605 |
+
* @param array $args
|
606 |
+
*
|
607 |
+
* @return object
|
608 |
+
* @throws MC4WP_API_Exception
|
609 |
+
*/
|
610 |
+
public function add_ecommerce_store_product_variant( $store_id, $product_id, array $args ) {
|
611 |
+
$resource = sprintf( '/ecommerce/stores/%s/products/%s/variants/%s', $store_id, $product_id, $args['id'] );
|
612 |
+
return $this->client->put( $resource, $args );
|
613 |
+
}
|
614 |
+
|
615 |
+
/**
|
616 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/variants/#edit-patch_ecommerce_stores_store_id_products_product_id_variants_variant_id
|
617 |
+
*
|
618 |
+
* @param string $store_id
|
619 |
+
* @param string $product_id
|
620 |
+
* @param string $variant_id
|
621 |
+
* @param array $args
|
622 |
+
*
|
623 |
+
* @return object
|
624 |
+
* @throws MC4WP_API_Exception
|
625 |
+
*/
|
626 |
+
public function update_ecommerce_store_product_variant( $store_id, $product_id, $variant_id, array $args ) {
|
627 |
+
$resource = sprintf( '/ecommerce/stores/%s/products/%s/variants/%s', $store_id, $product_id, $variant_id );
|
628 |
+
return $this->client->patch( $resource, $args );
|
629 |
+
}
|
630 |
+
|
631 |
+
/**
|
632 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/variants/#delete-delete_ecommerce_stores_store_id_products_product_id_variants_variant_id
|
633 |
+
*
|
634 |
+
* @param string $store_id
|
635 |
+
* @param string $product_id
|
636 |
+
* @param string $variant_id
|
637 |
+
*
|
638 |
+
* @return boolean
|
639 |
+
* @throws MC4WP_API_Exception
|
640 |
+
*/
|
641 |
+
public function delete_ecommerce_store_product_variant( $store_id, $product_id, $variant_id ) {
|
642 |
+
$resource = sprintf( '/ecommerce/stores/%s/products/%s/variants/%s', $store_id, $product_id, $variant_id );
|
643 |
+
return ! ! $this->client->delete( $resource );
|
644 |
+
}
|
645 |
+
|
646 |
+
/**
|
647 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/#read-get_ecommerce_stores_store_id_orders
|
648 |
+
*
|
649 |
+
* @param string $store_id
|
650 |
+
* @param array $args
|
651 |
+
*
|
652 |
+
* @return object
|
653 |
+
* @throws MC4WP_API_Exception
|
654 |
+
*/
|
655 |
+
public function get_ecommerce_store_orders( $store_id, array $args = array() ) {
|
656 |
+
$resource = sprintf( '/ecommerce/stores/%s/orders', $store_id );
|
657 |
+
return $this->client->get( $resource, $args );
|
658 |
+
}
|
659 |
+
|
660 |
+
/**
|
661 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/#read-get_ecommerce_stores_store_id_orders_order_id
|
662 |
+
*
|
663 |
+
* @param string $store_id
|
664 |
+
* @param string $order_id
|
665 |
+
* @param array $args
|
666 |
+
*
|
667 |
+
* @return object
|
668 |
+
* @throws MC4WP_API_Exception
|
669 |
+
*/
|
670 |
+
public function get_ecommerce_store_order( $store_id, $order_id, array $args = array() ) {
|
671 |
+
$resource = sprintf( '/ecommerce/stores/%s/orders/%s', $store_id, $order_id );
|
672 |
+
return $this->client->get( $resource, $args );
|
673 |
+
}
|
674 |
+
|
675 |
+
/**
|
676 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/#create-post_ecommerce_stores_store_id_orders
|
677 |
+
*
|
678 |
+
* @param string $store_id
|
679 |
+
* @param array $args
|
680 |
+
*
|
681 |
+
* @return object
|
682 |
+
* @throws MC4WP_API_Exception
|
683 |
+
*/
|
684 |
+
public function add_ecommerce_store_order( $store_id, array $args ) {
|
685 |
+
$resource = sprintf( '/ecommerce/stores/%s/orders', $store_id );
|
686 |
+
return $this->client->post( $resource, $args );
|
687 |
+
}
|
688 |
+
|
689 |
+
/**
|
690 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/#edit-patch_ecommerce_stores_store_id_orders_order_id
|
691 |
+
*
|
692 |
+
* @param string $store_id
|
693 |
+
* @param string $order_id
|
694 |
+
* @param array $args
|
695 |
+
*
|
696 |
+
* @return object
|
697 |
+
* @throws MC4WP_API_Exception
|
698 |
+
*/
|
699 |
+
public function update_ecommerce_store_order( $store_id, $order_id, array $args ) {
|
700 |
+
$resource = sprintf( '/ecommerce/stores/%s/orders/%s', $store_id, $order_id );
|
701 |
+
return $this->client->patch( $resource, $args );
|
702 |
+
}
|
703 |
+
|
704 |
+
/**
|
705 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/#delete-delete_ecommerce_stores_store_id_orders_order_id
|
706 |
+
*
|
707 |
+
* @param string $store_id
|
708 |
+
* @param string $order_id
|
709 |
+
*
|
710 |
+
* @return bool
|
711 |
+
* @throws MC4WP_API_Exception
|
712 |
+
*/
|
713 |
+
public function delete_ecommerce_store_order( $store_id, $order_id ) {
|
714 |
+
return ! ! $this->client->delete( sprintf( '/ecommerce/stores/%s/orders/%s', $store_id, $order_id ) );
|
715 |
+
}
|
716 |
+
|
717 |
+
/**
|
718 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/lines/#create-post_ecommerce_stores_store_id_orders_order_id_lines
|
719 |
+
*
|
720 |
+
* @param string $store_id
|
721 |
+
* @param string $order_id
|
722 |
+
* @param array $args
|
723 |
+
*
|
724 |
+
* @return object
|
725 |
+
* @throws MC4WP_API_Exception
|
726 |
+
*/
|
727 |
+
public function add_ecommerce_store_order_line( $store_id, $order_id, array $args ) {
|
728 |
+
$resource = sprintf( '/ecommerce/stores/%s/orders/%s/lines', $store_id, $order_id );
|
729 |
+
return $this->client->post( $resource, $args );
|
730 |
+
}
|
731 |
+
|
732 |
+
|
733 |
+
/**
|
734 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/lines/#read-get_ecommerce_stores_store_id_orders_order_id_lines
|
735 |
+
*
|
736 |
+
* @param string $store_id
|
737 |
+
* @param string $order_id
|
738 |
+
* @param array $args
|
739 |
+
*
|
740 |
+
* @return object
|
741 |
+
* @throws MC4WP_API_Exception
|
742 |
+
*/
|
743 |
+
public function get_ecommerce_store_order_lines( $store_id, $order_id, array $args = array() ) {
|
744 |
+
$resource = sprintf( '/ecommerce/stores/%s/orders/%s/lines', $store_id, $order_id );
|
745 |
+
return $this->client->get( $resource, $args );
|
746 |
+
}
|
747 |
+
|
748 |
+
/**
|
749 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/lines/#read-get_ecommerce_stores_store_id_orders_order_id_lines_line_id
|
750 |
+
*
|
751 |
+
* @param string $store_id
|
752 |
+
* @param string $order_id
|
753 |
+
* @param string $line_id
|
754 |
+
* @param array $args
|
755 |
+
*
|
756 |
+
* @return object
|
757 |
+
* @throws MC4WP_API_Exception
|
758 |
+
*/
|
759 |
+
public function get_ecommerce_store_order_line( $store_id, $order_id, $line_id, array $args = array() ) {
|
760 |
+
$resource = sprintf( '/ecommerce/stores/%s/orders/%s/lines/%s', $store_id, $order_id, $line_id );
|
761 |
+
return $this->client->get( $resource, $args );
|
762 |
+
}
|
763 |
+
|
764 |
+
/**
|
765 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/lines/#edit-patch_ecommerce_stores_store_id_orders_order_id_lines_line_id
|
766 |
+
*
|
767 |
+
* @param string $store_id
|
768 |
+
* @param string $order_id
|
769 |
+
* @param string $line_id
|
770 |
+
* @param array $args
|
771 |
+
*
|
772 |
+
* @return object
|
773 |
+
* @throws MC4WP_API_Exception
|
774 |
+
*/
|
775 |
+
public function update_ecommerce_store_order_line( $store_id, $order_id, $line_id, array $args ) {
|
776 |
+
$resource = sprintf( '/ecommerce/stores/%s/orders/%s/lines/%s', $store_id, $order_id, $line_id );
|
777 |
+
return $this->client->patch( $resource, $args );
|
778 |
+
}
|
779 |
+
|
780 |
+
/**
|
781 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/lines/#delete-delete_ecommerce_stores_store_id_orders_order_id_lines_line_id
|
782 |
+
*
|
783 |
+
* @param string $store_id
|
784 |
+
* @param string $order_id
|
785 |
+
* @param string $line_id
|
786 |
+
*
|
787 |
+
* @return bool
|
788 |
+
* @throws MC4WP_API_Exception
|
789 |
+
*/
|
790 |
+
public function delete_ecommerce_store_order_line( $store_id, $order_id, $line_id ) {
|
791 |
+
$resource = sprintf( '/ecommerce/stores/%s/orders/%s/lines/%s', $store_id, $order_id, $line_id );
|
792 |
+
return ! ! $this->client->delete( $resource );
|
793 |
+
}
|
794 |
+
|
795 |
+
/**
|
796 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/#read-get_ecommerce_stores_store_id_carts
|
797 |
+
*
|
798 |
+
* @param string $store_id
|
799 |
+
* @param array $args
|
800 |
+
*
|
801 |
+
* @return object
|
802 |
+
* @throws MC4WP_API_Exception
|
803 |
+
*/
|
804 |
+
public function get_ecommerce_store_carts( $store_id, array $args = array() ) {
|
805 |
+
$resource = sprintf( '/ecommerce/stores/%s/carts', $store_id );
|
806 |
+
return $this->client->get( $resource, $args );
|
807 |
+
}
|
808 |
+
|
809 |
+
/**
|
810 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/#read-get_ecommerce_stores_store_id_carts_cart_id
|
811 |
+
*
|
812 |
+
* @param string $store_id
|
813 |
+
* @param string $cart_id
|
814 |
+
* @param array $args
|
815 |
+
*
|
816 |
+
* @return object
|
817 |
+
* @throws MC4WP_API_Exception
|
818 |
+
*/
|
819 |
+
public function get_ecommerce_store_cart( $store_id, $cart_id, array $args = array() ) {
|
820 |
+
$resource = sprintf( '/ecommerce/stores/%s/carts/%s', $store_id, $cart_id );
|
821 |
+
return $this->client->get( $resource, $args );
|
822 |
+
}
|
823 |
+
|
824 |
+
/**
|
825 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/#create-post_ecommerce_stores_store_id_carts
|
826 |
+
*
|
827 |
+
* @param string $store_id
|
828 |
+
* @param array $args
|
829 |
+
*
|
830 |
+
* @return object
|
831 |
+
* @throws MC4WP_API_Exception
|
832 |
+
*/
|
833 |
+
public function add_ecommerce_store_cart( $store_id, array $args ) {
|
834 |
+
$resource = sprintf( '/ecommerce/stores/%s/carts', $store_id );
|
835 |
+
return $this->client->post( $resource, $args );
|
836 |
+
}
|
837 |
+
|
838 |
+
/**
|
839 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/#edit-patch_ecommerce_stores_store_id_carts_cart_id
|
840 |
+
*
|
841 |
+
* @param string $store_id
|
842 |
+
* @param string $cart_id
|
843 |
+
* @param array $args
|
844 |
+
*
|
845 |
+
* @return object
|
846 |
+
* @throws MC4WP_API_Exception
|
847 |
+
*/
|
848 |
+
public function update_ecommerce_store_cart( $store_id, $cart_id, array $args ) {
|
849 |
+
$resource = sprintf( '/ecommerce/stores/%s/carts/%s', $store_id, $cart_id );
|
850 |
+
return $this->client->patch( $resource, $args );
|
851 |
+
}
|
852 |
+
|
853 |
+
/**
|
854 |
+
* @link https://mailchimp.com/developer/reference/ecommerce-stores/ecommerce-carts/#delete-delete_ecommerce_stores_store_id_carts_cart_id
|
855 |
+
*
|
856 |
+
* @param string $store_id
|
857 |
+
* @param string $cart_id
|
858 |
+
*
|
859 |
+
* @return bool
|
860 |
+
*/
|
861 |
+
public function delete_ecommerce_store_cart( $store_id, $cart_id ) {
|
862 |
+
return ! ! $this->client->delete( sprintf( '/ecommerce/stores/%s/carts/%s', $store_id, $cart_id ) );
|
863 |
+
}
|
864 |
+
|
865 |
+
/**
|
866 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/lines/#read-get_ecommerce_stores_store_id_carts_cart_id_lines
|
867 |
+
*
|
868 |
+
* @param string $store_id
|
869 |
+
* @param string $cart_id
|
870 |
+
* @param array $args
|
871 |
+
*
|
872 |
+
* @return object
|
873 |
+
* @throws MC4WP_API_Exception
|
874 |
+
*/
|
875 |
+
public function get_ecommerce_store_cart_lines( $store_id, $cart_id, array $args = array() ) {
|
876 |
+
$resource = sprintf( '/ecommerce/stores/%s/carts/%/lines', $store_id, $cart_id );
|
877 |
+
return $this->client->get( $resource, $args );
|
878 |
+
}
|
879 |
+
|
880 |
+
/**
|
881 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/lines/#read-get_ecommerce_stores_store_id_carts_cart_id_lines_line_id
|
882 |
+
*
|
883 |
+
* @param string $store_id
|
884 |
+
* @param string $cart_id
|
885 |
+
* @param string $line_id
|
886 |
+
* @param array $args
|
887 |
+
*
|
888 |
+
* @return object
|
889 |
+
* @throws MC4WP_API_Exception
|
890 |
+
*/
|
891 |
+
public function get_ecommerce_store_cart_line( $store_id, $cart_id, $line_id, array $args = array() ) {
|
892 |
+
$resource = sprintf( '/ecommerce/stores/%s/carts/%s/lines/%s', $store_id, $cart_id, $line_id );
|
893 |
+
return $this->client->get( $resource, $args );
|
894 |
+
}
|
895 |
+
|
896 |
+
/**
|
897 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/lines/#create-post_ecommerce_stores_store_id_carts_cart_id_lines
|
898 |
+
*
|
899 |
+
* @param string $store_id
|
900 |
+
* @param string $cart_id
|
901 |
+
* @param array $args
|
902 |
+
*
|
903 |
+
* @return object
|
904 |
+
* @throws MC4WP_API_Exception
|
905 |
+
*/
|
906 |
+
public function add_ecommerce_store_cart_line( $store_id, $cart_id, array $args ) {
|
907 |
+
$resource = sprintf( '/ecommerce/stores/%s/carts/%s/lines', $store_id, $cart_id );
|
908 |
+
return $this->client->post( $resource, $args );
|
909 |
+
}
|
910 |
+
|
911 |
+
/**
|
912 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/lines/#edit-patch_ecommerce_stores_store_id_carts_cart_id_lines_line_id
|
913 |
+
*
|
914 |
+
* @param string $store_id
|
915 |
+
* @param string $cart_id
|
916 |
+
* @param string $line_id
|
917 |
+
* @param array $args
|
918 |
+
*
|
919 |
+
* @return object
|
920 |
+
* @throws MC4WP_API_Exception
|
921 |
+
*/
|
922 |
+
public function update_ecommerce_store_cart_line( $store_id, $cart_id, $line_id, array $args ) {
|
923 |
+
$resource = sprintf( '/ecommerce/stores/%s/carts/%s/lines/%s', $store_id, $cart_id, $line_id );
|
924 |
+
return $this->client->patch( $resource, $args );
|
925 |
+
}
|
926 |
+
|
927 |
+
/**
|
928 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/lines/#delete-delete_ecommerce_stores_store_id_carts_cart_id_lines_line_id
|
929 |
+
*
|
930 |
+
* @param string $store_id
|
931 |
+
* @param string $cart_id
|
932 |
+
* @param string $line_id
|
933 |
+
*
|
934 |
+
* @return bool
|
935 |
+
* @throws MC4WP_API_Exception
|
936 |
+
*/
|
937 |
+
public function delete_ecommerce_store_cart_line( $store_id, $cart_id, $line_id ) {
|
938 |
+
$resource = sprintf( '/ecommerce/stores/%s/carts/%s/lines/%s', $store_id, $cart_id, $line_id );
|
939 |
+
return ! ! $this->client->delete( $resource );
|
940 |
+
}
|
941 |
+
|
942 |
+
/**
|
943 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/promo-rules/#create-post_ecommerce_stores_store_id_promo_rules
|
944 |
+
*
|
945 |
+
* @param string $store_id
|
946 |
+
* @param array $args
|
947 |
+
*
|
948 |
+
* @return object
|
949 |
+
* @throws MC4WP_API_Exception
|
950 |
+
*/
|
951 |
+
public function add_ecommerce_store_promo_rule( $store_id, array $args ) {
|
952 |
+
$resource = sprintf( '/ecommerce/stores/%s/promo-rules', $store_id );
|
953 |
+
return $this->client->post( $resource, $args );
|
954 |
+
}
|
955 |
+
|
956 |
+
/**
|
957 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/promo-rules/#read-get_ecommerce_stores_store_id_promo_rules
|
958 |
+
*
|
959 |
+
* @param string $store_id
|
960 |
+
* @param array $args
|
961 |
+
*
|
962 |
+
* @return object
|
963 |
+
* @throws MC4WP_API_Exception
|
964 |
+
*/
|
965 |
+
public function get_ecommerce_store_promo_rules( $store_id, array $args = array() ) {
|
966 |
+
$resource = sprintf( '/ecommerce/stores/%s/promo-rules', $store_id );
|
967 |
+
return $this->client->get( $resource, $args );
|
968 |
+
}
|
969 |
+
|
970 |
+
/**
|
971 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/promo-rules/#read-get_ecommerce_stores_store_id_promo_rules_promo_rule_id
|
972 |
+
*
|
973 |
+
* @param string $store_id
|
974 |
+
* @param string $promo_rule_id
|
975 |
+
* @param array $args
|
976 |
+
*
|
977 |
+
* @return object
|
978 |
+
* @throws MC4WP_API_Exception
|
979 |
+
*/
|
980 |
+
public function get_ecommerce_store_promo_rule( $store_id, $promo_rule_id, array $args = array() ) {
|
981 |
+
$resource = sprintf( '/ecommerce/stores/%s/promo-rules/%s', $store_id, $promo_rule_id );
|
982 |
+
return $this->client->get( $resource, $args );
|
983 |
+
}
|
984 |
+
|
985 |
+
/**
|
986 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/promo-rules/#edit-patch_ecommerce_stores_store_id_promo_rules_promo_rule_id
|
987 |
+
*
|
988 |
+
* @param string $store_id
|
989 |
+
* @param string $promo_rule_id
|
990 |
+
* @param array $args
|
991 |
+
*
|
992 |
+
* @return object
|
993 |
+
* @throws MC4WP_API_Exception
|
994 |
+
*/
|
995 |
+
public function update_ecommerce_store_promo_rule( $store_id, $promo_rule_id, array $args ) {
|
996 |
+
$resource = sprintf( '/ecommerce/stores/%s/promo-rules/%s', $store_id, $promo_rule_id );
|
997 |
+
return $this->client->patch( $resource, $args );
|
998 |
+
}
|
999 |
+
|
1000 |
+
/**
|
1001 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/promo-rules/#delete-delete_ecommerce_stores_store_id_promo_rules_promo_rule_id
|
1002 |
+
*
|
1003 |
+
* @param string $store_id
|
1004 |
+
* @param string $promo_rule_id
|
1005 |
+
*
|
1006 |
+
* @return boolean
|
1007 |
+
* @throws MC4WP_API_Exception
|
1008 |
+
*/
|
1009 |
+
public function delete_ecommerce_store_promo_rule( $store_id, $promo_rule_id ) {
|
1010 |
+
$resource = sprintf( '/ecommerce/stores/%s/promo-rules/%s', $store_id, $promo_rule_id );
|
1011 |
+
return ! ! $this->client->delete( $resource );
|
1012 |
+
}
|
1013 |
+
|
1014 |
+
/**
|
1015 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/promo-rules/promo-codes/#create-post_ecommerce_stores_store_id_promo_rules_promo_rule_id_promo_codes
|
1016 |
+
*
|
1017 |
+
* @param string $store_id
|
1018 |
+
* @param string $promo_rule_id
|
1019 |
+
* @param array $args
|
1020 |
+
*
|
1021 |
+
* @return object
|
1022 |
+
* @throws MC4WP_API_Exception
|
1023 |
+
*/
|
1024 |
+
public function add_ecommerce_store_promo_rule_promo_code( $store_id, $promo_rule_id, array $args ) {
|
1025 |
+
$resource = sprintf( '/ecommerce/stores/%s/promo-rules/%s/promo-codes', $store_id, $promo_rule_id );
|
1026 |
+
return $this->client->post( $resource, $args );
|
1027 |
+
}
|
1028 |
+
|
1029 |
+
/**
|
1030 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/promo-rules/promo-codes/#read-get_ecommerce_stores_store_id_promo_rules_promo_rule_id_promo_codes
|
1031 |
+
*
|
1032 |
+
* @param string $store_id
|
1033 |
+
* @param string $promo_rule_id
|
1034 |
+
* @param array $args
|
1035 |
+
*
|
1036 |
+
* @return object
|
1037 |
+
* @throws MC4WP_API_Exception
|
1038 |
+
*/
|
1039 |
+
public function get_ecommerce_store_promo_rule_promo_codes( $store_id, $promo_rule_id, array $args = array() ) {
|
1040 |
+
$resource = sprintf( '/ecommerce/stores/%s/promo-rules/%s/promo-codes', $store_id, $promo_rule_id );
|
1041 |
+
return $this->client->get( $resource, $args );
|
1042 |
+
}
|
1043 |
+
|
1044 |
+
/**
|
1045 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/promo-rules/promo-codes/#read-get_ecommerce_stores_store_id_promo_rules_promo_rule_id_promo_codes_promo_code_id
|
1046 |
+
*
|
1047 |
+
* @param string $store_id
|
1048 |
+
* @param string $promo_rule_id
|
1049 |
+
* @param string $promo_code_id
|
1050 |
+
* @param array $args
|
1051 |
+
*
|
1052 |
+
* @return object
|
1053 |
+
* @throws MC4WP_API_Exception
|
1054 |
+
*/
|
1055 |
+
public function get_ecommerce_store_promo_rule_promo_code( $store_id, $promo_rule_id, $promo_code_id, array $args = array() ) {
|
1056 |
+
$resource = sprintf( '/ecommerce/stores/%s/promo-rules/%s/promo-codes/%s', $store_id, $promo_rule_id, $promo_code_id );
|
1057 |
+
return $this->client->get( $resource, $args );
|
1058 |
+
}
|
1059 |
+
|
1060 |
+
/**
|
1061 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/promo-rules/promo-codes/#edit-patch_ecommerce_stores_store_id_promo_rules_promo_rule_id_promo_codes_promo_code_id
|
1062 |
+
*
|
1063 |
+
* @param string $store_id
|
1064 |
+
* @param string $promo_rule_id
|
1065 |
+
* @param string $promo_code_id
|
1066 |
+
* @param array $args
|
1067 |
+
*
|
1068 |
+
* @return object
|
1069 |
+
* @throws MC4WP_API_Exception
|
1070 |
+
*/
|
1071 |
+
public function update_ecommerce_store_promo_rule_promo_code( $store_id, $promo_rule_id, $promo_code_id, array $args ) {
|
1072 |
+
$resource = sprintf( '/ecommerce/stores/%s/promo-rules/%s/promo-codes/%s', $store_id, $promo_rule_id, $promo_code_id );
|
1073 |
+
return $this->client->patch( $resource, $args );
|
1074 |
+
}
|
1075 |
+
|
1076 |
+
/**
|
1077 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/promo-rules/promo-codes/#delete-delete_ecommerce_stores_store_id_promo_rules_promo_rule_id_promo_codes_promo_code_id
|
1078 |
+
*
|
1079 |
+
* @param string $store_id
|
1080 |
+
* @param string $promo_rule_id
|
1081 |
+
* @param string $promo_code_id
|
1082 |
+
*
|
1083 |
+
* @return boolean
|
1084 |
+
* @throws MC4WP_API_Exception
|
1085 |
+
*/
|
1086 |
+
public function delete_ecommerce_store_promo_rule_promo_code( $store_id, $promo_rule_id, $promo_code_id ) {
|
1087 |
+
$resource = sprintf( '/ecommerce/stores/%s/promo-rules/%s/promo-codes/%s', $store_id, $promo_rule_id, $promo_code_id );
|
1088 |
+
return ! ! $this->client->delete( $resource );
|
1089 |
+
}
|
1090 |
+
|
1091 |
+
|
1092 |
+
/**
|
1093 |
+
* Get a list of an account's available templates
|
1094 |
+
*
|
1095 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/templates/#read-get_templates
|
1096 |
+
* @param array $args
|
1097 |
+
* @return object
|
1098 |
+
* @throws MC4WP_API_Exception
|
1099 |
+
*/
|
1100 |
+
public function get_templates( array $args = array() ) {
|
1101 |
+
$resource = '/templates';
|
1102 |
+
return $this->client->get( $resource, $args );
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
/**
|
1106 |
+
* Get information about a specific template.
|
1107 |
+
*
|
1108 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/templates/#read-get_templates_template_id
|
1109 |
+
* @param string $template_id
|
1110 |
+
* @param array $args
|
1111 |
+
* @return object
|
1112 |
+
* @throws MC4WP_API_Exception
|
1113 |
+
*/
|
1114 |
+
public function get_template( $template_id, array $args = array() ) {
|
1115 |
+
$resource = sprintf( '/templates/%s', $template_id );
|
1116 |
+
return $this->client->get( $resource, $args );
|
1117 |
+
}
|
1118 |
+
|
1119 |
+
/**
|
1120 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/templates/default-content/
|
1121 |
+
* @param string $template_id
|
1122 |
+
* @param array $args
|
1123 |
+
* @return object
|
1124 |
+
* @throws MC4WP_API_Exception
|
1125 |
+
*/
|
1126 |
+
public function get_template_default_content( $template_id, array $args = array() ) {
|
1127 |
+
$resource = sprintf( '/templates/%s/default-content', $template_id );
|
1128 |
+
return $this->client->get( $resource, $args );
|
1129 |
+
}
|
1130 |
+
|
1131 |
+
/**
|
1132 |
+
* Create a new campaign
|
1133 |
+
*
|
1134 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/#create-post_campaigns
|
1135 |
+
* @param array $args
|
1136 |
+
* @return object
|
1137 |
+
* @throws MC4WP_API_Exception
|
1138 |
+
*/
|
1139 |
+
public function add_campaign( array $args ) {
|
1140 |
+
$resource = '/campaigns';
|
1141 |
+
return $this->client->post( $resource, $args );
|
1142 |
+
}
|
1143 |
+
|
1144 |
+
/**
|
1145 |
+
* Get all campaigns in an account
|
1146 |
+
*
|
1147 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/#read-get_campaigns
|
1148 |
+
* @param array $args
|
1149 |
+
* @return object
|
1150 |
+
* @throws MC4WP_API_Exception
|
1151 |
+
*/
|
1152 |
+
public function get_campaigns( array $args = array() ) {
|
1153 |
+
$resource = '/campaigns';
|
1154 |
+
return $this->client->get( $resource, $args );
|
1155 |
+
}
|
1156 |
+
|
1157 |
+
/**
|
1158 |
+
* Get information about a specific campaign.
|
1159 |
+
*
|
1160 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/#read-get_campaigns_campaign_id
|
1161 |
+
* @param string $campaign_id
|
1162 |
+
* @param array $args
|
1163 |
+
* @return object
|
1164 |
+
* @throws MC4WP_API_Exception
|
1165 |
+
*/
|
1166 |
+
public function get_campaign( $campaign_id, array $args = array() ) {
|
1167 |
+
$resource = sprintf( '/campaigns/%s', $campaign_id );
|
1168 |
+
return $this->client->get( $resource, $args );
|
1169 |
+
}
|
1170 |
+
|
1171 |
+
/**
|
1172 |
+
* Update some or all of the settings for a specific campaign.
|
1173 |
+
*
|
1174 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/#edit-patch_campaigns_campaign_id
|
1175 |
+
* @param string $campaign_id
|
1176 |
+
* @param array $args
|
1177 |
+
* @return object
|
1178 |
+
* @throws MC4WP_API_Exception
|
1179 |
+
*/
|
1180 |
+
public function update_campaign( $campaign_id, array $args ) {
|
1181 |
+
$resource = sprintf( '/campaigns/%s', $campaign_id );
|
1182 |
+
return $this->client->patch( $resource, $args );
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
/**
|
1186 |
+
* Remove a campaign from the Mailchimp account
|
1187 |
+
*
|
1188 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/#delete-delete_campaigns_campaign_id
|
1189 |
+
* @param string $campaign_id
|
1190 |
+
* @return bool
|
1191 |
+
* @throws MC4WP_API_Exception
|
1192 |
+
*/
|
1193 |
+
public function delete_campaign( $campaign_id ) {
|
1194 |
+
$resource = sprintf( '/campaigns/%s', $campaign_id );
|
1195 |
+
return ! ! $this->client->delete( $resource );
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
/**
|
1199 |
+
* Perform an action on a Mailchimp campaign
|
1200 |
+
*
|
1201 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/#action-post_campaigns
|
1202 |
+
*
|
1203 |
+
* @param string $campaign_id
|
1204 |
+
* @param string $action
|
1205 |
+
* @param array $args
|
1206 |
+
* @return object
|
1207 |
+
* @throws MC4WP_API_Exception
|
1208 |
+
*/
|
1209 |
+
public function campaign_action( $campaign_id, $action, array $args = array() ) {
|
1210 |
+
$resource = sprintf( '/campaigns/%s/actions/%s', $campaign_id, $action );
|
1211 |
+
return $this->client->post( $resource, $args );
|
1212 |
+
}
|
1213 |
+
|
1214 |
+
/**
|
1215 |
+
* Get the HTML and plain-text content for a campaign
|
1216 |
+
*
|
1217 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/content/#read-get_campaigns_campaign_id_content
|
1218 |
+
* @param string $campaign_id
|
1219 |
+
* @param array $args
|
1220 |
+
* @return object
|
1221 |
+
* @throws MC4WP_API_Exception
|
1222 |
+
*/
|
1223 |
+
public function get_campaign_content( $campaign_id, array $args = array() ) {
|
1224 |
+
$resource = sprintf( '/campaigns/%s/content', $campaign_id );
|
1225 |
+
return $this->client->get( $resource, $args );
|
1226 |
+
}
|
1227 |
+
|
1228 |
+
/**
|
1229 |
+
* Set the content for a campaign
|
1230 |
+
*
|
1231 |
+
* @link https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/content/#edit-put_campaigns_campaign_id_content
|
1232 |
+
* @param string $campaign_id
|
1233 |
+
* @param array $args
|
1234 |
+
* @return object
|
1235 |
+
* @throws MC4WP_API_Exception
|
1236 |
+
*/
|
1237 |
+
public function update_campaign_content( $campaign_id, array $args ) {
|
1238 |
+
$resource = sprintf( '/campaigns/%s/content', $campaign_id );
|
1239 |
+
return $this->client->put( $resource, $args );
|
1240 |
+
}
|
1241 |
+
|
1242 |
+
/**
|
1243 |
+
* @return string
|
1244 |
+
*/
|
1245 |
+
public function get_last_response_body() {
|
1246 |
+
return $this->client->get_last_response_body();
|
1247 |
+
}
|
1248 |
+
|
1249 |
+
/**
|
1250 |
+
* @return array
|
1251 |
+
*/
|
1252 |
+
public function get_last_response_headers() {
|
1253 |
+
return $this->client->get_last_response_headers();
|
1254 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1255 |
}
|
includes/api/class-api.php
CHANGED
@@ -8,594 +8,571 @@
|
|
8 |
* @since 1.0
|
9 |
* @deprecated 4.0
|
10 |
*/
|
11 |
-
class MC4WP_API
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
$data = json_decode($body);
|
579 |
-
if (! is_null($data)) {
|
580 |
-
return $data;
|
581 |
-
}
|
582 |
-
|
583 |
-
$code = (int) wp_remote_retrieve_response_code($response);
|
584 |
-
$message = wp_remote_retrieve_response_message($response);
|
585 |
-
|
586 |
-
if ($code !== 200) {
|
587 |
-
$message = sprintf('The Mailchimp API server returned the following response: <em>%s %s</em>.', $code, $message);
|
588 |
-
|
589 |
-
// check for Akamai firewall response
|
590 |
-
if ($code === 403) {
|
591 |
-
preg_match('/Reference (.*)/i', $body, $matches);
|
592 |
-
|
593 |
-
if (! empty($matches[1])) {
|
594 |
-
$message .= '</strong><br /><br />' . sprintf('This usually means that your server is blacklisted by Mailchimp\'s firewall. Please contact Mailchimp support with the following reference number: %s </strong>', $matches[1]);
|
595 |
-
}
|
596 |
-
}
|
597 |
-
}
|
598 |
-
|
599 |
-
throw new Exception($message, $code);
|
600 |
-
}
|
601 |
}
|
8 |
* @since 1.0
|
9 |
* @deprecated 4.0
|
10 |
*/
|
11 |
+
class MC4WP_API {
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var string The URL to the Mailchimp API
|
16 |
+
*/
|
17 |
+
protected $api_url = 'https://api.mailchimp.com/2.0/';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var string The API key to use
|
21 |
+
*/
|
22 |
+
protected $api_key = '';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var string The error message of the latest API request (if any)
|
26 |
+
*/
|
27 |
+
protected $error_message = '';
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var int The error code of the last API request (if any)
|
31 |
+
*/
|
32 |
+
protected $error_code = 0;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @var boolean Boolean indicating whether the user is connected with Mailchimp
|
36 |
+
*/
|
37 |
+
protected $connected;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @var object The full response object of the latest API call
|
41 |
+
*/
|
42 |
+
protected $last_response;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Constructor
|
46 |
+
*
|
47 |
+
* @param string $api_key
|
48 |
+
*/
|
49 |
+
public function __construct( $api_key ) {
|
50 |
+
$this->api_key = $api_key;
|
51 |
+
|
52 |
+
$dash_position = strpos( $api_key, '-' );
|
53 |
+
if ( $dash_position !== false ) {
|
54 |
+
$this->api_url = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/';
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Show an error message to administrators
|
60 |
+
*
|
61 |
+
* @param string $message
|
62 |
+
*
|
63 |
+
* @return bool
|
64 |
+
*/
|
65 |
+
private function show_error( $message ) {
|
66 |
+
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
67 |
+
return false;
|
68 |
+
}
|
69 |
+
|
70 |
+
if ( ! function_exists( 'add_settings_error' ) ) {
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
|
74 |
+
add_settings_error( 'mc4wp-api', 'mc4wp-api-error', $message, 'error' );
|
75 |
+
return true;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @param $message
|
80 |
+
*
|
81 |
+
* @return bool
|
82 |
+
*/
|
83 |
+
private function show_connection_error( $message ) {
|
84 |
+
$message .= '<br /><br />' . sprintf( '<a href="%s">' . __( 'Read more about common connectivity issues.', 'mailchimp-for-wp' ) . '</a>', 'https://kb.mc4wp.com/solving-connectivity-issues/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=settings-notice' );
|
85 |
+
return $this->show_error( $message );
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Pings the Mailchimp API to see if we're connected
|
90 |
+
*
|
91 |
+
* The result is cached to ensure a maximum of 1 API call per page load
|
92 |
+
*
|
93 |
+
* @return boolean
|
94 |
+
*/
|
95 |
+
public function is_connected() {
|
96 |
+
if ( is_bool( $this->connected ) ) {
|
97 |
+
return $this->connected;
|
98 |
+
}
|
99 |
+
|
100 |
+
$result = $this->call( 'helper/ping' );
|
101 |
+
$this->connected = false;
|
102 |
+
|
103 |
+
if ( is_object( $result ) ) {
|
104 |
+
|
105 |
+
// Msg key set? All good then!
|
106 |
+
if ( ! empty( $result->msg ) ) {
|
107 |
+
$this->connected = true;
|
108 |
+
return true;
|
109 |
+
}
|
110 |
+
|
111 |
+
// Uh oh. We got an error back.
|
112 |
+
if ( isset( $result->error ) ) {
|
113 |
+
$this->show_error( 'Mailchimp Error: ' . $result->error );
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
return $this->connected;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Sends a subscription request to the Mailchimp API
|
122 |
+
*
|
123 |
+
* @param string $list_id The list id to subscribe to
|
124 |
+
* @param string $email The email address to subscribe
|
125 |
+
* @param array $merge_vars Array of extra merge variables
|
126 |
+
* @param string $email_type The email type to send to this email address. Possible values are `html` and `text`.
|
127 |
+
* @param boolean $double_optin Should this email be confirmed via double opt-in?
|
128 |
+
* @param boolean $update_existing Update information if this email is already on list?
|
129 |
+
* @param boolean $replace_interests Replace interest groupings, only if update_existing is true.
|
130 |
+
* @param boolean $send_welcome Send a welcome e-mail, only if double_optin is false.
|
131 |
+
*
|
132 |
+
* @return boolean|string True if success, 'error' if error
|
133 |
+
*/
|
134 |
+
public function subscribe( $list_id, $email, array $merge_vars = array(), $email_type = 'html', $double_optin = true, $update_existing = false, $replace_interests = true, $send_welcome = false ) {
|
135 |
+
$data = array(
|
136 |
+
'id' => $list_id,
|
137 |
+
'email' => array( 'email' => $email ),
|
138 |
+
'merge_vars' => $merge_vars,
|
139 |
+
'email_type' => $email_type,
|
140 |
+
'double_optin' => $double_optin,
|
141 |
+
'update_existing' => $update_existing,
|
142 |
+
'replace_interests' => $replace_interests,
|
143 |
+
'send_welcome' => $send_welcome,
|
144 |
+
);
|
145 |
+
|
146 |
+
$response = $this->call( 'lists/subscribe', $data );
|
147 |
+
|
148 |
+
if ( is_object( $response ) && isset( $response->email ) ) {
|
149 |
+
return true;
|
150 |
+
}
|
151 |
+
|
152 |
+
return false;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Gets the Groupings for a given List
|
157 |
+
* @param int $list_id
|
158 |
+
* @return array|boolean
|
159 |
+
*/
|
160 |
+
public function get_list_groupings( $list_id ) {
|
161 |
+
$result = $this->call( 'lists/interest-groupings', array( 'id' => $list_id ) );
|
162 |
+
if ( is_array( $result ) ) {
|
163 |
+
return $result;
|
164 |
+
}
|
165 |
+
|
166 |
+
return false;
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* @param array $list_ids Array of ID's of the lists to fetch. (optional)
|
171 |
+
*
|
172 |
+
* @return bool
|
173 |
+
*/
|
174 |
+
public function get_lists( $list_ids = array() ) {
|
175 |
+
$args = array(
|
176 |
+
'limit' => 100,
|
177 |
+
'sort_field' => 'web',
|
178 |
+
'sort_dir' => 'ASC',
|
179 |
+
);
|
180 |
+
|
181 |
+
// set filter if the $list_ids parameter was set
|
182 |
+
if ( count( $list_ids ) > 0 ) {
|
183 |
+
$args['filters'] = array(
|
184 |
+
'list_id' => implode( ',', $list_ids ),
|
185 |
+
);
|
186 |
+
}
|
187 |
+
|
188 |
+
$result = $this->call( 'lists/list', $args );
|
189 |
+
|
190 |
+
if ( is_object( $result ) && isset( $result->data ) ) {
|
191 |
+
return $result->data;
|
192 |
+
}
|
193 |
+
|
194 |
+
return false;
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Get the lists an email address is subscribed to
|
199 |
+
*
|
200 |
+
* @param array|string $email
|
201 |
+
*
|
202 |
+
* @return array
|
203 |
+
*/
|
204 |
+
public function get_lists_for_email( $email ) {
|
205 |
+
if ( is_string( $email ) ) {
|
206 |
+
$email = array(
|
207 |
+
'email' => $email,
|
208 |
+
);
|
209 |
+
}
|
210 |
+
|
211 |
+
$result = $this->call( 'helper/lists-for-email', array( 'email' => $email ) );
|
212 |
+
if ( ! is_array( $result ) ) {
|
213 |
+
return array();
|
214 |
+
}
|
215 |
+
|
216 |
+
return $result;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Get lists with their merge_vars for a given array of list id's
|
221 |
+
* @param array $list_ids
|
222 |
+
* @return array|bool
|
223 |
+
*/
|
224 |
+
public function get_lists_with_merge_vars( $list_ids ) {
|
225 |
+
$result = $this->call( 'lists/merge-vars', array( 'id' => $list_ids ) );
|
226 |
+
|
227 |
+
if ( is_object( $result ) && isset( $result->data ) ) {
|
228 |
+
return $result->data;
|
229 |
+
}
|
230 |
+
|
231 |
+
return false;
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Gets the member info for one or multiple emails on a list
|
236 |
+
*
|
237 |
+
* @param string $list_id
|
238 |
+
* @param array $emails
|
239 |
+
* @return array|bool
|
240 |
+
*/
|
241 |
+
public function get_subscriber_info( $list_id, $emails ) {
|
242 |
+
if ( is_string( $emails ) ) {
|
243 |
+
$emails = array( $emails );
|
244 |
+
}
|
245 |
+
|
246 |
+
$result = $this->call(
|
247 |
+
'lists/member-info',
|
248 |
+
array(
|
249 |
+
'id' => $list_id,
|
250 |
+
'emails' => $emails,
|
251 |
+
)
|
252 |
+
);
|
253 |
+
|
254 |
+
if ( is_object( $result ) && isset( $result->data ) ) {
|
255 |
+
return $result->data;
|
256 |
+
}
|
257 |
+
|
258 |
+
return false;
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Checks if an email address is on a given list
|
263 |
+
*
|
264 |
+
* @param string $list_id
|
265 |
+
* @param string $email
|
266 |
+
* @return bool
|
267 |
+
*/
|
268 |
+
public function list_has_subscriber( $list_id, $email ) {
|
269 |
+
$member_info = $this->get_subscriber_info( $list_id, array( array( 'email' => $email ) ) );
|
270 |
+
|
271 |
+
if ( is_array( $member_info ) && isset( $member_info[0] ) ) {
|
272 |
+
return ( $member_info[0]->status === 'subscribed' );
|
273 |
+
}
|
274 |
+
|
275 |
+
return false;
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* @param string $list_id
|
280 |
+
* @param array|string $email
|
281 |
+
* @param array $merge_vars
|
282 |
+
* @param string $email_type
|
283 |
+
* @param bool $replace_interests
|
284 |
+
*
|
285 |
+
* @return bool
|
286 |
+
*/
|
287 |
+
public function update_subscriber( $list_id, $email, $merge_vars = array(), $email_type = 'html', $replace_interests = false ) {
|
288 |
+
|
289 |
+
// default to using email for updating
|
290 |
+
if ( is_string( $email ) ) {
|
291 |
+
$email = array(
|
292 |
+
'email' => $email,
|
293 |
+
);
|
294 |
+
}
|
295 |
+
|
296 |
+
$result = $this->call(
|
297 |
+
'lists/update-member',
|
298 |
+
array(
|
299 |
+
'id' => $list_id,
|
300 |
+
'email' => $email,
|
301 |
+
'merge_vars' => $merge_vars,
|
302 |
+
'email_type' => $email_type,
|
303 |
+
'replace_interests' => $replace_interests,
|
304 |
+
)
|
305 |
+
);
|
306 |
+
|
307 |
+
if ( is_object( $result ) ) {
|
308 |
+
if ( isset( $result->error ) ) {
|
309 |
+
return false;
|
310 |
+
} else {
|
311 |
+
return true;
|
312 |
+
}
|
313 |
+
}
|
314 |
+
|
315 |
+
return false;
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Unsubscribes the given email or luid from the given Mailchimp list
|
320 |
+
*
|
321 |
+
* @param string $list_id
|
322 |
+
* @param array|string $struct
|
323 |
+
* @param bool $delete_member
|
324 |
+
* @param bool $send_goodbye
|
325 |
+
* @param bool $send_notification
|
326 |
+
*
|
327 |
+
* @return bool
|
328 |
+
*/
|
329 |
+
public function unsubscribe( $list_id, $struct, $send_goodbye = true, $send_notification = false, $delete_member = false ) {
|
330 |
+
if ( ! is_array( $struct ) ) {
|
331 |
+
// assume $struct is an email
|
332 |
+
$struct = array(
|
333 |
+
'email' => $struct,
|
334 |
+
);
|
335 |
+
}
|
336 |
+
|
337 |
+
$response = $this->call(
|
338 |
+
'lists/unsubscribe',
|
339 |
+
array(
|
340 |
+
'id' => $list_id,
|
341 |
+
'email' => $struct,
|
342 |
+
'delete_member' => $delete_member,
|
343 |
+
'send_goodbye' => $send_goodbye,
|
344 |
+
'send_notify' => $send_notification,
|
345 |
+
)
|
346 |
+
);
|
347 |
+
|
348 |
+
if ( is_object( $response ) ) {
|
349 |
+
if ( isset( $response->complete ) && $response->complete ) {
|
350 |
+
return true;
|
351 |
+
}
|
352 |
+
}
|
353 |
+
|
354 |
+
return false;
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* @see https://apidocs.mailchimp.com/api/2.0/ecomm/order-add.php
|
359 |
+
*
|
360 |
+
* @param array $order_data
|
361 |
+
*
|
362 |
+
* @return boolean
|
363 |
+
*/
|
364 |
+
public function add_ecommerce_order( array $order_data ) {
|
365 |
+
$response = $this->call( 'ecomm/order-add', array( 'order' => $order_data ) );
|
366 |
+
|
367 |
+
if ( is_object( $response ) ) {
|
368 |
+
|
369 |
+
// complete means success
|
370 |
+
if ( isset( $response->complete ) && $response->complete ) {
|
371 |
+
return true;
|
372 |
+
}
|
373 |
+
|
374 |
+
// if order was already added: great
|
375 |
+
if ( isset( $response->code, $response->error ) && $response->code == 330 && strpos( $response->error, 'already been recorded' ) !== false ) {
|
376 |
+
return true;
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
return false;
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* @see https://apidocs.mailchimp.com/api/2.0/ecomm/order-del.php
|
385 |
+
*
|
386 |
+
* @param string $store_id
|
387 |
+
* @param string $order_id
|
388 |
+
*
|
389 |
+
* @return bool
|
390 |
+
*/
|
391 |
+
public function delete_ecommerce_order( $store_id, $order_id ) {
|
392 |
+
$data = array(
|
393 |
+
'store_id' => $store_id,
|
394 |
+
'order_id' => $order_id,
|
395 |
+
);
|
396 |
+
|
397 |
+
$response = $this->call( 'ecomm/order-del', $data );
|
398 |
+
|
399 |
+
if ( is_object( $response ) ) {
|
400 |
+
if ( isset( $response->complete ) && $response->complete ) {
|
401 |
+
return true;
|
402 |
+
}
|
403 |
+
|
404 |
+
// Invalid order (order not existing). Good!
|
405 |
+
if ( isset( $response->code ) && $response->code == 330 ) {
|
406 |
+
return true;
|
407 |
+
}
|
408 |
+
}
|
409 |
+
|
410 |
+
return false;
|
411 |
+
}
|
412 |
+
|
413 |
+
|
414 |
+
|
415 |
+
/**
|
416 |
+
* Calls the Mailchimp API
|
417 |
+
*
|
418 |
+
* @uses WP_HTTP
|
419 |
+
*
|
420 |
+
* @param string $method
|
421 |
+
* @param array $data
|
422 |
+
*
|
423 |
+
* @return object|bool
|
424 |
+
*/
|
425 |
+
public function call( $method, array $data = array() ) {
|
426 |
+
$this->empty_last_response();
|
427 |
+
|
428 |
+
// do not make request when no api key was provided.
|
429 |
+
if ( empty( $this->api_key ) ) {
|
430 |
+
$this->error_message = 'Missing Mailchimp API key.';
|
431 |
+
$this->error_code = 001;
|
432 |
+
return false;
|
433 |
+
}
|
434 |
+
|
435 |
+
// do not make request if helper/ping failed already
|
436 |
+
if ( $this->connected === false ) {
|
437 |
+
return false;
|
438 |
+
}
|
439 |
+
|
440 |
+
$data['apikey'] = $this->api_key;
|
441 |
+
|
442 |
+
$url = $this->api_url . $method . '.json';
|
443 |
+
$request_args = array(
|
444 |
+
'body' => $data,
|
445 |
+
'timeout' => 10,
|
446 |
+
'headers' => $this->get_headers(),
|
447 |
+
'sslverify' => apply_filters( 'mc4wp_use_sslverify', true ),
|
448 |
+
);
|
449 |
+
|
450 |
+
$response = wp_remote_post( $url, $request_args );
|
451 |
+
|
452 |
+
try {
|
453 |
+
$response = $this->parse_response( $response );
|
454 |
+
} catch ( Exception $e ) {
|
455 |
+
$this->error_code = $e->getCode();
|
456 |
+
$this->error_message = $e->getMessage();
|
457 |
+
$this->show_connection_error( $e->getMessage() );
|
458 |
+
return false;
|
459 |
+
}
|
460 |
+
|
461 |
+
// store response
|
462 |
+
$this->last_response = $response;
|
463 |
+
|
464 |
+
// store error (if any)
|
465 |
+
if ( is_object( $response ) ) {
|
466 |
+
if ( ! empty( $response->error ) ) {
|
467 |
+
$this->error_message = $response->error;
|
468 |
+
}
|
469 |
+
|
470 |
+
// store error code (if any)
|
471 |
+
if ( ! empty( $response->code ) ) {
|
472 |
+
$this->error_code = (int) $response->code;
|
473 |
+
}
|
474 |
+
}
|
475 |
+
|
476 |
+
return $response;
|
477 |
+
}
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Checks if an error occured in the most recent request
|
481 |
+
* @return boolean
|
482 |
+
*/
|
483 |
+
public function has_error() {
|
484 |
+
return ( ! empty( $this->error_message ) );
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* Gets the most recent error message
|
489 |
+
* @return string
|
490 |
+
*/
|
491 |
+
public function get_error_message() {
|
492 |
+
return $this->error_message;
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Gets the most recent error code
|
497 |
+
*
|
498 |
+
* @return int
|
499 |
+
*/
|
500 |
+
public function get_error_code() {
|
501 |
+
return $this->error_code;
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Get the most recent response object
|
506 |
+
*
|
507 |
+
* @return object
|
508 |
+
*/
|
509 |
+
public function get_last_response() {
|
510 |
+
return $this->last_response;
|
511 |
+
}
|
512 |
+
|
513 |
+
/**
|
514 |
+
* Empties all data from previous response
|
515 |
+
*/
|
516 |
+
private function empty_last_response() {
|
517 |
+
$this->last_response = null;
|
518 |
+
$this->error_code = 0;
|
519 |
+
$this->error_message = '';
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Get the request headers to send to the Mailchimp API
|
524 |
+
*
|
525 |
+
* @return array
|
526 |
+
*/
|
527 |
+
private function get_headers() {
|
528 |
+
global $wp_version;
|
529 |
+
|
530 |
+
$headers = array(
|
531 |
+
'Accept' => 'application/json',
|
532 |
+
'User-Agent' => 'mc4wp/' . MC4WP_VERSION . '; WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
|
533 |
+
);
|
534 |
+
|
535 |
+
// Copy Accept-Language from browser headers
|
536 |
+
if ( ! empty( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
|
537 |
+
$headers['Accept-Language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
538 |
+
}
|
539 |
+
|
540 |
+
return $headers;
|
541 |
+
}
|
542 |
+
|
543 |
+
/**
|
544 |
+
* @param array|WP_Error $response
|
545 |
+
* @return object
|
546 |
+
* @throws Exception
|
547 |
+
*/
|
548 |
+
private function parse_response( $response ) {
|
549 |
+
if ( is_wp_error( $response ) ) {
|
550 |
+
throw new Exception( 'Error connecting to Mailchimp. ' . $response->get_error_message(), (int) $response->get_error_code() );
|
551 |
+
}
|
552 |
+
|
553 |
+
// decode response body
|
554 |
+
$body = wp_remote_retrieve_body( $response );
|
555 |
+
$data = json_decode( $body );
|
556 |
+
if ( ! is_null( $data ) ) {
|
557 |
+
return $data;
|
558 |
+
}
|
559 |
+
|
560 |
+
$code = (int) wp_remote_retrieve_response_code( $response );
|
561 |
+
$message = wp_remote_retrieve_response_message( $response );
|
562 |
+
|
563 |
+
if ( $code !== 200 ) {
|
564 |
+
$message = sprintf( 'The Mailchimp API server returned the following response: <em>%s %s</em>.', $code, $message );
|
565 |
+
|
566 |
+
// check for Akamai firewall response
|
567 |
+
if ( $code === 403 ) {
|
568 |
+
preg_match( '/Reference (.*)/i', $body, $matches );
|
569 |
+
|
570 |
+
if ( ! empty( $matches[1] ) ) {
|
571 |
+
$message .= '</strong><br /><br />' . sprintf( 'This usually means that your server is blacklisted by Mailchimp\'s firewall. Please contact Mailchimp support with the following reference number: %s </strong>', $matches[1] );
|
572 |
+
}
|
573 |
+
}
|
574 |
+
}
|
575 |
+
|
576 |
+
throw new Exception( $message, $code );
|
577 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
578 |
}
|
includes/api/class-connection-exception.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class MC4WP_API_Connection_Exception extends MC4WP_API_Exception
|
4 |
-
|
5 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class MC4WP_API_Connection_Exception extends MC4WP_API_Exception {
|
4 |
+
|
5 |
}
|
includes/api/class-exception.php
CHANGED
@@ -7,113 +7,110 @@
|
|
7 |
* @property string $detail
|
8 |
* @property array $errors
|
9 |
*/
|
10 |
-
class MC4WP_API_Exception extends Exception
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
return $string;
|
118 |
-
}
|
119 |
}
|
7 |
* @property string $detail
|
8 |
* @property array $errors
|
9 |
*/
|
10 |
+
class MC4WP_API_Exception extends Exception {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var object
|
14 |
+
*/
|
15 |
+
public $response = array();
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var object
|
19 |
+
*/
|
20 |
+
public $request = array();
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @var array
|
24 |
+
*/
|
25 |
+
public $response_data = array();
|
26 |
+
|
27 |
+
/**
|
28 |
+
* MC4WP_API_Exception constructor.
|
29 |
+
*
|
30 |
+
* @param string $message
|
31 |
+
* @param int $code
|
32 |
+
* @param array $request
|
33 |
+
* @param array $response
|
34 |
+
* @param object $data
|
35 |
+
*/
|
36 |
+
public function __construct( $message, $code, $request = null, $response = null, $data = null ) {
|
37 |
+
parent::__construct( $message, $code );
|
38 |
+
|
39 |
+
$this->request = $request;
|
40 |
+
$this->response = $response;
|
41 |
+
|
42 |
+
$this->response_data = $data;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Backwards compatibility for direct property access.
|
47 |
+
* @param string $property
|
48 |
+
* @return mixed
|
49 |
+
*/
|
50 |
+
public function __get( $property ) {
|
51 |
+
if ( in_array( $property, array( 'title', 'detail', 'errors' ), true ) ) {
|
52 |
+
if ( ! empty( $this->response_data ) && isset( $this->response_data->{$property} ) ) {
|
53 |
+
return $this->response_data->{$property};
|
54 |
+
}
|
55 |
+
|
56 |
+
return '';
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function __toString() {
|
64 |
+
$string = $this->message . '.';
|
65 |
+
|
66 |
+
// add errors from response data returned by Mailchimp
|
67 |
+
if ( ! empty( $this->response_data ) ) {
|
68 |
+
if ( ! empty( $this->response_data->title ) && $this->response_data->title !== $this->getMessage() ) {
|
69 |
+
$string .= ' ' . $this->response_data->title . '.';
|
70 |
+
}
|
71 |
+
|
72 |
+
// add detail message
|
73 |
+
if ( ! empty( $this->response_data->detail ) ) {
|
74 |
+
$string .= ' ' . $this->response_data->detail;
|
75 |
+
}
|
76 |
+
|
77 |
+
// add field specific errors
|
78 |
+
if ( ! empty( $this->response_data->errors ) && isset( $this->response_data->errors[0]->field ) ) {
|
79 |
+
|
80 |
+
// strip off obsolete msg
|
81 |
+
$string = str_replace( 'For field-specific details, see the \'errors\' array.', '', $string );
|
82 |
+
|
83 |
+
// generate list of field errors
|
84 |
+
$field_errors = array();
|
85 |
+
foreach ( $this->response_data->errors as $error ) {
|
86 |
+
if ( ! empty( $error->field ) ) {
|
87 |
+
$field_errors[] = sprintf( '- %s : %s', $error->field, $error->message );
|
88 |
+
} else {
|
89 |
+
$field_errors[] = sprintf( '- %s', $error->message );
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
$string .= " \n" . join( "\n", $field_errors );
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
// Add request data
|
98 |
+
if ( ! empty( $this->request ) && is_array( $this->request ) ) {
|
99 |
+
$string .= "\n" . sprintf( 'Request: %s %s', $this->request['method'], $this->request['url'] );
|
100 |
+
|
101 |
+
if ( ! empty( $this->request['body'] ) ) {
|
102 |
+
$string .= sprintf( ' - %s', $this->request['body'] );
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
// Add response data
|
107 |
+
if ( ! empty( $this->response ) && is_array( $this->response ) ) {
|
108 |
+
$response_code = wp_remote_retrieve_response_code( $this->response );
|
109 |
+
$response_message = wp_remote_retrieve_response_message( $this->response );
|
110 |
+
$response_body = wp_remote_retrieve_body( $this->response );
|
111 |
+
$string .= "\n" . sprintf( 'Response: %d %s - %s', $response_code, $response_message, $response_body );
|
112 |
+
}
|
113 |
+
|
114 |
+
return $string;
|
115 |
+
}
|
|
|
|
|
|
|
116 |
}
|
includes/api/class-resource-not-found-exception.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class MC4WP_API_Resource_Not_Found_Exception extends MC4WP_API_Exception
|
4 |
-
|
5 |
-
|
6 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class MC4WP_API_Resource_Not_Found_Exception extends MC4WP_API_Exception {
|
4 |
+
|
5 |
+
// Thrown when a requested resource does not exist in Mailchimp
|
6 |
}
|
includes/class-container.php
CHANGED
@@ -6,123 +6,117 @@
|
|
6 |
* @access private
|
7 |
* @ignore
|
8 |
*/
|
9 |
-
class MC4WP_Container implements ArrayAccess
|
10 |
-
{
|
11 |
|
12 |
-
/**
|
13 |
-
* @var array
|
14 |
-
*/
|
15 |
-
protected $services = array();
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
public function has($name)
|
27 |
-
{
|
28 |
-
return isset($this->services[ $name ]);
|
29 |
-
}
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
{
|
39 |
-
if (! $this->has($name)) {
|
40 |
-
throw new Exception(sprintf('No service named %s was registered.', $name));
|
41 |
-
}
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
-
|
46 |
-
if (is_callable($service)) {
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
$this->resolved_services[ $name ] = call_user_func($service);
|
51 |
-
}
|
52 |
|
53 |
-
|
54 |
-
|
|
|
|
|
55 |
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
* Whether a offset exists
|
62 |
-
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
|
63 |
-
*
|
64 |
-
* @param mixed $offset <p>
|
65 |
-
* An offset to check for.
|
66 |
-
* </p>
|
67 |
-
*
|
68 |
-
* @return boolean true on success or false on failure.
|
69 |
-
* </p>
|
70 |
-
* <p>
|
71 |
-
* The return value will be casted to boolean if non-boolean was returned.
|
72 |
-
*/
|
73 |
-
public function offsetExists($offset)
|
74 |
-
{
|
75 |
-
return $this->has($offset);
|
76 |
-
}
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
public function offsetSet($offset, $value)
|
109 |
-
{
|
110 |
-
$this->services[ $offset ] = $value;
|
111 |
-
}
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
}
|
6 |
* @access private
|
7 |
* @ignore
|
8 |
*/
|
9 |
+
class MC4WP_Container implements ArrayAccess {
|
|
|
10 |
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
/**
|
13 |
+
* @var array
|
14 |
+
*/
|
15 |
+
protected $services = array();
|
16 |
|
17 |
+
/**
|
18 |
+
* @var array
|
19 |
+
*/
|
20 |
+
protected $resolved_services = array();
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
/**
|
23 |
+
* @param $name
|
24 |
+
* @return boolean
|
25 |
+
*/
|
26 |
+
public function has( $name ) {
|
27 |
+
return isset( $this->services[ $name ] );
|
28 |
+
}
|
|
|
|
|
|
|
|
|
29 |
|
30 |
+
/**
|
31 |
+
* @param $name
|
32 |
+
*
|
33 |
+
* @return mixed
|
34 |
+
* @throws Exception
|
35 |
+
*/
|
36 |
+
public function get( $name ) {
|
37 |
+
if ( ! $this->has( $name ) ) {
|
38 |
+
throw new Exception( sprintf( 'No service named %s was registered.', $name ) );
|
39 |
+
}
|
40 |
|
41 |
+
$service = $this->services[ $name ];
|
|
|
42 |
|
43 |
+
// is this a resolvable service?
|
44 |
+
if ( is_callable( $service ) ) {
|
|
|
|
|
45 |
|
46 |
+
// resolve service if it's not resolved yet
|
47 |
+
if ( ! isset( $this->resolved_services[ $name ] ) ) {
|
48 |
+
$this->resolved_services[ $name ] = call_user_func( $service );
|
49 |
+
}
|
50 |
|
51 |
+
return $this->resolved_services[ $name ];
|
52 |
+
}
|
53 |
|
54 |
+
return $this->services[ $name ];
|
55 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
+
/**
|
58 |
+
* (PHP 5 >= 5.0.0)<br/>
|
59 |
+
* Whether a offset exists
|
60 |
+
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
|
61 |
+
*
|
62 |
+
* @param mixed $offset <p>
|
63 |
+
* An offset to check for.
|
64 |
+
* </p>
|
65 |
+
*
|
66 |
+
* @return boolean true on success or false on failure.
|
67 |
+
* </p>
|
68 |
+
* <p>
|
69 |
+
* The return value will be casted to boolean if non-boolean was returned.
|
70 |
+
*/
|
71 |
+
public function offsetExists( $offset ) {
|
72 |
+
return $this->has( $offset );
|
73 |
+
}
|
74 |
|
75 |
+
/**
|
76 |
+
* (PHP 5 >= 5.0.0)<br/>
|
77 |
+
* Offset to retrieve
|
78 |
+
* @link http://php.net/manual/en/arrayaccess.offsetget.php
|
79 |
+
*
|
80 |
+
* @param mixed $offset <p>
|
81 |
+
* The offset to retrieve.
|
82 |
+
* </p>
|
83 |
+
*
|
84 |
+
* @return mixed Can return all value types.
|
85 |
+
*/
|
86 |
+
public function offsetGet( $offset ) {
|
87 |
+
return $this->get( $offset );
|
88 |
+
}
|
|
|
|
|
|
|
|
|
89 |
|
90 |
+
/**
|
91 |
+
* (PHP 5 >= 5.0.0)<br/>
|
92 |
+
* Offset to set
|
93 |
+
* @link http://php.net/manual/en/arrayaccess.offsetset.php
|
94 |
+
*
|
95 |
+
* @param mixed $offset <p>
|
96 |
+
* The offset to assign the value to.
|
97 |
+
* </p>
|
98 |
+
* @param mixed $value <p>
|
99 |
+
* The value to set.
|
100 |
+
* </p>
|
101 |
+
*
|
102 |
+
* @return void
|
103 |
+
*/
|
104 |
+
public function offsetSet( $offset, $value ) {
|
105 |
+
$this->services[ $offset ] = $value;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* (PHP 5 >= 5.0.0)<br/>
|
110 |
+
* Offset to unset
|
111 |
+
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
|
112 |
+
*
|
113 |
+
* @param mixed $offset <p>
|
114 |
+
* The offset to unset.
|
115 |
+
* </p>
|
116 |
+
*
|
117 |
+
* @return void
|
118 |
+
*/
|
119 |
+
public function offsetUnset( $offset ) {
|
120 |
+
unset( $this->services[ $offset ] );
|
121 |
+
}
|
122 |
}
|
includes/class-debug-log-reader.php
CHANGED
@@ -3,160 +3,154 @@
|
|
3 |
/**
|
4 |
* Class MC4WP_Debug_Log_Reader
|
5 |
*/
|
6 |
-
class MC4WP_Debug_Log_Reader
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
$lines .= fgets($handle);
|
157 |
-
}
|
158 |
-
|
159 |
-
fclose($handle);
|
160 |
-
return $lines;
|
161 |
-
}
|
162 |
}
|
3 |
/**
|
4 |
* Class MC4WP_Debug_Log_Reader
|
5 |
*/
|
6 |
+
class MC4WP_Debug_Log_Reader {
|
7 |
+
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @var resource|null
|
11 |
+
*/
|
12 |
+
private $handle;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
private static $regex = '/^(\[[\d \-\:]+\]) (\w+\:) (.*)$/S';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
private static $html_template = '<span class="time">$1</span> <span class="level">$2</span> <span class="message">$3</span>';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var string The log file location.
|
26 |
+
*/
|
27 |
+
private $file;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* MC4WP_Debug_Log_Reader constructor.
|
31 |
+
*
|
32 |
+
* @param $file
|
33 |
+
*/
|
34 |
+
public function __construct( $file ) {
|
35 |
+
$this->file = $file;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
public function all() {
|
42 |
+
return file_get_contents( $this->file );
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Sets file pointer to $n of lines from the end of file.
|
47 |
+
*
|
48 |
+
* @param int $n
|
49 |
+
*/
|
50 |
+
private function seek_line_from_end( $n ) {
|
51 |
+
$line_count = 0;
|
52 |
+
|
53 |
+
// get line count
|
54 |
+
while ( ! feof( $this->handle ) ) {
|
55 |
+
fgets( $this->handle );
|
56 |
+
$line_count++;
|
57 |
+
}
|
58 |
+
|
59 |
+
// rewind to beginning
|
60 |
+
rewind( $this->handle );
|
61 |
+
|
62 |
+
// calculate target
|
63 |
+
$target = $line_count - $n;
|
64 |
+
$target = $target > 1 ? $target : 1; // always skip first line because oh PHP header
|
65 |
+
$current = 0;
|
66 |
+
|
67 |
+
// keep reading until we're at target
|
68 |
+
while ( $current < $target ) {
|
69 |
+
fgets( $this->handle );
|
70 |
+
$current++;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @return string|null
|
76 |
+
*/
|
77 |
+
public function read() {
|
78 |
+
|
79 |
+
// open file if not yet opened
|
80 |
+
if ( ! is_resource( $this->handle ) ) {
|
81 |
+
|
82 |
+
// doesn't exist?
|
83 |
+
if ( ! file_exists( $this->file ) ) {
|
84 |
+
return null;
|
85 |
+
}
|
86 |
+
|
87 |
+
$this->handle = @fopen( $this->file, 'r' );
|
88 |
+
|
89 |
+
// unable to read?
|
90 |
+
if ( ! is_resource( $this->handle ) ) {
|
91 |
+
return null;
|
92 |
+
}
|
93 |
+
|
94 |
+
// set pointer to 1000 files from EOF
|
95 |
+
$this->seek_line_from_end( 1000 );
|
96 |
+
}
|
97 |
+
|
98 |
+
// stop reading once we're at the end
|
99 |
+
if ( feof( $this->handle ) ) {
|
100 |
+
fclose( $this->handle );
|
101 |
+
$this->handle = null;
|
102 |
+
return null;
|
103 |
+
}
|
104 |
+
|
105 |
+
// read line, up to 8kb
|
106 |
+
$text = fgets( $this->handle );
|
107 |
+
|
108 |
+
// strip tags & trim
|
109 |
+
$text = strip_tags( $text );
|
110 |
+
$text = trim( $text );
|
111 |
+
|
112 |
+
return $text;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @return string
|
117 |
+
*/
|
118 |
+
public function read_as_html() {
|
119 |
+
$line = $this->read();
|
120 |
+
|
121 |
+
// null means end of file
|
122 |
+
if ( is_null( $line ) ) {
|
123 |
+
return null;
|
124 |
+
}
|
125 |
+
|
126 |
+
// empty string means empty line, but not yet eof
|
127 |
+
if ( empty( $line ) ) {
|
128 |
+
return '';
|
129 |
+
}
|
130 |
+
|
131 |
+
$line = preg_replace( self::$regex, self::$html_template, $line );
|
132 |
+
return $line;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Reads X number of lines.
|
137 |
+
*
|
138 |
+
* If $start is negative, reads from end of log file.
|
139 |
+
*
|
140 |
+
* @param int $start
|
141 |
+
* @param int $number
|
142 |
+
* @return string
|
143 |
+
*/
|
144 |
+
public function lines( $start, $number ) {
|
145 |
+
$handle = fopen( $start, 'r' );
|
146 |
+
$lines = '';
|
147 |
+
|
148 |
+
$current_line = 0;
|
149 |
+
while ( $current_line < $number ) {
|
150 |
+
$lines .= fgets( $handle );
|
151 |
+
}
|
152 |
+
|
153 |
+
fclose( $handle );
|
154 |
+
return $lines;
|
155 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
includes/class-debug-log.php
CHANGED
@@ -5,222 +5,246 @@
|
|
5 |
*
|
6 |
* Simple logging class which writes to a file, loosely based on PSR-3.
|
7 |
*/
|
8 |
-
class MC4WP_Debug_Log
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
}
|
5 |
*
|
6 |
* Simple logging class which writes to a file, loosely based on PSR-3.
|
7 |
*/
|
8 |
+
class MC4WP_Debug_Log {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Detailed debug information
|
13 |
+
*/
|
14 |
+
const DEBUG = 100;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Interesting events
|
18 |
+
*
|
19 |
+
* Examples: Visitor subscribed
|
20 |
+
*/
|
21 |
+
const INFO = 200;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Exceptional occurrences that are not errors
|
25 |
+
*
|
26 |
+
* Examples: User already subscribed
|
27 |
+
*/
|
28 |
+
const WARNING = 300;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Runtime errors
|
32 |
+
*/
|
33 |
+
const ERROR = 400;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Logging levels from syslog protocol defined in RFC 5424
|
37 |
+
*
|
38 |
+
* @var array $levels Logging levels
|
39 |
+
*/
|
40 |
+
protected static $levels = array(
|
41 |
+
self::DEBUG => 'DEBUG',
|
42 |
+
self::INFO => 'INFO',
|
43 |
+
self::WARNING => 'WARNING',
|
44 |
+
self::ERROR => 'ERROR',
|
45 |
+
);
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @var string The file to which messages should be written.
|
49 |
+
*/
|
50 |
+
public $file;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @var int Only write messages with this level or higher
|
54 |
+
*/
|
55 |
+
public $level;
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @var resource
|
59 |
+
*/
|
60 |
+
protected $stream;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* MC4WP_Debug_Log constructor.
|
64 |
+
*
|
65 |
+
* @param string $file
|
66 |
+
* @param mixed $level;
|
67 |
+
*/
|
68 |
+
public function __construct( $file, $level = self::DEBUG ) {
|
69 |
+
$this->file = $file;
|
70 |
+
$this->level = self::to_level( $level );
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @param mixed $level
|
75 |
+
* @param string $message
|
76 |
+
* @return boolean
|
77 |
+
*/
|
78 |
+
public function log( $level, $message ) {
|
79 |
+
$level = self::to_level( $level );
|
80 |
+
|
81 |
+
// only log if message level is higher than log level
|
82 |
+
if ( $level < $this->level ) {
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
|
86 |
+
// obfuscate email addresses in log message since log might be public.
|
87 |
+
$message = mc4wp_obfuscate_email_addresses( (string) $message );
|
88 |
+
|
89 |
+
// first, get rid of everything between "invisible" tags
|
90 |
+
$message = preg_replace( '/<(?:style|script|head)>.+?<\/(?:style|script|head)>/is', '', $message );
|
91 |
+
|
92 |
+
// then, strip tags (while retaining content of these tags)
|
93 |
+
$message = strip_tags( $message );
|
94 |
+
$message = trim( $message );
|
95 |
+
|
96 |
+
// generate line
|
97 |
+
$level_name = self::get_level_name( $level );
|
98 |
+
$datetime = gmdate( 'Y-m-d H:i:s', time() + ( get_option( 'gmt_offset', 0 ) * HOUR_IN_SECONDS ) );
|
99 |
+
$message = sprintf( '[%s] %s: %s', $datetime, $level_name, $message ) . PHP_EOL;
|
100 |
+
|
101 |
+
// did we open stream yet?
|
102 |
+
if ( ! is_resource( $this->stream ) ) {
|
103 |
+
|
104 |
+
// open stream
|
105 |
+
$this->stream = @fopen( $this->file, 'c+' );
|
106 |
+
|
107 |
+
// if this failed, bail..
|
108 |
+
if ( ! is_resource( $this->stream ) ) {
|
109 |
+
return false;
|
110 |
+
}
|
111 |
+
|
112 |
+
// make sure first line of log file is a PHP tag + exit statement (to prevent direct file access)
|
113 |
+
$line = fgets( $this->stream );
|
114 |
+
$php_exit_string = '<?php exit; ?>';
|
115 |
+
if ( strpos( $line, $php_exit_string ) !== 0 ) {
|
116 |
+
rewind( $this->stream );
|
117 |
+
fwrite( $this->stream, $php_exit_string . PHP_EOL . $line );
|
118 |
+
}
|
119 |
+
|
120 |
+
// place pointer at end of file
|
121 |
+
fseek( $this->stream, 0, SEEK_END );
|
122 |
+
}
|
123 |
+
|
124 |
+
// lock file while we write, ignore errors (not much we can do)
|
125 |
+
flock( $this->stream, LOCK_EX );
|
126 |
+
|
127 |
+
// write the message to the file
|
128 |
+
fwrite( $this->stream, $message );
|
129 |
+
|
130 |
+
// unlock file again, but don't close it for remainder of this request
|
131 |
+
flock( $this->stream, LOCK_UN );
|
132 |
+
|
133 |
+
$this->protect_log_file();
|
134 |
+
|
135 |
+
return true;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* @param string $message
|
140 |
+
* @return boolean
|
141 |
+
*/
|
142 |
+
public function warning( $message ) {
|
143 |
+
return $this->log( self::WARNING, $message );
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @param string $message
|
148 |
+
* @return boolean
|
149 |
+
*/
|
150 |
+
public function info( $message ) {
|
151 |
+
return $this->log( self::INFO, $message );
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* @param string $message
|
156 |
+
* @return boolean
|
157 |
+
*/
|
158 |
+
public function error( $message ) {
|
159 |
+
return $this->log( self::ERROR, $message );
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @param string $message
|
164 |
+
* @return boolean
|
165 |
+
*/
|
166 |
+
public function debug( $message ) {
|
167 |
+
return $this->log( self::DEBUG, $message );
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Converts PSR-3 levels to local ones if necessary
|
172 |
+
*
|
173 |
+
* @param string|int Level number or name (PSR-3)
|
174 |
+
* @return int
|
175 |
+
*/
|
176 |
+
public static function to_level( $level ) {
|
177 |
+
if ( is_string( $level ) ) {
|
178 |
+
$level = strtoupper( $level );
|
179 |
+
if ( defined( __CLASS__ . '::' . $level ) ) {
|
180 |
+
return constant( __CLASS__ . '::' . $level );
|
181 |
+
}
|
182 |
+
|
183 |
+
throw new InvalidArgumentException( 'Level "' . $level . '" is not defined, use one of: ' . implode( ', ', array_keys( self::$levels ) ) );
|
184 |
+
}
|
185 |
+
|
186 |
+
return $level;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Gets the name of the logging level.
|
191 |
+
*
|
192 |
+
* @param int $level
|
193 |
+
* @return string
|
194 |
+
*/
|
195 |
+
public static function get_level_name( $level ) {
|
196 |
+
if ( ! isset( self::$levels[ $level ] ) ) {
|
197 |
+
throw new InvalidArgumentException( 'Level "' . $level . '" is not defined, use one of: ' . implode( ', ', array_keys( self::$levels ) ) );
|
198 |
+
}
|
199 |
+
|
200 |
+
return self::$levels[ $level ];
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Tests if the log file is writable
|
205 |
+
*
|
206 |
+
* @return bool
|
207 |
+
*/
|
208 |
+
public function test() {
|
209 |
+
$handle = @fopen( $this->file, 'a' );
|
210 |
+
$writable = false;
|
211 |
+
|
212 |
+
if ( is_resource( $handle ) ) {
|
213 |
+
$writable = true;
|
214 |
+
fclose( $handle );
|
215 |
+
}
|
216 |
+
|
217 |
+
return $writable;
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* This writes a .htaccess file to the directory that the log file is in on servers supporting it.
|
222 |
+
*/
|
223 |
+
private function protect_log_file() {
|
224 |
+
if ( ! isset( $_SERVER['SERVER_SOFTWARE'] ) || substr( $_SERVER['SERVER_SOFTWARE'], 0, 6 ) !== 'Apache' ) {
|
225 |
+
return;
|
226 |
+
}
|
227 |
+
|
228 |
+
$filename = basename( $this->file );
|
229 |
+
$dirname = dirname( $this->file );
|
230 |
+
$htaccess_file = $dirname . '/.htaccess';
|
231 |
+
$lines = array(
|
232 |
+
'# MC4WP Start',
|
233 |
+
sprintf( '<Files %s>', $filename ),
|
234 |
+
'deny from all',
|
235 |
+
'</Files>',
|
236 |
+
'# MC4WP End',
|
237 |
+
);
|
238 |
+
|
239 |
+
if ( ! file_exists( $htaccess_file ) ) {
|
240 |
+
file_put_contents( $htaccess_file, join( PHP_EOL, $lines ) );
|
241 |
+
return;
|
242 |
+
}
|
243 |
+
|
244 |
+
$htaccess_content = file_get_contents( $htaccess_file );
|
245 |
+
if ( strpos( $htaccess_content, $lines[0] ) === false ) {
|
246 |
+
file_put_contents( $htaccess_file, join( PHP_EOL, $lines ), FILE_APPEND );
|
247 |
+
return;
|
248 |
+
}
|
249 |
+
}
|
250 |
}
|
includes/class-dynamic-content-tags.php
CHANGED
@@ -6,259 +6,246 @@
|
|
6 |
* @access private
|
7 |
* @ignore
|
8 |
*/
|
9 |
-
abstract class MC4WP_Dynamic_Content_Tags
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
if (!empty($_REQUEST['EMAIL'])) {
|
251 |
-
return $_REQUEST['EMAIL'];
|
252 |
-
}
|
253 |
-
|
254 |
-
// then , try logged-in user
|
255 |
-
if (is_user_logged_in()) {
|
256 |
-
$user = wp_get_current_user();
|
257 |
-
return $user->user_email;
|
258 |
-
}
|
259 |
-
|
260 |
-
// TODO: Read from cookie? Or add $_COOKIE support to {data} tag?
|
261 |
-
return '';
|
262 |
-
}
|
263 |
|
264 |
}
|
6 |
* @access private
|
7 |
* @ignore
|
8 |
*/
|
9 |
+
abstract class MC4WP_Dynamic_Content_Tags {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @var string The escape function for replacement values.
|
13 |
+
*/
|
14 |
+
protected $escape_function = null;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var array Array of registered dynamic content tags
|
18 |
+
*/
|
19 |
+
protected $tags = array();
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Register template tags
|
23 |
+
*/
|
24 |
+
protected function register() {
|
25 |
+
// Global tags can go here
|
26 |
+
$this->tags['cookie'] = array(
|
27 |
+
'description' => sprintf( __( 'Data from a cookie.', 'mailchimp-for-wp' ) ),
|
28 |
+
'callback' => array( $this, 'get_cookie' ),
|
29 |
+
'example' => "cookie name='my_cookie' default='Default Value'",
|
30 |
+
);
|
31 |
+
|
32 |
+
$this->tags['email'] = array(
|
33 |
+
'description' => __( 'The email address of the current visitor (if known).', 'mailchimp-for-wp' ),
|
34 |
+
'callback' => array( $this, 'get_email' ),
|
35 |
+
);
|
36 |
+
|
37 |
+
$this->tags['current_url'] = array(
|
38 |
+
'description' => __( 'The URL of the page.', 'mailchimp-for-wp' ),
|
39 |
+
'callback' => 'mc4wp_get_request_url',
|
40 |
+
);
|
41 |
+
|
42 |
+
$this->tags['current_path'] = array(
|
43 |
+
'description' => __( 'The path of the page.', 'mailchimp-for-wp' ),
|
44 |
+
'callback' => 'mc4wp_get_request_path',
|
45 |
+
);
|
46 |
+
|
47 |
+
$this->tags['date'] = array(
|
48 |
+
'description' => sprintf( __( 'The current date. Example: %s.', 'mailchimp-for-wp' ), '<strong>' . gmdate( 'Y/m/d', time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) . '</strong>' ),
|
49 |
+
'replacement' => gmdate( 'Y/m/d', time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ),
|
50 |
+
);
|
51 |
+
|
52 |
+
$this->tags['time'] = array(
|
53 |
+
'description' => sprintf( __( 'The current time. Example: %s.', 'mailchimp-for-wp' ), '<strong>' . gmdate( 'H:i:s', time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) . '</strong>' ),
|
54 |
+
'replacement' => gmdate( 'H:i:s', time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ),
|
55 |
+
);
|
56 |
+
|
57 |
+
$this->tags['language'] = array(
|
58 |
+
'description' => sprintf( __( 'The site\'s language. Example: %s.', 'mailchimp-for-wp' ), '<strong>' . get_locale() . '</strong>' ),
|
59 |
+
'callback' => 'get_locale',
|
60 |
+
);
|
61 |
+
|
62 |
+
$this->tags['ip'] = array(
|
63 |
+
'description' => sprintf( __( 'The visitor\'s IP address. Example: %s.', 'mailchimp-for-wp' ), '<strong>' . mc4wp_get_request_ip_address() . '</strong>' ),
|
64 |
+
'callback' => 'mc4wp_get_request_ip_address',
|
65 |
+
);
|
66 |
+
|
67 |
+
$this->tags['user'] = array(
|
68 |
+
'description' => sprintf( __( 'The property of the currently logged-in user.', 'mailchimp-for-wp' ) ),
|
69 |
+
'callback' => array( $this, 'get_user_property' ),
|
70 |
+
'example' => "user property='user_email'",
|
71 |
+
);
|
72 |
+
|
73 |
+
$this->tags['post'] = array(
|
74 |
+
'description' => sprintf( __( 'Property of the current page or post.', 'mailchimp-for-wp' ) ),
|
75 |
+
'callback' => array( $this, 'get_post_property' ),
|
76 |
+
'example' => "post property='ID'",
|
77 |
+
);
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @return array
|
82 |
+
*/
|
83 |
+
public function all() {
|
84 |
+
if ( $this->tags === array() ) {
|
85 |
+
$this->register();
|
86 |
+
}
|
87 |
+
|
88 |
+
return $this->tags;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @param array $matches
|
93 |
+
*
|
94 |
+
* @return string
|
95 |
+
*/
|
96 |
+
protected function replace_tag( array $matches ) {
|
97 |
+
$tags = $this->all();
|
98 |
+
$tag = $matches[1];
|
99 |
+
|
100 |
+
if ( isset( $tags[ $tag ] ) ) {
|
101 |
+
$config = $tags[ $tag ];
|
102 |
+
$replacement = '';
|
103 |
+
|
104 |
+
if ( isset( $config['replacement'] ) ) {
|
105 |
+
$replacement = $config['replacement'];
|
106 |
+
} elseif ( isset( $config['callback'] ) ) {
|
107 |
+
|
108 |
+
// parse attributes
|
109 |
+
$attributes = array();
|
110 |
+
if ( isset( $matches[2] ) ) {
|
111 |
+
$attribute_string = $matches[2];
|
112 |
+
$attributes = shortcode_parse_atts( $attribute_string );
|
113 |
+
}
|
114 |
+
|
115 |
+
// call function
|
116 |
+
$replacement = call_user_func( $config['callback'], $attributes );
|
117 |
+
}
|
118 |
+
|
119 |
+
if ( is_callable( $this->escape_function ) ) {
|
120 |
+
$replacement = call_user_func( $this->escape_function, $replacement );
|
121 |
+
}
|
122 |
+
|
123 |
+
return $replacement;
|
124 |
+
}
|
125 |
+
|
126 |
+
// default to not replacing it
|
127 |
+
return $matches[0];
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* @param string $string The string containing dynamic content tags.
|
132 |
+
* @param string $escape_function Escape mode for the replacement value. Leave empty for no escaping.
|
133 |
+
* @return string
|
134 |
+
*/
|
135 |
+
protected function replace( $string, $escape_function = '' ) {
|
136 |
+
$this->escape_function = $escape_function;
|
137 |
+
|
138 |
+
// replace strings like this: {tagname attr="value"}
|
139 |
+
$string = preg_replace_callback( '/\{(\w+)(\ +(?:(?!\{)[^}\n])+)*\}/', array( $this, 'replace_tag' ), $string );
|
140 |
+
|
141 |
+
// call again to take care of nested variables
|
142 |
+
$string = preg_replace_callback( '/\{(\w+)(\ +(?:(?!\{)[^}\n])+)*\}/', array( $this, 'replace_tag' ), $string );
|
143 |
+
return $string;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @param string $string
|
148 |
+
*
|
149 |
+
* @return string
|
150 |
+
*/
|
151 |
+
protected function replace_in_html( $string ) {
|
152 |
+
return $this->replace( $string, 'esc_html' );
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* @param string $string
|
157 |
+
*
|
158 |
+
* @return string
|
159 |
+
*/
|
160 |
+
protected function replace_in_attributes( $string ) {
|
161 |
+
return $this->replace( $string, 'esc_attr' );
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* @param string $string
|
166 |
+
*
|
167 |
+
* @return string
|
168 |
+
*/
|
169 |
+
protected function replace_in_url( $string ) {
|
170 |
+
return $this->replace( $string, 'urlencode' );
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Gets data variable from cookie.
|
175 |
+
*
|
176 |
+
* @param array $args
|
177 |
+
*
|
178 |
+
* @return string
|
179 |
+
*/
|
180 |
+
protected function get_cookie( $args = array() ) {
|
181 |
+
if ( empty( $args['name'] ) ) {
|
182 |
+
return '';
|
183 |
+
}
|
184 |
+
|
185 |
+
$name = $args['name'];
|
186 |
+
$default = isset( $args['default'] ) ? $args['default'] : '';
|
187 |
+
|
188 |
+
if ( isset( $_COOKIE[ $name ] ) ) {
|
189 |
+
return esc_html( stripslashes( $_COOKIE[ $name ] ) );
|
190 |
+
}
|
191 |
+
|
192 |
+
return $default;
|
193 |
+
}
|
194 |
+
|
195 |
+
/*
|
196 |
+
* Get property of currently logged-in user
|
197 |
+
*
|
198 |
+
* @param array $args
|
199 |
+
*
|
200 |
+
* @return string
|
201 |
+
*/
|
202 |
+
protected function get_user_property( $args = array() ) {
|
203 |
+
$property = empty( $args['property'] ) ? 'user_email' : $args['property'];
|
204 |
+
$default = isset( $args['default'] ) ? $args['default'] : '';
|
205 |
+
$user = wp_get_current_user();
|
206 |
+
|
207 |
+
if ( $user instanceof WP_User && isset( $user->{$property} ) ) {
|
208 |
+
return esc_html( $user->{$property} );
|
209 |
+
}
|
210 |
+
|
211 |
+
return $default;
|
212 |
+
}
|
213 |
+
|
214 |
+
/*
|
215 |
+
* Get property of viewed post
|
216 |
+
*
|
217 |
+
* @param array $args
|
218 |
+
*
|
219 |
+
* @return string
|
220 |
+
*/
|
221 |
+
protected function get_post_property( $args = array() ) {
|
222 |
+
global $post;
|
223 |
+
$property = empty( $args['property'] ) ? 'ID' : $args['property'];
|
224 |
+
$default = isset( $args['default'] ) ? $args['default'] : '';
|
225 |
+
|
226 |
+
if ( $post instanceof WP_Post && isset( $post->{$property} ) ) {
|
227 |
+
return $post->{$property};
|
228 |
+
}
|
229 |
+
|
230 |
+
return $default;
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* @return string
|
235 |
+
*/
|
236 |
+
protected function get_email() {
|
237 |
+
if ( ! empty( $_REQUEST['EMAIL'] ) ) {
|
238 |
+
return $_REQUEST['EMAIL'];
|
239 |
+
}
|
240 |
+
|
241 |
+
// then , try logged-in user
|
242 |
+
if ( is_user_logged_in() ) {
|
243 |
+
$user = wp_get_current_user();
|
244 |
+
return $user->user_email;
|
245 |
+
}
|
246 |
+
|
247 |
+
// TODO: Read from cookie? Or add $_COOKIE support to {data} tag?
|
248 |
+
return '';
|
249 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
|
251 |
}
|
includes/class-field-formatter.php
CHANGED
@@ -5,148 +5,143 @@
|
|
5 |
*
|
6 |
* Formats values based on what the Mailchimp API expects or accepts for the given field types.
|
7 |
*/
|
8 |
-
class MC4WP_Field_Formatter
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
}
|
148 |
-
|
149 |
-
// otherwise, just cast.
|
150 |
-
return (bool) $value;
|
151 |
-
}
|
152 |
}
|
5 |
*
|
6 |
* Formats values based on what the Mailchimp API expects or accepts for the given field types.
|
7 |
*/
|
8 |
+
class MC4WP_Field_Formatter {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param mixed $value
|
13 |
+
* @param object $options
|
14 |
+
* @return array
|
15 |
+
*/
|
16 |
+
public function address( $value, $options = null ) {
|
17 |
+
// auto-format if this is a string
|
18 |
+
if ( is_string( $value ) ) {
|
19 |
+
|
20 |
+
// addr1, addr2, city, state, zip, country
|
21 |
+
$address_pieces = explode( ',', $value );
|
22 |
+
$address_pieces = array_filter( $address_pieces );
|
23 |
+
$address_pieces = array_values( $address_pieces );
|
24 |
+
|
25 |
+
// try to fill it.... this is a long shot
|
26 |
+
$value = array(
|
27 |
+
'addr1' => $address_pieces[0],
|
28 |
+
'city' => isset( $address_pieces[1] ) ? $address_pieces[1] : '',
|
29 |
+
'state' => isset( $address_pieces[2] ) ? $address_pieces[2] : '',
|
30 |
+
'zip' => isset( $address_pieces[3] ) ? $address_pieces[3] : '',
|
31 |
+
);
|
32 |
+
|
33 |
+
if ( ! empty( $address_pieces[4] ) ) {
|
34 |
+
$value['country'] = $address_pieces[4];
|
35 |
+
}
|
36 |
+
} elseif ( is_array( $value ) ) {
|
37 |
+
// merge with array of empty defaults to allow skipping certain fields
|
38 |
+
$default = array_fill_keys( array( 'addr1', 'city', 'state', 'zip' ), '' );
|
39 |
+
$value = array_merge( $default, $value );
|
40 |
+
}
|
41 |
+
|
42 |
+
return $value;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @param mixed $value
|
47 |
+
* @param object $options
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
public function birthday( $value, $options = null ) {
|
51 |
+
$format = is_object( $options ) && isset( $options->date_format ) ? $options->date_format : 'MM/DD';
|
52 |
+
|
53 |
+
if ( is_array( $value ) ) {
|
54 |
+
// allow for "day" and "month" fields
|
55 |
+
if ( isset( $value['month'] ) && isset( $value['day'] ) ) {
|
56 |
+
$value = $value['month'] . '/' . $value['day'];
|
57 |
+
} else {
|
58 |
+
// if other array, just join together
|
59 |
+
$value = join( '/', $value );
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
$value = trim( $value );
|
64 |
+
if ( empty( $value ) ) {
|
65 |
+
return $value;
|
66 |
+
}
|
67 |
+
|
68 |
+
// always use slashes as delimiter, so next part works
|
69 |
+
$value = str_replace( array( '.', '-' ), '/', $value );
|
70 |
+
|
71 |
+
// if format = DD/MM OR if first part is definitely a day value (>12), then flip order
|
72 |
+
// this allows `strtotime` to understand `dd/mm` values
|
73 |
+
$values = explode( '/', $value );
|
74 |
+
if ( $format === 'DD/MM' || ( $values[0] > 12 && $values[0] <= 31 && isset( $values[1] ) && $values[1] <= 12 ) ) {
|
75 |
+
$values = array_reverse( $values );
|
76 |
+
$value = join( '/', $values );
|
77 |
+
}
|
78 |
+
|
79 |
+
// Mailchimp expects a MM/DD format, regardless of their display preference
|
80 |
+
$value = (string) gmdate( 'm/d', strtotime( $value ) );
|
81 |
+
return $value;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @param mixed $value
|
86 |
+
* @param object $options
|
87 |
+
* @return string
|
88 |
+
*/
|
89 |
+
public function date( $value, $options = null ) {
|
90 |
+
$format = is_object( $options ) && isset( $options->date_format ) ? $options->date_format : 'Y-m-d';
|
91 |
+
|
92 |
+
if ( is_array( $value ) ) {
|
93 |
+
|
94 |
+
// allow for "year", "month" and "day" keys
|
95 |
+
if ( isset( $value['year'] ) && isset( $value['month'] ) && isset( $value['day'] ) ) {
|
96 |
+
$value = $value['year'] . '/' . $value['month'] . '/' . $value['day'];
|
97 |
+
} else {
|
98 |
+
// if other array, just join together
|
99 |
+
$value = join( '/', $value );
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
$value = trim( $value );
|
104 |
+
if ( empty( $value ) ) {
|
105 |
+
return $value;
|
106 |
+
}
|
107 |
+
|
108 |
+
return (string) gmdate( $format, strtotime( $value ) );
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @param string $value
|
113 |
+
* @param object $options
|
114 |
+
* @return string
|
115 |
+
*/
|
116 |
+
public function language( $value, $options = null ) {
|
117 |
+
$value = trim( $value );
|
118 |
+
|
119 |
+
$exceptions = array(
|
120 |
+
'pt_PT',
|
121 |
+
'es_ES',
|
122 |
+
'fr_CA',
|
123 |
+
);
|
124 |
+
|
125 |
+
if ( ! in_array( $value, $exceptions, true ) ) {
|
126 |
+
$value = substr( $value, 0, 2 );
|
127 |
+
}
|
128 |
+
|
129 |
+
return $value;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* @param mixed $value
|
134 |
+
* @param object $options
|
135 |
+
* @return bool
|
136 |
+
*/
|
137 |
+
public function boolean( $value, $options = null ) {
|
138 |
+
$falsey = array( 'false', '0' );
|
139 |
+
|
140 |
+
if ( in_array( $value, $falsey, true ) ) {
|
141 |
+
return false;
|
142 |
+
}
|
143 |
+
|
144 |
+
// otherwise, just cast.
|
145 |
+
return (bool) $value;
|
146 |
+
}
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
includes/class-field-guesser.php
CHANGED
@@ -6,130 +6,125 @@
|
|
6 |
* @access private
|
7 |
* @ignore
|
8 |
*/
|
9 |
-
class MC4WP_Field_Guesser
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
return false;
|
134 |
-
}
|
135 |
}
|
6 |
* @access private
|
7 |
* @ignore
|
8 |
*/
|
9 |
+
class MC4WP_Field_Guesser {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var array
|
14 |
+
*/
|
15 |
+
protected $fields;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param array $fields
|
19 |
+
*/
|
20 |
+
public function __construct( array $fields ) {
|
21 |
+
$fields = array_change_key_case( $fields, CASE_UPPER );
|
22 |
+
$this->fields = $fields;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Get all data which is namespaced with a given namespace
|
27 |
+
*
|
28 |
+
* @param string $namespace
|
29 |
+
*
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
public function namespaced( $namespace = 'mc4wp-' ) {
|
33 |
+
$prefix = strtoupper( $namespace );
|
34 |
+
$return = array();
|
35 |
+
$length = strlen( $prefix );
|
36 |
+
|
37 |
+
foreach ( $this->fields as $key => $value ) {
|
38 |
+
if ( strpos( $key, $prefix ) === 0 ) {
|
39 |
+
$new_key = substr( $key, $length );
|
40 |
+
$return[ $new_key ] = $value;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
return $return;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Guess values for the following fields
|
49 |
+
* - EMAIL
|
50 |
+
* - NAME
|
51 |
+
* - FNAME
|
52 |
+
* - LNAME
|
53 |
+
*
|
54 |
+
* @return array
|
55 |
+
*/
|
56 |
+
public function guessed() {
|
57 |
+
$guessed = array();
|
58 |
+
|
59 |
+
foreach ( $this->fields as $field => $value ) {
|
60 |
+
|
61 |
+
// transform value into array to support 1-level arrays
|
62 |
+
$sub_fields = is_array( $value ) ? $value : array( $value );
|
63 |
+
|
64 |
+
foreach ( $sub_fields as $sub_field_value ) {
|
65 |
+
|
66 |
+
// poor man's urldecode, to get Enfold theme's contact element to work.
|
67 |
+
$sub_field_value = str_replace( '%40', '@', $sub_field_value );
|
68 |
+
|
69 |
+
// is this an email value? if so, assume it's the EMAIL field
|
70 |
+
if ( empty( $guessed['EMAIL'] ) && is_string( $sub_field_value ) && is_email( $sub_field_value ) ) {
|
71 |
+
$guessed['EMAIL'] = $sub_field_value;
|
72 |
+
continue 2;
|
73 |
+
}
|
74 |
+
|
75 |
+
// remove special characters from field name
|
76 |
+
$simple_key = str_replace( array( '-', '_', ' ' ), '', $field );
|
77 |
+
|
78 |
+
if ( empty( $guessed['FNAME'] ) && $this->string_contains( $simple_key, array( 'FIRSTNAME', 'FNAME', 'GIVENNAME', 'FORENAME' ) ) ) {
|
79 |
+
// find first name field
|
80 |
+
$guessed['FNAME'] = $sub_field_value;
|
81 |
+
} elseif ( empty( $guessed['LNAME'] ) && $this->string_contains( $simple_key, array( 'LASTNAME', 'LNAME', 'SURNAME', 'FAMILYNAME' ) ) ) {
|
82 |
+
// find last name field
|
83 |
+
$guessed['LNAME'] = $sub_field_value;
|
84 |
+
} elseif ( empty( $guessed['NAME'] ) && $this->string_contains( $simple_key, 'NAME' ) ) {
|
85 |
+
// find name field
|
86 |
+
$guessed['NAME'] = $sub_field_value;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
return $guessed;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @param $methods
|
96 |
+
*
|
97 |
+
* @return array
|
98 |
+
*/
|
99 |
+
public function combine( array $methods ) {
|
100 |
+
$combined = array();
|
101 |
+
|
102 |
+
foreach ( $methods as $method ) {
|
103 |
+
if ( method_exists( $this, $method ) ) {
|
104 |
+
$combined = array_merge( $combined, call_user_func( array( $this, $method ) ) );
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
return $combined;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @param string $haystack
|
113 |
+
* @param string|array $needles
|
114 |
+
*
|
115 |
+
* @return bool
|
116 |
+
*/
|
117 |
+
private function string_contains( $haystack, $needles ) {
|
118 |
+
if ( ! is_array( $needles ) ) {
|
119 |
+
$needles = array( $needles );
|
120 |
+
}
|
121 |
+
|
122 |
+
foreach ( $needles as $needle ) {
|
123 |
+
if ( strpos( $haystack, $needle ) !== false ) {
|
124 |
+
return true;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
return false;
|
129 |
+
}
|
|
|
|
|
|
|
|
|
|
|
130 |
}
|
includes/class-list-data-mapper.php
CHANGED
@@ -7,157 +7,156 @@
|
|
7 |
* @since 4.0
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_List_Data_Mapper
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
}
|
163 |
}
|
7 |
* @since 4.0
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_List_Data_Mapper {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
+
private $data = array();
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var array
|
20 |
+
*/
|
21 |
+
private $list_ids = array();
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var MC4WP_Field_Formatter
|
25 |
+
*/
|
26 |
+
private $formatter;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var MC4WP_MailChimp
|
30 |
+
*/
|
31 |
+
private $mailchimp;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @param array $data
|
35 |
+
* @param array $list_ids
|
36 |
+
*/
|
37 |
+
public function __construct( array $data, array $list_ids ) {
|
38 |
+
$this->data = array_change_key_case( $data, CASE_UPPER );
|
39 |
+
if ( ! isset( $this->data['EMAIL'] ) ) {
|
40 |
+
throw new InvalidArgumentException( 'Data needs at least an EMAIL key.' );
|
41 |
+
}
|
42 |
+
|
43 |
+
$this->list_ids = $list_ids;
|
44 |
+
$this->formatter = new MC4WP_Field_Formatter();
|
45 |
+
$this->mailchimp = new MC4WP_MailChimp();
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @return MC4WP_MailChimp_Subscriber[]
|
50 |
+
*/
|
51 |
+
public function map() {
|
52 |
+
$map = array();
|
53 |
+
|
54 |
+
foreach ( $this->list_ids as $list_id ) {
|
55 |
+
$map[ "$list_id" ] = $this->map_list( $list_id );
|
56 |
+
}
|
57 |
+
|
58 |
+
return $map;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @param string $list_id
|
63 |
+
* @return MC4WP_MailChimp_Subscriber
|
64 |
+
* @throws Exception
|
65 |
+
*/
|
66 |
+
protected function map_list( $list_id ) {
|
67 |
+
$subscriber = new MC4WP_MailChimp_Subscriber();
|
68 |
+
$subscriber->email_address = $this->data['EMAIL'];
|
69 |
+
|
70 |
+
// find merge fields
|
71 |
+
$merge_fields = $this->mailchimp->get_list_merge_fields( $list_id );
|
72 |
+
foreach ( $merge_fields as $merge_field ) {
|
73 |
+
|
74 |
+
// skip EMAIL field as that is handled separately (see above)
|
75 |
+
if ( $merge_field->tag === 'EMAIL' ) {
|
76 |
+
continue;
|
77 |
+
}
|
78 |
+
|
79 |
+
// use empty() here to skip empty field values
|
80 |
+
if ( empty( $this->data[ $merge_field->tag ] ) ) {
|
81 |
+
continue;
|
82 |
+
}
|
83 |
+
|
84 |
+
// format field value
|
85 |
+
$value = $this->data[ $merge_field->tag ];
|
86 |
+
$value = $this->format_merge_field_value( $merge_field, $value );
|
87 |
+
|
88 |
+
// add to map
|
89 |
+
$subscriber->merge_fields[ $merge_field->tag ] = $value;
|
90 |
+
}
|
91 |
+
|
92 |
+
// find interest categories
|
93 |
+
if ( ! empty( $this->data['INTERESTS'] ) ) {
|
94 |
+
$interest_categories = $this->mailchimp->get_list_interest_categories( $list_id );
|
95 |
+
foreach ( $interest_categories as $interest_category ) {
|
96 |
+
foreach ( $interest_category->interests as $interest_id => $interest_name ) {
|
97 |
+
// straight lookup by ID as key with value copy.
|
98 |
+
if ( isset( $this->data['INTERESTS'][ $interest_id ] ) ) {
|
99 |
+
$subscriber->interests[ $interest_id ] = $this->formatter->boolean( $this->data['INTERESTS'][ $interest_id ] );
|
100 |
+
}
|
101 |
+
|
102 |
+
// straight lookup by ID as top-level value
|
103 |
+
if ( in_array( $interest_id, $this->data['INTERESTS'], false ) ) {
|
104 |
+
$subscriber->interests[ $interest_id ] = true;
|
105 |
+
}
|
106 |
+
|
107 |
+
// look in array with category ID as key.
|
108 |
+
if ( isset( $this->data['INTERESTS'][ $interest_category->id ] ) ) {
|
109 |
+
$value = $this->data['INTERESTS'][ $interest_category->id ];
|
110 |
+
$values = is_array( $value ) ? $value : array_map( 'trim', explode( '|', $value ) );
|
111 |
+
|
112 |
+
// find by category ID + interest ID
|
113 |
+
if ( in_array( $interest_id, $values, false ) ) {
|
114 |
+
$subscriber->interests[ $interest_id ] = true;
|
115 |
+
}
|
116 |
+
|
117 |
+
// find by category ID + interest name
|
118 |
+
if ( in_array( $interest_name, $values, true ) ) {
|
119 |
+
$subscriber->interests[ $interest_id ] = true;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
// find language
|
127 |
+
/* @see http://kb.mailchimp.com/lists/managing-subscribers/view-and-edit-subscriber-languages?utm_source=mc-api&utm_medium=docs&utm_campaign=apidocs&_ga=1.211519638.2083589671.1469697070 */
|
128 |
+
if ( ! empty( $this->data['MC_LANGUAGE'] ) ) {
|
129 |
+
$subscriber->language = $this->formatter->language( $this->data['MC_LANGUAGE'] );
|
130 |
+
}
|
131 |
+
|
132 |
+
return $subscriber;
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @param object $merge_field
|
138 |
+
* @param string $value
|
139 |
+
*
|
140 |
+
* @return mixed
|
141 |
+
*/
|
142 |
+
private function format_merge_field_value( $merge_field, $value ) {
|
143 |
+
$field_type = strtolower( $merge_field->type );
|
144 |
+
|
145 |
+
if ( method_exists( $this->formatter, $field_type ) ) {
|
146 |
+
$value = call_user_func( array( $this->formatter, $field_type ), $value, $merge_field->options );
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Filters the value of a field after it is formatted.
|
151 |
+
*
|
152 |
+
* Use this to format a field value according to the field type (in Mailchimp).
|
153 |
+
*
|
154 |
+
* @since 3.0
|
155 |
+
* @param string $value The value
|
156 |
+
* @param string $field_type The type of the field (in Mailchimp)
|
157 |
+
*/
|
158 |
+
$value = apply_filters( 'mc4wp_format_field_value', $value, $field_type );
|
159 |
+
|
160 |
+
return $value;
|
161 |
+
}
|
|
|
162 |
}
|
includes/class-mailchimp-subscriber.php
CHANGED
@@ -1,66 +1,65 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class MC4WP_MailChimp_Subscriber
|
4 |
-
{
|
5 |
|
6 |
-
/**
|
7 |
-
* @var string Email address for this subscriber.
|
8 |
-
*/
|
9 |
-
public $email_address = '';
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
*/
|
56 |
-
public function to_array()
|
57 |
-
{
|
58 |
-
$array = get_object_vars($this);
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
63 |
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
66 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class MC4WP_MailChimp_Subscriber {
|
|
|
4 |
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
/**
|
7 |
+
* @var string Email address for this subscriber.
|
8 |
+
*/
|
9 |
+
public $email_address = '';
|
10 |
|
11 |
+
/**
|
12 |
+
* @var array The key of this object’s properties is the ID of the interest in question.
|
13 |
+
*/
|
14 |
+
public $interests = array();
|
15 |
|
16 |
+
/**
|
17 |
+
* @var array An individual merge var and value for a member.
|
18 |
+
*/
|
19 |
+
public $merge_fields = array();
|
20 |
|
21 |
+
/**
|
22 |
+
* @var string Subscriber’s status.
|
23 |
+
*/
|
24 |
+
public $status = 'pending';
|
25 |
|
26 |
+
/**
|
27 |
+
* @var string Type of email this member asked to get (‘html’ or ‘text’).
|
28 |
+
*/
|
29 |
+
public $email_type = 'html';
|
30 |
|
31 |
+
/**
|
32 |
+
* @var string IP address the subscriber signed up from.
|
33 |
+
*/
|
34 |
+
public $ip_signup;
|
35 |
|
36 |
+
/**
|
37 |
+
* @var string The subscriber's language
|
38 |
+
*/
|
39 |
+
public $language;
|
40 |
|
41 |
+
/**
|
42 |
+
* @var boolean VIP status for subscriber.
|
43 |
+
*/
|
44 |
+
public $vip;
|
45 |
|
46 |
+
/**
|
47 |
+
* @var array The tags applied to this member.
|
48 |
+
*/
|
49 |
+
public $tags = array();
|
|
|
|
|
|
|
|
|
50 |
|
51 |
+
/**
|
52 |
+
* Retrieves member data as an array, without null values.
|
53 |
+
*
|
54 |
+
* @return array
|
55 |
+
*/
|
56 |
+
public function to_array() {
|
57 |
+
$array = get_object_vars( $this );
|
58 |
|
59 |
+
// filter out null values
|
60 |
+
$null_values = array_filter( $array, 'is_null' );
|
61 |
+
$values = array_diff_key( $array, $null_values );
|
62 |
+
|
63 |
+
return $values;
|
64 |
+
}
|
65 |
}
|
includes/class-mailchimp.php
CHANGED
@@ -1,392 +1,416 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
|
|
|
|
|
|
4 |
* @access private
|
5 |
* @ignore
|
|
|
6 |
*/
|
7 |
-
class MC4WP_MailChimp
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Internal class for dealing with common API requests.
|
5 |
+
* Please don't use directly as this code can be subject to backwards incompatible changes.
|
6 |
+
*
|
7 |
* @access private
|
8 |
* @ignore
|
9 |
+
* @internal
|
10 |
*/
|
11 |
+
class MC4WP_MailChimp {
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
public $error_code = '';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
public $error_message = '';
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* Sends a subscription request to the Mailchimp API
|
27 |
+
*
|
28 |
+
* @param string $list_id The list id to subscribe to
|
29 |
+
* @param string $email_address The email address to subscribe
|
30 |
+
* @param array $args
|
31 |
+
* @param bool $update_existing Update information if this email is already on list?
|
32 |
+
* @param bool $replace_interests Replace interest groupings, only if update_existing is true.
|
33 |
+
* @return object
|
34 |
+
* @throws Exception
|
35 |
+
*/
|
36 |
+
public function list_subscribe( $list_id, $email_address, array $args = array(), $update_existing = false, $replace_interests = true ) {
|
37 |
+
$this->reset_error();
|
38 |
+
$default_args = array(
|
39 |
+
'status' => 'pending',
|
40 |
+
'email_address' => $email_address,
|
41 |
+
);
|
42 |
+
$existing_member_data = null;
|
43 |
+
|
44 |
+
// setup default args
|
45 |
+
$args = array_merge( $default_args, $args );
|
46 |
+
$api = $this->get_api();
|
47 |
+
|
48 |
+
// first, check if subscriber is already on the given list
|
49 |
+
try {
|
50 |
+
$existing_member_data = $api->get_list_member( $list_id, $email_address );
|
51 |
+
|
52 |
+
if ( $existing_member_data->status === 'subscribed' ) {
|
53 |
+
|
54 |
+
// if we're not supposed to update, bail.
|
55 |
+
if ( ! $update_existing ) {
|
56 |
+
$this->error_code = 214;
|
57 |
+
$this->error_message = 'That subscriber already exists.';
|
58 |
+
return null;
|
59 |
+
}
|
60 |
+
|
61 |
+
$args['status'] = 'subscribed';
|
62 |
+
|
63 |
+
// this key only exists if list actually has interests
|
64 |
+
if ( isset( $existing_member_data->interests ) ) {
|
65 |
+
$existing_interests = (array) $existing_member_data->interests;
|
66 |
+
|
67 |
+
// if replace, assume all existing interests disabled
|
68 |
+
if ( $replace_interests ) {
|
69 |
+
$existing_interests = array_fill_keys( array_keys( $existing_interests ), false );
|
70 |
+
}
|
71 |
+
|
72 |
+
// TODO: Use array_replace here (PHP 5.3+)
|
73 |
+
$new_interests = $args['interests'];
|
74 |
+
$args['interests'] = $existing_interests;
|
75 |
+
foreach ( $new_interests as $interest_id => $interest_status ) {
|
76 |
+
$args['interests'][ "{$interest_id}" ] = $interest_status;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
} elseif ( $args['status'] === 'pending' && $existing_member_data->status === 'pending' ) {
|
80 |
+
// this ensures that a new double opt-in email is send out
|
81 |
+
$api->update_list_member(
|
82 |
+
$list_id,
|
83 |
+
$email_address,
|
84 |
+
array(
|
85 |
+
'status' => 'unsubscribed',
|
86 |
+
)
|
87 |
+
);
|
88 |
+
}
|
89 |
+
} catch ( MC4WP_API_Resource_Not_Found_Exception $e ) {
|
90 |
+
// subscriber does not exist (not an issue in this case)
|
91 |
+
} catch ( MC4WP_API_Exception $e ) {
|
92 |
+
// other errors.
|
93 |
+
$this->error_code = $e->getCode();
|
94 |
+
$this->error_message = $e;
|
95 |
+
return null;
|
96 |
+
}
|
97 |
+
|
98 |
+
try {
|
99 |
+
if ( $existing_member_data ) {
|
100 |
+
$data = $api->update_list_member( $list_id, $email_address, $args );
|
101 |
+
$data->was_already_on_list = $existing_member_data->status === 'subscribed';
|
102 |
+
} else {
|
103 |
+
$data = $api->add_new_list_member( $list_id, $args );
|
104 |
+
$data->was_already_on_list = false;
|
105 |
+
}
|
106 |
+
} catch ( MC4WP_API_Exception $e ) {
|
107 |
+
$this->error_code = $e->getCode();
|
108 |
+
$this->error_message = $e;
|
109 |
+
return null;
|
110 |
+
}
|
111 |
+
|
112 |
+
return $data;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Changes the subscriber status to "unsubscribed"
|
117 |
+
*
|
118 |
+
* @param string $list_id
|
119 |
+
* @param string $email_address
|
120 |
+
*
|
121 |
+
* @return boolean
|
122 |
+
*/
|
123 |
+
public function list_unsubscribe( $list_id, $email_address ) {
|
124 |
+
$this->reset_error();
|
125 |
+
|
126 |
+
try {
|
127 |
+
$this->get_api()->update_list_member( $list_id, $email_address, array( 'status' => 'unsubscribed' ) );
|
128 |
+
} catch ( MC4WP_API_Resource_Not_Found_Exception $e ) {
|
129 |
+
// if email wasn't even on the list: great.
|
130 |
+
return true;
|
131 |
+
} catch ( MC4WP_API_Exception $e ) {
|
132 |
+
$this->error_code = $e->getCode();
|
133 |
+
$this->error_message = $e;
|
134 |
+
return false;
|
135 |
+
}
|
136 |
+
|
137 |
+
return true;
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Checks if an email address is on a given list with status "subscribed"
|
142 |
+
*
|
143 |
+
* @param string $list_id
|
144 |
+
* @param string $email_address
|
145 |
+
*
|
146 |
+
* @return boolean
|
147 |
+
* @throws Exception
|
148 |
+
*/
|
149 |
+
public function list_has_subscriber( $list_id, $email_address ) {
|
150 |
+
try {
|
151 |
+
$data = $this->get_api()->get_list_member( $list_id, $email_address );
|
152 |
+
} catch ( MC4WP_API_Resource_Not_Found_Exception $e ) {
|
153 |
+
return false;
|
154 |
+
}
|
155 |
+
|
156 |
+
return ! empty( $data->id ) && $data->status === 'subscribed';
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* @param string $list_id
|
161 |
+
* @return array
|
162 |
+
* @throws Exception
|
163 |
+
*/
|
164 |
+
public function get_list_merge_fields( $list_id ) {
|
165 |
+
$transient_key = sprintf( 'mc4wp_list_%s_mf', $list_id );
|
166 |
+
$cached = get_transient( $transient_key );
|
167 |
+
if ( is_array( $cached ) ) {
|
168 |
+
return $cached;
|
169 |
+
}
|
170 |
+
|
171 |
+
$api = $this->get_api();
|
172 |
+
|
173 |
+
try {
|
174 |
+
// fetch list merge fields
|
175 |
+
$merge_fields = $api->get_list_merge_fields(
|
176 |
+
$list_id,
|
177 |
+
array(
|
178 |
+
'count' => 100,
|
179 |
+
'fields' => 'merge_fields.name,merge_fields.tag,merge_fields.type,merge_fields.required,merge_fields.default_value,merge_fields.options,merge_fields.public',
|
180 |
+
)
|
181 |
+
);
|
182 |
+
} catch ( MC4WP_API_Exception $e ) {
|
183 |
+
return array();
|
184 |
+
}
|
185 |
+
|
186 |
+
// add EMAIL field
|
187 |
+
array_unshift(
|
188 |
+
$merge_fields,
|
189 |
+
(object) array(
|
190 |
+
'tag' => 'EMAIL',
|
191 |
+
'name' => __( 'Email address', 'mailchimp-for-wp' ),
|
192 |
+
'required' => true,
|
193 |
+
'type' => 'email',
|
194 |
+
'options' => array(),
|
195 |
+
'public' => true,
|
196 |
+
)
|
197 |
+
);
|
198 |
+
|
199 |
+
set_transient( $transient_key, $merge_fields, HOUR_IN_SECONDS * 24 );
|
200 |
+
return $merge_fields;
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* @param string $list_id
|
205 |
+
* @return array
|
206 |
+
* @throws Exception
|
207 |
+
*/
|
208 |
+
public function get_list_interest_categories( $list_id ) {
|
209 |
+
$transient_key = sprintf( 'mc4wp_list_%s_ic', $list_id );
|
210 |
+
$cached = get_transient( $transient_key );
|
211 |
+
if ( is_array( $cached ) ) {
|
212 |
+
return $cached;
|
213 |
+
}
|
214 |
+
|
215 |
+
$api = $this->get_api();
|
216 |
+
|
217 |
+
try {
|
218 |
+
// fetch list interest categories
|
219 |
+
$interest_categories = $api->get_list_interest_categories(
|
220 |
+
$list_id,
|
221 |
+
array(
|
222 |
+
'count' => 100,
|
223 |
+
'fields' => 'categories.id,categories.title,categories.type',
|
224 |
+
)
|
225 |
+
);
|
226 |
+
} catch ( MC4WP_API_Exception $e ) {
|
227 |
+
return array();
|
228 |
+
}
|
229 |
+
|
230 |
+
foreach ( $interest_categories as $interest_category ) {
|
231 |
+
$interest_category->interests = array();
|
232 |
+
|
233 |
+
try {
|
234 |
+
// fetch groups for this interest
|
235 |
+
$interests_data = $api->get_list_interest_category_interests(
|
236 |
+
$list_id,
|
237 |
+
$interest_category->id,
|
238 |
+
array(
|
239 |
+
'count' => 100,
|
240 |
+
'fields' => 'interests.id,interests.name',
|
241 |
+
)
|
242 |
+
);
|
243 |
+
foreach ( $interests_data as $interest_data ) {
|
244 |
+
$interest_category->interests[ (string) $interest_data->id ] = $interest_data->name;
|
245 |
+
}
|
246 |
+
} catch ( MC4WP_API_Exception $e ) {
|
247 |
+
// ignore
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
set_transient( $transient_key, $interest_categories, HOUR_IN_SECONDS * 24 );
|
252 |
+
return $interest_categories;
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Get Mailchimp lists, from cache or remote API.
|
257 |
+
*
|
258 |
+
* @param boolean $skip_cache Whether to force a result by hitting Mailchimp API
|
259 |
+
* @return array
|
260 |
+
*/
|
261 |
+
public function get_lists( $skip_cache = false ) {
|
262 |
+
$cache_key = 'mc4wp_mailchimp_lists';
|
263 |
+
$cached = get_transient( $cache_key );
|
264 |
+
|
265 |
+
if ( is_array( $cached ) && ! $skip_cache ) {
|
266 |
+
return $cached;
|
267 |
+
}
|
268 |
+
|
269 |
+
$lists = $this->fetch_lists();
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Filters the cache time for Mailchimp lists configuration, in seconds. Defaults to 24 hours.
|
273 |
+
*/
|
274 |
+
$cache_ttl = (int) apply_filters( 'mc4wp_lists_count_cache_time', HOUR_IN_SECONDS * 24 );
|
275 |
+
|
276 |
+
// make sure cache ttl is not lower than 60 seconds
|
277 |
+
$cache_ttl = max( 60, $cache_ttl );
|
278 |
+
set_transient( $cache_key, $lists, $cache_ttl );
|
279 |
+
return $lists;
|
280 |
+
}
|
281 |
+
|
282 |
+
private function fetch_lists() {
|
283 |
+
/**
|
284 |
+
* Filters the amount of Mailchimp lists to fetch.
|
285 |
+
*
|
286 |
+
* If you increase this, it might be necessary to increase your PHP configuration to allow for a higher max_execution_time.
|
287 |
+
*
|
288 |
+
* @param int
|
289 |
+
*/
|
290 |
+
$limit = apply_filters( 'mc4wp_mailchimp_list_limit', 200 );
|
291 |
+
|
292 |
+
try {
|
293 |
+
$lists_data = $this->get_api()->get_lists(
|
294 |
+
array(
|
295 |
+
'count' => $limit,
|
296 |
+
'fields' => 'lists.id,lists.name,lists.stats,lists.web_id',
|
297 |
+
)
|
298 |
+
);
|
299 |
+
} catch ( MC4WP_API_Exception $e ) {
|
300 |
+
return array();
|
301 |
+
}
|
302 |
+
|
303 |
+
// key by list ID
|
304 |
+
$lists = array();
|
305 |
+
foreach ( $lists_data as $list_data ) {
|
306 |
+
$lists[ "$list_data->id" ] = $list_data;
|
307 |
+
}
|
308 |
+
|
309 |
+
return $lists;
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* @param string $list_id
|
314 |
+
* @return object|null
|
315 |
+
*/
|
316 |
+
public function get_list( $list_id ) {
|
317 |
+
$lists = $this->get_lists();
|
318 |
+
return isset( $lists[ "$list_id" ] ) ? $lists[ "$list_id" ] : null;
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Fetch lists data from Mailchimp.
|
323 |
+
*/
|
324 |
+
public function refresh_lists() {
|
325 |
+
$lists = $this->get_lists( true );
|
326 |
+
|
327 |
+
foreach ( $lists as $list_id => $list ) {
|
328 |
+
$transient_key = sprintf( 'mc4wp_list_%s_mf', $list_id );
|
329 |
+
delete_transient( $transient_key );
|
330 |
+
|
331 |
+
$transient_key = sprintf( 'mc4wp_list_%s_ic', $list_id );
|
332 |
+
delete_transient( $transient_key );
|
333 |
+
}
|
334 |
+
|
335 |
+
return ! empty( $lists );
|
336 |
+
}
|
337 |
+
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Returns number of subscribers on given lists.
|
341 |
+
*
|
342 |
+
* @param array|string $list_ids Array of list ID's, or single string.
|
343 |
+
* @return int Total # subscribers for given lists.
|
344 |
+
*/
|
345 |
+
public function get_subscriber_count( $list_ids ) {
|
346 |
+
// make sure we're getting an array
|
347 |
+
if ( ! is_array( $list_ids ) ) {
|
348 |
+
$list_ids = array( $list_ids );
|
349 |
+
}
|
350 |
+
|
351 |
+
// if we got an empty array, return 0
|
352 |
+
if ( empty( $list_ids ) ) {
|
353 |
+
return 0;
|
354 |
+
}
|
355 |
+
|
356 |
+
$lists = $this->get_lists();
|
357 |
+
|
358 |
+
// start calculating subscribers count for all given list ID's combined
|
359 |
+
$count = 0;
|
360 |
+
foreach ( $list_ids as $list_id ) {
|
361 |
+
|
362 |
+
if ( ! isset( $lists[ "$list_id" ] ) ) {
|
363 |
+
continue;
|
364 |
+
}
|
365 |
+
|
366 |
+
$list = $lists[ "$list_id" ];
|
367 |
+
$count += $list->stats->member_count;
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Filters the total subscriber_count for the given List ID's.
|
372 |
+
*
|
373 |
+
* @since 2.0
|
374 |
+
* @param string $count
|
375 |
+
* @param array $list_ids
|
376 |
+
*/
|
377 |
+
return apply_filters( 'mc4wp_subscriber_count', $count, $list_ids );
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Resets error properties.
|
382 |
+
*/
|
383 |
+
public function reset_error() {
|
384 |
+
$this->error_message = '';
|
385 |
+
$this->error_code = '';
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* @return bool
|
390 |
+
*/
|
391 |
+
public function has_error() {
|
392 |
+
return ! empty( $this->error_code );
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* @return string
|
397 |
+
*/
|
398 |
+
public function get_error_message() {
|
399 |
+
return $this->error_message;
|
400 |
+
}
|
401 |
+
|
402 |
+
/**
|
403 |
+
* @return string
|
404 |
+
*/
|
405 |
+
public function get_error_code() {
|
406 |
+
return $this->error_code;
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* @return MC4WP_API_V3
|
411 |
+
* @throws Exception
|
412 |
+
*/
|
413 |
+
private function get_api() {
|
414 |
+
return mc4wp( 'api' );
|
415 |
+
}
|
416 |
}
|
includes/class-plugin.php
CHANGED
@@ -9,76 +9,71 @@
|
|
9 |
* @access public
|
10 |
* @ignore
|
11 |
*/
|
12 |
-
class MC4WP_Plugin
|
13 |
-
{
|
14 |
|
15 |
-
/**
|
16 |
-
* @var string The plugin version.
|
17 |
-
*/
|
18 |
-
protected $version;
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
public function __construct($file, $version)
|
30 |
-
{
|
31 |
-
$this->file = $file;
|
32 |
-
$this->version = $version;
|
33 |
-
}
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
}
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
}
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
{
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
|
71 |
-
|
|
|
|
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
84 |
}
|
9 |
* @access public
|
10 |
* @ignore
|
11 |
*/
|
12 |
+
class MC4WP_Plugin {
|
|
|
13 |
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
/**
|
16 |
+
* @var string The plugin version.
|
17 |
+
*/
|
18 |
+
protected $version;
|
19 |
|
20 |
+
/**
|
21 |
+
* @var string The main plugin file.
|
22 |
+
*/
|
23 |
+
protected $file;
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
/**
|
26 |
+
* @param string $file The plugin version.
|
27 |
+
* @param string $version The main plugin file.
|
28 |
+
*/
|
29 |
+
public function __construct( $file, $version ) {
|
30 |
+
$this->file = $file;
|
31 |
+
$this->version = $version;
|
32 |
+
}
|
|
|
33 |
|
34 |
+
/**
|
35 |
+
* Get the main plugin file.
|
36 |
+
*
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public function file() {
|
40 |
+
return $this->file;
|
41 |
+
}
|
|
|
42 |
|
43 |
+
/**
|
44 |
+
* Get the plugin version.
|
45 |
+
*
|
46 |
+
* @return string
|
47 |
+
*/
|
48 |
+
public function version() {
|
49 |
+
return $this->version;
|
50 |
+
}
|
|
|
51 |
|
52 |
+
/**
|
53 |
+
* Gets the directory the plugin lives in.
|
54 |
+
*
|
55 |
+
* @param string $path
|
56 |
+
*
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public function dir( $path = '' ) {
|
60 |
|
61 |
+
// ensure path has leading slash
|
62 |
+
if ( '' !== $path ) {
|
63 |
+
$path = '/' . ltrim( $path, '/' );
|
64 |
+
}
|
65 |
|
66 |
+
return dirname( $this->file ) . $path;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Gets the URL to the plugin files.
|
71 |
+
*
|
72 |
+
* @param string $path
|
73 |
+
*
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
public function url( $path = '' ) {
|
77 |
+
return plugins_url( $path, $this->file );
|
78 |
+
}
|
79 |
}
|
includes/class-queue-job.php
CHANGED
@@ -5,37 +5,36 @@
|
|
5 |
*
|
6 |
* @ignore
|
7 |
*/
|
8 |
-
class MC4WP_Queue_Job
|
9 |
-
{
|
10 |
|
11 |
-
/**
|
12 |
-
* @var string
|
13 |
-
*/
|
14 |
-
public $id;
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
41 |
}
|
5 |
*
|
6 |
* @ignore
|
7 |
*/
|
8 |
+
class MC4WP_Queue_Job {
|
|
|
9 |
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
/**
|
12 |
+
* @var string
|
13 |
+
*/
|
14 |
+
public $id;
|
15 |
|
16 |
+
/**
|
17 |
+
* @var mixed
|
18 |
+
*/
|
19 |
+
public $data;
|
20 |
|
21 |
+
/**
|
22 |
+
* @var int
|
23 |
+
*/
|
24 |
+
public $max_attempts = 1;
|
25 |
|
26 |
+
/**
|
27 |
+
* @var int
|
28 |
+
*/
|
29 |
+
public $attempts = 0;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* MC4WP_Queue_Job constructor.
|
33 |
+
*
|
34 |
+
* @param mixed $data
|
35 |
+
*/
|
36 |
+
public function __construct( $data ) {
|
37 |
+
$this->id = (string) microtime( true ) . rand( 1, 10000 );
|
38 |
+
$this->data = $data;
|
39 |
+
}
|
40 |
}
|
includes/class-queue.php
CHANGED
@@ -5,184 +5,175 @@
|
|
5 |
*
|
6 |
* @ignore
|
7 |
*/
|
8 |
-
class MC4WP_Queue
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
$success = update_option($this->option_name, $this->jobs, false);
|
181 |
-
|
182 |
-
if ($success) {
|
183 |
-
$this->dirty = false;
|
184 |
-
}
|
185 |
-
|
186 |
-
return $success;
|
187 |
-
}
|
188 |
}
|
5 |
*
|
6 |
* @ignore
|
7 |
*/
|
8 |
+
class MC4WP_Queue {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @var MC4WP_Queue_Job[]
|
13 |
+
*/
|
14 |
+
protected $jobs;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
protected $option_name;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @var bool
|
23 |
+
*/
|
24 |
+
protected $dirty = false;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* MC4WP_Ecommerce_Queue constructor.
|
28 |
+
*
|
29 |
+
* @param string $option_name
|
30 |
+
*/
|
31 |
+
public function __construct( $option_name ) {
|
32 |
+
$this->option_name = $option_name;
|
33 |
+
|
34 |
+
register_shutdown_function( array( $this, 'save' ) );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Load jobs from option
|
39 |
+
*/
|
40 |
+
protected function load() {
|
41 |
+
if ( ! is_null( $this->jobs ) ) {
|
42 |
+
return;
|
43 |
+
}
|
44 |
+
|
45 |
+
$jobs = get_option( $this->option_name, array() );
|
46 |
+
|
47 |
+
if ( ! is_array( $jobs ) ) {
|
48 |
+
$jobs = array();
|
49 |
+
} else {
|
50 |
+
$valid_jobs = array();
|
51 |
+
|
52 |
+
foreach ( $jobs as $i => $obj ) {
|
53 |
+
// filter invalid data from array
|
54 |
+
if ( ! is_object( $obj ) || empty( $obj->data ) ) {
|
55 |
+
continue;
|
56 |
+
}
|
57 |
+
|
58 |
+
// make sure each job is instance of MC4WP_Queue_Job
|
59 |
+
if ( $obj instanceof MC4WP_Queue_Job ) {
|
60 |
+
$job = $obj;
|
61 |
+
} else {
|
62 |
+
$job = new MC4WP_Queue_Job( $obj->data );
|
63 |
+
$job->id = $obj->id;
|
64 |
+
}
|
65 |
+
|
66 |
+
$valid_jobs[] = $job;
|
67 |
+
}
|
68 |
+
|
69 |
+
$jobs = $valid_jobs;
|
70 |
+
}
|
71 |
+
|
72 |
+
$this->jobs = $jobs;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Get all jobs in the queue
|
77 |
+
*
|
78 |
+
* @return MC4WP_Queue_Job[] Array of jobs
|
79 |
+
*/
|
80 |
+
public function all() {
|
81 |
+
$this->load();
|
82 |
+
return $this->jobs;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add job to queue
|
87 |
+
*
|
88 |
+
* @param mixed $data
|
89 |
+
* @return boolean
|
90 |
+
*/
|
91 |
+
public function put( $data ) {
|
92 |
+
$this->load();
|
93 |
+
|
94 |
+
// check if we already have a job with same data
|
95 |
+
foreach ( $this->jobs as $job ) {
|
96 |
+
if ( $job->data === $data ) {
|
97 |
+
return false;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
// add job to queue
|
102 |
+
$job = new MC4WP_Queue_Job( $data );
|
103 |
+
$this->jobs[] = $job;
|
104 |
+
$this->dirty = true;
|
105 |
+
return true;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Get all jobs in the queue
|
110 |
+
*
|
111 |
+
* @return MC4WP_Queue_Job|false
|
112 |
+
*/
|
113 |
+
public function get() {
|
114 |
+
$this->load();
|
115 |
+
|
116 |
+
// do we have jobs?
|
117 |
+
if ( count( $this->jobs ) === 0 ) {
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
|
121 |
+
// return first element
|
122 |
+
return reset( $this->jobs );
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* @param MC4WP_Queue_Job $job
|
127 |
+
*/
|
128 |
+
public function delete( MC4WP_Queue_Job $job ) {
|
129 |
+
$this->load();
|
130 |
+
|
131 |
+
$index = array_search( $job, $this->jobs, true );
|
132 |
+
|
133 |
+
// check for "false" here, as 0 is a valid index.
|
134 |
+
if ( $index !== false ) {
|
135 |
+
unset( $this->jobs[ $index ] );
|
136 |
+
$this->jobs = array_values( $this->jobs );
|
137 |
+
$this->dirty = true;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @param MC4WP_Queue_Job $job
|
143 |
+
*/
|
144 |
+
public function reschedule( MC4WP_Queue_Job $job ) {
|
145 |
+
$this->load();
|
146 |
+
|
147 |
+
// delete job from start of queue
|
148 |
+
$this->delete( $job );
|
149 |
+
|
150 |
+
// add job to end of queue
|
151 |
+
$this->jobs[] = $job;
|
152 |
+
$this->dirty = true;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Reset queue
|
157 |
+
*/
|
158 |
+
public function reset() {
|
159 |
+
$this->jobs = array();
|
160 |
+
$this->dirty = true;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Save the queue
|
165 |
+
*/
|
166 |
+
public function save() {
|
167 |
+
if ( ! $this->dirty || is_null( $this->jobs ) ) {
|
168 |
+
return false;
|
169 |
+
}
|
170 |
+
|
171 |
+
$success = update_option( $this->option_name, $this->jobs, false );
|
172 |
+
|
173 |
+
if ( $success ) {
|
174 |
+
$this->dirty = false;
|
175 |
+
}
|
176 |
+
|
177 |
+
return $success;
|
178 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
}
|
includes/class-tools.php
CHANGED
@@ -6,284 +6,282 @@
|
|
6 |
* @access private
|
7 |
* @ignore
|
8 |
*/
|
9 |
-
class MC4WP_Tools
|
10 |
-
{
|
11 |
|
12 |
-
/**
|
13 |
-
* @deprecated
|
14 |
-
* @param $datetime
|
15 |
-
* @param string $format
|
16 |
-
*
|
17 |
-
* @return bool|string
|
18 |
-
*/
|
19 |
-
public static function mysql_datetime_to_local_datetime($datetime, $format = '')
|
20 |
-
{
|
21 |
-
if ($format === '') {
|
22 |
-
$format = get_option('date_format') . ' ' . get_option('time_format');
|
23 |
-
}
|
24 |
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
|
|
|
|
289 |
}
|
6 |
* @access private
|
7 |
* @ignore
|
8 |
*/
|
9 |
+
class MC4WP_Tools {
|
|
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
/**
|
13 |
+
* @deprecated
|
14 |
+
* @param $datetime
|
15 |
+
* @param string $format
|
16 |
+
*
|
17 |
+
* @return bool|string
|
18 |
+
*/
|
19 |
+
public static function mysql_datetime_to_local_datetime( $datetime, $format = '' ) {
|
20 |
+
if ( $format === '' ) {
|
21 |
+
$format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
|
22 |
+
}
|
23 |
|
24 |
+
// add or subtract GMT offset to given mysql time
|
25 |
+
$local_datetime = strtotime( $datetime ) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
|
26 |
|
27 |
+
return gmdate( $format, $local_datetime );
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public static function get_countries() {
|
34 |
+
return array(
|
35 |
+
'AF' => 'Afghanistan',
|
36 |
+
'AX' => 'Aland Islands',
|
37 |
+
'AL' => 'Albania',
|
38 |
+
'DZ' => 'Algeria',
|
39 |
+
'AS' => 'American Samoa',
|
40 |
+
'AD' => 'Andorra',
|
41 |
+
'AO' => 'Angola',
|
42 |
+
'AI' => 'Anguilla',
|
43 |
+
'AQ' => 'Antarctica',
|
44 |
+
'AG' => 'Antigua and Barbuda',
|
45 |
+
'AR' => 'Argentina',
|
46 |
+
'AM' => 'Armenia',
|
47 |
+
'AW' => 'Aruba',
|
48 |
+
'AU' => 'Australia',
|
49 |
+
'AT' => 'Austria',
|
50 |
+
'AZ' => 'Azerbaijan',
|
51 |
+
'BS' => 'Bahamas',
|
52 |
+
'BH' => 'Bahrain',
|
53 |
+
'BD' => 'Bangladesh',
|
54 |
+
'BB' => 'Barbados',
|
55 |
+
'BY' => 'Belarus',
|
56 |
+
'BE' => 'Belgium',
|
57 |
+
'BZ' => 'Belize',
|
58 |
+
'BJ' => 'Benin',
|
59 |
+
'BM' => 'Bermuda',
|
60 |
+
'BT' => 'Bhutan',
|
61 |
+
'BO' => 'Bolivia',
|
62 |
+
'BQ' => 'Bonaire, Saint Eustatius and Saba',
|
63 |
+
'BA' => 'Bosnia and Herzegovina',
|
64 |
+
'BW' => 'Botswana',
|
65 |
+
'BV' => 'Bouvet Island',
|
66 |
+
'BR' => 'Brazil',
|
67 |
+
'IO' => 'British Indian Ocean Territory',
|
68 |
+
'VG' => 'British Virgin Islands',
|
69 |
+
'BN' => 'Brunei',
|
70 |
+
'BG' => 'Bulgaria',
|
71 |
+
'BF' => 'Burkina Faso',
|
72 |
+
'BI' => 'Burundi',
|
73 |
+
'KH' => 'Cambodia',
|
74 |
+
'CM' => 'Cameroon',
|
75 |
+
'CA' => 'Canada',
|
76 |
+
'CV' => 'Cape Verde',
|
77 |
+
'KY' => 'Cayman Islands',
|
78 |
+
'CF' => 'Central African Republic',
|
79 |
+
'TD' => 'Chad',
|
80 |
+
'CL' => 'Chile',
|
81 |
+
'CN' => 'China',
|
82 |
+
'CX' => 'Christmas Island',
|
83 |
+
'CC' => 'Cocos Islands',
|
84 |
+
'CO' => 'Colombia',
|
85 |
+
'KM' => 'Comoros',
|
86 |
+
'CK' => 'Cook Islands',
|
87 |
+
'CR' => 'Costa Rica',
|
88 |
+
'HR' => 'Croatia',
|
89 |
+
'CU' => 'Cuba',
|
90 |
+
'CW' => 'Curacao',
|
91 |
+
'CY' => 'Cyprus',
|
92 |
+
'CZ' => 'Czech Republic',
|
93 |
+
'CD' => 'Democratic Republic of the Congo',
|
94 |
+
'DK' => 'Denmark',
|
95 |
+
'DJ' => 'Djibouti',
|
96 |
+
'DM' => 'Dominica',
|
97 |
+
'DO' => 'Dominican Republic',
|
98 |
+
'TL' => 'East Timor',
|
99 |
+
'EC' => 'Ecuador',
|
100 |
+
'EG' => 'Egypt',
|
101 |
+
'SV' => 'El Salvador',
|
102 |
+
'GQ' => 'Equatorial Guinea',
|
103 |
+
'ER' => 'Eritrea',
|
104 |
+
'EE' => 'Estonia',
|
105 |
+
'ET' => 'Ethiopia',
|
106 |
+
'FK' => 'Falkland Islands',
|
107 |
+
'FO' => 'Faroe Islands',
|
108 |
+
'FJ' => 'Fiji',
|
109 |
+
'FI' => 'Finland',
|
110 |
+
'FR' => 'France',
|
111 |
+
'GF' => 'French Guiana',
|
112 |
+
'PF' => 'French Polynesia',
|
113 |
+
'TF' => 'French Southern Territories',
|
114 |
+
'GA' => 'Gabon',
|
115 |
+
'GM' => 'Gambia',
|
116 |
+
'GE' => 'Georgia',
|
117 |
+
'DE' => 'Germany',
|
118 |
+
'GH' => 'Ghana',
|
119 |
+
'GI' => 'Gibraltar',
|
120 |
+
'GR' => 'Greece',
|
121 |
+
'GL' => 'Greenland',
|
122 |
+
'GD' => 'Grenada',
|
123 |
+
'GP' => 'Guadeloupe',
|
124 |
+
'GU' => 'Guam',
|
125 |
+
'GT' => 'Guatemala',
|
126 |
+
'GG' => 'Guernsey',
|
127 |
+
'GN' => 'Guinea',
|
128 |
+
'GW' => 'Guinea-Bissau',
|
129 |
+
'GY' => 'Guyana',
|
130 |
+
'HT' => 'Haiti',
|
131 |
+
'HM' => 'Heard Island and McDonald Islands',
|
132 |
+
'HN' => 'Honduras',
|
133 |
+
'HK' => 'Hong Kong',
|
134 |
+
'HU' => 'Hungary',
|
135 |
+
'IS' => 'Iceland',
|
136 |
+
'IN' => 'India',
|
137 |
+
'ID' => 'Indonesia',
|
138 |
+
'IR' => 'Iran',
|
139 |
+
'IQ' => 'Iraq',
|
140 |
+
'IE' => 'Ireland',
|
141 |
+
'IM' => 'Isle of Man',
|
142 |
+
'IL' => 'Israel',
|
143 |
+
'IT' => 'Italy',
|
144 |
+
'CI' => 'Ivory Coast',
|
145 |
+
'JM' => 'Jamaica',
|
146 |
+
'JP' => 'Japan',
|
147 |
+
'JE' => 'Jersey',
|
148 |
+
'JO' => 'Jordan',
|
149 |
+
'KZ' => 'Kazakhstan',
|
150 |
+
'KE' => 'Kenya',
|
151 |
+
'KI' => 'Kiribati',
|
152 |
+
'XK' => 'Kosovo',
|
153 |
+
'KW' => 'Kuwait',
|
154 |
+
'KG' => 'Kyrgyzstan',
|
155 |
+
'LA' => 'Laos',
|
156 |
+
'LV' => 'Latvia',
|
157 |
+
'LB' => 'Lebanon',
|
158 |
+
'LS' => 'Lesotho',
|
159 |
+
'LR' => 'Liberia',
|
160 |
+
'LY' => 'Libya',
|
161 |
+
'LI' => 'Liechtenstein',
|
162 |
+
'LT' => 'Lithuania',
|
163 |
+
'LU' => 'Luxembourg',
|
164 |
+
'MO' => 'Macao',
|
165 |
+
'MK' => 'Macedonia',
|
166 |
+
'MG' => 'Madagascar',
|
167 |
+
'MW' => 'Malawi',
|
168 |
+
'MY' => 'Malaysia',
|
169 |
+
'MV' => 'Maldives',
|
170 |
+
'ML' => 'Mali',
|
171 |
+
'MT' => 'Malta',
|
172 |
+
'MH' => 'Marshall Islands',
|
173 |
+
'MQ' => 'Martinique',
|
174 |
+
'MR' => 'Mauritania',
|
175 |
+
'MU' => 'Mauritius',
|
176 |
+
'YT' => 'Mayotte',
|
177 |
+
'MX' => 'Mexico',
|
178 |
+
'FM' => 'Micronesia',
|
179 |
+
'MD' => 'Moldova',
|
180 |
+
'MC' => 'Monaco',
|
181 |
+
'MN' => 'Mongolia',
|
182 |
+
'ME' => 'Montenegro',
|
183 |
+
'MS' => 'Montserrat',
|
184 |
+
'MA' => 'Morocco',
|
185 |
+
'MZ' => 'Mozambique',
|
186 |
+
'MM' => 'Myanmar',
|
187 |
+
'NA' => 'Namibia',
|
188 |
+
'NR' => 'Nauru',
|
189 |
+
'NP' => 'Nepal',
|
190 |
+
'NL' => 'Netherlands',
|
191 |
+
'NC' => 'New Caledonia',
|
192 |
+
'NZ' => 'New Zealand',
|
193 |
+
'NI' => 'Nicaragua',
|
194 |
+
'NE' => 'Niger',
|
195 |
+
'NG' => 'Nigeria',
|
196 |
+
'NU' => 'Niue',
|
197 |
+
'NF' => 'Norfolk Island',
|
198 |
+
'KP' => 'North Korea',
|
199 |
+
'MP' => 'Northern Mariana Islands',
|
200 |
+
'NO' => 'Norway',
|
201 |
+
'OM' => 'Oman',
|
202 |
+
'PK' => 'Pakistan',
|
203 |
+
'PW' => 'Palau',
|
204 |
+
'PS' => 'Palestinian Territory',
|
205 |
+
'PA' => 'Panama',
|
206 |
+
'PG' => 'Papua New Guinea',
|
207 |
+
'PY' => 'Paraguay',
|
208 |
+
'PE' => 'Peru',
|
209 |
+
'PH' => 'Philippines',
|
210 |
+
'PN' => 'Pitcairn',
|
211 |
+
'PL' => 'Poland',
|
212 |
+
'PT' => 'Portugal',
|
213 |
+
'PR' => 'Puerto Rico',
|
214 |
+
'QA' => 'Qatar',
|
215 |
+
'CG' => 'Republic of the Congo',
|
216 |
+
'RE' => 'Reunion',
|
217 |
+
'RO' => 'Romania',
|
218 |
+
'RU' => 'Russia',
|
219 |
+
'RW' => 'Rwanda',
|
220 |
+
'BL' => 'Saint Barthelemy',
|
221 |
+
'SH' => 'Saint Helena',
|
222 |
+
'KN' => 'Saint Kitts and Nevis',
|
223 |
+
'LC' => 'Saint Lucia',
|
224 |
+
'MF' => 'Saint Martin',
|
225 |
+
'PM' => 'Saint Pierre and Miquelon',
|
226 |
+
'VC' => 'Saint Vincent and the Grenadines',
|
227 |
+
'WS' => 'Samoa',
|
228 |
+
'SM' => 'San Marino',
|
229 |
+
'ST' => 'Sao Tome and Principe',
|
230 |
+
'SA' => 'Saudi Arabia',
|
231 |
+
'SN' => 'Senegal',
|
232 |
+
'RS' => 'Serbia',
|
233 |
+
'SC' => 'Seychelles',
|
234 |
+
'SL' => 'Sierra Leone',
|
235 |
+
'SG' => 'Singapore',
|
236 |
+
'SX' => 'Sint Maarten',
|
237 |
+
'SK' => 'Slovakia',
|
238 |
+
'SI' => 'Slovenia',
|
239 |
+
'SB' => 'Solomon Islands',
|
240 |
+
'SO' => 'Somalia',
|
241 |
+
'ZA' => 'South Africa',
|
242 |
+
'GS' => 'South Georgia and the South Sandwich Islands',
|
243 |
+
'KR' => 'South Korea',
|
244 |
+
'SS' => 'South Sudan',
|
245 |
+
'ES' => 'Spain',
|
246 |
+
'LK' => 'Sri Lanka',
|
247 |
+
'SD' => 'Sudan',
|
248 |
+
'SR' => 'Suriname',
|
249 |
+
'SJ' => 'Svalbard and Jan Mayen',
|
250 |
+
'SZ' => 'Swaziland',
|
251 |
+
'SE' => 'Sweden',
|
252 |
+
'CH' => 'Switzerland',
|
253 |
+
'SY' => 'Syria',
|
254 |
+
'TW' => 'Taiwan',
|
255 |
+
'TJ' => 'Tajikistan',
|
256 |
+
'TZ' => 'Tanzania',
|
257 |
+
'TH' => 'Thailand',
|
258 |
+
'TG' => 'Togo',
|
259 |
+
'TK' => 'Tokelau',
|
260 |
+
'TO' => 'Tonga',
|
261 |
+
'TT' => 'Trinidad and Tobago',
|
262 |
+
'TN' => 'Tunisia',
|
263 |
+
'TR' => 'Turkey',
|
264 |
+
'TM' => 'Turkmenistan',
|
265 |
+
'TC' => 'Turks and Caicos Islands',
|
266 |
+
'TV' => 'Tuvalu',
|
267 |
+
'VI' => 'U.S. Virgin Islands',
|
268 |
+
'UG' => 'Uganda',
|
269 |
+
'UA' => 'Ukraine',
|
270 |
+
'AE' => 'United Arab Emirates',
|
271 |
+
'GB' => 'United Kingdom',
|
272 |
+
'US' => 'United States',
|
273 |
+
'UM' => 'United States Minor Outlying Islands',
|
274 |
+
'UY' => 'Uruguay',
|
275 |
+
'UZ' => 'Uzbekistan',
|
276 |
+
'VU' => 'Vanuatu',
|
277 |
+
'VA' => 'Vatican',
|
278 |
+
'VE' => 'Venezuela',
|
279 |
+
'VN' => 'Vietnam',
|
280 |
+
'WF' => 'Wallis and Futuna',
|
281 |
+
'EH' => 'Western Sahara',
|
282 |
+
'YE' => 'Yemen',
|
283 |
+
'ZM' => 'Zambia',
|
284 |
+
'ZW' => 'Zimbabwe',
|
285 |
+
);
|
286 |
+
}
|
287 |
}
|
includes/default-actions.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
-
add_action('mc4wp_refresh_mailchimp_lists', 'mc4wp_refresh_mailchimp_lists');
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
+
add_action( 'mc4wp_refresh_mailchimp_lists', 'mc4wp_refresh_mailchimp_lists' );
|
includes/default-filters.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
-
add_filter('mc4wp_form_data', 'mc4wp_add_name_data', 60);
|
6 |
-
add_filter('mc4wp_integration_data', 'mc4wp_add_name_data', 60);
|
7 |
|
8 |
-
add_filter('mctb_data', '_mc4wp_update_groupings_data', PHP_INT_MAX - 1);
|
9 |
-
add_filter('mc4wp_form_data', '_mc4wp_update_groupings_data', PHP_INT_MAX - 1);
|
10 |
-
add_filter('mc4wp_integration_data', '_mc4wp_update_groupings_data', PHP_INT_MAX - 1);
|
11 |
-
add_filter('mailchimp_sync_user_data', '_mc4wp_update_groupings_data', PHP_INT_MAX - 1);
|
12 |
-
add_filter('mc4wp_use_sslverify', '_mc4wp_use_sslverify', 1);
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
+
add_filter( 'mc4wp_form_data', 'mc4wp_add_name_data', 60 );
|
6 |
+
add_filter( 'mc4wp_integration_data', 'mc4wp_add_name_data', 60 );
|
7 |
|
8 |
+
add_filter( 'mctb_data', '_mc4wp_update_groupings_data', PHP_INT_MAX - 1 );
|
9 |
+
add_filter( 'mc4wp_form_data', '_mc4wp_update_groupings_data', PHP_INT_MAX - 1 );
|
10 |
+
add_filter( 'mc4wp_integration_data', '_mc4wp_update_groupings_data', PHP_INT_MAX - 1 );
|
11 |
+
add_filter( 'mailchimp_sync_user_data', '_mc4wp_update_groupings_data', PHP_INT_MAX - 1 );
|
12 |
+
add_filter( 'mc4wp_use_sslverify', '_mc4wp_use_sslverify', 1 );
|
includes/deprecated-functions.php
CHANGED
@@ -8,12 +8,11 @@
|
|
8 |
* @param array $merge_vars
|
9 |
* @return array
|
10 |
*/
|
11 |
-
function mc4wp_guess_merge_vars($merge_vars = array())
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
return $merge_vars;
|
17 |
}
|
18 |
|
19 |
/**
|
@@ -24,10 +23,9 @@ function mc4wp_guess_merge_vars($merge_vars = array())
|
|
24 |
*
|
25 |
* @use mc4wp_get_integration()
|
26 |
*/
|
27 |
-
function mc4wp_checkbox()
|
28 |
-
|
29 |
-
|
30 |
-
mc4wp_get_integration('wp-comment-form')->output_checkbox();
|
31 |
}
|
32 |
|
33 |
/**
|
@@ -43,17 +41,15 @@ function mc4wp_checkbox()
|
|
43 |
* @return string
|
44 |
*
|
45 |
*/
|
46 |
-
function mc4wp_form($id = 0, $attributes = array())
|
47 |
-
|
48 |
-
|
49 |
-
return mc4wp_show_form($id, $attributes);
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
* @deprecated 4.1.12
|
54 |
* @return string
|
55 |
*/
|
56 |
-
function mc4wp_get_current_url()
|
57 |
-
|
58 |
-
return $mc4wp_get_current_url();
|
59 |
}
|
8 |
* @param array $merge_vars
|
9 |
* @return array
|
10 |
*/
|
11 |
+
function mc4wp_guess_merge_vars( $merge_vars = array() ) {
|
12 |
+
_deprecated_function( __FUNCTION__, 'Mailchimp for WordPress v4.0' );
|
13 |
+
$merge_vars = mc4wp_add_name_data( $merge_vars );
|
14 |
+
$merge_vars = _mc4wp_update_groupings_data( $merge_vars );
|
15 |
+
return $merge_vars;
|
|
|
16 |
}
|
17 |
|
18 |
/**
|
23 |
*
|
24 |
* @use mc4wp_get_integration()
|
25 |
*/
|
26 |
+
function mc4wp_checkbox() {
|
27 |
+
_deprecated_function( __FUNCTION__, 'Mailchimp for WordPress v3.0' );
|
28 |
+
mc4wp_get_integration( 'wp-comment-form' )->output_checkbox();
|
|
|
29 |
}
|
30 |
|
31 |
/**
|
41 |
* @return string
|
42 |
*
|
43 |
*/
|
44 |
+
function mc4wp_form( $id = 0, $attributes = array() ) {
|
45 |
+
_deprecated_function( __FUNCTION__, 'Mailchimp for WordPress v3.0', 'mc4wp_show_form' );
|
46 |
+
return mc4wp_show_form( $id, $attributes );
|
|
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
* @deprecated 4.1.12
|
51 |
* @return string
|
52 |
*/
|
53 |
+
function mc4wp_get_current_url() {
|
54 |
+
return $mc4wp_get_current_url();
|
|
|
55 |
}
|
includes/forms/admin-functions.php
CHANGED
@@ -8,15 +8,14 @@
|
|
8 |
*
|
9 |
* @return string
|
10 |
*/
|
11 |
-
function mc4wp_get_edit_form_url($form_id, $tab = '')
|
12 |
-
|
13 |
-
$url = admin_url(sprintf('admin.php?page=mailchimp-for-wp-forms&view=edit-form&form_id=%d', $form_id));
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
19 |
-
|
20 |
}
|
21 |
|
22 |
/**
|
@@ -24,10 +23,9 @@ function mc4wp_get_edit_form_url($form_id, $tab = '')
|
|
24 |
*
|
25 |
* @return string
|
26 |
*/
|
27 |
-
function mc4wp_get_add_form_url()
|
28 |
-
|
29 |
-
|
30 |
-
return $url;
|
31 |
}
|
32 |
|
33 |
/**
|
8 |
*
|
9 |
* @return string
|
10 |
*/
|
11 |
+
function mc4wp_get_edit_form_url( $form_id, $tab = '' ) {
|
12 |
+
$url = admin_url( sprintf( 'admin.php?page=mailchimp-for-wp-forms&view=edit-form&form_id=%d', $form_id ) );
|
|
|
13 |
|
14 |
+
if ( ! empty( $tab ) ) {
|
15 |
+
$url .= sprintf( '&tab=%s', $tab );
|
16 |
+
}
|
17 |
|
18 |
+
return $url;
|
19 |
}
|
20 |
|
21 |
/**
|
23 |
*
|
24 |
* @return string
|
25 |
*/
|
26 |
+
function mc4wp_get_add_form_url() {
|
27 |
+
$url = admin_url( 'admin.php?page=mailchimp-for-wp-forms&view=add-form' );
|
28 |
+
return $url;
|
|
|
29 |
}
|
30 |
|
31 |
/**
|
includes/forms/class-admin.php
CHANGED
@@ -6,479 +6,471 @@
|
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
-
class MC4WP_Forms_Admin
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
$
|
283 |
-
|
284 |
-
|
285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
}
|
287 |
-
update_option('mc4wp', $options);
|
288 |
}
|
289 |
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
* @param $tab
|
441 |
-
* @return string
|
442 |
-
*/
|
443 |
-
public function tab_url($tab)
|
444 |
-
{
|
445 |
-
return add_query_arg(array( 'tab' => $tab ), remove_query_arg('tab'));
|
446 |
-
}
|
447 |
-
|
448 |
-
/**
|
449 |
-
* Registers UI for when shortcake is activated
|
450 |
-
*/
|
451 |
-
public function register_shortcake_ui()
|
452 |
-
{
|
453 |
-
$assets = new MC4WP_Form_Asset_Manager();
|
454 |
-
$assets->load_stylesheets();
|
455 |
-
|
456 |
-
$forms = mc4wp_get_forms();
|
457 |
-
$options = array();
|
458 |
-
foreach ($forms as $form) {
|
459 |
-
$options[ $form->ID ] = $form->name;
|
460 |
-
}
|
461 |
-
|
462 |
-
/**
|
463 |
-
* Register UI for your shortcode
|
464 |
-
*
|
465 |
-
* @param string $shortcode_tag
|
466 |
-
* @param array $ui_args
|
467 |
-
*/
|
468 |
-
shortcode_ui_register_for_shortcode(
|
469 |
-
'mc4wp_form',
|
470 |
-
array(
|
471 |
-
'label' => esc_html__('Mailchimp Sign-Up Form', 'mailchimp-for-wp'),
|
472 |
-
'listItemImage' => 'dashicons-feedback',
|
473 |
-
'attrs' => array(
|
474 |
-
array(
|
475 |
-
'label' => esc_html__('Select the form to show', 'mailchimp-for-wp'),
|
476 |
-
'attr' => 'id',
|
477 |
-
'type' => 'select',
|
478 |
-
'options' => $options
|
479 |
-
)
|
480 |
-
),
|
481 |
-
)
|
482 |
-
);
|
483 |
-
}
|
484 |
}
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
+
class MC4WP_Forms_Admin {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var MC4WP_Admin_Messages
|
14 |
+
*/
|
15 |
+
protected $messages;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param MC4WP_Admin_Messages $messages
|
19 |
+
*/
|
20 |
+
public function __construct( MC4WP_Admin_Messages $messages ) {
|
21 |
+
$this->messages = $messages;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Add hooks
|
26 |
+
*/
|
27 |
+
public function add_hooks() {
|
28 |
+
add_action( 'register_shortcode_ui', array( $this, 'register_shortcake_ui' ) );
|
29 |
+
add_action( 'mc4wp_save_form', array( $this, 'update_form_stylesheets' ) );
|
30 |
+
add_action( 'mc4wp_admin_edit_form', array( $this, 'process_save_form' ) );
|
31 |
+
add_action( 'mc4wp_admin_add_form', array( $this, 'process_add_form' ) );
|
32 |
+
add_filter( 'mc4wp_admin_menu_items', array( $this, 'add_menu_item' ), 5 );
|
33 |
+
add_action( 'mc4wp_admin_show_forms_page-edit-form', array( $this, 'show_edit_page' ) );
|
34 |
+
add_action( 'mc4wp_admin_show_forms_page-add-form', array( $this, 'show_add_page' ) );
|
35 |
+
add_action( 'mc4wp_admin_enqueue_assets', array( $this, 'enqueue_assets' ), 10, 2 );
|
36 |
+
|
37 |
+
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_gutenberg_assets' ) );
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
public function enqueue_gutenberg_assets() {
|
42 |
+
wp_enqueue_script( 'mc4wp-form-block', MC4WP_PLUGIN_URL . 'assets/js/forms-block.js', array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components' ) );
|
43 |
+
|
44 |
+
$forms = mc4wp_get_forms();
|
45 |
+
$data = array();
|
46 |
+
foreach ( $forms as $form ) {
|
47 |
+
$data[] = array(
|
48 |
+
'name' => $form->name,
|
49 |
+
'id' => $form->ID,
|
50 |
+
);
|
51 |
+
}
|
52 |
+
wp_localize_script( 'mc4wp-form-block', 'mc4wp_forms', $data );
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @param string $suffix
|
57 |
+
* @param string $page
|
58 |
+
*/
|
59 |
+
public function enqueue_assets( $suffix, $page = '' ) {
|
60 |
+
if ( $page !== 'forms' || empty( $_GET['view'] ) || $_GET['view'] !== 'edit-form' ) {
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
|
64 |
+
wp_register_script( 'mc4wp-forms-admin', MC4WP_PLUGIN_URL . 'assets/js/forms-admin' . $suffix . '.js', array( 'mc4wp-admin' ), MC4WP_VERSION, true );
|
65 |
+
wp_enqueue_script( 'mc4wp-forms-admin' );
|
66 |
+
wp_localize_script(
|
67 |
+
'mc4wp-forms-admin',
|
68 |
+
'mc4wp_forms_i18n',
|
69 |
+
array(
|
70 |
+
'addToForm' => __( 'Add to form', 'mailchimp-for-wp' ),
|
71 |
+
'agreeToTerms' => __( 'I have read and agree to the terms & conditions', 'mailchimp-for-wp' ),
|
72 |
+
'agreeToTermsShort' => __( 'Agree to terms', 'mailchimp-for-wp' ),
|
73 |
+
'agreeToTermsLink' => __( 'Link to your terms & conditions page', 'mailchimp-for-wp' ),
|
74 |
+
'city' => __( 'City', 'mailchimp-for-wp' ),
|
75 |
+
'checkboxes' => __( 'Checkboxes', 'mailchimp-for-wp' ),
|
76 |
+
'choices' => __( 'Choices', 'mailchimp-for-wp' ),
|
77 |
+
'choiceType' => __( 'Choice type', 'mailchimp-for-wp' ),
|
78 |
+
'chooseField' => __( 'Choose a field to add to the form', 'mailchimp-for-wp' ),
|
79 |
+
'close' => __( 'Close', 'mailchimp-for-wp' ),
|
80 |
+
'country' => __( 'Country', 'mailchimp-for-wp' ),
|
81 |
+
'dropdown' => __( 'Dropdown', 'mailchimp-for-wp' ),
|
82 |
+
'emailAddress' => __( 'Email address', 'mailchimp-for-wp' ),
|
83 |
+
'fieldType' => __( 'Field type', 'mailchimp-for-wp' ),
|
84 |
+
'fieldLabel' => __( 'Field label', 'mailchimp-for-wp' ),
|
85 |
+
'formAction' => __( 'Form action', 'mailchimp-for-wp' ),
|
86 |
+
'formActionDescription' => __( 'This field will allow your visitors to choose whether they would like to subscribe or unsubscribe', 'mailchimp-for-wp' ),
|
87 |
+
'formFields' => __( 'Form fields', 'mailchimp-for-wp' ),
|
88 |
+
'forceRequired' => __( 'This field is marked as required in Mailchimp.', 'mailchimp-for-wp' ),
|
89 |
+
'initialValue' => __( 'Initial value', 'mailchimp-for-wp' ),
|
90 |
+
'interestCategories' => __( 'Interest categories', 'mailchimp-for-wp' ),
|
91 |
+
'isFieldRequired' => __( 'Is this field required?', 'mailchimp-for-wp' ),
|
92 |
+
'listChoice' => __( 'List choice', 'mailchimp-for-wp' ),
|
93 |
+
'listChoiceDescription' => __( 'This field will allow your visitors to choose a list to subscribe to.', 'mailchimp-for-wp' ),
|
94 |
+
'listFields' => __( 'List fields', 'mailchimp-for-wp' ),
|
95 |
+
'min' => __( 'Min', 'mailchimp-for-wp' ),
|
96 |
+
'max' => __( 'Max', 'mailchimp-for-wp' ),
|
97 |
+
'noAvailableFields' => __( 'No available fields. Did you select a Mailchimp list in the form settings?', 'mailchimp-for-wp' ),
|
98 |
+
'optional' => __( 'Optional', 'mailchimp-for-wp' ),
|
99 |
+
'placeholder' => __( 'Placeholder', 'mailchimp-for-wp' ),
|
100 |
+
'placeholderHelp' => __( 'Text to show when field has no value.', 'mailchimp-for-wp' ),
|
101 |
+
'preselect' => __( 'Preselect', 'mailchimp-for-wp' ),
|
102 |
+
'remove' => __( 'Remove', 'mailchimp-for-wp' ),
|
103 |
+
'radioButtons' => __( 'Radio buttons', 'mailchimp-for-wp' ),
|
104 |
+
'streetAddress' => __( 'Street Address', 'mailchimp-for-wp' ),
|
105 |
+
'state' => __( 'State', 'mailchimp-for-wp' ),
|
106 |
+
'subscribe' => __( 'Subscribe', 'mailchimp-for-wp' ),
|
107 |
+
'submitButton' => __( 'Submit button', 'mailchimp-for-wp' ),
|
108 |
+
'wrapInParagraphTags' => __( 'Wrap in paragraph tags?', 'mailchimp-for-wp' ),
|
109 |
+
'value' => __( 'Value', 'mailchimp-for-wp' ),
|
110 |
+
'valueHelp' => __( 'Text to prefill this field with.', 'mailchimp-for-wp' ),
|
111 |
+
'zip' => __( 'ZIP', 'mailchimp-for-wp' ),
|
112 |
+
)
|
113 |
+
);
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* @param $items
|
118 |
+
*
|
119 |
+
* @return mixed
|
120 |
+
*/
|
121 |
+
public function add_menu_item( $items ) {
|
122 |
+
$items['forms'] = array(
|
123 |
+
'title' => __( 'Forms', 'mailchimp-for-wp' ),
|
124 |
+
'text' => __( 'Form', 'mailchimp-for-wp' ),
|
125 |
+
'slug' => 'forms',
|
126 |
+
'callback' => array( $this, 'show_forms_page' ),
|
127 |
+
'load_callback' => array( $this, 'redirect_to_form_action' ),
|
128 |
+
'position' => 10,
|
129 |
+
);
|
130 |
+
|
131 |
+
return $items;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Act on the "add form" form
|
136 |
+
*/
|
137 |
+
public function process_add_form() {
|
138 |
+
check_admin_referer( 'add_form', '_mc4wp_nonce' );
|
139 |
+
|
140 |
+
$form_data = $_POST['mc4wp_form'];
|
141 |
+
$form_content = include MC4WP_PLUGIN_DIR . 'config/default-form-content.php';
|
142 |
+
|
143 |
+
// Fix for MultiSite stripping KSES for roles other than administrator
|
144 |
+
remove_all_filters( 'content_save_pre' );
|
145 |
+
|
146 |
+
$form_id = wp_insert_post(
|
147 |
+
array(
|
148 |
+
'post_type' => 'mc4wp-form',
|
149 |
+
'post_status' => 'publish',
|
150 |
+
'post_title' => $form_data['name'],
|
151 |
+
'post_content' => $form_content,
|
152 |
+
)
|
153 |
+
);
|
154 |
+
|
155 |
+
// if settings were passed, save those too.
|
156 |
+
if ( isset( $form_data['settings'] ) ) {
|
157 |
+
update_post_meta( $form_id, '_mc4wp_settings', $form_data['settings'] );
|
158 |
+
}
|
159 |
+
|
160 |
+
// set default form ID
|
161 |
+
$this->set_default_form_id( $form_id );
|
162 |
+
|
163 |
+
$this->messages->flash( __( '<strong>Success!</strong> Form successfully saved.', 'mailchimp-for-wp' ) );
|
164 |
+
wp_redirect( mc4wp_get_edit_form_url( $form_id ) );
|
165 |
+
exit;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Saves a form to the database
|
170 |
+
*
|
171 |
+
* @param array $data
|
172 |
+
* @return int
|
173 |
+
*/
|
174 |
+
public function save_form( $data ) {
|
175 |
+
$keys = array(
|
176 |
+
'settings' => array(),
|
177 |
+
'messages' => array(),
|
178 |
+
'name' => '',
|
179 |
+
'content' => '',
|
180 |
+
);
|
181 |
+
|
182 |
+
$data = array_merge( $keys, $data );
|
183 |
+
$data = $this->sanitize_form_data( $data );
|
184 |
+
|
185 |
+
$post_data = array(
|
186 |
+
'post_type' => 'mc4wp-form',
|
187 |
+
'post_status' => ! empty( $data['status'] ) ? $data['status'] : 'publish',
|
188 |
+
'post_title' => $data['name'],
|
189 |
+
'post_content' => $data['content'],
|
190 |
+
);
|
191 |
+
|
192 |
+
// if an `ID` is given, make sure post is of type `mc4wp-form`
|
193 |
+
if ( ! empty( $data['ID'] ) ) {
|
194 |
+
$post = get_post( $data['ID'] );
|
195 |
+
|
196 |
+
if ( $post instanceof WP_Post && $post->post_type === 'mc4wp-form' ) {
|
197 |
+
$post_data['ID'] = $data['ID'];
|
198 |
+
|
199 |
+
// merge new settings with current settings to allow passing partial data
|
200 |
+
$current_settings = get_post_meta( $post->ID, '_mc4wp_settings', true );
|
201 |
+
if ( is_array( $current_settings ) ) {
|
202 |
+
$data['settings'] = array_merge( $current_settings, $data['settings'] );
|
203 |
+
}
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
// Fix for MultiSite stripping KSES for roles other than administrator
|
208 |
+
remove_all_filters( 'content_save_pre' );
|
209 |
+
|
210 |
+
$form_id = wp_insert_post( $post_data );
|
211 |
+
update_post_meta( $form_id, '_mc4wp_settings', $data['settings'] );
|
212 |
+
|
213 |
+
// save form messages in individual meta keys
|
214 |
+
foreach ( $data['messages'] as $key => $message ) {
|
215 |
+
update_post_meta( $form_id, 'text_' . $key, $message );
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Runs right after a form is updated.
|
220 |
+
*
|
221 |
+
* @since 3.0
|
222 |
+
*
|
223 |
+
* @param int $form_id
|
224 |
+
*/
|
225 |
+
do_action( 'mc4wp_save_form', $form_id );
|
226 |
+
|
227 |
+
return $form_id;
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* @param array $data
|
232 |
+
* @return array
|
233 |
+
*/
|
234 |
+
public function sanitize_form_data( $data ) {
|
235 |
+
$raw_data = $data;
|
236 |
+
|
237 |
+
// strip <form> tags from content
|
238 |
+
$data['content'] = preg_replace( '/<\/?form(.|\s)*?>/i', '', $data['content'] );
|
239 |
+
|
240 |
+
// replace lowercased name="name" to prevent 404
|
241 |
+
$data['content'] = str_ireplace( ' name=\"name\"', ' name=\"NAME\"', $data['content'] );
|
242 |
+
|
243 |
+
// sanitize text fields
|
244 |
+
$data['settings']['redirect'] = sanitize_text_field( $data['settings']['redirect'] );
|
245 |
+
|
246 |
+
// strip tags from messages
|
247 |
+
foreach ( $data['messages'] as $key => $message ) {
|
248 |
+
$data['messages'][ $key ] = strip_tags( $message, '<strong><b><br><a><script><u><em><i><span><img>' );
|
249 |
+
}
|
250 |
+
|
251 |
+
// make sure lists is an array
|
252 |
+
if ( ! isset( $data['settings']['lists'] ) ) {
|
253 |
+
$data['settings']['lists'] = array();
|
254 |
+
}
|
255 |
+
|
256 |
+
$data['settings']['lists'] = array_filter( (array) $data['settings']['lists'] );
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Filters the form data just before it is saved.
|
260 |
+
*
|
261 |
+
* @param array $data Sanitized array of form data.
|
262 |
+
* @param array $raw_data Raw array of form data.
|
263 |
+
*
|
264 |
+
* @since 3.0.8
|
265 |
+
* @ignore
|
266 |
+
*/
|
267 |
+
$data = (array) apply_filters( 'mc4wp_form_sanitized_data', $data, $raw_data );
|
268 |
+
|
269 |
+
return $data;
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Saves a form
|
274 |
+
*/
|
275 |
+
public function process_save_form() {
|
276 |
+
check_admin_referer( 'edit_form', '_mc4wp_nonce' );
|
277 |
+
|
278 |
+
// save global settings (if submitted)
|
279 |
+
if ( isset( $_POST['mc4wp'] ) && is_array( $_POST['mc4wp'] ) ) {
|
280 |
+
$options = get_option( 'mc4wp', array() );
|
281 |
+
$posted = $_POST['mc4wp'];
|
282 |
+
foreach ( $posted as $key => $value ) {
|
283 |
+
$options[ $key ] = trim( $value );
|
284 |
+
}
|
285 |
+
update_option( 'mc4wp', $options );
|
286 |
+
}
|
287 |
+
|
288 |
+
// save form + settings
|
289 |
+
$form_id = (int) $_POST['mc4wp_form_id'];
|
290 |
+
$form_data = $_POST['mc4wp_form'];
|
291 |
+
$form_data['ID'] = $form_id;
|
292 |
+
$this->save_form( $form_data );
|
293 |
+
$this->set_default_form_id( $form_id );
|
294 |
+
|
295 |
+
$this->messages->flash( __( '<strong>Success!</strong> Form successfully saved.', 'mailchimp-for-wp' ) );
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* @param int $form_id
|
300 |
+
*/
|
301 |
+
private function set_default_form_id( $form_id ) {
|
302 |
+
$default_form_id = (int) get_option( 'mc4wp_default_form_id', 0 );
|
303 |
+
|
304 |
+
if ( empty( $default_form_id ) ) {
|
305 |
+
update_option( 'mc4wp_default_form_id', $form_id );
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Goes through each form and aggregates array of stylesheet slugs to load.
|
311 |
+
*
|
312 |
+
* @hooked `mc4wp_save_form`
|
313 |
+
*/
|
314 |
+
public function update_form_stylesheets() {
|
315 |
+
$stylesheets = array();
|
316 |
+
|
317 |
+
$forms = mc4wp_get_forms();
|
318 |
+
foreach ( $forms as $form ) {
|
319 |
+
$stylesheet = $form->get_stylesheet();
|
320 |
+
|
321 |
+
if ( ! empty( $stylesheet ) && ! in_array( $stylesheet, $stylesheets, true ) ) {
|
322 |
+
$stylesheets[] = $stylesheet;
|
323 |
}
|
|
|
324 |
}
|
325 |
|
326 |
+
update_option( 'mc4wp_form_stylesheets', $stylesheets );
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Redirect to correct form action
|
331 |
+
*
|
332 |
+
* @ignore
|
333 |
+
*/
|
334 |
+
public function redirect_to_form_action() {
|
335 |
+
if ( ! empty( $_GET['view'] ) ) {
|
336 |
+
return;
|
337 |
+
}
|
338 |
+
|
339 |
+
try {
|
340 |
+
// try default form first
|
341 |
+
$default_form = mc4wp_get_form();
|
342 |
+
$redirect_url = mc4wp_get_edit_form_url( $default_form->ID );
|
343 |
+
} catch ( Exception $e ) {
|
344 |
+
// no default form, query first available form and go there
|
345 |
+
$forms = mc4wp_get_forms( array( 'numberposts' => 1 ) );
|
346 |
+
|
347 |
+
if ( $forms ) {
|
348 |
+
// if we have a post, go to the "edit form" screen
|
349 |
+
$form = array_pop( $forms );
|
350 |
+
$redirect_url = mc4wp_get_edit_form_url( $form->ID );
|
351 |
+
} else {
|
352 |
+
// we don't have a form yet, go to "add new" screen
|
353 |
+
$redirect_url = mc4wp_get_add_form_url();
|
354 |
+
}
|
355 |
+
}
|
356 |
+
|
357 |
+
if ( headers_sent() ) {
|
358 |
+
echo sprintf( '<meta http-equiv="refresh" content="0;url=%s" />', $redirect_url );
|
359 |
+
} else {
|
360 |
+
wp_redirect( $redirect_url );
|
361 |
+
}
|
362 |
+
|
363 |
+
exit;
|
364 |
+
}
|
365 |
+
|
366 |
+
/**
|
367 |
+
* Show the Forms Settings page
|
368 |
+
*
|
369 |
+
* @internal
|
370 |
+
*/
|
371 |
+
public function show_forms_page() {
|
372 |
+
$view = ! empty( $_GET['view'] ) ? $_GET['view'] : '';
|
373 |
+
|
374 |
+
/**
|
375 |
+
* @ignore
|
376 |
+
*/
|
377 |
+
do_action( 'mc4wp_admin_show_forms_page', $view );
|
378 |
+
|
379 |
+
/**
|
380 |
+
* @ignore
|
381 |
+
*/
|
382 |
+
do_action( 'mc4wp_admin_show_forms_page-' . $view );
|
383 |
+
}
|
384 |
+
|
385 |
+
/**
|
386 |
+
* Show the "Edit Form" page
|
387 |
+
*
|
388 |
+
* @internal
|
389 |
+
*/
|
390 |
+
public function show_edit_page() {
|
391 |
+
$form_id = ( ! empty( $_GET['form_id'] ) ) ? (int) $_GET['form_id'] : 0;
|
392 |
+
$mailchimp = new MC4WP_MailChimp();
|
393 |
+
$lists = $mailchimp->get_lists();
|
394 |
+
|
395 |
+
try {
|
396 |
+
$form = mc4wp_get_form( $form_id );
|
397 |
+
} catch ( Exception $e ) {
|
398 |
+
echo '<h2>' . __( 'Form not found.', 'mailchimp-for-wp' ) . '</h2>';
|
399 |
+
echo '<p>' . $e->getMessage() . '</p>';
|
400 |
+
echo '<p><a href="javascript:history.go(-1);"> ‹ ' . __( 'Go back', 'mailchimp-for-wp' ) . '</a></p>';
|
401 |
+
return;
|
402 |
+
}
|
403 |
+
|
404 |
+
$opts = $form->settings;
|
405 |
+
$active_tab = ( isset( $_GET['tab'] ) ) ? $_GET['tab'] : 'fields';
|
406 |
+
|
407 |
+
$form_preview_url = add_query_arg(
|
408 |
+
array(
|
409 |
+
'mc4wp_preview_form' => $form_id,
|
410 |
+
),
|
411 |
+
site_url( '/', 'admin' )
|
412 |
+
);
|
413 |
+
|
414 |
+
require dirname( __FILE__ ) . '/views/edit-form.php';
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Shows the "Add Form" page
|
419 |
+
*
|
420 |
+
* @internal
|
421 |
+
*/
|
422 |
+
public function show_add_page() {
|
423 |
+
$mailchimp = new MC4WP_MailChimp();
|
424 |
+
$lists = $mailchimp->get_lists();
|
425 |
+
$number_of_lists = count( $lists );
|
426 |
+
require dirname( __FILE__ ) . '/views/add-form.php';
|
427 |
+
}
|
428 |
+
|
429 |
+
/**
|
430 |
+
* Get URL for a tab on the current page.
|
431 |
+
*
|
432 |
+
* @since 3.0
|
433 |
+
* @internal
|
434 |
+
* @param $tab
|
435 |
+
* @return string
|
436 |
+
*/
|
437 |
+
public function tab_url( $tab ) {
|
438 |
+
return add_query_arg( array( 'tab' => $tab ), remove_query_arg( 'tab' ) );
|
439 |
+
}
|
440 |
+
|
441 |
+
/**
|
442 |
+
* Registers UI for when shortcake is activated
|
443 |
+
*/
|
444 |
+
public function register_shortcake_ui() {
|
445 |
+
$assets = new MC4WP_Form_Asset_Manager();
|
446 |
+
$assets->load_stylesheets();
|
447 |
+
|
448 |
+
$forms = mc4wp_get_forms();
|
449 |
+
$options = array();
|
450 |
+
foreach ( $forms as $form ) {
|
451 |
+
$options[ $form->ID ] = $form->name;
|
452 |
+
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
* Register UI for your shortcode
|
456 |
+
*
|
457 |
+
* @param string $shortcode_tag
|
458 |
+
* @param array $ui_args
|
459 |
+
*/
|
460 |
+
shortcode_ui_register_for_shortcode(
|
461 |
+
'mc4wp_form',
|
462 |
+
array(
|
463 |
+
'label' => esc_html__( 'Mailchimp Sign-Up Form', 'mailchimp-for-wp' ),
|
464 |
+
'listItemImage' => 'dashicons-feedback',
|
465 |
+
'attrs' => array(
|
466 |
+
array(
|
467 |
+
'label' => esc_html__( 'Select the form to show', 'mailchimp-for-wp' ),
|
468 |
+
'attr' => 'id',
|
469 |
+
'type' => 'select',
|
470 |
+
'options' => $options,
|
471 |
+
),
|
472 |
+
),
|
473 |
+
)
|
474 |
+
);
|
475 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
}
|
includes/forms/class-asset-manager.php
CHANGED
@@ -6,243 +6,231 @@
|
|
6 |
* @access private
|
7 |
* @ignore
|
8 |
*/
|
9 |
-
class MC4WP_Form_Asset_Manager
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
// print inline scripts depending on printed fields
|
237 |
-
echo '<script>';
|
238 |
-
echo '(function() {';
|
239 |
-
include dirname(__FILE__) . '/views/js/general-form-enhancements.js';
|
240 |
-
include dirname(__FILE__) . '/views/js/url-fields.js';
|
241 |
-
include dirname(__FILE__) . '/views/js/date-fields.js';
|
242 |
-
echo '})();';
|
243 |
-
echo '</script>';
|
244 |
-
|
245 |
-
/** @ignore */
|
246 |
-
do_action('mc4wp_load_form_scripts');
|
247 |
-
}
|
248 |
}
|
6 |
* @access private
|
7 |
* @ignore
|
8 |
*/
|
9 |
+
class MC4WP_Form_Asset_Manager {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var bool
|
14 |
+
*/
|
15 |
+
protected $load_scripts = false;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
protected $filename_suffix = '';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* MC4WP_Form_Asset_Manager constructor.
|
24 |
+
*/
|
25 |
+
public function __construct() {
|
26 |
+
$this->filename_suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Add hooks
|
31 |
+
*/
|
32 |
+
public function hook() {
|
33 |
+
// load checkbox css if necessary
|
34 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'load_stylesheets' ) );
|
35 |
+
add_action( 'mc4wp_output_form', array( $this, 'before_output_form' ) );
|
36 |
+
add_action( 'wp_footer', array( $this, 'load_scripts' ) );
|
37 |
+
|
38 |
+
$this->register_assets();
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Register the various JS files used by the plugin
|
43 |
+
*/
|
44 |
+
public function register_assets() {
|
45 |
+
$suffix = $this->filename_suffix;
|
46 |
+
|
47 |
+
wp_register_script( 'mc4wp-forms-api', MC4WP_PLUGIN_URL . 'assets/js/forms-api' . $this->filename_suffix . '.js', array(), MC4WP_VERSION, true );
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Runs right after all assets (scripts & stylesheets) for forms have been registered
|
51 |
+
*
|
52 |
+
* @since 3.0
|
53 |
+
* @deprecated 3.1.9
|
54 |
+
*
|
55 |
+
* @param string $suffix The suffix to add to the filename, before the file extension. Is usually set to ".min".
|
56 |
+
* @ignore
|
57 |
+
*/
|
58 |
+
do_action( 'mc4wp_register_form_assets', $suffix );
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @param string $stylesheet
|
64 |
+
*
|
65 |
+
* @return bool
|
66 |
+
*/
|
67 |
+
public function is_registered_stylesheet( $stylesheet ) {
|
68 |
+
$stylesheets = $this->get_registered_stylesheets();
|
69 |
+
return in_array( $stylesheet, $stylesheets, true );
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @return array
|
74 |
+
*/
|
75 |
+
public function get_registered_stylesheets() {
|
76 |
+
return array(
|
77 |
+
'basic',
|
78 |
+
'themes',
|
79 |
+
);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @param string $stylesheet
|
84 |
+
*
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
public function get_stylesheet_url( $stylesheet ) {
|
88 |
+
if ( ! $this->is_registered_stylesheet( $stylesheet ) ) {
|
89 |
+
return '';
|
90 |
+
}
|
91 |
+
|
92 |
+
$suffix = $this->filename_suffix;
|
93 |
+
return MC4WP_PLUGIN_URL . 'assets/css/form-' . $stylesheet . $suffix . '.css';
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Get array of stylesheet handles which should be enqueued.
|
98 |
+
*
|
99 |
+
* @return array
|
100 |
+
*/
|
101 |
+
public function get_active_stylesheets() {
|
102 |
+
$stylesheets = (array) get_option( 'mc4wp_form_stylesheets', array() );
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Filters the stylesheets to be loaded
|
106 |
+
*
|
107 |
+
* Should be an array of stylesheet handles previously registered using `wp_register_style`.
|
108 |
+
* Each value is prefixed with `mc4wp-form-` to get the handle.
|
109 |
+
*
|
110 |
+
* Return an empty array if you want to disable the loading of all stylesheets.
|
111 |
+
*
|
112 |
+
* @since 3.0
|
113 |
+
* @param array $stylesheets Array of valid stylesheet handles
|
114 |
+
*/
|
115 |
+
$stylesheets = (array) apply_filters( 'mc4wp_form_stylesheets', $stylesheets );
|
116 |
+
return $stylesheets;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Load the various stylesheets
|
121 |
+
*/
|
122 |
+
public function load_stylesheets() {
|
123 |
+
$stylesheets = $this->get_active_stylesheets();
|
124 |
+
|
125 |
+
foreach ( $stylesheets as $stylesheet ) {
|
126 |
+
if ( ! $this->is_registered_stylesheet( $stylesheet ) ) {
|
127 |
+
continue;
|
128 |
+
}
|
129 |
+
|
130 |
+
$handle = 'mc4wp-form-' . $stylesheet;
|
131 |
+
wp_enqueue_style( $handle, $this->get_stylesheet_url( $stylesheet ), array(), MC4WP_VERSION );
|
132 |
+
add_editor_style( $this->get_stylesheet_url( $stylesheet ) );
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* @ignore
|
137 |
+
*/
|
138 |
+
do_action( 'mc4wp_load_form_stylesheets', $stylesheets );
|
139 |
+
|
140 |
+
return true;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Get configuration object for client-side use.
|
145 |
+
*
|
146 |
+
* @return array
|
147 |
+
*/
|
148 |
+
public function get_javascript_config() {
|
149 |
+
$submitted_form = mc4wp_get_submitted_form();
|
150 |
+
if ( ! $submitted_form instanceof MC4WP_Form ) {
|
151 |
+
return array();
|
152 |
+
}
|
153 |
+
|
154 |
+
$config = array(
|
155 |
+
'submitted_form' => array(
|
156 |
+
'id' => $submitted_form->ID,
|
157 |
+
'event' => $submitted_form->last_event,
|
158 |
+
'data' => $submitted_form->get_data(),
|
159 |
+
'element_id' => $submitted_form->config['element_id'],
|
160 |
+
),
|
161 |
+
);
|
162 |
+
|
163 |
+
if ( $submitted_form->has_errors() ) {
|
164 |
+
$config['submitted_form']['errors'] = $submitted_form->errors;
|
165 |
+
}
|
166 |
+
|
167 |
+
$auto_scroll = true;
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Filters the `auto_scroll` setting for when a form is submitted.
|
171 |
+
* Set to false to disable scrolling to form.
|
172 |
+
*
|
173 |
+
* @param boolean $auto_scroll
|
174 |
+
* @since 3.0
|
175 |
+
*/
|
176 |
+
$config['auto_scroll'] = apply_filters( 'mc4wp_form_auto_scroll', $auto_scroll );
|
177 |
+
|
178 |
+
return $config;
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Load JavaScript files
|
183 |
+
*/
|
184 |
+
public function before_output_form() {
|
185 |
+
// print dummy JS
|
186 |
+
$this->print_dummy_javascript();
|
187 |
+
|
188 |
+
// set flags
|
189 |
+
$this->load_scripts = true;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Prints dummy JavaScript which allows people to call `mc4wp.forms.on()` before the JS is loaded.
|
194 |
+
*/
|
195 |
+
public function print_dummy_javascript() {
|
196 |
+
$file = dirname( __FILE__ ) . '/views/js/dummy-api.js';
|
197 |
+
echo '<script>';
|
198 |
+
include $file;
|
199 |
+
echo '</script>';
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Outputs the inline JavaScript that is used to enhance forms
|
204 |
+
*/
|
205 |
+
public function load_scripts() {
|
206 |
+
$load_scripts = $this->load_scripts;
|
207 |
+
|
208 |
+
/** @ignore */
|
209 |
+
$load_scripts = apply_filters( 'mc4wp_load_form_scripts', $load_scripts );
|
210 |
+
if ( ! $load_scripts ) {
|
211 |
+
return;
|
212 |
+
}
|
213 |
+
|
214 |
+
global $wp_scripts;
|
215 |
+
|
216 |
+
// make sure scripts are loaded
|
217 |
+
wp_enqueue_script( 'mc4wp-forms-api' );
|
218 |
+
wp_localize_script( 'mc4wp-forms-api', 'mc4wp_forms_config', $this->get_javascript_config() );
|
219 |
+
|
220 |
+
// load placeholder polyfill if browser is Internet Explorer
|
221 |
+
wp_enqueue_script( 'mc4wp-forms-placeholders', MC4WP_PLUGIN_URL . 'assets/js/third-party/placeholders.min.js', array(), MC4WP_VERSION, true );
|
222 |
+
$wp_scripts->add_data( 'mc4wp-forms-placeholders', 'conditional', 'lte IE 9' );
|
223 |
+
|
224 |
+
// print inline scripts depending on printed fields
|
225 |
+
echo '<script>';
|
226 |
+
echo '(function() {';
|
227 |
+
include dirname( __FILE__ ) . '/views/js/general-form-enhancements.js';
|
228 |
+
include dirname( __FILE__ ) . '/views/js/url-fields.js';
|
229 |
+
include dirname( __FILE__ ) . '/views/js/date-fields.js';
|
230 |
+
echo '})();';
|
231 |
+
echo '</script>';
|
232 |
+
|
233 |
+
/** @ignore */
|
234 |
+
do_action( 'mc4wp_load_form_scripts' );
|
235 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
}
|
includes/forms/class-form-element.php
CHANGED
@@ -7,370 +7,359 @@
|
|
7 |
* @ignore
|
8 |
* @access private
|
9 |
*/
|
10 |
-
class MC4WP_Form_Element
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
/**
|
367 |
-
* Filters `class` attributes for the `<form>` element.
|
368 |
-
*
|
369 |
-
* @param array $classes
|
370 |
-
* @param MC4WP_Form $form
|
371 |
-
*/
|
372 |
-
$classes = apply_filters('mc4wp_form_css_classes', $classes, $form);
|
373 |
-
|
374 |
-
return implode(' ', $classes);
|
375 |
-
}
|
376 |
}
|
7 |
* @ignore
|
8 |
* @access private
|
9 |
*/
|
10 |
+
class MC4WP_Form_Element {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $ID;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var MC4WP_Form
|
20 |
+
*/
|
21 |
+
public $form;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var array
|
25 |
+
*
|
26 |
+
* Can be used to set element-specific config settings. Accepts the following keys.
|
27 |
+
*
|
28 |
+
* - lists: Customized number of Mailchimp list ID's to subscribe to.
|
29 |
+
* - email_type: The email type
|
30 |
+
*/
|
31 |
+
public $config = array();
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @var bool
|
35 |
+
*/
|
36 |
+
public $is_submitted = false;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @param MC4WP_Form $form
|
40 |
+
* @param string $id
|
41 |
+
* @param array $config
|
42 |
+
*/
|
43 |
+
public function __construct( MC4WP_Form $form, $id, array $config = array() ) {
|
44 |
+
$this->form = $form;
|
45 |
+
$this->ID = $id;
|
46 |
+
$this->config = $config;
|
47 |
+
|
48 |
+
$this->is_submitted = $this->form->is_submitted
|
49 |
+
&& $this->form->config['element_id'] === $this->ID;
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @return string
|
55 |
+
*/
|
56 |
+
protected function get_visible_fields() {
|
57 |
+
$content = $this->form->content;
|
58 |
+
$form = $this->form;
|
59 |
+
$element = $this;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Filters the HTML for the form fields.
|
63 |
+
*
|
64 |
+
* Use this filter to add custom HTML to a form programmatically
|
65 |
+
*
|
66 |
+
* @param string $content
|
67 |
+
* @param MC4WP_Form $form
|
68 |
+
* @param MC4WP_Form_Element $element
|
69 |
+
* @since 2.0
|
70 |
+
*/
|
71 |
+
$visible_fields = (string) apply_filters( 'mc4wp_form_content', $content, $form, $element );
|
72 |
+
|
73 |
+
return $visible_fields;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @return string
|
78 |
+
*/
|
79 |
+
protected function get_hidden_fields() {
|
80 |
+
|
81 |
+
// hidden fields
|
82 |
+
$hidden_fields = '<label style="display: none !important;">' . __( 'Leave this field empty if you\'re human:', 'mailchimp-for-wp' ) . ' ' . '<input type="text" name="_mc4wp_honeypot" value="" tabindex="-1" autocomplete="off" /></label>';
|
83 |
+
$hidden_fields .= '<input type="hidden" name="_mc4wp_timestamp" value="' . time() . '" />';
|
84 |
+
$hidden_fields .= '<input type="hidden" name="_mc4wp_form_id" value="' . esc_attr( $this->form->ID ) . '" />';
|
85 |
+
$hidden_fields .= '<input type="hidden" name="_mc4wp_form_element_id" value="' . esc_attr( $this->ID ) . '" />';
|
86 |
+
|
87 |
+
// was "lists" parameter passed in shortcode arguments?
|
88 |
+
if ( ! empty( $this->config['lists'] ) ) {
|
89 |
+
$lists_string = is_array( $this->config['lists'] ) ? join( ',', $this->config['lists'] ) : $this->config['lists'];
|
90 |
+
$hidden_fields .= '<input type="hidden" name="_mc4wp_lists" value="' . esc_attr( $lists_string ) . '" />';
|
91 |
+
}
|
92 |
+
|
93 |
+
// was "lists" parameter passed in shortcode arguments?
|
94 |
+
if ( ! empty( $this->config['email_type'] ) ) {
|
95 |
+
$hidden_fields .= '<input type="hidden" name="_mc4wp_email_type" value="' . esc_attr( $this->config['email_type'] ) . '" />';
|
96 |
+
}
|
97 |
+
|
98 |
+
return (string) $hidden_fields;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Get HTML string for a notice, including wrapper element.
|
103 |
+
*
|
104 |
+
* @param MC4WP_Form_Notice $notice
|
105 |
+
*
|
106 |
+
* @return string
|
107 |
+
*/
|
108 |
+
protected function get_notice_html( MC4WP_Form_Notice $notice ) {
|
109 |
+
if ( $notice->text === '' ) {
|
110 |
+
return '';
|
111 |
+
}
|
112 |
+
|
113 |
+
$html = sprintf( '<div class="mc4wp-alert mc4wp-%s" role="alert"><p>%s</p></div>', esc_attr( $notice->type ), $notice->text );
|
114 |
+
return $html;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Gets the form response string
|
119 |
+
*
|
120 |
+
* @param boolean $force_show
|
121 |
+
* @return string
|
122 |
+
*/
|
123 |
+
public function get_response_html( $force_show = false ) {
|
124 |
+
$html = '';
|
125 |
+
$form = $this->form;
|
126 |
+
|
127 |
+
if ( $this->is_submitted || $force_show ) {
|
128 |
+
foreach ( $this->form->notices as $notice ) {
|
129 |
+
$html .= $this->get_notice_html( $notice );
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Filter the form response HTML
|
135 |
+
*
|
136 |
+
* Use this to add your own HTML to the form response. The form instance is passed to the callback function.
|
137 |
+
*
|
138 |
+
* @since 3.0
|
139 |
+
*
|
140 |
+
* @param string $html The complete HTML string of the response, excluding the wrapper element.
|
141 |
+
* @param MC4WP_Form $form The form object
|
142 |
+
*/
|
143 |
+
$html = (string) apply_filters( 'mc4wp_form_response_html', $html, $form );
|
144 |
+
|
145 |
+
// wrap entire response in div, regardless of a form was submitted
|
146 |
+
$html = '<div class="mc4wp-response">' . $html . '</div>';
|
147 |
+
return $html;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* @return string
|
152 |
+
*/
|
153 |
+
protected function get_response_position() {
|
154 |
+
$position = 'after';
|
155 |
+
$form = $this->form;
|
156 |
+
|
157 |
+
// check if content contains {response} tag
|
158 |
+
if ( stripos( $this->form->content, '{response}' ) !== false ) {
|
159 |
+
return '';
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Filters the position for the form response.
|
164 |
+
*
|
165 |
+
* Valid values are "before" and "after". Will have no effect if `{response}` is used in the form content.
|
166 |
+
*
|
167 |
+
* @param string $position
|
168 |
+
* @param MC4WP_Form $form
|
169 |
+
* @since 2.0
|
170 |
+
*/
|
171 |
+
$response_position = (string) apply_filters( 'mc4wp_form_response_position', $position, $form );
|
172 |
+
|
173 |
+
return $response_position;
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Get HTML to be added _before_ the HTML of the form fields.
|
178 |
+
*
|
179 |
+
* @return string
|
180 |
+
*/
|
181 |
+
protected function get_html_before_fields() {
|
182 |
+
$html = '';
|
183 |
+
$form = $this->form;
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Filters the HTML before the form fields.
|
187 |
+
*
|
188 |
+
* @param string $html
|
189 |
+
* @param MC4WP_Form $form
|
190 |
+
* @ignore
|
191 |
+
*/
|
192 |
+
$html = (string) apply_filters( 'mc4wp_form_before_fields', $html, $form );
|
193 |
+
|
194 |
+
if ( $this->get_response_position() === 'before' ) {
|
195 |
+
$html = $html . $this->get_response_html();
|
196 |
+
}
|
197 |
+
|
198 |
+
return $html;
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Get HTML to be added _after_ the HTML of the form fields.
|
203 |
+
*
|
204 |
+
* @return string
|
205 |
+
*/
|
206 |
+
protected function get_html_after_fields() {
|
207 |
+
$html = '';
|
208 |
+
$form = $this->form;
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Filters the HTML after the form fields.
|
212 |
+
*
|
213 |
+
* @param string $html
|
214 |
+
* @param MC4WP_Form $form
|
215 |
+
* @ignore
|
216 |
+
*/
|
217 |
+
$html = (string) apply_filters( 'mc4wp_form_after_fields', $html, $form );
|
218 |
+
|
219 |
+
if ( $this->get_response_position() === 'after' ) {
|
220 |
+
$html = $this->get_response_html() . $html;
|
221 |
+
}
|
222 |
+
|
223 |
+
return $html;
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Get all HTMl attributes for the form element
|
228 |
+
*
|
229 |
+
* @return string
|
230 |
+
*/
|
231 |
+
protected function get_form_element_attributes() {
|
232 |
+
$form = $this;
|
233 |
+
$form_action_attribute = null;
|
234 |
+
|
235 |
+
$attributes = array(
|
236 |
+
'id' => $this->ID,
|
237 |
+
'class' => $this->get_css_classes(),
|
238 |
+
);
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Filters the `action` attribute of the `<form>` element.
|
242 |
+
*
|
243 |
+
* Defaults to `null`, which means no `action` attribute will be printed.
|
244 |
+
*
|
245 |
+
* @param string $form_action_attribute
|
246 |
+
* @param MC4WP_Form $form
|
247 |
+
*/
|
248 |
+
$form_action_attribute = apply_filters( 'mc4wp_form_action', $form_action_attribute, $form );
|
249 |
+
if ( is_string( $form_action_attribute ) ) {
|
250 |
+
$attributes['action'] = $form_action_attribute;
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Filters all attributes to be added to the `<form>` element
|
255 |
+
*
|
256 |
+
* @param array $attributes Key-value pairs of attributes.
|
257 |
+
* @param MC4WP_Form $form
|
258 |
+
*/
|
259 |
+
$attributes = (array) apply_filters( 'mc4wp_form_element_attributes', $attributes, $form );
|
260 |
+
|
261 |
+
// hardcoded attributes, can not be changed.
|
262 |
+
$attributes['method'] = 'post';
|
263 |
+
$attributes['data-id'] = $this->form->ID;
|
264 |
+
$attributes['data-name'] = $this->form->name;
|
265 |
+
|
266 |
+
// build string of key="value" from array
|
267 |
+
$string = '';
|
268 |
+
foreach ( $attributes as $name => $value ) {
|
269 |
+
$string .= sprintf( '%s="%s" ', $name, esc_attr( $value ) );
|
270 |
+
}
|
271 |
+
|
272 |
+
return $string;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* @param array|null $config Use this to override the configuration for this form element
|
277 |
+
* @return string
|
278 |
+
*/
|
279 |
+
public function generate_html( array $config = null ) {
|
280 |
+
if ( $config ) {
|
281 |
+
$this->config = $config;
|
282 |
+
}
|
283 |
+
|
284 |
+
// return empty string if form is in trash
|
285 |
+
if ( $this->form->status !== 'publish' ) {
|
286 |
+
return '';
|
287 |
+
}
|
288 |
+
|
289 |
+
// Start building content string
|
290 |
+
$opening_html = '<!-- Mailchimp for WordPress v' . MC4WP_VERSION . ' - https://wordpress.org/plugins/mailchimp-for-wp/ -->';
|
291 |
+
$opening_html .= '<form ' . $this->get_form_element_attributes() . '>';
|
292 |
+
$before_fields = $this->get_html_before_fields();
|
293 |
+
$fields = '';
|
294 |
+
$after_fields = $this->get_html_after_fields();
|
295 |
+
$closing_html = '</form><!-- / Mailchimp for WordPress Plugin -->';
|
296 |
+
|
297 |
+
if ( ! $this->is_submitted
|
298 |
+
|| ! $this->form->settings['hide_after_success']
|
299 |
+
|| $this->form->has_errors() ) {
|
300 |
+
|
301 |
+
// add HTML for fields + wrapper element.
|
302 |
+
$fields = '<div class="mc4wp-form-fields">' .
|
303 |
+
$this->get_visible_fields() .
|
304 |
+
'</div>' .
|
305 |
+
$this->get_hidden_fields();
|
306 |
+
}
|
307 |
+
|
308 |
+
// concatenate everything
|
309 |
+
$output = $opening_html .
|
310 |
+
$before_fields .
|
311 |
+
$fields .
|
312 |
+
$after_fields .
|
313 |
+
$closing_html;
|
314 |
+
|
315 |
+
return $output;
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Get a space separated list of CSS classes for this form
|
320 |
+
*
|
321 |
+
* @return string
|
322 |
+
*/
|
323 |
+
protected function get_css_classes() {
|
324 |
+
$classes = array();
|
325 |
+
$form = $this->form;
|
326 |
+
|
327 |
+
$classes[] = 'mc4wp-form';
|
328 |
+
$classes[] = 'mc4wp-form-' . $form->ID;
|
329 |
+
|
330 |
+
// Add form classes if this specific form element was submitted
|
331 |
+
if ( $this->is_submitted ) {
|
332 |
+
$classes[] = 'mc4wp-form-submitted';
|
333 |
+
|
334 |
+
if ( ! $form->has_errors() ) {
|
335 |
+
$classes[] = 'mc4wp-form-success';
|
336 |
+
} else {
|
337 |
+
$classes[] = 'mc4wp-form-error';
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
// add class for CSS targeting in custom stylesheets
|
342 |
+
if ( ! empty( $form->settings['css'] ) ) {
|
343 |
+
if ( strpos( $form->settings['css'], 'theme-' ) === 0 ) {
|
344 |
+
$classes[] = 'mc4wp-form-theme';
|
345 |
+
}
|
346 |
+
|
347 |
+
$classes[] = 'mc4wp-form-' . $form->settings['css'];
|
348 |
+
}
|
349 |
+
|
350 |
+
// add classes from config array
|
351 |
+
if ( ! empty( $this->config['element_class'] ) ) {
|
352 |
+
$classes = array_merge( $classes, explode( ' ', $this->config['element_class'] ) );
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Filters `class` attributes for the `<form>` element.
|
357 |
+
*
|
358 |
+
* @param array $classes
|
359 |
+
* @param MC4WP_Form $form
|
360 |
+
*/
|
361 |
+
$classes = apply_filters( 'mc4wp_form_css_classes', $classes, $form );
|
362 |
+
|
363 |
+
return implode( ' ', $classes );
|
364 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
}
|
includes/forms/class-form-listener.php
CHANGED
@@ -6,322 +6,314 @@
|
|
6 |
* @since 3.0
|
7 |
* @access private
|
8 |
*/
|
9 |
-
class MC4WP_Form_Listener
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
/**
|
321 |
-
* @return MC4WP_Debug_Log
|
322 |
-
*/
|
323 |
-
protected function get_log()
|
324 |
-
{
|
325 |
-
return mc4wp('log');
|
326 |
-
}
|
327 |
}
|
6 |
* @since 3.0
|
7 |
* @access private
|
8 |
*/
|
9 |
+
class MC4WP_Form_Listener {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var MC4WP_Form The submitted form instance
|
14 |
+
*/
|
15 |
+
public $submitted_form;
|
16 |
+
|
17 |
+
public function add_hooks() {
|
18 |
+
add_action( 'init', array( $this, 'listen' ) );
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Listen for submitted forms
|
23 |
+
* @return bool
|
24 |
+
*/
|
25 |
+
public function listen() {
|
26 |
+
if ( empty( $_POST['_mc4wp_form_id'] ) ) {
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
|
30 |
+
// get form instance
|
31 |
+
try {
|
32 |
+
$form_id = (int) $_POST['_mc4wp_form_id'];
|
33 |
+
$form = mc4wp_get_form( $form_id );
|
34 |
+
} catch ( Exception $e ) {
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
|
38 |
+
// sanitize request data
|
39 |
+
$request_data = $_POST;
|
40 |
+
$request_data = mc4wp_sanitize_deep( $request_data );
|
41 |
+
$request_data = stripslashes_deep( $request_data );
|
42 |
+
|
43 |
+
// bind request to form & validate
|
44 |
+
$form->handle_request( $request_data );
|
45 |
+
$form->validate();
|
46 |
+
|
47 |
+
// store submitted form
|
48 |
+
$this->submitted_form = $form;
|
49 |
+
|
50 |
+
// did form have errors?
|
51 |
+
if ( ! $form->has_errors() ) {
|
52 |
+
switch ( $form->get_action() ) {
|
53 |
+
case 'subscribe':
|
54 |
+
$this->process_subscribe_form( $form );
|
55 |
+
break;
|
56 |
+
|
57 |
+
case 'unsubscribe':
|
58 |
+
$this->process_unsubscribe_form( $form );
|
59 |
+
break;
|
60 |
+
}
|
61 |
+
} else {
|
62 |
+
foreach ( $form->errors as $error_code ) {
|
63 |
+
$form->add_notice( $form->get_message( $error_code ), 'error' );
|
64 |
+
}
|
65 |
+
|
66 |
+
$this->get_log()->info( sprintf( 'Form %d > Submitted with errors: %s', $form->ID, join( ', ', $form->errors ) ) );
|
67 |
+
}
|
68 |
+
|
69 |
+
$this->respond( $form );
|
70 |
+
return true;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Process a subscribe form.
|
75 |
+
*
|
76 |
+
* @param MC4WP_Form $form
|
77 |
+
*/
|
78 |
+
public function process_subscribe_form( MC4WP_Form $form ) {
|
79 |
+
$result = false;
|
80 |
+
$mailchimp = new MC4WP_MailChimp();
|
81 |
+
$email_type = $form->get_email_type();
|
82 |
+
$data = $form->get_data();
|
83 |
+
$ip_address = mc4wp_get_request_ip_address();
|
84 |
+
|
85 |
+
/** @var MC4WP_MailChimp_Subscriber $subscriber */
|
86 |
+
$subscriber = null;
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @ignore
|
90 |
+
* @deprecated 4.0
|
91 |
+
*/
|
92 |
+
$data = apply_filters( 'mc4wp_merge_vars', $data );
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @ignore
|
96 |
+
* @deprecated 4.0
|
97 |
+
*/
|
98 |
+
$data = (array) apply_filters( 'mc4wp_form_merge_vars', $data, $form );
|
99 |
+
|
100 |
+
// create a map of all lists with list-specific data
|
101 |
+
$mapper = new MC4WP_List_Data_Mapper( $data, $form->get_lists() );
|
102 |
+
|
103 |
+
/** @var MC4WP_MailChimp_Subscriber[] $map */
|
104 |
+
$map = $mapper->map();
|
105 |
+
|
106 |
+
// loop through lists
|
107 |
+
foreach ( $map as $list_id => $subscriber ) {
|
108 |
+
$subscriber->status = $form->settings['double_optin'] ? 'pending' : 'subscribed';
|
109 |
+
$subscriber->email_type = $email_type;
|
110 |
+
$subscriber->ip_signup = $ip_address;
|
111 |
+
$subscriber->tags = $form->get_subscriber_tags();
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Filters subscriber data before it is sent to Mailchimp. Fires for both form & integration requests.
|
115 |
+
*
|
116 |
+
* @param MC4WP_MailChimp_Subscriber $subscriber
|
117 |
+
*/
|
118 |
+
$subscriber = apply_filters( 'mc4wp_subscriber_data', $subscriber );
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Filters subscriber data before it is sent to Mailchimp. Only fires for form requests.
|
122 |
+
*
|
123 |
+
* @param MC4WP_MailChimp_Subscriber $subscriber
|
124 |
+
*/
|
125 |
+
$subscriber = apply_filters( 'mc4wp_form_subscriber_data', $subscriber );
|
126 |
+
|
127 |
+
// send a subscribe request to Mailchimp for each list
|
128 |
+
$result = $mailchimp->list_subscribe( $list_id, $subscriber->email_address, $subscriber->to_array(), $form->settings['update_existing'], $form->settings['replace_interests'] );
|
129 |
+
}
|
130 |
+
|
131 |
+
$log = $this->get_log();
|
132 |
+
|
133 |
+
// do stuff on failure
|
134 |
+
if ( ! is_object( $result ) || empty( $result->id ) ) {
|
135 |
+
$error_code = $mailchimp->get_error_code();
|
136 |
+
$error_message = $mailchimp->get_error_message();
|
137 |
+
|
138 |
+
if ( (int) $mailchimp->get_error_code() === 214 ) {
|
139 |
+
$form->add_error( 'already_subscribed' );
|
140 |
+
$form->add_notice( $form->messages['already_subscribed'], 'notice' );
|
141 |
+
$log->warning( sprintf( 'Form %d > %s is already subscribed to the selected list(s)', $form->ID, $data['EMAIL'] ) );
|
142 |
+
} else {
|
143 |
+
$form->add_error( $error_code );
|
144 |
+
$form->add_notice( $form->messages['error'], 'error' );
|
145 |
+
$log->error( sprintf( 'Form %d > Mailchimp API error: %s %s', $form->ID, $error_code, $error_message ) );
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Fire action hook so API errors can be hooked into.
|
149 |
+
*
|
150 |
+
* @param MC4WP_Form $form
|
151 |
+
* @param string $error_message
|
152 |
+
*/
|
153 |
+
do_action( 'mc4wp_form_api_error', $form, $error_message );
|
154 |
+
}
|
155 |
+
|
156 |
+
// bail
|
157 |
+
return;
|
158 |
+
}
|
159 |
+
|
160 |
+
// Success! Did we update or newly subscribe?
|
161 |
+
if ( $result->status === 'subscribed' && $result->was_already_on_list ) {
|
162 |
+
$form->last_event = 'updated_subscriber';
|
163 |
+
$form->add_notice( $form->messages['updated'], 'success' );
|
164 |
+
$log->info( sprintf( 'Form %d > Successfully updated %s', $form->ID, $data['EMAIL'] ) );
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Fires right after a form was used to update an existing subscriber.
|
168 |
+
*
|
169 |
+
* @since 3.0
|
170 |
+
*
|
171 |
+
* @param MC4WP_Form $form Instance of the submitted form
|
172 |
+
* @param string $email
|
173 |
+
* @param array $data
|
174 |
+
*/
|
175 |
+
do_action( 'mc4wp_form_updated_subscriber', $form, $subscriber->email_address, $data );
|
176 |
+
} else {
|
177 |
+
$form->last_event = 'subscribed';
|
178 |
+
$form->add_notice( $form->messages['subscribed'], 'success' );
|
179 |
+
$log->info( sprintf( 'Form %d > Successfully subscribed %s', $form->ID, $data['EMAIL'] ) );
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Fires right after a form was used to add a new subscriber (or update an existing one).
|
184 |
+
*
|
185 |
+
* @since 3.0
|
186 |
+
*
|
187 |
+
* @param MC4WP_Form $form Instance of the submitted form
|
188 |
+
* @param string $email
|
189 |
+
* @param array $data
|
190 |
+
* @param MC4WP_MailChimp_Subscriber[] $subscriber
|
191 |
+
*/
|
192 |
+
do_action( 'mc4wp_form_subscribed', $form, $subscriber->email_address, $data, $map );
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* @param MC4WP_Form $form
|
197 |
+
*/
|
198 |
+
public function process_unsubscribe_form( MC4WP_Form $form ) {
|
199 |
+
$mailchimp = new MC4WP_MailChimp();
|
200 |
+
$log = $this->get_log();
|
201 |
+
$result = null;
|
202 |
+
$data = $form->get_data();
|
203 |
+
|
204 |
+
// unsubscribe from each list
|
205 |
+
foreach ( $form->get_lists() as $list_id ) {
|
206 |
+
$result = $mailchimp->list_unsubscribe( $list_id, $data['EMAIL'] );
|
207 |
+
}
|
208 |
+
|
209 |
+
if ( ! $result ) {
|
210 |
+
$form->add_notice( $form->messages['error'], 'error' );
|
211 |
+
$log->error( sprintf( 'Form %d > Mailchimp API error: %s', $form->ID, $mailchimp->get_error_message() ) );
|
212 |
+
|
213 |
+
// bail
|
214 |
+
return;
|
215 |
+
}
|
216 |
+
|
217 |
+
// Success! Unsubscribed.
|
218 |
+
$form->last_event = 'unsubscribed';
|
219 |
+
$form->add_notice( $form->messages['unsubscribed'], 'notice' );
|
220 |
+
$log->info( sprintf( 'Form %d > Successfully unsubscribed %s', $form->ID, $data['EMAIL'] ) );
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Fires right after a form was used to unsubscribe.
|
224 |
+
*
|
225 |
+
* @since 3.0
|
226 |
+
*
|
227 |
+
* @param MC4WP_Form $form Instance of the submitted form.
|
228 |
+
* @param string $email
|
229 |
+
*/
|
230 |
+
do_action( 'mc4wp_form_unsubscribed', $form, $data['EMAIL'] );
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* @param MC4WP_Form $form
|
235 |
+
*/
|
236 |
+
public function respond( MC4WP_Form $form ) {
|
237 |
+
$success = ! $form->has_errors();
|
238 |
+
|
239 |
+
if ( $success ) {
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Fires right after a form is submitted without any errors (success).
|
243 |
+
*
|
244 |
+
* @since 3.0
|
245 |
+
*
|
246 |
+
* @param MC4WP_Form $form Instance of the submitted form
|
247 |
+
*/
|
248 |
+
do_action( 'mc4wp_form_success', $form );
|
249 |
+
} else {
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Fires right after a form is submitted with errors.
|
253 |
+
*
|
254 |
+
* @since 3.0
|
255 |
+
*
|
256 |
+
* @param MC4WP_Form $form The submitted form instance.
|
257 |
+
*/
|
258 |
+
do_action( 'mc4wp_form_error', $form );
|
259 |
+
|
260 |
+
// fire a dedicated event for each error
|
261 |
+
foreach ( $form->errors as $error ) {
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Fires right after a form was submitted with errors.
|
265 |
+
*
|
266 |
+
* The dynamic portion of the hook, `$error`, refers to the error that occurred.
|
267 |
+
*
|
268 |
+
* Default errors give us the following possible hooks:
|
269 |
+
*
|
270 |
+
* - mc4wp_form_error_error General errors
|
271 |
+
* - mc4wp_form_error_spam
|
272 |
+
* - mc4wp_form_error_invalid_email Invalid email address
|
273 |
+
* - mc4wp_form_error_already_subscribed Email is already on selected list(s)
|
274 |
+
* - mc4wp_form_error_required_field_missing One or more required fields are missing
|
275 |
+
* - mc4wp_form_error_no_lists_selected No Mailchimp lists were selected
|
276 |
+
*
|
277 |
+
* @since 3.0
|
278 |
+
*
|
279 |
+
* @param MC4WP_Form $form The form instance of the submitted form.
|
280 |
+
*/
|
281 |
+
do_action( 'mc4wp_form_error_' . $error, $form );
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Fires right before responding to the form request.
|
287 |
+
*
|
288 |
+
* @since 3.0
|
289 |
+
*
|
290 |
+
* @param MC4WP_Form $form Instance of the submitted form.
|
291 |
+
*/
|
292 |
+
do_action( 'mc4wp_form_respond', $form );
|
293 |
+
|
294 |
+
// do stuff on success (non-AJAX only)
|
295 |
+
if ( $success && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
|
296 |
+
|
297 |
+
// do we want to redirect?
|
298 |
+
$redirect_url = $form->get_redirect_url();
|
299 |
+
if ( ! empty( $redirect_url ) ) {
|
300 |
+
wp_redirect( $redirect_url );
|
301 |
+
exit;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* @return MC4WP_API_V3
|
308 |
+
*/
|
309 |
+
protected function get_api() {
|
310 |
+
return mc4wp( 'api' );
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* @return MC4WP_Debug_Log
|
315 |
+
*/
|
316 |
+
protected function get_log() {
|
317 |
+
return mc4wp( 'log' );
|
318 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
}
|
includes/forms/class-form-manager.php
CHANGED
@@ -9,150 +9,143 @@
|
|
9 |
* @ignore
|
10 |
* @access private
|
11 |
*/
|
12 |
-
class MC4WP_Form_Manager
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
*
|
152 |
-
* @return array
|
153 |
-
*/
|
154 |
-
public function get_tags()
|
155 |
-
{
|
156 |
-
return $this->tags->all();
|
157 |
-
}
|
158 |
}
|
9 |
* @ignore
|
10 |
* @access private
|
11 |
*/
|
12 |
+
class MC4WP_Form_Manager {
|
13 |
+
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @var MC4WP_Form_Output_Manager
|
17 |
+
*/
|
18 |
+
protected $output_manager;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var MC4WP_Form_Listener
|
22 |
+
*/
|
23 |
+
protected $listener;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var MC4WP_Form_Tags
|
27 |
+
*/
|
28 |
+
protected $tags;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var MC4WP_Form_Previewer
|
32 |
+
*/
|
33 |
+
protected $previewer;
|
34 |
+
|
35 |
+
protected $recaptcha;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Constructor
|
39 |
+
*/
|
40 |
+
public function __construct() {
|
41 |
+
$this->output_manager = new MC4WP_Form_Output_Manager();
|
42 |
+
$this->tags = new MC4WP_Form_Tags();
|
43 |
+
$this->listener = new MC4WP_Form_Listener();
|
44 |
+
$this->previewer = new MC4WP_Form_Previewer();
|
45 |
+
$this->recaptcha = new MC4WP_Google_Recaptcha();
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Hook!
|
50 |
+
*/
|
51 |
+
public function add_hooks() {
|
52 |
+
add_action( 'init', array( $this, 'initialize' ) );
|
53 |
+
add_action( 'wp', array( $this, 'init_asset_manager' ), 90 );
|
54 |
+
add_action( 'widgets_init', array( $this, 'register_widget' ) );
|
55 |
+
|
56 |
+
$this->listener->add_hooks();
|
57 |
+
$this->output_manager->add_hooks();
|
58 |
+
$this->tags->add_hooks();
|
59 |
+
$this->previewer->add_hooks();
|
60 |
+
$this->recaptcha->add_hooks();
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Initialize
|
65 |
+
*/
|
66 |
+
public function initialize() {
|
67 |
+
$this->register_post_type();
|
68 |
+
$this->register_block_type();
|
69 |
+
}
|
70 |
+
|
71 |
+
private function register_block_type() {
|
72 |
+
// Bail if register_block_type does not exist (available since WP 5.0)
|
73 |
+
if ( ! function_exists( 'register_block_type' ) ) {
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
register_block_type(
|
78 |
+
'mailchimp-for-wp/form',
|
79 |
+
array(
|
80 |
+
'render_callback' => array( $this->output_manager, 'shortcode' ),
|
81 |
+
)
|
82 |
+
);
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Register post type "mc4wp-form"
|
87 |
+
*/
|
88 |
+
private function register_post_type() {
|
89 |
+
// register post type
|
90 |
+
register_post_type(
|
91 |
+
'mc4wp-form',
|
92 |
+
array(
|
93 |
+
'labels' => array(
|
94 |
+
'name' => 'Mailchimp Sign-up Forms',
|
95 |
+
'singular_name' => 'Sign-up Form',
|
96 |
+
),
|
97 |
+
'public' => false,
|
98 |
+
)
|
99 |
+
);
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Initialise asset manager
|
104 |
+
*
|
105 |
+
* @hooked `template_redirect`
|
106 |
+
*/
|
107 |
+
public function init_asset_manager() {
|
108 |
+
$assets = new MC4WP_Form_Asset_Manager();
|
109 |
+
$assets->hook();
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Register our Form widget
|
114 |
+
*/
|
115 |
+
public function register_widget() {
|
116 |
+
register_widget( 'MC4WP_Form_Widget' );
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* @param $form_id
|
121 |
+
* @param array $config
|
122 |
+
* @param bool $echo
|
123 |
+
*
|
124 |
+
* @return string
|
125 |
+
*/
|
126 |
+
public function output_form( $form_id, $config = array(), $echo = true ) {
|
127 |
+
return $this->output_manager->output_form( $form_id, $config, $echo );
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Gets the currently submitted form
|
132 |
+
*
|
133 |
+
* @return MC4WP_Form|null
|
134 |
+
*/
|
135 |
+
public function get_submitted_form() {
|
136 |
+
if ( $this->listener->submitted_form instanceof MC4WP_Form ) {
|
137 |
+
return $this->listener->submitted_form;
|
138 |
+
}
|
139 |
+
|
140 |
+
return null;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Return all tags
|
145 |
+
*
|
146 |
+
* @return array
|
147 |
+
*/
|
148 |
+
public function get_tags() {
|
149 |
+
return $this->tags->all();
|
150 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
includes/forms/class-form-message.php
CHANGED
@@ -6,37 +6,35 @@
|
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
-
class MC4WP_Form_Notice
|
10 |
-
{
|
11 |
|
12 |
-
/**
|
13 |
-
* @var string
|
14 |
-
*/
|
15 |
-
public $type = 'error';
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
public function __construct($text, $type = 'error')
|
27 |
-
{
|
28 |
-
$this->text = $text;
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
42 |
}
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
+
class MC4WP_Form_Notice {
|
|
|
10 |
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
/**
|
13 |
+
* @var string
|
14 |
+
*/
|
15 |
+
public $type = 'error';
|
16 |
|
17 |
+
/**
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
public $text;
|
|
|
|
|
|
|
21 |
|
22 |
+
/**
|
23 |
+
* @param string $text
|
24 |
+
* @param string $type
|
25 |
+
*/
|
26 |
+
public function __construct( $text, $type = 'error' ) {
|
27 |
+
$this->text = $text;
|
28 |
|
29 |
+
if ( ! empty( $type ) ) {
|
30 |
+
$this->type = $type;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @return string
|
36 |
+
*/
|
37 |
+
public function __toString() {
|
38 |
+
return $this->text;
|
39 |
+
}
|
40 |
}
|
includes/forms/class-form-previewer.php
CHANGED
@@ -1,40 +1,37 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class MC4WP_Form_Previewer
|
4 |
-
{
|
5 |
-
public function add_hooks()
|
6 |
-
{
|
7 |
-
add_action('parse_request', array( $this, 'listen' ));
|
8 |
-
}
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
return;
|
14 |
-
}
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
}
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
}
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class MC4WP_Form_Previewer {
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
public function add_hooks() {
|
6 |
+
add_action( 'parse_request', array( $this, 'listen' ) );
|
7 |
+
}
|
|
|
|
|
8 |
|
9 |
+
public function listen() {
|
10 |
+
if ( empty( $_GET['mc4wp_preview_form'] ) ) {
|
11 |
+
return;
|
12 |
+
}
|
|
|
13 |
|
14 |
+
try {
|
15 |
+
$form = mc4wp_get_form( $_GET['mc4wp_preview_form'] );
|
16 |
+
} catch ( Exception $e ) {
|
17 |
+
return;
|
18 |
+
}
|
19 |
|
20 |
+
show_admin_bar( false );
|
21 |
+
add_filter( 'pre_handle_404', '__return_true' );
|
22 |
+
remove_all_actions( 'template_redirect' );
|
23 |
+
add_action( 'template_redirect', array( $this, 'load_preview' ) );
|
24 |
+
}
|
|
|
25 |
|
26 |
+
public function load_preview() {
|
27 |
+
// clear output, some plugin or hooked code might have thrown errors by now.
|
28 |
+
if ( ob_get_level() > 0 ) {
|
29 |
+
ob_end_clean();
|
30 |
+
}
|
31 |
+
|
32 |
+
$form_id = (int) $_GET['mc4wp_preview_form'];
|
33 |
+
status_header( 200 );
|
34 |
+
require dirname( __FILE__ ) . '/views/preview.php';
|
35 |
+
exit;
|
36 |
+
}
|
37 |
}
|
includes/forms/class-form-tags.php
CHANGED
@@ -6,126 +6,118 @@
|
|
6 |
* @access private
|
7 |
* @ignore
|
8 |
*/
|
9 |
-
class MC4WP_Form_Tags extends MC4WP_Dynamic_Content_Tags
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
// turn array into readable value
|
122 |
-
if (is_array($value)) {
|
123 |
-
$value = array_filter($value);
|
124 |
-
$value = join(', ', $value);
|
125 |
-
}
|
126 |
-
|
127 |
-
return esc_html($value);
|
128 |
-
}
|
129 |
|
130 |
|
131 |
}
|
6 |
* @access private
|
7 |
* @ignore
|
8 |
*/
|
9 |
+
class MC4WP_Form_Tags extends MC4WP_Dynamic_Content_Tags {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @var MC4WP_Form
|
13 |
+
*/
|
14 |
+
protected $form;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var MC4WP_Form_Element
|
18 |
+
*/
|
19 |
+
protected $form_element;
|
20 |
+
|
21 |
+
public function add_hooks() {
|
22 |
+
add_filter( 'mc4wp_form_response_html', array( $this, 'replace_in_form_response' ), 10, 2 );
|
23 |
+
add_filter( 'mc4wp_form_content', array( $this, 'replace_in_form_content' ), 10, 3 );
|
24 |
+
add_filter( 'mc4wp_form_redirect_url', array( $this, 'replace_in_form_redirect_url' ), 10, 2 );
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Register template tags
|
29 |
+
*/
|
30 |
+
public function register() {
|
31 |
+
parent::register();
|
32 |
+
|
33 |
+
$this->tags['response'] = array(
|
34 |
+
'description' => __( 'Replaced with the form response (error or success messages).', 'mailchimp-for-wp' ),
|
35 |
+
'callback' => array( $this, 'get_form_response' ),
|
36 |
+
);
|
37 |
+
|
38 |
+
$this->tags['data'] = array(
|
39 |
+
'description' => sprintf( __( 'Data from the URL or a submitted form.', 'mailchimp-for-wp' ) ),
|
40 |
+
'callback' => array( $this, 'get_data' ),
|
41 |
+
'example' => "data key='UTM_SOURCE' default='Default Source'",
|
42 |
+
);
|
43 |
+
|
44 |
+
$this->tags['subscriber_count'] = array(
|
45 |
+
'description' => __( 'Replaced with the number of subscribers on the selected list(s)', 'mailchimp-for-wp' ),
|
46 |
+
'callback' => array( $this, 'get_subscriber_count' ),
|
47 |
+
);
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
public function replace_in_form_content( $string, MC4WP_Form $form, MC4WP_Form_Element $element = null ) {
|
52 |
+
$this->form = $form;
|
53 |
+
$this->form_element = $element;
|
54 |
+
|
55 |
+
$string = $this->replace( $string );
|
56 |
+
return $string;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function replace_in_form_response( $string, MC4WP_Form $form ) {
|
60 |
+
$this->form = $form;
|
61 |
+
|
62 |
+
$string = $this->replace( $string );
|
63 |
+
return $string;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function replace_in_form_redirect_url( $string, MC4WP_Form $form ) {
|
67 |
+
$this->form = $form;
|
68 |
+
$string = $this->replace_in_url( $string );
|
69 |
+
return $string;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Returns the number of subscribers on the selected lists (for the form context)
|
74 |
+
*
|
75 |
+
* @return int
|
76 |
+
*/
|
77 |
+
public function get_subscriber_count() {
|
78 |
+
$mailchimp = new MC4WP_MailChimp();
|
79 |
+
$count = $mailchimp->get_subscriber_count( $this->form->get_lists() );
|
80 |
+
return number_format( $count );
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Returns the form response
|
85 |
+
*
|
86 |
+
* @return string
|
87 |
+
*/
|
88 |
+
public function get_form_response() {
|
89 |
+
if ( $this->form_element instanceof MC4WP_Form_Element ) {
|
90 |
+
return $this->form_element->get_response_html();
|
91 |
+
}
|
92 |
+
|
93 |
+
return '';
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Gets data value from GET or POST variables.
|
98 |
+
*
|
99 |
+
* @param array $args
|
100 |
+
* @return string
|
101 |
+
*/
|
102 |
+
public function get_data( array $args = array() ) {
|
103 |
+
if ( empty( $args['key'] ) ) {
|
104 |
+
return '';
|
105 |
+
}
|
106 |
+
|
107 |
+
$default = isset( $args['default'] ) ? $args['default'] : '';
|
108 |
+
$key = $args['key'];
|
109 |
+
|
110 |
+
$data = array_merge( $_GET, $_POST );
|
111 |
+
$value = isset( $data[ $key ] ) ? $data[ $key ] : $default;
|
112 |
+
|
113 |
+
// turn array into readable value
|
114 |
+
if ( is_array( $value ) ) {
|
115 |
+
$value = array_filter( $value );
|
116 |
+
$value = join( ', ', $value );
|
117 |
+
}
|
118 |
+
|
119 |
+
return esc_html( $value );
|
120 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
|
123 |
}
|
includes/forms/class-form.php
CHANGED
@@ -10,781 +10,752 @@
|
|
10 |
* @access public
|
11 |
* @since 3.0
|
12 |
*/
|
13 |
-
class MC4WP_Form
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
*/
|
762 |
-
public function add_message($key)
|
763 |
-
{
|
764 |
-
_deprecated_function(__METHOD__, '3.3');
|
765 |
-
$this->add_notice($this->get_message($key));
|
766 |
-
}
|
767 |
-
|
768 |
-
/**
|
769 |
-
* @since 4.4
|
770 |
-
* @return array
|
771 |
-
*/
|
772 |
-
public function get_subscriber_tags()
|
773 |
-
{
|
774 |
-
if (empty($this->settings['subscriber_tags'])) {
|
775 |
-
return array();
|
776 |
-
}
|
777 |
-
|
778 |
-
$tags = explode(',', $this->settings['subscriber_tags']);
|
779 |
-
$tags = array_map('trim', $tags);
|
780 |
-
|
781 |
-
// remove empty tag values
|
782 |
-
foreach($tags as $i => $tag) {
|
783 |
-
if ($tag === '') {
|
784 |
-
unset($tags[$i]);
|
785 |
-
}
|
786 |
-
}
|
787 |
-
|
788 |
-
return array_values($tags);
|
789 |
-
}
|
790 |
}
|
10 |
* @access public
|
11 |
* @since 3.0
|
12 |
*/
|
13 |
+
class MC4WP_Form {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var array Array of instantiated form objects.
|
18 |
+
*/
|
19 |
+
public static $instances = array();
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Get a shared form instance.
|
23 |
+
*
|
24 |
+
* @param WP_Post|int $post Post instance or post ID.
|
25 |
+
* @return MC4WP_Form
|
26 |
+
* @throws Exception
|
27 |
+
*/
|
28 |
+
public static function get_instance( $post = 0 ) {
|
29 |
+
if ( $post instanceof WP_Post ) {
|
30 |
+
$post_id = $post->ID;
|
31 |
+
} else {
|
32 |
+
$post_id = absint( $post );
|
33 |
+
|
34 |
+
if ( $post_id === 0 ) {
|
35 |
+
$post_id = (int) get_option( 'mc4wp_default_form_id', 0 );
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
if ( isset( self::$instances[ $post_id ] ) ) {
|
40 |
+
return self::$instances[ $post_id ];
|
41 |
+
}
|
42 |
+
|
43 |
+
// get post object if we don't have it by now
|
44 |
+
if ( ! $post instanceof WP_Post ) {
|
45 |
+
$post = get_post( $post_id );
|
46 |
+
}
|
47 |
+
|
48 |
+
// check post object
|
49 |
+
if ( ! $post instanceof WP_Post || $post->post_type !== 'mc4wp-form' ) {
|
50 |
+
$message = sprintf( __( 'There is no form with ID %d, perhaps it was deleted?', 'mailchimp-for-wp' ), $post_id );
|
51 |
+
throw new Exception( $message );
|
52 |
+
}
|
53 |
+
|
54 |
+
// get all post meta in single call for performance
|
55 |
+
$post_meta = (array) get_post_meta( $post_id );
|
56 |
+
$form = new MC4WP_Form( $post_id, $post, $post_meta );
|
57 |
+
|
58 |
+
// store instance
|
59 |
+
self::$instances[ $post_id ] = $form;
|
60 |
+
|
61 |
+
return $form;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @var int The form ID, matches the underlying post its ID
|
66 |
+
*/
|
67 |
+
public $ID = 0;
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @var string The form name
|
71 |
+
*/
|
72 |
+
public $name = 'Default Form';
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @var string The form HTML content
|
76 |
+
*/
|
77 |
+
public $content = '';
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @var array Array of settings
|
81 |
+
*/
|
82 |
+
public $settings = array();
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @var array Array of messages
|
86 |
+
*/
|
87 |
+
public $messages = array();
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @var array Array of notices to be shown when this form is rendered
|
91 |
+
*/
|
92 |
+
public $notices = array();
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @var array Array of error codes
|
96 |
+
*/
|
97 |
+
public $errors = array();
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @var bool Was this form submitted?
|
101 |
+
*/
|
102 |
+
public $is_submitted = false;
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @var array Array of the data that was submitted, in name => value pairs.
|
106 |
+
*
|
107 |
+
* Keys in this array are uppercased and keys starting with _ are stripped.
|
108 |
+
*/
|
109 |
+
private $data = array();
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @var array Array of the raw form data that was submitted.
|
113 |
+
*/
|
114 |
+
public $raw_data = array();
|
115 |
+
|
116 |
+
/**
|
117 |
+
* @var array
|
118 |
+
*/
|
119 |
+
public $config = array(
|
120 |
+
'action' => 'subscribe',
|
121 |
+
'lists' => array(),
|
122 |
+
'email_type' => '',
|
123 |
+
'element_id' => '',
|
124 |
+
);
|
125 |
+
|
126 |
+
/**
|
127 |
+
* @var string
|
128 |
+
*/
|
129 |
+
public $last_event = '';
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @var string
|
133 |
+
*/
|
134 |
+
public $status;
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @param int $id The post ID
|
138 |
+
* @param WP_Post $post
|
139 |
+
* @param array $post_meta
|
140 |
+
*/
|
141 |
+
public function __construct( $id, WP_Post $post, array $post_meta = array() ) {
|
142 |
+
$this->ID = (int) $id;
|
143 |
+
$this->name = $post->post_title;
|
144 |
+
$this->content = $post->post_content;
|
145 |
+
$this->status = $post->post_status;
|
146 |
+
$this->settings = $this->load_settings( $post_meta );
|
147 |
+
$this->messages = $this->load_messages( $post_meta );
|
148 |
+
|
149 |
+
// update config from settings
|
150 |
+
$this->config['lists'] = $this->settings['lists'];
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* @param string $name
|
155 |
+
*
|
156 |
+
* @return mixed
|
157 |
+
*/
|
158 |
+
public function __get( $name ) {
|
159 |
+
$method_name = sprintf( 'get_%s', $name );
|
160 |
+
if ( method_exists( $this, $method_name ) ) {
|
161 |
+
return $this->$method_name();
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Gets the form response string
|
168 |
+
*
|
169 |
+
* This does not take the submitted form element into account.
|
170 |
+
*
|
171 |
+
* @see MC4WP_Form_Element::get_response_html()
|
172 |
+
*
|
173 |
+
* @return string
|
174 |
+
*/
|
175 |
+
public function get_response_html() {
|
176 |
+
return $this->get_element()->get_response_html( true );
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* @param string $element_id
|
181 |
+
* @param array $config
|
182 |
+
* @return MC4WP_Form_element
|
183 |
+
*/
|
184 |
+
public function get_element( $element_id = 'mc4wp-form', array $config = array() ) {
|
185 |
+
return new MC4WP_Form_Element( $this, $element_id, $config );
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Get HTML string for this form.
|
190 |
+
*
|
191 |
+
* If you want to output a form, use `mc4wp_show_form` instead as it.
|
192 |
+
*
|
193 |
+
* @param string $element_id
|
194 |
+
* @param array $config
|
195 |
+
*
|
196 |
+
* @return string
|
197 |
+
*/
|
198 |
+
public function get_html( $element_id = 'mc4wp-form', array $config = array() ) {
|
199 |
+
$element = $this->get_element( $element_id, $config );
|
200 |
+
$html = $element->generate_html();
|
201 |
+
return $html;
|
202 |
+
}
|
203 |
+
|
204 |
+
|
205 |
+
/**
|
206 |
+
* @param array $post_meta
|
207 |
+
* @return array
|
208 |
+
*/
|
209 |
+
protected function load_settings( array $post_meta = array() ) {
|
210 |
+
$form = $this;
|
211 |
+
$default_settings = include MC4WP_PLUGIN_DIR . 'config/default-form-settings.php';
|
212 |
+
|
213 |
+
// start with defaults
|
214 |
+
$settings = $default_settings;
|
215 |
+
|
216 |
+
// get custom settings from meta
|
217 |
+
if ( ! empty( $post_meta['_mc4wp_settings'] ) ) {
|
218 |
+
$meta = $post_meta['_mc4wp_settings'][0];
|
219 |
+
$meta = (array) maybe_unserialize( $meta );
|
220 |
+
|
221 |
+
// ensure lists is an array
|
222 |
+
if ( empty( $meta['lists'] ) ) {
|
223 |
+
$meta['lists'] = array();
|
224 |
+
}
|
225 |
+
|
226 |
+
// merge with current settings (defaults)
|
227 |
+
$settings = array_merge( $settings, $meta );
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Filters the form settings
|
232 |
+
*
|
233 |
+
* @since 3.0
|
234 |
+
*
|
235 |
+
* @param array $settings
|
236 |
+
* @param MC4WP_Form $form
|
237 |
+
*/
|
238 |
+
$settings = (array) apply_filters( 'mc4wp_form_settings', $settings, $form );
|
239 |
+
|
240 |
+
return $settings;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* @param array $post_meta
|
245 |
+
* @return array
|
246 |
+
*/
|
247 |
+
protected function load_messages( array $post_meta = array() ) {
|
248 |
+
$form = $this;
|
249 |
+
|
250 |
+
// get default messages
|
251 |
+
$default_messages = include MC4WP_PLUGIN_DIR . 'config/default-form-messages.php';
|
252 |
+
|
253 |
+
// start with default messages
|
254 |
+
$messages = $default_messages;
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Filters the form messages
|
258 |
+
*
|
259 |
+
* @since 3.0
|
260 |
+
*
|
261 |
+
* @param array $registered_messages
|
262 |
+
* @param MC4WP_Form $form
|
263 |
+
*/
|
264 |
+
$messages = (array) apply_filters( 'mc4wp_form_messages', $messages, $form );
|
265 |
+
|
266 |
+
// for backwards compatiblity, grab text of each message (if is array)
|
267 |
+
foreach ( $messages as $key => $message ) {
|
268 |
+
if ( is_array( $message ) && isset( $message['text'] ) ) {
|
269 |
+
$messages[ $key ] = $message['text'];
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
foreach ( $messages as $key => $message_text ) {
|
274 |
+
|
275 |
+
// overwrite default text with text in form meta.
|
276 |
+
if ( isset( $post_meta[ 'text_' . $key ][0] ) ) {
|
277 |
+
$message_text = $post_meta[ 'text_' . $key ][0];
|
278 |
+
}
|
279 |
+
|
280 |
+
$messages[ $key ] = $message_text;
|
281 |
+
}
|
282 |
+
|
283 |
+
return $messages;
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Does this form has a field of the given type?
|
288 |
+
*
|
289 |
+
* @param string $type
|
290 |
+
*
|
291 |
+
* @return bool
|
292 |
+
*/
|
293 |
+
public function has_field_type( $type ) {
|
294 |
+
return in_array( strtolower( $type ), $this->get_field_types(), true );
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Get an array of field types which are present in this form.
|
299 |
+
*
|
300 |
+
* @return array
|
301 |
+
*/
|
302 |
+
public function get_field_types() {
|
303 |
+
preg_match_all( '/type=\"(\w+)?\"/', strtolower( $this->content ), $result );
|
304 |
+
$field_types = $result[1];
|
305 |
+
return $field_types;
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Add notice to this form when it is rendered
|
310 |
+
* @param string $text
|
311 |
+
* @param string $type
|
312 |
+
*/
|
313 |
+
public function add_notice( $text, $type = 'notice' ) {
|
314 |
+
$this->notices[] = new MC4WP_Form_Notice( $text, $type );
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Output this form
|
319 |
+
*
|
320 |
+
* @return string
|
321 |
+
*/
|
322 |
+
public function __toString() {
|
323 |
+
return mc4wp_show_form( $this->ID, array(), false );
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Get "redirect to url after success" setting for this form
|
328 |
+
*
|
329 |
+
* @return string
|
330 |
+
*/
|
331 |
+
public function get_redirect_url() {
|
332 |
+
$form = $this;
|
333 |
+
$url = trim( $this->settings['redirect'] );
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Filters the redirect URL setting
|
337 |
+
*
|
338 |
+
* @since 3.0
|
339 |
+
*
|
340 |
+
* @param string $url
|
341 |
+
* @param MC4WP_Form $form
|
342 |
+
*/
|
343 |
+
$url = (string) apply_filters( 'mc4wp_form_redirect_url', $url, $form );
|
344 |
+
return $url;
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Is this form valid?
|
349 |
+
*
|
350 |
+
* Will always return true if the form is not yet submitted. Otherwise, it will run validation and store any errors.
|
351 |
+
* This method should be called before `get_errors()`
|
352 |
+
*
|
353 |
+
* @return bool
|
354 |
+
*/
|
355 |
+
public function validate() {
|
356 |
+
if ( ! $this->is_submitted ) {
|
357 |
+
return true;
|
358 |
+
}
|
359 |
+
|
360 |
+
$form = $this;
|
361 |
+
$errors = array();
|
362 |
+
|
363 |
+
if ( empty( $this->config['lists'] ) ) {
|
364 |
+
$errors[] = 'no_lists_selected';
|
365 |
+
}
|
366 |
+
|
367 |
+
if ( ! isset( $this->raw_data['_mc4wp_timestamp'] ) || $this->raw_data['_mc4wp_timestamp'] > ( time() - 2 ) ) {
|
368 |
+
$errors[] = 'spam';
|
369 |
+
} elseif ( ! isset( $this->raw_data['_mc4wp_honeypot'] ) || ! empty( $this->raw_data['_mc4wp_honeypot'] ) ) {
|
370 |
+
$errors[] = 'spam';
|
371 |
+
}
|
372 |
+
|
373 |
+
if ( empty( $errors ) ) {
|
374 |
+
// validate email field
|
375 |
+
if ( empty( $this->data['EMAIL'] ) || ! is_email( $this->data['EMAIL'] ) ) {
|
376 |
+
$errors[] = 'invalid_email';
|
377 |
+
}
|
378 |
+
|
379 |
+
// validate other required fields
|
380 |
+
foreach ( $this->get_required_fields() as $field ) {
|
381 |
+
$value = mc4wp_array_get( $this->data, $field );
|
382 |
+
|
383 |
+
// check for empty string or array here instead of empty() since we want to allow for "0" values.
|
384 |
+
if ( $value === '' || $value === array() ) {
|
385 |
+
$errors[] = 'required_field_missing';
|
386 |
+
break;
|
387 |
+
}
|
388 |
+
}
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Filters whether this form has errors. Runs only when a form is submitted.
|
393 |
+
* Expects an array of message keys with an error type (string).
|
394 |
+
*
|
395 |
+
* Beware: all non-string values added to this array will be filtered out.
|
396 |
+
*
|
397 |
+
* @since 3.0
|
398 |
+
*
|
399 |
+
* @param array $errors
|
400 |
+
* @param MC4WP_Form $form
|
401 |
+
*/
|
402 |
+
$errors = (array) apply_filters( 'mc4wp_form_errors', $errors, $form );
|
403 |
+
|
404 |
+
/**
|
405 |
+
* @ignore
|
406 |
+
* @deprecated 3.0 Use `mc4wp_form_errors` instead
|
407 |
+
*/
|
408 |
+
$form_validity = apply_filters( 'mc4wp_valid_form_request', true, $this->data );
|
409 |
+
if ( is_string( $form_validity ) ) {
|
410 |
+
$errors[] = $form_validity;
|
411 |
+
}
|
412 |
+
|
413 |
+
// filter out all non-string values
|
414 |
+
$errors = array_filter( $errors, 'is_string' );
|
415 |
+
|
416 |
+
// set property on self
|
417 |
+
$this->errors = $errors;
|
418 |
+
|
419 |
+
// return whether we have errors
|
420 |
+
return ! $this->has_errors();
|
421 |
+
}
|
422 |
+
|
423 |
+
/**
|
424 |
+
* Handle an incoming request. Should be called before calling validate() method.
|
425 |
+
*
|
426 |
+
* @see MC4WP_Form::validate
|
427 |
+
* @param array $data
|
428 |
+
* @return void
|
429 |
+
*/
|
430 |
+
public function handle_request( array $data ) {
|
431 |
+
$this->is_submitted = true;
|
432 |
+
$this->raw_data = $data;
|
433 |
+
$this->data = $this->parse_request_data( $data );
|
434 |
+
$this->last_event = '';
|
435 |
+
|
436 |
+
// update form configuration from given data
|
437 |
+
$config = array();
|
438 |
+
$map = array(
|
439 |
+
'_mc4wp_lists' => 'lists',
|
440 |
+
'_mc4wp_action' => 'action',
|
441 |
+
'_mc4wp_form_element_id' => 'element_id',
|
442 |
+
'_mc4wp_email_type' => 'email_type',
|
443 |
+
);
|
444 |
+
|
445 |
+
// use isset here to allow empty lists (which should show a notice)
|
446 |
+
foreach ( $map as $param_key => $config_key ) {
|
447 |
+
if ( isset( $this->raw_data[ $param_key ] ) ) {
|
448 |
+
$value = $this->raw_data[ $param_key ];
|
449 |
+
if ( is_array( $value ) ) {
|
450 |
+
$value = array_filter( $value );
|
451 |
+
}
|
452 |
+
|
453 |
+
$config[ $config_key ] = $value;
|
454 |
+
}
|
455 |
+
}
|
456 |
+
|
457 |
+
if ( ! empty( $config ) ) {
|
458 |
+
$this->set_config( $config );
|
459 |
+
}
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* Parse a request for data which should be binded to `$data` property.
|
464 |
+
*
|
465 |
+
* This does the following on all post data.
|
466 |
+
*
|
467 |
+
* - Removes fields starting with an underscore.
|
468 |
+
* - Remove fields which are set to be ignored.
|
469 |
+
* - Uppercase all field names
|
470 |
+
*
|
471 |
+
* @param array $data
|
472 |
+
*
|
473 |
+
* @return array
|
474 |
+
*/
|
475 |
+
protected function parse_request_data( array $data ) {
|
476 |
+
$form = $this;
|
477 |
+
$filtered = array();
|
478 |
+
$ignored_field_names = array();
|
479 |
+
|
480 |
+
/**
|
481 |
+
* Filters field names which should be ignored when showing data.
|
482 |
+
*
|
483 |
+
* @since 3.0
|
484 |
+
*
|
485 |
+
* @param array $ignored_field_names Array of ignored field names
|
486 |
+
* @param MC4WP_Form $form The form instance.
|
487 |
+
*/
|
488 |
+
$ignored_field_names = apply_filters( 'mc4wp_form_ignored_field_names', $ignored_field_names, $form );
|
489 |
+
|
490 |
+
foreach ( $data as $key => $value ) {
|
491 |
+
// skip fields in ignored field names
|
492 |
+
if ( $key[0] === '_' || in_array( $key, $ignored_field_names, true ) ) {
|
493 |
+
continue;
|
494 |
+
}
|
495 |
+
|
496 |
+
// uppercase key
|
497 |
+
$key = strtoupper( $key );
|
498 |
+
|
499 |
+
// filter empty array values
|
500 |
+
if ( is_array( $value ) ) {
|
501 |
+
$value = array_filter( $value );
|
502 |
+
}
|
503 |
+
|
504 |
+
$filtered[ $key ] = $value;
|
505 |
+
}
|
506 |
+
|
507 |
+
return $filtered;
|
508 |
+
}
|
509 |
+
|
510 |
+
/**
|
511 |
+
* Update configuration for this form
|
512 |
+
*
|
513 |
+
* @param array $config
|
514 |
+
* @return array
|
515 |
+
*/
|
516 |
+
public function set_config( array $config ) {
|
517 |
+
$this->config = array_merge( $this->config, $config );
|
518 |
+
|
519 |
+
// make sure lists is an array
|
520 |
+
if ( ! is_array( $this->config['lists'] ) ) {
|
521 |
+
$this->config['lists'] = array_map( 'trim', explode( ',', $this->config['lists'] ) );
|
522 |
+
}
|
523 |
+
|
524 |
+
// make sure action is valid
|
525 |
+
if ( ! in_array( $this->config['action'], array( 'subscribe', 'unsubscribe' ), true ) ) {
|
526 |
+
$this->config['action'] = 'subscribe';
|
527 |
+
}
|
528 |
+
|
529 |
+
// email_type should be a valid value
|
530 |
+
if ( ! in_array( $this->config['email_type'], array( 'html', 'text' ), true ) ) {
|
531 |
+
$this->config['email_type'] = '';
|
532 |
+
}
|
533 |
+
|
534 |
+
return $this->config;
|
535 |
+
}
|
536 |
+
|
537 |
+
/**
|
538 |
+
* Get Mailchimp lists this form subscribes to
|
539 |
+
*
|
540 |
+
* @return array
|
541 |
+
*/
|
542 |
+
public function get_lists() {
|
543 |
+
$lists = $this->config['lists'];
|
544 |
+
$form = $this;
|
545 |
+
|
546 |
+
/**
|
547 |
+
* Filters Mailchimp lists new subscribers should be added to.
|
548 |
+
*
|
549 |
+
* @param array $lists
|
550 |
+
*/
|
551 |
+
$lists = (array) apply_filters( 'mc4wp_lists', $lists );
|
552 |
+
|
553 |
+
/**
|
554 |
+
* Filters Mailchimp lists new subscribers coming from this form should be added to.
|
555 |
+
*
|
556 |
+
* @param array $lists
|
557 |
+
* @param MC4WP_Form $form
|
558 |
+
*/
|
559 |
+
$lists = (array) apply_filters( 'mc4wp_form_lists', $lists, $form );
|
560 |
+
|
561 |
+
// filter out empty array elements
|
562 |
+
$lists = array_filter( $lists );
|
563 |
+
|
564 |
+
return $lists;
|
565 |
+
}
|
566 |
+
|
567 |
+
/**
|
568 |
+
* Does this form have errors?
|
569 |
+
*
|
570 |
+
* Should always evaluate to false when form has not been submitted.
|
571 |
+
*
|
572 |
+
* @see `mc4wp_form_errors` filter.
|
573 |
+
* @return bool
|
574 |
+
*/
|
575 |
+
public function has_errors() {
|
576 |
+
return count( $this->errors ) > 0;
|
577 |
+
}
|
578 |
+
|
579 |
+
/**
|
580 |
+
* Add an error to this form
|
581 |
+
*
|
582 |
+
* @param string $error_code
|
583 |
+
*/
|
584 |
+
public function add_error( $error_code ) {
|
585 |
+
// only add each error once
|
586 |
+
if ( ! in_array( $error_code, $this->errors, true ) ) {
|
587 |
+
$this->errors[] = $error_code;
|
588 |
+
}
|
589 |
+
}
|
590 |
+
|
591 |
+
/**
|
592 |
+
* Get the form action
|
593 |
+
*
|
594 |
+
* Valid return values are "subscribe" and "unsubscribe"
|
595 |
+
*
|
596 |
+
* @return string
|
597 |
+
*/
|
598 |
+
public function get_action() {
|
599 |
+
return $this->config['action'];
|
600 |
+
}
|
601 |
+
|
602 |
+
/**
|
603 |
+
* @return array
|
604 |
+
*/
|
605 |
+
public function get_data() {
|
606 |
+
$data = $this->data;
|
607 |
+
$form = $this;
|
608 |
+
|
609 |
+
/**
|
610 |
+
* Filters the form data.
|
611 |
+
*
|
612 |
+
* @param array $data
|
613 |
+
* @param MC4WP_Form $form
|
614 |
+
*/
|
615 |
+
$data = apply_filters( 'mc4wp_form_data', $data, $form );
|
616 |
+
|
617 |
+
return $data;
|
618 |
+
}
|
619 |
+
|
620 |
+
/**
|
621 |
+
* Get array of name attributes for the required fields in this form.
|
622 |
+
*
|
623 |
+
* @return array
|
624 |
+
*/
|
625 |
+
public function get_required_fields() {
|
626 |
+
$form = $this;
|
627 |
+
|
628 |
+
// explode required fields (generated in JS) to an array (uppercased)
|
629 |
+
$required_fields_string = strtoupper( $this->settings['required_fields'] );
|
630 |
+
|
631 |
+
// remove array-formatted fields
|
632 |
+
// workaround for #261 (https://github.com/ibericode/mailchimp-for-wordpress/issues/261)
|
633 |
+
$required_fields_string = preg_replace( '/\[\w+\]/', '', $required_fields_string );
|
634 |
+
|
635 |
+
// turn into an array
|
636 |
+
$required_fields = explode( ',', $required_fields_string );
|
637 |
+
|
638 |
+
// EMAIL is not a required field as it has its own validation rules
|
639 |
+
$required_fields = array_diff( $required_fields, array( 'EMAIL' ) );
|
640 |
+
|
641 |
+
// filter duplicate & empty values
|
642 |
+
$required_fields = array_unique( $required_fields );
|
643 |
+
$required_fields = array_filter( $required_fields );
|
644 |
+
|
645 |
+
// fix uppercased subkeys, see https://github.com/ibericode/mailchimp-for-wordpress/issues/516
|
646 |
+
foreach ( $required_fields as $key => $value ) {
|
647 |
+
$pos = strpos( $value, '.' );
|
648 |
+
if ( $pos > 0 ) {
|
649 |
+
$required_fields[ $key ] = substr( $value, 0, $pos ) . strtolower( substr( $value, $pos ) );
|
650 |
+
}
|
651 |
+
}
|
652 |
+
|
653 |
+
/**
|
654 |
+
* Filters the required fields for a form
|
655 |
+
*
|
656 |
+
* By default, this holds the following fields.
|
657 |
+
*
|
658 |
+
* - All fields which are required for the selected Mailchimp lists
|
659 |
+
* - All fields in the form with a `required` attribute.
|
660 |
+
*
|
661 |
+
* @param array $required_fields
|
662 |
+
* @param MC4WP_Form $form
|
663 |
+
*/
|
664 |
+
$required_fields = (array) apply_filters( 'mc4wp_form_required_fields', $required_fields, $form );
|
665 |
+
|
666 |
+
return $required_fields;
|
667 |
+
}
|
668 |
+
|
669 |
+
/**
|
670 |
+
* Get "email_type" setting for new Mailchimp subscribers added by this form.
|
671 |
+
*
|
672 |
+
* @return string
|
673 |
+
*/
|
674 |
+
public function get_email_type() {
|
675 |
+
$email_type = $this->config['email_type'];
|
676 |
+
|
677 |
+
if ( empty( $email_type ) ) {
|
678 |
+
$email_type = mc4wp_get_email_type();
|
679 |
+
}
|
680 |
+
|
681 |
+
return $email_type;
|
682 |
+
}
|
683 |
+
|
684 |
+
/**
|
685 |
+
* Gets the filename of the stylesheet to load for this form.
|
686 |
+
*
|
687 |
+
* @return string
|
688 |
+
*/
|
689 |
+
public function get_stylesheet() {
|
690 |
+
$stylesheet = $this->settings['css'];
|
691 |
+
|
692 |
+
if ( empty( $stylesheet ) ) {
|
693 |
+
return '';
|
694 |
+
}
|
695 |
+
|
696 |
+
// form themes live in the same stylesheet
|
697 |
+
if ( strpos( $stylesheet, 'theme-' ) !== false ) {
|
698 |
+
$stylesheet = 'themes';
|
699 |
+
}
|
700 |
+
|
701 |
+
return $stylesheet;
|
702 |
+
}
|
703 |
+
|
704 |
+
/**
|
705 |
+
* @param string $key
|
706 |
+
* @return string
|
707 |
+
*/
|
708 |
+
public function get_message( $key ) {
|
709 |
+
$message = isset( $this->messages[ $key ] ) ? $this->messages[ $key ] : $this->messages['error'];
|
710 |
+
|
711 |
+
if ( $key === 'no_lists_selected' && current_user_can( 'manage_options' ) ) {
|
712 |
+
$message .= sprintf( ' (<a href="%s">%s</a>)', mc4wp_get_edit_form_url( $this->ID, 'settings' ), 'edit form settings' );
|
713 |
+
}
|
714 |
+
|
715 |
+
return $message;
|
716 |
+
}
|
717 |
+
|
718 |
+
/**
|
719 |
+
* Get HTML string for a message, including wrapper element.
|
720 |
+
*
|
721 |
+
* @deprecated 3.1
|
722 |
+
*
|
723 |
+
* @param string $key
|
724 |
+
*
|
725 |
+
* @return string
|
726 |
+
*/
|
727 |
+
public function get_message_html( $key ) {
|
728 |
+
_deprecated_function( __METHOD__, '3.2' );
|
729 |
+
return '';
|
730 |
+
}
|
731 |
+
|
732 |
+
/**
|
733 |
+
* Add a notice to this form
|
734 |
+
*/
|
735 |
+
public function add_message( $key ) {
|
736 |
+
_deprecated_function( __METHOD__, '3.3' );
|
737 |
+
$this->add_notice( $this->get_message( $key ) );
|
738 |
+
}
|
739 |
+
|
740 |
+
/**
|
741 |
+
* @since 4.4
|
742 |
+
* @return array
|
743 |
+
*/
|
744 |
+
public function get_subscriber_tags() {
|
745 |
+
if ( empty( $this->settings['subscriber_tags'] ) ) {
|
746 |
+
return array();
|
747 |
+
}
|
748 |
+
|
749 |
+
$tags = explode( ',', $this->settings['subscriber_tags'] );
|
750 |
+
$tags = array_map( 'trim', $tags );
|
751 |
+
|
752 |
+
// remove empty tag values
|
753 |
+
foreach ( $tags as $i => $tag ) {
|
754 |
+
if ( $tag === '' ) {
|
755 |
+
unset( $tags[ $i ] );
|
756 |
+
}
|
757 |
+
}
|
758 |
+
|
759 |
+
return array_values( $tags );
|
760 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
761 |
}
|
includes/forms/class-google-recaptcha.php
CHANGED
@@ -2,200 +2,211 @@
|
|
2 |
|
3 |
class MC4WP_Google_Recaptcha {
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
class MC4WP_Google_Recaptcha {
|
4 |
|
5 |
+
private $form_ids = array();
|
6 |
+
|
7 |
+
public function add_hooks() {
|
8 |
+
add_filter( 'mc4wp_form_settings', array( $this, 'add_default_form_settings' ) );
|
9 |
+
add_filter( 'mc4wp_settings', array( $this, 'add_default_settings' ) );
|
10 |
+
add_action( 'mc4wp_output_form', array( $this, 'on_output_form' ), 20 );
|
11 |
+
add_filter( 'mc4wp_form_errors', array( $this, 'verify_token' ), 10, 2 );
|
12 |
+
add_action( 'mc4wp_admin_form_after_behaviour_settings_rows', array( $this, 'show_settings' ), 30, 2 );
|
13 |
+
add_filter( 'mc4wp_form_sanitized_data', array( $this, 'sanitize_settings' ), 20, 2 );
|
14 |
+
add_action( 'wp_footer', array( $this, 'load_script' ), 8000 );
|
15 |
+
}
|
16 |
+
|
17 |
+
|
18 |
+
public function add_default_settings( $settings ) {
|
19 |
+
$defaults = array(
|
20 |
+
'grecaptcha_site_key' => '',
|
21 |
+
'grecaptcha_secret_key' => '',
|
22 |
+
);
|
23 |
+
$settings = array_merge( $defaults, $settings );
|
24 |
+
return $settings;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function add_default_form_settings( $settings ) {
|
28 |
+
$defaults = array(
|
29 |
+
'grecaptcha_enabled' => 0,
|
30 |
+
);
|
31 |
+
$settings = array_merge( $defaults, $settings );
|
32 |
+
return $settings;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function sanitize_settings( $data, $raw_data ) {
|
36 |
+
if ( ! isset( $data['settings']['grecaptcha_enabled'] ) || ! $data['settings']['grecaptcha_enabled'] ) {
|
37 |
+
return $data;
|
38 |
+
}
|
39 |
+
|
40 |
+
// only enable grecaptcha if both site & secret key are set
|
41 |
+
$global_settings = mc4wp_get_settings();
|
42 |
+
$data['settings']['grecaptcha_enabled'] = isset( $global_settings['grecaptcha_site_key'] )
|
43 |
+
&& isset( $global_settings['grecaptcha_secret_key'] )
|
44 |
+
&& strlen( $global_settings['grecaptcha_site_key'] ) === 40
|
45 |
+
&& strlen( $global_settings['grecaptcha_secret_key'] ) === 40 ? '1' : '0';
|
46 |
+
return $data;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function load_script() {
|
50 |
+
$global_settings = mc4wp_get_settings();
|
51 |
+
|
52 |
+
// do not load if no forms with Google reCAPTCHA enabled were outputted
|
53 |
+
if ( empty( $this->form_ids ) || empty( $global_settings['grecaptcha_site_key'] ) || empty( $global_settings['grecaptcha_secret_key'] ) ) {
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
// load Google reCAPTCHA script
|
58 |
+
echo sprintf( '<script src="https://www.google.com/recaptcha/api.js?render=%s"></script>', esc_attr( $global_settings['grecaptcha_site_key'] ) );
|
59 |
+
|
60 |
+
// hook into form submit
|
61 |
+
?><script>
|
62 |
+
(function() {
|
63 |
+
var formIds = <?php echo json_encode( $this->form_ids ); ?>;
|
64 |
+
|
65 |
+
function addGoogleReCaptchaTokenToForm(form, event) {
|
66 |
+
event.preventDefault();
|
67 |
+
|
68 |
+
var submitForm = function() {
|
69 |
+
if(form.element.className.indexOf('mc4wp-ajax') > -1) {
|
70 |
+
mc4wp.forms.trigger('submit', [form, event]);
|
71 |
+
} else {
|
72 |
+
form.element.submit();
|
73 |
+
}
|
74 |
+
};
|
75 |
+
var previousToken = form.element.querySelector('input[name=_mc4wp_grecaptcha_token]');
|
76 |
+
if (previousToken) {
|
77 |
+
previousToken.parentElement.removeChild(previousToken);
|
78 |
+
}
|
79 |
+
|
80 |
+
window.grecaptcha
|
81 |
+
.execute('<?php echo esc_attr( $global_settings['grecaptcha_site_key'] ); ?>', {action: 'mc4wp_form_submit'})
|
82 |
+
.then(function (token) {
|
83 |
+
var tokenEl = document.createElement('input');
|
84 |
+
tokenEl.type = 'hidden';
|
85 |
+
tokenEl.value = token;
|
86 |
+
tokenEl.name = '_mc4wp_grecaptcha_token';
|
87 |
+
form.element.appendChild(tokenEl);
|
88 |
+
submitForm();
|
89 |
+
})
|
90 |
+
}
|
91 |
+
|
92 |
+
for(var i=0; i<formIds.length; i++) {
|
93 |
+
mc4wp.forms.on(formIds[i]+'.submit', addGoogleReCaptchaTokenToForm)
|
94 |
+
}
|
95 |
+
})();
|
96 |
+
</script>
|
97 |
+
<?php
|
98 |
+
}
|
99 |
+
|
100 |
+
public function on_output_form( MC4WP_Form $form ) {
|
101 |
+
// Check if form has Google ReCaptcha enabled
|
102 |
+
if ( ! $form->settings['grecaptcha_enabled'] ) {
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
|
106 |
+
if ( ! in_array( $form->ID, $this->form_ids ) ) {
|
107 |
+
$this->form_ids[] = $form->ID;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
public function verify_token( array $errors, MC4WP_Form $form ) {
|
112 |
+
// Check if form has Google ReCaptcha enabled
|
113 |
+
if ( ! $form->settings['grecaptcha_enabled'] ) {
|
114 |
+
return $errors;
|
115 |
+
}
|
116 |
+
|
117 |
+
// Verify token
|
118 |
+
if ( empty( $_POST['_mc4wp_grecaptcha_token'] ) ) {
|
119 |
+
$errors[] = 'spam';
|
120 |
+
return $errors;
|
121 |
+
}
|
122 |
+
|
123 |
+
$global_settings = mc4wp_get_settings();
|
124 |
+
$token = $_POST['_mc4wp_grecaptcha_token'];
|
125 |
+
$response = wp_remote_post(
|
126 |
+
'https://www.google.com/recaptcha/api/siteverify',
|
127 |
+
array(
|
128 |
+
'body' => array(
|
129 |
+
'secret' => $global_settings['grecaptcha_secret_key'],
|
130 |
+
'response' => $token,
|
131 |
+
),
|
132 |
+
)
|
133 |
+
);
|
134 |
+
|
135 |
+
$response_code = wp_remote_retrieve_response_code( $response );
|
136 |
+
if ( $response_code >= 400 ) {
|
137 |
+
// The request somehow failed... Allow the sign-up to go through to not break sign-up forms when Google reCaptcha is down (unlikely)
|
138 |
+
return $errors;
|
139 |
+
}
|
140 |
+
|
141 |
+
$response_body = wp_remote_retrieve_body( $response );
|
142 |
+
$data = json_decode( $response_body, true );
|
143 |
+
$score_treshold = apply_filters( 'mc4wp_grecaptcha_score_treshold', 0.5 );
|
144 |
+
|
145 |
+
if ( isset( $data['error-codes'] ) && in_array( 'invalid-input-secret', $data['error-codes'], true ) ) {
|
146 |
+
$this->get_log()->warning( sprintf( 'Form %d > Invalid Google reCAPTCHA secret key', $form->ID ) );
|
147 |
+
return $errors;
|
148 |
+
}
|
149 |
+
|
150 |
+
if ( $data['success'] === false || ! isset( $data['score'] ) || $data['score'] <= $score_treshold || $data['action'] !== 'mc4wp_form_submit' ) {
|
151 |
+
$errors[] = 'spam';
|
152 |
+
return $errors;
|
153 |
+
}
|
154 |
+
|
155 |
+
return $errors;
|
156 |
+
}
|
157 |
+
|
158 |
+
public function show_settings( array $settings, MC4WP_Form $form ) {
|
159 |
+
if ( ! $settings['grecaptcha_enabled'] ) {
|
160 |
+
return;
|
161 |
+
}
|
162 |
+
|
163 |
+
$global_settings = mc4wp_get_settings();
|
164 |
+
?>
|
165 |
+
<tr valign="top">
|
166 |
+
<th scope="row"><?php _e( 'Enable Google reCaptcha', 'mailchimp-for-wp' ); ?></th>
|
167 |
+
<td>
|
168 |
+
<label><input type="radio" name="mc4wp_form[settings][grecaptcha_enabled]" value="1" <?php checked( $settings['grecaptcha_enabled'], 1 ); ?> /> <?php _e( 'Yes', 'mailchimp-for-wp' ); ?> ‏</label>
|
169 |
+
|
170 |
+
<label><input type="radio" name="mc4wp_form[settings][grecaptcha_enabled]" value="0" <?php checked( $settings['grecaptcha_enabled'], 0 ); ?> /> <?php _e( 'No', 'mailchimp-for-wp' ); ?> ‏</label>
|
171 |
+
<p class="help">
|
172 |
+
<?php _e( 'Select "yes" to enable Google reCAPTCHA spam protection for this form.', 'mailchimp-for-wp' ); ?>
|
173 |
+
</p>
|
174 |
+
</td>
|
175 |
+
</tr>
|
176 |
+
<?php
|
177 |
+
$config = array(
|
178 |
+
'element' => 'mc4wp_form[settings][grecaptcha_enabled]',
|
179 |
+
'value' => 1,
|
180 |
+
);
|
181 |
+
?>
|
182 |
+
<tr valign="top" data-showif="<?php echo esc_attr( json_encode( $config ) ); ?>">
|
183 |
+
<th scope="row"><label for="mc4wp_grecaptcha_site_key"><?php _e( 'Google reCAPTCHA Site Key', 'mailchimp-for-wp' ); ?></label></th>
|
184 |
+
<td>
|
185 |
+
<input type="text" class="widefat" name="mc4wp[grecaptcha_site_key]" id="mc4wp_grecaptcha_site_key" placeholder="<?php echo str_repeat( '●', 40 ); ?>" value="<?php echo esc_attr( $global_settings['grecaptcha_site_key'] ); ?>" />
|
186 |
+
<p class="help">
|
187 |
+
<?php printf( __( 'Enter your Google reCAPTCHA keys here. You can <a href="%1$s">retrieve your keys in the Google reCAPTCHA admin console</a> or read our help article on <a href="%2$s">how to configure Google reCAPTCHA</a>.', 'mailchimp-for-wp' ), 'https://g.co/recaptcha/v3', 'https://kb.mc4wp.com/google-recaptcha-forms/' ); ?>
|
188 |
+
</p>
|
189 |
+
</td>
|
190 |
+
</tr>
|
191 |
+
<?php
|
192 |
+
$config = array(
|
193 |
+
'element' => 'mc4wp_form[settings][grecaptcha_enabled]',
|
194 |
+
'value' => 1,
|
195 |
+
);
|
196 |
+
?>
|
197 |
+
<tr valign="top" data-showif="<?php echo esc_attr( json_encode( $config ) ); ?>">
|
198 |
+
<th scope="row"><label for="mc4wp_grecaptcha_secret_key"><?php _e( 'Google reCAPTCHA Secret Key', 'mailchimp-for-wp' ); ?></label></th>
|
199 |
+
<td>
|
200 |
+
<input type="text" class="widefat" name="mc4wp[grecaptcha_secret_key]" id="mc4wp_grecaptcha_secret_key" placeholder="<?php echo str_repeat( '●', 40 ); ?>" value="<?php echo esc_attr( $global_settings['grecaptcha_secret_key'] ); ?>" />
|
201 |
+
</td>
|
202 |
+
</tr>
|
203 |
+
<?php
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* @return MC4WP_Debug_Log
|
208 |
+
*/
|
209 |
+
private function get_log() {
|
210 |
+
return mc4wp( 'log' );
|
211 |
+
}
|
212 |
+
}
|
includes/forms/class-output-manager.php
CHANGED
@@ -7,136 +7,118 @@
|
|
7 |
* @ignore
|
8 |
* @access private
|
9 |
*/
|
10 |
-
class MC4WP_Form_Output_Manager
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
do_action('mc4wp_output_form', $form);
|
125 |
-
|
126 |
-
// output the form (in output buffer)
|
127 |
-
echo $form_html;
|
128 |
-
|
129 |
-
// grab all contents in current output buffer & then clean + end it.
|
130 |
-
$html = ob_get_clean();
|
131 |
-
} catch (Error $e) {
|
132 |
-
$html = $form_html;
|
133 |
-
}
|
134 |
-
|
135 |
-
// echo content if necessary
|
136 |
-
if ($echo) {
|
137 |
-
echo $html;
|
138 |
-
}
|
139 |
-
|
140 |
-
return $html;
|
141 |
-
}
|
142 |
}
|
7 |
* @ignore
|
8 |
* @access private
|
9 |
*/
|
10 |
+
class MC4WP_Form_Output_Manager {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var int The # of forms outputted
|
14 |
+
*/
|
15 |
+
public $count = 0;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @const string
|
19 |
+
*/
|
20 |
+
const SHORTCODE = 'mc4wp_form';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Add hooks
|
24 |
+
*/
|
25 |
+
public function add_hooks() {
|
26 |
+
// enable shortcodes in form content
|
27 |
+
add_filter( 'mc4wp_form_content', 'do_shortcode' );
|
28 |
+
add_action( 'init', array( $this, 'register_shortcode' ) );
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Registers the [mc4wp_form] shortcode
|
33 |
+
*/
|
34 |
+
public function register_shortcode() {
|
35 |
+
add_shortcode( self::SHORTCODE, array( $this, 'shortcode' ) );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @param array $attributes
|
40 |
+
* @param string $content
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function shortcode( $attributes = array(), $content = '' ) {
|
44 |
+
$default_attributes = array(
|
45 |
+
'id' => '',
|
46 |
+
'lists' => '',
|
47 |
+
'email_type' => '',
|
48 |
+
'element_id' => '',
|
49 |
+
'element_class' => '',
|
50 |
+
);
|
51 |
+
|
52 |
+
$attributes = shortcode_atts(
|
53 |
+
$default_attributes,
|
54 |
+
$attributes,
|
55 |
+
self::SHORTCODE
|
56 |
+
);
|
57 |
+
|
58 |
+
$config = array(
|
59 |
+
'element_id' => $attributes['element_id'],
|
60 |
+
'lists' => $attributes['lists'],
|
61 |
+
'email_type' => $attributes['email_type'],
|
62 |
+
'element_class' => $attributes['element_class'],
|
63 |
+
);
|
64 |
+
|
65 |
+
return $this->output_form( $attributes['id'], $config, false );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @param int $id
|
70 |
+
* @param array $config
|
71 |
+
* @param bool $echo
|
72 |
+
*
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
public function output_form( $id = 0, $config = array(), $echo = true ) {
|
76 |
+
try {
|
77 |
+
$form = mc4wp_get_form( $id );
|
78 |
+
} catch ( Exception $e ) {
|
79 |
+
if ( current_user_can( 'manage_options' ) ) {
|
80 |
+
return sprintf( '<strong>Mailchimp for WordPress error:</strong> %s', $e->getMessage() );
|
81 |
+
}
|
82 |
+
|
83 |
+
return '';
|
84 |
+
}
|
85 |
+
|
86 |
+
$this->count++;
|
87 |
+
|
88 |
+
// set a default element_id if none is given
|
89 |
+
if ( empty( $config['element_id'] ) ) {
|
90 |
+
$config['element_id'] = 'mc4wp-form-' . $this->count;
|
91 |
+
}
|
92 |
+
|
93 |
+
$form_html = $form->get_html( $config['element_id'], $config );
|
94 |
+
|
95 |
+
try {
|
96 |
+
// start new output buffer
|
97 |
+
ob_start();
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Runs just before a form element is outputted.
|
101 |
+
*
|
102 |
+
* @since 3.0
|
103 |
+
*
|
104 |
+
* @param MC4WP_Form $form
|
105 |
+
*/
|
106 |
+
do_action( 'mc4wp_output_form', $form );
|
107 |
+
|
108 |
+
// output the form (in output buffer)
|
109 |
+
echo $form_html;
|
110 |
+
|
111 |
+
// grab all contents in current output buffer & then clean + end it.
|
112 |
+
$html = ob_get_clean();
|
113 |
+
} catch ( Error $e ) {
|
114 |
+
$html = $form_html;
|
115 |
+
}
|
116 |
+
|
117 |
+
// echo content if necessary
|
118 |
+
if ( $echo ) {
|
119 |
+
echo $html;
|
120 |
+
}
|
121 |
+
|
122 |
+
return $html;
|
123 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
includes/forms/class-widget.php
CHANGED
@@ -1,131 +1,128 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Adds MC4WP_Widget widget.
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_Form_Widget extends WP_Widget
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'mailchimp-for-wp'); ?></label>
|
83 |
-
<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($settings['title']); ?>" />
|
84 |
-
</p>
|
85 |
|
86 |
|
87 |
<?php
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
100 |
<?php
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
}
|
131 |
} // class MC4WP_Widget
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Adds MC4WP_Widget widget.
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_Form_Widget extends WP_Widget {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
+
private $default_instance_settings = array(
|
17 |
+
'title' => '',
|
18 |
+
'form_id' => '',
|
19 |
+
);
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Register widget with WordPress.
|
23 |
+
*/
|
24 |
+
public function __construct() {
|
25 |
+
|
26 |
+
// translate default widget title
|
27 |
+
$this->default_instance_settings['title'] = __( 'Newsletter', 'mailchimp-for-wp' );
|
28 |
+
|
29 |
+
parent::__construct(
|
30 |
+
'mc4wp_form_widget', // Base ID
|
31 |
+
__( 'Mailchimp Sign-Up Form', 'mailchimp-for-wp' ), // Name
|
32 |
+
array(
|
33 |
+
'description' => __( 'Displays your Mailchimp for WordPress sign-up form', 'mailchimp-for-wp' ),
|
34 |
+
)
|
35 |
+
);
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Front-end display of widget.
|
40 |
+
*
|
41 |
+
* @see WP_Widget::widget()
|
42 |
+
*
|
43 |
+
* @param array $args Widget arguments.
|
44 |
+
* @param array $instance_settings Saved values from database.
|
45 |
+
*/
|
46 |
+
public function widget( $args, $instance_settings ) {
|
47 |
+
|
48 |
+
// ensure $instance_settings is an array
|
49 |
+
if ( ! is_array( $instance_settings ) ) {
|
50 |
+
$instance_settings = array();
|
51 |
+
}
|
52 |
+
|
53 |
+
$instance_settings = array_merge( $this->default_instance_settings, $instance_settings );
|
54 |
+
$title = apply_filters( 'widget_title', $instance_settings['title'] );
|
55 |
+
|
56 |
+
echo $args['before_widget'];
|
57 |
+
|
58 |
+
if ( ! empty( $title ) ) {
|
59 |
+
echo $args['before_title'] . $title . $args['after_title'];
|
60 |
+
}
|
61 |
+
|
62 |
+
mc4wp_show_form( $instance_settings['form_id'] );
|
63 |
+
|
64 |
+
echo $args['after_widget'];
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Back-end widget form.
|
69 |
+
*
|
70 |
+
* @see WP_Widget::form()
|
71 |
+
*
|
72 |
+
* @param array $settings Previously saved values from database.
|
73 |
+
*
|
74 |
+
* @return string|void
|
75 |
+
*/
|
76 |
+
public function form( $settings ) {
|
77 |
+
$settings = array_merge( $this->default_instance_settings, (array) $settings ); ?>
|
78 |
+
<p>
|
79 |
+
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'mailchimp-for-wp' ); ?></label>
|
80 |
+
<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( $settings['title'] ); ?>" />
|
81 |
+
</p>
|
|
|
|
|
|
|
82 |
|
83 |
|
84 |
<?php
|
85 |
+
/**
|
86 |
+
* Runs right after the widget settings form is outputted
|
87 |
+
*
|
88 |
+
* @param array $settings
|
89 |
+
* @param MC4WP_Form_Widget $this
|
90 |
+
* @ignore
|
91 |
+
*/
|
92 |
+
do_action( 'mc4wp_form_widget_form', $settings, $this );
|
93 |
+
?>
|
94 |
+
|
95 |
+
<p class="help">
|
96 |
+
<?php printf( __( 'You can edit your sign-up form in the <a href="%s">Mailchimp for WordPress form settings</a>.', 'mailchimp-for-wp' ), admin_url( 'admin.php?page=mailchimp-for-wp-forms' ) ); ?>
|
97 |
+
</p>
|
98 |
<?php
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Validates widget form values as they are saved.
|
103 |
+
*
|
104 |
+
* @see WP_Widget::update()
|
105 |
+
*
|
106 |
+
* @param array $new_settings Values just sent to be saved.
|
107 |
+
* @param array $old_settings Previously saved values from database.
|
108 |
+
*
|
109 |
+
* @return array Updated safe values to be saved.
|
110 |
+
*/
|
111 |
+
public function update( $new_settings, $old_settings ) {
|
112 |
+
if ( ! empty( $new_settings['title'] ) ) {
|
113 |
+
$new_settings['title'] = sanitize_text_field( $new_settings['title'] );
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Filters the widget settings before they are saved.
|
118 |
+
*
|
119 |
+
* @param array $new_settings
|
120 |
+
* @param array $old_settings
|
121 |
+
* @param MC4WP_Form_Widget $widget
|
122 |
+
* @ignore
|
123 |
+
*/
|
124 |
+
$new_settings = apply_filters( 'mc4wp_form_widget_update_settings', $new_settings, $old_settings, $this );
|
125 |
+
|
126 |
+
return $new_settings;
|
127 |
+
}
|
|
|
128 |
} // class MC4WP_Widget
|
includes/forms/functions.php
CHANGED
@@ -9,9 +9,8 @@
|
|
9 |
*
|
10 |
* @return MC4WP_Form
|
11 |
*/
|
12 |
-
function mc4wp_get_form($form_id = 0)
|
13 |
-
|
14 |
-
return MC4WP_Form::get_instance($form_id);
|
15 |
}
|
16 |
|
17 |
/**
|
@@ -23,30 +22,29 @@ function mc4wp_get_form($form_id = 0)
|
|
23 |
*
|
24 |
* @return MC4WP_Form[]
|
25 |
*/
|
26 |
-
function mc4wp_get_forms(array $args = array())
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
$posts = $q->query($args);
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
}
|
51 |
|
52 |
/**
|
@@ -60,11 +58,10 @@ function mc4wp_get_forms(array $args = array())
|
|
60 |
*
|
61 |
* @return string
|
62 |
*/
|
63 |
-
function mc4wp_show_form($form_id = 0, $config = array(), $echo = true)
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
return $forms->output_form($form_id, $config, $echo);
|
68 |
}
|
69 |
|
70 |
/**
|
@@ -80,20 +77,19 @@ function mc4wp_show_form($form_id = 0, $config = array(), $echo = true)
|
|
80 |
*
|
81 |
* @return boolean
|
82 |
*/
|
83 |
-
function mc4wp_form_is_submitted($form_id = 0, $element_id = null)
|
84 |
-
{
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
}
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
|
96 |
-
|
97 |
}
|
98 |
|
99 |
/**
|
@@ -106,15 +102,14 @@ function mc4wp_form_is_submitted($form_id = 0, $element_id = null)
|
|
106 |
*
|
107 |
* @return string
|
108 |
*/
|
109 |
-
function mc4wp_form_get_response_html($form_id = 0)
|
110 |
-
{
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
}
|
116 |
|
117 |
-
|
118 |
}
|
119 |
|
120 |
/**
|
@@ -124,7 +119,6 @@ function mc4wp_form_get_response_html($form_id = 0)
|
|
124 |
*
|
125 |
* @return MC4WP_Form|null
|
126 |
*/
|
127 |
-
function mc4wp_get_submitted_form()
|
128 |
-
|
129 |
-
return mc4wp('forms')->get_submitted_form();
|
130 |
}
|
9 |
*
|
10 |
* @return MC4WP_Form
|
11 |
*/
|
12 |
+
function mc4wp_get_form( $form_id = 0 ) {
|
13 |
+
return MC4WP_Form::get_instance( $form_id );
|
|
|
14 |
}
|
15 |
|
16 |
/**
|
22 |
*
|
23 |
* @return MC4WP_Form[]
|
24 |
*/
|
25 |
+
function mc4wp_get_forms( array $args = array() ) {
|
26 |
+
$default_args = array(
|
27 |
+
'post_status' => 'publish',
|
28 |
+
'posts_per_page' => -1,
|
29 |
+
'ignore_sticky_posts' => true,
|
30 |
+
'no_found_rows' => true,
|
31 |
+
);
|
32 |
+
$args = array_merge( $default_args, $args );
|
33 |
+
$args['post_type'] = 'mc4wp-form';
|
34 |
+
$q = new WP_Query();
|
35 |
+
$posts = $q->query( $args );
|
|
|
36 |
|
37 |
+
$forms = array();
|
38 |
+
foreach ( $posts as $post ) {
|
39 |
+
try {
|
40 |
+
$form = mc4wp_get_form( $post );
|
41 |
+
} catch ( Exception $e ) {
|
42 |
+
continue;
|
43 |
+
}
|
44 |
|
45 |
+
$forms[] = $form;
|
46 |
+
}
|
47 |
+
return $forms;
|
48 |
}
|
49 |
|
50 |
/**
|
58 |
*
|
59 |
* @return string
|
60 |
*/
|
61 |
+
function mc4wp_show_form( $form_id = 0, $config = array(), $echo = true ) {
|
62 |
+
/** @var MC4WP_Form_Manager $forms */
|
63 |
+
$forms = mc4wp( 'forms' );
|
64 |
+
return $forms->output_form( $form_id, $config, $echo );
|
|
|
65 |
}
|
66 |
|
67 |
/**
|
77 |
*
|
78 |
* @return boolean
|
79 |
*/
|
80 |
+
function mc4wp_form_is_submitted( $form_id = 0, $element_id = null ) {
|
81 |
+
try {
|
82 |
+
$form = mc4wp_get_form( $form_id );
|
83 |
+
} catch ( Exception $e ) {
|
84 |
+
return false;
|
85 |
+
}
|
|
|
86 |
|
87 |
+
if ( $element_id ) {
|
88 |
+
$form_element = new MC4WP_Form_Element( $form, array( 'element_id' => $element_id ) );
|
89 |
+
return $form_element->is_submitted;
|
90 |
+
}
|
91 |
|
92 |
+
return $form->is_submitted;
|
93 |
}
|
94 |
|
95 |
/**
|
102 |
*
|
103 |
* @return string
|
104 |
*/
|
105 |
+
function mc4wp_form_get_response_html( $form_id = 0 ) {
|
106 |
+
try {
|
107 |
+
$form = mc4wp_get_form( $form_id );
|
108 |
+
} catch ( Exception $e ) {
|
109 |
+
return '';
|
110 |
+
}
|
|
|
111 |
|
112 |
+
return $form->get_response_html();
|
113 |
}
|
114 |
|
115 |
/**
|
119 |
*
|
120 |
* @return MC4WP_Form|null
|
121 |
*/
|
122 |
+
function mc4wp_get_submitted_form() {
|
123 |
+
return mc4wp( 'forms' )->get_submitted_form();
|
|
|
124 |
}
|
includes/forms/views/add-form.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<?php defined('ABSPATH') or exit; ?>
|
2 |
<div id="mc4wp-admin" class="wrap mc4wp-settings">
|
3 |
|
4 |
<div class="row">
|
@@ -7,10 +7,10 @@
|
|
7 |
<div class="main-content col col-4">
|
8 |
|
9 |
<h1 class="page-title">
|
10 |
-
<?php _e(
|
11 |
</h1>
|
12 |
|
13 |
-
<h2 style="display: none;"></h2><?php // fake h2 for admin notices?>
|
14 |
|
15 |
<div style="max-width: 480px;">
|
16 |
|
@@ -18,52 +18,56 @@
|
|
18 |
<form method="post">
|
19 |
|
20 |
<input type="hidden" name="_mc4wp_action" value="add_form" />
|
21 |
-
<?php wp_nonce_field('add_form', '_mc4wp_nonce'); ?>
|
22 |
|
23 |
|
24 |
<div class="small-margin">
|
25 |
<h3>
|
26 |
<label>
|
27 |
-
<?php _e('What is the name of this form?', 'mailchimp-for-wp'); ?>
|
28 |
</label>
|
29 |
</h3>
|
30 |
-
<input type="text" name="mc4wp_form[name]" class="widefat" value="" spellcheck="true" autocomplete="off" placeholder="<?php _e('Enter your form title..', 'mailchimp-for-wp'); ?>">
|
31 |
</div>
|
32 |
|
33 |
<div class="small-margin">
|
34 |
|
35 |
<h3>
|
36 |
<label>
|
37 |
-
<?php _e('To which Mailchimp lists should this form subscribe?', 'mailchimp-for-wp'); ?>
|
38 |
</label>
|
39 |
</h3>
|
40 |
|
41 |
-
<?php
|
42 |
-
|
|
|
43 |
<ul id="mc4wp-lists">
|
44 |
-
<?php
|
45 |
-
|
|
|
46 |
<li>
|
47 |
<label>
|
48 |
-
<input type="checkbox" name="mc4wp_form[settings][lists][<?php echo esc_attr($list->id); ?>]" value="<?php echo esc_attr($list->id); ?>" <?php checked($number_of_lists, 1); ?> >
|
49 |
-
<?php echo esc_html($list->name); ?>
|
50 |
</label>
|
51 |
</li>
|
52 |
-
|
53 |
-
|
|
|
54 |
</ul>
|
55 |
-
|
56 |
-
} else {
|
57 |
-
|
58 |
<p class="mc4wp-notice">
|
59 |
-
<?php printf(__('No lists found. Did you <a href="%s">connect with Mailchimp</a>?', 'mailchimp-for-wp'), admin_url('admin.php?page=mailchimp-for-wp')); ?>
|
60 |
</p>
|
61 |
-
|
62 |
-
|
|
|
63 |
|
64 |
</div>
|
65 |
|
66 |
-
<?php submit_button(__('Add new form', 'mailchimp-for-wp')); ?>
|
67 |
|
68 |
|
69 |
</form><!-- Entire page form wrap -->
|
1 |
+
<?php defined( 'ABSPATH' ) or exit; ?>
|
2 |
<div id="mc4wp-admin" class="wrap mc4wp-settings">
|
3 |
|
4 |
<div class="row">
|
7 |
<div class="main-content col col-4">
|
8 |
|
9 |
<h1 class="page-title">
|
10 |
+
<?php _e( 'Add new form', 'mailchimp-for-wp' ); ?>
|
11 |
</h1>
|
12 |
|
13 |
+
<h2 style="display: none;"></h2><?php // fake h2 for admin notices ?>
|
14 |
|
15 |
<div style="max-width: 480px;">
|
16 |
|
18 |
<form method="post">
|
19 |
|
20 |
<input type="hidden" name="_mc4wp_action" value="add_form" />
|
21 |
+
<?php wp_nonce_field( 'add_form', '_mc4wp_nonce' ); ?>
|
22 |
|
23 |
|
24 |
<div class="small-margin">
|
25 |
<h3>
|
26 |
<label>
|
27 |
+
<?php _e( 'What is the name of this form?', 'mailchimp-for-wp' ); ?>
|
28 |
</label>
|
29 |
</h3>
|
30 |
+
<input type="text" name="mc4wp_form[name]" class="widefat" value="" spellcheck="true" autocomplete="off" placeholder="<?php _e( 'Enter your form title..', 'mailchimp-for-wp' ); ?>">
|
31 |
</div>
|
32 |
|
33 |
<div class="small-margin">
|
34 |
|
35 |
<h3>
|
36 |
<label>
|
37 |
+
<?php _e( 'To which Mailchimp lists should this form subscribe?', 'mailchimp-for-wp' ); ?>
|
38 |
</label>
|
39 |
</h3>
|
40 |
|
41 |
+
<?php
|
42 |
+
if ( ! empty( $lists ) ) {
|
43 |
+
?>
|
44 |
<ul id="mc4wp-lists">
|
45 |
+
<?php
|
46 |
+
foreach ( $lists as $list ) {
|
47 |
+
?>
|
48 |
<li>
|
49 |
<label>
|
50 |
+
<input type="checkbox" name="mc4wp_form[settings][lists][<?php echo esc_attr( $list->id ); ?>]" value="<?php echo esc_attr( $list->id ); ?>" <?php checked( $number_of_lists, 1 ); ?> >
|
51 |
+
<?php echo esc_html( $list->name ); ?>
|
52 |
</label>
|
53 |
</li>
|
54 |
+
<?php
|
55 |
+
}
|
56 |
+
?>
|
57 |
</ul>
|
58 |
+
<?php
|
59 |
+
} else {
|
60 |
+
?>
|
61 |
<p class="mc4wp-notice">
|
62 |
+
<?php printf( __( 'No lists found. Did you <a href="%s">connect with Mailchimp</a>?', 'mailchimp-for-wp' ), admin_url( 'admin.php?page=mailchimp-for-wp' ) ); ?>
|
63 |
</p>
|
64 |
+
<?php
|
65 |
+
}
|
66 |
+
?>
|
67 |
|
68 |
</div>
|
69 |
|
70 |
+
<?php submit_button( __( 'Add new form', 'mailchimp-for-wp' ) ); ?>
|
71 |
|
72 |
|
73 |
</form><!-- Entire page form wrap -->
|
includes/forms/views/edit-form.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
<?php defined('ABSPATH') or exit;
|
2 |
|
3 |
$tabs = array(
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
);
|
9 |
|
10 |
/**
|
@@ -13,115 +13,119 @@ $tabs = array(
|
|
13 |
* @param array $tabs
|
14 |
* @ignore
|
15 |
*/
|
16 |
-
$tabs = apply_filters('mc4wp_admin_edit_form_tabs', $tabs);
|
17 |
|
18 |
?>
|
19 |
<div id="mc4wp-admin" class="wrap mc4wp-settings">
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
|
35 |
-
|
36 |
-
|
37 |
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
81 |
|
82 |
-
|
83 |
|
84 |
-
|
|
|
85 |
|
86 |
-
|
87 |
|
88 |
-
|
89 |
-
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
|
104 |
-
|
105 |
-
|
106 |
|
107 |
-
|
|
|
108 |
|
109 |
-
|
110 |
-
|
111 |
|
112 |
-
|
113 |
|
114 |
|
115 |
-
|
116 |
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
-
<!-- Sidebar -->
|
120 |
-
<div class="sidebar col col-1">
|
121 |
-
<?php include MC4WP_PLUGIN_DIR . 'includes/views/parts/admin-sidebar.php'; ?>
|
122 |
-
</div>
|
123 |
|
124 |
-
|
125 |
-
</div>
|
126 |
|
127 |
</div>
|
1 |
+
<?php defined( 'ABSPATH' ) or exit;
|
2 |
|
3 |
$tabs = array(
|
4 |
+
'fields' => __( 'Fields', 'mailchimp-for-wp' ),
|
5 |
+
'messages' => __( 'Messages', 'mailchimp-for-wp' ),
|
6 |
+
'settings' => __( 'Settings', 'mailchimp-for-wp' ),
|
7 |
+
'appearance' => __( 'Appearance', 'mailchimp-for-wp' ),
|
8 |
);
|
9 |
|
10 |
/**
|
13 |
* @param array $tabs
|
14 |
* @ignore
|
15 |
*/
|
16 |
+
$tabs = apply_filters( 'mc4wp_admin_edit_form_tabs', $tabs );
|
17 |
|
18 |
?>
|
19 |
<div id="mc4wp-admin" class="wrap mc4wp-settings">
|
20 |
|
21 |
+
<p class="breadcrumbs">
|
22 |
+
<span class="prefix"><?php echo __( 'You are here: ', 'mailchimp-for-wp' ); ?></span>
|
23 |
+
<a href="<?php echo admin_url( 'admin.php?page=mailchimp-for-wp' ); ?>">Mailchimp for WordPress</a> ›
|
24 |
+
<a href="<?php echo admin_url( 'admin.php?page=mailchimp-for-wp-forms' ); ?>"><?php _e( 'Forms', 'mailchimp-for-wp' ); ?></a>
|
25 |
+
›
|
26 |
+
<span class="current-crumb"><strong><?php echo __( 'Form', 'mailchimp-for-wp' ); ?> <?php echo $form_id; ?>
|
27 |
+
| <?php echo esc_html( $form->name ); ?></strong></span>
|
28 |
+
</p>
|
29 |
|
30 |
+
<div class="row">
|
31 |
|
32 |
+
<!-- Main Content -->
|
33 |
+
<div class="main-content col col-5">
|
34 |
|
35 |
+
<h1 class="page-title">
|
36 |
+
<?php _e( 'Edit Form', 'mailchimp-for-wp' ); ?>
|
37 |
|
38 |
+
<!-- Form actions -->
|
39 |
+
<?php
|
40 |
|
41 |
+
/**
|
42 |
+
* @ignore
|
43 |
+
*/
|
44 |
+
do_action( 'mc4wp_admin_edit_form_after_title' );
|
45 |
+
?>
|
46 |
+
</h1>
|
47 |
|
48 |
+
<h2 style="display: none;"></h2><?php // fake h2 for admin notices ?>
|
49 |
|
50 |
+
<!-- Wrap entire page in <form> -->
|
51 |
+
<form method="post">
|
52 |
+
<?php // default submit button to prevent opening preview ?>
|
53 |
+
<input type="submit" style="display: none; "/>
|
54 |
+
<input type="hidden" name="_mc4wp_action" value="edit_form"/>
|
55 |
+
<input type="hidden" name="mc4wp_form_id" value="<?php echo esc_attr( $form->ID ); ?>"/>
|
56 |
+
<?php wp_nonce_field( 'edit_form', '_mc4wp_nonce' ); ?>
|
57 |
|
58 |
+
<div id="titlediv" class="small-margin">
|
59 |
+
<div id="titlewrap">
|
60 |
+
<label class="screen-reader-text"
|
61 |
+
for="title"><?php _e( 'Enter form title here', 'mailchimp-for-wp' ); ?></label>
|
62 |
+
<input type="text" name="mc4wp_form[name]" size="30"
|
63 |
+
value="<?php echo esc_attr( $form->name ); ?>" id="title" spellcheck="true"
|
64 |
+
autocomplete="off"
|
65 |
+
placeholder="<?php echo __( 'Enter the title of your sign-up form', 'mailchimp-for-wp' ); ?>"
|
66 |
+
style="line-height: initial;">
|
67 |
+
</div>
|
68 |
+
<div>
|
69 |
+
<?php printf( __( 'Use the shortcode %s to display this form inside a post, page or text widget.', 'mailchimp-for-wp' ), '<input type="text" onfocus="this.select();" readonly="readonly" value="' . esc_attr( sprintf( '[mc4wp_form id="%d"]', $form->ID ) ) . '" size="' . ( strlen( $form->ID ) + 18 ) . '">' ); ?>
|
70 |
+
</div>
|
71 |
+
</div>
|
72 |
|
73 |
|
74 |
+
<div>
|
75 |
+
<h2 class="nav-tab-wrapper" id="mc4wp-tabs-nav">
|
76 |
+
<?php
|
77 |
+
foreach ( $tabs as $tab => $name ) {
|
78 |
+
$class = ( $active_tab === $tab ) ? 'nav-tab-active' : '';
|
79 |
+
echo sprintf( '<a class="nav-tab nav-tab-%s %s" href="%s">%s</a>', $tab, $class, esc_attr( $this->tab_url( $tab ) ), $name );
|
80 |
+
}
|
81 |
+
?>
|
82 |
+
</h2>
|
83 |
|
84 |
+
<div id="mc4wp-tabs">
|
85 |
|
86 |
+
<?php
|
87 |
+
foreach ( $tabs as $tab => $name ) :
|
88 |
|
89 |
+
$class = ( $active_tab === $tab ) ? 'tab-active' : '';
|
90 |
|
91 |
+
// start of .tab
|
92 |
+
echo sprintf( '<div class="tab %s" id="tab-%s">', $class, $tab );
|
93 |
|
94 |
+
/**
|
95 |
+
* Runs when outputting a tab section on the "edit form" screen
|
96 |
+
*
|
97 |
+
* @param string $tab
|
98 |
+
* @ignore
|
99 |
+
*/
|
100 |
+
do_action( 'mc4wp_admin_edit_form_output_' . $tab . '_tab', $opts, $form );
|
101 |
|
102 |
+
$tab_file = dirname( __FILE__ ) . '/tabs/form-' . $tab . '.php';
|
103 |
+
if ( file_exists( $tab_file ) ) {
|
104 |
+
include $tab_file;
|
105 |
+
}
|
106 |
|
107 |
+
// end of .tab
|
108 |
+
echo '</div>';
|
109 |
|
110 |
+
endforeach; // foreach tabs
|
111 |
+
?>
|
112 |
|
113 |
+
</div><!-- / tabs -->
|
114 |
+
</div>
|
115 |
|
116 |
+
</form><!-- Entire page form wrap -->
|
117 |
|
118 |
|
119 |
+
<?php include MC4WP_PLUGIN_DIR . 'includes/views/parts/admin-footer.php'; ?>
|
120 |
|
121 |
+
</div>
|
122 |
+
|
123 |
+
<!-- Sidebar -->
|
124 |
+
<div class="sidebar col col-1">
|
125 |
+
<?php include MC4WP_PLUGIN_DIR . 'includes/views/parts/admin-sidebar.php'; ?>
|
126 |
+
</div>
|
127 |
|
|
|
|
|
|
|
|
|
128 |
|
129 |
+
</div>
|
|
|
130 |
|
131 |
</div>
|
includes/forms/views/js/date-fields.js
CHANGED
@@ -1,17 +1,16 @@
|
|
1 |
/* test if browser supports date fields */
|
2 |
-
var testInput = document.createElement('input');
|
3 |
-
testInput.setAttribute('type', 'date');
|
4 |
-
if( testInput.type !== 'date') {
|
5 |
|
6 |
/* add placeholder & pattern to all date fields */
|
7 |
-
var dateFields = document.querySelectorAll('.mc4wp-form input[type="date"]');
|
8 |
-
for(var i=0; i<dateFields.length; i++) {
|
9 |
-
if(!dateFields[i].placeholder) {
|
10 |
dateFields[i].placeholder = 'YYYY-MM-DD';
|
11 |
}
|
12 |
-
if(!dateFields[i].pattern) {
|
13 |
dateFields[i].pattern = '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])';
|
14 |
}
|
15 |
}
|
16 |
}
|
17 |
-
|
1 |
/* test if browser supports date fields */
|
2 |
+
var testInput = document.createElement( 'input' );
|
3 |
+
testInput.setAttribute( 'type', 'date' );
|
4 |
+
if ( testInput.type !== 'date') {
|
5 |
|
6 |
/* add placeholder & pattern to all date fields */
|
7 |
+
var dateFields = document.querySelectorAll( '.mc4wp-form input[type="date"]' );
|
8 |
+
for (var i = 0; i < dateFields.length; i++) {
|
9 |
+
if ( ! dateFields[i].placeholder) {
|
10 |
dateFields[i].placeholder = 'YYYY-MM-DD';
|
11 |
}
|
12 |
+
if ( ! dateFields[i].pattern) {
|
13 |
dateFields[i].pattern = '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])';
|
14 |
}
|
15 |
}
|
16 |
}
|
|
includes/forms/views/js/dummy-api.js
CHANGED
@@ -1,13 +1,15 @@
|
|
1 |
(function() {
|
2 |
-
if (!window.mc4wp) {
|
3 |
window.mc4wp = {
|
4 |
listeners: [],
|
5 |
forms : {
|
6 |
on: function (event, callback) {
|
7 |
-
window.mc4wp.listeners.push(
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
}
|
12 |
}
|
13 |
}
|
1 |
(function() {
|
2 |
+
if ( ! window.mc4wp) {
|
3 |
window.mc4wp = {
|
4 |
listeners: [],
|
5 |
forms : {
|
6 |
on: function (event, callback) {
|
7 |
+
window.mc4wp.listeners.push(
|
8 |
+
{
|
9 |
+
event : event,
|
10 |
+
callback: callback
|
11 |
+
}
|
12 |
+
);
|
13 |
}
|
14 |
}
|
15 |
}
|
includes/forms/views/js/general-form-enhancements.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
function addEventListener(element,event,handler) {
|
2 |
-
if(element.addEventListener) {
|
3 |
-
element.addEventListener(event,handler, false);
|
4 |
-
} else if(element.attachEvent){
|
5 |
-
element.attachEvent('on'+event,handler);
|
6 |
}
|
7 |
-
}
|
1 |
function addEventListener(element,event,handler) {
|
2 |
+
if (element.addEventListener) {
|
3 |
+
element.addEventListener( event,handler, false );
|
4 |
+
} else if (element.attachEvent) {
|
5 |
+
element.attachEvent( 'on' + event,handler );
|
6 |
}
|
7 |
+
}
|
includes/forms/views/js/url-fields.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
function maybePrefixUrlField() {
|
2 |
-
if(this.value.trim() !== '' && this.value.indexOf('http') !== 0) {
|
3 |
this.value = "http://" + this.value;
|
4 |
}
|
5 |
}
|
6 |
|
7 |
-
var urlFields = document.querySelectorAll('.mc4wp-form input[type="url"]');
|
8 |
-
if( urlFields && urlFields.length > 0 ) {
|
9 |
-
for( var j=0; j < urlFields.length; j++ ) {
|
10 |
-
addEventListener(urlFields[j],'blur',maybePrefixUrlField);
|
11 |
}
|
12 |
-
}
|
1 |
function maybePrefixUrlField() {
|
2 |
+
if (this.value.trim() !== '' && this.value.indexOf( 'http' ) !== 0) {
|
3 |
this.value = "http://" + this.value;
|
4 |
}
|
5 |
}
|
6 |
|
7 |
+
var urlFields = document.querySelectorAll( '.mc4wp-form input[type="url"]' );
|
8 |
+
if ( urlFields && urlFields.length > 0 ) {
|
9 |
+
for ( var j = 0; j < urlFields.length; j++ ) {
|
10 |
+
addEventListener( urlFields[j],'blur',maybePrefixUrlField );
|
11 |
}
|
12 |
+
}
|
includes/forms/views/parts/add-fields-help.php
CHANGED
@@ -1,48 +1,50 @@
|
|
1 |
-
<?php defined('ABSPATH') or exit; ?>
|
2 |
|
3 |
<div class="mc4wp-admin">
|
4 |
-
<h2><?php _e('Add more fields', 'mailchimp-for-wp'); ?></h2>
|
5 |
|
6 |
<div class="help-text">
|
7 |
|
8 |
<p>
|
9 |
-
<?php echo __('To add more fields to your form, you will need to create those fields in Mailchimp first.', 'mailchimp-for-wp'); ?>
|
10 |
</p>
|
11 |
|
12 |
-
<p><strong><?php echo __("Here's how:", 'mailchimp-for-wp'); ?></strong></p>
|
13 |
|
14 |
<ol>
|
15 |
<li>
|
16 |
<p>
|
17 |
-
<?php echo __('Log in to your Mailchimp account.', 'mailchimp-for-wp'); ?>
|
18 |
</p>
|
19 |
</li>
|
20 |
<li>
|
21 |
<p>
|
22 |
-
<?php echo __('Add list fields to any of your selected lists.', 'mailchimp-for-wp'); ?>
|
23 |
-
<?php echo __('Clicking the following links will take you to the right screen.', 'mailchimp-for-wp'); ?>
|
24 |
</p>
|
25 |
<ul class="children lists--only-selected">
|
26 |
-
<?php
|
27 |
-
|
28 |
-
|
|
|
29 |
<a href="https://admin.mailchimp.com/lists/settings/merge-tags?id=<?php echo $list->web_id; ?>">
|
30 |
-
<span class="screen-reader-text"><?php _e('Edit list fields for', 'mailchimp-for-wp'); ?> </span>
|
31 |
<?php echo $list->name; ?>
|
32 |
</a>
|
33 |
</li>
|
34 |
-
|
35 |
-
}
|
|
|
36 |
</ul>
|
37 |
</li>
|
38 |
<li>
|
39 |
<p>
|
40 |
-
<?php echo __('Click the following button to have Mailchimp for WordPress pick up on your changes.', 'mailchimp-for-wp'); ?>
|
41 |
</p>
|
42 |
|
43 |
<p>
|
44 |
-
<a class="button button-primary" href="<?php echo esc_attr(add_query_arg(array( '_mc4wp_action' => 'empty_lists_cache' ))); ?>">
|
45 |
-
<?php _e('Renew Mailchimp lists', 'mailchimp-for-wp'); ?>
|
46 |
</a>
|
47 |
</p>
|
48 |
</li>
|
@@ -50,4 +52,4 @@
|
|
50 |
|
51 |
|
52 |
</div>
|
53 |
-
</div>
|
1 |
+
<?php defined( 'ABSPATH' ) or exit; ?>
|
2 |
|
3 |
<div class="mc4wp-admin">
|
4 |
+
<h2><?php _e( 'Add more fields', 'mailchimp-for-wp' ); ?></h2>
|
5 |
|
6 |
<div class="help-text">
|
7 |
|
8 |
<p>
|
9 |
+
<?php echo __( 'To add more fields to your form, you will need to create those fields in Mailchimp first.', 'mailchimp-for-wp' ); ?>
|
10 |
</p>
|
11 |
|
12 |
+
<p><strong><?php echo __( "Here's how:", 'mailchimp-for-wp' ); ?></strong></p>
|
13 |
|
14 |
<ol>
|
15 |
<li>
|
16 |
<p>
|
17 |
+
<?php echo __( 'Log in to your Mailchimp account.', 'mailchimp-for-wp' ); ?>
|
18 |
</p>
|
19 |
</li>
|
20 |
<li>
|
21 |
<p>
|
22 |
+
<?php echo __( 'Add list fields to any of your selected lists.', 'mailchimp-for-wp' ); ?>
|
23 |
+
<?php echo __( 'Clicking the following links will take you to the right screen.', 'mailchimp-for-wp' ); ?>
|
24 |
</p>
|
25 |
<ul class="children lists--only-selected">
|
26 |
+
<?php
|
27 |
+
foreach ( $lists as $list ) {
|
28 |
+
?>
|
29 |
+
<li data-list-id="<?php echo $list->id; ?>" style="display: <?php echo in_array( $list->id, $opts['lists'] ) ? '' : 'none'; ?>">
|
30 |
<a href="https://admin.mailchimp.com/lists/settings/merge-tags?id=<?php echo $list->web_id; ?>">
|
31 |
+
<span class="screen-reader-text"><?php _e( 'Edit list fields for', 'mailchimp-for-wp' ); ?> </span>
|
32 |
<?php echo $list->name; ?>
|
33 |
</a>
|
34 |
</li>
|
35 |
+
<?php
|
36 |
+
}
|
37 |
+
?>
|
38 |
</ul>
|
39 |
</li>
|
40 |
<li>
|
41 |
<p>
|
42 |
+
<?php echo __( 'Click the following button to have Mailchimp for WordPress pick up on your changes.', 'mailchimp-for-wp' ); ?>
|
43 |
</p>
|
44 |
|
45 |
<p>
|
46 |
+
<a class="button button-primary" href="<?php echo esc_attr( add_query_arg( array( '_mc4wp_action' => 'empty_lists_cache' ) ) ); ?>">
|
47 |
+
<?php _e( 'Renew Mailchimp lists', 'mailchimp-for-wp' ); ?>
|
48 |
</a>
|
49 |
</p>
|
50 |
</li>
|
52 |
|
53 |
|
54 |
</div>
|
55 |
+
</div>
|
includes/forms/views/parts/dynamic-content-tags.php
CHANGED
@@ -1,21 +1,24 @@
|
|
1 |
<?php
|
2 |
-
defined('ABSPATH') or exit;
|
3 |
|
4 |
-
$tags = mc4wp('forms')->get_tags();
|
5 |
?>
|
6 |
-
<h2><?php _e('Add dynamic form variable', 'mailchimp-for-wp'); ?></h2>
|
7 |
<p>
|
8 |
-
<?php echo sprintf(__('The following list of variables can be used to <a href="%s">add some dynamic content to your form or success and error messages</a>.', 'mailchimp-for-wp'), 'https://kb.mc4wp.com/using-variables-in-your-form-or-messages/') . ' ' . __('This allows you to personalise your form or response messages.', 'mailchimp-for-wp'); ?>
|
9 |
</p>
|
10 |
<table class="widefat striped">
|
11 |
-
<?php
|
12 |
-
|
|
|
|
|
13 |
<tr>
|
14 |
<td>
|
15 |
-
<input type="text" class="widefat" value="<?php echo esc_attr(sprintf('{%s}', $tag)); ?>" readonly="readonly" onfocus="this.select();" />
|
16 |
-
<p class="help" style="margin-bottom:0;"><?php echo strip_tags($config['description'], '<strong><b><em><i><a><code>'); ?></p>
|
17 |
</td>
|
18 |
</tr>
|
19 |
-
|
20 |
-
}
|
|
|
21 |
</table>
|
1 |
<?php
|
2 |
+
defined( 'ABSPATH' ) or exit;
|
3 |
|
4 |
+
$tags = mc4wp( 'forms' )->get_tags();
|
5 |
?>
|
6 |
+
<h2><?php _e( 'Add dynamic form variable', 'mailchimp-for-wp' ); ?></h2>
|
7 |
<p>
|
8 |
+
<?php echo sprintf( __( 'The following list of variables can be used to <a href="%s">add some dynamic content to your form or success and error messages</a>.', 'mailchimp-for-wp' ), 'https://kb.mc4wp.com/using-variables-in-your-form-or-messages/' ) . ' ' . __( 'This allows you to personalise your form or response messages.', 'mailchimp-for-wp' ); ?>
|
9 |
</p>
|
10 |
<table class="widefat striped">
|
11 |
+
<?php
|
12 |
+
foreach ( $tags as $tag => $config ) {
|
13 |
+
$tag = ! empty( $config['example'] ) ? $config['example'] : $tag;
|
14 |
+
?>
|
15 |
<tr>
|
16 |
<td>
|
17 |
+
<input type="text" class="widefat" value="<?php echo esc_attr( sprintf( '{%s}', $tag ) ); ?>" readonly="readonly" onfocus="this.select();" />
|
18 |
+
<p class="help" style="margin-bottom:0;"><?php echo strip_tags( $config['description'], '<strong><b><em><i><a><code>' ); ?></p>
|
19 |
</td>
|
20 |
</tr>
|
21 |
+
<?php
|
22 |
+
}
|
23 |
+
?>
|
24 |
</table>
|
includes/forms/views/preview.php
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
<?php
|
2 |
-
defined('ABSPATH') or exit;
|
3 |
|
4 |
// fake post to prevent notices in wp_enqueue_scripts call
|
5 |
-
$GLOBALS['post'] = new \WP_Post((object) array( 'filter' => 'raw' ));
|
6 |
|
7 |
// render simple page with form in it.
|
8 |
?><!DOCTYPE html>
|
9 |
<html>
|
10 |
<head>
|
11 |
-
|
12 |
-
|
13 |
<?php
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
</head>
|
47 |
<body class="page-template-default page ">
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
<?php wp_footer(); ?>
|
52 |
</body>
|
53 |
</html>
|
1 |
<?php
|
2 |
+
defined( 'ABSPATH' ) or exit;
|
3 |
|
4 |
// fake post to prevent notices in wp_enqueue_scripts call
|
5 |
+
$GLOBALS['post'] = new \WP_Post( (object) array( 'filter' => 'raw' ) );
|
6 |
|
7 |
// render simple page with form in it.
|
8 |
?><!DOCTYPE html>
|
9 |
<html>
|
10 |
<head>
|
11 |
+
<meta charset="utf-8" />
|
12 |
+
<link type="text/css" rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
|
13 |
<?php
|
14 |
+
wp_enqueue_scripts();
|
15 |
+
wp_print_styles();
|
16 |
+
wp_print_head_scripts();
|
17 |
|
18 |
+
if ( function_exists( 'wp_custom_css_cb' ) ) {
|
19 |
+
wp_custom_css_cb();
|
20 |
+
}
|
21 |
+
?>
|
22 |
+
<style type="text/css">
|
23 |
+
body{
|
24 |
+
background: white;
|
25 |
+
width: 100%;
|
26 |
+
max-width: 100%;
|
27 |
+
text-align: left;
|
28 |
+
}
|
29 |
|
30 |
+
/* hide all other elements */
|
31 |
+
body::before,
|
32 |
+
body::after,
|
33 |
+
body > *:not(#form-preview) {
|
34 |
+
display:none !important;
|
35 |
+
}
|
36 |
|
37 |
+
#form-preview {
|
38 |
+
display: block !important;
|
39 |
+
width: 100%;
|
40 |
+
height: 100%;
|
41 |
+
padding: 20px;
|
42 |
+
border: 0;
|
43 |
+
margin: 0;
|
44 |
+
}
|
45 |
+
</style>
|
46 |
</head>
|
47 |
<body class="page-template-default page ">
|
48 |
+
<div id="form-preview" class="page type-page status-publish hentry post post-content">
|
49 |
+
<?php mc4wp_show_form( $form_id ); ?>
|
50 |
+
</div>
|
51 |
<?php wp_footer(); ?>
|
52 |
</body>
|
53 |
</html>
|
includes/forms/views/tabs/form-appearance.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
$theme
|
4 |
$css_options = array(
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
);
|
15 |
|
16 |
/**
|
@@ -18,43 +18,45 @@ $css_options = array(
|
|
18 |
*
|
19 |
* @ignore
|
20 |
*/
|
21 |
-
$css_options = apply_filters('mc4wp_admin_form_css_options', $css_options);
|
22 |
|
23 |
?>
|
24 |
|
25 |
-
<h2><?php _e('Form Appearance', 'mailchimp-for-wp'); ?></h2>
|
26 |
|
27 |
<table class="form-table">
|
28 |
<tr valign="top">
|
29 |
-
<th scope="row"><label for="mc4wp_load_stylesheet_select"><?php _e('Form Style', 'mailchimp-for-wp'); ?></label></th>
|
30 |
<td class="nowrap valigntop">
|
31 |
<select name="mc4wp_form[settings][css]" id="mc4wp_load_stylesheet_select">
|
32 |
|
33 |
-
<?php
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
}
|
|
|
|
|
46 |
</select>
|
47 |
<p class="help">
|
48 |
-
<?php _e('If you want to load some default CSS styles, select "basic formatting styles" or choose one of the color themes', 'mailchimp-for-wp'); ?>
|
49 |
</p>
|
50 |
</td>
|
51 |
</tr>
|
52 |
|
53 |
<?php
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
|
58 |
</table>
|
59 |
|
60 |
-
<?php submit_button(); ?>
|
1 |
<?php
|
2 |
|
3 |
+
$theme = wp_get_theme();
|
4 |
$css_options = array(
|
5 |
+
'0' => sprintf( __( 'Inherit from %s theme', 'mailchimp-for-wp' ), $theme->Name ),
|
6 |
+
'basic' => __( 'Basic', 'mailchimp-for-wp' ),
|
7 |
+
__( 'Form Themes', 'mailchimp-for-wp' ) => array(
|
8 |
+
'theme-light' => __( 'Light Theme', 'mailchimp-for-wp' ),
|
9 |
+
'theme-dark' => __( 'Dark Theme', 'mailchimp-for-wp' ),
|
10 |
+
'theme-red' => __( 'Red Theme', 'mailchimp-for-wp' ),
|
11 |
+
'theme-green' => __( 'Green Theme', 'mailchimp-for-wp' ),
|
12 |
+
'theme-blue' => __( 'Blue Theme', 'mailchimp-for-wp' ),
|
13 |
+
),
|
14 |
);
|
15 |
|
16 |
/**
|
18 |
*
|
19 |
* @ignore
|
20 |
*/
|
21 |
+
$css_options = apply_filters( 'mc4wp_admin_form_css_options', $css_options );
|
22 |
|
23 |
?>
|
24 |
|
25 |
+
<h2><?php _e( 'Form Appearance', 'mailchimp-for-wp' ); ?></h2>
|
26 |
|
27 |
<table class="form-table">
|
28 |
<tr valign="top">
|
29 |
+
<th scope="row"><label for="mc4wp_load_stylesheet_select"><?php _e( 'Form Style', 'mailchimp-for-wp' ); ?></label></th>
|
30 |
<td class="nowrap valigntop">
|
31 |
<select name="mc4wp_form[settings][css]" id="mc4wp_load_stylesheet_select">
|
32 |
|
33 |
+
<?php
|
34 |
+
foreach ( $css_options as $key => $option ) {
|
35 |
+
if ( is_array( $option ) ) {
|
36 |
+
$label = $key;
|
37 |
+
$options = $option;
|
38 |
+
printf( '<optgroup label="%s">', $label );
|
39 |
+
foreach ( $options as $key => $option ) {
|
40 |
+
printf( '<option value="%s" %s>%s</option>', $key, selected( $opts['css'], $key, false ), $option );
|
41 |
+
}
|
42 |
+
print( '</optgroup>' );
|
43 |
+
} else {
|
44 |
+
printf( '<option value="%s" %s>%s</option>', $key, selected( $opts['css'], $key, false ), $option );
|
45 |
+
}
|
46 |
+
}
|
47 |
+
?>
|
48 |
</select>
|
49 |
<p class="help">
|
50 |
+
<?php _e( 'If you want to load some default CSS styles, select "basic formatting styles" or choose one of the color themes', 'mailchimp-for-wp' ); ?>
|
51 |
</p>
|
52 |
</td>
|
53 |
</tr>
|
54 |
|
55 |
<?php
|
56 |
+
/** @ignore */
|
57 |
+
do_action( 'mc4wp_admin_form_after_appearance_settings_rows', $opts, $form );
|
58 |
+
?>
|
59 |
|
60 |
</table>
|
61 |
|
62 |
+
<?php submit_button(); ?>
|
includes/forms/views/tabs/form-fields.php
CHANGED
@@ -3,48 +3,48 @@
|
|
3 |
<div class="alignright">
|
4 |
<a href="#TB_inline?width=0&height=550&inlineId=mc4wp-form-variables" class="thickbox button-secondary">
|
5 |
<span class="dashicons dashicons-info"></span>
|
6 |
-
<?php _e('Form variables', 'mailchimp-for-wp'); ?>
|
7 |
</a>
|
8 |
<a href="#TB_inline?width=600&height=400&inlineId=mc4wp-add-field-help" class="thickbox button-secondary">
|
9 |
<span class="dashicons dashicons-editor-help"></span>
|
10 |
-
<?php _e('Add more fields', 'mailchimp-for-wp'); ?>
|
11 |
</a>
|
12 |
</div>
|
13 |
-
<h2><?php _e(
|
14 |
|
15 |
<!-- Placeholder for the field wizard -->
|
16 |
<div id="mc4wp-field-wizard"></div>
|
17 |
|
18 |
<div class="mc4wp-row">
|
19 |
<div class="mc4wp-col mc4wp-col-3 mc4wp-form-editor-wrap">
|
20 |
-
<h4 style="margin: 0"><label><?php _e('Form code', 'mailchimp-for-wp'); ?></label></h4>
|
21 |
<!-- Textarea for the actual form content HTML -->
|
22 |
-
<textarea class="widefat" cols="160" rows="20" id="mc4wp-form-content" name="mc4wp_form[content]" placeholder="<?php _e('Enter the HTML code for your form fields..', 'mailchimp-for-wp'); ?>" autocomplete="false" autocorrect="false" autocapitalize="false" spellcheck="false"><?php echo htmlspecialchars($form->content, ENT_QUOTES, get_option('blog_charset')); ?></textarea>
|
23 |
</div>
|
24 |
<div class="mc4wp-col mc4wp-col-3 mc4wp-form-preview-wrap">
|
25 |
<h4 style="margin: 0;">
|
26 |
-
<label><?php _e('Form preview', 'mailchimp-for-wp'); ?>
|
27 |
-
<span class="mc4wp-tooltip dashicons dashicons-editor-help" title="<?php esc_attr_e('The form may look slightly different than this when shown in a post, page or widget area.', 'mailchimp-for-wp'); ?>"></span>
|
28 |
</label>
|
29 |
</h4>
|
30 |
-
<iframe id="mc4wp-form-preview" src="<?php echo esc_attr($form_preview_url); ?>"></iframe>
|
31 |
</div>
|
32 |
</div>
|
33 |
|
34 |
|
35 |
<!-- This field is updated by JavaScript as the form content changes -->
|
36 |
-
<input type="hidden" id="required-fields" name="mc4wp_form[settings][required_fields]" value="<?php echo esc_attr($form->settings['required_fields']); ?>" />
|
37 |
|
38 |
<?php submit_button(); ?>
|
39 |
|
40 |
-
<p class="mc4wp-form-usage"><?php printf(__('Use the shortcode %s to display this form inside a post, page or text widget.', 'mailchimp-for-wp'), '<input type="text" onfocus="this.select();" readonly="readonly" value="'. esc_attr(sprintf('[mc4wp_form id="%d"]', $form->ID)) .'" size="'. (strlen($form->ID) + 18) .'">'); ?></p>
|
41 |
|
42 |
|
43 |
-
<?php // Content for Thickboxes?>
|
44 |
<div id="mc4wp-form-variables" style="display: none;">
|
45 |
-
<?php include dirname(__FILE__) . '/../parts/dynamic-content-tags.php'; ?>
|
46 |
</div>
|
47 |
|
48 |
<div id="mc4wp-add-field-help" style="display: none;">
|
49 |
-
<?php include dirname(__FILE__) . '/../parts/add-fields-help.php'; ?>
|
50 |
</div>
|
3 |
<div class="alignright">
|
4 |
<a href="#TB_inline?width=0&height=550&inlineId=mc4wp-form-variables" class="thickbox button-secondary">
|
5 |
<span class="dashicons dashicons-info"></span>
|
6 |
+
<?php _e( 'Form variables', 'mailchimp-for-wp' ); ?>
|
7 |
</a>
|
8 |
<a href="#TB_inline?width=600&height=400&inlineId=mc4wp-add-field-help" class="thickbox button-secondary">
|
9 |
<span class="dashicons dashicons-editor-help"></span>
|
10 |
+
<?php _e( 'Add more fields', 'mailchimp-for-wp' ); ?>
|
11 |
</a>
|
12 |
</div>
|
13 |
+
<h2><?php _e( 'Form Fields', 'mailchimp-for-wp' ); ?></h2>
|
14 |
|
15 |
<!-- Placeholder for the field wizard -->
|
16 |
<div id="mc4wp-field-wizard"></div>
|
17 |
|
18 |
<div class="mc4wp-row">
|
19 |
<div class="mc4wp-col mc4wp-col-3 mc4wp-form-editor-wrap">
|
20 |
+
<h4 style="margin: 0"><label><?php _e( 'Form code', 'mailchimp-for-wp' ); ?></label></h4>
|
21 |
<!-- Textarea for the actual form content HTML -->
|
22 |
+
<textarea class="widefat" cols="160" rows="20" id="mc4wp-form-content" name="mc4wp_form[content]" placeholder="<?php _e( 'Enter the HTML code for your form fields..', 'mailchimp-for-wp' ); ?>" autocomplete="false" autocorrect="false" autocapitalize="false" spellcheck="false"><?php echo htmlspecialchars( $form->content, ENT_QUOTES, get_option( 'blog_charset' ) ); ?></textarea>
|
23 |
</div>
|
24 |
<div class="mc4wp-col mc4wp-col-3 mc4wp-form-preview-wrap">
|
25 |
<h4 style="margin: 0;">
|
26 |
+
<label><?php _e( 'Form preview', 'mailchimp-for-wp' ); ?>
|
27 |
+
<span class="mc4wp-tooltip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'The form may look slightly different than this when shown in a post, page or widget area.', 'mailchimp-for-wp' ); ?>"></span>
|
28 |
</label>
|
29 |
</h4>
|
30 |
+
<iframe id="mc4wp-form-preview" src="<?php echo esc_attr( $form_preview_url ); ?>"></iframe>
|
31 |
</div>
|
32 |
</div>
|
33 |
|
34 |
|
35 |
<!-- This field is updated by JavaScript as the form content changes -->
|
36 |
+
<input type="hidden" id="required-fields" name="mc4wp_form[settings][required_fields]" value="<?php echo esc_attr( $form->settings['required_fields'] ); ?>" />
|
37 |
|
38 |
<?php submit_button(); ?>
|
39 |
|
40 |
+
<p class="mc4wp-form-usage"><?php printf( __( 'Use the shortcode %s to display this form inside a post, page or text widget.', 'mailchimp-for-wp' ), '<input type="text" onfocus="this.select();" readonly="readonly" value="' . esc_attr( sprintf( '[mc4wp_form id="%d"]', $form->ID ) ) . '" size="' . ( strlen( $form->ID ) + 18 ) . '">' ); ?></p>
|
41 |
|
42 |
|
43 |
+
<?php // Content for Thickboxes ?>
|
44 |
<div id="mc4wp-form-variables" style="display: none;">
|
45 |
+
<?php include dirname( __FILE__ ) . '/../parts/dynamic-content-tags.php'; ?>
|
46 |
</div>
|
47 |
|
48 |
<div id="mc4wp-add-field-help" style="display: none;">
|
49 |
+
<?php include dirname( __FILE__ ) . '/../parts/add-fields-help.php'; ?>
|
50 |
</div>
|
includes/forms/views/tabs/form-messages.php
CHANGED
@@ -1,92 +1,97 @@
|
|
1 |
-
<?php defined('ABSPATH') or exit;
|
2 |
|
3 |
/** @var MC4WP_Form $form */
|
4 |
?>
|
5 |
|
6 |
-
<h2><?php _e('Form Messages', 'mailchimp-for-wp'); ?></h2>
|
7 |
|
8 |
<table class="form-table mc4wp-form-messages">
|
9 |
|
10 |
<?php
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
<tr valign="top">
|
16 |
-
<th scope="row"><label for="mc4wp_form_subscribed"><?php _e('Successfully subscribed', 'mailchimp-for-wp'); ?></label></th>
|
17 |
<td>
|
18 |
-
<input type="text" class="widefat" id="mc4wp_form_subscribed" name="mc4wp_form[messages][subscribed]" value="<?php echo esc_attr($form->messages['subscribed']); ?>" />
|
19 |
-
<p class="help"><?php _e('The text that shows when an email address is successfully subscribed to the selected list(s).', 'mailchimp-for-wp'); ?></p>
|
20 |
</td>
|
21 |
</tr>
|
22 |
<tr valign="top">
|
23 |
-
<th scope="row"><label for="mc4wp_form_invalid_email"><?php _e('Invalid email address', 'mailchimp-for-wp'); ?></label></th>
|
24 |
<td>
|
25 |
-
<input type="text" class="widefat" id="mc4wp_form_invalid_email" name="mc4wp_form[messages][invalid_email]" value="<?php echo esc_attr($form->messages['invalid_email']); ?>" required />
|
26 |
-
<p class="help"><?php _e('The text that shows when an invalid email address is given.', 'mailchimp-for-wp'); ?></p>
|
27 |
</td>
|
28 |
</tr>
|
29 |
<tr valign="top">
|
30 |
-
<th scope="row"><label for="mc4wp_form_required_field_missing"><?php _e('Required field missing', 'mailchimp-for-wp'); ?></label></th>
|
31 |
<td>
|
32 |
-
<input type="text" class="widefat" id="mc4wp_form_required_field_missing" name="mc4wp_form[messages][required_field_missing]" value="<?php echo esc_attr($form->messages['required_field_missing']); ?>" required />
|
33 |
-
<p class="help"><?php _e('The text that shows when a required field for the selected list(s) is missing.', 'mailchimp-for-wp'); ?></p>
|
34 |
</td>
|
35 |
</tr>
|
36 |
<tr valign="top">
|
37 |
-
<th scope="row"><label for="mc4wp_form_already_subscribed"><?php _e('Already subscribed', 'mailchimp-for-wp'); ?></label></th>
|
38 |
<td>
|
39 |
-
<input type="text" class="widefat" id="mc4wp_form_already_subscribed" name="mc4wp_form[messages][already_subscribed]" value="<?php echo esc_attr($form->messages['already_subscribed']); ?>" required />
|
40 |
-
<p class="help"><?php _e('The text that shows when the given email is already subscribed to the selected list(s).', 'mailchimp-for-wp'); ?></p>
|
41 |
</td>
|
42 |
</tr>
|
43 |
<tr valign="top">
|
44 |
-
<th scope="row"><label for="mc4wp_form_error"><?php _e('General error', 'mailchimp-for-wp'); ?></label></th>
|
45 |
<td>
|
46 |
-
<input type="text" class="widefat" id="mc4wp_form_error" name="mc4wp_form[messages][error]" value="<?php echo esc_attr($form->messages['error']); ?>" required />
|
47 |
-
<p class="help"><?php _e('The text that shows when a general error occured.', 'mailchimp-for-wp'); ?></p>
|
48 |
</td>
|
49 |
</tr>
|
50 |
<tr valign="top">
|
51 |
-
<th scope="row"><label for="mc4wp_form_unsubscribed"><?php _e('Unsubscribed', 'mailchimp-for-wp'); ?></label></th>
|
52 |
<td>
|
53 |
-
<input type="text" class="widefat" id="mc4wp_form_unsubscribed" name="mc4wp_form[messages][unsubscribed]" value="<?php echo esc_attr($form->messages['unsubscribed']); ?>" required />
|
54 |
-
<p class="help"><?php _e('When using the unsubscribe method, this is the text that shows when the given email address is successfully unsubscribed from the selected list(s).', 'mailchimp-for-wp'); ?></p>
|
55 |
</td>
|
56 |
</tr>
|
57 |
<tr valign="top">
|
58 |
-
<th scope="row"><label for="mc4wp_form_not_subscribed"><?php _e('Not subscribed', 'mailchimp-for-wp'); ?></label></th>
|
59 |
<td>
|
60 |
-
<input type="text" class="widefat" id="mc4wp_form_not_subscribed" name="mc4wp_form[messages][not_subscribed]" value="<?php echo esc_attr($form->messages['not_subscribed']); ?>" required />
|
61 |
-
<p class="help"><?php _e('When using the unsubscribe method, this is the text that shows when the given email address is not on the selected list(s).', 'mailchimp-for-wp'); ?></p>
|
62 |
</td>
|
63 |
</tr>
|
64 |
<tr valign="top">
|
65 |
-
<th scope="row"><label for="mc4wp_form_no_lists_selected"><?php _e('No list selected', 'mailchimp-for-wp'); ?></label></th>
|
66 |
<td>
|
67 |
-
<input type="text" class="widefat" id="mc4wp_form_no_lists_selected" name="mc4wp_form[messages][no_lists_selected]" value="<?php echo esc_attr($form->messages[
|
68 |
-
<p class="help"><?php _e('When offering a list choice, this is the text that shows when no lists were selected.', 'mailchimp-for-wp'); ?></p>
|
69 |
</td>
|
70 |
</tr>
|
71 |
|
72 |
-
<?php
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
75 |
<td>
|
76 |
-
<input type="text" class="widefat" id="mc4wp_form_updated" name="mc4wp_form[messages][updated]" value="<?php echo esc_attr($form->messages['updated']); ?>" />
|
77 |
-
<p class="help"><?php _e('The text that shows when an existing subscriber is updated.', 'mailchimp-for-wp'); ?></p>
|
78 |
</td>
|
79 |
</tr>
|
80 |
|
81 |
<?php
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
|
86 |
<tr valign="top">
|
87 |
<th></th>
|
88 |
<td>
|
89 |
-
<p class="help"><?php printf(__('HTML tags like %s are allowed in the message fields.', 'mailchimp-for-wp'), '<code>' . esc_html('<strong><em><a>') . '</code>'); ?></p>
|
90 |
</td>
|
91 |
</tr>
|
92 |
|
1 |
+
<?php defined( 'ABSPATH' ) or exit;
|
2 |
|
3 |
/** @var MC4WP_Form $form */
|
4 |
?>
|
5 |
|
6 |
+
<h2><?php _e( 'Form Messages', 'mailchimp-for-wp' ); ?></h2>
|
7 |
|
8 |
<table class="form-table mc4wp-form-messages">
|
9 |
|
10 |
<?php
|
11 |
+
/** @ignore */
|
12 |
+
do_action( 'mc4wp_admin_form_before_messages_settings_rows', $opts, $form );
|
13 |
+
?>
|
14 |
|
15 |
<tr valign="top">
|
16 |
+
<th scope="row"><label for="mc4wp_form_subscribed"><?php _e( 'Successfully subscribed', 'mailchimp-for-wp' ); ?></label></th>
|
17 |
<td>
|
18 |
+
<input type="text" class="widefat" id="mc4wp_form_subscribed" name="mc4wp_form[messages][subscribed]" value="<?php echo esc_attr( $form->messages['subscribed'] ); ?>" />
|
19 |
+
<p class="help"><?php _e( 'The text that shows when an email address is successfully subscribed to the selected list(s).', 'mailchimp-for-wp' ); ?></p>
|
20 |
</td>
|
21 |
</tr>
|
22 |
<tr valign="top">
|
23 |
+
<th scope="row"><label for="mc4wp_form_invalid_email"><?php _e( 'Invalid email address', 'mailchimp-for-wp' ); ?></label></th>
|
24 |
<td>
|
25 |
+
<input type="text" class="widefat" id="mc4wp_form_invalid_email" name="mc4wp_form[messages][invalid_email]" value="<?php echo esc_attr( $form->messages['invalid_email'] ); ?>" required />
|
26 |
+
<p class="help"><?php _e( 'The text that shows when an invalid email address is given.', 'mailchimp-for-wp' ); ?></p>
|
27 |
</td>
|
28 |
</tr>
|
29 |
<tr valign="top">
|
30 |
+
<th scope="row"><label for="mc4wp_form_required_field_missing"><?php _e( 'Required field missing', 'mailchimp-for-wp' ); ?></label></th>
|
31 |
<td>
|
32 |
+
<input type="text" class="widefat" id="mc4wp_form_required_field_missing" name="mc4wp_form[messages][required_field_missing]" value="<?php echo esc_attr( $form->messages['required_field_missing'] ); ?>" required />
|
33 |
+
<p class="help"><?php _e( 'The text that shows when a required field for the selected list(s) is missing.', 'mailchimp-for-wp' ); ?></p>
|
34 |
</td>
|
35 |
</tr>
|
36 |
<tr valign="top">
|
37 |
+
<th scope="row"><label for="mc4wp_form_already_subscribed"><?php _e( 'Already subscribed', 'mailchimp-for-wp' ); ?></label></th>
|
38 |
<td>
|
39 |
+
<input type="text" class="widefat" id="mc4wp_form_already_subscribed" name="mc4wp_form[messages][already_subscribed]" value="<?php echo esc_attr( $form->messages['already_subscribed'] ); ?>" required />
|
40 |
+
<p class="help"><?php _e( 'The text that shows when the given email is already subscribed to the selected list(s).', 'mailchimp-for-wp' ); ?></p>
|
41 |
</td>
|
42 |
</tr>
|
43 |
<tr valign="top">
|
44 |
+
<th scope="row"><label for="mc4wp_form_error"><?php _e( 'General error', 'mailchimp-for-wp' ); ?></label></th>
|
45 |
<td>
|
46 |
+
<input type="text" class="widefat" id="mc4wp_form_error" name="mc4wp_form[messages][error]" value="<?php echo esc_attr( $form->messages['error'] ); ?>" required />
|
47 |
+
<p class="help"><?php _e( 'The text that shows when a general error occured.', 'mailchimp-for-wp' ); ?></p>
|
48 |
</td>
|
49 |
</tr>
|
50 |
<tr valign="top">
|
51 |
+
<th scope="row"><label for="mc4wp_form_unsubscribed"><?php _e( 'Unsubscribed', 'mailchimp-for-wp' ); ?></label></th>
|
52 |
<td>
|
53 |
+
<input type="text" class="widefat" id="mc4wp_form_unsubscribed" name="mc4wp_form[messages][unsubscribed]" value="<?php echo esc_attr( $form->messages['unsubscribed'] ); ?>" required />
|
54 |
+
<p class="help"><?php _e( 'When using the unsubscribe method, this is the text that shows when the given email address is successfully unsubscribed from the selected list(s).', 'mailchimp-for-wp' ); ?></p>
|
55 |
</td>
|
56 |
</tr>
|
57 |
<tr valign="top">
|
58 |
+
<th scope="row"><label for="mc4wp_form_not_subscribed"><?php _e( 'Not subscribed', 'mailchimp-for-wp' ); ?></label></th>
|
59 |
<td>
|
60 |
+
<input type="text" class="widefat" id="mc4wp_form_not_subscribed" name="mc4wp_form[messages][not_subscribed]" value="<?php echo esc_attr( $form->messages['not_subscribed'] ); ?>" required />
|
61 |
+
<p class="help"><?php _e( 'When using the unsubscribe method, this is the text that shows when the given email address is not on the selected list(s).', 'mailchimp-for-wp' ); ?></p>
|
62 |
</td>
|
63 |
</tr>
|
64 |
<tr valign="top">
|
65 |
+
<th scope="row"><label for="mc4wp_form_no_lists_selected"><?php _e( 'No list selected', 'mailchimp-for-wp' ); ?></label></th>
|
66 |
<td>
|
67 |
+
<input type="text" class="widefat" id="mc4wp_form_no_lists_selected" name="mc4wp_form[messages][no_lists_selected]" value="<?php echo esc_attr( $form->messages['no_lists_selected'] ); ?>" required />
|
68 |
+
<p class="help"><?php _e( 'When offering a list choice, this is the text that shows when no lists were selected.', 'mailchimp-for-wp' ); ?></p>
|
69 |
</td>
|
70 |
</tr>
|
71 |
|
72 |
+
<?php
|
73 |
+
$config = array(
|
74 |
+
'element' => 'mc4wp_form[settings][update_existing]',
|
75 |
+
'value' => 1,
|
76 |
+
);
|
77 |
+
?>
|
78 |
+
<tr valign="top" data-showif="<?php echo esc_attr( json_encode( $config ) ); ?>">
|
79 |
+
<th scope="row"><label for="mc4wp_form_updated"><?php _e( 'Updated', 'mailchimp-for-wp' ); ?></label></th>
|
80 |
<td>
|
81 |
+
<input type="text" class="widefat" id="mc4wp_form_updated" name="mc4wp_form[messages][updated]" value="<?php echo esc_attr( $form->messages['updated'] ); ?>" />
|
82 |
+
<p class="help"><?php _e( 'The text that shows when an existing subscriber is updated.', 'mailchimp-for-wp' ); ?></p>
|
83 |
</td>
|
84 |
</tr>
|
85 |
|
86 |
<?php
|
87 |
+
/** @ignore */
|
88 |
+
do_action( 'mc4wp_admin_form_after_messages_settings_rows', array(), $form );
|
89 |
+
?>
|
90 |
|
91 |
<tr valign="top">
|
92 |
<th></th>
|
93 |
<td>
|
94 |
+
<p class="help"><?php printf( __( 'HTML tags like %s are allowed in the message fields.', 'mailchimp-for-wp' ), '<code>' . esc_html( '<strong><em><a>' ) . '</code>' ); ?></p>
|
95 |
</td>
|
96 |
</tr>
|
97 |
|
includes/forms/views/tabs/form-settings.php
CHANGED
@@ -1,155 +1,166 @@
|
|
1 |
-
<h2><?php echo __('Form Settings', 'mailchimp-for-wp'); ?></h2>
|
2 |
|
3 |
<div class="medium-margin"></div>
|
4 |
|
5 |
-
<h3><?php echo __('Mailchimp specific settings', 'mailchimp-for-wp'); ?></h3>
|
6 |
|
7 |
<table class="form-table" style="table-layout: fixed;">
|
8 |
|
9 |
<?php
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
<tr valign="top">
|
15 |
-
<th scope="row" style="width: 250px;"><?php _e('Lists this form subscribes to', 'mailchimp-for-wp'); ?></th>
|
16 |
-
<?php
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
21 |
<td >
|
22 |
|
23 |
<ul id="mc4wp-lists" style="margin-bottom: 20px; max-height: 300px; overflow-y: auto;">
|
24 |
-
<?php
|
25 |
-
|
|
|
26 |
<li>
|
27 |
<label>
|
28 |
-
<input class="mc4wp-list-input" type="checkbox" name="mc4wp_form[settings][lists][]" value="<?php echo esc_attr($list->id); ?>" <?php
|
29 |
</label>
|
30 |
</li>
|
31 |
-
|
32 |
-
|
|
|
33 |
</ul>
|
34 |
-
<p class="help"><?php _e('Select the list(s) to which people who submit this form should be subscribed.', 'mailchimp-for-wp'); ?></p>
|
35 |
</td>
|
36 |
-
|
37 |
-
|
|
|
38 |
|
39 |
</tr>
|
40 |
<tr valign="top">
|
41 |
-
<th scope="row"><?php _e('Use double opt-in?', 'mailchimp-for-wp'); ?></th>
|
42 |
<td class="nowrap">
|
43 |
<label>
|
44 |
-
<input type="radio" name="mc4wp_form[settings][double_optin]" value="1" <?php checked($opts['double_optin'], 1); ?> />‏
|
45 |
-
<?php _e('Yes'); ?>
|
46 |
</label>
|
47 |
<label>
|
48 |
-
<input type="radio" name="mc4wp_form[settings][double_optin]" value="0" <?php checked($opts['double_optin'], 0); ?> onclick="return confirm('<?php esc_attr_e('Are you sure you want to disable double opt-in?', 'mailchimp-for-wp'); ?>');" />‏
|
49 |
-
<?php _e('No'); ?>
|
50 |
</label>
|
51 |
-
<p class="help"><?php _e('We strongly suggest keeping double opt-in enabled. Disabling double opt-in may result in abuse.', 'mailchimp-for-wp'); ?></p>
|
52 |
</td>
|
53 |
</tr>
|
54 |
|
55 |
<tr valign="top">
|
56 |
-
<th scope="row"><?php _e('Update existing subscribers?', 'mailchimp-for-wp'); ?></th>
|
57 |
<td class="nowrap">
|
58 |
<label>
|
59 |
-
<input type="radio" name="mc4wp_form[settings][update_existing]" value="1" <?php checked($opts['update_existing'], 1); ?> />‏
|
60 |
-
<?php _e('Yes'); ?>
|
61 |
</label>
|
62 |
<label>
|
63 |
-
<input type="radio" name="mc4wp_form[settings][update_existing]" value="0" <?php checked($opts['update_existing'], 0); ?> />‏
|
64 |
-
<?php _e('No'); ?>
|
65 |
</label>
|
66 |
-
<p class="help"><?php _e('Select "yes" if you want to update existing subscribers with the data that is sent.', 'mailchimp-for-wp'); ?></p>
|
67 |
</td>
|
68 |
</tr>
|
69 |
|
70 |
-
<?php
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
73 |
<td class="nowrap">
|
74 |
<label>
|
75 |
-
<input type="radio" name="mc4wp_form[settings][replace_interests]" value="1" <?php checked($opts['replace_interests'], 1); ?> />‏
|
76 |
-
<?php _e('Yes'); ?>
|
77 |
</label>
|
78 |
<label>
|
79 |
-
<input type="radio" name="mc4wp_form[settings][replace_interests]" value="0" <?php checked($opts['replace_interests'], 0); ?> />‏
|
80 |
-
<?php _e('No'); ?>
|
81 |
</label>
|
82 |
<p class="help">
|
83 |
-
<?php _e('Select "no" if you want to add the selected interests to any previously selected interests when updating a subscriber.', 'mailchimp-for-wp'); ?>
|
84 |
-
<?php printf(' <a href="%s" target="_blank">' . __('What does this do?', 'mailchimp-for-wp') . '</a>', 'https://kb.mc4wp.com/what-does-replace-groupings-mean/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=settings-page'); ?>
|
85 |
</p>
|
86 |
</td>
|
87 |
</tr>
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
|
98 |
-
|
99 |
-
|
100 |
|
101 |
<?php
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
|
106 |
</table>
|
107 |
|
108 |
<div class="medium-margin"></div>
|
109 |
|
110 |
-
<h3><?php _e('Form behaviour', 'mailchimp-for-wp'); ?></h3>
|
111 |
|
112 |
<table class="form-table" style="table-layout: fixed;">
|
113 |
|
114 |
<?php
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
|
119 |
<tr valign="top">
|
120 |
-
<th scope="row"><?php _e('Hide form after a successful sign-up?', 'mailchimp-for-wp'); ?></th>
|
121 |
<td class="nowrap">
|
122 |
<label>
|
123 |
-
<input type="radio" name="mc4wp_form[settings][hide_after_success]" value="1" <?php checked($opts['hide_after_success'], 1); ?> />‏
|
124 |
-
<?php _e('Yes'); ?>
|
125 |
</label>
|
126 |
<label>
|
127 |
-
<input type="radio" name="mc4wp_form[settings][hide_after_success]" value="0" <?php checked($opts['hide_after_success'], 0); ?> />‏
|
128 |
-
<?php _e('No'); ?>
|
129 |
</label>
|
130 |
<p class="help">
|
131 |
-
<?php _e('Select "yes" to hide the form fields after a successful sign-up.', 'mailchimp-for-wp'); ?>
|
132 |
</p>
|
133 |
</td>
|
134 |
</tr>
|
135 |
<tr valign="top">
|
136 |
-
<th scope="row"><label for="mc4wp_form_redirect"><?php _e('Redirect to URL after successful sign-ups', 'mailchimp-for-wp'); ?></label></th>
|
137 |
<td>
|
138 |
-
<input type="text" class="widefat" name="mc4wp_form[settings][redirect]" id="mc4wp_form_redirect" placeholder="<?php printf(__('Example: %s', 'mailchimp-for-wp'), esc_attr(site_url('/thank-you/'))); ?>" value="<?php echo esc_attr($opts['redirect']); ?>" />
|
139 |
<p class="help">
|
140 |
-
<?php _e('Leave empty or enter <code>0</code> for no redirect. Otherwise, use complete (absolute) URLs, including <code>http://</code>.', 'mailchimp-for-wp'); ?>
|
141 |
</p>
|
142 |
<p class="help">
|
143 |
-
<?php _e('Your "subscribed" message will not show when redirecting to another page, so make sure to let your visitors know they were successfully subscribed.', 'mailchimp-for-wp'); ?>
|
144 |
</p>
|
145 |
|
146 |
</td>
|
147 |
</tr>
|
148 |
|
149 |
<?php
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
|
154 |
</table>
|
155 |
|
1 |
+
<h2><?php echo __( 'Form Settings', 'mailchimp-for-wp' ); ?></h2>
|
2 |
|
3 |
<div class="medium-margin"></div>
|
4 |
|
5 |
+
<h3><?php echo __( 'Mailchimp specific settings', 'mailchimp-for-wp' ); ?></h3>
|
6 |
|
7 |
<table class="form-table" style="table-layout: fixed;">
|
8 |
|
9 |
<?php
|
10 |
+
/** @ignore */
|
11 |
+
do_action( 'mc4wp_admin_form_after_mailchimp_settings_rows', $opts, $form );
|
12 |
+
?>
|
13 |
|
14 |
<tr valign="top">
|
15 |
+
<th scope="row" style="width: 250px;"><?php _e( 'Lists this form subscribes to', 'mailchimp-for-wp' ); ?></th>
|
16 |
+
<?php
|
17 |
+
// loop through lists
|
18 |
+
if ( empty( $lists ) ) {
|
19 |
+
?>
|
20 |
+
<td colspan="2"><?php printf( __( 'No lists found, <a href="%s">are you connected to Mailchimp</a>?', 'mailchimp-for-wp' ), admin_url( 'admin.php?page=mailchimp-for-wp' ) ); ?></td>
|
21 |
+
<?php
|
22 |
+
} else {
|
23 |
+
?>
|
24 |
<td >
|
25 |
|
26 |
<ul id="mc4wp-lists" style="margin-bottom: 20px; max-height: 300px; overflow-y: auto;">
|
27 |
+
<?php
|
28 |
+
foreach ( $lists as $list ) {
|
29 |
+
?>
|
30 |
<li>
|
31 |
<label>
|
32 |
+
<input class="mc4wp-list-input" type="checkbox" name="mc4wp_form[settings][lists][]" value="<?php echo esc_attr( $list->id ); ?>" <?php checked( in_array( $list->id, $opts['lists'] ), true ); ?>> <?php echo esc_html( $list->name ); ?>
|
33 |
</label>
|
34 |
</li>
|
35 |
+
<?php
|
36 |
+
}
|
37 |
+
?>
|
38 |
</ul>
|
39 |
+
<p class="help"><?php _e( 'Select the list(s) to which people who submit this form should be subscribed.', 'mailchimp-for-wp' ); ?></p>
|
40 |
</td>
|
41 |
+
<?php
|
42 |
+
}
|
43 |
+
?>
|
44 |
|
45 |
</tr>
|
46 |
<tr valign="top">
|
47 |
+
<th scope="row"><?php _e( 'Use double opt-in?', 'mailchimp-for-wp' ); ?></th>
|
48 |
<td class="nowrap">
|
49 |
<label>
|
50 |
+
<input type="radio" name="mc4wp_form[settings][double_optin]" value="1" <?php checked( $opts['double_optin'], 1 ); ?> />‏
|
51 |
+
<?php _e( 'Yes', 'mailchimp-for-wp' ); ?>
|
52 |
</label>
|
53 |
<label>
|
54 |
+
<input type="radio" name="mc4wp_form[settings][double_optin]" value="0" <?php checked( $opts['double_optin'], 0 ); ?> onclick="return confirm('<?php esc_attr_e( 'Are you sure you want to disable double opt-in?', 'mailchimp-for-wp' ); ?>');" />‏
|
55 |
+
<?php _e( 'No', 'mailchimp-for-wp' ); ?>
|
56 |
</label>
|
57 |
+
<p class="help"><?php _e( 'We strongly suggest keeping double opt-in enabled. Disabling double opt-in may result in abuse.', 'mailchimp-for-wp' ); ?></p>
|
58 |
</td>
|
59 |
</tr>
|
60 |
|
61 |
<tr valign="top">
|
62 |
+
<th scope="row"><?php _e( 'Update existing subscribers?', 'mailchimp-for-wp' ); ?></th>
|
63 |
<td class="nowrap">
|
64 |
<label>
|
65 |
+
<input type="radio" name="mc4wp_form[settings][update_existing]" value="1" <?php checked( $opts['update_existing'], 1 ); ?> />‏
|
66 |
+
<?php _e( 'Yes', 'mailchimp-for-wp' ); ?>
|
67 |
</label>
|
68 |
<label>
|
69 |
+
<input type="radio" name="mc4wp_form[settings][update_existing]" value="0" <?php checked( $opts['update_existing'], 0 ); ?> />‏
|
70 |
+
<?php _e( 'No', 'mailchimp-for-wp' ); ?>
|
71 |
</label>
|
72 |
+
<p class="help"><?php _e( 'Select "yes" if you want to update existing subscribers with the data that is sent.', 'mailchimp-for-wp' ); ?></p>
|
73 |
</td>
|
74 |
</tr>
|
75 |
|
76 |
+
<?php
|
77 |
+
$config = array(
|
78 |
+
'element' => 'mc4wp_form[settings][update_existing]',
|
79 |
+
'value' => 1,
|
80 |
+
);
|
81 |
+
?>
|
82 |
+
<tr valign="top" data-showif="<?php echo esc_attr( json_encode( $config ) ); ?>">
|
83 |
+
<th scope="row"><?php _e( 'Replace interest groups?', 'mailchimp-for-wp' ); ?></th>
|
84 |
<td class="nowrap">
|
85 |
<label>
|
86 |
+
<input type="radio" name="mc4wp_form[settings][replace_interests]" value="1" <?php checked( $opts['replace_interests'], 1 ); ?> />‏
|
87 |
+
<?php _e( 'Yes', 'mailchimp-for-wp' ); ?>
|
88 |
</label>
|
89 |
<label>
|
90 |
+
<input type="radio" name="mc4wp_form[settings][replace_interests]" value="0" <?php checked( $opts['replace_interests'], 0 ); ?> />‏
|
91 |
+
<?php _e( 'No', 'mailchimp-for-wp' ); ?>
|
92 |
</label>
|
93 |
<p class="help">
|
94 |
+
<?php _e( 'Select "no" if you want to add the selected interests to any previously selected interests when updating a subscriber.', 'mailchimp-for-wp' ); ?>
|
95 |
+
<?php printf( ' <a href="%s" target="_blank">' . __( 'What does this do?', 'mailchimp-for-wp' ) . '</a>', 'https://kb.mc4wp.com/what-does-replace-groupings-mean/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=settings-page' ); ?>
|
96 |
</p>
|
97 |
</td>
|
98 |
</tr>
|
99 |
|
100 |
+
<tr valign="top">
|
101 |
+
<th scope="row"><label for="mc4wp_form_subscriber_tags"><?php _e( 'Subscriber tags', 'mailchimp-for-wp' ); ?></label></th>
|
102 |
+
<td>
|
103 |
+
<input type="text" class="widefat" name="mc4wp_form[settings][subscriber_tags]" id="mc4wp_form_subscriber_tags" placeholder="<?php echo __( 'Example: My tag, another tag', 'mailchimp-for-wp' ); ?>" value="<?php echo esc_attr( $opts['subscriber_tags'] ); ?>" />
|
104 |
+
<p class="help">
|
105 |
+
<?php _e( 'The listed tags will be applied to all new subscribers added by this form.', 'mailchimp-for-wp' ); ?>
|
106 |
+
<?php _e( 'Separate multiple values with a comma.', 'mailchimp-for-wp' ); ?>
|
107 |
+
</p>
|
108 |
|
109 |
+
</td>
|
110 |
+
</tr>
|
111 |
|
112 |
<?php
|
113 |
+
/** @ignore */
|
114 |
+
do_action( 'mc4wp_admin_form_after_mailchimp_settings_rows', $opts, $form );
|
115 |
+
?>
|
116 |
|
117 |
</table>
|
118 |
|
119 |
<div class="medium-margin"></div>
|
120 |
|
121 |
+
<h3><?php _e( 'Form behaviour', 'mailchimp-for-wp' ); ?></h3>
|
122 |
|
123 |
<table class="form-table" style="table-layout: fixed;">
|
124 |
|
125 |
<?php
|
126 |
+
/** @ignore */
|
127 |
+
do_action( 'mc4wp_admin_form_before_behaviour_settings_rows', $opts, $form );
|
128 |
+
?>
|
129 |
|
130 |
<tr valign="top">
|
131 |
+
<th scope="row"><?php _e( 'Hide form after a successful sign-up?', 'mailchimp-for-wp' ); ?></th>
|
132 |
<td class="nowrap">
|
133 |
<label>
|
134 |
+
<input type="radio" name="mc4wp_form[settings][hide_after_success]" value="1" <?php checked( $opts['hide_after_success'], 1 ); ?> />‏
|
135 |
+
<?php _e( 'Yes', 'mailchimp-for-wp' ); ?>
|
136 |
</label>
|
137 |
<label>
|
138 |
+
<input type="radio" name="mc4wp_form[settings][hide_after_success]" value="0" <?php checked( $opts['hide_after_success'], 0 ); ?> />‏
|
139 |
+
<?php _e( 'No', 'mailchimp-for-wp' ); ?>
|
140 |
</label>
|
141 |
<p class="help">
|
142 |
+
<?php _e( 'Select "yes" to hide the form fields after a successful sign-up.', 'mailchimp-for-wp' ); ?>
|
143 |
</p>
|
144 |
</td>
|
145 |
</tr>
|
146 |
<tr valign="top">
|
147 |
+
<th scope="row"><label for="mc4wp_form_redirect"><?php _e( 'Redirect to URL after successful sign-ups', 'mailchimp-for-wp' ); ?></label></th>
|
148 |
<td>
|
149 |
+
<input type="text" class="widefat" name="mc4wp_form[settings][redirect]" id="mc4wp_form_redirect" placeholder="<?php printf( __( 'Example: %s', 'mailchimp-for-wp' ), esc_attr( site_url( '/thank-you/' ) ) ); ?>" value="<?php echo esc_attr( $opts['redirect'] ); ?>" />
|
150 |
<p class="help">
|
151 |
+
<?php _e( 'Leave empty or enter <code>0</code> for no redirect. Otherwise, use complete (absolute) URLs, including <code>http://</code>.', 'mailchimp-for-wp' ); ?>
|
152 |
</p>
|
153 |
<p class="help">
|
154 |
+
<?php _e( 'Your "subscribed" message will not show when redirecting to another page, so make sure to let your visitors know they were successfully subscribed.', 'mailchimp-for-wp' ); ?>
|
155 |
</p>
|
156 |
|
157 |
</td>
|
158 |
</tr>
|
159 |
|
160 |
<?php
|
161 |
+
/** @ignore */
|
162 |
+
do_action( 'mc4wp_admin_form_after_behaviour_settings_rows', $opts, $form );
|
163 |
+
?>
|
164 |
|
165 |
</table>
|
166 |
|
includes/functions.php
CHANGED
@@ -18,19 +18,18 @@
|
|
18 |
*
|
19 |
* @throws Exception when service is not found
|
20 |
*/
|
21 |
-
function mc4wp($service = null)
|
22 |
-
|
23 |
-
static $mc4wp;
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
|
33 |
-
|
34 |
}
|
35 |
|
36 |
/**
|
@@ -42,41 +41,39 @@ function mc4wp($service = null)
|
|
42 |
* @static array $options
|
43 |
* @return array
|
44 |
*/
|
45 |
-
function mc4wp_get_options()
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
return apply_filters('mc4wp_settings', $options);
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
* @return array
|
61 |
*/
|
62 |
function mc4wp_get_settings() {
|
63 |
-
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
* @since 4.2.6
|
68 |
* @return string
|
69 |
*/
|
70 |
-
function mc4wp_get_api_key()
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
return $opts['api_key'];
|
80 |
}
|
81 |
|
82 |
/**
|
@@ -85,13 +82,12 @@ function mc4wp_get_api_key()
|
|
85 |
* @since 4.0
|
86 |
* @access public
|
87 |
*
|
88 |
-
* @return
|
89 |
*/
|
90 |
-
function mc4wp_get_api_v3()
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
return $instance;
|
95 |
}
|
96 |
|
97 |
/**
|
@@ -105,12 +101,11 @@ function mc4wp_get_api_v3()
|
|
105 |
*
|
106 |
* @return MC4WP_API
|
107 |
*/
|
108 |
-
function mc4wp_get_api()
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
return $instance;
|
114 |
}
|
115 |
|
116 |
/**
|
@@ -118,31 +113,30 @@ function mc4wp_get_api()
|
|
118 |
*
|
119 |
* @return MC4WP_Debug_Log
|
120 |
*/
|
121 |
-
function mc4wp_get_debug_log()
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
return new MC4WP_Debug_Log($file, $level);
|
146 |
}
|
147 |
|
148 |
|
@@ -151,23 +145,22 @@ function mc4wp_get_debug_log()
|
|
151 |
*
|
152 |
* @return string
|
153 |
*/
|
154 |
-
function mc4wp_get_request_url()
|
155 |
-
|
156 |
-
global $wp;
|
157 |
|
158 |
-
|
159 |
-
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
|
170 |
-
|
171 |
}
|
172 |
|
173 |
/**
|
@@ -175,9 +168,8 @@ function mc4wp_get_request_url()
|
|
175 |
*
|
176 |
* @return string
|
177 |
*/
|
178 |
-
function mc4wp_get_request_path()
|
179 |
-
|
180 |
-
return $_SERVER['REQUEST_URI'];
|
181 |
}
|
182 |
|
183 |
/**
|
@@ -185,19 +177,18 @@ function mc4wp_get_request_path()
|
|
185 |
*
|
186 |
* @return string
|
187 |
*/
|
188 |
-
function mc4wp_get_request_ip_address()
|
189 |
-
|
190 |
-
$headers = (function_exists('apache_request_headers')) ? apache_request_headers() : $_SERVER;
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
|
200 |
-
|
201 |
}
|
202 |
|
203 |
/**
|
@@ -208,24 +199,23 @@ function mc4wp_get_request_ip_address()
|
|
208 |
*
|
209 |
* @return mixed
|
210 |
*/
|
211 |
-
function mc4wp_sanitize_deep($value)
|
212 |
-
{
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
return $value;
|
229 |
}
|
230 |
|
231 |
/**
|
@@ -236,79 +226,78 @@ function mc4wp_sanitize_deep($value)
|
|
236 |
* @param array $data
|
237 |
* @return array
|
238 |
*/
|
239 |
-
function _mc4wp_update_groupings_data($data = array())
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
return $data;
|
312 |
}
|
313 |
|
314 |
/**
|
@@ -321,28 +310,27 @@ function _mc4wp_update_groupings_data($data = array())
|
|
321 |
*
|
322 |
* @return array
|
323 |
*/
|
324 |
-
function mc4wp_add_name_data($data = array())
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
return $data;
|
346 |
}
|
347 |
|
348 |
/**
|
@@ -355,18 +343,17 @@ function mc4wp_add_name_data($data = array())
|
|
355 |
*
|
356 |
* @return string
|
357 |
*/
|
358 |
-
function mc4wp_get_email_type()
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
return $email_type;
|
370 |
}
|
371 |
|
372 |
/**
|
@@ -374,27 +361,26 @@ function mc4wp_get_email_type()
|
|
374 |
* @ignore
|
375 |
* @return bool
|
376 |
*/
|
377 |
-
function _mc4wp_use_sslverify()
|
378 |
-
{
|
379 |
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
|
385 |
-
|
386 |
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
|
397 |
-
|
398 |
}
|
399 |
|
400 |
/**
|
@@ -403,24 +389,22 @@ function _mc4wp_use_sslverify()
|
|
403 |
* @param string $string
|
404 |
* @return string
|
405 |
*/
|
406 |
-
function mc4wp_obfuscate_string($string)
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
return $string;
|
412 |
}
|
413 |
|
414 |
/**
|
415 |
* @internal
|
416 |
* @ignore
|
417 |
*/
|
418 |
-
function _mc4wp_obfuscate_email_addresses_callback($m)
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
return sprintf('%s@%s.%s', $one, $two, $three);
|
424 |
}
|
425 |
|
426 |
/**
|
@@ -429,9 +413,8 @@ function _mc4wp_obfuscate_email_addresses_callback($m)
|
|
429 |
* @param $string String possibly containing email address
|
430 |
* @return string
|
431 |
*/
|
432 |
-
function mc4wp_obfuscate_email_addresses($string)
|
433 |
-
{
|
434 |
-
return preg_replace_callback('/([\w\.]{1,4})([\w\.]*)\@(\w{1,2})(\w*)\.(\w+)/', '_mc4wp_obfuscate_email_addresses_callback', $string);
|
435 |
}
|
436 |
|
437 |
/**
|
@@ -439,10 +422,9 @@ function mc4wp_obfuscate_email_addresses($string)
|
|
439 |
*
|
440 |
* @return void
|
441 |
*/
|
442 |
-
function mc4wp_refresh_mailchimp_lists()
|
443 |
-
|
444 |
-
|
445 |
-
$mailchimp->refresh_lists();
|
446 |
}
|
447 |
|
448 |
/**
|
@@ -453,23 +435,22 @@ function mc4wp_refresh_mailchimp_lists()
|
|
453 |
* @param mixed $default
|
454 |
* @return mixed
|
455 |
*/
|
456 |
-
function mc4wp_array_get($array, $key, $default = null)
|
457 |
-
{
|
458 |
-
|
459 |
-
|
460 |
-
}
|
461 |
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
|
471 |
-
|
472 |
-
|
473 |
|
474 |
-
|
475 |
}
|
18 |
*
|
19 |
* @throws Exception when service is not found
|
20 |
*/
|
21 |
+
function mc4wp( $service = null ) {
|
22 |
+
static $mc4wp;
|
|
|
23 |
|
24 |
+
if ( ! $mc4wp ) {
|
25 |
+
$mc4wp = new MC4WP_Container();
|
26 |
+
}
|
27 |
|
28 |
+
if ( $service ) {
|
29 |
+
return $mc4wp->get( $service );
|
30 |
+
}
|
31 |
|
32 |
+
return $mc4wp;
|
33 |
}
|
34 |
|
35 |
/**
|
41 |
* @static array $options
|
42 |
* @return array
|
43 |
*/
|
44 |
+
function mc4wp_get_options() {
|
45 |
+
$defaults = require MC4WP_PLUGIN_DIR . 'config/default-settings.php';
|
46 |
+
$options = (array) get_option( 'mc4wp', array() );
|
47 |
+
$options = array_merge( $defaults, $options );
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Filters the Mailchimp for WordPress settings (general).
|
51 |
+
*
|
52 |
+
* @param array $options
|
53 |
+
*/
|
54 |
+
return apply_filters( 'mc4wp_settings', $options );
|
|
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
* @return array
|
59 |
*/
|
60 |
function mc4wp_get_settings() {
|
61 |
+
return mc4wp_get_options();
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
* @since 4.2.6
|
66 |
* @return string
|
67 |
*/
|
68 |
+
function mc4wp_get_api_key() {
|
69 |
+
// try to get from constant
|
70 |
+
if ( defined( 'MC4WP_API_KEY' ) && constant( 'MC4WP_API_KEY' ) !== '' ) {
|
71 |
+
return MC4WP_API_KEY;
|
72 |
+
}
|
73 |
+
|
74 |
+
// get from options
|
75 |
+
$opts = mc4wp_get_options();
|
76 |
+
return $opts['api_key'];
|
|
|
77 |
}
|
78 |
|
79 |
/**
|
82 |
* @since 4.0
|
83 |
* @access public
|
84 |
*
|
85 |
+
* @return MC4WP_API_V3
|
86 |
*/
|
87 |
+
function mc4wp_get_api_v3() {
|
88 |
+
$api_key = mc4wp_get_api_key();
|
89 |
+
$instance = new MC4WP_API_V3( $api_key );
|
90 |
+
return $instance;
|
|
|
91 |
}
|
92 |
|
93 |
/**
|
101 |
*
|
102 |
* @return MC4WP_API
|
103 |
*/
|
104 |
+
function mc4wp_get_api() {
|
105 |
+
_deprecated_function( __FUNCTION__, '4.0', 'mc4wp_get_api_v3' );
|
106 |
+
$api_key = mc4wp_get_api_key();
|
107 |
+
$instance = new MC4WP_API( $api_key );
|
108 |
+
return $instance;
|
|
|
109 |
}
|
110 |
|
111 |
/**
|
113 |
*
|
114 |
* @return MC4WP_Debug_Log
|
115 |
*/
|
116 |
+
function mc4wp_get_debug_log() {
|
117 |
+
$opts = mc4wp_get_options();
|
118 |
+
|
119 |
+
// get default log file location
|
120 |
+
$upload_dir = wp_upload_dir( null, false );
|
121 |
+
$file = trailingslashit( $upload_dir['basedir'] ) . 'mc4wp-debug-log.php';
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Filters the log file to write to.
|
125 |
+
*
|
126 |
+
* @param string $file The log file location. Default: /wp-content/uploads/mc4wp-debug.log
|
127 |
+
*/
|
128 |
+
$file = apply_filters( 'mc4wp_debug_log_file', $file );
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Filters the minimum level to log messages.
|
132 |
+
*
|
133 |
+
* @see MC4WP_Debug_Log
|
134 |
+
*
|
135 |
+
* @param string|int $level The minimum level of messages which should be logged.
|
136 |
+
*/
|
137 |
+
$level = apply_filters( 'mc4wp_debug_log_level', $opts['debug_log_level'] );
|
138 |
+
|
139 |
+
return new MC4WP_Debug_Log( $file, $level );
|
|
|
140 |
}
|
141 |
|
142 |
|
145 |
*
|
146 |
* @return string
|
147 |
*/
|
148 |
+
function mc4wp_get_request_url() {
|
149 |
+
global $wp;
|
|
|
150 |
|
151 |
+
// get requested url from global $wp object
|
152 |
+
$site_request_uri = $wp->request;
|
153 |
|
154 |
+
// fix for IIS servers using index.php in the URL
|
155 |
+
if ( false !== stripos( $_SERVER['REQUEST_URI'], '/index.php/' . $site_request_uri ) ) {
|
156 |
+
$site_request_uri = 'index.php/' . $site_request_uri;
|
157 |
+
}
|
158 |
|
159 |
+
// concatenate request url to home url
|
160 |
+
$url = home_url( $site_request_uri );
|
161 |
+
$url = trailingslashit( $url );
|
162 |
|
163 |
+
return esc_url( $url );
|
164 |
}
|
165 |
|
166 |
/**
|
168 |
*
|
169 |
* @return string
|
170 |
*/
|
171 |
+
function mc4wp_get_request_path() {
|
172 |
+
return $_SERVER['REQUEST_URI'];
|
|
|
173 |
}
|
174 |
|
175 |
/**
|
177 |
*
|
178 |
* @return string
|
179 |
*/
|
180 |
+
function mc4wp_get_request_ip_address() {
|
181 |
+
$headers = ( function_exists( 'apache_request_headers' ) ) ? apache_request_headers() : $_SERVER;
|
|
|
182 |
|
183 |
+
if ( array_key_exists( 'X-Forwarded-For', $headers ) && filter_var( $headers['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {
|
184 |
+
return $headers['X-Forwarded-For'];
|
185 |
+
}
|
186 |
|
187 |
+
if ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ) && filter_var( $headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {
|
188 |
+
return $headers['HTTP_X_FORWARDED_FOR'];
|
189 |
+
}
|
190 |
|
191 |
+
return $_SERVER['REMOTE_ADDR'];
|
192 |
}
|
193 |
|
194 |
/**
|
199 |
*
|
200 |
* @return mixed
|
201 |
*/
|
202 |
+
function mc4wp_sanitize_deep( $value ) {
|
203 |
+
if ( is_scalar( $value ) ) {
|
204 |
+
// strip all HTML tags & whitespace
|
205 |
+
$value = trim( strip_tags( $value ) );
|
206 |
+
|
207 |
+
// convert & back to &
|
208 |
+
$value = html_entity_decode( $value, ENT_NOQUOTES );
|
209 |
+
} elseif ( is_array( $value ) ) {
|
210 |
+
$value = array_map( 'mc4wp_sanitize_deep', $value );
|
211 |
+
} elseif ( is_object( $value ) ) {
|
212 |
+
$vars = get_object_vars( $value );
|
213 |
+
foreach ( $vars as $key => $data ) {
|
214 |
+
$value->{$key} = mc4wp_sanitize_deep( $data );
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
return $value;
|
|
|
219 |
}
|
220 |
|
221 |
/**
|
226 |
* @param array $data
|
227 |
* @return array
|
228 |
*/
|
229 |
+
function _mc4wp_update_groupings_data( $data = array() ) {
|
230 |
+
|
231 |
+
// data still has old "GROUPINGS" key?
|
232 |
+
if ( empty( $data['GROUPINGS'] ) ) {
|
233 |
+
return $data;
|
234 |
+
}
|
235 |
+
|
236 |
+
// prepare new key
|
237 |
+
if ( ! isset( $data['INTERESTS'] ) ) {
|
238 |
+
$data['INTERESTS'] = array();
|
239 |
+
}
|
240 |
+
|
241 |
+
$map = get_option( 'mc4wp_groupings_map', array() );
|
242 |
+
|
243 |
+
foreach ( $data['GROUPINGS'] as $grouping_id => $groups ) {
|
244 |
+
|
245 |
+
// for compatibility with expanded grouping arrays
|
246 |
+
$grouping_key = $grouping_id;
|
247 |
+
if ( is_array( $groups ) && isset( $groups['id'] ) && isset( $groups['groups'] ) ) {
|
248 |
+
$grouping_id = $groups['id'];
|
249 |
+
$groups = $groups['groups'];
|
250 |
+
}
|
251 |
+
|
252 |
+
// do we have transfer data for this grouping id?
|
253 |
+
if ( ! isset( $map[ $grouping_id ] ) ) {
|
254 |
+
continue;
|
255 |
+
}
|
256 |
+
|
257 |
+
// if we get a string, explode on delimiter(s)
|
258 |
+
if ( is_string( $groups ) ) {
|
259 |
+
// for BC with 3.x: explode on comma's
|
260 |
+
$groups = join( '|', explode( ',', $groups ) );
|
261 |
+
|
262 |
+
// explode on current delimiter
|
263 |
+
$groups = explode( '|', $groups );
|
264 |
+
}
|
265 |
+
|
266 |
+
// loop through groups and find interest ID
|
267 |
+
$migrated = 0;
|
268 |
+
foreach ( $groups as $key => $group_name_or_id ) {
|
269 |
+
|
270 |
+
// do we know the new interest ID?
|
271 |
+
if ( empty( $map[ $grouping_id ]['groups'][ $group_name_or_id ] ) ) {
|
272 |
+
continue;
|
273 |
+
}
|
274 |
+
|
275 |
+
$interest_id = $map[ $grouping_id ]['groups'][ $group_name_or_id ];
|
276 |
+
|
277 |
+
// add to interests data
|
278 |
+
if ( ! in_array( $interest_id, $data['INTERESTS'], false ) ) {
|
279 |
+
$migrated++;
|
280 |
+
$data['INTERESTS'][] = $interest_id;
|
281 |
+
}
|
282 |
+
}
|
283 |
+
|
284 |
+
// remove old grouping ID if we migrated all groups.
|
285 |
+
if ( $migrated === count( $groups ) ) {
|
286 |
+
unset( $data['GROUPINGS'][ $grouping_key ] );
|
287 |
+
}
|
288 |
+
}
|
289 |
+
|
290 |
+
// if everything went well, this is now empty & moved to new INTERESTS key.
|
291 |
+
if ( empty( $data['GROUPINGS'] ) ) {
|
292 |
+
unset( $data['GROUPINGS'] );
|
293 |
+
}
|
294 |
+
|
295 |
+
// is this empty? just unset it then.
|
296 |
+
if ( empty( $data['INTERESTS'] ) ) {
|
297 |
+
unset( $data['INTERESTS'] );
|
298 |
+
}
|
299 |
+
|
300 |
+
return $data;
|
|
|
301 |
}
|
302 |
|
303 |
/**
|
310 |
*
|
311 |
* @return array
|
312 |
*/
|
313 |
+
function mc4wp_add_name_data( $data = array() ) {
|
314 |
+
|
315 |
+
// Guess first and last name
|
316 |
+
if ( ! empty( $data['NAME'] ) && empty( $data['FNAME'] ) && empty( $data['LNAME'] ) ) {
|
317 |
+
$data['NAME'] = trim( $data['NAME'] );
|
318 |
+
$strpos = strpos( $data['NAME'], ' ' );
|
319 |
+
|
320 |
+
if ( $strpos !== false ) {
|
321 |
+
$data['FNAME'] = trim( substr( $data['NAME'], 0, $strpos ) );
|
322 |
+
$data['LNAME'] = trim( substr( $data['NAME'], $strpos ) );
|
323 |
+
} else {
|
324 |
+
$data['FNAME'] = $data['NAME'];
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
// Set name value
|
329 |
+
if ( empty( $data['NAME'] ) && ! empty( $data['FNAME'] ) && ! empty( $data['LNAME'] ) ) {
|
330 |
+
$data['NAME'] = sprintf( '%s %s', $data['FNAME'], $data['LNAME'] );
|
331 |
+
}
|
332 |
+
|
333 |
+
return $data;
|
|
|
334 |
}
|
335 |
|
336 |
/**
|
343 |
*
|
344 |
* @return string
|
345 |
*/
|
346 |
+
function mc4wp_get_email_type() {
|
347 |
+
$email_type = 'html';
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Filters the email type preference for this new subscriber.
|
351 |
+
*
|
352 |
+
* @param string $email_type
|
353 |
+
*/
|
354 |
+
$email_type = (string) apply_filters( 'mc4wp_email_type', $email_type );
|
355 |
+
|
356 |
+
return $email_type;
|
|
|
357 |
}
|
358 |
|
359 |
/**
|
361 |
* @ignore
|
362 |
* @return bool
|
363 |
*/
|
364 |
+
function _mc4wp_use_sslverify() {
|
|
|
365 |
|
366 |
+
// Disable for all transports other than CURL
|
367 |
+
if ( ! function_exists( 'curl_version' ) ) {
|
368 |
+
return false;
|
369 |
+
}
|
370 |
|
371 |
+
$curl = curl_version();
|
372 |
|
373 |
+
// Disable if OpenSSL is not installed
|
374 |
+
if ( empty( $curl['ssl_version'] ) ) {
|
375 |
+
return false;
|
376 |
+
}
|
377 |
|
378 |
+
// Disable if on WP 4.4, see https://core.trac.wordpress.org/ticket/34935
|
379 |
+
if ( $GLOBALS['wp_version'] === '4.4' ) {
|
380 |
+
return false;
|
381 |
+
}
|
382 |
|
383 |
+
return true;
|
384 |
}
|
385 |
|
386 |
/**
|
389 |
* @param string $string
|
390 |
* @return string
|
391 |
*/
|
392 |
+
function mc4wp_obfuscate_string( $string ) {
|
393 |
+
$length = strlen( $string );
|
394 |
+
$obfuscated_length = ceil( $length / 2 );
|
395 |
+
$string = str_repeat( '*', $obfuscated_length ) . substr( $string, $obfuscated_length );
|
396 |
+
return $string;
|
|
|
397 |
}
|
398 |
|
399 |
/**
|
400 |
* @internal
|
401 |
* @ignore
|
402 |
*/
|
403 |
+
function _mc4wp_obfuscate_email_addresses_callback( $m ) {
|
404 |
+
$one = $m[1] . str_repeat( '*', strlen( $m[2] ) );
|
405 |
+
$two = $m[3] . str_repeat( '*', strlen( $m[4] ) );
|
406 |
+
$three = $m[5];
|
407 |
+
return sprintf( '%s@%s.%s', $one, $two, $three );
|
|
|
408 |
}
|
409 |
|
410 |
/**
|
413 |
* @param $string String possibly containing email address
|
414 |
* @return string
|
415 |
*/
|
416 |
+
function mc4wp_obfuscate_email_addresses( $string ) {
|
417 |
+
return preg_replace_callback( '/([\w\.]{1,4})([\w\.]*)\@(\w{1,2})(\w*)\.(\w+)/', '_mc4wp_obfuscate_email_addresses_callback', $string );
|
|
|
418 |
}
|
419 |
|
420 |
/**
|
422 |
*
|
423 |
* @return void
|
424 |
*/
|
425 |
+
function mc4wp_refresh_mailchimp_lists() {
|
426 |
+
$mailchimp = new MC4WP_MailChimp();
|
427 |
+
$mailchimp->refresh_lists();
|
|
|
428 |
}
|
429 |
|
430 |
/**
|
435 |
* @param mixed $default
|
436 |
* @return mixed
|
437 |
*/
|
438 |
+
function mc4wp_array_get( $array, $key, $default = null ) {
|
439 |
+
if ( is_null( $key ) ) {
|
440 |
+
return $array;
|
441 |
+
}
|
|
|
442 |
|
443 |
+
if ( isset( $array[ $key ] ) ) {
|
444 |
+
return $array[ $key ];
|
445 |
+
}
|
446 |
|
447 |
+
foreach ( explode( '.', $key ) as $segment ) {
|
448 |
+
if ( ! is_array( $array ) || ! array_key_exists( $segment, $array ) ) {
|
449 |
+
return $default;
|
450 |
+
}
|
451 |
|
452 |
+
$array = $array[ $segment ];
|
453 |
+
}
|
454 |
|
455 |
+
return $array;
|
456 |
}
|
includes/integrations/class-admin.php
CHANGED
@@ -6,189 +6,179 @@
|
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
-
class MC4WP_Integration_Admin
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
echo sprintf('<h3>Integration not found.</h3><p>No integration with slug <strong>%s</strong> was found.</p>', esc_html($slug));
|
185 |
-
return;
|
186 |
-
}
|
187 |
-
|
188 |
-
$opts = $integration->options;
|
189 |
-
$mailchimp = new MC4WP_MailChimp();
|
190 |
-
$lists = $mailchimp->get_lists();
|
191 |
-
|
192 |
-
require dirname(__FILE__) . '/views/integration-settings.php';
|
193 |
-
}
|
194 |
}
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
+
class MC4WP_Integration_Admin {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var MC4WP_Integration_Manager
|
14 |
+
*/
|
15 |
+
protected $integrations;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var MC4WP_Admin_Messages
|
19 |
+
*/
|
20 |
+
protected $messages;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param MC4WP_Integration_Manager $integrations
|
24 |
+
* @param MC4WP_Admin_Messages $messages
|
25 |
+
*/
|
26 |
+
public function __construct( MC4WP_Integration_Manager $integrations, MC4WP_Admin_Messages $messages ) {
|
27 |
+
$this->integrations = $integrations;
|
28 |
+
$this->messages = $messages;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Add hooks
|
33 |
+
*/
|
34 |
+
public function add_hooks() {
|
35 |
+
add_action( 'admin_init', array( $this, 'register_setting' ) );
|
36 |
+
add_action( 'mc4wp_admin_enqueue_assets', array( $this, 'enqueue_assets' ), 10, 2 );
|
37 |
+
add_filter( 'mc4wp_admin_menu_items', array( $this, 'add_menu_item' ) );
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Register settings
|
42 |
+
*/
|
43 |
+
public function register_setting() {
|
44 |
+
register_setting( 'mc4wp_integrations_settings', 'mc4wp_integrations', array( $this, 'save_integration_settings' ) );
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Enqueue assets
|
49 |
+
*
|
50 |
+
* @param string $suffix
|
51 |
+
* @param string $page
|
52 |
+
*
|
53 |
+
* @return void
|
54 |
+
*/
|
55 |
+
public function enqueue_assets( $suffix, $page = '' ) {
|
56 |
+
|
57 |
+
// only load on integrations pages
|
58 |
+
if ( $page !== 'integrations' ) {
|
59 |
+
return;
|
60 |
+
}
|
61 |
+
|
62 |
+
wp_register_script( 'mc4wp-integrations-admin', MC4WP_PLUGIN_URL . 'assets/js/integrations-admin' . $suffix . '.js', array( 'mc4wp-admin' ), MC4WP_VERSION, true );
|
63 |
+
wp_enqueue_script( 'mc4wp-integrations-admin' );
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @param array $items
|
68 |
+
*
|
69 |
+
* @return array
|
70 |
+
*/
|
71 |
+
public function add_menu_item( $items ) {
|
72 |
+
$items[] = array(
|
73 |
+
'title' => __( 'Integrations', 'mailchimp-for-wp' ),
|
74 |
+
'text' => __( 'Integrations', 'mailchimp-for-wp' ),
|
75 |
+
'slug' => 'integrations',
|
76 |
+
'callback' => array( $this, 'show_integrations_page' ),
|
77 |
+
'position' => 20,
|
78 |
+
);
|
79 |
+
|
80 |
+
return $items;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @param array $new_settings
|
85 |
+
* @return array
|
86 |
+
*/
|
87 |
+
public function save_integration_settings( array $new_settings ) {
|
88 |
+
$integrations = $this->integrations->get_all();
|
89 |
+
$current_settings = (array) get_option( 'mc4wp_integrations', array() );
|
90 |
+
$settings = array();
|
91 |
+
|
92 |
+
foreach ( $integrations as $slug => $integration ) {
|
93 |
+
$settings[ $slug ] = $this->parse_integration_settings( $slug, $current_settings, $new_settings );
|
94 |
+
}
|
95 |
+
|
96 |
+
return $settings;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @since 3.0
|
101 |
+
* @param string $slug
|
102 |
+
* @param array $current
|
103 |
+
* @param array $new
|
104 |
+
*
|
105 |
+
* @return array
|
106 |
+
*/
|
107 |
+
protected function parse_integration_settings( $slug, $current, $new ) {
|
108 |
+
$settings = array();
|
109 |
+
|
110 |
+
// start with current settings
|
111 |
+
if ( ! empty( $current[ $slug ] ) ) {
|
112 |
+
$settings = $current[ $slug ];
|
113 |
+
}
|
114 |
+
|
115 |
+
// if no new settings were given, return current settings.
|
116 |
+
if ( empty( $new[ $slug ] ) ) {
|
117 |
+
return $settings;
|
118 |
+
}
|
119 |
+
|
120 |
+
// merge new settings with currents (to allow passing partial setting arrays)
|
121 |
+
$settings = array_merge( $settings, $new[ $slug ] );
|
122 |
+
|
123 |
+
// sanitize settings
|
124 |
+
$settings = $this->sanitize_integration_settings( $settings );
|
125 |
+
|
126 |
+
return $settings;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* @param array $settings
|
131 |
+
* @return array
|
132 |
+
*/
|
133 |
+
protected function sanitize_integration_settings( $settings ) {
|
134 |
+
|
135 |
+
// filter null values from lists setting
|
136 |
+
if ( ! empty( $settings['lists'] ) ) {
|
137 |
+
$settings['lists'] = array_filter( $settings['lists'] );
|
138 |
+
} else {
|
139 |
+
$settings['lists'] = array();
|
140 |
+
}
|
141 |
+
|
142 |
+
return $settings;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Show the Integration Settings page
|
147 |
+
*
|
148 |
+
* @internal
|
149 |
+
*/
|
150 |
+
public function show_integrations_page() {
|
151 |
+
if ( ! empty( $_GET['integration'] ) ) {
|
152 |
+
$this->show_integration_settings_page( $_GET['integration'] );
|
153 |
+
return;
|
154 |
+
}
|
155 |
+
|
156 |
+
// get all installed & enabled integrations
|
157 |
+
$enabled_integrations = $this->integrations->get_enabled_integrations();
|
158 |
+
|
159 |
+
// get all integrations but remove enabled integrations from the resulting array
|
160 |
+
$integrations = $this->integrations->get_all();
|
161 |
+
|
162 |
+
require dirname( __FILE__ ) . '/views/integrations.php';
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* @param string $slug
|
167 |
+
*
|
168 |
+
* @internal
|
169 |
+
*/
|
170 |
+
public function show_integration_settings_page( $slug ) {
|
171 |
+
try {
|
172 |
+
$integration = $this->integrations->get( $slug );
|
173 |
+
} catch ( Exception $e ) {
|
174 |
+
echo sprintf( '<h3>Integration not found.</h3><p>No integration with slug <strong>%s</strong> was found.</p>', esc_html( $slug ) );
|
175 |
+
return;
|
176 |
+
}
|
177 |
+
|
178 |
+
$opts = $integration->options;
|
179 |
+
$mailchimp = new MC4WP_MailChimp();
|
180 |
+
$lists = $mailchimp->get_lists();
|
181 |
+
|
182 |
+
require dirname( __FILE__ ) . '/views/integration-settings.php';
|
183 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
}
|
includes/integrations/class-integration-fixture.php
CHANGED
@@ -6,99 +6,95 @@
|
|
6 |
* @since 3.0
|
7 |
* @ignore
|
8 |
*/
|
9 |
-
class MC4WP_Integration_Fixture
|
10 |
-
{
|
11 |
|
12 |
-
/**
|
13 |
-
* @var string
|
14 |
-
*/
|
15 |
-
public $slug;
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
* @param array $options
|
47 |
-
*/
|
48 |
-
public function __construct($slug, $class, $enabled_by_default = false, array $options = array())
|
49 |
-
{
|
50 |
-
$this->slug = $slug;
|
51 |
-
$this->class = $class;
|
52 |
-
$this->enabled = $this->enabled_by_default = $enabled_by_default;
|
53 |
-
$this->options = $options;
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
*/
|
65 |
-
public function load()
|
66 |
-
{
|
67 |
-
if (! $this->instance instanceof MC4WP_Integration) {
|
68 |
-
$this->instance = new $this->class($this->slug, $this->options);
|
69 |
-
}
|
70 |
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
*
|
77 |
-
* @param $name
|
78 |
-
* @param $arguments
|
79 |
-
*
|
80 |
-
* @return MC4WP_Integration
|
81 |
-
*/
|
82 |
-
public function __call($name, $arguments)
|
83 |
-
{
|
84 |
-
return call_user_func_array(array( $this->load(), $name ), $arguments);
|
85 |
-
}
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
}
|
6 |
* @since 3.0
|
7 |
* @ignore
|
8 |
*/
|
9 |
+
class MC4WP_Integration_Fixture {
|
|
|
10 |
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
/**
|
13 |
+
* @var string
|
14 |
+
*/
|
15 |
+
public $slug;
|
16 |
|
17 |
+
/**
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
public $class;
|
21 |
|
22 |
+
/**
|
23 |
+
* @var bool
|
24 |
+
*/
|
25 |
+
public $enabled = false;
|
26 |
|
27 |
+
/**
|
28 |
+
* @var bool
|
29 |
+
*/
|
30 |
+
public $enabled_by_default = true;
|
31 |
|
32 |
+
/**
|
33 |
+
* @var MC4WP_Integration
|
34 |
+
*/
|
35 |
+
public $instance;
|
36 |
|
37 |
+
/**
|
38 |
+
* @var array
|
39 |
+
*/
|
40 |
+
public $options;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
/**
|
43 |
+
* @param string $slug
|
44 |
+
* @param string $class
|
45 |
+
* @param bool $enabled_by_default
|
46 |
+
* @param array $options
|
47 |
+
*/
|
48 |
+
public function __construct( $slug, $class, $enabled_by_default = false, array $options = array() ) {
|
49 |
+
$this->slug = $slug;
|
50 |
+
$this->class = $class;
|
51 |
+
$this->enabled_by_default = $enabled_by_default;
|
52 |
+
$this->enabled = $enabled_by_default;
|
53 |
+
$this->options = $options;
|
54 |
|
55 |
+
if ( ! empty( $options['enabled'] ) ) {
|
56 |
+
$this->enabled = true;
|
57 |
+
}
|
58 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
+
/**
|
61 |
+
* Returns the actual instance
|
62 |
+
*
|
63 |
+
* @return MC4WP_Integration
|
64 |
+
*/
|
65 |
+
public function load() {
|
66 |
+
if ( ! $this->instance instanceof MC4WP_Integration ) {
|
67 |
+
$this->instance = new $this->class( $this->slug, $this->options );
|
68 |
+
}
|
69 |
|
70 |
+
return $this->instance;
|
71 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
+
/**
|
74 |
+
* Tunnel everything to MC4WP_Integration class
|
75 |
+
*
|
76 |
+
* @param $name
|
77 |
+
* @param $arguments
|
78 |
+
*
|
79 |
+
* @return MC4WP_Integration
|
80 |
+
*/
|
81 |
+
public function __call( $name, $arguments ) {
|
82 |
+
return call_user_func_array( array( $this->load(), $name ), $arguments );
|
83 |
+
}
|
84 |
|
85 |
+
/**
|
86 |
+
* @param $name
|
87 |
+
*
|
88 |
+
* @return string
|
89 |
+
*/
|
90 |
+
public function __get( $name ) {
|
91 |
+
return $this->load()->$name;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @return string
|
96 |
+
*/
|
97 |
+
public function __toString() {
|
98 |
+
return $this->slug;
|
99 |
+
}
|
100 |
}
|
includes/integrations/class-integration-manager.php
CHANGED
@@ -6,184 +6,172 @@
|
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
-
class MC4WP_Integration_Manager
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
* @param $slug
|
178 |
-
* @return array
|
179 |
-
*/
|
180 |
-
public function get_integration_options($slug)
|
181 |
-
{
|
182 |
-
static $options;
|
183 |
-
if ($options === null) {
|
184 |
-
$options = $this->load_options();
|
185 |
-
}
|
186 |
-
|
187 |
-
return isset($options[ $slug ]) ? $options[ $slug ] : array();
|
188 |
-
}
|
189 |
}
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
+
class MC4WP_Integration_Manager {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var MC4WP_Integration_Fixture[]
|
14 |
+
*/
|
15 |
+
protected $integrations = array();
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var MC4WP_Integration_Tags
|
19 |
+
*/
|
20 |
+
protected $tags;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Constructor
|
24 |
+
*/
|
25 |
+
public function __construct() {
|
26 |
+
$this->tags = new MC4WP_Integration_Tags();
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Add hooks
|
31 |
+
*/
|
32 |
+
public function add_hooks() {
|
33 |
+
add_action( 'after_setup_theme', array( $this, 'initialize' ) );
|
34 |
+
|
35 |
+
$this->tags->add_hooks();
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Add hooks
|
41 |
+
*/
|
42 |
+
public function initialize() {
|
43 |
+
/*** @var MC4WP_Integration_Fixture $integration */
|
44 |
+
$enabled_integrations = $this->get_enabled_integrations();
|
45 |
+
|
46 |
+
foreach ( $enabled_integrations as $integration ) {
|
47 |
+
$integration->load()->initialize();
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Get an integration instance
|
53 |
+
*
|
54 |
+
* @return MC4WP_Integration_Fixture[]
|
55 |
+
* @throws Exception
|
56 |
+
*/
|
57 |
+
public function get_all() {
|
58 |
+
return $this->integrations;
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Get an integration instance
|
64 |
+
*
|
65 |
+
* @param string $slug
|
66 |
+
* @return MC4WP_Integration
|
67 |
+
* @throws Exception
|
68 |
+
*/
|
69 |
+
public function get( $slug ) {
|
70 |
+
if ( ! isset( $this->integrations[ $slug ] ) ) {
|
71 |
+
throw new Exception( sprintf( 'No integration with slug %s has been registered.', $slug ) );
|
72 |
+
}
|
73 |
+
|
74 |
+
return $this->integrations[ $slug ]->load();
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Register a new integration class
|
79 |
+
*
|
80 |
+
* @param string $slug
|
81 |
+
* @param string $class
|
82 |
+
* @param bool $enabled
|
83 |
+
*/
|
84 |
+
public function register_integration( $slug, $class, $enabled = false ) {
|
85 |
+
$raw_options = $this->get_integration_options( $slug );
|
86 |
+
$this->integrations[ $slug ] = new MC4WP_Integration_Fixture( $slug, $class, $enabled, $raw_options );
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Deregister an integration class
|
91 |
+
*
|
92 |
+
* @param string $slug
|
93 |
+
*/
|
94 |
+
public function deregister_integration( $slug ) {
|
95 |
+
if ( isset( $this->integrations[ $slug ] ) ) {
|
96 |
+
unset( $this->integrations[ $slug ] );
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Checks whether a certain integration is enabled (in the settings)
|
102 |
+
*
|
103 |
+
* This is decoupled from the integration class itself as checking an array is way "cheaper" than instantiating an object
|
104 |
+
*
|
105 |
+
* @param MC4WP_Integration_Fixture $integration
|
106 |
+
*
|
107 |
+
* @return bool
|
108 |
+
*/
|
109 |
+
public function is_enabled( MC4WP_Integration_Fixture $integration ) {
|
110 |
+
return $integration->enabled;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* @param MC4WP_Integration $integration
|
115 |
+
* @return bool
|
116 |
+
*/
|
117 |
+
public function is_installed( $integration ) {
|
118 |
+
return $integration->is_installed();
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Get the integrations which are enabled
|
123 |
+
*
|
124 |
+
* - Some integrations are always enabled because they need manual work
|
125 |
+
* - Other integrations can be enabled in the settings page
|
126 |
+
* - Only returns installed integrations
|
127 |
+
*
|
128 |
+
* @return array
|
129 |
+
*/
|
130 |
+
public function get_enabled_integrations() {
|
131 |
+
// get all enabled integrations
|
132 |
+
$enabled_integrations = array_filter( $this->integrations, array( $this, 'is_enabled' ) );
|
133 |
+
|
134 |
+
// remove duplicate values, for whatever reason..
|
135 |
+
$enabled_integrations = array_unique( $enabled_integrations );
|
136 |
+
|
137 |
+
// filter out integrations which are not installed
|
138 |
+
$installed_enabled_integrations = array_filter( $enabled_integrations, array( $this, 'is_installed' ) );
|
139 |
+
|
140 |
+
return $installed_enabled_integrations;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Gets all integration options in a keyed array
|
145 |
+
*
|
146 |
+
* @return array
|
147 |
+
*/
|
148 |
+
private function load_options() {
|
149 |
+
$options = (array) get_option( 'mc4wp_integrations', array() );
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Filters global integration options
|
153 |
+
*
|
154 |
+
* This array holds ALL integration settings
|
155 |
+
*
|
156 |
+
* @since 3.0
|
157 |
+
* @param array $options
|
158 |
+
* @ignore
|
159 |
+
*/
|
160 |
+
return (array) apply_filters( 'mc4wp_integration_options', $options );
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Gets the raw options for an integration
|
165 |
+
*
|
166 |
+
* @param $slug
|
167 |
+
* @return array
|
168 |
+
*/
|
169 |
+
public function get_integration_options( $slug ) {
|
170 |
+
static $options;
|
171 |
+
if ( $options === null ) {
|
172 |
+
$options = $this->load_options();
|
173 |
+
}
|
174 |
+
|
175 |
+
return isset( $options[ $slug ] ) ? $options[ $slug ] : array();
|
176 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
}
|
includes/integrations/class-integration-tags.php
CHANGED
@@ -6,57 +6,53 @@
|
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
-
class MC4WP_Integration_Tags extends MC4WP_Dynamic_Content_Tags
|
10 |
-
{
|
11 |
-
/**
|
12 |
-
* @var MC4WP_Integration
|
13 |
-
*/
|
14 |
-
protected $integration;
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
{
|
21 |
-
add_filter('mc4wp_integration_checkbox_label', array($this, 'replace_in_checkbox_label'), 10, 2);
|
22 |
-
}
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
*/
|
43 |
-
public function replace_in_checkbox_label($string, MC4WP_Integration $integration)
|
44 |
-
{
|
45 |
-
$this->integration = $integration;
|
46 |
-
$string = $this->replace($string, 'esc_html');
|
47 |
-
return $string;
|
48 |
-
}
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
}
|
6 |
* @ignore
|
7 |
* @access private
|
8 |
*/
|
9 |
+
class MC4WP_Integration_Tags extends MC4WP_Dynamic_Content_Tags {
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
/**
|
12 |
+
* @var MC4WP_Integration
|
13 |
+
*/
|
14 |
+
protected $integration;
|
|
|
|
|
|
|
15 |
|
16 |
+
/**
|
17 |
+
* Add hooks
|
18 |
+
*/
|
19 |
+
public function add_hooks() {
|
20 |
+
add_filter( 'mc4wp_integration_checkbox_label', array( $this, 'replace_in_checkbox_label' ), 10, 2 );
|
21 |
+
}
|
22 |
|
23 |
+
/**
|
24 |
+
* Register template tags for integrations
|
25 |
+
*/
|
26 |
+
public function register() {
|
27 |
+
parent::register();
|
28 |
|
29 |
+
$this->tags['subscriber_count'] = array(
|
30 |
+
'description' => __( 'Replaced with the number of subscribers on the selected list(s)', 'mailchimp-for-wp' ),
|
31 |
+
'callback' => array( $this, 'get_subscriber_count' ),
|
32 |
+
);
|
33 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
+
/**
|
36 |
+
* @hooked `mc4wp_integration_checkbox_label`
|
37 |
+
* @param string $string
|
38 |
+
* @param MC4WP_Integration $integration
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
public function replace_in_checkbox_label( $string, MC4WP_Integration $integration ) {
|
42 |
+
$this->integration = $integration;
|
43 |
+
$string = $this->replace( $string, 'esc_html' );
|
44 |
+
return $string;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Returns the number of subscribers on the selected lists (for the form context)
|
49 |
+
*
|
50 |
+
* @return int
|
51 |
+
*/
|
52 |
+
public function get_subscriber_count() {
|
53 |
+
$mailchimp = new MC4WP_MailChimp();
|
54 |
+
$list_ids = $this->integration->get_lists();
|
55 |
+
$count = $mailchimp->get_subscriber_count( $list_ids );
|
56 |
+
return number_format( $count );
|
57 |
+
}
|
58 |
}
|
includes/integrations/class-integration.php
CHANGED
@@ -11,8 +11,8 @@
|
|
11 |
* @since 3.0
|
12 |
* @abstract
|
13 |
*/
|
14 |
-
abstract class MC4WP_Integration
|
15 |
-
|
16 |
|
17 |
/**
|
18 |
* @var string Name of this integration.
|
@@ -45,13 +45,12 @@ abstract class MC4WP_Integration
|
|
45 |
* @param string $slug
|
46 |
* @param array $options
|
47 |
*/
|
48 |
-
public function __construct($slug, array $options)
|
49 |
-
|
50 |
-
$this->
|
51 |
-
$this->options = $this->parse_options($options);
|
52 |
|
53 |
// if checkbox name is not set, set a good custom value
|
54 |
-
if ($this->checkbox_name === '') {
|
55 |
$this->checkbox_name = '_mc4wp_subscribe_' . $this->slug;
|
56 |
}
|
57 |
}
|
@@ -61,19 +60,18 @@ abstract class MC4WP_Integration
|
|
61 |
*
|
62 |
* @return array
|
63 |
*/
|
64 |
-
protected function get_default_options()
|
65 |
-
{
|
66 |
return array(
|
67 |
-
'css'
|
68 |
-
'double_optin'
|
69 |
-
'enabled'
|
70 |
-
'implicit'
|
71 |
-
'label'
|
72 |
-
'lists'
|
73 |
-
'precheck'
|
74 |
'replace_interests' => 0,
|
75 |
-
'update_existing'
|
76 |
-
'wrap_p'
|
77 |
);
|
78 |
}
|
79 |
|
@@ -82,17 +80,16 @@ abstract class MC4WP_Integration
|
|
82 |
*
|
83 |
* @return array
|
84 |
*/
|
85 |
-
protected function parse_options(array $options)
|
86 |
-
{
|
87 |
$slug = $this->slug;
|
88 |
|
89 |
$default_options = $this->get_default_options();
|
90 |
-
$options
|
91 |
|
92 |
/**
|
93 |
* @deprecated Use mc4wp_integration_{$slug}_options instead
|
94 |
*/
|
95 |
-
$options = (array) apply_filters('mc4wp_' . $slug . '_integration_options', $options);
|
96 |
|
97 |
/**
|
98 |
* Filters options for a specific integration
|
@@ -101,14 +98,13 @@ abstract class MC4WP_Integration
|
|
101 |
*
|
102 |
* @param array $integration_options
|
103 |
*/
|
104 |
-
return (array) apply_filters('mc4wp_integration_' . $slug . '_options', $options);
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
* Initialize the integration
|
109 |
*/
|
110 |
-
public function initialize()
|
111 |
-
{
|
112 |
$this->add_required_hooks();
|
113 |
$this->add_hooks();
|
114 |
}
|
@@ -116,10 +112,9 @@ abstract class MC4WP_Integration
|
|
116 |
/**
|
117 |
* Adds the required hooks for core functionality, like adding checkbox reset CSS.
|
118 |
*/
|
119 |
-
protected function add_required_hooks()
|
120 |
-
|
121 |
-
|
122 |
-
add_action('wp_head', array( $this, 'print_css_reset' ));
|
123 |
}
|
124 |
}
|
125 |
|
@@ -131,8 +126,7 @@ abstract class MC4WP_Integration
|
|
131 |
* @param int $object_id Useful when overriding method. (optional)
|
132 |
* @return bool
|
133 |
*/
|
134 |
-
public function triggered($object_id = null)
|
135 |
-
{
|
136 |
return $this->options['implicit'] || $this->checkbox_was_checked();
|
137 |
}
|
138 |
|
@@ -146,15 +140,14 @@ abstract class MC4WP_Integration
|
|
146 |
*
|
147 |
* @hooked `wp_head`
|
148 |
*/
|
149 |
-
public function print_css_reset()
|
150 |
-
|
151 |
-
$
|
152 |
-
$css = file_get_contents(MC4WP_PLUGIN_DIR . 'assets/css/checkbox-reset' . $suffix . '.css');
|
153 |
|
154 |
// replace selector by integration specific selector so the css affects just this checkbox
|
155 |
-
$css = str_ireplace('__INTEGRATION_SLUG__', $this->slug, $css);
|
156 |
|
157 |
-
printf('<style type="text/css">%s</style>', $css);
|
158 |
}
|
159 |
|
160 |
/**
|
@@ -162,10 +155,9 @@ abstract class MC4WP_Integration
|
|
162 |
*
|
163 |
* @return string
|
164 |
*/
|
165 |
-
public function get_label_text()
|
166 |
-
{
|
167 |
$integration = $this;
|
168 |
-
$label
|
169 |
|
170 |
/**
|
171 |
* Filters the checkbox label
|
@@ -176,7 +168,7 @@ abstract class MC4WP_Integration
|
|
176 |
* @param MC4WP_Integration $integration
|
177 |
* @ignore
|
178 |
*/
|
179 |
-
$label = (string) apply_filters('mc4wp_integration_checkbox_label', $label, $integration);
|
180 |
return $label;
|
181 |
}
|
182 |
|
@@ -185,10 +177,9 @@ abstract class MC4WP_Integration
|
|
185 |
*
|
186 |
* @return bool
|
187 |
*/
|
188 |
-
public function checkbox_was_checked()
|
189 |
-
{
|
190 |
$data = $this->get_data();
|
191 |
-
return
|
192 |
}
|
193 |
|
194 |
/**
|
@@ -196,14 +187,13 @@ abstract class MC4WP_Integration
|
|
196 |
*
|
197 |
* @return string
|
198 |
*/
|
199 |
-
protected function get_checkbox_attributes()
|
200 |
-
{
|
201 |
$integration = $this;
|
202 |
-
$slug
|
203 |
|
204 |
$attributes = array();
|
205 |
|
206 |
-
if ($this->options['precheck']) {
|
207 |
$attributes['checked'] = 'checked';
|
208 |
}
|
209 |
|
@@ -214,7 +204,7 @@ abstract class MC4WP_Integration
|
|
214 |
* @param MC4WP_Integration $integration
|
215 |
* @ignore
|
216 |
*/
|
217 |
-
$attributes = (array) apply_filters('mc4wp_integration_checkbox_attributes', $attributes, $integration);
|
218 |
|
219 |
/**
|
220 |
* Filters the attributes array.
|
@@ -225,11 +215,11 @@ abstract class MC4WP_Integration
|
|
225 |
* @param MC4WP_Integration $integration
|
226 |
* @ignore
|
227 |
*/
|
228 |
-
$attributes = (array) apply_filters('mc4wp_integration_' . $slug . '_checkbox_attributes', $attributes, $integration);
|
229 |
|
230 |
$string = '';
|
231 |
-
foreach ($attributes as $key => $value) {
|
232 |
-
$string .= sprintf('%s="%s"', $key, esc_attr($value));
|
233 |
}
|
234 |
|
235 |
return $string;
|
@@ -238,8 +228,7 @@ abstract class MC4WP_Integration
|
|
238 |
/**
|
239 |
* Outputs a checkbox
|
240 |
*/
|
241 |
-
public function output_checkbox()
|
242 |
-
{
|
243 |
echo $this->get_checkbox_html();
|
244 |
}
|
245 |
|
@@ -248,9 +237,8 @@ abstract class MC4WP_Integration
|
|
248 |
* @param array $html_attrs
|
249 |
* @return string
|
250 |
*/
|
251 |
-
public function get_checkbox_html(array $html_attrs = array())
|
252 |
-
|
253 |
-
$show_checkbox = empty($this->options['implicit']);
|
254 |
$integration_slug = $this->slug;
|
255 |
|
256 |
/**
|
@@ -259,48 +247,51 @@ abstract class MC4WP_Integration
|
|
259 |
* @param bool $show_checkbox
|
260 |
* @param string $integration_slug
|
261 |
*/
|
262 |
-
$show_checkbox = (bool) apply_filters('mc4wp_integration_show_checkbox', $show_checkbox, $integration_slug);
|
263 |
|
264 |
-
if (! $show_checkbox) {
|
265 |
return '';
|
266 |
}
|
267 |
|
268 |
ob_start();
|
269 |
|
270 |
-
echo sprintf('<!-- Mailchimp for WordPress v%s - https://mc4wp.com/ -->', MC4WP_VERSION);
|
271 |
|
272 |
/** @ignore */
|
273 |
-
do_action('mc4wp_integration_before_checkbox_wrapper', $this);
|
274 |
|
275 |
/** @ignore */
|
276 |
-
do_action('mc4wp_integration_'. $this->slug .'_before_checkbox_wrapper', $this);
|
277 |
|
278 |
$wrapper_tag = $this->options['wrap_p'] ? 'p' : 'span';
|
279 |
|
280 |
-
$html_attrs
|
281 |
-
|
282 |
-
|
283 |
-
|
|
|
|
|
|
|
284 |
|
285 |
$html_attr_str = '';
|
286 |
-
foreach ($html_attrs as $key => $value) {
|
287 |
-
$html_attr_str .= sprintf('%s="%s" ', $key, esc_attr($value));
|
288 |
}
|
289 |
|
290 |
// Hidden field to make sure "0" is sent to server
|
291 |
-
echo sprintf('<input type="hidden" name="%s" value="0" />', esc_attr($this->checkbox_name));
|
292 |
-
echo sprintf('<%s %s>', $wrapper_tag, $html_attr_str);
|
293 |
echo '<label>';
|
294 |
-
echo sprintf('<input type="checkbox" name="%s" value="1" %s />', esc_attr($this->checkbox_name), $this->get_checkbox_attributes());
|
295 |
-
echo sprintf('<span>%s</span>', $this->get_label_text());
|
296 |
echo '</label>';
|
297 |
-
echo sprintf('</%s>', $wrapper_tag);
|
298 |
|
299 |
/** @ignore */
|
300 |
-
do_action('mc4wp_integration_after_checkbox_wrapper', $this);
|
301 |
|
302 |
/** @ignore */
|
303 |
-
do_action('mc4wp_integration_'. $this->slug .'_after_checkbox_wrapper', $this);
|
304 |
echo '<!-- / Mailchimp for WordPress -->';
|
305 |
|
306 |
$html = ob_get_clean();
|
@@ -312,23 +303,22 @@ abstract class MC4WP_Integration
|
|
312 |
*
|
313 |
* @return array Array of List ID's
|
314 |
*/
|
315 |
-
public function get_lists()
|
316 |
-
|
317 |
-
$data = $this->get_data();
|
318 |
$integration = $this;
|
319 |
-
$slug
|
320 |
|
321 |
// get checkbox lists options
|
322 |
$lists = $this->options['lists'];
|
323 |
|
324 |
// get lists from request, if set.
|
325 |
-
if (! empty($data['_mc4wp_lists'])) {
|
326 |
$lists = $data['_mc4wp_lists'];
|
327 |
|
328 |
// ensure lists is an array
|
329 |
-
if (! is_array($lists)) {
|
330 |
-
$lists = explode(',', $lists);
|
331 |
-
$lists = array_map('trim', $lists);
|
332 |
}
|
333 |
}
|
334 |
|
@@ -339,7 +329,7 @@ abstract class MC4WP_Integration
|
|
339 |
* @see MC4WP_Form::get_lists
|
340 |
* @ignore
|
341 |
*/
|
342 |
-
$lists = (array) apply_filters('mc4wp_lists', $lists);
|
343 |
|
344 |
/**
|
345 |
* Filters the Mailchimp lists this integration should subscribe to
|
@@ -349,7 +339,7 @@ abstract class MC4WP_Integration
|
|
349 |
* @param array $lists
|
350 |
* @param MC4WP_Integration $integration
|
351 |
*/
|
352 |
-
$lists = (array) apply_filters('mc4wp_integration_lists', $lists, $integration);
|
353 |
|
354 |
/**
|
355 |
* Filters the Mailchimp lists a specific integration should subscribe to
|
@@ -361,7 +351,7 @@ abstract class MC4WP_Integration
|
|
361 |
* @param array $lists
|
362 |
* @param MC4WP_Integration $integration
|
363 |
*/
|
364 |
-
$lists = (array) apply_filters('mc4wp_integration_' . $slug . '_lists', $lists, $integration);
|
365 |
|
366 |
return $lists;
|
367 |
}
|
@@ -374,21 +364,20 @@ abstract class MC4WP_Integration
|
|
374 |
*
|
375 |
* @return boolean
|
376 |
*/
|
377 |
-
protected function subscribe(array $data, $related_object_id = 0)
|
378 |
-
{
|
379 |
$integration = $this;
|
380 |
-
$slug
|
381 |
-
$mailchimp
|
382 |
-
$log
|
383 |
-
$list_ids
|
384 |
|
385 |
/** @var MC4WP_MailChimp_Subscriber $subscriber */
|
386 |
$subscriber = null;
|
387 |
-
$result
|
388 |
|
389 |
// validate lists
|
390 |
-
if (empty($list_ids)) {
|
391 |
-
$log->warning(sprintf('%s > No Mailchimp lists were selected', $this->name));
|
392 |
return false;
|
393 |
}
|
394 |
|
@@ -397,7 +386,7 @@ abstract class MC4WP_Integration
|
|
397 |
*
|
398 |
* @param array $data
|
399 |
*/
|
400 |
-
$data = apply_filters('mc4wp_integration_data', $data);
|
401 |
|
402 |
/**
|
403 |
* Filters data for a specific integration request.
|
@@ -407,47 +396,47 @@ abstract class MC4WP_Integration
|
|
407 |
* @param array $data
|
408 |
* @param int $related_object_id
|
409 |
*/
|
410 |
-
$data = apply_filters("mc4wp_integration_{$slug}_data", $data, $related_object_id);
|
411 |
|
412 |
/**
|
413 |
* @ignore
|
414 |
* @deprecated 4.0
|
415 |
*/
|
416 |
-
$data = apply_filters('mc4wp_merge_vars', $data);
|
417 |
|
418 |
/**
|
419 |
* @deprecated 4.0
|
420 |
* @ignore
|
421 |
*/
|
422 |
-
$data = apply_filters('mc4wp_integration_merge_vars', $data, $integration);
|
423 |
|
424 |
/**
|
425 |
* @deprecated 4.0
|
426 |
* @ignore
|
427 |
*/
|
428 |
-
$data = apply_filters("mc4wp_integration_{$slug}_merge_vars", $data, $integration);
|
429 |
|
430 |
$email_type = mc4wp_get_email_type();
|
431 |
|
432 |
-
$mapper = new MC4WP_List_Data_Mapper($data, $list_ids);
|
433 |
|
434 |
/** @var MC4WP_MailChimp_Subscriber[] $map */
|
435 |
$map = $mapper->map();
|
436 |
|
437 |
-
foreach ($map as $list_id => $subscriber) {
|
438 |
-
$subscriber->status
|
439 |
$subscriber->email_type = $email_type;
|
440 |
-
$subscriber->ip_signup
|
441 |
|
442 |
/** @ignore (documented elsewhere) */
|
443 |
-
$subscriber = apply_filters('mc4wp_subscriber_data', $subscriber);
|
444 |
|
445 |
/**
|
446 |
* Filters subscriber data before it is sent to Mailchimp. Only fires for integration requests.
|
447 |
*
|
448 |
* @param MC4WP_MailChimp_Subscriber $subscriber
|
449 |
*/
|
450 |
-
$subscriber = apply_filters('mc4wp_integration_subscriber_data', $subscriber);
|
451 |
|
452 |
/**
|
453 |
* Filters subscriber data before it is sent to Mailchimp. Only fires for integration requests.
|
@@ -457,26 +446,26 @@ abstract class MC4WP_Integration
|
|
457 |
* @param MC4WP_MailChimp_Subscriber $subscriber
|
458 |
* @param int $related_object_id
|
459 |
*/
|
460 |
-
$subscriber = apply_filters("mc4wp_integration_{$slug}_subscriber_data", $subscriber, $related_object_id);
|
461 |
|
462 |
-
$result = $mailchimp->list_subscribe($list_id, $subscriber->email_address, $subscriber->to_array(), $this->options['update_existing'], $this->options['replace_interests']);
|
463 |
}
|
464 |
|
465 |
// if result failed, show error message
|
466 |
-
if (! $result) {
|
467 |
|
468 |
// log error
|
469 |
-
if ($mailchimp->get_error_code()
|
470 |
-
$log->warning(sprintf(
|
471 |
} else {
|
472 |
-
$log->error(sprintf('%s > Mailchimp API Error: %s', $this->name, $mailchimp->get_error_message()));
|
473 |
}
|
474 |
|
475 |
// bail
|
476 |
return false;
|
477 |
}
|
478 |
|
479 |
-
$log->info(sprintf('%s > Successfully subscribed %s', $this->name, $subscriber->email_address));
|
480 |
|
481 |
/**
|
482 |
* Runs right after someone is subscribed using an integration
|
@@ -489,7 +478,7 @@ abstract class MC4WP_Integration
|
|
489 |
* @param MC4WP_MailChimp_Subscriber[] $subscriber_data
|
490 |
* @param int $related_object_id
|
491 |
*/
|
492 |
-
do_action('mc4wp_integration_subscribed', $integration, $subscriber->email_address, $subscriber->merge_fields, $map, $related_object_id);
|
493 |
|
494 |
return $result;
|
495 |
}
|
@@ -499,8 +488,7 @@ abstract class MC4WP_Integration
|
|
499 |
*
|
500 |
* @return bool
|
501 |
*/
|
502 |
-
public function is_installed()
|
503 |
-
{
|
504 |
return false;
|
505 |
}
|
506 |
|
@@ -509,9 +497,8 @@ abstract class MC4WP_Integration
|
|
509 |
*
|
510 |
* @return array
|
511 |
*/
|
512 |
-
public function get_ui_elements()
|
513 |
-
|
514 |
-
return array_keys($this->options);
|
515 |
}
|
516 |
|
517 |
/**
|
@@ -520,10 +507,9 @@ abstract class MC4WP_Integration
|
|
520 |
* @param string $element
|
521 |
* @return bool
|
522 |
*/
|
523 |
-
public function has_ui_element($element)
|
524 |
-
{
|
525 |
$elements = $this->get_ui_elements();
|
526 |
-
return in_array($element, $elements);
|
527 |
}
|
528 |
|
529 |
/**
|
@@ -532,8 +518,7 @@ abstract class MC4WP_Integration
|
|
532 |
* @param int $object_id
|
533 |
* @return string
|
534 |
*/
|
535 |
-
public function get_object_link($object_id)
|
536 |
-
{
|
537 |
return '';
|
538 |
}
|
539 |
|
@@ -552,25 +537,22 @@ abstract class MC4WP_Integration
|
|
552 |
*
|
553 |
* @return array
|
554 |
*/
|
555 |
-
public function get_data()
|
556 |
-
|
557 |
-
$data = array_merge((array) $_GET, (array) $_POST);
|
558 |
return $data;
|
559 |
}
|
560 |
|
561 |
/**
|
562 |
* @return MC4WP_Debug_Log
|
563 |
*/
|
564 |
-
protected function get_log()
|
565 |
-
|
566 |
-
return mc4wp('log');
|
567 |
}
|
568 |
|
569 |
/**
|
570 |
-
* @return
|
571 |
*/
|
572 |
-
protected function get_api()
|
573 |
-
|
574 |
-
return mc4wp('api');
|
575 |
}
|
576 |
}
|
11 |
* @since 3.0
|
12 |
* @abstract
|
13 |
*/
|
14 |
+
abstract class MC4WP_Integration {
|
15 |
+
|
16 |
|
17 |
/**
|
18 |
* @var string Name of this integration.
|
45 |
* @param string $slug
|
46 |
* @param array $options
|
47 |
*/
|
48 |
+
public function __construct( $slug, array $options ) {
|
49 |
+
$this->slug = $slug;
|
50 |
+
$this->options = $this->parse_options( $options );
|
|
|
51 |
|
52 |
// if checkbox name is not set, set a good custom value
|
53 |
+
if ( $this->checkbox_name === '' ) {
|
54 |
$this->checkbox_name = '_mc4wp_subscribe_' . $this->slug;
|
55 |
}
|
56 |
}
|
60 |
*
|
61 |
* @return array
|
62 |
*/
|
63 |
+
protected function get_default_options() {
|
|
|
64 |
return array(
|
65 |
+
'css' => 0,
|
66 |
+
'double_optin' => 1,
|
67 |
+
'enabled' => 0,
|
68 |
+
'implicit' => 0,
|
69 |
+
'label' => __( 'Sign me up for the newsletter!', 'mailchimp-for-wp' ),
|
70 |
+
'lists' => array(),
|
71 |
+
'precheck' => 0,
|
72 |
'replace_interests' => 0,
|
73 |
+
'update_existing' => 0,
|
74 |
+
'wrap_p' => 1,
|
75 |
);
|
76 |
}
|
77 |
|
80 |
*
|
81 |
* @return array
|
82 |
*/
|
83 |
+
protected function parse_options( array $options ) {
|
|
|
84 |
$slug = $this->slug;
|
85 |
|
86 |
$default_options = $this->get_default_options();
|
87 |
+
$options = array_merge( $default_options, $options );
|
88 |
|
89 |
/**
|
90 |
* @deprecated Use mc4wp_integration_{$slug}_options instead
|
91 |
*/
|
92 |
+
$options = (array) apply_filters( 'mc4wp_' . $slug . '_integration_options', $options );
|
93 |
|
94 |
/**
|
95 |
* Filters options for a specific integration
|
98 |
*
|
99 |
* @param array $integration_options
|
100 |
*/
|
101 |
+
return (array) apply_filters( 'mc4wp_integration_' . $slug . '_options', $options );
|
102 |
}
|
103 |
|
104 |
/**
|
105 |
* Initialize the integration
|
106 |
*/
|
107 |
+
public function initialize() {
|
|
|
108 |
$this->add_required_hooks();
|
109 |
$this->add_hooks();
|
110 |
}
|
112 |
/**
|
113 |
* Adds the required hooks for core functionality, like adding checkbox reset CSS.
|
114 |
*/
|
115 |
+
protected function add_required_hooks() {
|
116 |
+
if ( $this->options['css'] && ! $this->options['implicit'] ) {
|
117 |
+
add_action( 'wp_head', array( $this, 'print_css_reset' ) );
|
|
|
118 |
}
|
119 |
}
|
120 |
|
126 |
* @param int $object_id Useful when overriding method. (optional)
|
127 |
* @return bool
|
128 |
*/
|
129 |
+
public function triggered( $object_id = null ) {
|
|
|
130 |
return $this->options['implicit'] || $this->checkbox_was_checked();
|
131 |
}
|
132 |
|
140 |
*
|
141 |
* @hooked `wp_head`
|
142 |
*/
|
143 |
+
public function print_css_reset() {
|
144 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) ? '' : '.min';
|
145 |
+
$css = file_get_contents( MC4WP_PLUGIN_DIR . 'assets/css/checkbox-reset' . $suffix . '.css' );
|
|
|
146 |
|
147 |
// replace selector by integration specific selector so the css affects just this checkbox
|
148 |
+
$css = str_ireplace( '__INTEGRATION_SLUG__', $this->slug, $css );
|
149 |
|
150 |
+
printf( '<style type="text/css">%s</style>', $css );
|
151 |
}
|
152 |
|
153 |
/**
|
155 |
*
|
156 |
* @return string
|
157 |
*/
|
158 |
+
public function get_label_text() {
|
|
|
159 |
$integration = $this;
|
160 |
+
$label = $this->options['label'];
|
161 |
|
162 |
/**
|
163 |
* Filters the checkbox label
|
168 |
* @param MC4WP_Integration $integration
|
169 |
* @ignore
|
170 |
*/
|
171 |
+
$label = (string) apply_filters( 'mc4wp_integration_checkbox_label', $label, $integration );
|
172 |
return $label;
|
173 |
}
|
174 |
|
177 |
*
|
178 |
* @return bool
|
179 |
*/
|
180 |
+
public function checkbox_was_checked() {
|
|
|
181 |
$data = $this->get_data();
|
182 |
+
return isset( $data[ $this->checkbox_name ] ) && (int) $data[ $this->checkbox_name ] === 1;
|
183 |
}
|
184 |
|
185 |
/**
|
187 |
*
|
188 |
* @return string
|
189 |
*/
|
190 |
+
protected function get_checkbox_attributes() {
|
|
|
191 |
$integration = $this;
|
192 |
+
$slug = $this->slug;
|
193 |
|
194 |
$attributes = array();
|
195 |
|
196 |
+
if ( $this->options['precheck'] ) {
|
197 |
$attributes['checked'] = 'checked';
|
198 |
}
|
199 |
|
204 |
* @param MC4WP_Integration $integration
|
205 |
* @ignore
|
206 |
*/
|
207 |
+
$attributes = (array) apply_filters( 'mc4wp_integration_checkbox_attributes', $attributes, $integration );
|
208 |
|
209 |
/**
|
210 |
* Filters the attributes array.
|
215 |
* @param MC4WP_Integration $integration
|
216 |
* @ignore
|
217 |
*/
|
218 |
+
$attributes = (array) apply_filters( 'mc4wp_integration_' . $slug . '_checkbox_attributes', $attributes, $integration );
|
219 |
|
220 |
$string = '';
|
221 |
+
foreach ( $attributes as $key => $value ) {
|
222 |
+
$string .= sprintf( '%s="%s"', $key, esc_attr( $value ) );
|
223 |
}
|
224 |
|
225 |
return $string;
|
228 |
/**
|
229 |
* Outputs a checkbox
|
230 |
*/
|
231 |
+
public function output_checkbox() {
|
|
|
232 |
echo $this->get_checkbox_html();
|
233 |
}
|
234 |
|
237 |
* @param array $html_attrs
|
238 |
* @return string
|
239 |
*/
|
240 |
+
public function get_checkbox_html( array $html_attrs = array() ) {
|
241 |
+
$show_checkbox = empty( $this->options['implicit'] );
|
|
|
242 |
$integration_slug = $this->slug;
|
243 |
|
244 |
/**
|
247 |
* @param bool $show_checkbox
|
248 |
* @param string $integration_slug
|
249 |
*/
|
250 |
+
$show_checkbox = (bool) apply_filters( 'mc4wp_integration_show_checkbox', $show_checkbox, $integration_slug );
|
251 |
|
252 |
+
if ( ! $show_checkbox ) {
|
253 |
return '';
|
254 |
}
|
255 |
|
256 |
ob_start();
|
257 |
|
258 |
+
echo sprintf( '<!-- Mailchimp for WordPress v%s - https://mc4wp.com/ -->', MC4WP_VERSION );
|
259 |
|
260 |
/** @ignore */
|
261 |
+
do_action( 'mc4wp_integration_before_checkbox_wrapper', $this );
|
262 |
|
263 |
/** @ignore */
|
264 |
+
do_action( 'mc4wp_integration_' . $this->slug . '_before_checkbox_wrapper', $this );
|
265 |
|
266 |
$wrapper_tag = $this->options['wrap_p'] ? 'p' : 'span';
|
267 |
|
268 |
+
$html_attrs = array_merge(
|
269 |
+
array(
|
270 |
+
'class' => '',
|
271 |
+
),
|
272 |
+
$html_attrs
|
273 |
+
);
|
274 |
+
$html_attrs['class'] = $html_attrs['class'] . sprintf( ' mc4wp-checkbox mc4wp-checkbox-%s', $this->slug );
|
275 |
|
276 |
$html_attr_str = '';
|
277 |
+
foreach ( $html_attrs as $key => $value ) {
|
278 |
+
$html_attr_str .= sprintf( '%s="%s" ', $key, esc_attr( $value ) );
|
279 |
}
|
280 |
|
281 |
// Hidden field to make sure "0" is sent to server
|
282 |
+
echo sprintf( '<input type="hidden" name="%s" value="0" />', esc_attr( $this->checkbox_name ) );
|
283 |
+
echo sprintf( '<%s %s>', $wrapper_tag, $html_attr_str );
|
284 |
echo '<label>';
|
285 |
+
echo sprintf( '<input type="checkbox" name="%s" value="1" %s />', esc_attr( $this->checkbox_name ), $this->get_checkbox_attributes() );
|
286 |
+
echo sprintf( '<span>%s</span>', $this->get_label_text() );
|
287 |
echo '</label>';
|
288 |
+
echo sprintf( '</%s>', $wrapper_tag );
|
289 |
|
290 |
/** @ignore */
|
291 |
+
do_action( 'mc4wp_integration_after_checkbox_wrapper', $this );
|
292 |
|
293 |
/** @ignore */
|
294 |
+
do_action( 'mc4wp_integration_' . $this->slug . '_after_checkbox_wrapper', $this );
|
295 |
echo '<!-- / Mailchimp for WordPress -->';
|
296 |
|
297 |
$html = ob_get_clean();
|
303 |
*
|
304 |
* @return array Array of List ID's
|
305 |
*/
|
306 |
+
public function get_lists() {
|
307 |
+
$data = $this->get_data();
|
|
|
308 |
$integration = $this;
|
309 |
+
$slug = $this->slug;
|
310 |
|
311 |
// get checkbox lists options
|
312 |
$lists = $this->options['lists'];
|
313 |
|
314 |
// get lists from request, if set.
|
315 |
+
if ( ! empty( $data['_mc4wp_lists'] ) ) {
|
316 |
$lists = $data['_mc4wp_lists'];
|
317 |
|
318 |
// ensure lists is an array
|
319 |
+
if ( ! is_array( $lists ) ) {
|
320 |
+
$lists = explode( ',', $lists );
|
321 |
+
$lists = array_map( 'trim', $lists );
|
322 |
}
|
323 |
}
|
324 |
|
329 |
* @see MC4WP_Form::get_lists
|
330 |
* @ignore
|
331 |
*/
|
332 |
+
$lists = (array) apply_filters( 'mc4wp_lists', $lists );
|
333 |
|
334 |
/**
|
335 |
* Filters the Mailchimp lists this integration should subscribe to
|
339 |
* @param array $lists
|
340 |
* @param MC4WP_Integration $integration
|
341 |
*/
|
342 |
+
$lists = (array) apply_filters( 'mc4wp_integration_lists', $lists, $integration );
|
343 |
|
344 |
/**
|
345 |
* Filters the Mailchimp lists a specific integration should subscribe to
|
351 |
* @param array $lists
|
352 |
* @param MC4WP_Integration $integration
|
353 |
*/
|
354 |
+
$lists = (array) apply_filters( 'mc4wp_integration_' . $slug . '_lists', $lists, $integration );
|
355 |
|
356 |
return $lists;
|
357 |
}
|
364 |
*
|
365 |
* @return boolean
|
366 |
*/
|
367 |
+
protected function subscribe( array $data, $related_object_id = 0 ) {
|
|
|
368 |
$integration = $this;
|
369 |
+
$slug = $this->slug;
|
370 |
+
$mailchimp = new MC4WP_MailChimp();
|
371 |
+
$log = $this->get_log();
|
372 |
+
$list_ids = $this->get_lists();
|
373 |
|
374 |
/** @var MC4WP_MailChimp_Subscriber $subscriber */
|
375 |
$subscriber = null;
|
376 |
+
$result = false;
|
377 |
|
378 |
// validate lists
|
379 |
+
if ( empty( $list_ids ) ) {
|
380 |
+
$log->warning( sprintf( '%s > No Mailchimp lists were selected', $this->name ) );
|
381 |
return false;
|
382 |
}
|
383 |
|
386 |
*
|
387 |
* @param array $data
|
388 |
*/
|
389 |
+
$data = apply_filters( 'mc4wp_integration_data', $data );
|
390 |
|
391 |
/**
|
392 |
* Filters data for a specific integration request.
|
396 |
* @param array $data
|
397 |
* @param int $related_object_id
|
398 |
*/
|
399 |
+
$data = apply_filters( "mc4wp_integration_{$slug}_data", $data, $related_object_id );
|
400 |
|
401 |
/**
|
402 |
* @ignore
|
403 |
* @deprecated 4.0
|
404 |
*/
|
405 |
+
$data = apply_filters( 'mc4wp_merge_vars', $data );
|
406 |
|
407 |
/**
|
408 |
* @deprecated 4.0
|
409 |
* @ignore
|
410 |
*/
|
411 |
+
$data = apply_filters( 'mc4wp_integration_merge_vars', $data, $integration );
|
412 |
|
413 |
/**
|
414 |
* @deprecated 4.0
|
415 |
* @ignore
|
416 |
*/
|
417 |
+
$data = apply_filters( "mc4wp_integration_{$slug}_merge_vars", $data, $integration );
|
418 |
|
419 |
$email_type = mc4wp_get_email_type();
|
420 |
|
421 |
+
$mapper = new MC4WP_List_Data_Mapper( $data, $list_ids );
|
422 |
|
423 |
/** @var MC4WP_MailChimp_Subscriber[] $map */
|
424 |
$map = $mapper->map();
|
425 |
|
426 |
+
foreach ( $map as $list_id => $subscriber ) {
|
427 |
+
$subscriber->status = $this->options['double_optin'] ? 'pending' : 'subscribed';
|
428 |
$subscriber->email_type = $email_type;
|
429 |
+
$subscriber->ip_signup = mc4wp_get_request_ip_address();
|
430 |
|
431 |
/** @ignore (documented elsewhere) */
|
432 |
+
$subscriber = apply_filters( 'mc4wp_subscriber_data', $subscriber );
|
433 |
|
434 |
/**
|
435 |
* Filters subscriber data before it is sent to Mailchimp. Only fires for integration requests.
|
436 |
*
|
437 |
* @param MC4WP_MailChimp_Subscriber $subscriber
|
438 |
*/
|
439 |
+
$subscriber = apply_filters( 'mc4wp_integration_subscriber_data', $subscriber );
|
440 |
|
441 |
/**
|
442 |
* Filters subscriber data before it is sent to Mailchimp. Only fires for integration requests.
|
446 |
* @param MC4WP_MailChimp_Subscriber $subscriber
|
447 |
* @param int $related_object_id
|
448 |
*/
|
449 |
+
$subscriber = apply_filters( "mc4wp_integration_{$slug}_subscriber_data", $subscriber, $related_object_id );
|
450 |
|
451 |
+
$result = $mailchimp->list_subscribe( $list_id, $subscriber->email_address, $subscriber->to_array(), $this->options['update_existing'], $this->options['replace_interests'] );
|
452 |
}
|
453 |
|
454 |
// if result failed, show error message
|
455 |
+
if ( ! $result ) {
|
456 |
|
457 |
// log error
|
458 |
+
if ( (int) $mailchimp->get_error_code() === 214 ) {
|
459 |
+
$log->warning( sprintf( '%s > %s is already subscribed to the selected list(s)', $this->name, $subscriber->email_address ) );
|
460 |
} else {
|
461 |
+
$log->error( sprintf( '%s > Mailchimp API Error: %s', $this->name, $mailchimp->get_error_message() ) );
|
462 |
}
|
463 |
|
464 |
// bail
|
465 |
return false;
|
466 |
}
|
467 |
|
468 |
+
$log->info( sprintf( '%s > Successfully subscribed %s', $this->name, $subscriber->email_address ) );
|
469 |
|
470 |
/**
|
471 |
* Runs right after someone is subscribed using an integration
|
478 |
* @param MC4WP_MailChimp_Subscriber[] $subscriber_data
|
479 |
* @param int $related_object_id
|
480 |
*/
|
481 |
+
do_action( 'mc4wp_integration_subscribed', $integration, $subscriber->email_address, $subscriber->merge_fields, $map, $related_object_id );
|
482 |
|
483 |
return $result;
|
484 |
}
|
488 |
*
|
489 |
* @return bool
|
490 |
*/
|
491 |
+
public function is_installed() {
|
|
|
492 |
return false;
|
493 |
}
|
494 |
|
497 |
*
|
498 |
* @return array
|
499 |
*/
|
500 |
+
public function get_ui_elements() {
|
501 |
+
return array_keys( $this->options );
|
|
|
502 |
}
|
503 |
|
504 |
/**
|
507 |
* @param string $element
|
508 |
* @return bool
|
509 |
*/
|
510 |
+
public function has_ui_element( $element ) {
|
|
|
511 |
$elements = $this->get_ui_elements();
|
512 |
+
return in_array( $element, $elements, true );
|
513 |
}
|
514 |
|
515 |
/**
|
518 |
* @param int $object_id
|
519 |
* @return string
|
520 |
*/
|
521 |
+
public function get_object_link( $object_id ) {
|
|
|
522 |
return '';
|
523 |
}
|
524 |
|
537 |
*
|
538 |
* @return array
|
539 |
*/
|
540 |
+
public function get_data() {
|
541 |
+
$data = array_merge( (array) $_GET, (array) $_POST );
|
|
|
542 |
return $data;
|
543 |
}
|
544 |
|
545 |
/**
|
546 |
* @return MC4WP_Debug_Log
|
547 |
*/
|
548 |
+
protected function get_log() {
|
549 |
+
return mc4wp( 'log' );
|
|
|
550 |
}
|
551 |
|
552 |
/**
|
553 |
+
* @return MC4WP_API_V3
|
554 |
*/
|
555 |
+
protected function get_api() {
|
556 |
+
return mc4wp( 'api' );
|
|
|
557 |
}
|
558 |
}
|
includes/integrations/class-user-integration.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_User_Integration
|
@@ -8,43 +8,42 @@ defined('ABSPATH') or exit;
|
|
8 |
* @access public
|
9 |
* @since 2.0
|
10 |
*/
|
11 |
-
abstract class MC4WP_User_Integration extends MC4WP_Integration
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
}
|
50 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_User_Integration
|
8 |
* @access public
|
9 |
* @since 2.0
|
10 |
*/
|
11 |
+
abstract class MC4WP_User_Integration extends MC4WP_Integration {
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @param WP_User $user
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
protected function user_merge_vars( WP_User $user ) {
|
20 |
+
|
21 |
+
// start with user_login as name, since that's always known
|
22 |
+
$data = array(
|
23 |
+
'EMAIL' => $user->user_email,
|
24 |
+
'NAME' => $user->user_login,
|
25 |
+
);
|
26 |
+
|
27 |
+
if ( '' !== $user->first_name ) {
|
28 |
+
$data['NAME'] = $user->first_name;
|
29 |
+
$data['FNAME'] = $user->first_name;
|
30 |
+
}
|
31 |
+
|
32 |
+
if ( '' !== $user->last_name ) {
|
33 |
+
$data['LNAME'] = $user->last_name;
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( '' !== $user->first_name && '' !== $user->last_name ) {
|
37 |
+
$data['NAME'] = sprintf( '%s %s', $user->first_name, $user->last_name );
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @since 3.0
|
42 |
+
* @deprecated 4.0
|
43 |
+
* @ignore
|
44 |
+
*/
|
45 |
+
$data = (array) apply_filters( 'mc4wp_user_merge_vars', $data, $user );
|
46 |
+
|
47 |
+
return $data;
|
48 |
+
}
|
|
|
49 |
}
|
includes/integrations/functions.php
CHANGED
@@ -8,9 +8,8 @@
|
|
8 |
*
|
9 |
* @return MC4WP_Integration[]
|
10 |
*/
|
11 |
-
function mc4wp_get_integrations()
|
12 |
-
|
13 |
-
return mc4wp('integrations')->get_all();
|
14 |
}
|
15 |
|
16 |
/**
|
@@ -23,9 +22,8 @@ function mc4wp_get_integrations()
|
|
23 |
*
|
24 |
* @return MC4WP_Integration
|
25 |
*/
|
26 |
-
function mc4wp_get_integration($slug)
|
27 |
-
|
28 |
-
return mc4wp('integrations')->get($slug);
|
29 |
}
|
30 |
|
31 |
/**
|
@@ -39,9 +37,8 @@ function mc4wp_get_integration($slug)
|
|
39 |
*
|
40 |
* @param bool $always_enabled
|
41 |
*/
|
42 |
-
function mc4wp_register_integration($slug, $class, $always_enabled = false)
|
43 |
-
|
44 |
-
return mc4wp('integrations')->register_integration($slug, $class, $always_enabled);
|
45 |
}
|
46 |
|
47 |
/**
|
@@ -51,7 +48,6 @@ function mc4wp_register_integration($slug, $class, $always_enabled = false)
|
|
51 |
* @access public
|
52 |
* @param string $slug
|
53 |
*/
|
54 |
-
function mc4wp_deregister_integration($slug)
|
55 |
-
|
56 |
-
mc4wp('integrations')->deregister_integration($slug);
|
57 |
}
|
8 |
*
|
9 |
* @return MC4WP_Integration[]
|
10 |
*/
|
11 |
+
function mc4wp_get_integrations() {
|
12 |
+
return mc4wp( 'integrations' )->get_all();
|
|
|
13 |
}
|
14 |
|
15 |
/**
|
22 |
*
|
23 |
* @return MC4WP_Integration
|
24 |
*/
|
25 |
+
function mc4wp_get_integration( $slug ) {
|
26 |
+
return mc4wp( 'integrations' )->get( $slug );
|
|
|
27 |
}
|
28 |
|
29 |
/**
|
37 |
*
|
38 |
* @param bool $always_enabled
|
39 |
*/
|
40 |
+
function mc4wp_register_integration( $slug, $class, $always_enabled = false ) {
|
41 |
+
return mc4wp( 'integrations' )->register_integration( $slug, $class, $always_enabled );
|
|
|
42 |
}
|
43 |
|
44 |
/**
|
48 |
* @access public
|
49 |
* @param string $slug
|
50 |
*/
|
51 |
+
function mc4wp_deregister_integration( $slug ) {
|
52 |
+
mc4wp( 'integrations' )->deregister_integration( $slug );
|
|
|
53 |
}
|
includes/integrations/views/integration-settings.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
<?php defined('ABSPATH') or exit;
|
2 |
/** @var MC4WP_Integration $integration */
|
3 |
/** @var array $opts */
|
4 |
?>
|
5 |
<div id="mc4wp-admin" class="wrap mc4wp-settings">
|
6 |
|
7 |
<p class="breadcrumbs">
|
8 |
-
<span class="prefix"><?php echo __('You are here: ', 'mailchimp-for-wp'); ?></span>
|
9 |
-
<a href="<?php echo admin_url('admin.php?page=mailchimp-for-wp'); ?>">Mailchimp for WordPress</a> ›
|
10 |
-
<a href="<?php echo admin_url('admin.php?page=mailchimp-for-wp-integrations'); ?>"><?php _e('Integrations', 'mailchimp-for-wp'); ?></a> ›
|
11 |
-
<span class="current-crumb"><strong><?php echo esc_html($integration->name); ?></strong></span>
|
12 |
</p>
|
13 |
|
14 |
<div class="main-content row">
|
@@ -17,236 +17,284 @@
|
|
17 |
<div class="main-content col col-4 col-sm-6">
|
18 |
|
19 |
<h1 class="page-title">
|
20 |
-
<?php printf(__('%s integration', 'mailchimp-for-wp'), esc_html($integration->name)); ?>
|
21 |
</h1>
|
22 |
|
23 |
<h2 style="display: none;"></h2>
|
24 |
<?php settings_errors(); ?>
|
25 |
|
26 |
<div id="notice-additional-fields" class="notice notice-warning" style="display: none;">
|
27 |
-
<p><?php _e('The selected Mailchimp lists require non-default fields, which may prevent this integration from working.', 'mailchimp-for-wp'); ?></p>
|
28 |
-
<p><?php echo sprintf(__('Please ensure you <a href="%s">configure the plugin to send all required fields</a> or <a href="%s">log into your Mailchimp account</a> and make sure only the email & name fields are marked as required fields for the selected list(s).', 'mailchimp-for-wp'), 'https://kb.mc4wp.com/send-additional-fields-from-integrations/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=integrations-page', 'https://admin.mailchimp.com/lists/'); ?></p>
|
29 |
</div>
|
30 |
|
31 |
<p>
|
32 |
-
<?php
|
33 |
</p>
|
34 |
|
35 |
<!-- Settings form -->
|
36 |
-
<form method="post" action="<?php echo admin_url('options.php'); ?>">
|
37 |
-
<?php settings_fields('mc4wp_integrations_settings'); ?>
|
38 |
|
39 |
<?php
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
|
58 |
<table class="form-table">
|
59 |
|
60 |
-
<?php
|
61 |
-
|
|
|
62 |
<tr valign="top">
|
63 |
-
<th scope="row"><?php _e('Enabled?', 'mailchimp-for-wp'); ?></th>
|
64 |
<td class="nowrap integration-toggles-wrap">
|
65 |
-
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][enabled]" value="1" <?php checked($opts['enabled'], 1); ?> /> <?php _e('Yes'); ?></label>
|
66 |
-
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][enabled]" value="0" <?php checked($opts['enabled'], 0); ?> /> <?php _e('No'); ?></label>
|
67 |
-
<p class="help"><?php printf(__('Enable the %s integration? This will add a sign-up checkbox to the form.', 'mailchimp-for-wp'), $integration->name); ?></p>
|
68 |
</td>
|
69 |
</tr>
|
70 |
-
|
71 |
-
|
|
|
72 |
|
73 |
-
<?php
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
<?php
|
77 |
-
|
|
|
78 |
<tr valign="top">
|
79 |
-
<th scope="row"><?php _e('Implicit?', 'mailchimp-for-wp'); ?></th>
|
80 |
<td class="nowrap">
|
81 |
-
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][implicit]" value="1" <?php checked($opts['implicit'], 1); ?> /> <?php _e('Yes'); ?></label>
|
82 |
-
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][implicit]" value="0" <?php checked($opts['implicit'], 0); ?> /> <?php _e('No'); ?> <?php echo '<em>' . __('(recommended)', 'mailchimp-for-wp') . '</em>'; ?>
|
83 |
</label>
|
84 |
<p class="help">
|
85 |
-
<?php
|
86 |
-
|
|
|
87 |
|
88 |
-
|
|
|
89 |
</p>
|
90 |
</td>
|
91 |
</tr>
|
92 |
-
|
93 |
-
|
|
|
94 |
|
95 |
-
<?php
|
96 |
-
|
97 |
-
|
|
|
98 |
<input type="hidden" name="mc4wp_integrations[<?php echo $integration->slug; ?>][lists][]" value="" />
|
99 |
<tr valign="top">
|
100 |
-
<th scope="row"><?php _e('Mailchimp Lists', 'mailchimp-for-wp'); ?></th>
|
101 |
-
<?php
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
|
|
|
|
119 |
</tr>
|
120 |
-
|
121 |
-
|
|
|
122 |
|
123 |
-
<?php
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
127 |
<td>
|
128 |
-
<input type="text" class="widefat" id="mc4wp_checkbox_label" name="mc4wp_integrations[<?php echo $integration->slug; ?>][label]" value="<?php echo esc_attr($opts['label']); ?>" required />
|
129 |
-
<p class="help"><?php printf(__('HTML tags like %s are allowed in the label text.', 'mailchimp-for-wp'), '<code>' . esc_html('<strong><em><a>') . '</code>'); ?></p>
|
130 |
</td>
|
131 |
</tr>
|
132 |
-
|
133 |
-
|
|
|
134 |
|
135 |
|
136 |
-
<?php
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
140 |
<td class="nowrap">
|
141 |
-
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][precheck]" value="1" <?php checked($opts['precheck'], 1); ?> /> <?php _e('Yes'); ?></label>
|
142 |
-
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][precheck]" value="0" <?php checked($opts['precheck'], 0); ?> /> <?php _e('No'); ?> <?php echo '<em>' . __('(recommended)', 'mailchimp-for-wp') . '</em>'; ?></label>
|
143 |
<p class="help">
|
144 |
-
<?php
|
145 |
-
|
146 |
-
|
|
|
|
|
147 |
</p>
|
148 |
</td>
|
149 |
-
|
150 |
-
|
|
|
151 |
|
152 |
-
<?php
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
156 |
<td class="nowrap">
|
157 |
-
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][css]" value="1" <?php checked($opts['css'], 1); ?> />‏ <?php _e('Yes'); ?></label>
|
158 |
-
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][css]" value="0" <?php checked($opts['css'], 0); ?> />‏ <?php _e('No'); ?></label>
|
159 |
-
<p class="help"><?php _e('Select "yes" if the checkbox appears in a weird place.', 'mailchimp-for-wp'); ?></p>
|
160 |
</td>
|
161 |
</tr>
|
162 |
-
|
163 |
-
|
|
|
164 |
|
165 |
-
<?php
|
166 |
-
|
|
|
167 |
<tr valign="top">
|
168 |
-
<th scope="row"><?php _e('Double opt-in?', 'mailchimp-for-wp'); ?></th>
|
169 |
<td class="nowrap">
|
170 |
<label>
|
171 |
-
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][double_optin]" value="1" <?php checked($opts['double_optin'], 1); ?> />‏
|
172 |
-
<?php _e('Yes'); ?>
|
173 |
</label>
|
174 |
<label>
|
175 |
-
<input type="radio" id="mc4wp_checkbox_double_optin_0" name="mc4wp_integrations[<?php echo $integration->slug; ?>][double_optin]" value="0" <?php checked($opts['double_optin'], 0); ?> />‏
|
176 |
-
<?php _e('No'); ?>
|
177 |
</label>
|
178 |
<p class="help">
|
179 |
-
<?php _e('Select "yes" if you want people to confirm their email address before being subscribed (recommended)', 'mailchimp-for-wp'); ?>
|
180 |
</p>
|
181 |
</td>
|
182 |
</tr>
|
183 |
-
|
184 |
-
|
|
|
185 |
|
186 |
-
<?php
|
187 |
-
|
|
|
188 |
<tr valign="top">
|
189 |
-
<th scope="row"><?php _e('Update existing subscribers?', 'mailchimp-for-wp'); ?></th>
|
190 |
<td class="nowrap">
|
191 |
<label>
|
192 |
-
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][update_existing]" value="1" <?php checked($opts['update_existing'], 1); ?> />‏
|
193 |
-
<?php _e('Yes'); ?>
|
194 |
</label>
|
195 |
<label>
|
196 |
-
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][update_existing]" value="0" <?php checked($opts['update_existing'], 0); ?> />‏
|
197 |
-
<?php _e('No'); ?>
|
198 |
</label>
|
199 |
-
<p class="help"><?php _e('Select "yes" if you want to update existing subscribers with the data that is sent.', 'mailchimp-for-wp'); ?></p>
|
200 |
</td>
|
201 |
</tr>
|
202 |
-
|
203 |
-
|
|
|
204 |
|
205 |
-
<?php
|
206 |
-
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
209 |
<td class="nowrap">
|
210 |
<label>
|
211 |
-
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][replace_interests]" value="1" <?php checked($opts['replace_interests'], 1); ?> />‏
|
212 |
-
<?php _e('Yes'); ?>
|
213 |
</label>
|
214 |
<label>
|
215 |
-
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][replace_interests]" value="0" <?php checked($opts['replace_interests'], 0); ?> />‏
|
216 |
-
<?php _e('No'); ?>
|
217 |
</label>
|
218 |
<p class="help">
|
219 |
-
<?php _e('Select "no" if you want to add the selected interests to any previously selected interests when updating a subscriber.', 'mailchimp-for-wp'); ?>
|
220 |
-
<?php printf(' <a href="%s" target="_blank">' . __('What does this do?', 'mailchimp-for-wp') . '</a>', 'https://kb.mc4wp.com/what-does-replace-groupings-mean/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=integrations-page'); ?>
|
221 |
</p>
|
222 |
</td>
|
223 |
</tr>
|
224 |
-
|
225 |
-
|
|
|
226 |
|
227 |
</tbody>
|
228 |
</table>
|
229 |
|
230 |
<?php
|
231 |
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
<?php
|
248 |
-
|
249 |
-
|
|
|
|
|
250 |
|
251 |
</form>
|
252 |
|
1 |
+
<?php defined( 'ABSPATH' ) or exit;
|
2 |
/** @var MC4WP_Integration $integration */
|
3 |
/** @var array $opts */
|
4 |
?>
|
5 |
<div id="mc4wp-admin" class="wrap mc4wp-settings">
|
6 |
|
7 |
<p class="breadcrumbs">
|
8 |
+
<span class="prefix"><?php echo __( 'You are here: ', 'mailchimp-for-wp' ); ?></span>
|
9 |
+
<a href="<?php echo admin_url( 'admin.php?page=mailchimp-for-wp' ); ?>">Mailchimp for WordPress</a> ›
|
10 |
+
<a href="<?php echo admin_url( 'admin.php?page=mailchimp-for-wp-integrations' ); ?>"><?php _e( 'Integrations', 'mailchimp-for-wp' ); ?></a> ›
|
11 |
+
<span class="current-crumb"><strong><?php echo esc_html( $integration->name ); ?></strong></span>
|
12 |
</p>
|
13 |
|
14 |
<div class="main-content row">
|
17 |
<div class="main-content col col-4 col-sm-6">
|
18 |
|
19 |
<h1 class="page-title">
|
20 |
+
<?php printf( __( '%s integration', 'mailchimp-for-wp' ), esc_html( $integration->name ) ); ?>
|
21 |
</h1>
|
22 |
|
23 |
<h2 style="display: none;"></h2>
|
24 |
<?php settings_errors(); ?>
|
25 |
|
26 |
<div id="notice-additional-fields" class="notice notice-warning" style="display: none;">
|
27 |
+
<p><?php _e( 'The selected Mailchimp lists require non-default fields, which may prevent this integration from working.', 'mailchimp-for-wp' ); ?></p>
|
28 |
+
<p><?php echo sprintf( __( 'Please ensure you <a href="%1$s">configure the plugin to send all required fields</a> or <a href="%2$s">log into your Mailchimp account</a> and make sure only the email & name fields are marked as required fields for the selected list(s).', 'mailchimp-for-wp' ), 'https://kb.mc4wp.com/send-additional-fields-from-integrations/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=integrations-page', 'https://admin.mailchimp.com/lists/' ); ?></p>
|
29 |
</div>
|
30 |
|
31 |
<p>
|
32 |
+
<?php echo esc_html( $integration->description ); ?>
|
33 |
</p>
|
34 |
|
35 |
<!-- Settings form -->
|
36 |
+
<form method="post" action="<?php echo admin_url( 'options.php' ); ?>">
|
37 |
+
<?php settings_fields( 'mc4wp_integrations_settings' ); ?>
|
38 |
|
39 |
<?php
|
40 |
|
41 |
+
/**
|
42 |
+
* Runs just before integration settings are outputted in admin.
|
43 |
+
*
|
44 |
+
* @since 3.0
|
45 |
+
*
|
46 |
+
* @param MC4WP_Integration $integration
|
47 |
+
* @param array $opts
|
48 |
+
* @ignore
|
49 |
+
*/
|
50 |
+
do_action( 'mc4wp_admin_before_integration_settings', $integration, $opts );
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @ignore
|
54 |
+
*/
|
55 |
+
do_action( 'mc4wp_admin_before_' . $integration->slug . '_integration_settings', $integration, $opts );
|
56 |
+
?>
|
57 |
|
58 |
<table class="form-table">
|
59 |
|
60 |
+
<?php
|
61 |
+
if ( $integration->has_ui_element( 'enabled' ) ) {
|
62 |
+
?>
|
63 |
<tr valign="top">
|
64 |
+
<th scope="row"><?php _e( 'Enabled?', 'mailchimp-for-wp' ); ?></th>
|
65 |
<td class="nowrap integration-toggles-wrap">
|
66 |
+
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][enabled]" value="1" <?php checked( $opts['enabled'], 1 ); ?> /> <?php _e( 'Yes', 'mailchimp-for-wp' ); ?></label>
|
67 |
+
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][enabled]" value="0" <?php checked( $opts['enabled'], 0 ); ?> /> <?php _e( 'No', 'mailchimp-for-wp' ); ?></label>
|
68 |
+
<p class="help"><?php printf( __( 'Enable the %s integration? This will add a sign-up checkbox to the form.', 'mailchimp-for-wp' ), $integration->name ); ?></p>
|
69 |
</td>
|
70 |
</tr>
|
71 |
+
<?php
|
72 |
+
}
|
73 |
+
?>
|
74 |
|
75 |
+
<?php
|
76 |
+
$config = array(
|
77 |
+
'element' => 'mc4wp_integrations[' . $integration->slug . '][enabled]',
|
78 |
+
'value' => '1',
|
79 |
+
'hide' => false,
|
80 |
+
);
|
81 |
+
?>
|
82 |
+
<tbody class="integration-toggled-settings" data-showif="<?php echo esc_attr( json_encode( $config ) ); ?>">
|
83 |
|
84 |
+
<?php
|
85 |
+
if ( $integration->has_ui_element( 'implicit' ) ) {
|
86 |
+
?>
|
87 |
<tr valign="top">
|
88 |
+
<th scope="row"><?php _e( 'Implicit?', 'mailchimp-for-wp' ); ?></th>
|
89 |
<td class="nowrap">
|
90 |
+
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][implicit]" value="1" <?php checked( $opts['implicit'], 1 ); ?> /> <?php _e( 'Yes', 'mailchimp-for-wp' ); ?></label>
|
91 |
+
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][implicit]" value="0" <?php checked( $opts['implicit'], 0 ); ?> /> <?php _e( 'No', 'mailchimp-for-wp' ); ?> <?php echo '<em>' . __( '(recommended)', 'mailchimp-for-wp' ) . '</em>'; ?>
|
92 |
</label>
|
93 |
<p class="help">
|
94 |
+
<?php
|
95 |
+
_e( 'Select "yes" if you want to subscribe people without asking them explicitly.', 'mailchimp-for-wp' );
|
96 |
+
echo '<br />';
|
97 |
|
98 |
+
printf( __( '<strong>Warning: </strong> enabling this may affect your <a href="%s">GDPR compliance</a>.', 'mailchimp-for-wp' ), 'https://kb.mc4wp.com/gdpr-compliance/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=integrations-page' );
|
99 |
+
?>
|
100 |
</p>
|
101 |
</td>
|
102 |
</tr>
|
103 |
+
<?php
|
104 |
+
}
|
105 |
+
?>
|
106 |
|
107 |
+
<?php
|
108 |
+
if ( $integration->has_ui_element( 'lists' ) ) {
|
109 |
+
?>
|
110 |
+
<?php // hidden input to make sure a value is sent to the server when no checkboxes were selected ?>
|
111 |
<input type="hidden" name="mc4wp_integrations[<?php echo $integration->slug; ?>][lists][]" value="" />
|
112 |
<tr valign="top">
|
113 |
+
<th scope="row"><?php _e( 'Mailchimp Lists', 'mailchimp-for-wp' ); ?></th>
|
114 |
+
<?php
|
115 |
+
if ( ! empty( $lists ) ) {
|
116 |
+
echo '<td>';
|
117 |
+
echo '<ul style="margin-bottom: 20px; max-height: 300px; overflow-y: auto;">';
|
118 |
+
foreach ( $lists as $list ) {
|
119 |
+
echo '<li><label>';
|
120 |
+
echo sprintf( '<input type="checkbox" name="mc4wp_integrations[%s][lists][]" value="%s" class="mc4wp-list-input" %s> ', $integration->slug, $list->id, checked( in_array( $list->id, $opts['lists'], true ), true, false ) );
|
121 |
+
echo esc_html( $list->name );
|
122 |
+
echo '</label></li>';
|
123 |
+
}
|
124 |
+
echo '</ul>';
|
125 |
+
|
126 |
+
echo '<p class="help">';
|
127 |
+
_e( 'Select the list(s) to which people who check the checkbox should be subscribed.', 'mailchimp-for-wp' );
|
128 |
+
echo '</p>';
|
129 |
+
echo '</td>';
|
130 |
+
} else {
|
131 |
+
echo '<td>' . sprintf( __( 'No lists found, <a href="%s">are you connected to Mailchimp</a>?', 'mailchimp-for-wp' ), admin_url( 'admin.php?page=mailchimp-for-wp' ) ) . '</td>';
|
132 |
+
}
|
133 |
+
?>
|
134 |
</tr>
|
135 |
+
<?php
|
136 |
+
} // end if UI has lists
|
137 |
+
?>
|
138 |
|
139 |
+
<?php
|
140 |
+
if ( $integration->has_ui_element( 'label' ) ) {
|
141 |
+
$config = array(
|
142 |
+
'element' => 'mc4wp_integrations[' . $integration->slug . '][implicit]',
|
143 |
+
'value' => 0,
|
144 |
+
);
|
145 |
+
?>
|
146 |
+
<tr valign="top" data-showif="<?php echo esc_attr( json_encode( $config ) ); ?>">
|
147 |
+
<th scope="row"><label for="mc4wp_checkbox_label"><?php _e( 'Checkbox label text', 'mailchimp-for-wp' ); ?></label></th>
|
148 |
<td>
|
149 |
+
<input type="text" class="widefat" id="mc4wp_checkbox_label" name="mc4wp_integrations[<?php echo $integration->slug; ?>][label]" value="<?php echo esc_attr( $opts['label'] ); ?>" required />
|
150 |
+
<p class="help"><?php printf( __( 'HTML tags like %s are allowed in the label text.', 'mailchimp-for-wp' ), '<code>' . esc_html( '<strong><em><a>' ) . '</code>' ); ?></p>
|
151 |
</td>
|
152 |
</tr>
|
153 |
+
<?php
|
154 |
+
} // end if UI label
|
155 |
+
?>
|
156 |
|
157 |
|
158 |
+
<?php
|
159 |
+
if ( $integration->has_ui_element( 'precheck' ) ) {
|
160 |
+
$config = array(
|
161 |
+
'element' => 'mc4wp_integrations[' . $integration->slug . '][implicit]',
|
162 |
+
'value' => 0,
|
163 |
+
);
|
164 |
+
?>
|
165 |
+
<tr valign="top" data-showif="<?php echo esc_attr( json_encode( $config ) ); ?>">
|
166 |
+
<th scope="row"><?php _e( 'Pre-check the checkbox?', 'mailchimp-for-wp' ); ?></th>
|
167 |
<td class="nowrap">
|
168 |
+
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][precheck]" value="1" <?php checked( $opts['precheck'], 1 ); ?> /> <?php _e( 'Yes', 'mailchimp-for-wp' ); ?></label>
|
169 |
+
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][precheck]" value="0" <?php checked( $opts['precheck'], 0 ); ?> /> <?php _e( 'No', 'mailchimp-for-wp' ); ?> <?php echo '<em>' . __( '(recommended)', 'mailchimp-for-wp' ) . '</em>'; ?></label>
|
170 |
<p class="help">
|
171 |
+
<?php
|
172 |
+
_e( 'Select "yes" if the checkbox should be pre-checked.', 'mailchimp-for-wp' );
|
173 |
+
echo '<br />';
|
174 |
+
printf( __( '<strong>Warning: </strong> enabling this may affect your <a href="%s">GDPR compliance</a>.', 'mailchimp-for-wp' ), 'https://kb.mc4wp.com/gdpr-compliance/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=integrations-page' );
|
175 |
+
?>
|
176 |
</p>
|
177 |
</td>
|
178 |
+
<?php
|
179 |
+
} // end if UI precheck
|
180 |
+
?>
|
181 |
|
182 |
+
<?php
|
183 |
+
if ( $integration->has_ui_element( 'css' ) ) {
|
184 |
+
$config = array(
|
185 |
+
'element' => 'mc4wp_integrations[' . $integration->slug . '][implicit]',
|
186 |
+
'value' => 0,
|
187 |
+
);
|
188 |
+
?>
|
189 |
+
<tr valign="top" data-showif="<?php echo esc_attr( json_encode( $config ) ); ?>">
|
190 |
+
<th scope="row"><?php _e( 'Load some default CSS?', 'mailchimp-for-wp' ); ?></th>
|
191 |
<td class="nowrap">
|
192 |
+
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][css]" value="1" <?php checked( $opts['css'], 1 ); ?> />‏ <?php _e( 'Yes', 'mailchimp-for-wp' ); ?></label>
|
193 |
+
<label><input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][css]" value="0" <?php checked( $opts['css'], 0 ); ?> />‏ <?php _e( 'No', 'mailchimp-for-wp' ); ?></label>
|
194 |
+
<p class="help"><?php _e( 'Select "yes" if the checkbox appears in a weird place.', 'mailchimp-for-wp' ); ?></p>
|
195 |
</td>
|
196 |
</tr>
|
197 |
+
<?php
|
198 |
+
} // end if UI css
|
199 |
+
?>
|
200 |
|
201 |
+
<?php
|
202 |
+
if ( $integration->has_ui_element( 'double_optin' ) ) {
|
203 |
+
?>
|
204 |
<tr valign="top">
|
205 |
+
<th scope="row"><?php _e( 'Double opt-in?', 'mailchimp-for-wp' ); ?></th>
|
206 |
<td class="nowrap">
|
207 |
<label>
|
208 |
+
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][double_optin]" value="1" <?php checked( $opts['double_optin'], 1 ); ?> />‏
|
209 |
+
<?php _e( 'Yes', 'mailchimp-for-wp' ); ?>
|
210 |
</label>
|
211 |
<label>
|
212 |
+
<input type="radio" id="mc4wp_checkbox_double_optin_0" name="mc4wp_integrations[<?php echo $integration->slug; ?>][double_optin]" value="0" <?php checked( $opts['double_optin'], 0 ); ?> />‏
|
213 |
+
<?php _e( 'No', 'mailchimp-for-wp' ); ?>
|
214 |
</label>
|
215 |
<p class="help">
|
216 |
+
<?php _e( 'Select "yes" if you want people to confirm their email address before being subscribed (recommended)', 'mailchimp-for-wp' ); ?>
|
217 |
</p>
|
218 |
</td>
|
219 |
</tr>
|
220 |
+
<?php
|
221 |
+
} // end if UI double_optin
|
222 |
+
?>
|
223 |
|
224 |
+
<?php
|
225 |
+
if ( $integration->has_ui_element( 'update_existing' ) ) {
|
226 |
+
?>
|
227 |
<tr valign="top">
|
228 |
+
<th scope="row"><?php _e( 'Update existing subscribers?', 'mailchimp-for-wp' ); ?></th>
|
229 |
<td class="nowrap">
|
230 |
<label>
|
231 |
+
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][update_existing]" value="1" <?php checked( $opts['update_existing'], 1 ); ?> />‏
|
232 |
+
<?php _e( 'Yes', 'mailchimp-for-wp' ); ?>
|
233 |
</label>
|
234 |
<label>
|
235 |
+
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][update_existing]" value="0" <?php checked( $opts['update_existing'], 0 ); ?> />‏
|
236 |
+
<?php _e( 'No', 'mailchimp-for-wp' ); ?>
|
237 |
</label>
|
238 |
+
<p class="help"><?php _e( 'Select "yes" if you want to update existing subscribers with the data that is sent.', 'mailchimp-for-wp' ); ?></p>
|
239 |
</td>
|
240 |
</tr>
|
241 |
+
<?php
|
242 |
+
} // end if UI update_existing
|
243 |
+
?>
|
244 |
|
245 |
+
<?php
|
246 |
+
if ( $integration->has_ui_element( 'replace_interests' ) ) {
|
247 |
+
$config = array(
|
248 |
+
'element' => 'mc4wp_integrations[' . $integration->slug . '][update_existing]',
|
249 |
+
'value' => 1,
|
250 |
+
);
|
251 |
+
?>
|
252 |
+
<tr valign="top" data-showif="<?php echo esc_attr( json_encode( $config ) ); ?>">
|
253 |
+
<th scope="row"><?php _e( 'Replace interest groups?', 'mailchimp-for-wp' ); ?></th>
|
254 |
<td class="nowrap">
|
255 |
<label>
|
256 |
+
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][replace_interests]" value="1" <?php checked( $opts['replace_interests'], 1 ); ?> />‏
|
257 |
+
<?php _e( 'Yes', 'mailchimp-for-wp' ); ?>
|
258 |
</label>
|
259 |
<label>
|
260 |
+
<input type="radio" name="mc4wp_integrations[<?php echo $integration->slug; ?>][replace_interests]" value="0" <?php checked( $opts['replace_interests'], 0 ); ?> />‏
|
261 |
+
<?php _e( 'No', 'mailchimp-for-wp' ); ?>
|
262 |
</label>
|
263 |
<p class="help">
|
264 |
+
<?php _e( 'Select "no" if you want to add the selected interests to any previously selected interests when updating a subscriber.', 'mailchimp-for-wp' ); ?>
|
265 |
+
<?php printf( ' <a href="%s" target="_blank">' . __( 'What does this do?', 'mailchimp-for-wp' ) . '</a>', 'https://kb.mc4wp.com/what-does-replace-groupings-mean/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=integrations-page' ); ?>
|
266 |
</p>
|
267 |
</td>
|
268 |
</tr>
|
269 |
+
<?php
|
270 |
+
} // end if UI replace_interests
|
271 |
+
?>
|
272 |
|
273 |
</tbody>
|
274 |
</table>
|
275 |
|
276 |
<?php
|
277 |
|
278 |
+
/**
|
279 |
+
* Runs right after integration settings are outputted (before the submit button).
|
280 |
+
*
|
281 |
+
* @param MC4WP_Integration $integration
|
282 |
+
* @param array $opts
|
283 |
+
* @ignore
|
284 |
+
*/
|
285 |
+
do_action( 'mc4wp_admin_after_integration_settings', $integration, $opts );
|
286 |
+
|
287 |
+
/**
|
288 |
+
* @ignore
|
289 |
+
*/
|
290 |
+
do_action( 'mc4wp_admin_after_' . $integration->slug . '_integration_settings', $integration, $opts );
|
291 |
+
?>
|
292 |
+
|
293 |
+
<?php
|
294 |
+
if ( count( $integration->get_ui_elements() ) > 0 ) {
|
295 |
+
submit_button();
|
296 |
+
}
|
297 |
+
?>
|
298 |
|
299 |
</form>
|
300 |
|
includes/integrations/views/integrations.php
CHANGED
@@ -1,42 +1,48 @@
|
|
1 |
-
<?php defined('ABSPATH') or exit;
|
2 |
/** @var MC4WP_Integration_Fixture[] $enabled_integrations */
|
3 |
/** @var MC4WP_Integration_Fixture[] $available_integrations */
|
4 |
-
/** @var
|
5 |
-
function _mc4wp_integrations_table_row($integration) {
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
|
42 |
/**
|
@@ -45,54 +51,54 @@ function _mc4wp_integrations_table_row($integration) {
|
|
45 |
* @param $integrations
|
46 |
* @ignore
|
47 |
*/
|
48 |
-
function _mc4wp_integrations_table($integrations)
|
49 |
-
|
50 |
-
?>
|
51 |
<table class="mc4wp-table widefat striped">
|
52 |
|
53 |
<thead>
|
54 |
<tr>
|
55 |
-
<th><?php _e('Name', 'mailchimp-for-wp'); ?></th>
|
56 |
-
<th><?php _e('Description', 'mailchimp-for-wp'); ?></th>
|
57 |
-
|
58 |
</tr>
|
59 |
</thead>
|
60 |
|
61 |
<tbody>
|
62 |
|
63 |
<?php
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
|
86 |
</tbody>
|
87 |
-
</table
|
|
|
88 |
}
|
89 |
?>
|
90 |
<div id="mc4wp-admin" class="wrap mc4wp-settings">
|
91 |
|
92 |
<p class="breadcrumbs">
|
93 |
-
<span class="prefix"><?php echo __('You are here: ', 'mailchimp-for-wp'); ?></span>
|
94 |
-
<a href="<?php echo admin_url('admin.php?page=mailchimp-for-wp'); ?>">Mailchimp for WordPress</a> ›
|
95 |
-
<span class="current-crumb"><strong><?php _e('Integrations', 'mailchimp-for-wp'); ?></strong></span>
|
96 |
</p>
|
97 |
|
98 |
<div class="main-content row">
|
@@ -100,27 +106,27 @@ function _mc4wp_integrations_table($integrations)
|
|
100 |
<!-- Main Content -->
|
101 |
<div class="col col-4">
|
102 |
|
103 |
-
<h1 class="page-title">Mailchimp for WordPress: <?php _e('Integrations', 'mailchimp-for-wp'); ?></h1>
|
104 |
|
105 |
<h2 style="display: none;"></h2>
|
106 |
<?php settings_errors(); ?>
|
107 |
|
108 |
<p>
|
109 |
-
<?php _e('The table below shows all available integrations.', 'mailchimp-for-wp'); ?>
|
110 |
-
<?php _e('Click on the name of an integration to edit all settings specific to that integration.', 'mailchimp-for-wp'); ?>
|
111 |
</p>
|
112 |
|
113 |
-
<form action="<?php echo admin_url('options.php'); ?>" method="post">
|
114 |
|
115 |
-
<?php settings_fields('mc4wp_integrations_settings'); ?>
|
116 |
|
117 |
-
<h3><?php _e('Integrations', 'mailchimp-for-wp'); ?></h3>
|
118 |
-
<?php _mc4wp_integrations_table($integrations); ?>
|
119 |
|
120 |
-
|
121 |
|
122 |
|
123 |
-
|
124 |
|
125 |
</div>
|
126 |
|
1 |
+
<?php defined( 'ABSPATH' ) or exit;
|
2 |
/** @var MC4WP_Integration_Fixture[] $enabled_integrations */
|
3 |
/** @var MC4WP_Integration_Fixture[] $available_integrations */
|
4 |
+
/** @var MC4WP_Integration_Fixture $integration */
|
5 |
+
function _mc4wp_integrations_table_row( $integration ) {
|
6 |
+
?>
|
7 |
+
<tr style="
|
8 |
+
<?php
|
9 |
+
if ( ! $integration->is_installed() ) {
|
10 |
+
echo 'opacity: 0.4;';
|
11 |
+
}
|
12 |
+
?>
|
13 |
+
">
|
14 |
+
|
15 |
+
<!-- Integration Name -->
|
16 |
+
<td>
|
17 |
+
|
18 |
+
<?php
|
19 |
+
if ( $integration->is_installed() ) {
|
20 |
+
printf( '<strong><a href="%s" title="%s">%s</a></strong>', esc_attr( add_query_arg( array( 'integration' => $integration->slug ) ) ), __( 'Configure this integration', 'mailchimp-for-wp' ), $integration->name );
|
21 |
+
} else {
|
22 |
+
echo $integration->name;
|
23 |
+
}
|
24 |
+
?>
|
25 |
+
|
26 |
+
|
27 |
+
</td>
|
28 |
+
<td class="desc">
|
29 |
+
<?php
|
30 |
+
echo esc_html( $integration->description );
|
31 |
+
?>
|
32 |
+
</td>
|
33 |
+
<td>
|
34 |
+
<?php
|
35 |
+
if ( $integration->enabled && $integration->is_installed() ) {
|
36 |
+
echo '<span class="green">' . __( 'Active', 'mailchimp-for-wp' ) . '</span>';
|
37 |
+
} elseif ( $integration->is_installed() ) {
|
38 |
+
echo '<span class="neutral">' . __( 'Inactive', 'mailchimp-for-wp' ) . '</span>';
|
39 |
+
} else {
|
40 |
+
echo '<span class="red">' . __( 'Not installed', 'mailchimp-for-wp' ) . '</span>';
|
41 |
+
}
|
42 |
+
?>
|
43 |
+
</td>
|
44 |
+
</tr>
|
45 |
+
<?php
|
46 |
}
|
47 |
|
48 |
/**
|
51 |
* @param $integrations
|
52 |
* @ignore
|
53 |
*/
|
54 |
+
function _mc4wp_integrations_table( $integrations ) {
|
55 |
+
?>
|
|
|
56 |
<table class="mc4wp-table widefat striped">
|
57 |
|
58 |
<thead>
|
59 |
<tr>
|
60 |
+
<th><?php _e( 'Name', 'mailchimp-for-wp' ); ?></th>
|
61 |
+
<th><?php _e( 'Description', 'mailchimp-for-wp' ); ?></th>
|
62 |
+
<th><?php _e( 'Status', 'mailchimp-for-wp' ); ?></th>
|
63 |
</tr>
|
64 |
</thead>
|
65 |
|
66 |
<tbody>
|
67 |
|
68 |
<?php
|
69 |
+
// active & enabled integrations first
|
70 |
+
foreach ( $integrations as $integration ) {
|
71 |
+
if ( $integration->is_installed() && $integration->enabled ) {
|
72 |
+
_mc4wp_integrations_table_row( $integration );
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
// active & disabled integrations next
|
77 |
+
foreach ( $integrations as $integration ) {
|
78 |
+
if ( $integration->is_installed() && ! $integration->enabled ) {
|
79 |
+
_mc4wp_integrations_table_row( $integration );
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
// rest
|
84 |
+
foreach ( $integrations as $integration ) {
|
85 |
+
if ( ! $integration->is_installed() ) {
|
86 |
+
_mc4wp_integrations_table_row( $integration );
|
87 |
+
}
|
88 |
+
}
|
89 |
+
?>
|
90 |
|
91 |
</tbody>
|
92 |
+
</table>
|
93 |
+
<?php
|
94 |
}
|
95 |
?>
|
96 |
<div id="mc4wp-admin" class="wrap mc4wp-settings">
|
97 |
|
98 |
<p class="breadcrumbs">
|
99 |
+
<span class="prefix"><?php echo __( 'You are here: ', 'mailchimp-for-wp' ); ?></span>
|
100 |
+
<a href="<?php echo admin_url( 'admin.php?page=mailchimp-for-wp' ); ?>">Mailchimp for WordPress</a> ›
|
101 |
+
<span class="current-crumb"><strong><?php _e( 'Integrations', 'mailchimp-for-wp' ); ?></strong></span>
|
102 |
</p>
|
103 |
|
104 |
<div class="main-content row">
|
106 |
<!-- Main Content -->
|
107 |
<div class="col col-4">
|
108 |
|
109 |
+
<h1 class="page-title">Mailchimp for WordPress: <?php _e( 'Integrations', 'mailchimp-for-wp' ); ?></h1>
|
110 |
|
111 |
<h2 style="display: none;"></h2>
|
112 |
<?php settings_errors(); ?>
|
113 |
|
114 |
<p>
|
115 |
+
<?php _e( 'The table below shows all available integrations.', 'mailchimp-for-wp' ); ?>
|
116 |
+
<?php _e( 'Click on the name of an integration to edit all settings specific to that integration.', 'mailchimp-for-wp' ); ?>
|
117 |
</p>
|
118 |
|
119 |
+
<form action="<?php echo admin_url( 'options.php' ); ?>" method="post">
|
120 |
|
121 |
+
<?php settings_fields( 'mc4wp_integrations_settings' ); ?>
|
122 |
|
123 |
+
<h3><?php _e( 'Integrations', 'mailchimp-for-wp' ); ?></h3>
|
124 |
+
<?php _mc4wp_integrations_table( $integrations ); ?>
|
125 |
|
126 |
+
<p><?php echo __( 'Greyed out integrations will become available after installing & activating the corresponding plugin.', 'mailchimp-for-wp' ); ?></p>
|
127 |
|
128 |
|
129 |
+
</form>
|
130 |
|
131 |
</div>
|
132 |
|
includes/views/extensions.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
defined('ABSPATH') or exit;
|
3 |
?>
|
4 |
|
5 |
|
@@ -48,10 +48,10 @@ defined('ABSPATH') or exit;
|
|
48 |
<p>Improved Mailchimp integration for multilingual sites using WPML.</p>
|
49 |
</div>
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
</div>
|
56 |
|
57 |
|
1 |
<?php
|
2 |
+
defined( 'ABSPATH' ) or exit;
|
3 |
?>
|
4 |
|
5 |
|
48 |
<p>Improved Mailchimp integration for multilingual sites using WPML.</p>
|
49 |
</div>
|
50 |
|
51 |
+
<div>
|
52 |
+
<h4><a href="https://wordpress.org/plugins/mailchimp-top-bar/">Boxzilla Pop-ups</a></h4>
|
53 |
+
<p>Pop-ups for your sign-up forms.</p>
|
54 |
+
</div>
|
55 |
</div>
|
56 |
|
57 |
|
includes/views/general-settings.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
-
defined('ABSPATH') or exit;
|
3 |
?>
|
4 |
<div id="mc4wp-admin" class="wrap mc4wp-settings">
|
5 |
|
6 |
<p class="breadcrumbs">
|
7 |
-
<span class="prefix"><?php echo __('You are here: ', 'mailchimp-for-wp'); ?></span>
|
8 |
<span class="current-crumb"><strong>Mailchimp for WordPress</strong></span>
|
9 |
</p>
|
10 |
|
@@ -15,50 +15,54 @@ defined('ABSPATH') or exit;
|
|
15 |
<div class="main-content col col-4">
|
16 |
|
17 |
<h1 class="page-title">
|
18 |
-
|
19 |
</h1>
|
20 |
|
21 |
<h2 style="display: none;"></h2>
|
22 |
<?php
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
<form action="<?php echo admin_url('options.php'); ?>" method="post">
|
28 |
-
<?php settings_fields('mc4wp_settings'); ?>
|
29 |
|
30 |
<table class="form-table">
|
31 |
|
32 |
<tr valign="top">
|
33 |
<th scope="row">
|
34 |
-
<?php _e('Status', 'mailchimp-for-wp'); ?>
|
35 |
</th>
|
36 |
<td>
|
37 |
-
<?php if ($connected) {
|
38 |
-
?>
|
39 |
-
<span class="status positive"><?php _e('CONNECTED', 'mailchimp-for-wp'); ?></span>
|
40 |
<?php
|
41 |
-
|
42 |
-
|
43 |
-
<span class="status
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
46 |
</td>
|
47 |
</tr>
|
48 |
|
49 |
|
50 |
<tr valign="top">
|
51 |
-
<th scope="row"><label for="mailchimp_api_key"><?php _e('API Key', 'mailchimp-for-wp'); ?></label></th>
|
52 |
<td>
|
53 |
-
<input type="text" class="widefat" placeholder="<?php _e('Your Mailchimp API key', 'mailchimp-for-wp'); ?>" id="mailchimp_api_key" name="mc4wp[api_key]" value="<?php echo esc_attr($obfuscated_api_key); ?>" <?php echo defined('MC4WP_API_KEY') ? 'readonly="readonly"' : ''; ?> />
|
54 |
<p class="help">
|
55 |
-
<?php _e('The API key for connecting with your Mailchimp account.', 'mailchimp-for-wp'); ?>
|
56 |
-
<a target="_blank" href="https://admin.mailchimp.com/account/api"><?php _e('Get your API key here.', 'mailchimp-for-wp'); ?></a>
|
57 |
</p>
|
58 |
|
59 |
-
<?php
|
60 |
-
|
61 |
-
|
|
|
|
|
62 |
</td>
|
63 |
|
64 |
</tr>
|
@@ -71,27 +75,27 @@ defined('ABSPATH') or exit;
|
|
71 |
|
72 |
<?php
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
|
87 |
-
|
88 |
|
89 |
-
|
90 |
</div>
|
91 |
|
92 |
<!-- Sidebar -->
|
93 |
<div class="sidebar col col-2">
|
94 |
-
<?php include dirname(__FILE__) . '/parts/admin-sidebar.php'; ?>
|
95 |
</div>
|
96 |
|
97 |
|
1 |
<?php
|
2 |
+
defined( 'ABSPATH' ) or exit;
|
3 |
?>
|
4 |
<div id="mc4wp-admin" class="wrap mc4wp-settings">
|
5 |
|
6 |
<p class="breadcrumbs">
|
7 |
+
<span class="prefix"><?php echo __( 'You are here: ', 'mailchimp-for-wp' ); ?></span>
|
8 |
<span class="current-crumb"><strong>Mailchimp for WordPress</strong></span>
|
9 |
</p>
|
10 |
|
15 |
<div class="main-content col col-4">
|
16 |
|
17 |
<h1 class="page-title">
|
18 |
+
Mailchimp for WordPress: <?php _e( 'API Settings', 'mailchimp-for-wp' ); ?>
|
19 |
</h1>
|
20 |
|
21 |
<h2 style="display: none;"></h2>
|
22 |
<?php
|
23 |
+
settings_errors();
|
24 |
+
$this->messages->show();
|
25 |
+
?>
|
26 |
|
27 |
+
<form action="<?php echo admin_url( 'options.php' ); ?>" method="post">
|
28 |
+
<?php settings_fields( 'mc4wp_settings' ); ?>
|
29 |
|
30 |
<table class="form-table">
|
31 |
|
32 |
<tr valign="top">
|
33 |
<th scope="row">
|
34 |
+
<?php _e( 'Status', 'mailchimp-for-wp' ); ?>
|
35 |
</th>
|
36 |
<td>
|
|
|
|
|
|
|
37 |
<?php
|
38 |
+
if ( $connected ) {
|
39 |
+
?>
|
40 |
+
<span class="status positive"><?php _e( 'CONNECTED', 'mailchimp-for-wp' ); ?></span>
|
41 |
+
<?php
|
42 |
+
} else {
|
43 |
+
?>
|
44 |
+
<span class="status neutral"><?php _e( 'NOT CONNECTED', 'mailchimp-for-wp' ); ?></span>
|
45 |
+
<?php
|
46 |
+
}
|
47 |
+
?>
|
48 |
</td>
|
49 |
</tr>
|
50 |
|
51 |
|
52 |
<tr valign="top">
|
53 |
+
<th scope="row"><label for="mailchimp_api_key"><?php _e( 'API Key', 'mailchimp-for-wp' ); ?></label></th>
|
54 |
<td>
|
55 |
+
<input type="text" class="widefat" placeholder="<?php _e( 'Your Mailchimp API key', 'mailchimp-for-wp' ); ?>" id="mailchimp_api_key" name="mc4wp[api_key]" value="<?php echo esc_attr( $obfuscated_api_key ); ?>" <?php echo defined( 'MC4WP_API_KEY' ) ? 'readonly="readonly"' : ''; ?> />
|
56 |
<p class="help">
|
57 |
+
<?php _e( 'The API key for connecting with your Mailchimp account.', 'mailchimp-for-wp' ); ?>
|
58 |
+
<a target="_blank" href="https://admin.mailchimp.com/account/api"><?php _e( 'Get your API key here.', 'mailchimp-for-wp' ); ?></a>
|
59 |
</p>
|
60 |
|
61 |
+
<?php
|
62 |
+
if ( defined( 'MC4WP_API_KEY' ) ) {
|
63 |
+
echo '<p class="help">' . __( 'You defined your Mailchimp API key using the <code>MC4WP_API_KEY</code> constant.', 'mailchimp-for-wp' ) . '</p>';
|
64 |
+
}
|
65 |
+
?>
|
66 |
</td>
|
67 |
|
68 |
</tr>
|
75 |
|
76 |
<?php
|
77 |
|
78 |
+
/**
|
79 |
+
* Runs right after general settings are outputted in admin.
|
80 |
+
*
|
81 |
+
* @since 3.0
|
82 |
+
* @ignore
|
83 |
+
*/
|
84 |
+
do_action( 'mc4wp_admin_after_general_settings' );
|
85 |
|
86 |
+
if ( ! empty( $opts['api_key'] ) ) {
|
87 |
+
echo '<hr />';
|
88 |
+
include dirname( __FILE__ ) . '/parts/lists-overview.php';
|
89 |
+
}
|
90 |
|
91 |
+
include dirname( __FILE__ ) . '/parts/admin-footer.php';
|
92 |
|
93 |
+
?>
|
94 |
</div>
|
95 |
|
96 |
<!-- Sidebar -->
|
97 |
<div class="sidebar col col-2">
|
98 |
+
<?php include dirname( __FILE__ ) . '/parts/admin-sidebar.php'; ?>
|
99 |
</div>
|
100 |
|
101 |
|
includes/views/other-settings.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
defined('ABSPATH') or exit;
|
3 |
|
4 |
/** @var MC4WP_Debug_Log $log */
|
5 |
/** @var MC4WP_Debug_Log_Reader $log_reader */
|
@@ -8,41 +8,40 @@ defined('ABSPATH') or exit;
|
|
8 |
* @ignore
|
9 |
* @param array $opts
|
10 |
*/
|
11 |
-
function _mc4wp_usage_tracking_setting($opts)
|
12 |
-
|
13 |
-
?>
|
14 |
<div class="medium-margin" >
|
15 |
-
<h3><?php _e('Miscellaneous settings', 'mailchimp-for-wp'); ?></h3>
|
16 |
<table class="form-table">
|
17 |
<tr>
|
18 |
-
<th><?php _e('Usage Tracking', 'mailchimp-for-wp'); ?></th>
|
19 |
<td>
|
20 |
<label>
|
21 |
-
<input type="radio" name="mc4wp[allow_usage_tracking]" value="1" <?php checked($opts['allow_usage_tracking'], 1); ?> />
|
22 |
-
<?php _e('Yes'); ?>
|
23 |
</label>
|
24 |
<label>
|
25 |
-
<input type="radio" name="mc4wp[allow_usage_tracking]" value="0" <?php checked($opts['allow_usage_tracking'], 0); ?> />
|
26 |
-
<?php _e('No'); ?>
|
27 |
</label>
|
28 |
|
29 |
<p class="help">
|
30 |
-
<?php echo __('Allow us to anonymously track how this plugin is used to help us make it better fit your needs.', 'mailchimp-for-wp'); ?>
|
31 |
<a href="https://kb.mc4wp.com/what-is-usage-tracking/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=settings-page" target="_blank">
|
32 |
-
<?php _e('This is what we track.', 'mailchimp-for-wp'); ?>
|
33 |
</a>
|
34 |
</p>
|
35 |
</td>
|
36 |
</tr>
|
37 |
<tr>
|
38 |
-
<th><?php _e('Logging', 'mailchimp-for-wp'); ?></th>
|
39 |
<td>
|
40 |
<select name="mc4wp[debug_log_level]">
|
41 |
-
<option value="warning" <?php selected('warning', $opts['debug_log_level']); ?>><?php _e('Errors & warnings only', 'mailchimp-for-wp'); ?></option>
|
42 |
-
<option value="debug" <?php selected('debug', $opts['debug_log_level']); ?>><?php _e('Everything', 'mailchimp-for-wp'); ?></option>
|
43 |
</select>
|
44 |
<p class="help">
|
45 |
-
<?php printf(__('Determines what events should be written to <a href="%s">the debug log</a> (see below).', 'mailchimp-for-wp'), 'https://kb.mc4wp.com/how-to-enable-log-debugging/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=settings-page'); ?>
|
46 |
</p>
|
47 |
</td>
|
48 |
</tr>
|
@@ -51,14 +50,14 @@ function _mc4wp_usage_tracking_setting($opts)
|
|
51 |
<?php
|
52 |
}
|
53 |
|
54 |
-
add_action('mc4wp_admin_other_settings', '_mc4wp_usage_tracking_setting', 70);
|
55 |
?>
|
56 |
<div id="mc4wp-admin" class="wrap mc4wp-settings">
|
57 |
|
58 |
<p class="breadcrumbs">
|
59 |
-
<span class="prefix"><?php echo __('You are here: ', 'mailchimp-for-wp'); ?></span>
|
60 |
-
<a href="<?php echo admin_url('admin.php?page=mailchimp-for-wp'); ?>">Mailchimp for WordPress</a> ›
|
61 |
-
<span class="current-crumb"><strong><?php _e('Other Settings', 'mailchimp-for-wp'); ?></strong></span>
|
62 |
</p>
|
63 |
|
64 |
|
@@ -68,83 +67,84 @@ add_action('mc4wp_admin_other_settings', '_mc4wp_usage_tracking_setting', 70);
|
|
68 |
<div class="main-content col col-4">
|
69 |
|
70 |
<h1 class="page-title">
|
71 |
-
<?php _e('Other Settings', 'mailchimp-for-wp'); ?>
|
72 |
</h1>
|
73 |
|
74 |
<h2 style="display: none;"></h2>
|
75 |
<?php settings_errors(); ?>
|
76 |
|
77 |
<?php
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
|
84 |
<!-- Settings -->
|
85 |
-
<form action="<?php echo admin_url('options.php'); ?>" method="post">
|
86 |
-
<?php settings_fields('mc4wp_settings'); ?>
|
87 |
|
88 |
<?php
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
|
95 |
<div style="margin-top: -20px;"><?php submit_button(); ?></div>
|
96 |
</form>
|
97 |
|
98 |
<!-- Debug Log -->
|
99 |
<div class="medium-margin">
|
100 |
-
<h3><?php _e('Debug Log', 'mailchimp-for-wp'); ?> <input type="text" id="debug-log-filter" class="alignright regular-text" placeholder="<?php esc_attr_e('Filter..', 'mailchimp-for-wp'); ?>" /></h3>
|
101 |
|
102 |
<?php
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
<div id="debug-log" class="mc4wp-log widefat">
|
114 |
<?php
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
130 |
</div>
|
131 |
|
132 |
<form method="post">
|
133 |
<input type="hidden" name="_mc4wp_action" value="empty_debug_log">
|
134 |
<p>
|
135 |
<input type="submit" class="button"
|
136 |
-
value="<?php esc_attr_e('Empty Log', 'mailchimp-for-wp'); ?>"/>
|
137 |
</p>
|
138 |
</form>
|
139 |
<?php
|
140 |
-
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
|
149 |
<script>
|
150 |
(function() {
|
@@ -193,12 +193,12 @@ add_action('mc4wp_admin_other_settings', '_mc4wp_usage_tracking_setting', 70);
|
|
193 |
|
194 |
|
195 |
|
196 |
-
<?php include dirname(__FILE__) . '/parts/admin-footer.php'; ?>
|
197 |
</div>
|
198 |
|
199 |
<!-- Sidebar -->
|
200 |
<div class="sidebar col col-2">
|
201 |
-
<?php include dirname(__FILE__) . '/parts/admin-sidebar.php'; ?>
|
202 |
</div>
|
203 |
|
204 |
|
1 |
<?php
|
2 |
+
defined( 'ABSPATH' ) or exit;
|
3 |
|
4 |
/** @var MC4WP_Debug_Log $log */
|
5 |
/** @var MC4WP_Debug_Log_Reader $log_reader */
|
8 |
* @ignore
|
9 |
* @param array $opts
|
10 |
*/
|
11 |
+
function _mc4wp_usage_tracking_setting( $opts ) {
|
12 |
+
?>
|
|
|
13 |
<div class="medium-margin" >
|
14 |
+
<h3><?php _e( 'Miscellaneous settings', 'mailchimp-for-wp' ); ?></h3>
|
15 |
<table class="form-table">
|
16 |
<tr>
|
17 |
+
<th><?php _e( 'Usage Tracking', 'mailchimp-for-wp' ); ?></th>
|
18 |
<td>
|
19 |
<label>
|
20 |
+
<input type="radio" name="mc4wp[allow_usage_tracking]" value="1" <?php checked( $opts['allow_usage_tracking'], 1 ); ?> />
|
21 |
+
<?php _e( 'Yes', 'mailchimp-for-wp' ); ?>
|
22 |
</label>
|
23 |
<label>
|
24 |
+
<input type="radio" name="mc4wp[allow_usage_tracking]" value="0" <?php checked( $opts['allow_usage_tracking'], 0 ); ?> />
|
25 |
+
<?php _e( 'No', 'mailchimp-for-wp' ); ?>
|
26 |
</label>
|
27 |
|
28 |
<p class="help">
|
29 |
+
<?php echo __( 'Allow us to anonymously track how this plugin is used to help us make it better fit your needs.', 'mailchimp-for-wp' ); ?>
|
30 |
<a href="https://kb.mc4wp.com/what-is-usage-tracking/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=settings-page" target="_blank">
|
31 |
+
<?php _e( 'This is what we track.', 'mailchimp-for-wp' ); ?>
|
32 |
</a>
|
33 |
</p>
|
34 |
</td>
|
35 |
</tr>
|
36 |
<tr>
|
37 |
+
<th><?php _e( 'Logging', 'mailchimp-for-wp' ); ?></th>
|
38 |
<td>
|
39 |
<select name="mc4wp[debug_log_level]">
|
40 |
+
<option value="warning" <?php selected( 'warning', $opts['debug_log_level'] ); ?>><?php _e( 'Errors & warnings only', 'mailchimp-for-wp' ); ?></option>
|
41 |
+
<option value="debug" <?php selected( 'debug', $opts['debug_log_level'] ); ?>><?php _e( 'Everything', 'mailchimp-for-wp' ); ?></option>
|
42 |
</select>
|
43 |
<p class="help">
|
44 |
+
<?php printf( __( 'Determines what events should be written to <a href="%s">the debug log</a> (see below).', 'mailchimp-for-wp' ), 'https://kb.mc4wp.com/how-to-enable-log-debugging/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=settings-page' ); ?>
|
45 |
</p>
|
46 |
</td>
|
47 |
</tr>
|
50 |
<?php
|
51 |
}
|
52 |
|
53 |
+
add_action( 'mc4wp_admin_other_settings', '_mc4wp_usage_tracking_setting', 70 );
|
54 |
?>
|
55 |
<div id="mc4wp-admin" class="wrap mc4wp-settings">
|
56 |
|
57 |
<p class="breadcrumbs">
|
58 |
+
<span class="prefix"><?php echo __( 'You are here: ', 'mailchimp-for-wp' ); ?></span>
|
59 |
+
<a href="<?php echo admin_url( 'admin.php?page=mailchimp-for-wp' ); ?>">Mailchimp for WordPress</a> ›
|
60 |
+
<span class="current-crumb"><strong><?php _e( 'Other Settings', 'mailchimp-for-wp' ); ?></strong></span>
|
61 |
</p>
|
62 |
|
63 |
|
67 |
<div class="main-content col col-4">
|
68 |
|
69 |
<h1 class="page-title">
|
70 |
+
<?php _e( 'Other Settings', 'mailchimp-for-wp' ); ?>
|
71 |
</h1>
|
72 |
|
73 |
<h2 style="display: none;"></h2>
|
74 |
<?php settings_errors(); ?>
|
75 |
|
76 |
<?php
|
77 |
+
/**
|
78 |
+
* @ignore
|
79 |
+
*/
|
80 |
+
do_action( 'mc4wp_admin_before_other_settings', $opts );
|
81 |
+
?>
|
82 |
|
83 |
<!-- Settings -->
|
84 |
+
<form action="<?php echo admin_url( 'options.php' ); ?>" method="post">
|
85 |
+
<?php settings_fields( 'mc4wp_settings' ); ?>
|
86 |
|
87 |
<?php
|
88 |
+
/**
|
89 |
+
* @ignore
|
90 |
+
*/
|
91 |
+
do_action( 'mc4wp_admin_other_settings', $opts );
|
92 |
+
?>
|
93 |
|
94 |
<div style="margin-top: -20px;"><?php submit_button(); ?></div>
|
95 |
</form>
|
96 |
|
97 |
<!-- Debug Log -->
|
98 |
<div class="medium-margin">
|
99 |
+
<h3><?php _e( 'Debug Log', 'mailchimp-for-wp' ); ?> <input type="text" id="debug-log-filter" class="alignright regular-text" placeholder="<?php esc_attr_e( 'Filter..', 'mailchimp-for-wp' ); ?>" /></h3>
|
100 |
|
101 |
<?php
|
102 |
+
if ( ! $log->test() ) {
|
103 |
+
echo '<p>';
|
104 |
+
echo __( 'Log file is not writable.', 'mailchimp-for-wp' ) . ' ';
|
105 |
+
echo sprintf( __( 'Please ensure %1$s has the proper <a href="%2$s">file permissions</a>.', 'mailchimp-for-wp' ), '<code>' . $log->file . '</code>', 'https://codex.wordpress.org/Changing_File_Permissions' );
|
106 |
+
echo '</p>';
|
107 |
+
|
108 |
+
// hack to hide filter input
|
109 |
+
echo '<style type="text/css">#debug-log-filter { display: none; }</style>';
|
110 |
+
} else {
|
111 |
+
?>
|
112 |
<div id="debug-log" class="mc4wp-log widefat">
|
113 |
<?php
|
114 |
+
$line = $log_reader->read_as_html();
|
115 |
+
|
116 |
+
if ( ! empty( $line ) ) {
|
117 |
+
while ( is_string( $line ) ) {
|
118 |
+
if ( ! empty( $line ) ) {
|
119 |
+
echo '<div class="debug-log-line">' . $line . '</div>';
|
120 |
+
}
|
121 |
+
|
122 |
+
$line = $log_reader->read_as_html();
|
123 |
+
}
|
124 |
+
} else {
|
125 |
+
echo '<div class="debug-log-empty">';
|
126 |
+
echo '-- ' . __( 'Nothing here. Which means there are no errors!', 'mailchimp-for-wp' );
|
127 |
+
echo '</div>';
|
128 |
+
}
|
129 |
+
?>
|
130 |
</div>
|
131 |
|
132 |
<form method="post">
|
133 |
<input type="hidden" name="_mc4wp_action" value="empty_debug_log">
|
134 |
<p>
|
135 |
<input type="submit" class="button"
|
136 |
+
value="<?php esc_attr_e( 'Empty Log', 'mailchimp-for-wp' ); ?>"/>
|
137 |
</p>
|
138 |
</form>
|
139 |
<?php
|
140 |
+
} // end if is writable
|
141 |
|
142 |
+
if ( $log->level >= 300 ) {
|
143 |
+
echo '<p>';
|
144 |
+
echo __( 'Right now, the plugin is configured to only log errors and warnings.', 'mailchimp-for-wp' );
|
145 |
+
echo '</p>';
|
146 |
+
}
|
147 |
+
?>
|
148 |
|
149 |
<script>
|
150 |
(function() {
|
193 |
|
194 |
|
195 |
|
196 |
+
<?php include dirname( __FILE__ ) . '/parts/admin-footer.php'; ?>
|
197 |
</div>
|
198 |
|
199 |
<!-- Sidebar -->
|
200 |
<div class="sidebar col col-2">
|
201 |
+
<?php include dirname( __FILE__ ) . '/parts/admin-sidebar.php'; ?>
|
202 |
</div>
|
203 |
|
204 |
|
includes/views/parts/admin-footer.php
CHANGED
@@ -1,55 +1,52 @@
|
|
1 |
-
<?php defined('ABSPATH') or exit;
|
2 |
|
3 |
/**
|
4 |
* @ignore
|
5 |
*/
|
6 |
-
function _mc4wp_admin_translation_notice()
|
7 |
-
{
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
echo '<p class="help">' . sprintf(__('Mailchimp for WordPress is in need of translations. Is the plugin not translated in your language or do you spot errors with the current translations? Helping out is easy! Head over to <a href="%s">the translation project and click "help translate"</a>.', 'mailchimp-for-wp'), 'https://www.transifex.com/projects/p/mailchimp-for-wordpress/') . '</p>';
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
* @ignore
|
21 |
*/
|
22 |
-
function _mc4wp_admin_github_notice()
|
23 |
-
{
|
24 |
-
|
25 |
-
|
26 |
-
}
|
27 |
|
28 |
-
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
* @ignore
|
33 |
*/
|
34 |
-
function _mc4wp_admin_disclaimer_notice()
|
35 |
-
|
36 |
-
echo '<p class="help">' . __('This plugin is not developed by or affiliated with Mailchimp in any way.', 'mailchimp-for-wp') . '</p>';
|
37 |
}
|
38 |
|
39 |
-
add_action('mc4wp_admin_footer', '_mc4wp_admin_translation_notice', 20);
|
40 |
-
add_action('mc4wp_admin_footer', '_mc4wp_admin_github_notice', 50);
|
41 |
-
add_action('mc4wp_admin_footer', '_mc4wp_admin_disclaimer_notice', 80);
|
42 |
?>
|
43 |
|
44 |
<div class="big-margin">
|
45 |
|
46 |
<?php
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
54 |
|
55 |
</div>
|
1 |
+
<?php defined( 'ABSPATH' ) or exit;
|
2 |
|
3 |
/**
|
4 |
* @ignore
|
5 |
*/
|
6 |
+
function _mc4wp_admin_translation_notice() {
|
|
|
7 |
|
8 |
+
// show for every language other than the default
|
9 |
+
if ( stripos( get_locale(), 'en_us' ) === 0 ) {
|
10 |
+
return;
|
11 |
+
}
|
12 |
|
13 |
+
/* translators: %s links to the WordPress.org translation project */
|
14 |
+
echo '<p class="help">' . sprintf( __( 'Mailchimp for WordPress is in need of translations. Is the plugin not translated in your language or do you spot errors with the current translations? Helping out is easy! Please <a href="%s">help translate the plugin using your WordPress.org account</a>.', 'mailchimp-for-wp' ), 'https://translate.wordpress.org/projects/wp-plugins/mailchimp-for-wp/stable/' ) . '</p>';
|
|
|
15 |
}
|
16 |
|
17 |
/**
|
18 |
* @ignore
|
19 |
*/
|
20 |
+
function _mc4wp_admin_github_notice() {
|
21 |
+
if ( strpos( $_SERVER['HTTP_HOST'], 'local' ) !== 0 && ! WP_DEBUG ) {
|
22 |
+
return;
|
23 |
+
}
|
|
|
24 |
|
25 |
+
echo '<p class="help">Developer? Follow <a href="https://github.com/ibericode/mailchimp-for-wordpress">Mailchimp for WordPress on GitHub</a> or have a look at our repository of <a href="https://github.com/ibericode/mc4wp-snippets">sample code snippets</a>.</p>';
|
26 |
}
|
27 |
|
28 |
/**
|
29 |
* @ignore
|
30 |
*/
|
31 |
+
function _mc4wp_admin_disclaimer_notice() {
|
32 |
+
echo '<p class="help">' . __( 'This plugin is not developed by or affiliated with Mailchimp in any way.', 'mailchimp-for-wp' ) . '</p>';
|
|
|
33 |
}
|
34 |
|
35 |
+
add_action( 'mc4wp_admin_footer', '_mc4wp_admin_translation_notice', 20 );
|
36 |
+
add_action( 'mc4wp_admin_footer', '_mc4wp_admin_github_notice', 50 );
|
37 |
+
add_action( 'mc4wp_admin_footer', '_mc4wp_admin_disclaimer_notice', 80 );
|
38 |
?>
|
39 |
|
40 |
<div class="big-margin">
|
41 |
|
42 |
<?php
|
43 |
|
44 |
+
/**
|
45 |
+
* Runs while printing the footer of every Mailchimp for WordPress settings page.
|
46 |
+
*
|
47 |
+
* @since 3.0
|
48 |
+
*/
|
49 |
+
do_action( 'mc4wp_admin_footer' );
|
50 |
+
?>
|
51 |
|
52 |
</div>
|
includes/views/parts/admin-sidebar.php
CHANGED
@@ -1,22 +1,21 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* @ignore
|
7 |
*/
|
8 |
-
function _mc4wp_admin_sidebar_support_notice()
|
9 |
-
|
10 |
-
?>
|
11 |
<div class="mc4wp-box">
|
12 |
-
<h4 class="mc4wp-title"><?php echo esc_html__('Looking for help?', 'mailchimp-for-wp'); ?></h4>
|
13 |
-
<p><?php echo __('We have some resources available to help you in the right direction.', 'mailchimp-for-wp'); ?></p>
|
14 |
<ul class="ul-square">
|
15 |
-
<li><a href="https://kb.mc4wp.com/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=sidebar"><?php echo esc_html__('Knowledge Base', 'mailchimp-for-wp'); ?></a></li>
|
16 |
-
<li><a href="https://wordpress.org/plugins/mailchimp-for-wp/faq/"><?php echo esc_html__('Frequently Asked Questions', 'mailchimp-for-wp'); ?></a></li>
|
17 |
</ul>
|
18 |
-
<p><?php echo sprintf(__('If your answer can not be found in the resources listed above, please use the <a href="%s">support forums on WordPress.org</a>.'), 'https://wordpress.org/support/plugin/mailchimp-for-wp'); ?></p>
|
19 |
-
<p><?php echo sprintf(__('Found a bug? Please <a href="%s">open an issue on GitHub</a>.'), 'https://github.com/ibericode/mailchimp-for-wordpress/issues'); ?></p>
|
20 |
</div>
|
21 |
<?php
|
22 |
}
|
@@ -24,37 +23,36 @@ function _mc4wp_admin_sidebar_support_notice()
|
|
24 |
/**
|
25 |
* @ignore
|
26 |
*/
|
27 |
-
function _mc4wp_admin_sidebar_other_plugins()
|
28 |
-
|
29 |
-
|
30 |
-
echo '<h4 class="mc4wp-title">' . __('Other plugins by ibericode', 'mailchimp-for-wp') . '</h4>';
|
31 |
|
32 |
-
|
33 |
|
34 |
// Koko Analytics
|
35 |
echo '<li style="margin: 12px 0;">';
|
36 |
-
echo sprintf('<strong><a href="%s">Koko Analytics</a></strong><br />', 'https://wordpress.org/plugins/koko-analytics/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=sidebar');
|
37 |
-
echo __('Privacy-friendly analytics plugin that does not use any external services.', 'mailchimp-for-wp');
|
38 |
echo '</li>';
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
}
|
55 |
|
56 |
-
add_action('mc4wp_admin_sidebar', '_mc4wp_admin_sidebar_other_plugins', 40);
|
57 |
-
add_action('mc4wp_admin_sidebar', '_mc4wp_admin_sidebar_support_notice', 50);
|
58 |
|
59 |
/**
|
60 |
* Runs when the sidebar is outputted on Mailchimp for WordPress settings pages.
|
@@ -63,4 +61,4 @@ add_action('mc4wp_admin_sidebar', '_mc4wp_admin_sidebar_support_notice', 50);
|
|
63 |
*
|
64 |
* @since 3.0
|
65 |
*/
|
66 |
-
do_action('mc4wp_admin_sidebar');
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* @ignore
|
7 |
*/
|
8 |
+
function _mc4wp_admin_sidebar_support_notice() {
|
9 |
+
?>
|
|
|
10 |
<div class="mc4wp-box">
|
11 |
+
<h4 class="mc4wp-title"><?php echo esc_html__( 'Looking for help?', 'mailchimp-for-wp' ); ?></h4>
|
12 |
+
<p><?php echo __( 'We have some resources available to help you in the right direction.', 'mailchimp-for-wp' ); ?></p>
|
13 |
<ul class="ul-square">
|
14 |
+
<li><a href="https://kb.mc4wp.com/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=sidebar"><?php echo esc_html__( 'Knowledge Base', 'mailchimp-for-wp' ); ?></a></li>
|
15 |
+
<li><a href="https://wordpress.org/plugins/mailchimp-for-wp/faq/"><?php echo esc_html__( 'Frequently Asked Questions', 'mailchimp-for-wp' ); ?></a></li>
|
16 |
</ul>
|
17 |
+
<p><?php echo sprintf( __( 'If your answer can not be found in the resources listed above, please use the <a href="%s">support forums on WordPress.org</a>.', 'mailchimp-for-wp' ), 'https://wordpress.org/support/plugin/mailchimp-for-wp' ); ?></p>
|
18 |
+
<p><?php echo sprintf( __( 'Found a bug? Please <a href="%s">open an issue on GitHub</a>.', 'mailchimp-for-wp' ), 'https://github.com/ibericode/mailchimp-for-wordpress/issues' ); ?></p>
|
19 |
</div>
|
20 |
<?php
|
21 |
}
|
23 |
/**
|
24 |
* @ignore
|
25 |
*/
|
26 |
+
function _mc4wp_admin_sidebar_other_plugins() {
|
27 |
+
echo '<div class="mc4wp-box">';
|
28 |
+
echo '<h4 class="mc4wp-title">' . __( 'Other plugins by ibericode', 'mailchimp-for-wp' ) . '</h4>';
|
|
|
29 |
|
30 |
+
echo '<ul style="margin-bottom: 0;">';
|
31 |
|
32 |
// Koko Analytics
|
33 |
echo '<li style="margin: 12px 0;">';
|
34 |
+
echo sprintf( '<strong><a href="%s">Koko Analytics</a></strong><br />', 'https://wordpress.org/plugins/koko-analytics/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=sidebar' );
|
35 |
+
echo __( 'Privacy-friendly analytics plugin that does not use any external services.', 'mailchimp-for-wp' );
|
36 |
echo '</li>';
|
37 |
|
38 |
+
// Boxzilla
|
39 |
+
echo '<li style="margin: 12px 0;">';
|
40 |
+
echo sprintf( '<strong><a href="%s">Boxzilla Pop-ups</a></strong><br />', 'https://wordpress.org/plugins/boxzilla/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=sidebar' );
|
41 |
+
echo __( 'Pop-ups or boxes that slide-in with a newsletter sign-up form. A sure-fire way to grow your email lists.', 'mailchimp-for-wp' );
|
42 |
+
echo '</li>';
|
43 |
|
44 |
+
// HTML Forms
|
45 |
+
echo '<li style="margin: 12px 0;">';
|
46 |
+
echo sprintf( '<strong><a href="%s">HTML Forms</a></strong><br />', 'https://wordpress.org/plugins/html-forms/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=sidebar' );
|
47 |
+
echo __( 'Super flexible forms using native HTML. Just like Mailchimp for WordPress forms but for other purposes, like a contact form.', 'mailchimp-for-wp' );
|
48 |
+
echo '</li>';
|
49 |
|
50 |
+
echo '</ul>';
|
51 |
+
echo '</div>';
|
52 |
}
|
53 |
|
54 |
+
add_action( 'mc4wp_admin_sidebar', '_mc4wp_admin_sidebar_other_plugins', 40 );
|
55 |
+
add_action( 'mc4wp_admin_sidebar', '_mc4wp_admin_sidebar_support_notice', 50 );
|
56 |
|
57 |
/**
|
58 |
* Runs when the sidebar is outputted on Mailchimp for WordPress settings pages.
|
61 |
*
|
62 |
* @since 3.0
|
63 |
*/
|
64 |
+
do_action( 'mc4wp_admin_sidebar' );
|
includes/views/parts/lists-overview.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
<h3><?php _e('Your Mailchimp Account', 'mailchimp-for-wp'); ?></h3>
|
2 |
-
<p><?php _e('The table below shows your Mailchimp lists and their details. If you just applied changes to your Mailchimp lists, please use the following button to renew the cached lists configuration.', 'mailchimp-for-wp'); ?></p>
|
3 |
|
4 |
|
5 |
<div id="mc4wp-list-fetcher">
|
@@ -7,51 +7,54 @@
|
|
7 |
<input type="hidden" name="_mc4wp_action" value="empty_lists_cache" />
|
8 |
|
9 |
<p>
|
10 |
-
<input type="submit" value="<?php _e('Renew Mailchimp lists', 'mailchimp-for-wp'); ?>" class="button" />
|
11 |
</p>
|
12 |
</form>
|
13 |
</div>
|
14 |
|
15 |
<div class="mc4wp-lists-overview">
|
16 |
-
<?php if (empty($lists)) {
|
17 |
-
?>
|
18 |
-
<p><?php _e('No lists were found in your Mailchimp account', 'mailchimp-for-wp'); ?>.</p>
|
19 |
<?php
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
echo '<table class="widefat striped" id="mc4wp-mailchimp-lists-overview">';
|
24 |
-
|
25 |
-
$headings = array(
|
26 |
-
__('List Name', 'mailchimp-for-wp'),
|
27 |
-
__('ID', 'mailchimp-for-wp'),
|
28 |
-
__('Subscribers', 'mailchimp-for-wp')
|
29 |
-
);
|
30 |
-
|
31 |
-
echo '<thead>';
|
32 |
-
echo '<tr>';
|
33 |
-
foreach ($headings as $heading) {
|
34 |
-
echo sprintf('<th>%s</th>', $heading);
|
35 |
-
}
|
36 |
-
echo '</tr>';
|
37 |
-
echo '</thead>';
|
38 |
-
|
39 |
-
foreach ($lists as $list) {
|
40 |
-
echo '<tr>';
|
41 |
-
echo sprintf('<td><a href="#" class="mc4wp-mailchimp-list" data-list-id="%s">%s</a><span class="row-actions alignright"></span></td>', esc_attr($list->id), esc_html($list->name));
|
42 |
-
echo sprintf('<td><code>%s</code></td>', esc_html($list->id));
|
43 |
-
echo sprintf('<td>%s</td>', esc_html($list->stats->member_count));
|
44 |
-
echo '</tr>';
|
45 |
-
|
46 |
-
echo sprintf('<tr class="list-details list-%s-details" style="display: none;">', $list->id);
|
47 |
-
echo '<td colspan="3" style="padding: 0 20px 40px;">';
|
48 |
-
|
49 |
-
echo sprintf('<p class="alignright" style="margin: 20px 0;"><a href="https://admin.mailchimp.com/lists/members/?id=%s" target="_blank"><span class="dashicons dashicons-edit"></span> ' . __('Edit this list in Mailchimp', 'mailchimp-for-wp') . '</a></p>', $list->web_id);
|
50 |
-
echo '<div><div>' . __('Loading... Please wait.', 'mailchimp-for-wp') . '</div></div>';
|
51 |
-
echo '</td>';
|
52 |
-
echo '</tr>'; ?>
|
53 |
<?php
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
</div>
|
1 |
+
<h3><?php _e( 'Your Mailchimp Account', 'mailchimp-for-wp' ); ?></h3>
|
2 |
+
<p><?php _e( 'The table below shows your Mailchimp lists and their details. If you just applied changes to your Mailchimp lists, please use the following button to renew the cached lists configuration.', 'mailchimp-for-wp' ); ?></p>
|
3 |
|
4 |
|
5 |
<div id="mc4wp-list-fetcher">
|
7 |
<input type="hidden" name="_mc4wp_action" value="empty_lists_cache" />
|
8 |
|
9 |
<p>
|
10 |
+
<input type="submit" value="<?php _e( 'Renew Mailchimp lists', 'mailchimp-for-wp' ); ?>" class="button" />
|
11 |
</p>
|
12 |
</form>
|
13 |
</div>
|
14 |
|
15 |
<div class="mc4wp-lists-overview">
|
|
|
|
|
|
|
16 |
<?php
|
17 |
+
if ( empty( $lists ) ) {
|
18 |
+
?>
|
19 |
+
<p><?php _e( 'No lists were found in your Mailchimp account', 'mailchimp-for-wp' ); ?>.</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
<?php
|
21 |
+
} else {
|
22 |
+
printf( '<p>' . __( 'A total of %d lists were found in your Mailchimp account.', 'mailchimp-for-wp' ) . '</p>', count( $lists ) );
|
23 |
+
|
24 |
+
echo '<table class="widefat striped" id="mc4wp-mailchimp-lists-overview">';
|
25 |
+
|
26 |
+
$headings = array(
|
27 |
+
__( 'List Name', 'mailchimp-for-wp' ),
|
28 |
+
__( 'ID', 'mailchimp-for-wp' ),
|
29 |
+
__( 'Subscribers', 'mailchimp-for-wp' ),
|
30 |
+
);
|
31 |
+
|
32 |
+
echo '<thead>';
|
33 |
+
echo '<tr>';
|
34 |
+
foreach ( $headings as $heading ) {
|
35 |
+
echo sprintf( '<th>%s</th>', $heading );
|
36 |
+
}
|
37 |
+
echo '</tr>';
|
38 |
+
echo '</thead>';
|
39 |
+
|
40 |
+
foreach ( $lists as $list ) {
|
41 |
+
echo '<tr>';
|
42 |
+
echo sprintf( '<td><a href="#" class="mc4wp-mailchimp-list" data-list-id="%s">%s</a><span class="row-actions alignright"></span></td>', esc_attr( $list->id ), esc_html( $list->name ) );
|
43 |
+
echo sprintf( '<td><code>%s</code></td>', esc_html( $list->id ) );
|
44 |
+
echo sprintf( '<td>%s</td>', esc_html( $list->stats->member_count ) );
|
45 |
+
echo '</tr>';
|
46 |
+
|
47 |
+
echo sprintf( '<tr class="list-details list-%s-details" style="display: none;">', $list->id );
|
48 |
+
echo '<td colspan="3" style="padding: 0 20px 40px;">';
|
49 |
+
|
50 |
+
echo sprintf( '<p class="alignright" style="margin: 20px 0;"><a href="https://admin.mailchimp.com/lists/members/?id=%s" target="_blank"><span class="dashicons dashicons-edit"></span> ' . __( 'Edit this list in Mailchimp', 'mailchimp-for-wp' ) . '</a></p>', $list->web_id );
|
51 |
+
echo '<div><div>' . __( 'Loading... Please wait.', 'mailchimp-for-wp' ) . '</div></div>';
|
52 |
+
echo '</td>';
|
53 |
+
echo '</tr>';
|
54 |
+
?>
|
55 |
+
<?php
|
56 |
+
} // end foreach $lists
|
57 |
+
echo '</table>';
|
58 |
+
} // end if empty
|
59 |
+
?>
|
60 |
</div>
|
integrations/affiliatewp/class-affiliatewp.php
CHANGED
@@ -1,89 +1,85 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_AffiliateWP_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_AffiliateWP_Integration extends MC4WP_User_Integration
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
public function is_installed()
|
86 |
-
{
|
87 |
-
return class_exists('Affiliate_WP');
|
88 |
-
}
|
89 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_AffiliateWP_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_AffiliateWP_Integration extends MC4WP_User_Integration {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $name = 'AffiliateWP';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $description = 'Subscribes people from your AffiliateWP registration form.';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var bool
|
25 |
+
*/
|
26 |
+
public $shown = false;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Add hooks
|
30 |
+
*/
|
31 |
+
public function add_hooks() {
|
32 |
+
if ( ! $this->options['implicit'] ) {
|
33 |
+
add_action( 'affwp_register_fields_before_tos', array( $this, 'maybe_output_checkbox' ), 20 );
|
34 |
+
}
|
35 |
+
|
36 |
+
add_action( 'affwp_register_user', array( $this, 'subscribe_from_registration' ), 90, 1 );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Output checkbox, once.
|
41 |
+
*/
|
42 |
+
public function maybe_output_checkbox() {
|
43 |
+
if ( ! $this->shown ) {
|
44 |
+
$this->output_checkbox();
|
45 |
+
$this->shown = true;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Subscribes from WP Registration Form
|
51 |
+
*
|
52 |
+
* @param int $affiliate_id
|
53 |
+
*
|
54 |
+
* @return bool|string
|
55 |
+
*/
|
56 |
+
public function subscribe_from_registration( $affiliate_id ) {
|
57 |
+
|
58 |
+
// was sign-up checkbox checked?
|
59 |
+
if ( ! $this->triggered() ) {
|
60 |
+
return false;
|
61 |
+
}
|
62 |
+
|
63 |
+
// gather emailadress from user who WordPress registered
|
64 |
+
$user_id = affwp_get_affiliate_user_id( $affiliate_id );
|
65 |
+
$user = get_userdata( $user_id );
|
66 |
+
|
67 |
+
// was a user found with the given ID?
|
68 |
+
if ( ! $user instanceof WP_User ) {
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
|
72 |
+
$data = $this->user_merge_vars( $user );
|
73 |
+
|
74 |
+
return $this->subscribe( $data, $user_id );
|
75 |
+
}
|
76 |
+
/* End registration form functions */
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @return bool
|
81 |
+
*/
|
82 |
+
public function is_installed() {
|
83 |
+
return class_exists( 'Affiliate_WP' );
|
84 |
+
}
|
|
|
|
|
|
|
|
|
85 |
}
|
integrations/bootstrap.php
CHANGED
@@ -7,13 +7,12 @@
|
|
7 |
* @param array $opts
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
function mc4wp_admin_before_integration_settings(MC4WP_Integration $integration, $opts)
|
11 |
-
|
12 |
-
$file = dirname(__FILE__) . sprintf('/%s/admin-before.php', $integration->slug);
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
}
|
18 |
|
19 |
/**
|
@@ -23,34 +22,33 @@ function mc4wp_admin_before_integration_settings(MC4WP_Integration $integration,
|
|
23 |
* @param array $opts
|
24 |
* @ignore
|
25 |
*/
|
26 |
-
function mc4wp_admin_after_integration_settings(MC4WP_Integration $integration, $opts)
|
27 |
-
|
28 |
-
$file = dirname(__FILE__) . sprintf('/%s/admin-after.php', $integration->slug);
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
}
|
34 |
|
35 |
-
add_action('mc4wp_admin_before_integration_settings', 'mc4wp_admin_before_integration_settings', 30, 2);
|
36 |
-
add_action('mc4wp_admin_after_integration_settings', 'mc4wp_admin_after_integration_settings', 30, 2);
|
37 |
|
38 |
// Register core integrations
|
39 |
-
mc4wp_register_integration('ninja-forms-2', '
|
40 |
-
mc4wp_register_integration('wp-comment-form', 'MC4WP_Comment_Form_Integration');
|
41 |
-
mc4wp_register_integration('wp-registration-form', 'MC4WP_Registration_Form_Integration');
|
42 |
-
mc4wp_register_integration('buddypress', 'MC4WP_BuddyPress_Integration');
|
43 |
-
mc4wp_register_integration('woocommerce', 'MC4WP_WooCommerce_Integration');
|
44 |
-
mc4wp_register_integration('easy-digital-downloads', 'MC4WP_Easy_Digital_Downloads_Integration');
|
45 |
-
mc4wp_register_integration('contact-form-7', 'MC4WP_Contact_Form_7_Integration', true);
|
46 |
-
mc4wp_register_integration('events-manager', 'MC4WP_Events_Manager_Integration');
|
47 |
-
mc4wp_register_integration('memberpress', 'MC4WP_MemberPress_Integration');
|
48 |
-
mc4wp_register_integration('affiliatewp', 'MC4WP_AffiliateWP_Integration');
|
49 |
-
mc4wp_register_integration('give', 'MC4WP_Give_Integration');
|
50 |
-
|
51 |
-
|
52 |
-
mc4wp_register_integration('custom', 'MC4WP_Custom_Integration', true);
|
53 |
-
$dir = dirname(__FILE__);
|
54 |
require $dir . '/ninja-forms/bootstrap.php';
|
55 |
require $dir . '/wpforms/bootstrap.php';
|
56 |
require $dir . '/gravity-forms/bootstrap.php';
|
7 |
* @param array $opts
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
function mc4wp_admin_before_integration_settings( MC4WP_Integration $integration, $opts ) {
|
11 |
+
$file = dirname( __FILE__ ) . sprintf( '/%s/admin-before.php', $integration->slug );
|
|
|
12 |
|
13 |
+
if ( file_exists( $file ) ) {
|
14 |
+
include $file;
|
15 |
+
}
|
16 |
}
|
17 |
|
18 |
/**
|
22 |
* @param array $opts
|
23 |
* @ignore
|
24 |
*/
|
25 |
+
function mc4wp_admin_after_integration_settings( MC4WP_Integration $integration, $opts ) {
|
26 |
+
$file = dirname( __FILE__ ) . sprintf( '/%s/admin-after.php', $integration->slug );
|
|
|
27 |
|
28 |
+
if ( file_exists( $file ) ) {
|
29 |
+
include $file;
|
30 |
+
}
|
31 |
}
|
32 |
|
33 |
+
add_action( 'mc4wp_admin_before_integration_settings', 'mc4wp_admin_before_integration_settings', 30, 2 );
|
34 |
+
add_action( 'mc4wp_admin_after_integration_settings', 'mc4wp_admin_after_integration_settings', 30, 2 );
|
35 |
|
36 |
// Register core integrations
|
37 |
+
mc4wp_register_integration( 'ninja-forms-2', 'MC4WP_Ninja_Forms_V2_Integration', true );
|
38 |
+
mc4wp_register_integration( 'wp-comment-form', 'MC4WP_Comment_Form_Integration' );
|
39 |
+
mc4wp_register_integration( 'wp-registration-form', 'MC4WP_Registration_Form_Integration' );
|
40 |
+
mc4wp_register_integration( 'buddypress', 'MC4WP_BuddyPress_Integration' );
|
41 |
+
mc4wp_register_integration( 'woocommerce', 'MC4WP_WooCommerce_Integration' );
|
42 |
+
mc4wp_register_integration( 'easy-digital-downloads', 'MC4WP_Easy_Digital_Downloads_Integration' );
|
43 |
+
mc4wp_register_integration( 'contact-form-7', 'MC4WP_Contact_Form_7_Integration', true );
|
44 |
+
mc4wp_register_integration( 'events-manager', 'MC4WP_Events_Manager_Integration' );
|
45 |
+
mc4wp_register_integration( 'memberpress', 'MC4WP_MemberPress_Integration' );
|
46 |
+
mc4wp_register_integration( 'affiliatewp', 'MC4WP_AffiliateWP_Integration' );
|
47 |
+
mc4wp_register_integration( 'give', 'MC4WP_Give_Integration' );
|
48 |
+
|
49 |
+
|
50 |
+
mc4wp_register_integration( 'custom', 'MC4WP_Custom_Integration', true );
|
51 |
+
$dir = dirname( __FILE__ );
|
52 |
require $dir . '/ninja-forms/bootstrap.php';
|
53 |
require $dir . '/wpforms/bootstrap.php';
|
54 |
require $dir . '/gravity-forms/bootstrap.php';
|
integrations/buddypress/class-buddypress.php
CHANGED
@@ -1,184 +1,178 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_BuddyPress_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_BuddyPress_Integration extends MC4WP_User_Integration
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
* @return bool
|
179 |
-
*/
|
180 |
-
public function is_installed()
|
181 |
-
{
|
182 |
-
return class_exists('BuddyPress');
|
183 |
-
}
|
184 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_BuddyPress_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_BuddyPress_Integration extends MC4WP_User_Integration {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $name = 'BuddyPress';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $description = 'Subscribes users from BuddyPress registration forms.';
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Add hooks
|
26 |
+
*/
|
27 |
+
public function add_hooks() {
|
28 |
+
if ( ! $this->options['implicit'] ) {
|
29 |
+
add_action( 'bp_before_registration_submit_buttons', array( $this, 'output_checkbox' ), 20 );
|
30 |
+
}
|
31 |
+
|
32 |
+
if ( is_multisite() ) {
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Multisite signups are a two-stage process - the data is first added to
|
36 |
+
* the 'signups' table and then converted into an actual user during the
|
37 |
+
* activation process.
|
38 |
+
*
|
39 |
+
* To avoid all signups being subscribed to the Mailchimp list until they
|
40 |
+
* have responded to the activation email, a value is stored in the signup
|
41 |
+
* usermeta data which is retrieved on activation and acted upon.
|
42 |
+
*/
|
43 |
+
add_filter( 'bp_signup_usermeta', array( $this, 'store_usermeta' ), 10, 1 );
|
44 |
+
add_action( 'bp_core_activated_user', array( $this, 'subscribe_from_usermeta' ), 10, 3 );
|
45 |
+
} else {
|
46 |
+
add_action( 'bp_core_signup_user', array( $this, 'subscribe_from_form' ), 10, 4 );
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* There is one further issue to consider, which is that many BuddyPress
|
51 |
+
* installs have a user moderation plugin (e.g. BP Registration Options)
|
52 |
+
* installed. This is because email activation on itself is sometimes not enough to ensure
|
53 |
+
* that user signups are not spammers. There should therefore be a way for
|
54 |
+
* plugins to delay the Mailchimp signup process.
|
55 |
+
*
|
56 |
+
* Plugins can hook into the 'mc4wp_integration_buddypress_should_subscribe' filter to prevent
|
57 |
+
* subscriptions from taking place:
|
58 |
+
*
|
59 |
+
* add_filter( 'mc4wp_integration_buddypress_should_subscribe', '__return_false' );
|
60 |
+
*
|
61 |
+
* The plugin would then then call:
|
62 |
+
*
|
63 |
+
* do_action( 'mc4wp_integration_buddypress_subscribe_user', $user_id );
|
64 |
+
*
|
65 |
+
* to perform the subscription at a later point.
|
66 |
+
*/
|
67 |
+
add_action( 'mc4wp_integration_buddypress_subscribe_user', array( $this, 'subscribe_buddypress_user' ), 10, 1 );
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Subscribes from BuddyPress Registration Form.
|
72 |
+
*
|
73 |
+
* @param int $user_id
|
74 |
+
* @param string $user_login
|
75 |
+
* @param string $user_password
|
76 |
+
* @param string $user_email
|
77 |
+
* @return bool
|
78 |
+
*/
|
79 |
+
public function subscribe_from_form( $user_id, $user_login, $user_password, $user_email ) {
|
80 |
+
if ( ! $this->triggered() ) {
|
81 |
+
return false;
|
82 |
+
}
|
83 |
+
|
84 |
+
$subscribe = true;
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Allow other plugins to prevent the Mailchimp sign-up.
|
88 |
+
*
|
89 |
+
* @param bool $subscribe False does not subscribe the user.
|
90 |
+
* @param int $user_id The user ID to subscribe
|
91 |
+
*/
|
92 |
+
$subscribe = apply_filters( 'mc4wp_integration_buddypress_should_subscribe', $subscribe, $user_id );
|
93 |
+
|
94 |
+
if ( ! $subscribe ) {
|
95 |
+
return false;
|
96 |
+
}
|
97 |
+
|
98 |
+
return $this->subscribe_buddypress_user( $user_id );
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Stores subscription data from BuddyPress Registration Form.
|
103 |
+
*
|
104 |
+
* @param array $usermeta The existing usermeta
|
105 |
+
* @return array $usermeta The modified usermeta
|
106 |
+
*/
|
107 |
+
public function store_usermeta( $usermeta ) {
|
108 |
+
|
109 |
+
// only add meta if triggered (checked)
|
110 |
+
if ( $this->triggered() ) {
|
111 |
+
$usermeta['mc4wp_subscribe'] = '1';
|
112 |
+
}
|
113 |
+
|
114 |
+
return $usermeta;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Subscribes from BuddyPress Activation.
|
119 |
+
*
|
120 |
+
* @param int $user_id The activated user ID
|
121 |
+
* @param string $key the activation key (not used)
|
122 |
+
* @param array $userdata An array containing the activated user data
|
123 |
+
* @return bool
|
124 |
+
*/
|
125 |
+
public function subscribe_from_usermeta( $user_id, $key, $userdata ) {
|
126 |
+
|
127 |
+
// sanity check
|
128 |
+
if ( empty( $user_id ) ) {
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
|
132 |
+
// bail if our usermeta key is not switched on
|
133 |
+
$meta = ( isset( $userdata['meta'] ) ) ? $userdata['meta'] : array();
|
134 |
+
if ( empty( $meta['mc4wp_subscribe'] ) ) {
|
135 |
+
return false;
|
136 |
+
}
|
137 |
+
|
138 |
+
$subscribe = true;
|
139 |
+
|
140 |
+
/**
|
141 |
+
* @ignore Documented elsewhere, see MC4WP_BuddyPress_Integration::subscribe_from_form.
|
142 |
+
*/
|
143 |
+
$subscribe = apply_filters( 'mc4wp_integration_buddypress_should_subscribe', $subscribe, $user_id );
|
144 |
+
if ( ! $subscribe ) {
|
145 |
+
return false;
|
146 |
+
}
|
147 |
+
|
148 |
+
return $this->subscribe_buddypress_user( $user_id );
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Subscribes a user to Mailchimp list(s).
|
153 |
+
*
|
154 |
+
* @param int $user_id The user ID to subscribe
|
155 |
+
* @return bool
|
156 |
+
*/
|
157 |
+
public function subscribe_buddypress_user( $user_id ) {
|
158 |
+
$user = get_userdata( $user_id );
|
159 |
+
|
160 |
+
// was a user found with the given ID?
|
161 |
+
if ( ! $user instanceof WP_User ) {
|
162 |
+
return false;
|
163 |
+
}
|
164 |
+
|
165 |
+
// gather email address and name from user
|
166 |
+
$data = $this->user_merge_vars( $user );
|
167 |
+
|
168 |
+
return $this->subscribe( $data, $user_id );
|
169 |
+
}
|
170 |
+
/* End BuddyPress functions */
|
171 |
+
|
172 |
+
/**
|
173 |
+
* @return bool
|
174 |
+
*/
|
175 |
+
public function is_installed() {
|
176 |
+
return class_exists( 'BuddyPress' );
|
177 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
}
|
integrations/contact-form-7/admin-before.php
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
<p>
|
2 |
-
<?php printf(__('To integrate with Contact Form 7, configure the settings below and then add %s to your CF7 form mark-up.', 'mailchimp-for-wp'), '<input type="text" onfocus="this.select()" readonly value="'. esc_attr('[mc4wp_checkbox]') .'">'); ?>
|
3 |
-
</p>
|
1 |
<p>
|
2 |
+
<?php printf( __( 'To integrate with Contact Form 7, configure the settings below and then add %s to your CF7 form mark-up.', 'mailchimp-for-wp' ), '<input type="text" onfocus="this.select()" readonly value="' . esc_attr( '[mc4wp_checkbox]' ) . '">' ); ?>
|
3 |
+
</p>
|
integrations/contact-form-7/class-contact-form-7.php
CHANGED
@@ -1,179 +1,169 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Contact_Form_7_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_Contact_Form_7_Integration extends MC4WP_Integration
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
if (! function_exists('wpcf7_contact_form')) {
|
170 |
-
return '';
|
171 |
-
}
|
172 |
-
|
173 |
-
$form = wpcf7_contact_form($object_id);
|
174 |
-
if (! is_object($form)) {
|
175 |
-
return '';
|
176 |
-
}
|
177 |
-
return sprintf('<a href="%s">%s</a>', admin_url('admin.php?page=wpcf7&post=' . $object_id), $form->title());
|
178 |
-
}
|
179 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Contact_Form_7_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_Contact_Form_7_Integration extends MC4WP_Integration {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $name = 'Contact Form 7';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $description = 'Subscribes people from Contact Form 7 forms.';
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Add hooks
|
26 |
+
*/
|
27 |
+
public function add_hooks() {
|
28 |
+
add_action( 'wpcf7_init', array( $this, 'init' ) );
|
29 |
+
add_action( 'wpcf7_mail_sent', array( $this, 'process' ), 1 );
|
30 |
+
add_action( 'wpcf7_posted_data', array( $this, 'alter_cf7_data' ) );
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Registers the CF7 shortcode
|
35 |
+
*
|
36 |
+
* @return boolean
|
37 |
+
*/
|
38 |
+
public function init() {
|
39 |
+
if ( function_exists( 'wpcf7_add_form_tag' ) ) {
|
40 |
+
wpcf7_add_form_tag( 'mc4wp_checkbox', array( $this, 'shortcode' ) );
|
41 |
+
} else {
|
42 |
+
wpcf7_add_shortcode( 'mc4wp_checkbox', array( $this, 'shortcode' ) );
|
43 |
+
}
|
44 |
+
|
45 |
+
return true;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @{inheritdoc}
|
50 |
+
*
|
51 |
+
* Contact Form 7 listens to the following triggers.
|
52 |
+
*
|
53 |
+
* - _mc4wp_subscribe_contact-form-7
|
54 |
+
* - mc4wp-subscribe
|
55 |
+
*
|
56 |
+
* @return bool
|
57 |
+
*/
|
58 |
+
public function checkbox_was_checked() {
|
59 |
+
$data = $this->get_data();
|
60 |
+
|
61 |
+
return ( isset( $data[ $this->checkbox_name ] ) && (int) $data[ $this->checkbox_name ] === 1 )
|
62 |
+
|| ( isset( $data['mc4wp-subscribe'] ) && (int) $data['mc4wp-subscribe'] === 1 );
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Alter Contact Form 7 data.
|
67 |
+
*
|
68 |
+
* Adds mc4wp_checkbox to post data so users can use `mc4wp_checkbox` in their email templates
|
69 |
+
*
|
70 |
+
* @param array $data
|
71 |
+
* @return array
|
72 |
+
*/
|
73 |
+
public function alter_cf7_data( $data = array() ) {
|
74 |
+
$data['mc4wp_checkbox'] = $this->checkbox_was_checked() ? __( 'Yes', 'mailchimp-for-wp' ) : __( 'No', 'mailchimp-for-wp' );
|
75 |
+
return $data;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Subscribe from Contact Form 7 Forms
|
80 |
+
*
|
81 |
+
* @todo improve smart guessing based on selected Mailchimp lists
|
82 |
+
*
|
83 |
+
* @param WPCF7_ContactForm $cf7_form
|
84 |
+
* @return bool
|
85 |
+
*/
|
86 |
+
public function process( $cf7_form ) {
|
87 |
+
|
88 |
+
// was sign-up checkbox checked?
|
89 |
+
if ( ! $this->checkbox_was_checked() ) {
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
|
93 |
+
$parser = new MC4WP_Field_Guesser( $this->get_data() );
|
94 |
+
$data = $parser->combine( array( 'guessed', 'namespaced' ) );
|
95 |
+
|
96 |
+
// do nothing if no email was found
|
97 |
+
if ( empty( $data['EMAIL'] ) ) {
|
98 |
+
$this->get_log()->warning( sprintf( '%s > Unable to find EMAIL field.', $this->name ) );
|
99 |
+
return false;
|
100 |
+
}
|
101 |
+
|
102 |
+
return $this->subscribe( $data, $cf7_form->id() );
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Return the shortcode output
|
107 |
+
*
|
108 |
+
* @return string
|
109 |
+
*/
|
110 |
+
public function shortcode( $args = array() ) {
|
111 |
+
if ( ! empty( $args['labels'][0] ) ) {
|
112 |
+
$this->options['label'] = $args['labels'][0];
|
113 |
+
}
|
114 |
+
|
115 |
+
if ( isset( $args['options'] ) ) {
|
116 |
+
|
117 |
+
// check for default:0 or default:1 to set the checked attribute
|
118 |
+
if ( in_array( 'default:1', $args['options'], true ) ) {
|
119 |
+
$this->options['precheck'] = true;
|
120 |
+
} elseif ( in_array( 'default:0', $args['options'], true ) ) {
|
121 |
+
$this->options['precheck'] = false;
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
// disable paragraph wrap because CF7 defaults to `wpautop`
|
126 |
+
$this->options['wrap_p'] = 0;
|
127 |
+
|
128 |
+
return $this->get_checkbox_html();
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @return bool
|
133 |
+
*/
|
134 |
+
public function is_installed() {
|
135 |
+
return function_exists( 'wpcf7_contact_form' );
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* @since 3.0
|
140 |
+
* @return array
|
141 |
+
*/
|
142 |
+
public function get_ui_elements() {
|
143 |
+
return array_diff( parent::get_ui_elements(), array( 'enabled', 'implicit' ) );
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @param int $object_id
|
148 |
+
* @since 3.0
|
149 |
+
* @return string
|
150 |
+
*/
|
151 |
+
public function get_object_link( $object_id ) {
|
152 |
+
|
153 |
+
// for backwards compatibility, not all CF7 sign-ups have an object id
|
154 |
+
if ( empty( $object_id ) ) {
|
155 |
+
return '';
|
156 |
+
}
|
157 |
+
|
158 |
+
// Return empty string if CF7 is no longer activated.
|
159 |
+
if ( ! function_exists( 'wpcf7_contact_form' ) ) {
|
160 |
+
return '';
|
161 |
+
}
|
162 |
+
|
163 |
+
$form = wpcf7_contact_form( $object_id );
|
164 |
+
if ( ! is_object( $form ) ) {
|
165 |
+
return '';
|
166 |
+
}
|
167 |
+
return sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=wpcf7&post=' . $object_id ), $form->title() );
|
168 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
}
|
integrations/custom/admin-before.php
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
<p>
|
2 |
-
<?php _e('To get a custom integration to work, include the following HTML in the form you are trying to integrate with.', 'mailchimp-for-wp'); ?>
|
3 |
</p>
|
4 |
|
5 |
<?php ob_start(); ?>
|
6 |
<p>
|
7 |
<label>
|
8 |
<input type="checkbox" name="mc4wp-subscribe" value="1" />
|
9 |
-
<?php _e('Subscribe to our newsletter.', 'mailchimp-for-wp'); ?>
|
10 |
</label>
|
11 |
</p>
|
12 |
|
13 |
<?php $html = ob_get_clean(); ?>
|
14 |
|
15 |
-
<textarea class="widefat code-sample" rows="<?php echo substr_count($html, PHP_EOL); ?>" readonly onfocus="this.select()"><?php echo esc_textarea($html); ?></textarea>
|
1 |
<p>
|
2 |
+
<?php _e( 'To get a custom integration to work, include the following HTML in the form you are trying to integrate with.', 'mailchimp-for-wp' ); ?>
|
3 |
</p>
|
4 |
|
5 |
<?php ob_start(); ?>
|
6 |
<p>
|
7 |
<label>
|
8 |
<input type="checkbox" name="mc4wp-subscribe" value="1" />
|
9 |
+
<?php _e( 'Subscribe to our newsletter.', 'mailchimp-for-wp' ); ?>
|
10 |
</label>
|
11 |
</p>
|
12 |
|
13 |
<?php $html = ob_get_clean(); ?>
|
14 |
|
15 |
+
<textarea class="widefat code-sample" rows="<?php echo substr_count( $html, PHP_EOL ); ?>" readonly onfocus="this.select()"><?php echo esc_textarea( $html ); ?></textarea>
|
integrations/custom/class-custom.php
CHANGED
@@ -1,116 +1,110 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Custom_Integration
|
7 |
* @ignore
|
8 |
*/
|
9 |
-
class MC4WP_Custom_Integration extends MC4WP_Integration
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
* @return array
|
111 |
-
*/
|
112 |
-
public function get_ui_elements()
|
113 |
-
{
|
114 |
-
return array( 'lists', 'double_optin', 'update_existing', 'replace_interests' );
|
115 |
-
}
|
116 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Custom_Integration
|
7 |
* @ignore
|
8 |
*/
|
9 |
+
class MC4WP_Custom_Integration extends MC4WP_Integration {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var string
|
14 |
+
*/
|
15 |
+
protected $checkbox_name = 'mc4wp-subscribe';
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
public $name = 'Custom';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
public $description = 'Integrate with custom third-party forms.';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Add hooks
|
29 |
+
*/
|
30 |
+
public function add_hooks() {
|
31 |
+
add_action( 'init', array( $this, 'listen' ), 50 );
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Was the integration checkbox checked?
|
36 |
+
*
|
37 |
+
* @return bool
|
38 |
+
*/
|
39 |
+
public function checkbox_was_checked() {
|
40 |
+
$data = $this->get_data();
|
41 |
+
$value = isset( $data[ $this->checkbox_name ] ) ? $data[ $this->checkbox_name ] : '';
|
42 |
+
$truthy_values = array( 1, '1', 'yes', true, 'true', 'y' );
|
43 |
+
return in_array( $value, $truthy_values, true );
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Maybe fire a general subscription request
|
48 |
+
*/
|
49 |
+
public function listen() {
|
50 |
+
if ( ! $this->checkbox_was_checked() ) {
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
|
54 |
+
$data = $this->get_data();
|
55 |
+
|
56 |
+
// don't run for CF7 or Events Manager requests
|
57 |
+
// (since they use the same "mc4wp-subscribe" trigger)
|
58 |
+
$disable_triggers = array(
|
59 |
+
'_wpcf7' => '',
|
60 |
+
'action' => 'booking_add',
|
61 |
+
);
|
62 |
+
|
63 |
+
foreach ( $disable_triggers as $trigger => $trigger_value ) {
|
64 |
+
if ( isset( $data[ $trigger ] ) ) {
|
65 |
+
$value = $data[ $trigger ];
|
66 |
+
|
67 |
+
// do nothing if trigger value is optional
|
68 |
+
// or if trigger value matches
|
69 |
+
if ( empty( $trigger_value ) || $value === $trigger_value ) {
|
70 |
+
return false;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
// run!
|
76 |
+
return $this->process();
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Process custom form
|
81 |
+
*
|
82 |
+
* @return bool|string
|
83 |
+
*/
|
84 |
+
public function process() {
|
85 |
+
$parser = new MC4WP_Field_Guesser( $this->get_data() );
|
86 |
+
$data = $parser->combine( array( 'guessed', 'namespaced' ) );
|
87 |
+
|
88 |
+
// do nothing if no email was found
|
89 |
+
if ( empty( $data['EMAIL'] ) ) {
|
90 |
+
$this->get_log()->warning( sprintf( '%s > Unable to find EMAIL field.', $this->name ) );
|
91 |
+
return false;
|
92 |
+
}
|
93 |
+
|
94 |
+
return $this->subscribe( $data );
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @return bool
|
99 |
+
*/
|
100 |
+
public function is_installed() {
|
101 |
+
return true;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @return array
|
106 |
+
*/
|
107 |
+
public function get_ui_elements() {
|
108 |
+
return array( 'lists', 'double_optin', 'update_existing', 'replace_interests' );
|
109 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
integrations/easy-digital-downloads/class-easy-digital-downloads.php
CHANGED
@@ -1,121 +1,116 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Easy_Digital_Downloads_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_Easy_Digital_Downloads_Integration extends MC4WP_Integration
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
*/
|
117 |
-
public function is_installed()
|
118 |
-
{
|
119 |
-
return class_exists('Easy_Digital_Downloads');
|
120 |
-
}
|
121 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Easy_Digital_Downloads_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_Easy_Digital_Downloads_Integration extends MC4WP_Integration {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $name = 'Easy Digital Downloads';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $description = 'Subscribes your Easy Digital Downloads customers.';
|
22 |
+
|
23 |
+
/**
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
public function add_hooks() {
|
27 |
+
if ( ! $this->options['implicit'] ) {
|
28 |
+
|
29 |
+
// TODO: Allow more positions
|
30 |
+
add_action( 'edd_purchase_form_user_info_fields', array( $this, 'output_checkbox' ), 1 );
|
31 |
+
add_action( 'edd_payment_meta', array( $this, 'save_checkbox_value' ) );
|
32 |
+
}
|
33 |
+
|
34 |
+
add_action( 'edd_complete_purchase', array( $this, 'subscribe_from_edd' ), 50 );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param array $meta
|
39 |
+
*
|
40 |
+
* @return array
|
41 |
+
*/
|
42 |
+
public function save_checkbox_value( $meta ) {
|
43 |
+
|
44 |
+
// don't save anything if the checkbox was not checked
|
45 |
+
if ( ! $this->checkbox_was_checked() ) {
|
46 |
+
return $meta;
|
47 |
+
}
|
48 |
+
|
49 |
+
$meta['_mc4wp_optin'] = 1;
|
50 |
+
return $meta;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* {@inheritdoc}
|
55 |
+
*
|
56 |
+
* @param $object_id
|
57 |
+
*
|
58 |
+
* @return bool
|
59 |
+
*/
|
60 |
+
public function triggered( $object_id = null ) {
|
61 |
+
if ( $this->options['implicit'] ) {
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
|
65 |
+
if ( ! $object_id ) {
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
|
69 |
+
$meta = edd_get_payment_meta( $object_id );
|
70 |
+
if ( is_array( $meta ) && isset( $meta['_mc4wp_optin'] ) && $meta['_mc4wp_optin'] ) {
|
71 |
+
return true;
|
72 |
+
}
|
73 |
+
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @param int $payment_id The ID of the payment
|
79 |
+
*
|
80 |
+
* @return bool|string
|
81 |
+
*/
|
82 |
+
public function subscribe_from_edd( $payment_id ) {
|
83 |
+
if ( ! $this->triggered( $payment_id ) ) {
|
84 |
+
return false;
|
85 |
+
}
|
86 |
+
|
87 |
+
$email = (string) edd_get_payment_user_email( $payment_id );
|
88 |
+
$data = array(
|
89 |
+
'EMAIL' => $email,
|
90 |
+
);
|
91 |
+
|
92 |
+
// add first and last name to merge vars, if given
|
93 |
+
$user_info = (array) edd_get_payment_meta_user_info( $payment_id );
|
94 |
+
|
95 |
+
if ( ! empty( $user_info['first_name'] ) && ! empty( $user_info['last_name'] ) ) {
|
96 |
+
$data['NAME'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
|
97 |
+
}
|
98 |
+
|
99 |
+
if ( ! empty( $user_info['first_name'] ) ) {
|
100 |
+
$data['FNAME'] = $user_info['first_name'];
|
101 |
+
}
|
102 |
+
|
103 |
+
if ( ! empty( $user_info['last_name'] ) ) {
|
104 |
+
$data['LNAME'] = $user_info['last_name'];
|
105 |
+
}
|
106 |
+
|
107 |
+
return $this->subscribe( $data, $payment_id );
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* @return bool
|
112 |
+
*/
|
113 |
+
public function is_installed() {
|
114 |
+
return class_exists( 'Easy_Digital_Downloads' );
|
115 |
+
}
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
integrations/events-manager/class-events-manager.php
CHANGED
@@ -1,81 +1,78 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Events_Manager_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_Events_Manager_Integration extends MC4WP_Integration
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
{
|
79 |
-
return defined('EM_VERSION');
|
80 |
-
}
|
81 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Events_Manager_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_Events_Manager_Integration extends MC4WP_Integration {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $name = 'Events Manager';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $description = 'Subscribes people from Events Manager booking forms.';
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Add hooks
|
26 |
+
*/
|
27 |
+
public function add_hooks() {
|
28 |
+
if ( ! $this->options['implicit'] ) {
|
29 |
+
add_action( 'em_booking_form_footer', array( $this, 'output_checkbox' ) );
|
30 |
+
}
|
31 |
+
|
32 |
+
add_action( 'em_bookings_added', array( $this, 'subscribe_from_events_manager' ), 5 );
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Subscribe from Events Manager booking forms.
|
39 |
+
*
|
40 |
+
* @param EM_Booking $args
|
41 |
+
* @return bool
|
42 |
+
*/
|
43 |
+
public function subscribe_from_events_manager( $args ) {
|
44 |
+
|
45 |
+
// Is this integration triggered? (checkbox checked or implicit)
|
46 |
+
if ( ! $this->triggered() ) {
|
47 |
+
return false;
|
48 |
+
}
|
49 |
+
|
50 |
+
$em_data = $this->get_data();
|
51 |
+
|
52 |
+
// logged-in users do not have these form fields, so grab from user object instead
|
53 |
+
if ( empty( $em_data['user_email'] ) && is_user_logged_in() ) {
|
54 |
+
$user = wp_get_current_user();
|
55 |
+
$em_data['user_email'] = $user->user_email;
|
56 |
+
$em_data['user_name'] = sprintf( '%s %s', $user->first_name, $user->last_name );
|
57 |
+
}
|
58 |
+
|
59 |
+
if ( empty( $em_data['user_email'] ) ) {
|
60 |
+
return false;
|
61 |
+
}
|
62 |
+
|
63 |
+
$data = array(
|
64 |
+
'EMAIL' => $em_data['user_email'],
|
65 |
+
'NAME' => $em_data['user_name'],
|
66 |
+
);
|
67 |
+
|
68 |
+
// subscribe using email and name
|
69 |
+
return $this->subscribe( $data, $args->booking_id );
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @return bool
|
74 |
+
*/
|
75 |
+
public function is_installed() {
|
76 |
+
return defined( 'EM_VERSION' );
|
77 |
+
}
|
|
|
|
|
|
|
78 |
}
|
integrations/give/class-give.php
CHANGED
@@ -1,49 +1,46 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* @ignore
|
7 |
*/
|
8 |
-
class MC4WP_Give_Integration extends MC4WP_Integration
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
{
|
47 |
-
return defined('GIVE_VERSION');
|
48 |
-
}
|
49 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* @ignore
|
7 |
*/
|
8 |
+
class MC4WP_Give_Integration extends MC4WP_Integration {
|
9 |
+
|
10 |
+
public $name = 'Give';
|
11 |
+
public $description = 'Subscribes people from your Give donation forms.';
|
12 |
+
public $shown = false;
|
13 |
+
|
14 |
+
public function add_hooks() {
|
15 |
+
if ( ! $this->options['implicit'] ) {
|
16 |
+
add_action( 'give_donation_form_top', array( $this, 'output_checkbox' ), 50 );
|
17 |
+
}
|
18 |
+
|
19 |
+
add_action( 'give_checkout_before_gateway', array( $this, 'subscribe_from_give' ), 90, 2 );
|
20 |
+
}
|
21 |
+
|
22 |
+
public function subscribe_from_give( $posted, $user ) {
|
23 |
+
// was sign-up checkbox checked?
|
24 |
+
if ( true !== $this->triggered() ) {
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
|
28 |
+
$merge_fields = array(
|
29 |
+
'EMAIL' => $user['email'],
|
30 |
+
);
|
31 |
+
|
32 |
+
if ( ! empty( $user['first_name'] ) ) {
|
33 |
+
$merge_fields['FNAME'] = $user['first_name'];
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( ! empty( $user['last_name'] ) ) {
|
37 |
+
$merge_fields['LNAME'] = $user['last_name'];
|
38 |
+
}
|
39 |
+
|
40 |
+
return $this->subscribe( $merge_fields );
|
41 |
+
}
|
42 |
+
|
43 |
+
public function is_installed() {
|
44 |
+
return defined( 'GIVE_VERSION' );
|
45 |
+
}
|
|
|
|
|
|
|
46 |
}
|
integrations/gravity-forms/admin-before.php
CHANGED
@@ -1,3 +1,6 @@
|
|
1 |
<p>
|
2 |
-
|
3 |
-
|
|
|
|
|
|
1 |
<p>
|
2 |
+
<?php
|
3 |
+
/* translators: %s links to the Gravity Forms overview page */
|
4 |
+
echo sprintf( __( 'To integrate with Gravity Forms, add the "Mailchimp for WordPress" field to <a href="%s">one of your Gravity Forms forms</a>.', 'mailchimp-for-wp' ), admin_url( 'admin.php?page=gf_edit_forms' ) );
|
5 |
+
?>
|
6 |
+
</p>
|
integrations/gravity-forms/bootstrap.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
-
mc4wp_register_integration('gravity-forms', 'MC4WP_Gravity_Forms_Integration', true);
|
6 |
|
7 |
-
if (class_exists('GF_Fields')) {
|
8 |
-
|
9 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
+
mc4wp_register_integration( 'gravity-forms', 'MC4WP_Gravity_Forms_Integration', true );
|
6 |
|
7 |
+
if ( class_exists( 'GF_Fields' ) ) {
|
8 |
+
GF_Fields::register( new MC4WP_Gravity_Forms_Field() );
|
9 |
}
|
integrations/gravity-forms/class-field.php
CHANGED
@@ -1,129 +1,129 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class MC4WP_Gravity_Forms_Field extends GF_Field
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
}
|
112 |
-
|
113 |
-
$tabindex = $this->get_tabindex();
|
114 |
-
$choice_value = $choice['value'];
|
115 |
-
$choice_value = esc_attr($choice_value);
|
116 |
-
$choice_markup = "<li class='gchoice_{$id}'>
|
117 |
<input name='input_{$input_id}' type='checkbox' value='{$choice_value}' {$checked} id='choice_{$id}' {$tabindex} {$disabled_text} />
|
118 |
<label for='choice_{$id}' id='label_{$id}'>{$choice['text']}</label>
|
119 |
</li>";
|
120 |
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class MC4WP_Gravity_Forms_Field extends GF_Field {
|
4 |
+
|
5 |
+
public $type = 'mailchimp';
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Returns the field markup; including field label, description, validation, and the form editor admin buttons.
|
9 |
+
*
|
10 |
+
* The {FIELD} placeholder will be replaced in GFFormDisplay::get_field_content with the markup returned by GF_Field::get_field_input().
|
11 |
+
*
|
12 |
+
* @param string|array $value The field value. From default/dynamic population, $_POST, or a resumed incomplete submission.
|
13 |
+
* @param bool $force_frontend_label Should the frontend label be displayed in the admin even if an admin label is configured.
|
14 |
+
* @param array $form The Form Object currently being processed.
|
15 |
+
*
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
public function get_field_content( $value, $force_frontend_label, $form ) {
|
19 |
+
$validation_message = ( $this->failed_validation && ! empty( $this->validation_message ) ) ? sprintf( "<div class='gfield_description validation_message'>%s</div>", $this->validation_message ) : '';
|
20 |
+
$is_form_editor = $this->is_form_editor();
|
21 |
+
$is_entry_detail = $this->is_entry_detail();
|
22 |
+
$is_admin = $is_form_editor || $is_entry_detail;
|
23 |
+
|
24 |
+
$admin_buttons = $this->get_admin_buttons();
|
25 |
+
|
26 |
+
$description = $this->get_description( $this->description, 'gfield_description' );
|
27 |
+
if ( $this->is_description_above( $form ) ) {
|
28 |
+
$clear = $is_admin ? "<div class='gf_clear'></div>" : '';
|
29 |
+
$field_content = sprintf( "%s%s{FIELD}%s$clear", $admin_buttons, $description, $validation_message );
|
30 |
+
} else {
|
31 |
+
$field_content = sprintf( '%s{FIELD}%s%s', $admin_buttons, $description, $validation_message );
|
32 |
+
}
|
33 |
+
|
34 |
+
return $field_content;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function get_form_editor_field_title() {
|
38 |
+
return esc_attr__( 'Mailchimp for WordPress', 'mailchimp-for-wp' );
|
39 |
+
}
|
40 |
+
|
41 |
+
public function get_form_editor_field_settings() {
|
42 |
+
return array(
|
43 |
+
'label_setting',
|
44 |
+
'description_setting',
|
45 |
+
'css_class_setting',
|
46 |
+
'mailchimp_list_setting',
|
47 |
+
'mailchimp_double_optin',
|
48 |
+
'mailchimp_precheck',
|
49 |
+
'rules_setting',
|
50 |
+
);
|
51 |
+
}
|
52 |
+
|
53 |
+
public function get_field_input( $form, $value = '', $entry = null ) {
|
54 |
+
$form_id = absint( $form['id'] );
|
55 |
+
$is_entry_detail = $this->is_entry_detail();
|
56 |
+
$is_form_editor = $this->is_form_editor();
|
57 |
+
|
58 |
+
$id = $this->id;
|
59 |
+
$field_id = $is_entry_detail || $is_form_editor || 0 === (int) $form_id ? "input_$id" : 'input_' . $form_id . "_$id";
|
60 |
+
$disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
|
61 |
+
|
62 |
+
return sprintf( "<div class='ginput_container ginput_container_checkbox'><ul class='gfield_checkbox' id='%s'>%s</ul></div>", esc_attr( $field_id ), $this->get_checkbox_choices( $value, $disabled_text, $form_id ) );
|
63 |
+
}
|
64 |
+
|
65 |
+
private function apply_mc4wp_options_filters( $options ) {
|
66 |
+
$options = apply_filters( 'mc4wp_gravity-forms_integration_options', $options );
|
67 |
+
$options = apply_filters( 'mc4wp_integration_gravity-forms_options', $options );
|
68 |
+
return $options;
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
public function get_checkbox_choices( $value, $disabled_text, $form_id = 0 ) {
|
73 |
+
$choices = '';
|
74 |
+
$is_entry_detail = $this->is_entry_detail();
|
75 |
+
$is_form_editor = $this->is_form_editor();
|
76 |
+
|
77 |
+
$options = array(
|
78 |
+
'label' => $this->get_field_label( false, $value ),
|
79 |
+
'precheck' => isset( $this->mailchimp_precheck ) ? $this->mailchimp_precheck : false,
|
80 |
+
);
|
81 |
+
$options = $this->apply_mc4wp_options_filters( $options );
|
82 |
+
|
83 |
+
// generate html
|
84 |
+
$choice = array(
|
85 |
+
'text' => $options['label'],
|
86 |
+
'value' => '1',
|
87 |
+
'isSelected' => $options['precheck'],
|
88 |
+
);
|
89 |
+
|
90 |
+
$input_id = $this->id;
|
91 |
+
if ( $is_entry_detail || $is_form_editor || 0 === (int) $form_id ) {
|
92 |
+
$id = $this->id;
|
93 |
+
} else {
|
94 |
+
$id = $form_id . '_' . $this->id;
|
95 |
+
}
|
96 |
+
|
97 |
+
if ( ! isset( $_GET['gf_token'] ) && empty( $_POST ) && rgar( $choice, 'isSelected' ) ) {
|
98 |
+
$checked = "checked='checked'";
|
99 |
+
} elseif ( is_array( $value ) && RGFormsModel::choice_value_match( $this, $choice, rgget( $input_id, $value ) ) ) {
|
100 |
+
$checked = "checked='checked'";
|
101 |
+
} elseif ( ! is_array( $value ) && RGFormsModel::choice_value_match( $this, $choice, $value ) ) {
|
102 |
+
$checked = "checked='checked'";
|
103 |
+
} else {
|
104 |
+
$checked = '';
|
105 |
+
}
|
106 |
+
|
107 |
+
$tabindex = $this->get_tabindex();
|
108 |
+
$choice_value = $choice['value'];
|
109 |
+
$choice_value = esc_attr( $choice_value );
|
110 |
+
$choice_markup = "<li class='gchoice_{$id}'>
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
<input name='input_{$input_id}' type='checkbox' value='{$choice_value}' {$checked} id='choice_{$id}' {$tabindex} {$disabled_text} />
|
112 |
<label for='choice_{$id}' id='label_{$id}'>{$choice['text']}</label>
|
113 |
</li>";
|
114 |
|
115 |
+
$choices .= gf_apply_filters(
|
116 |
+
array(
|
117 |
+
'gform_field_choice_markup_pre_render',
|
118 |
+
$this->formId,
|
119 |
+
$this->id,
|
120 |
+
),
|
121 |
+
$choice_markup,
|
122 |
+
$choice,
|
123 |
+
$this,
|
124 |
+
$value
|
125 |
+
);
|
126 |
+
|
127 |
+
return gf_apply_filters( array( 'gform_field_choices', $this->formId, $this->id ), $choices, $this );
|
128 |
+
}
|
129 |
}
|
integrations/gravity-forms/class-gravity-forms.php
CHANGED
@@ -1,166 +1,164 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Ninja_Forms_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_Gravity_Forms_Integration extends MC4WP_Integration
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
return '<a href="'. admin_url(sprintf('admin.php?page=gf_edit_forms&id=%d', $form_id)) . '">Gravity Forms</a>';
|
165 |
-
}
|
166 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Ninja_Forms_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_Gravity_Forms_Integration extends MC4WP_Integration {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $name = 'Gravity Forms';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $description = 'Subscribe visitors from your Gravity Forms forms.';
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Add hooks
|
26 |
+
*/
|
27 |
+
public function add_hooks() {
|
28 |
+
add_action( 'gform_field_standard_settings', array( $this, 'settings_fields' ), 10, 2 );
|
29 |
+
add_action( 'gform_editor_js', array( $this, 'editor_js' ) );
|
30 |
+
add_action( 'gform_after_submission', array( $this, 'after_submission' ), 10, 2 );
|
31 |
+
}
|
32 |
+
|
33 |
+
public function after_submission( $submission, $form ) {
|
34 |
+
$subscribe = false;
|
35 |
+
$email_address = '';
|
36 |
+
$mailchimp_list_id = '';
|
37 |
+
$double_optin = $this->options['double_optin'];
|
38 |
+
|
39 |
+
// find email field & checkbox value
|
40 |
+
foreach ( $form['fields'] as $field ) {
|
41 |
+
if ( $field->type === 'email' && empty( $email_address ) && ! empty( $submission[ $field->id ] ) ) {
|
42 |
+
$email_address = $submission[ $field->id ];
|
43 |
+
}
|
44 |
+
|
45 |
+
if ( $field->type === 'mailchimp' && ! empty( $submission[ $field->id ] ) ) {
|
46 |
+
$subscribe = true;
|
47 |
+
$mailchimp_list_id = $field->mailchimp_list;
|
48 |
+
|
49 |
+
if ( isset( $field->mailchimp_double_optin ) ) {
|
50 |
+
$double_optin = $field->mailchimp_double_optin;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
if ( ! $subscribe || empty( $email_address ) ) {
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
|
59 |
+
// override integration settings with field options
|
60 |
+
$orig_options = $this->options;
|
61 |
+
$this->options['lists'] = array( $mailchimp_list_id );
|
62 |
+
$this->options['double_optin'] = $double_optin;
|
63 |
+
|
64 |
+
// perform the sign-up
|
65 |
+
$this->subscribe( array( 'EMAIL' => $email_address ), $submission['form_id'] );
|
66 |
+
|
67 |
+
// revert back to original options in case request lives on
|
68 |
+
$this->options = $orig_options;
|
69 |
+
}
|
70 |
+
|
71 |
+
public function editor_js() {
|
72 |
+
?>
|
73 |
+
<script type="text/javascript">
|
74 |
+
/*
|
75 |
+
* When the field settings are initialized, populate
|
76 |
+
* the custom field setting.
|
77 |
+
*/
|
78 |
+
jQuery(document).on('gform_load_field_settings', function(ev, field) {
|
79 |
+
jQuery('#field_mailchimp_list').val(field.mailchimp_list || '');
|
80 |
+
jQuery('#field_mailchimp_double_optin').val(field.mailchimp_double_optin || "1");
|
81 |
+
jQuery('#field_mailchimp_precheck').val(field.mailchimp_precheck || "0");
|
82 |
+
});
|
83 |
+
</script>
|
84 |
+
<?php
|
85 |
+
}
|
86 |
+
|
87 |
+
public function settings_fields( $pos, $form_id ) {
|
88 |
+
if ( $pos !== 0 ) {
|
89 |
+
return;
|
90 |
+
}
|
91 |
+
|
92 |
+
$mailchimp = new MC4WP_MailChimp();
|
93 |
+
$lists = $mailchimp->get_lists();
|
94 |
+
?>
|
95 |
+
<li class="mailchimp_list_setting field_setting">
|
96 |
+
<label for="field_mailchimp_list" class="section_label">
|
97 |
+
<?php esc_html_e( 'Mailchimp list', 'mailchimp-for-wp' ); ?>
|
98 |
+
</label>
|
99 |
+
<select id="field_mailchimp_list" onchange="SetFieldProperty('mailchimp_list', this.value)">
|
100 |
+
<option value="" disabled><?php _e( 'Select a Mailchimp list', 'mailchimp-for-wp' ); ?></option>
|
101 |
+
<?php
|
102 |
+
foreach ( $lists as $list ) {
|
103 |
+
echo sprintf( '<option value="%s">%s</option>', $list->id, $list->name );
|
104 |
+
}
|
105 |
+
?>
|
106 |
+
</select>
|
107 |
+
<p class="help">
|
108 |
+
<?php echo __( 'Select the list(s) to which people who check the checkbox should be subscribed.', 'mailchimp-for-wp' ); ?>
|
109 |
+
</p>
|
110 |
+
</li>
|
111 |
+
<li class="mailchimp_double_optin field_setting">
|
112 |
+
<label for="field_mailchimp_double_optin" class="section_label">
|
113 |
+
<?php esc_html_e( 'Double opt-in?', 'mailchimp-for-wp' ); ?>
|
114 |
+
</label>
|
115 |
+
<select id="field_mailchimp_double_optin" onchange="SetFieldProperty('mailchimp_double_optin', this.value)">
|
116 |
+
<option value="1"><?php echo __( 'Yes', 'mailchimp-for-wp' ); ?></option>
|
117 |
+
<option value="0"><?php echo __( 'No', 'mailchimp-for-wp' ); ?></option>
|
118 |
+
</select>
|
119 |
+
<p class="help">
|
120 |
+
<?php _e( 'Select "yes" if you want people to confirm their email address before being subscribed (recommended)', 'mailchimp-for-wp' ); ?>
|
121 |
+
</p>
|
122 |
+
</li>
|
123 |
+
<li class="mailchimp_precheck field_setting">
|
124 |
+
<label for="field_mailchimp_precheck" class="section_label">
|
125 |
+
<?php esc_html_e( 'Pre-check the checkbox?', 'mailchimp-for-wp' ); ?>
|
126 |
+
</label>
|
127 |
+
<select id="field_mailchimp_precheck" onchange="SetFieldProperty('mailchimp_precheck', this.value)">
|
128 |
+
<option value="1"><?php echo __( 'Yes', 'mailchimp-for-wp' ); ?></option>
|
129 |
+
<option value="0"><?php echo __( 'No', 'mailchimp-for-wp' ); ?></option>
|
130 |
+
</select>
|
131 |
+
<p class="help">
|
132 |
+
<?php
|
133 |
+
_e( 'Select "yes" if the checkbox should be pre-checked.', 'mailchimp-for-wp' );
|
134 |
+
echo '<br />';
|
135 |
+
printf( __( '<strong>Warning: </strong> enabling this may affect your <a href="%s">GDPR compliance</a>.', 'mailchimp-for-wp' ), 'https://kb.mc4wp.com/gdpr-compliance/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=integrations-page' );
|
136 |
+
?>
|
137 |
+
</p>
|
138 |
+
</li>
|
139 |
+
<?php
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* @return bool
|
144 |
+
*/
|
145 |
+
public function is_installed() {
|
146 |
+
return class_exists( 'GF_Field' ) && class_exists( 'GF_Fields' );
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* @since 3.0
|
151 |
+
* @return array
|
152 |
+
*/
|
153 |
+
public function get_ui_elements() {
|
154 |
+
return array();
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* @param int $form_id
|
159 |
+
* @return string
|
160 |
+
*/
|
161 |
+
public function get_object_link( $form_id ) {
|
162 |
+
return '<a href="' . admin_url( sprintf( 'admin.php?page=gf_edit_forms&id=%d', $form_id ) ) . '">Gravity Forms</a>';
|
163 |
+
}
|
|
|
|
|
164 |
}
|
integrations/memberpress/class-memberpress.php
CHANGED
@@ -1,71 +1,75 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_MemberPress_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_MemberPress_Integration extends MC4WP_Integration
|
11 |
-
{
|
12 |
|
13 |
-
/**
|
14 |
-
* @var string
|
15 |
-
*/
|
16 |
-
public $name = "MemberPress";
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
/**
|
25 |
-
* Add hooks
|
26 |
-
*/
|
27 |
-
public function add_hooks()
|
28 |
-
{
|
29 |
-
if (! $this->options['implicit']) {
|
30 |
-
add_action('mepr_checkout_before_submit', array( $this, 'output_checkbox' ));
|
31 |
-
}
|
32 |
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
{
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
}
|
71 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_MemberPress_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_MemberPress_Integration extends MC4WP_Integration {
|
|
|
11 |
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $name = 'MemberPress';
|
17 |
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $description = 'Subscribes people from MemberPress register forms.';
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
/**
|
25 |
+
* Add hooks
|
26 |
+
*/
|
27 |
+
public function add_hooks() {
|
28 |
+
if ( ! $this->options['implicit'] ) {
|
29 |
+
if ( has_action( 'mepr_checkout_before_submit' ) ) {
|
30 |
+
add_action( 'mepr_checkout_before_submit', array( $this, 'output_checkbox' ) );
|
31 |
+
} else {
|
32 |
+
add_action( 'mepr-checkout-before-submit', array( $this, 'output_checkbox' ) );
|
33 |
+
}
|
34 |
+
}
|
35 |
+
if ( has_action( 'mepr_signup' ) ) {
|
36 |
+
add_action( 'mepr_signup', array( $this, 'subscribe_from_memberpress' ), 5 );
|
37 |
+
} else {
|
38 |
+
add_action( 'mepr-signup', array( $this, 'subscribe_from_memberpress' ), 5 );
|
39 |
+
}
|
40 |
+
}
|
41 |
|
42 |
|
43 |
|
44 |
+
/**
|
45 |
+
* Subscribe from MemberPress sign-up forms.
|
46 |
+
*
|
47 |
+
* @param MeprTransaction $txn
|
48 |
+
* @return bool
|
49 |
+
*/
|
50 |
+
public function subscribe_from_memberpress( $txn ) {
|
|
|
51 |
|
52 |
+
// Is this integration triggered? (checkbox checked or implicit)
|
53 |
+
if ( ! $this->triggered() ) {
|
54 |
+
return false;
|
55 |
+
}
|
56 |
|
57 |
+
$user = get_userdata( $txn->user_id );
|
58 |
|
59 |
+
$data = array(
|
60 |
+
'EMAIL' => $user->user_email,
|
61 |
+
'FNAME' => $user->first_name,
|
62 |
+
'LNAME' => $user->last_name,
|
63 |
+
);
|
64 |
|
65 |
+
// subscribe using email and name
|
66 |
+
return $this->subscribe( $data, $txn->id );
|
67 |
+
}
|
68 |
|
69 |
+
/**
|
70 |
+
* @return bool
|
71 |
+
*/
|
72 |
+
public function is_installed() {
|
73 |
+
return defined( 'MEPR_VERSION' );
|
74 |
+
}
|
|
|
75 |
}
|
integrations/ninja-forms-2/admin-before.php
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
<p>
|
2 |
-
<?php echo __('To integrate with Ninja Forms, add the "Mailchimp" field to your Ninja Forms forms.', 'mailchimp-for-wp'); ?>
|
3 |
-
</p>
|
1 |
<p>
|
2 |
+
<?php echo __( 'To integrate with Ninja Forms, add the "Mailchimp" field to your Ninja Forms forms.', 'mailchimp-for-wp' ); ?>
|
3 |
+
</p>
|
integrations/ninja-forms-2/class-ninja-forms.php
CHANGED
@@ -1,145 +1,152 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Ninja_Forms_v2_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Ninja_Forms_v2_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_Ninja_Forms_V2_Integration extends MC4WP_Integration {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $name = 'Ninja Forms (v2)';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $description = 'Subscribe visitors from your Ninja Forms forms.';
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Add hooks
|
26 |
+
*/
|
27 |
+
public function add_hooks() {
|
28 |
+
add_action( 'init', array( $this, 'register_field' ) );
|
29 |
+
}
|
30 |
+
|
31 |
+
public function register_field() {
|
32 |
+
$args = array(
|
33 |
+
'name' => __( 'Mailchimp', 'ninja-forms' ),
|
34 |
+
'edit_function' => '',
|
35 |
+
'display_function' => 'ninja_forms_field_checkbox_display',
|
36 |
+
'group' => 'standard_fields',
|
37 |
+
'sidebar' => 'template_fields',
|
38 |
+
'edit_label' => true,
|
39 |
+
'edit_label_pos' => true,
|
40 |
+
'label_pos_options' => array(
|
41 |
+
array(
|
42 |
+
'name' => __( 'Left of Element', 'ninja-forms' ),
|
43 |
+
'value' => 'left',
|
44 |
+
),
|
45 |
+
array(
|
46 |
+
'name' => __( 'Above Element', 'ninja-forms' ),
|
47 |
+
'value' => 'above',
|
48 |
+
),
|
49 |
+
array(
|
50 |
+
'name' => __( 'Below Element', 'ninja-forms' ),
|
51 |
+
'value' => 'below',
|
52 |
+
),
|
53 |
+
array(
|
54 |
+
'name' => __( 'Right of Element', 'ninja-forms' ),
|
55 |
+
'value' => 'right',
|
56 |
+
),
|
57 |
+
),
|
58 |
+
'edit_placeholder' => false,
|
59 |
+
'edit_req' => true,
|
60 |
+
'edit_custom_class' => true,
|
61 |
+
'edit_help' => true,
|
62 |
+
'edit_desc' => true,
|
63 |
+
'edit_meta' => false,
|
64 |
+
'process' => array( $this, 'process' ),
|
65 |
+
'default_label' => $this->options['label'],
|
66 |
+
'edit_options' => array(
|
67 |
+
array(
|
68 |
+
'type' => 'select', //What type of input should this be?
|
69 |
+
'options' => array(
|
70 |
+
array(
|
71 |
+
'name' => __( 'Unchecked', 'ninja-forms' ),
|
72 |
+
'value' => 'unchecked',
|
73 |
+
),
|
74 |
+
array(
|
75 |
+
'name' => __( 'Checked', 'ninja-forms' ),
|
76 |
+
'value' => 'checked',
|
77 |
+
),
|
78 |
+
),
|
79 |
+
'name' => 'default_value', //What should it be named. This should always be a programmatic name, not a label.
|
80 |
+
'label' => __( 'Default Value', 'ninja-forms' ),
|
81 |
+
'class' => 'widefat', //Additional classes to be added to the input element.
|
82 |
+
),
|
83 |
+
),
|
84 |
+
);
|
85 |
+
|
86 |
+
ninja_forms_register_field( 'mc4wp-subscribe', $args );
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Process form submissions
|
91 |
+
*
|
92 |
+
* @param int $id
|
93 |
+
* @param string $value
|
94 |
+
*
|
95 |
+
* @return bool|string
|
96 |
+
*/
|
97 |
+
public function process( $id, $value ) {
|
98 |
+
|
99 |
+
// field was not checked
|
100 |
+
if ( $value !== 'checked' ) {
|
101 |
+
return false;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @var Ninja_Forms_Processing $ninja_forms_processing
|
106 |
+
*/
|
107 |
+
global $ninja_forms_processing;
|
108 |
+
|
109 |
+
// generate an array of field label => field value
|
110 |
+
$fields = $ninja_forms_processing->get_all_submitted_fields();
|
111 |
+
|
112 |
+
$pretty = array();
|
113 |
+
foreach ( $fields as $field_id => $field_value ) {
|
114 |
+
|
115 |
+
// try admin label for "mc4wp-" prefixed fields, otherwise use general label
|
116 |
+
$label = $ninja_forms_processing->get_field_setting( $field_id, 'admin_label' );
|
117 |
+
if ( empty( $label ) || stripos( $label, 'mc4wp-' ) !== 0 ) {
|
118 |
+
$label = $ninja_forms_processing->get_field_setting( $field_id, 'label' );
|
119 |
+
}
|
120 |
+
|
121 |
+
$pretty[ $label ] = $field_value;
|
122 |
+
}
|
123 |
+
|
124 |
+
// guess mailchimp variables
|
125 |
+
$parser = new MC4WP_Field_Guesser( $pretty );
|
126 |
+
$data = $parser->combine( array( 'guessed', 'namespaced' ) );
|
127 |
+
|
128 |
+
// do nothing if no email was found
|
129 |
+
if ( empty( $data['EMAIL'] ) ) {
|
130 |
+
$this->get_log()->warning( sprintf( '%s > Unable to find EMAIL field.', $this->name ) );
|
131 |
+
return false;
|
132 |
+
}
|
133 |
+
|
134 |
+
return $this->subscribe( $data, $ninja_forms_processing->get_form_ID() );
|
135 |
+
}
|
136 |
+
|
137 |
+
|
138 |
+
/**
|
139 |
+
* @return bool
|
140 |
+
*/
|
141 |
+
public function is_installed() {
|
142 |
+
return function_exists( 'ninja_forms_register_field' );
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* @since 3.0
|
147 |
+
* @return array
|
148 |
+
*/
|
149 |
+
public function get_ui_elements() {
|
150 |
+
return array_diff( parent::get_ui_elements(), array( 'enabled', 'implicit', 'precheck', 'css', 'label' ) );
|
151 |
+
}
|
152 |
}
|
integrations/ninja-forms/admin-before.php
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
<p>
|
2 |
-
|
3 |
-
</p>
|
1 |
<p>
|
2 |
+
<?php echo sprintf( __( 'To integrate with Ninja Forms, add the "Mailchimp" action to <a href="%s">one of your Ninja Forms forms</a>.', 'mailchimp-for-wp' ), admin_url( 'admin.php?page=ninja-forms' ) ); ?>
|
3 |
+
</p>
|
integrations/ninja-forms/bootstrap.php
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
mc4wp_register_integration('ninja-forms', 'MC4WP_Ninja_Forms_Integration', true);
|
4 |
|
5 |
-
if (class_exists('Ninja_Forms') && method_exists('Ninja_Forms', 'instance')) {
|
6 |
-
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
}
|
1 |
<?php
|
2 |
|
3 |
+
mc4wp_register_integration( 'ninja-forms', 'MC4WP_Ninja_Forms_Integration', true );
|
4 |
|
5 |
+
if ( class_exists( 'Ninja_Forms' ) && method_exists( 'Ninja_Forms', 'instance' ) ) {
|
6 |
+
$ninja_forms = Ninja_Forms::instance();
|
7 |
|
8 |
+
if ( isset( $ninja_forms->fields ) ) {
|
9 |
+
$ninja_forms->fields['mc4wp_optin'] = new MC4WP_Ninja_Forms_Field();
|
10 |
+
}
|
11 |
|
12 |
+
if ( isset( $ninja_forms->actions ) ) {
|
13 |
+
$ninja_forms->actions['mc4wp_subscribe'] = new MC4WP_Ninja_Forms_Action();
|
14 |
+
}
|
15 |
}
|
integrations/ninja-forms/class-action.php
CHANGED
@@ -1,153 +1,149 @@
|
|
1 |
-
<?php if (! defined('ABSPATH')) {
|
2 |
-
|
3 |
}
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Ninja_Forms_Action
|
7 |
*/
|
8 |
-
final class MC4WP_Ninja_Forms_Action extends NF_Abstracts_ActionNewsletter
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
//
|
66 |
-
// '
|
67 |
-
// '
|
68 |
-
// '
|
69 |
-
// '
|
70 |
-
// '
|
71 |
-
// '
|
72 |
-
//
|
73 |
-
//
|
74 |
-
// '
|
75 |
-
//
|
76 |
-
//
|
77 |
-
//
|
78 |
-
// '
|
79 |
-
//
|
80 |
-
//
|
81 |
-
//
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
}
|
150 |
-
|
151 |
-
return $return;
|
152 |
-
}
|
153 |
}
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
+
exit;
|
3 |
}
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Ninja_Forms_Action
|
7 |
*/
|
8 |
+
final class MC4WP_Ninja_Forms_Action extends NF_Abstracts_ActionNewsletter {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @var string
|
12 |
+
*/
|
13 |
+
protected $_name = 'mc4wp_subscribe';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Constructor
|
17 |
+
*/
|
18 |
+
public function __construct() {
|
19 |
+
parent::__construct();
|
20 |
+
|
21 |
+
$this->_nicename = __( 'Mailchimp', 'mailchimp-for-wp' );
|
22 |
+
$prefix = $this->get_name();
|
23 |
+
|
24 |
+
unset( $this->_settings[ $prefix . 'newsletter_list_groups' ] );
|
25 |
+
|
26 |
+
$this->_settings['double_optin'] = array(
|
27 |
+
'name' => 'double_optin',
|
28 |
+
'type' => 'select',
|
29 |
+
'label' => __( 'Use double opt-in?', 'mailchimp-for-wp' ),
|
30 |
+
'width' => 'full',
|
31 |
+
'group' => 'primary',
|
32 |
+
'value' => 1,
|
33 |
+
'options' => array(
|
34 |
+
array(
|
35 |
+
'value' => 1,
|
36 |
+
'label' => 'Yes',
|
37 |
+
),
|
38 |
+
array(
|
39 |
+
'value' => 0,
|
40 |
+
'label' => 'No',
|
41 |
+
),
|
42 |
+
),
|
43 |
+
);
|
44 |
+
|
45 |
+
$this->_settings['update_existing'] = array(
|
46 |
+
'name' => 'update_existing',
|
47 |
+
'type' => 'select',
|
48 |
+
'label' => __( 'Update existing subscribers?', 'mailchimp-for-wp' ),
|
49 |
+
'width' => 'full',
|
50 |
+
'group' => 'primary',
|
51 |
+
'value' => 0,
|
52 |
+
'options' => array(
|
53 |
+
array(
|
54 |
+
'value' => 1,
|
55 |
+
'label' => 'Yes',
|
56 |
+
),
|
57 |
+
array(
|
58 |
+
'value' => 0,
|
59 |
+
'label' => 'No',
|
60 |
+
),
|
61 |
+
),
|
62 |
+
);
|
63 |
+
|
64 |
+
// $this->_settings[ 'replace_interests' ] = array(
|
65 |
+
// 'name' => 'replace_interests',
|
66 |
+
// 'type' => 'select',
|
67 |
+
// 'label' => __( 'Replace existing interest groups?', 'mailchimp-for-wp'),
|
68 |
+
// 'width' => 'full',
|
69 |
+
// 'group' => 'primary',
|
70 |
+
// 'value' => 0,
|
71 |
+
// 'options' => array(
|
72 |
+
// array(
|
73 |
+
// 'value' => 1,
|
74 |
+
// 'label' => 'Yes',
|
75 |
+
// ),
|
76 |
+
// array(
|
77 |
+
// 'value' => 0,
|
78 |
+
// 'label' => 'No',
|
79 |
+
// ),
|
80 |
+
// ),
|
81 |
+
// );
|
82 |
+
}
|
83 |
+
|
84 |
+
/*
|
85 |
+
* PUBLIC METHODS
|
86 |
+
*/
|
87 |
+
|
88 |
+
public function save( $action_settings ) {
|
89 |
+
}
|
90 |
+
|
91 |
+
public function process( $action_settings, $form_id, $data ) {
|
92 |
+
if ( empty( $action_settings['newsletter_list'] ) || empty( $action_settings['EMAIL'] ) ) {
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
|
96 |
+
// find "mc4wp_optin" type field, bail if not checked.
|
97 |
+
foreach ( $data['fields'] as $field_data ) {
|
98 |
+
if ( $field_data['type'] === 'mc4wp_optin' && empty( $field_data['value'] ) ) {
|
99 |
+
return;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
$list_id = $action_settings['newsletter_list'];
|
104 |
+
$email_address = $action_settings['EMAIL'];
|
105 |
+
$mailchimp = new MC4WP_MailChimp();
|
106 |
+
|
107 |
+
$merge_fields = $mailchimp->get_list_merge_fields( $list_id );
|
108 |
+
foreach ( $merge_fields as $merge_field ) {
|
109 |
+
if ( ! empty( $action_settings[ $merge_field->tag ] ) ) {
|
110 |
+
$merge_fields[ $merge_field->tag ] = $action_settings[ $merge_field->tag ];
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
$double_optin = (int) $action_settings['double_optin'] !== 0;
|
115 |
+
$update_existing = (int) $action_settings['update_existing'] === 1;
|
116 |
+
$replace_interests = isset( $action_settings['replace_interests'] ) && (int) $action_settings['replace_interests'] === 1;
|
117 |
+
|
118 |
+
do_action( 'mc4wp_integration_ninja_forms_subscribe', $email_address, $merge_fields, $list_id, $double_optin, $update_existing, $replace_interests, $form_id );
|
119 |
+
}
|
120 |
+
|
121 |
+
protected function get_lists() {
|
122 |
+
$mailchimp = new MC4WP_MailChimp();
|
123 |
+
|
124 |
+
/** @var array $lists */
|
125 |
+
$lists = $mailchimp->get_lists();
|
126 |
+
$return = array();
|
127 |
+
|
128 |
+
foreach ( $lists as $list ) {
|
129 |
+
$list_fields = array();
|
130 |
+
|
131 |
+
foreach ( $mailchimp->get_list_merge_fields( $list->id ) as $merge_field ) {
|
132 |
+
$list_fields[] = array(
|
133 |
+
'value' => $merge_field->tag,
|
134 |
+
'label' => $merge_field->name,
|
135 |
+
);
|
136 |
+
}
|
137 |
+
|
138 |
+
// TODO: Add support for groups once base class supports this.
|
139 |
+
|
140 |
+
$return[] = array(
|
141 |
+
'value' => $list->id,
|
142 |
+
'label' => $list->name,
|
143 |
+
'fields' => $list_fields,
|
144 |
+
);
|
145 |
+
}
|
146 |
+
|
147 |
+
return $return;
|
148 |
+
}
|
|
|
|
|
|
|
|
|
149 |
}
|
integrations/ninja-forms/class-field.php
CHANGED
@@ -1,98 +1,95 @@
|
|
1 |
-
<?php if (! defined('ABSPATH')) {
|
2 |
-
|
3 |
}
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Ninja_Forms_Field
|
7 |
*/
|
8 |
-
class MC4WP_Ninja_Forms_Field extends NF_Abstracts_Input
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
}
|
96 |
-
return $value;
|
97 |
-
}
|
98 |
}
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
+
exit;
|
3 |
}
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Ninja_Forms_Field
|
7 |
*/
|
8 |
+
class MC4WP_Ninja_Forms_Field extends NF_Abstracts_Input {
|
9 |
+
|
10 |
+
protected $_name = 'mc4wp_optin';
|
11 |
+
|
12 |
+
protected $_nicename = 'Mailchimp';
|
13 |
+
|
14 |
+
protected $_section = 'misc';
|
15 |
+
|
16 |
+
protected $_type = 'checkbox';
|
17 |
+
|
18 |
+
protected $_icon = 'check-square-o';
|
19 |
+
|
20 |
+
protected $_templates = 'checkbox';
|
21 |
+
|
22 |
+
protected $_test_value = 0;
|
23 |
+
|
24 |
+
protected $_settings = array( 'checkbox_default_value', 'checked_calc_value', 'unchecked_calc_value' );
|
25 |
+
|
26 |
+
protected $_settings_exclude = array( 'default', 'placeholder', 'input_limit_set', 'checkbox_values' );
|
27 |
+
|
28 |
+
/**
|
29 |
+
* NF_Fields_Checkbox constructor.
|
30 |
+
* @since 3.0
|
31 |
+
*/
|
32 |
+
public function __construct() {
|
33 |
+
parent::__construct();
|
34 |
+
|
35 |
+
$this->_nicename = __( 'Mailchimp opt-in', 'mailchimp-for-wp' );
|
36 |
+
|
37 |
+
$this->_settings['label_pos']['value'] = 'right';
|
38 |
+
|
39 |
+
add_filter( 'ninja_forms_custom_columns', array( $this, 'custom_columns' ), 10, 2 );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Admin Form Element
|
44 |
+
* Display the checkbox on the edit submissions area.
|
45 |
+
* @since 3.0
|
46 |
+
*
|
47 |
+
* @param $id Field ID.
|
48 |
+
* @param $value Field value.
|
49 |
+
* @return string HTML used for display of checkbox.
|
50 |
+
*/
|
51 |
+
public function admin_form_element( $id, $value ) {
|
52 |
+
// If the checkboxes value is one...
|
53 |
+
if ( 1 === (int) $value ) {
|
54 |
+
// ...this variable to checked.
|
55 |
+
$checked = 'checked';
|
56 |
+
} else {
|
57 |
+
// ...else leave the variable empty.
|
58 |
+
$checked = '';
|
59 |
+
}
|
60 |
+
|
61 |
+
// Return HTML to be output to the submission edit page.
|
62 |
+
return "<input type='hidden' name='fields[$id]' value='0' ><input type='checkbox' name='fields[$id]' value='1' id='' $checked>";
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Custom Columns
|
67 |
+
* Creates what is displayed in the columns on the submissions page.
|
68 |
+
* @since 3.0
|
69 |
+
*
|
70 |
+
* @param string $value checkbox value
|
71 |
+
* @param MC4WP_Ninja_Forms_Field $field field model.
|
72 |
+
* @return $value string|void
|
73 |
+
*/
|
74 |
+
public function custom_columns( $value, $field ) {
|
75 |
+
// If the field type is equal to checkbox...
|
76 |
+
if ( 'mc4wp_optin' === $field->get_setting( 'type' ) ) {
|
77 |
+
// Backwards compatibility check for the new checked value setting.
|
78 |
+
if ( null === $field->get_setting( 'checked_value' ) && 1 === (int) $value ) {
|
79 |
+
return __( 'Checked', 'ninja-forms' );
|
80 |
+
} elseif ( null === $field->get_setting( 'unchecked_value' ) && 0 === (int) $value ) {
|
81 |
+
return __( 'Unchecked', 'ninja-forms' );
|
82 |
+
}
|
83 |
+
|
84 |
+
// If the field value is set to 1....
|
85 |
+
if ( 1 === (int) $value ) {
|
86 |
+
// Set the value to the checked value setting.
|
87 |
+
$value = $field->get_setting( 'checked_value' );
|
88 |
+
} else {
|
89 |
+
// Else set the value to the unchecked value setting.
|
90 |
+
$value = $field->get_setting( 'unchecked_value' );
|
91 |
+
}
|
92 |
+
}
|
93 |
+
return $value;
|
94 |
+
}
|
|
|
|
|
|
|
95 |
}
|
integrations/ninja-forms/class-ninja-forms.php
CHANGED
@@ -1,75 +1,70 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Ninja_Forms_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_Ninja_Forms_Integration extends MC4WP_Integration
|
11 |
-
{
|
12 |
|
13 |
-
/**
|
14 |
-
* @var string
|
15 |
-
*/
|
16 |
-
public $name = "Ninja Forms";
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
/**
|
25 |
-
* Add hooks
|
26 |
-
*/
|
27 |
-
public function add_hooks()
|
28 |
-
{
|
29 |
-
add_action('mc4wp_integration_ninja_forms_subscribe', array( $this, 'subscribe_from_ninja_forms' ), 10, 7);
|
30 |
-
}
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
$this->options['replace_interests'] = $replace_interests;
|
39 |
-
$this->options['lists'] = array( $list_id );
|
40 |
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
|
|
45 |
|
46 |
-
|
47 |
-
$this->options = $orig_options;
|
48 |
-
}
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
public function is_installed()
|
54 |
-
{
|
55 |
-
return class_exists('Ninja_Forms');
|
56 |
-
}
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
return array();
|
65 |
-
}
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Ninja_Forms_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_Ninja_Forms_Integration extends MC4WP_Integration {
|
|
|
11 |
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $name = 'Ninja Forms';
|
17 |
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $description = 'Subscribe visitors from your Ninja Forms forms.';
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
/**
|
25 |
+
* Add hooks
|
26 |
+
*/
|
27 |
+
public function add_hooks() {
|
28 |
+
add_action( 'mc4wp_integration_ninja_forms_subscribe', array( $this, 'subscribe_from_ninja_forms' ), 10, 7 );
|
29 |
+
}
|
|
|
|
|
30 |
|
31 |
+
public function subscribe_from_ninja_forms( $email_address, $merge_fields, $list_id, $double_optin = true, $update_existing = false, $replace_interests = false, $form_id = 0 ) {
|
32 |
+
// set options from parameters (coming from action)
|
33 |
+
$orig_options = $this->options;
|
34 |
+
$this->options['double_optin'] = $double_optin;
|
35 |
+
$this->options['update_existing'] = $update_existing;
|
36 |
+
$this->options['replace_interests'] = $replace_interests;
|
37 |
+
$this->options['lists'] = array( $list_id );
|
38 |
|
39 |
+
$data = $merge_fields;
|
40 |
+
$data['EMAIL'] = $email_address;
|
41 |
|
42 |
+
$this->subscribe( $data, $form_id );
|
|
|
|
|
43 |
|
44 |
+
// revert to original options
|
45 |
+
$this->options = $orig_options;
|
46 |
+
}
|
|
|
|
|
|
|
|
|
47 |
|
48 |
+
/**
|
49 |
+
* @return bool
|
50 |
+
*/
|
51 |
+
public function is_installed() {
|
52 |
+
return class_exists( 'Ninja_Forms' );
|
53 |
+
}
|
|
|
|
|
54 |
|
55 |
+
/**
|
56 |
+
* @since 3.0
|
57 |
+
* @return array
|
58 |
+
*/
|
59 |
+
public function get_ui_elements() {
|
60 |
+
return array();
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @param int $form_id
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function get_object_link( $form_id ) {
|
68 |
+
return '<a href="' . admin_url( sprintf( 'admin.php?page=ninja-forms&form_id=%d', $form_id ) ) . '">Ninja Forms</a>';
|
69 |
+
}
|
70 |
}
|
integrations/woocommerce/admin-after.php
CHANGED
@@ -1,32 +1,42 @@
|
|
1 |
<?php
|
2 |
|
3 |
$position_options = array(
|
4 |
-
'after_email_field'
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
);
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
/** @var MC4WP_Integration $integration */
|
14 |
|
15 |
?>
|
16 |
<table class="form-table">
|
17 |
-
<?php
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
19 |
<th scope="row">
|
20 |
-
<?php _e('Position', 'mailchimp-for-wp'); ?>
|
21 |
</th>
|
22 |
<td>
|
23 |
<select name="mc4wp_integrations[<?php echo $integration->slug; ?>][position]">
|
24 |
<?php
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
</select>
|
32 |
</td>
|
1 |
<?php
|
2 |
|
3 |
$position_options = array(
|
4 |
+
'after_email_field' => __( 'After email field', 'mailchimp-for-wp' ),
|
5 |
+
'checkout_billing' => __( 'After billing details', 'mailchimp-for-wp' ),
|
6 |
+
'checkout_shipping' => __( 'After shipping details', 'mailchimp-for-wp' ),
|
7 |
+
'checkout_after_customer_details' => __( 'After customer details', 'mailchimp-for-wp' ),
|
8 |
+
'review_order_before_submit' => __( 'Before submit button', 'mailchimp-for-wp' ),
|
9 |
+
'after_order_notes' => __( 'After order notes', 'mailchimp-for-wp' ),
|
10 |
);
|
11 |
|
12 |
+
if ( defined( 'CFW_NAME' ) ) {
|
13 |
+
$position_options['cfw_checkout_before_payment_method_tab_nav'] = __( 'Checkout for WooCommerce: Before complete order button', 'mailchimp-for-wp' );
|
14 |
+
$position_options['cfw_checkout_after_login'] = __( 'Checkout for WooCommerce: After account info', 'mailchimp-for-wp' );
|
15 |
+
$position_options['cfw_checkout_after_customer_info_address'] = __( 'Checkout for WooCommerce: After customer info', 'mailchimp-for-wp' );
|
16 |
+
}
|
17 |
|
18 |
/** @var MC4WP_Integration $integration */
|
19 |
|
20 |
?>
|
21 |
<table class="form-table">
|
22 |
+
<?php
|
23 |
+
$config = array(
|
24 |
+
'element' => 'mc4wp_integrations[' . $integration->slug . '][implicit]',
|
25 |
+
'value' => '0',
|
26 |
+
);
|
27 |
+
?>
|
28 |
+
<tr valign="top" data-showif="<?php echo esc_attr( json_encode( $config ) ); ?>">
|
29 |
<th scope="row">
|
30 |
+
<?php _e( 'Position', 'mailchimp-for-wp' ); ?>
|
31 |
</th>
|
32 |
<td>
|
33 |
<select name="mc4wp_integrations[<?php echo $integration->slug; ?>][position]">
|
34 |
<?php
|
35 |
|
36 |
+
foreach ( $position_options as $value => $label ) {
|
37 |
+
printf( '<option value="%s" %s>%s</option>', esc_attr( $value ), selected( $value, $opts['position'], false ), esc_html( $label ) );
|
38 |
+
}
|
39 |
+
?>
|
40 |
|
41 |
</select>
|
42 |
</td>
|
integrations/woocommerce/class-woocommerce.php
CHANGED
@@ -1,172 +1,172 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_WooCommerce_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_WooCommerce_Integration extends MC4WP_Integration
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
33 |
} else {
|
34 |
-
add_filter('woocommerce_form_field_email', array($this, 'add_checkbox_after_email_field'), 10, 4);
|
35 |
}
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
if ($key !== 'billing_email') {
|
69 |
return $field;
|
70 |
}
|
71 |
|
72 |
$field .= PHP_EOL;
|
73 |
-
$field .= $this->get_checkbox_html(
|
74 |
-
|
75 |
-
|
|
|
|
|
76 |
return $field;
|
77 |
}
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
* @return string
|
167 |
-
*/
|
168 |
-
public function get_object_link($object_id)
|
169 |
-
{
|
170 |
-
return sprintf('<a href="%s">%s</a>', get_edit_post_link($object_id), sprintf(__('Order #%d', 'mailchimp-for-wp'), $object_id));
|
171 |
-
}
|
172 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_WooCommerce_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_WooCommerce_Integration extends MC4WP_Integration {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $name = 'WooCommerce Checkout';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $description = "Subscribes people from WooCommerce's checkout form.";
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Add hooks
|
25 |
+
*/
|
26 |
+
public function add_hooks() {
|
27 |
+
if ( ! $this->options['implicit'] ) {
|
28 |
+
|
29 |
+
if ( $this->options['position'] !== 'after_email_field' ) {
|
30 |
+
|
31 |
+
// create hook name based on position setting
|
32 |
+
$hook = $this->options['position'];
|
33 |
+
if ( strpos( $hook, 'cfw_' ) !== 0 && strpos( $hook, 'woocommerce_' ) !== 0 ) {
|
34 |
+
$hook = sprintf( 'woocommerce_%s', $hook );
|
35 |
+
}
|
36 |
+
|
37 |
+
add_action( $hook, array( $this, 'output_checkbox' ), 20 );
|
38 |
} else {
|
39 |
+
add_filter( 'woocommerce_form_field_email', array( $this, 'add_checkbox_after_email_field' ), 10, 4 );
|
40 |
}
|
41 |
|
42 |
+
add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'save_woocommerce_checkout_checkbox_value' ) );
|
43 |
+
|
44 |
+
// specific hooks for klarna
|
45 |
+
add_filter( 'kco_create_order', array( $this, 'add_klarna_field' ) );
|
46 |
+
add_filter( 'klarna_after_kco_confirmation', array( $this, 'subscribe_from_klarna_checkout' ), 10, 2 );
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
add_action( 'woocommerce_checkout_order_processed', array( $this, 'subscribe_from_woocommerce_checkout' ) );
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Add default value for "position" setting
|
55 |
+
*
|
56 |
+
* @return array
|
57 |
+
*/
|
58 |
+
protected function get_default_options() {
|
59 |
+
$defaults = parent::get_default_options();
|
60 |
+
$defaults['position'] = 'billing';
|
61 |
+
return $defaults;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function add_klarna_field( $create ) {
|
65 |
+
$create['options']['additional_checkbox']['text'] = $this->get_label_text();
|
66 |
+
$create['options']['additional_checkbox']['checked'] = (bool) $this->options['precheck'];
|
67 |
+
$create['options']['additional_checkbox']['required'] = false;
|
68 |
+
return $create;
|
69 |
+
}
|
70 |
+
|
71 |
+
function add_checkbox_after_email_field( $field, $key, $args, $value ) {
|
72 |
+
if ( $key !== 'billing_email' ) {
|
|
|
73 |
return $field;
|
74 |
}
|
75 |
|
76 |
$field .= PHP_EOL;
|
77 |
+
$field .= $this->get_checkbox_html(
|
78 |
+
array(
|
79 |
+
'class' => 'form-row form-row-wide',
|
80 |
+
)
|
81 |
+
);
|
82 |
return $field;
|
83 |
}
|
84 |
|
85 |
+
/**
|
86 |
+
* @param int $order_id
|
87 |
+
*/
|
88 |
+
public function save_woocommerce_checkout_checkbox_value( $order_id ) {
|
89 |
+
update_post_meta( $order_id, '_mc4wp_optin', $this->checkbox_was_checked() );
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* {@inheritdoc}
|
94 |
+
*
|
95 |
+
* @param $order_id
|
96 |
+
*
|
97 |
+
* @return bool|mixed
|
98 |
+
*/
|
99 |
+
public function triggered( $order_id = null ) {
|
100 |
+
if ( $this->options['implicit'] ) {
|
101 |
+
return true;
|
102 |
+
}
|
103 |
+
|
104 |
+
if ( ! $order_id ) {
|
105 |
+
return false;
|
106 |
+
}
|
107 |
+
|
108 |
+
$do_optin = get_post_meta( $order_id, '_mc4wp_optin', true );
|
109 |
+
return $do_optin;
|
110 |
+
}
|
111 |
+
|
112 |
+
public function subscribe_from_klarna_checkout( $order_id, $klarna_order ) {
|
113 |
+
// $klarna_order is the returned object from Klarna
|
114 |
+
if ( false === (bool) $klarna_order['merchant_requested']['additional_checkbox'] ) {
|
115 |
+
return;
|
116 |
+
}
|
117 |
+
|
118 |
+
// get back into regular subscribe flow
|
119 |
+
update_post_meta( $order_id, '_mc4wp_optin', true );
|
120 |
+
$this->subscribe_from_woocommerce_checkout( $order_id );
|
121 |
+
return;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* @param int $order_id
|
126 |
+
* @return boolean
|
127 |
+
*/
|
128 |
+
public function subscribe_from_woocommerce_checkout( $order_id ) {
|
129 |
+
if ( ! $this->triggered( $order_id ) ) {
|
130 |
+
return false;
|
131 |
+
}
|
132 |
+
|
133 |
+
$order = wc_get_order( $order_id );
|
134 |
+
|
135 |
+
if ( method_exists( $order, 'get_billing_email' ) ) {
|
136 |
+
$data = array(
|
137 |
+
'EMAIL' => $order->get_billing_email(),
|
138 |
+
'NAME' => "{$order->get_billing_first_name()} {$order->get_billing_last_name()}",
|
139 |
+
'FNAME' => $order->get_billing_first_name(),
|
140 |
+
'LNAME' => $order->get_billing_last_name(),
|
141 |
+
);
|
142 |
+
} else {
|
143 |
+
// NOTE: for compatibility with WooCommerce < 3.0
|
144 |
+
$data = array(
|
145 |
+
'EMAIL' => $order->billing_email,
|
146 |
+
'NAME' => "{$order->billing_first_name} {$order->billing_last_name}",
|
147 |
+
'FNAME' => $order->billing_first_name,
|
148 |
+
'LNAME' => $order->billing_last_name,
|
149 |
+
);
|
150 |
+
}
|
151 |
+
|
152 |
+
// TODO: add billing address fields, maybe by finding Mailchimp field of type "address"?
|
153 |
+
|
154 |
+
return $this->subscribe( $data, $order_id );
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* @return bool
|
159 |
+
*/
|
160 |
+
public function is_installed() {
|
161 |
+
return class_exists( 'WooCommerce' );
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* {@inheritdoc}
|
166 |
+
*
|
167 |
+
* @return string
|
168 |
+
*/
|
169 |
+
public function get_object_link( $object_id ) {
|
170 |
+
return sprintf( '<a href="%s">%s</a>', get_edit_post_link( $object_id ), sprintf( __( 'Order #%d', 'mailchimp-for-wp' ), $object_id ) );
|
171 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
}
|
integrations/wp-comment-form/class-comment-form.php
CHANGED
@@ -1,122 +1,116 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Comment_Form_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_Comment_Form_Integration extends MC4WP_Integration
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
if (! $comment) {
|
117 |
-
return '';
|
118 |
-
}
|
119 |
-
|
120 |
-
return sprintf('<a href="%s">Comment #%d</a>', get_edit_comment_link($object_id), $object_id);
|
121 |
-
}
|
122 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Comment_Form_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_Comment_Form_Integration extends MC4WP_Integration {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var bool
|
15 |
+
*/
|
16 |
+
protected $added_through_filter = false;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $name = 'Comment Form';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
public $description = 'Subscribes people from your WordPress comment form.';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Add hooks
|
30 |
+
*/
|
31 |
+
public function add_hooks() {
|
32 |
+
if ( ! $this->options['implicit'] ) {
|
33 |
+
// hooks for outputting the checkbox
|
34 |
+
add_filter( 'comment_form_submit_field', array( $this, 'add_checkbox_before_submit_button' ), 90 );
|
35 |
+
|
36 |
+
add_action( 'thesis_hook_after_comment_box', array( $this, 'maybe_output_checkbox' ), 90 );
|
37 |
+
add_action( 'comment_form', array( $this, 'maybe_output_checkbox' ), 90 );
|
38 |
+
}
|
39 |
+
|
40 |
+
// hooks for checking if we should subscribe the commenter
|
41 |
+
add_action( 'comment_post', array( $this, 'subscribe_from_comment' ), 40, 2 );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* This adds the checkbox just before the submit button and sets a flag to prevent it from outputting twice
|
46 |
+
*
|
47 |
+
* @param $submit_button_html
|
48 |
+
*
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
public function add_checkbox_before_submit_button( $submit_button_html ) {
|
52 |
+
$this->added_through_filter = true;
|
53 |
+
return $this->get_checkbox_html() . $submit_button_html;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Output fallback
|
58 |
+
* Will output the checkbox if comment_form() function does not use `comment_form_submit_field` filter yet.
|
59 |
+
*/
|
60 |
+
public function maybe_output_checkbox() {
|
61 |
+
if ( ! $this->added_through_filter ) {
|
62 |
+
$this->output_checkbox();
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Grabs data from WP Comment Form
|
68 |
+
*
|
69 |
+
* @param int $comment_id
|
70 |
+
* @param string $comment_approved
|
71 |
+
*
|
72 |
+
* @return bool|string
|
73 |
+
*/
|
74 |
+
public function subscribe_from_comment( $comment_id, $comment_approved = '' ) {
|
75 |
+
|
76 |
+
// was sign-up checkbox checked?
|
77 |
+
if ( ! $this->triggered() ) {
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
|
81 |
+
// is this a spam comment?
|
82 |
+
if ( $comment_approved === 'spam' ) {
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
|
86 |
+
$comment = get_comment( $comment_id );
|
87 |
+
|
88 |
+
$data = array(
|
89 |
+
'EMAIL' => $comment->comment_author_email,
|
90 |
+
'NAME' => $comment->comment_author,
|
91 |
+
'OPTIN_IP' => $comment->comment_author_IP,
|
92 |
+
);
|
93 |
+
|
94 |
+
return $this->subscribe( $data, $comment_id );
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @return bool
|
99 |
+
*/
|
100 |
+
public function is_installed() {
|
101 |
+
return true;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* {@inheritdoc }
|
106 |
+
*/
|
107 |
+
public function get_object_link( $object_id ) {
|
108 |
+
$comment = get_comment( $object_id );
|
109 |
+
|
110 |
+
if ( ! $comment ) {
|
111 |
+
return '';
|
112 |
+
}
|
113 |
+
|
114 |
+
return sprintf( '<a href="%s">Comment #%d</a>', get_edit_comment_link( $object_id ), $object_id );
|
115 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
integrations/wp-registration-form/class-registration-form.php
CHANGED
@@ -1,97 +1,93 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Registration_Form_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_Registration_Form_Integration extends MC4WP_User_Integration
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
public function is_installed()
|
94 |
-
{
|
95 |
-
return true;
|
96 |
-
}
|
97 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_Registration_Form_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_Registration_Form_Integration extends MC4WP_User_Integration {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $name = 'Registration Form';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $description = 'Subscribes people from your WordPress registration form.';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var bool
|
25 |
+
*/
|
26 |
+
public $shown = false;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Add hooks
|
30 |
+
*/
|
31 |
+
public function add_hooks() {
|
32 |
+
if ( ! $this->options['implicit'] ) {
|
33 |
+
add_action( 'login_head', array( $this, 'print_css_reset' ) );
|
34 |
+
add_action( 'um_after_register_fields', array( $this, 'maybe_output_checkbox' ), 20 );
|
35 |
+
add_action( 'register_form', array( $this, 'maybe_output_checkbox' ), 20 );
|
36 |
+
add_action( 'woocommerce_register_form', array( $this, 'maybe_output_checkbox' ), 20 );
|
37 |
+
}
|
38 |
+
|
39 |
+
add_action( 'um_user_register', array( $this, 'subscribe_from_registration' ), 90, 1 );
|
40 |
+
add_action( 'user_register', array( $this, 'subscribe_from_registration' ), 90, 1 );
|
41 |
+
|
42 |
+
if ( defined( 'um_plugin' ) && class_exists( 'UM' ) ) {
|
43 |
+
$this->name = 'UltimateMember';
|
44 |
+
$this->description = 'Subscribes people from your UltimateMember registration form.';
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Output checkbox, once.
|
50 |
+
*/
|
51 |
+
public function maybe_output_checkbox() {
|
52 |
+
if ( ! $this->shown ) {
|
53 |
+
$this->output_checkbox();
|
54 |
+
$this->shown = true;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Subscribes from WP Registration Form
|
60 |
+
*
|
61 |
+
* @param int $user_id
|
62 |
+
*
|
63 |
+
* @return bool|string
|
64 |
+
*/
|
65 |
+
public function subscribe_from_registration( $user_id ) {
|
66 |
+
|
67 |
+
// was sign-up checkbox checked?
|
68 |
+
if ( ! $this->triggered() ) {
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
|
72 |
+
// gather emailadress from user who WordPress registered
|
73 |
+
$user = get_userdata( $user_id );
|
74 |
+
|
75 |
+
// was a user found with the given ID?
|
76 |
+
if ( ! $user instanceof WP_User ) {
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
+
$data = $this->user_merge_vars( $user );
|
81 |
+
|
82 |
+
return $this->subscribe( $data, $user_id );
|
83 |
+
}
|
84 |
+
/* End registration form functions */
|
85 |
+
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @return bool
|
89 |
+
*/
|
90 |
+
public function is_installed() {
|
91 |
+
return true;
|
92 |
+
}
|
|
|
|
|
|
|
|
|
93 |
}
|
integrations/wpforms/admin-before.php
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
<p>
|
2 |
-
<?php printf(__('Use this integration by adding the "Mailchimp" field to <a href="%s">your WPForms forms</a>.', 'mailchimp-for-wp'), admin_url('admin.php?page=wpforms-overview')); ?>
|
3 |
-
</p>
|
1 |
<p>
|
2 |
+
<?php printf( __( 'Use this integration by adding the "Mailchimp" field to <a href="%s">your WPForms forms</a>.', 'mailchimp-for-wp' ), admin_url( 'admin.php?page=wpforms-overview' ) ); ?>
|
3 |
+
</p>
|
integrations/wpforms/bootstrap.php
CHANGED
@@ -1,14 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
mc4wp_register_integration('wpforms', 'MC4WP_WPForms_Integration', true);
|
4 |
|
5 |
-
function _mc4wp_wpforms_register_field()
|
6 |
-
{
|
7 |
-
|
8 |
-
|
9 |
-
}
|
10 |
|
11 |
-
|
12 |
}
|
13 |
|
14 |
-
add_action('init', '_mc4wp_wpforms_register_field');
|
1 |
<?php
|
2 |
|
3 |
+
mc4wp_register_integration( 'wpforms', 'MC4WP_WPForms_Integration', true );
|
4 |
|
5 |
+
function _mc4wp_wpforms_register_field() {
|
6 |
+
if ( ! class_exists( 'WPForms_Field' ) ) {
|
7 |
+
return;
|
8 |
+
}
|
|
|
9 |
|
10 |
+
new MC4WP_WPForms_Field();
|
11 |
}
|
12 |
|
13 |
+
add_action( 'init', '_mc4wp_wpforms_register_field' );
|
integrations/wpforms/class-field.php
CHANGED
@@ -9,267 +9,253 @@
|
|
9 |
* @license GPL-2.0+
|
10 |
* @copyright Copyright (c) 2016, WPForms LLC
|
11 |
*/
|
12 |
-
class MC4WP_WPForms_Field extends WPForms_Field
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
$field = $form_data['fields'][$field_id];
|
262 |
-
$choice = array_pop($field['choices']);
|
263 |
-
$name = sanitize_text_field($choice['label']);
|
264 |
-
|
265 |
-
$data = array(
|
266 |
-
'name' => $name,
|
267 |
-
'value' => empty($field_submit) ? __('No') : __('Yes'),
|
268 |
-
'value_raw' => $field_submit,
|
269 |
-
'id' => absint($field_id),
|
270 |
-
'type' => $this->type,
|
271 |
-
);
|
272 |
-
|
273 |
-
wpforms()->process->fields[$field_id] = $data;
|
274 |
-
}
|
275 |
}
|
9 |
* @license GPL-2.0+
|
10 |
* @copyright Copyright (c) 2016, WPForms LLC
|
11 |
*/
|
12 |
+
class MC4WP_WPForms_Field extends WPForms_Field {
|
13 |
+
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Primary class constructor.
|
17 |
+
*
|
18 |
+
* @since 1.0.0
|
19 |
+
*/
|
20 |
+
public function init() {
|
21 |
+
|
22 |
+
// Define field type information
|
23 |
+
$this->name = 'Mailchimp';
|
24 |
+
$this->type = 'mailchimp';
|
25 |
+
$this->icon = 'fa-envelope-o';
|
26 |
+
$this->order = 21;
|
27 |
+
$this->defaults = array(
|
28 |
+
0 => array(
|
29 |
+
'label' => __( 'Sign-up to our newsletter?', 'mailchimp-for-wp' ),
|
30 |
+
'value' => '1',
|
31 |
+
'default' => '',
|
32 |
+
),
|
33 |
+
);
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Field options panel inside the builder.
|
38 |
+
*
|
39 |
+
* @since 1.0.0
|
40 |
+
* @param array $field
|
41 |
+
*/
|
42 |
+
public function field_options( $field ) {
|
43 |
+
|
44 |
+
//--------------------------------------------------------------------//
|
45 |
+
// Basic field options
|
46 |
+
//--------------------------------------------------------------------//
|
47 |
+
|
48 |
+
// Options open markup
|
49 |
+
$this->field_option( 'basic-options', $field, array( 'markup' => 'open' ) );
|
50 |
+
|
51 |
+
// Mailchimp list
|
52 |
+
$this->field_option_mailchimp_list( $field );
|
53 |
+
|
54 |
+
// Choices
|
55 |
+
$this->field_option_choices( $field );
|
56 |
+
|
57 |
+
// Description
|
58 |
+
$this->field_option( 'description', $field );
|
59 |
+
|
60 |
+
// Required toggle
|
61 |
+
$this->field_option( 'required', $field );
|
62 |
+
|
63 |
+
// Options close markup
|
64 |
+
$this->field_option( 'basic-options', $field, array( 'markup' => 'close' ) );
|
65 |
+
|
66 |
+
//--------------------------------------------------------------------//
|
67 |
+
// Advanced field options
|
68 |
+
//--------------------------------------------------------------------//
|
69 |
+
|
70 |
+
// Options open markup
|
71 |
+
$this->field_option( 'advanced-options', $field, array( 'markup' => 'open' ) );
|
72 |
+
|
73 |
+
// Custom CSS classes
|
74 |
+
$this->field_option( 'css', $field );
|
75 |
+
|
76 |
+
// Options close markup
|
77 |
+
$this->field_option( 'advanced-options', $field, array( 'markup' => 'close' ) );
|
78 |
+
}
|
79 |
+
|
80 |
+
private function field_option_mailchimp_list( $field ) {
|
81 |
+
$mailchimp = new MC4WP_MailChimp();
|
82 |
+
|
83 |
+
// Field option label
|
84 |
+
$tooltip = __( 'Select the Mailchimp list to subscribe to.', 'mailchimp-for-wp' );
|
85 |
+
$option_label = $this->field_element(
|
86 |
+
'label',
|
87 |
+
$field,
|
88 |
+
array(
|
89 |
+
'slug' => 'mailchimp-list',
|
90 |
+
'value' => __( 'Mailchimp list', 'mailchimp-for-wp' ),
|
91 |
+
'tooltip' => $tooltip,
|
92 |
+
),
|
93 |
+
false
|
94 |
+
);
|
95 |
+
|
96 |
+
$option_select = sprintf( '<select name="fields[%s][mailchimp_list]" data-field-id="%d" data-field-type="%s">', $field['id'], $field['id'], $this->type );
|
97 |
+
$lists = $mailchimp->get_lists();
|
98 |
+
foreach ( $lists as $list ) {
|
99 |
+
$option_select .= sprintf( '<option value="%s" %s>%s</option>', $list->id, selected( $list->id, $field['mailchimp_list'], false ), $list->name );
|
100 |
+
}
|
101 |
+
$option_select .= '</select>';
|
102 |
+
|
103 |
+
// Field option row (markup) including label and input.
|
104 |
+
$output = $this->field_element(
|
105 |
+
'row',
|
106 |
+
$field,
|
107 |
+
array(
|
108 |
+
'slug' => 'mailchimp-list',
|
109 |
+
'content' => $option_label . $option_select,
|
110 |
+
)
|
111 |
+
);
|
112 |
+
}
|
113 |
+
|
114 |
+
private function field_option_choices( $field ) {
|
115 |
+
$tooltip = __( 'Set your sign-up label text and whether it should be pre-checked.', 'mailchimp-for-wp' );
|
116 |
+
$values = ! empty( $field['choices'] ) ? $field['choices'] : $this->defaults;
|
117 |
+
$class = ! empty( $field['show_values'] ) && (int) $field['show_values'] === 1 ? 'show-values' : '';
|
118 |
+
$class .= ! empty( $dynamic ) ? ' wpforms-hidden' : '';
|
119 |
+
|
120 |
+
// Field option label
|
121 |
+
$option_label = $this->field_element(
|
122 |
+
'label',
|
123 |
+
$field,
|
124 |
+
array(
|
125 |
+
'slug' => 'mailchimp-checkbox',
|
126 |
+
'value' => __( 'Sign-up checkbox', 'mailchimp-for-wp' ),
|
127 |
+
'tooltip' => $tooltip,
|
128 |
+
),
|
129 |
+
false
|
130 |
+
);
|
131 |
+
|
132 |
+
// Field option choices inputs
|
133 |
+
$option_choices = sprintf( '<ul class="choices-list %s" data-field-id="%d" data-field-type="%s">', $class, $field['id'], $this->type );
|
134 |
+
foreach ( $values as $key => $value ) {
|
135 |
+
$default = ! empty( $value['default'] ) ? $value['default'] : '';
|
136 |
+
$option_choices .= sprintf( '<li data-key="%d">', $key );
|
137 |
+
$option_choices .= sprintf( '<input type="checkbox" name="fields[%s][choices][%s][default]" class="default" value="1" %s>', $field['id'], $key, checked( '1', $default, false ) );
|
138 |
+
$option_choices .= sprintf( '<input type="text" name="fields[%s][choices][%s][label]" value="%s" class="label">', $field['id'], $key, esc_attr( $value['label'] ) );
|
139 |
+
$option_choices .= sprintf( '<input type="text" name="fields[%s][choices][%s][value]" value="%s" class="value">', $field['id'], $key, esc_attr( $value['value'] ) );
|
140 |
+
$option_choices .= '</li>';
|
141 |
+
}
|
142 |
+
$option_choices .= '</ul>';
|
143 |
+
|
144 |
+
// Field option row (markup) including label and input.
|
145 |
+
$output = $this->field_element(
|
146 |
+
'row',
|
147 |
+
$field,
|
148 |
+
array(
|
149 |
+
'slug' => 'choices',
|
150 |
+
'content' => $option_label . $option_choices,
|
151 |
+
)
|
152 |
+
);
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Field preview inside the builder.
|
157 |
+
*
|
158 |
+
* @since 1.0.0
|
159 |
+
* @param array $field
|
160 |
+
*/
|
161 |
+
public function field_preview( $field ) {
|
162 |
+
$values = ! empty( $field['choices'] ) ? $field['choices'] : $this->defaults;
|
163 |
+
|
164 |
+
// Field checkbox elements
|
165 |
+
echo '<ul class="primary-input">';
|
166 |
+
|
167 |
+
// Notify if currently empty
|
168 |
+
if ( empty( $values ) ) {
|
169 |
+
$values = array( 'label' => __( '(empty)', 'wpforms' ) );
|
170 |
+
}
|
171 |
+
|
172 |
+
// Individual checkbox options
|
173 |
+
foreach ( $values as $key => $value ) {
|
174 |
+
$default = isset( $value['default'] ) ? $value['default'] : '';
|
175 |
+
$selected = checked( '1', $default, false );
|
176 |
+
|
177 |
+
printf( '<li><input type="checkbox" %s disabled>%s</li>', $selected, $value['label'] );
|
178 |
+
}
|
179 |
+
|
180 |
+
echo '</ul>';
|
181 |
+
|
182 |
+
// Dynamic population is enabled and contains more than 20 items
|
183 |
+
if ( isset( $total ) && $total > 20 ) {
|
184 |
+
echo '<div class="wpforms-alert-dynamic wpforms-alert wpforms-alert-warning">';
|
185 |
+
printf( __( 'Showing the first 20 choices.<br> All %d choices will be displayed when viewing the form.', 'wpforms' ), absint( $total ) );
|
186 |
+
echo '</div>';
|
187 |
+
}
|
188 |
+
|
189 |
+
// Description
|
190 |
+
$this->field_preview_option( 'description', $field );
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Field display on the form front-end.
|
195 |
+
*
|
196 |
+
* @since 1.0.0
|
197 |
+
* @param array $field
|
198 |
+
* @param array $form_data
|
199 |
+
*/
|
200 |
+
public function field_display( $field, $field_atts, $form_data ) {
|
201 |
+
|
202 |
+
// Setup and sanitize the necessary data
|
203 |
+
$field_required = ! empty( $field['required'] ) ? ' required' : '';
|
204 |
+
$field_class = implode( ' ', array_map( 'sanitize_html_class', $field_atts['input_class'] ) );
|
205 |
+
$field_id = implode( ' ', array_map( 'sanitize_html_class', $field_atts['input_id'] ) );
|
206 |
+
$form_id = $form_data['id'];
|
207 |
+
$choices = $field['choices'];
|
208 |
+
|
209 |
+
// List
|
210 |
+
printf( '<ul id="%s" class="%s">', $field_id, $field_class );
|
211 |
+
|
212 |
+
foreach ( $choices as $key => $choice ) {
|
213 |
+
$selected = isset( $choice['default'] ) ? '1' : '0';
|
214 |
+
$depth = isset( $choice['depth'] ) ? absint( $choice['depth'] ) : 1;
|
215 |
+
|
216 |
+
printf( '<li class="choice-%d depth-%d">', $key, $depth );
|
217 |
+
|
218 |
+
// Checkbox elements
|
219 |
+
printf(
|
220 |
+
'<input type="checkbox" id="wpforms-%d-field_%d_%d" name="wpforms[fields][%d]" value="%s" %s %s>',
|
221 |
+
$form_id,
|
222 |
+
$field['id'],
|
223 |
+
$key,
|
224 |
+
$field['id'],
|
225 |
+
esc_attr( $choice['value'] ),
|
226 |
+
checked( '1', $selected, false ),
|
227 |
+
$field_required
|
228 |
+
);
|
229 |
+
|
230 |
+
printf( '<label class="wpforms-field-label-inline" for="wpforms-%d-field_%d_%d">%s</label>', $form_id, $field['id'], $key, wp_kses_post( $choice['label'] ) );
|
231 |
+
|
232 |
+
echo '</li>';
|
233 |
+
}
|
234 |
+
|
235 |
+
echo '</ul>';
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Formats and sanitizes field.
|
240 |
+
*
|
241 |
+
* @since 1.0.2
|
242 |
+
* @param int $field_id
|
243 |
+
* @param array $field_submit
|
244 |
+
* @param array $form_data
|
245 |
+
*/
|
246 |
+
public function format( $field_id, $field_submit, $form_data ) {
|
247 |
+
$field = $form_data['fields'][ $field_id ];
|
248 |
+
$choice = array_pop( $field['choices'] );
|
249 |
+
$name = sanitize_text_field( $choice['label'] );
|
250 |
+
|
251 |
+
$data = array(
|
252 |
+
'name' => $name,
|
253 |
+
'value' => empty( $field_submit ) ? __( 'No', 'mailchimp-for-wp' ) : __( 'Yes', 'mailchimp-for-wp' ),
|
254 |
+
'value_raw' => $field_submit,
|
255 |
+
'id' => absint( $field_id ),
|
256 |
+
'type' => $this->type,
|
257 |
+
);
|
258 |
+
|
259 |
+
wpforms()->process->fields[ $field_id ] = $data;
|
260 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
}
|
integrations/wpforms/class-wpforms.php
CHANGED
@@ -1,82 +1,76 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
defined('ABSPATH') or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_WPForms_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
-
class MC4WP_WPForms_Integration extends MC4WP_Integration
|
11 |
-
{
|
12 |
|
13 |
-
/**
|
14 |
-
* @var string
|
15 |
-
*/
|
16 |
-
public $name = "WPForms";
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
/**
|
25 |
-
* Add hooks
|
26 |
-
*/
|
27 |
-
public function add_hooks()
|
28 |
-
{
|
29 |
-
add_action('wpforms_process', array( $this, 'listen_to_wpforms' ), 20, 3);
|
30 |
-
}
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
}
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
return array();
|
47 |
-
}
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
}
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
}
|
72 |
-
}
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
82 |
}
|
1 |
<?php
|
2 |
|
3 |
+
defined( 'ABSPATH' ) or exit;
|
4 |
|
5 |
/**
|
6 |
* Class MC4WP_WPForms_Integration
|
7 |
*
|
8 |
* @ignore
|
9 |
*/
|
10 |
+
class MC4WP_WPForms_Integration extends MC4WP_Integration {
|
|
|
11 |
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
public $name = 'WPForms';
|
17 |
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $description = 'Subscribe visitors from your WPForms forms.';
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
/**
|
25 |
+
* Add hooks
|
26 |
+
*/
|
27 |
+
public function add_hooks() {
|
28 |
+
add_action( 'wpforms_process', array( $this, 'listen_to_wpforms' ), 20, 3 );
|
29 |
+
}
|
|
|
30 |
|
31 |
+
/**
|
32 |
+
* @return bool
|
33 |
+
*/
|
34 |
+
public function is_installed() {
|
35 |
+
return defined( 'WPFORMS_VERSION' );
|
36 |
+
}
|
|
|
|
|
37 |
|
38 |
+
/**
|
39 |
+
* @since 3.0
|
40 |
+
* @return array
|
41 |
+
*/
|
42 |
+
public function get_ui_elements() {
|
43 |
+
return array();
|
44 |
+
}
|
|
|
45 |
|
46 |
+
public function listen_to_wpforms( $fields, $entry, $form_data ) {
|
47 |
+
foreach ( $fields as $field_id => $field ) {
|
48 |
+
if ( $field['type'] === 'mailchimp' && (int) $field['value_raw'] === 1 ) {
|
49 |
+
return $this->subscribe_from_wpforms( $field_id, $fields, $form_data );
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
|
54 |
+
public function subscribe_from_wpforms( $checkbox_field_id, $fields, $form_data ) {
|
55 |
+
foreach ( $fields as $field ) {
|
56 |
+
if ( $field['type'] === 'email' ) {
|
57 |
+
$email_address = $field['value'];
|
58 |
+
}
|
59 |
+
}
|
60 |
|
61 |
+
$mailchimp_list_id = $form_data['fields'][ $checkbox_field_id ]['mailchimp_list'];
|
62 |
+
$this->options['lists'] = array( $mailchimp_list_id );
|
|
|
|
|
63 |
|
64 |
+
if ( ! empty( $email_address ) ) {
|
65 |
+
return $this->subscribe( array( 'EMAIL' => $email_address ), $form_data['id'] );
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @param int $form_id
|
71 |
+
* @return string
|
72 |
+
*/
|
73 |
+
public function get_object_link( $form_id ) {
|
74 |
+
return '<a href="' . admin_url( sprintf( 'admin.php?page=wpforms-builder&view=fields&form_id=%d', $form_id ) ) . '">WPForms</a>';
|
75 |
+
}
|
76 |
}
|
languages/index.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Do not put custom translations here as they will be overwritten during plugin updates.
|
5 |
+
*
|
6 |
+
* @see https://translate.wordpress.org/projects/wp-plugins/mailchimp-for-wp/stable/
|
7 |
+
*/
|
languages/mailchimp-for-wp-af_ZA.mo
DELETED
Binary file
|
languages/mailchimp-for-wp-af_ZA.po
DELETED
@@ -1,1634 +0,0 @@
|
|
1 |
-
# Copyright (C) 2014 Danny van Kooten
|
2 |
-
# This file is distributed under the GPL v3.
|
3 |
-
# Translators:
|
4 |
-
msgid ""
|
5 |
-
msgstr ""
|
6 |
-
"Project-Id-Version: Mailchimp for WordPress\n"
|
7 |
-
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/mailchimp-for-wp\n"
|
8 |
-
"POT-Creation-Date: 2014-12-09 19:20:27+00:00\n"
|
9 |
-
"PO-Revision-Date: 2014-12-09 19:20+0000\n"
|
10 |
-
"Last-Translator: Danny van Kooten <dannyvankooten@gmail.com>\n"
|
11 |
-
"Language-Team: Afrikaans (South Africa) (http://www.transifex.com/projects/p/mailchimp-for-wordpress/language/af_ZA/)\n"
|
12 |
-
"MIME-Version: 1.0\n"
|
13 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
-
"Content-Transfer-Encoding: 8bit\n"
|
15 |
-
"Language: af_ZA\n"
|
16 |
-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
17 |
-
"X-Generator: grunt-wp-i18n 0.4.4\n"
|
18 |
-
"X-Poedit-Basepath: .\n"
|
19 |
-
"X-Poedit-Bookmarks: \n"
|
20 |
-
"X-Poedit-Country: UNITED STATES\n"
|
21 |
-
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2; _nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__; esc_html__;esc_attr_e; esc_html_e;esc_attr_x:1,2c; esc_html_x:1,2c;\n"
|
22 |
-
"X-Poedit-Language: English\n"
|
23 |
-
"X-Poedit-SearchPath-0: .\n"
|
24 |
-
"X-Poedit-SourceCharset: utf-8\n"
|
25 |
-
"X-Textdomain-Support: yes\n"
|
26 |
-
|
27 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:130
|
28 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:185
|
29 |
-
msgid "Settings"
|
30 |
-
msgstr ""
|
31 |
-
|
32 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:149
|
33 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:163
|
34 |
-
msgid "Upgrade to Pro"
|
35 |
-
msgstr ""
|
36 |
-
|
37 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:160
|
38 |
-
#: mailchimp-for-wordpress/includes/views/api-settings.php:12
|
39 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:106
|
40 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:10
|
41 |
-
msgid "Mailchimp Settings"
|
42 |
-
msgstr ""
|
43 |
-
|
44 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:161
|
45 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:572
|
46 |
-
msgid "Checkboxes"
|
47 |
-
msgstr ""
|
48 |
-
|
49 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:162
|
50 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:573
|
51 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-form-settings.php:10
|
52 |
-
msgid "Forms"
|
53 |
-
msgstr ""
|
54 |
-
|
55 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:299
|
56 |
-
msgid "This option is only available in Mailchimp for WordPress Pro."
|
57 |
-
msgstr ""
|
58 |
-
|
59 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:313
|
60 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:671
|
61 |
-
msgid "Comment form"
|
62 |
-
msgstr ""
|
63 |
-
|
64 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:314
|
65 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:672
|
66 |
-
msgid "Registration form"
|
67 |
-
msgstr ""
|
68 |
-
|
69 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:318
|
70 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:676
|
71 |
-
msgid "MultiSite forms"
|
72 |
-
msgstr ""
|
73 |
-
|
74 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:322
|
75 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:680
|
76 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:231
|
77 |
-
msgid "BuddyPress registration"
|
78 |
-
msgstr ""
|
79 |
-
|
80 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:330
|
81 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:334
|
82 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:688
|
83 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:692
|
84 |
-
msgid "%s checkout"
|
85 |
-
msgstr ""
|
86 |
-
|
87 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:363
|
88 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:738
|
89 |
-
msgid "Renewed Mailchimp cache."
|
90 |
-
msgstr ""
|
91 |
-
|
92 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:365
|
93 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:740
|
94 |
-
msgid "Failed to renew Mailchimp cache - please try again later."
|
95 |
-
msgstr ""
|
96 |
-
|
97 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:398
|
98 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:313
|
99 |
-
msgid "An EMAIL field. Example: <code>%s</code>"
|
100 |
-
msgstr ""
|
101 |
-
|
102 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:404
|
103 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:319
|
104 |
-
msgid "A submit button. Example: <code>%s</code>"
|
105 |
-
msgstr ""
|
106 |
-
|
107 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:404
|
108 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:319
|
109 |
-
msgid "Sign Up"
|
110 |
-
msgstr ""
|
111 |
-
|
112 |
-
#: mailchimp-for-wordpress/includes/class-admin.php:429
|
113 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:347
|
114 |
-
msgid "A '%s' field"
|
115 |
-
msgstr ""
|
116 |
-
|
117 |
-
#: mailchimp-for-wordpress/includes/class-form-request.php:675
|
118 |
-
msgid "Please select at least one list to subscribe to."
|
119 |
-
msgstr ""
|
120 |
-
|
121 |
-
#: mailchimp-for-wordpress/includes/class-widget.php:20
|
122 |
-
msgid "Mailchimp Sign-Up Form"
|
123 |
-
msgstr ""
|
124 |
-
|
125 |
-
#: mailchimp-for-wordpress/includes/class-widget.php:21
|
126 |
-
msgid "Displays your Mailchimp for WordPress sign-up form"
|
127 |
-
msgstr ""
|
128 |
-
|
129 |
-
#: mailchimp-for-wordpress/includes/class-widget.php:62
|
130 |
-
#: mailchimp-for-wordpress-pro/includes/class-widget.php:69
|
131 |
-
msgid "Newsletter"
|
132 |
-
msgstr ""
|
133 |
-
|
134 |
-
#: mailchimp-for-wordpress/includes/class-widget.php:65
|
135 |
-
#: mailchimp-for-wordpress-pro/includes/class-widget.php:80
|
136 |
-
msgid "Title:"
|
137 |
-
msgstr ""
|
138 |
-
|
139 |
-
#: mailchimp-for-wordpress/includes/class-widget.php:69
|
140 |
-
msgid ""
|
141 |
-
"You can edit your sign-up form in the %sMailchimp for WordPress form "
|
142 |
-
"settings%s."
|
143 |
-
msgstr ""
|
144 |
-
|
145 |
-
#: mailchimp-for-wordpress/includes/functions/general.php:21
|
146 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:285
|
147 |
-
#: mailchimp-for-wordpress-pro/includes/class-mailchimp.php:135
|
148 |
-
msgid "Email address"
|
149 |
-
msgstr ""
|
150 |
-
|
151 |
-
#: mailchimp-for-wordpress/includes/functions/general.php:22
|
152 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:284
|
153 |
-
msgid "Your email address"
|
154 |
-
msgstr ""
|
155 |
-
|
156 |
-
#: mailchimp-for-wordpress/includes/functions/general.php:23
|
157 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:286
|
158 |
-
msgid "Sign up"
|
159 |
-
msgstr ""
|
160 |
-
|
161 |
-
#: mailchimp-for-wordpress/includes/functions/general.php:30
|
162 |
-
#: mailchimp-for-wordpress-pro/includes/functions/general.php:27
|
163 |
-
msgid "Sign me up for the newsletter!"
|
164 |
-
msgstr ""
|
165 |
-
|
166 |
-
#: mailchimp-for-wordpress/includes/functions/general.php:47
|
167 |
-
msgid ""
|
168 |
-
"Thank you, your sign-up request was successful! Please check your e-mail "
|
169 |
-
"inbox."
|
170 |
-
msgstr ""
|
171 |
-
|
172 |
-
#: mailchimp-for-wordpress/includes/functions/general.php:48
|
173 |
-
#: mailchimp-for-wordpress-pro/includes/functions/general.php:51
|
174 |
-
msgid "Oops. Something went wrong. Please try again later."
|
175 |
-
msgstr ""
|
176 |
-
|
177 |
-
#: mailchimp-for-wordpress/includes/functions/general.php:49
|
178 |
-
#: mailchimp-for-wordpress-pro/includes/functions/general.php:52
|
179 |
-
msgid "Please provide a valid email address."
|
180 |
-
msgstr ""
|
181 |
-
|
182 |
-
#: mailchimp-for-wordpress/includes/functions/general.php:50
|
183 |
-
#: mailchimp-for-wordpress-pro/includes/functions/general.php:53
|
184 |
-
msgid "Given email address is already subscribed, thank you!"
|
185 |
-
msgstr ""
|
186 |
-
|
187 |
-
#: mailchimp-for-wordpress/includes/functions/general.php:51
|
188 |
-
#: mailchimp-for-wordpress-pro/includes/functions/general.php:54
|
189 |
-
msgid "Please complete the CAPTCHA."
|
190 |
-
msgstr ""
|
191 |
-
|
192 |
-
#: mailchimp-for-wordpress/includes/functions/general.php:52
|
193 |
-
#: mailchimp-for-wordpress-pro/includes/functions/general.php:55
|
194 |
-
msgid "Please fill in the required fields."
|
195 |
-
msgstr ""
|
196 |
-
|
197 |
-
#: mailchimp-for-wordpress/includes/integrations/class-cf7.php:44
|
198 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:52
|
199 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:91
|
200 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:96
|
201 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:113
|
202 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:126
|
203 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:136
|
204 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:147
|
205 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:166
|
206 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:180
|
207 |
-
#: mailchimp-for-wordpress-pro/includes/integrations/class-cf7.php:44
|
208 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:17
|
209 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:37
|
210 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:56
|
211 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:75
|
212 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:98
|
213 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:116
|
214 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:139
|
215 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:52
|
216 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:60
|
217 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:99
|
218 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:104
|
219 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:59
|
220 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:72
|
221 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:82
|
222 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:97
|
223 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:115
|
224 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:123
|
225 |
-
msgid "Yes"
|
226 |
-
msgstr ""
|
227 |
-
|
228 |
-
#: mailchimp-for-wordpress/includes/integrations/class-cf7.php:44
|
229 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:56
|
230 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:91
|
231 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:96
|
232 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:27
|
233 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:117
|
234 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:128
|
235 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:138
|
236 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:151
|
237 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:170
|
238 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:184
|
239 |
-
#: mailchimp-for-wordpress-pro/includes/integrations/class-cf7.php:44
|
240 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:21
|
241 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:41
|
242 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:60
|
243 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:79
|
244 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:102
|
245 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:120
|
246 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:140
|
247 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:52
|
248 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:62
|
249 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:99
|
250 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:104
|
251 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:22
|
252 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:63
|
253 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:73
|
254 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:86
|
255 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:101
|
256 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:116
|
257 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:124
|
258 |
-
msgid "No"
|
259 |
-
msgstr ""
|
260 |
-
|
261 |
-
#: mailchimp-for-wordpress/includes/integrations/class-integration.php:212
|
262 |
-
#: mailchimp-for-wordpress/includes/integrations/class-integration.php:215
|
263 |
-
#: mailchimp-for-wordpress/includes/integrations/class-integration.php:293
|
264 |
-
#: mailchimp-for-wordpress/includes/integrations/class-integration.php:302
|
265 |
-
msgid "Mailchimp for WordPress - Error"
|
266 |
-
msgstr ""
|
267 |
-
|
268 |
-
#: mailchimp-for-wordpress/includes/integrations/class-integration.php:213
|
269 |
-
msgid ""
|
270 |
-
"Please select a list to subscribe to in the <a href=\"%s\">checkbox "
|
271 |
-
"settings</a>."
|
272 |
-
msgstr ""
|
273 |
-
|
274 |
-
#: mailchimp-for-wordpress/includes/integrations/class-integration.php:214
|
275 |
-
#: mailchimp-for-wordpress/includes/integrations/class-integration.php:301
|
276 |
-
msgid "This message is only visible to administrators for debugging purposes."
|
277 |
-
msgstr ""
|
278 |
-
|
279 |
-
#: mailchimp-for-wordpress/includes/integrations/class-integration.php:294
|
280 |
-
msgid ""
|
281 |
-
"The Mailchimp server returned the following error message as a response to "
|
282 |
-
"our sign-up request:"
|
283 |
-
msgstr ""
|
284 |
-
|
285 |
-
#: mailchimp-for-wordpress/includes/integrations/class-integration.php:296
|
286 |
-
msgid "This is the data that was sent to Mailchimp:"
|
287 |
-
msgstr ""
|
288 |
-
|
289 |
-
#: mailchimp-for-wordpress/includes/integrations/class-integration.php:297
|
290 |
-
#: mailchimp-for-wordpress-pro/includes/class-form-request.php:638
|
291 |
-
msgid "Email address:"
|
292 |
-
msgstr ""
|
293 |
-
|
294 |
-
#: mailchimp-for-wordpress/includes/integrations/class-integration.php:299
|
295 |
-
msgid "Merge variables:"
|
296 |
-
msgstr ""
|
297 |
-
|
298 |
-
#. Plugin Name of the plugin/theme
|
299 |
-
msgid "Mailchimp for WordPress"
|
300 |
-
msgstr ""
|
301 |
-
|
302 |
-
#: mailchimp-for-wordpress/includes/views/api-settings.php:22
|
303 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-general-settings.php:19
|
304 |
-
msgid "API Settings"
|
305 |
-
msgstr ""
|
306 |
-
|
307 |
-
#: mailchimp-for-wordpress/includes/views/api-settings.php:24
|
308 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-general-settings.php:21
|
309 |
-
msgid "CONNECTED"
|
310 |
-
msgstr ""
|
311 |
-
|
312 |
-
#: mailchimp-for-wordpress/includes/views/api-settings.php:26
|
313 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-general-settings.php:23
|
314 |
-
msgid "NOT CONNECTED"
|
315 |
-
msgstr ""
|
316 |
-
|
317 |
-
#: mailchimp-for-wordpress/includes/views/api-settings.php:32
|
318 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-general-settings.php:29
|
319 |
-
msgid "API Key"
|
320 |
-
msgstr ""
|
321 |
-
|
322 |
-
#: mailchimp-for-wordpress/includes/views/api-settings.php:34
|
323 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-general-settings.php:31
|
324 |
-
msgid "Your Mailchimp API key"
|
325 |
-
msgstr ""
|
326 |
-
|
327 |
-
#: mailchimp-for-wordpress/includes/views/api-settings.php:35
|
328 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-general-settings.php:32
|
329 |
-
msgid "Get your API key here."
|
330 |
-
msgstr ""
|
331 |
-
|
332 |
-
#: mailchimp-for-wordpress/includes/views/api-settings.php:47
|
333 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-general-settings.php:48
|
334 |
-
msgid "Mailchimp Data"
|
335 |
-
msgstr ""
|
336 |
-
|
337 |
-
#: mailchimp-for-wordpress/includes/views/api-settings.php:48
|
338 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-general-settings.php:49
|
339 |
-
msgid ""
|
340 |
-
"The table below shows your Mailchimp lists data. If you applied changes to "
|
341 |
-
"your Mailchimp lists, please use the following button to renew your cached "
|
342 |
-
"data."
|
343 |
-
msgstr ""
|
344 |
-
|
345 |
-
#: mailchimp-for-wordpress/includes/views/api-settings.php:54
|
346 |
-
#: mailchimp-for-wordpress/includes/views/api-settings.php:125
|
347 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-general-settings.php:55
|
348 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-general-settings.php:126
|
349 |
-
msgid "Renew Mailchimp lists"
|
350 |
-
msgstr ""
|
351 |
-
|
352 |
-
#: mailchimp-for-wordpress/includes/views/api-settings.php:112
|
353 |
-
msgid "No lists were found in your Mailchimp account"
|
354 |
-
msgstr ""
|
355 |
-
|
356 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:11
|
357 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:11
|
358 |
-
msgid "Checkbox Settings"
|
359 |
-
msgstr ""
|
360 |
-
|
361 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:16
|
362 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:14
|
363 |
-
msgid ""
|
364 |
-
"To use sign-up checkboxes, select at least one list and one form to add the "
|
365 |
-
"checkbox to."
|
366 |
-
msgstr ""
|
367 |
-
|
368 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:21
|
369 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:21
|
370 |
-
msgid "Mailchimp settings for checkboxes"
|
371 |
-
msgstr ""
|
372 |
-
|
373 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:25
|
374 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:26
|
375 |
-
msgid ""
|
376 |
-
"If you want to use sign-up checkboxes, select at least one Mailchimp list to"
|
377 |
-
" subscribe people to."
|
378 |
-
msgstr ""
|
379 |
-
|
380 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:31
|
381 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:34
|
382 |
-
msgid "Mailchimp Lists"
|
383 |
-
msgstr ""
|
384 |
-
|
385 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:35
|
386 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:48
|
387 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:17
|
388 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:38
|
389 |
-
msgid "No lists found, %sare you connected to Mailchimp?%s"
|
390 |
-
msgstr ""
|
391 |
-
|
392 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:42
|
393 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:45
|
394 |
-
msgid ""
|
395 |
-
"Select the list(s) to which people who check the checkbox should be "
|
396 |
-
"subscribed."
|
397 |
-
msgstr ""
|
398 |
-
|
399 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:48
|
400 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:109
|
401 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:13
|
402 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:51
|
403 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:55
|
404 |
-
msgid "Double opt-in?"
|
405 |
-
msgstr ""
|
406 |
-
|
407 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:59
|
408 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:120
|
409 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:28
|
410 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:53
|
411 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:66
|
412 |
-
msgid ""
|
413 |
-
"Select \"yes\" if you want people to confirm their email address before "
|
414 |
-
"being subscribed (recommended)"
|
415 |
-
msgstr ""
|
416 |
-
|
417 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:63
|
418 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:68
|
419 |
-
msgid "Checkbox settings"
|
420 |
-
msgstr ""
|
421 |
-
|
422 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:67
|
423 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:71
|
424 |
-
msgid "Add the checkbox to these forms"
|
425 |
-
msgstr ""
|
426 |
-
|
427 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:79
|
428 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:78
|
429 |
-
msgid "Selecting a form will automatically add the sign-up checkbox to it."
|
430 |
-
msgstr ""
|
431 |
-
|
432 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:83
|
433 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:91
|
434 |
-
msgid "Checkbox label text"
|
435 |
-
msgstr ""
|
436 |
-
|
437 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:86
|
438 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:94
|
439 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:134
|
440 |
-
msgid "HTML tags like %s are allowed in the label text."
|
441 |
-
msgstr ""
|
442 |
-
|
443 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:90
|
444 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:98
|
445 |
-
msgid "Pre-check the checkbox?"
|
446 |
-
msgstr ""
|
447 |
-
|
448 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:95
|
449 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:103
|
450 |
-
msgid "Load some default CSS?"
|
451 |
-
msgstr ""
|
452 |
-
|
453 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:97
|
454 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:105
|
455 |
-
msgid "Select \"yes\" if the checkbox appears in a weird place."
|
456 |
-
msgstr ""
|
457 |
-
|
458 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:100
|
459 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:108
|
460 |
-
msgid "WooCommerce checkbox position"
|
461 |
-
msgstr ""
|
462 |
-
|
463 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:103
|
464 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:111
|
465 |
-
msgid "After the billing details"
|
466 |
-
msgstr ""
|
467 |
-
|
468 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:104
|
469 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:112
|
470 |
-
msgid "After the additional information"
|
471 |
-
msgstr ""
|
472 |
-
|
473 |
-
#: mailchimp-for-wordpress/includes/views/checkbox-settings.php:107
|
474 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:115
|
475 |
-
msgid ""
|
476 |
-
"Choose the position for the checkbox in your WooCommerce checkout form."
|
477 |
-
msgstr ""
|
478 |
-
|
479 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:9
|
480 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:431
|
481 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:91
|
482 |
-
msgid "Form Settings"
|
483 |
-
msgstr ""
|
484 |
-
|
485 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:15
|
486 |
-
msgid ""
|
487 |
-
"To use the Mailchimp sign-up form, configure the form below and then either "
|
488 |
-
"paste %s in the content of a post or page or use the widget."
|
489 |
-
msgstr ""
|
490 |
-
|
491 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:20
|
492 |
-
msgid "Required form settings"
|
493 |
-
msgstr ""
|
494 |
-
|
495 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:24
|
496 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:19
|
497 |
-
msgid "Load form styles (CSS)?"
|
498 |
-
msgstr ""
|
499 |
-
|
500 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:28
|
501 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:23
|
502 |
-
msgid "Yes, load basic form styles"
|
503 |
-
msgstr ""
|
504 |
-
|
505 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:29
|
506 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:36
|
507 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:20
|
508 |
-
msgid "(PRO ONLY)"
|
509 |
-
msgstr ""
|
510 |
-
|
511 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:29
|
512 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:24
|
513 |
-
msgid "Yes, load my custom form styles"
|
514 |
-
msgstr ""
|
515 |
-
|
516 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:30
|
517 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:25
|
518 |
-
msgid "Yes, load default form theme"
|
519 |
-
msgstr ""
|
520 |
-
|
521 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:31
|
522 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:26
|
523 |
-
msgid "Light Theme"
|
524 |
-
msgstr ""
|
525 |
-
|
526 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:32
|
527 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:27
|
528 |
-
msgid "Red Theme"
|
529 |
-
msgstr ""
|
530 |
-
|
531 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:33
|
532 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:28
|
533 |
-
msgid "Green Theme"
|
534 |
-
msgstr ""
|
535 |
-
|
536 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:34
|
537 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:29
|
538 |
-
msgid "Blue Theme"
|
539 |
-
msgstr ""
|
540 |
-
|
541 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:35
|
542 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:30
|
543 |
-
msgid "Dark Theme"
|
544 |
-
msgstr ""
|
545 |
-
|
546 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:36
|
547 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:31
|
548 |
-
msgid "Custom Color Theme"
|
549 |
-
msgstr ""
|
550 |
-
|
551 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:41
|
552 |
-
msgid ""
|
553 |
-
"If you want to load some default CSS styles, select \"basic formatting "
|
554 |
-
"styles\" or choose one of the color themes"
|
555 |
-
msgstr ""
|
556 |
-
|
557 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:45
|
558 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:14
|
559 |
-
msgid "Lists this form subscribes to"
|
560 |
-
msgstr ""
|
561 |
-
|
562 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:63
|
563 |
-
msgid ""
|
564 |
-
"Select the list(s) to which people who submit this form should be "
|
565 |
-
"subscribed."
|
566 |
-
msgstr ""
|
567 |
-
|
568 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:69
|
569 |
-
msgid "Form mark-up"
|
570 |
-
msgstr ""
|
571 |
-
|
572 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:75
|
573 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:359
|
574 |
-
msgid "Your form is missing the following (required) form fields:"
|
575 |
-
msgstr ""
|
576 |
-
|
577 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:92
|
578 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:87
|
579 |
-
msgid ""
|
580 |
-
"Use the shortcode %s to display this form inside a post, page or text "
|
581 |
-
"widget."
|
582 |
-
msgstr ""
|
583 |
-
|
584 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:123
|
585 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:71
|
586 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:57
|
587 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:70
|
588 |
-
msgid "Send Welcome Email?"
|
589 |
-
msgstr ""
|
590 |
-
|
591 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:130
|
592 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:86
|
593 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:64
|
594 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:75
|
595 |
-
msgid ""
|
596 |
-
"Select \"yes\" if you want to send your lists Welcome Email if a subscribe "
|
597 |
-
"succeeds (only when double opt-in is disabled)."
|
598 |
-
msgstr ""
|
599 |
-
|
600 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:133
|
601 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:33
|
602 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:78
|
603 |
-
msgid "Update existing subscribers?"
|
604 |
-
msgstr ""
|
605 |
-
|
606 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:140
|
607 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:47
|
608 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:89
|
609 |
-
msgid ""
|
610 |
-
"Select \"yes\" if you want to update existing subscribers (instead of "
|
611 |
-
"showing the \"already subscribed\" message)."
|
612 |
-
msgstr ""
|
613 |
-
|
614 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:143
|
615 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:52
|
616 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:93
|
617 |
-
msgid "Replace interest groups?"
|
618 |
-
msgstr ""
|
619 |
-
|
620 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:154
|
621 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:66
|
622 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:104
|
623 |
-
msgid ""
|
624 |
-
"Select \"yes\" if you want to replace the interest groups with the groups "
|
625 |
-
"provided instead of adding the provided groups to the member's interest "
|
626 |
-
"groups (only when updating a subscriber)."
|
627 |
-
msgstr ""
|
628 |
-
|
629 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:158
|
630 |
-
msgid "Form Settings & Messages"
|
631 |
-
msgstr ""
|
632 |
-
|
633 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:162
|
634 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:94
|
635 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:113
|
636 |
-
msgid "Enable AJAX form submission?"
|
637 |
-
msgstr ""
|
638 |
-
|
639 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:173
|
640 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:108
|
641 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:118
|
642 |
-
msgid "Select \"yes\" if you want to use AJAX (JavaScript) to submit forms."
|
643 |
-
msgstr ""
|
644 |
-
|
645 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:176
|
646 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:112
|
647 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:121
|
648 |
-
msgid "Hide form after a successful sign-up?"
|
649 |
-
msgstr ""
|
650 |
-
|
651 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:187
|
652 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:126
|
653 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:126
|
654 |
-
msgid "Select \"yes\" to hide the form fields after a successful sign-up."
|
655 |
-
msgstr ""
|
656 |
-
|
657 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:190
|
658 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:130
|
659 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:129
|
660 |
-
msgid "Redirect to URL after successful sign-ups"
|
661 |
-
msgstr ""
|
662 |
-
|
663 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:192
|
664 |
-
msgid "Example: %s"
|
665 |
-
msgstr ""
|
666 |
-
|
667 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:193
|
668 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:133
|
669 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:132
|
670 |
-
msgid ""
|
671 |
-
"Leave empty or enter 0 for no redirection. Use complete (absolute) URLs, "
|
672 |
-
"including <code>http://</code>"
|
673 |
-
msgstr ""
|
674 |
-
|
675 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:197
|
676 |
-
msgid "Success message"
|
677 |
-
msgstr ""
|
678 |
-
|
679 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:201
|
680 |
-
msgid "Invalid email address message"
|
681 |
-
msgstr ""
|
682 |
-
|
683 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:205
|
684 |
-
msgid "Required field missing message"
|
685 |
-
msgstr ""
|
686 |
-
|
687 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:209
|
688 |
-
msgid "Already subscribed message"
|
689 |
-
msgstr ""
|
690 |
-
|
691 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:214
|
692 |
-
msgid "Invalid CAPTCHA message"
|
693 |
-
msgstr ""
|
694 |
-
|
695 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:219
|
696 |
-
msgid "General error message"
|
697 |
-
msgstr ""
|
698 |
-
|
699 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:225
|
700 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:181
|
701 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:169
|
702 |
-
msgid "HTML tags like %s are allowed in the message fields."
|
703 |
-
msgstr ""
|
704 |
-
|
705 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:239
|
706 |
-
msgid "Building your sign-up form"
|
707 |
-
msgstr ""
|
708 |
-
|
709 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:240
|
710 |
-
msgid ""
|
711 |
-
"At a minimum, your form should include just an %s field and a submit button."
|
712 |
-
msgstr ""
|
713 |
-
|
714 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:241
|
715 |
-
msgid ""
|
716 |
-
"Add more form fields if your selected lists require more fields. Field names"
|
717 |
-
" should match the field tags of the selected lists. Use the \"Add a new "
|
718 |
-
"field\" tool to have the HTML generated for you."
|
719 |
-
msgstr ""
|
720 |
-
|
721 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:243
|
722 |
-
msgid "Form Styling"
|
723 |
-
msgstr ""
|
724 |
-
|
725 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:244
|
726 |
-
msgid "Alter the visual appearance of the form by applying CSS rules to %s."
|
727 |
-
msgstr ""
|
728 |
-
|
729 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:245
|
730 |
-
msgid ""
|
731 |
-
"You can add the CSS rules to your theme stylesheet using the <a "
|
732 |
-
"href=\"%s\">Theme Editor</a> or by editing %s over FTP. Alternatively, use a"
|
733 |
-
" plugin like %s"
|
734 |
-
msgstr ""
|
735 |
-
|
736 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:246
|
737 |
-
msgid ""
|
738 |
-
"The <a href=\"%s\" target=\"_blank\">plugin FAQ</a> lists the various CSS "
|
739 |
-
"selectors you can use to target the different form elements."
|
740 |
-
msgstr ""
|
741 |
-
|
742 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:247
|
743 |
-
msgid ""
|
744 |
-
"If you need an easier way to style your forms, <a href=\"%s\">upgrade to "
|
745 |
-
"Mailchimp for WordPress Pro</a>. It comes with a \"Styles Builder\" that "
|
746 |
-
"lets you customize form styles without writing any code."
|
747 |
-
msgstr ""
|
748 |
-
|
749 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:249
|
750 |
-
msgid "Form variables"
|
751 |
-
msgstr ""
|
752 |
-
|
753 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:250
|
754 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:473
|
755 |
-
msgid "Use the following variables to add some dynamic content to your form."
|
756 |
-
msgstr ""
|
757 |
-
|
758 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:257
|
759 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:13
|
760 |
-
msgid "Replaced with the visitor's email (if set in URL or cookie)."
|
761 |
-
msgstr ""
|
762 |
-
|
763 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:261
|
764 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:17
|
765 |
-
msgid "Replaced with the form response (error or success messages)."
|
766 |
-
msgstr ""
|
767 |
-
|
768 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:266
|
769 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:22
|
770 |
-
msgid "Replaced with a captcha field."
|
771 |
-
msgstr ""
|
772 |
-
|
773 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:271
|
774 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:27
|
775 |
-
msgid "Replaced with the number of subscribers on the selected list(s)"
|
776 |
-
msgstr ""
|
777 |
-
|
778 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:275
|
779 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:31
|
780 |
-
msgid "Replaced with the current site language, eg: %s"
|
781 |
-
msgstr ""
|
782 |
-
|
783 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:279
|
784 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:35
|
785 |
-
msgid "Replaced with the visitor's IP address"
|
786 |
-
msgstr ""
|
787 |
-
|
788 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:283
|
789 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:39
|
790 |
-
msgid "Replaced with the current date (yyyy/mm/dd eg: %s)"
|
791 |
-
msgstr ""
|
792 |
-
|
793 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:287
|
794 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:43
|
795 |
-
msgid "Replaced with the current time (hh:mm:ss eg: %s)"
|
796 |
-
msgstr ""
|
797 |
-
|
798 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:291
|
799 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:47
|
800 |
-
msgid ""
|
801 |
-
"Replaced with the logged in user's email (or nothing, if there is no logged "
|
802 |
-
"in user)"
|
803 |
-
msgstr ""
|
804 |
-
|
805 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:295
|
806 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:51
|
807 |
-
msgid "First name of the current user"
|
808 |
-
msgstr ""
|
809 |
-
|
810 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:299
|
811 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:55
|
812 |
-
msgid "Last name of the current user"
|
813 |
-
msgstr ""
|
814 |
-
|
815 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:303
|
816 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:59
|
817 |
-
msgid "Current user ID"
|
818 |
-
msgstr ""
|
819 |
-
|
820 |
-
#: mailchimp-for-wordpress/includes/views/form-settings.php:307
|
821 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-text-variables.php:63
|
822 |
-
msgid "Current URL"
|
823 |
-
msgstr ""
|
824 |
-
|
825 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:10
|
826 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:29
|
827 |
-
msgid "Add a new field"
|
828 |
-
msgstr ""
|
829 |
-
|
830 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:12
|
831 |
-
msgid "Use the tool below to generate the HTML for your form fields."
|
832 |
-
msgstr ""
|
833 |
-
|
834 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:15
|
835 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:32
|
836 |
-
msgid "Select Mailchimp field.."
|
837 |
-
msgstr ""
|
838 |
-
|
839 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:19
|
840 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:36
|
841 |
-
msgid "Submit Button"
|
842 |
-
msgstr ""
|
843 |
-
|
844 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:20
|
845 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:37
|
846 |
-
msgid "Lists Choice"
|
847 |
-
msgstr ""
|
848 |
-
|
849 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:28
|
850 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:45
|
851 |
-
msgid "Label"
|
852 |
-
msgstr ""
|
853 |
-
|
854 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:28
|
855 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:33
|
856 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:38
|
857 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:45
|
858 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:50
|
859 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:55
|
860 |
-
msgid "(optional)"
|
861 |
-
msgstr ""
|
862 |
-
|
863 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:33
|
864 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:50
|
865 |
-
msgid "Placeholder"
|
866 |
-
msgstr ""
|
867 |
-
|
868 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:38
|
869 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:55
|
870 |
-
msgid "Initial value"
|
871 |
-
msgstr ""
|
872 |
-
|
873 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:43
|
874 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:60
|
875 |
-
msgid "Labels"
|
876 |
-
msgstr ""
|
877 |
-
|
878 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:43
|
879 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:60
|
880 |
-
msgid "(leave empty to hide)"
|
881 |
-
msgstr ""
|
882 |
-
|
883 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:48
|
884 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:65
|
885 |
-
msgid "Wrap in paragraph %s tags?"
|
886 |
-
msgstr ""
|
887 |
-
|
888 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:53
|
889 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:69
|
890 |
-
msgid "Required field?"
|
891 |
-
msgstr ""
|
892 |
-
|
893 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:57
|
894 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:73
|
895 |
-
msgid "Add to form"
|
896 |
-
msgstr ""
|
897 |
-
|
898 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:61
|
899 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:77
|
900 |
-
msgid "Generated HTML"
|
901 |
-
msgstr ""
|
902 |
-
|
903 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-field-wizard.php:68
|
904 |
-
msgid "Select at least one list first."
|
905 |
-
msgstr ""
|
906 |
-
|
907 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-footer.php:9
|
908 |
-
msgid ""
|
909 |
-
"Mailchimp for WordPress is in need of translations. Is the plugin not "
|
910 |
-
"translated in your language or do you spot errors with the current "
|
911 |
-
"translations? Helping out is easy! Head over to <a href=\"%s\">the "
|
912 |
-
"translation project and click \"help translate\"</a>."
|
913 |
-
msgstr ""
|
914 |
-
|
915 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-footer.php:10
|
916 |
-
msgid ""
|
917 |
-
"Enjoying this plugin? <a href=\"%s\">Upgrade to Mailchimp for WordPress Pro "
|
918 |
-
"now</a> for an even better plugin, you will love it."
|
919 |
-
msgstr ""
|
920 |
-
|
921 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-footer.php:11
|
922 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-footer.php:10
|
923 |
-
msgid ""
|
924 |
-
"This plugin is not developed by or affiliated with Mailchimp in any way."
|
925 |
-
msgstr ""
|
926 |
-
|
927 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-need-support.php:9
|
928 |
-
msgid "Looking for support?"
|
929 |
-
msgstr ""
|
930 |
-
|
931 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-need-support.php:10
|
932 |
-
msgid ""
|
933 |
-
"Make sure to look at the <a href=\"%s\">frequently asked questions</a> or "
|
934 |
-
"use the <a href=\"%s\">support forums</a> on WordPress.org."
|
935 |
-
msgstr ""
|
936 |
-
|
937 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-need-support.php:11
|
938 |
-
msgid ""
|
939 |
-
"If you need priority support, please <a href=\"%s\">upgrade to the premium "
|
940 |
-
"version</a>."
|
941 |
-
msgstr ""
|
942 |
-
|
943 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-need-support.php:15
|
944 |
-
msgid "Show a token of your appreciation"
|
945 |
-
msgstr ""
|
946 |
-
|
947 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-need-support.php:17
|
948 |
-
msgid "Upgrade to Mailchimp for WordPress Pro"
|
949 |
-
msgstr ""
|
950 |
-
|
951 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-need-support.php:18
|
952 |
-
msgid "Leave a %s plugin review on WordPress.org"
|
953 |
-
msgstr ""
|
954 |
-
|
955 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-need-support.php:19
|
956 |
-
msgid "I am using Mailchimp for WordPress by @DannyvanKooten - it is great!"
|
957 |
-
msgstr ""
|
958 |
-
|
959 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-need-support.php:19
|
960 |
-
msgid "Tweet about Mailchimp for WordPress"
|
961 |
-
msgstr ""
|
962 |
-
|
963 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-need-support.php:20
|
964 |
-
msgid ""
|
965 |
-
"Review the plugin on your blog and link to <a href=\"%s\">the plugin "
|
966 |
-
"page</a>."
|
967 |
-
msgstr ""
|
968 |
-
|
969 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-need-support.php:21
|
970 |
-
msgid "Vote \"works\" on the WordPress.org plugin page"
|
971 |
-
msgstr ""
|
972 |
-
|
973 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-need-support.php:25
|
974 |
-
msgid "About the developer"
|
975 |
-
msgstr ""
|
976 |
-
|
977 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-upgrade-to-pro.php:11
|
978 |
-
msgid ""
|
979 |
-
"This plugin has an even better premium version, I am sure you will love it."
|
980 |
-
msgstr ""
|
981 |
-
|
982 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-upgrade-to-pro.php:12
|
983 |
-
msgid ""
|
984 |
-
"Pro features include better and multiple forms, advanced and easy form "
|
985 |
-
"styling, more default themes, detailed statistics and priority support."
|
986 |
-
msgstr ""
|
987 |
-
|
988 |
-
#: mailchimp-for-wordpress/includes/views/parts/admin-upgrade-to-pro.php:13
|
989 |
-
msgid "More information about Mailchimp for WP Pro"
|
990 |
-
msgstr ""
|
991 |
-
|
992 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:204
|
993 |
-
msgid "Documentation"
|
994 |
-
msgstr ""
|
995 |
-
|
996 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:247
|
997 |
-
msgid "Save Form"
|
998 |
-
msgstr ""
|
999 |
-
|
1000 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:251
|
1001 |
-
msgid "Update Form"
|
1002 |
-
msgstr ""
|
1003 |
-
|
1004 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:302
|
1005 |
-
msgid "Back to general form settings"
|
1006 |
-
msgstr ""
|
1007 |
-
|
1008 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:304
|
1009 |
-
msgid "Form updated."
|
1010 |
-
msgstr ""
|
1011 |
-
|
1012 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:305
|
1013 |
-
msgid "Form saved."
|
1014 |
-
msgstr ""
|
1015 |
-
|
1016 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:432
|
1017 |
-
msgid "Optional Settings"
|
1018 |
-
msgstr ""
|
1019 |
-
|
1020 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:433
|
1021 |
-
msgid "Form Variables"
|
1022 |
-
msgstr ""
|
1023 |
-
|
1024 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:571
|
1025 |
-
msgid "Mailchimp & License"
|
1026 |
-
msgstr ""
|
1027 |
-
|
1028 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:574
|
1029 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-reports.php:10
|
1030 |
-
msgid "Reports"
|
1031 |
-
msgstr ""
|
1032 |
-
|
1033 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:728
|
1034 |
-
msgid ""
|
1035 |
-
"Please make sure the plugin is connected to Mailchimp. <a "
|
1036 |
-
"href=\"%s\">Provide a valid API key.</a>"
|
1037 |
-
msgstr ""
|
1038 |
-
|
1039 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:830
|
1040 |
-
msgid "End date can't be before the start date"
|
1041 |
-
msgstr ""
|
1042 |
-
|
1043 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:862
|
1044 |
-
msgid ""
|
1045 |
-
"You disabled logging using the %s filter. Re-enable it to use the Reports "
|
1046 |
-
"page."
|
1047 |
-
msgstr ""
|
1048 |
-
|
1049 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-admin.php:878
|
1050 |
-
msgid ""
|
1051 |
-
"<strong>Welcome to Mailchimp for WordPress Pro!</strong> We transfered the "
|
1052 |
-
"settings you had set in the Lite version, please <a href=\"%s\">deactivate "
|
1053 |
-
"it now</a> to prevent problems"
|
1054 |
-
msgstr ""
|
1055 |
-
|
1056 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-styles-builder.php:319
|
1057 |
-
msgid ""
|
1058 |
-
"Couldn't create the stylesheet. Manually add the generated CSS to your theme"
|
1059 |
-
" stylesheet by using the %sTheme Editor%s or use FTP and edit <em>%s</em>."
|
1060 |
-
msgstr ""
|
1061 |
-
|
1062 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-styles-builder.php:320
|
1063 |
-
msgid "%sShow generated CSS%s"
|
1064 |
-
msgstr ""
|
1065 |
-
|
1066 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-styles-builder.php:331
|
1067 |
-
msgid ""
|
1068 |
-
"To apply these styles on your website, select \"load custom form styles\" in"
|
1069 |
-
" the %sform settings%s"
|
1070 |
-
msgstr ""
|
1071 |
-
|
1072 |
-
#: mailchimp-for-wordpress-pro/includes/admin/class-styles-builder.php:332
|
1073 |
-
msgid "The %sCSS Stylesheet%s has been created."
|
1074 |
-
msgstr ""
|
1075 |
-
|
1076 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:152
|
1077 |
-
msgid "I know. Don't bug me."
|
1078 |
-
msgstr ""
|
1079 |
-
|
1080 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:171
|
1081 |
-
msgid ""
|
1082 |
-
"<b>Warning!</b> You're blocking external requests which means you won't be "
|
1083 |
-
"able to get %s updates. Please add %s to %s."
|
1084 |
-
msgstr ""
|
1085 |
-
|
1086 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:213
|
1087 |
-
msgid "Your %s license has been activated. You have an unlimited license. "
|
1088 |
-
msgstr ""
|
1089 |
-
|
1090 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:215
|
1091 |
-
msgid "Your %s license has been activated. You have used %d/%d activations. "
|
1092 |
-
msgstr ""
|
1093 |
-
|
1094 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:220
|
1095 |
-
msgid "<a href=\"%s\">Did you know you can upgrade your license?</a>"
|
1096 |
-
msgstr ""
|
1097 |
-
|
1098 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:224
|
1099 |
-
msgid ""
|
1100 |
-
"<a href=\"%s\">Your license is expiring in %d days, would you like to extend"
|
1101 |
-
" it?</a>"
|
1102 |
-
msgstr ""
|
1103 |
-
|
1104 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:233
|
1105 |
-
msgid ""
|
1106 |
-
"You've reached your activation limit. You must <a href=\"%s\">reset</a> or "
|
1107 |
-
"<a href=\"%s\">upgrade your license</a> to use it on this site."
|
1108 |
-
msgstr ""
|
1109 |
-
|
1110 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:237
|
1111 |
-
msgid ""
|
1112 |
-
"Your license has expired. You must <a href=\"%s\">renew your license</a> if "
|
1113 |
-
"you want to use it again."
|
1114 |
-
msgstr ""
|
1115 |
-
|
1116 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:240
|
1117 |
-
msgid "Failed to activate your license, your license key seems to be invalid."
|
1118 |
-
msgstr ""
|
1119 |
-
|
1120 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:265
|
1121 |
-
msgid "Your %s license has been deactivated."
|
1122 |
-
msgstr ""
|
1123 |
-
|
1124 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:270
|
1125 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:69
|
1126 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:78
|
1127 |
-
msgid ""
|
1128 |
-
"Your plugin license has expired. You will no longer have access to plugin "
|
1129 |
-
"updates unless you <a href=\"%s\">renew your license</a>."
|
1130 |
-
msgstr ""
|
1131 |
-
|
1132 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:272
|
1133 |
-
msgid "Failed to deactivate your %s license."
|
1134 |
-
msgstr ""
|
1135 |
-
|
1136 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:310
|
1137 |
-
msgid "Request error: \"%s\""
|
1138 |
-
msgstr ""
|
1139 |
-
|
1140 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-license-manager.php:469
|
1141 |
-
msgid "%s: License Settings"
|
1142 |
-
msgstr ""
|
1143 |
-
|
1144 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-plugin-license-manager.php:67
|
1145 |
-
msgid ""
|
1146 |
-
"%s is network activated, please contact your site administrator to manage "
|
1147 |
-
"the license."
|
1148 |
-
msgstr ""
|
1149 |
-
|
1150 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-update-manager.php:69
|
1151 |
-
msgid ""
|
1152 |
-
"%s failed to check for updates because of the following error: <em>%s</em>"
|
1153 |
-
msgstr ""
|
1154 |
-
|
1155 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/class-update-manager.php:131
|
1156 |
-
msgid ""
|
1157 |
-
"This site has not been activated properly on dannyvankooten.com and thus "
|
1158 |
-
"cannot check for future updates. Please activate your site with a valid "
|
1159 |
-
"license key."
|
1160 |
-
msgstr ""
|
1161 |
-
|
1162 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:23
|
1163 |
-
msgid "License status"
|
1164 |
-
msgstr ""
|
1165 |
-
|
1166 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:26
|
1167 |
-
msgid "ACTIVE"
|
1168 |
-
msgstr ""
|
1169 |
-
|
1170 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:26
|
1171 |
-
msgid "you are receiving updates"
|
1172 |
-
msgstr ""
|
1173 |
-
|
1174 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:28
|
1175 |
-
msgid "EXPIRED"
|
1176 |
-
msgstr ""
|
1177 |
-
|
1178 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:28
|
1179 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:30
|
1180 |
-
msgid "you are <strong>not</strong> receiving updates."
|
1181 |
-
msgstr ""
|
1182 |
-
|
1183 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:30
|
1184 |
-
msgid "INACTIVE"
|
1185 |
-
msgstr ""
|
1186 |
-
|
1187 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:35
|
1188 |
-
msgid "Toggle license status"
|
1189 |
-
msgstr ""
|
1190 |
-
|
1191 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:39
|
1192 |
-
msgid "Deactivate License"
|
1193 |
-
msgstr ""
|
1194 |
-
|
1195 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:40
|
1196 |
-
msgid ""
|
1197 |
-
"(deactivate your license so you can activate it on another WordPress site)"
|
1198 |
-
msgstr ""
|
1199 |
-
|
1200 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:44
|
1201 |
-
msgid "Activate License"
|
1202 |
-
msgstr ""
|
1203 |
-
|
1204 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:46
|
1205 |
-
msgid "Please enter a license key in the field below first."
|
1206 |
-
msgstr ""
|
1207 |
-
|
1208 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:54
|
1209 |
-
msgid "License Key"
|
1210 |
-
msgstr ""
|
1211 |
-
|
1212 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:56
|
1213 |
-
msgid "Paste your license key here, as found in the email receipt."
|
1214 |
-
msgstr ""
|
1215 |
-
|
1216 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:58
|
1217 |
-
msgid "You defined your license key using the %s PHP constant."
|
1218 |
-
msgstr ""
|
1219 |
-
|
1220 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:82
|
1221 |
-
msgid "Your %s license will expire on %s."
|
1222 |
-
msgstr ""
|
1223 |
-
|
1224 |
-
#: mailchimp-for-wordpress-pro/includes/admin/license-manager/views/form.php:86
|
1225 |
-
msgid "%sRenew your license now%s."
|
1226 |
-
msgstr ""
|
1227 |
-
|
1228 |
-
#: mailchimp-for-wordpress-pro/includes/class-form-manager.php:241
|
1229 |
-
msgid "<strong>Error:</strong> Please specify a form ID. Example: %s."
|
1230 |
-
msgstr ""
|
1231 |
-
|
1232 |
-
#: mailchimp-for-wordpress-pro/includes/class-form-manager.php:255
|
1233 |
-
msgid ""
|
1234 |
-
"<strong>Error:</strong> Sign-up form not found. Please check if you used the"
|
1235 |
-
" correct form ID."
|
1236 |
-
msgstr ""
|
1237 |
-
|
1238 |
-
#: mailchimp-for-wordpress-pro/includes/class-form-request.php:621
|
1239 |
-
msgid "New Mailchimp Sign-Up"
|
1240 |
-
msgstr ""
|
1241 |
-
|
1242 |
-
#: mailchimp-for-wordpress-pro/includes/class-form-request.php:629
|
1243 |
-
msgid "New Sign-Up"
|
1244 |
-
msgstr ""
|
1245 |
-
|
1246 |
-
#: mailchimp-for-wordpress-pro/includes/class-form-request.php:630
|
1247 |
-
msgid "<strong>%s</strong> signed-up at %s on %s using the form \"%s\"."
|
1248 |
-
msgstr ""
|
1249 |
-
|
1250 |
-
#: mailchimp-for-wordpress-pro/includes/class-form-request.php:635
|
1251 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:54
|
1252 |
-
msgid "List"
|
1253 |
-
msgstr ""
|
1254 |
-
|
1255 |
-
#: mailchimp-for-wordpress-pro/includes/class-form-request.php:675
|
1256 |
-
msgid "Other fields"
|
1257 |
-
msgstr ""
|
1258 |
-
|
1259 |
-
#: mailchimp-for-wordpress-pro/includes/class-form-request.php:692
|
1260 |
-
msgid ""
|
1261 |
-
"Note that you've enabled double opt-in for the \"%s\" form. The user won't "
|
1262 |
-
"be added to the selected Mailchimp lists until they confirm their email "
|
1263 |
-
"address."
|
1264 |
-
msgstr ""
|
1265 |
-
|
1266 |
-
#: mailchimp-for-wordpress-pro/includes/class-form-request.php:694
|
1267 |
-
msgid "This email was auto-sent by the Mailchimp for WordPress plugin."
|
1268 |
-
msgstr ""
|
1269 |
-
|
1270 |
-
#: mailchimp-for-wordpress-pro/includes/class-mailchimp.php:140
|
1271 |
-
msgid "IP Address"
|
1272 |
-
msgstr ""
|
1273 |
-
|
1274 |
-
#: mailchimp-for-wordpress-pro/includes/class-widget.php:20
|
1275 |
-
msgid "Mailchimp for WP Form"
|
1276 |
-
msgstr ""
|
1277 |
-
|
1278 |
-
#: mailchimp-for-wordpress-pro/includes/class-widget.php:21
|
1279 |
-
msgid "Displays one of your Mailchimp for WordPress sign-up forms"
|
1280 |
-
msgstr ""
|
1281 |
-
|
1282 |
-
#: mailchimp-for-wordpress-pro/includes/class-widget.php:43
|
1283 |
-
msgid ""
|
1284 |
-
"Please select the sign-up form you'd like to show here in the <a "
|
1285 |
-
"href=\"%s\">widget settings</a>."
|
1286 |
-
msgstr ""
|
1287 |
-
|
1288 |
-
#: mailchimp-for-wordpress-pro/includes/class-widget.php:84
|
1289 |
-
msgid "Form:"
|
1290 |
-
msgstr ""
|
1291 |
-
|
1292 |
-
#: mailchimp-for-wordpress-pro/includes/class-widget.php:86
|
1293 |
-
msgid "Select the form to show"
|
1294 |
-
msgstr ""
|
1295 |
-
|
1296 |
-
#: mailchimp-for-wordpress-pro/includes/class-widget.php:94
|
1297 |
-
msgid "You don't have any sign-up forms. <a href=\"%s\">Create one now.</a>"
|
1298 |
-
msgstr ""
|
1299 |
-
|
1300 |
-
#: mailchimp-for-wordpress-pro/includes/functions/general.php:50
|
1301 |
-
msgid ""
|
1302 |
-
"Thank you, your sign-up request was successful! Please check your email "
|
1303 |
-
"inbox to confirm."
|
1304 |
-
msgstr ""
|
1305 |
-
|
1306 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-forms-table.php:35
|
1307 |
-
msgid "ID"
|
1308 |
-
msgstr ""
|
1309 |
-
|
1310 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-forms-table.php:36
|
1311 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:226
|
1312 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:341
|
1313 |
-
msgid "Form"
|
1314 |
-
msgstr ""
|
1315 |
-
|
1316 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-forms-table.php:37
|
1317 |
-
msgid "Shortcode"
|
1318 |
-
msgstr ""
|
1319 |
-
|
1320 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-forms-table.php:38
|
1321 |
-
msgid "List(s)"
|
1322 |
-
msgstr ""
|
1323 |
-
|
1324 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-forms-table.php:39
|
1325 |
-
msgid "Last edited"
|
1326 |
-
msgstr ""
|
1327 |
-
|
1328 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-forms-table.php:76
|
1329 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-forms-table.php:80
|
1330 |
-
msgid "Edit Form"
|
1331 |
-
msgstr ""
|
1332 |
-
|
1333 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-forms-table.php:77
|
1334 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:188
|
1335 |
-
msgid "Delete"
|
1336 |
-
msgstr ""
|
1337 |
-
|
1338 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-forms-table.php:98
|
1339 |
-
msgid "No Mailchimp list(s) selected yet."
|
1340 |
-
msgstr ""
|
1341 |
-
|
1342 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-forms-table.php:105
|
1343 |
-
msgid "You have not created any sign-up forms yet. Time to do so!"
|
1344 |
-
msgstr ""
|
1345 |
-
|
1346 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:33
|
1347 |
-
msgid "Subscriber Log"
|
1348 |
-
msgstr ""
|
1349 |
-
|
1350 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:34
|
1351 |
-
msgid "Subscriber Logs"
|
1352 |
-
msgstr ""
|
1353 |
-
|
1354 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:53
|
1355 |
-
msgid "Email"
|
1356 |
-
msgstr ""
|
1357 |
-
|
1358 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:55
|
1359 |
-
msgid "Type"
|
1360 |
-
msgstr ""
|
1361 |
-
|
1362 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:56
|
1363 |
-
msgid "Source"
|
1364 |
-
msgstr ""
|
1365 |
-
|
1366 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:57
|
1367 |
-
msgid "Data"
|
1368 |
-
msgstr ""
|
1369 |
-
|
1370 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:58
|
1371 |
-
msgid "Subscribed"
|
1372 |
-
msgstr ""
|
1373 |
-
|
1374 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:116
|
1375 |
-
msgid "Log items deleted."
|
1376 |
-
msgstr ""
|
1377 |
-
|
1378 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:209
|
1379 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:215
|
1380 |
-
msgid "Comment"
|
1381 |
-
msgstr ""
|
1382 |
-
|
1383 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:209
|
1384 |
-
msgid "deleted"
|
1385 |
-
msgstr ""
|
1386 |
-
|
1387 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:219
|
1388 |
-
msgid "Registration"
|
1389 |
-
msgstr ""
|
1390 |
-
|
1391 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:235
|
1392 |
-
msgid "MultiSite registration"
|
1393 |
-
msgstr ""
|
1394 |
-
|
1395 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:239
|
1396 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:243
|
1397 |
-
msgid "Checkout"
|
1398 |
-
msgstr ""
|
1399 |
-
|
1400 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:248
|
1401 |
-
msgid "Contact Form 7"
|
1402 |
-
msgstr ""
|
1403 |
-
|
1404 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:252
|
1405 |
-
msgid "bbPress: New Topic"
|
1406 |
-
msgstr ""
|
1407 |
-
|
1408 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:256
|
1409 |
-
msgid "bbPress: New Reply"
|
1410 |
-
msgstr ""
|
1411 |
-
|
1412 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:262
|
1413 |
-
msgid "Other Form"
|
1414 |
-
msgstr ""
|
1415 |
-
|
1416 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:312
|
1417 |
-
msgid "No subscribe requests found."
|
1418 |
-
msgstr ""
|
1419 |
-
|
1420 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:335
|
1421 |
-
msgid "All"
|
1422 |
-
msgstr ""
|
1423 |
-
|
1424 |
-
#: mailchimp-for-wordpress-pro/includes/tables/class-log-table.php:347
|
1425 |
-
msgid "Checkbox"
|
1426 |
-
msgstr ""
|
1427 |
-
|
1428 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:8
|
1429 |
-
msgid ""
|
1430 |
-
"Any settings you specify here will override the <a href=\"%s\">general form "
|
1431 |
-
"settings</a>. If no setting is specified, the corresponding general setting "
|
1432 |
-
"value will be used."
|
1433 |
-
msgstr ""
|
1434 |
-
|
1435 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:25
|
1436 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:45
|
1437 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:64
|
1438 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:83
|
1439 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:106
|
1440 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:124
|
1441 |
-
msgid "Inherit"
|
1442 |
-
msgstr ""
|
1443 |
-
|
1444 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:137
|
1445 |
-
msgid "Send an email copy of the form data?"
|
1446 |
-
msgstr ""
|
1447 |
-
|
1448 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:141
|
1449 |
-
msgid ""
|
1450 |
-
"Tick \"yes\" if you want to receive an email with the form data for every "
|
1451 |
-
"sign-up request."
|
1452 |
-
msgstr ""
|
1453 |
-
|
1454 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:144
|
1455 |
-
msgid "Send the copy to this email:"
|
1456 |
-
msgstr ""
|
1457 |
-
|
1458 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:150
|
1459 |
-
msgid "Messages"
|
1460 |
-
msgstr ""
|
1461 |
-
|
1462 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:153
|
1463 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:140
|
1464 |
-
msgid "Success"
|
1465 |
-
msgstr ""
|
1466 |
-
|
1467 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:157
|
1468 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:145
|
1469 |
-
msgid "Invalid email address"
|
1470 |
-
msgstr ""
|
1471 |
-
|
1472 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:161
|
1473 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:149
|
1474 |
-
msgid "Required field missing"
|
1475 |
-
msgstr ""
|
1476 |
-
|
1477 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:165
|
1478 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:153
|
1479 |
-
msgid "Already subscribed"
|
1480 |
-
msgstr ""
|
1481 |
-
|
1482 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:170
|
1483 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:159
|
1484 |
-
msgid "Invalid CAPTCHA"
|
1485 |
-
msgstr ""
|
1486 |
-
|
1487 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/optional-form-settings.php:175
|
1488 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:164
|
1489 |
-
msgid "Other errors"
|
1490 |
-
msgstr ""
|
1491 |
-
|
1492 |
-
#: mailchimp-for-wordpress-pro/includes/views/metaboxes/required-form-settings.php:86
|
1493 |
-
msgid "Form usage"
|
1494 |
-
msgstr ""
|
1495 |
-
|
1496 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:86
|
1497 |
-
msgid ""
|
1498 |
-
"Use %s in your Contact Form 7 mark-up to add a sign-up checkbox to your CF7 "
|
1499 |
-
"forms."
|
1500 |
-
msgstr ""
|
1501 |
-
|
1502 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:122
|
1503 |
-
msgid "Custom label texts"
|
1504 |
-
msgstr ""
|
1505 |
-
|
1506 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-checkbox-settings.php:123
|
1507 |
-
msgid ""
|
1508 |
-
"Override the default checkbox label text for any given checkbox using the "
|
1509 |
-
"fields below."
|
1510 |
-
msgstr ""
|
1511 |
-
|
1512 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-form-settings.php:13
|
1513 |
-
msgid "Forms & Settings"
|
1514 |
-
msgstr ""
|
1515 |
-
|
1516 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-form-settings.php:14
|
1517 |
-
msgid "CSS Styles Builder"
|
1518 |
-
msgstr ""
|
1519 |
-
|
1520 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-general-settings.php:10
|
1521 |
-
msgid "License & API Settings"
|
1522 |
-
msgstr ""
|
1523 |
-
|
1524 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-general-settings.php:113
|
1525 |
-
msgid "No lists were found in your Mailchimp account."
|
1526 |
-
msgstr ""
|
1527 |
-
|
1528 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-reports.php:14
|
1529 |
-
msgid "Statistics"
|
1530 |
-
msgstr ""
|
1531 |
-
|
1532 |
-
#: mailchimp-for-wordpress-pro/includes/views/pages/admin-reports.php:15
|
1533 |
-
msgid "Log"
|
1534 |
-
msgstr ""
|
1535 |
-
|
1536 |
-
#: mailchimp-for-wordpress-pro/includes/views/parts/admin-footer.php:9
|
1537 |
-
msgid ""
|
1538 |
-
"Need help? Have a look at the <a href=\"%s\">plugin documentation</a> or "
|
1539 |
-
"email me directly at <a href=\"%s\">support@mc4wp.com</a>."
|
1540 |
-
msgstr ""
|
1541 |
-
|
1542 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-css-builder.php:10
|
1543 |
-
msgid "Use the fields below to create custom styling rules for your forms."
|
1544 |
-
msgstr ""
|
1545 |
-
|
1546 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-css-builder.php:15
|
1547 |
-
msgid "Select form to build styles for:"
|
1548 |
-
msgstr ""
|
1549 |
-
|
1550 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-css-builder.php:26
|
1551 |
-
msgid "Create at least one form first."
|
1552 |
-
msgstr ""
|
1553 |
-
|
1554 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-css-builder.php:41
|
1555 |
-
msgid "You need to have JavaScript enabled to see a preview of your form."
|
1556 |
-
msgstr ""
|
1557 |
-
|
1558 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-css-builder.php:223
|
1559 |
-
msgid "Are you sure you want to delete all custom styles for this form?"
|
1560 |
-
msgstr ""
|
1561 |
-
|
1562 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-css-builder.php:223
|
1563 |
-
msgid "Delete Form Styles"
|
1564 |
-
msgstr ""
|
1565 |
-
|
1566 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-css-builder.php:224
|
1567 |
-
msgid "Use to delete all styles for this form"
|
1568 |
-
msgstr ""
|
1569 |
-
|
1570 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-css-builder.php:231
|
1571 |
-
msgid "Build CSS File"
|
1572 |
-
msgstr ""
|
1573 |
-
|
1574 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:8
|
1575 |
-
msgid "Sign-Up Forms"
|
1576 |
-
msgstr ""
|
1577 |
-
|
1578 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:8
|
1579 |
-
msgid "Create New Form"
|
1580 |
-
msgstr ""
|
1581 |
-
|
1582 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:16
|
1583 |
-
msgid "General form settings"
|
1584 |
-
msgstr ""
|
1585 |
-
|
1586 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:36
|
1587 |
-
msgid ""
|
1588 |
-
"If you %screated a custom stylesheet%s and want it to be loaded, select "
|
1589 |
-
"\"custom form styles\". Otherwise, choose the basic formatting styles or one"
|
1590 |
-
" of the default themes."
|
1591 |
-
msgstr ""
|
1592 |
-
|
1593 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:40
|
1594 |
-
msgid "Select Color"
|
1595 |
-
msgstr ""
|
1596 |
-
|
1597 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:48
|
1598 |
-
msgid "Save all changes"
|
1599 |
-
msgstr ""
|
1600 |
-
|
1601 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:50
|
1602 |
-
msgid "Default Mailchimp settings"
|
1603 |
-
msgstr ""
|
1604 |
-
|
1605 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:51
|
1606 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:109
|
1607 |
-
msgid ""
|
1608 |
-
"The following settings apply to <strong>all</strong> forms but can be "
|
1609 |
-
"overridden on a per-form basis."
|
1610 |
-
msgstr ""
|
1611 |
-
|
1612 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:108
|
1613 |
-
msgid "Default Form Settings"
|
1614 |
-
msgstr ""
|
1615 |
-
|
1616 |
-
#: mailchimp-for-wordpress-pro/includes/views/tabs/admin-forms-general-settings.php:137
|
1617 |
-
msgid "Default Messages"
|
1618 |
-
msgstr ""
|
1619 |
-
|
1620 |
-
#. Plugin URI of the plugin/theme
|
1621 |
-
msgid "https://mc4wp.com/"
|
1622 |
-
msgstr ""
|
1623 |
-
|
1624 |
-
#. Description of the plugin/theme
|
1625 |
-
msgid "Adds various sign-up methods to your website."
|
1626 |
-
msgstr ""
|
1627 |
-
|
1628 |
-
#. Author of the plugin/theme
|
1629 |
-
msgid "Danny van Kooten"
|
1630 |
-
msgstr ""
|
1631 |
-
|
1632 |
-
#. Author URI of the plugin/theme
|
1633 |
-
msgid "http://dannyvankooten.com"
|
1634 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/mailchimp-for-wp-bg_BG.mo
DELETED
Binary file
|
languages/mailchimp-for-wp-bg_BG.po
DELETED
@@ -1,1094 +0,0 @@
|
|
1 |
-
# Copyright (C) 2017 mailchimp-for-wp
|
2 |
-
# This file is distributed under the same license as the mailchimp-for-wp package.
|
3 |
-
# Translators:
|
4 |
-
# Emanuil Svetlinski <svetlinski2@gmail.com>, 2016
|
5 |
-
# Velin Naydenov <velin.naydenov@gmail.com>, 2014
|
6 |
-
# Yuriy Chamkoriyski <chamkoriyski@gmail.com>, 2018
|
7 |
-
# Zhivko Vasilev <vasilevzhivko@gmail.com>, 2017
|
8 |
-
msgid ""
|
9 |
-
msgstr ""
|
10 |
-
"Project-Id-Version: Mailchimp for WordPress\n"
|
11 |
-
"PO-Revision-Date: 2018-07-14 20:37+0000\n"
|
12 |
-
"Last-Translator: Yuriy Chamkoriyski <chamkoriyski@gmail.com>\n"
|
13 |
-
"Language-Team: Bulgarian (Bulgaria) (http://www.transifex.com/ibericode/mailchimp-for-wordpress/language/bg_BG/)\n"
|
14 |
-
"MIME-Version: 1.0\n"
|
15 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
16 |
-
"Content-Transfer-Encoding: 8bit\n"
|
17 |
-
"Language: bg_BG\n"
|
18 |
-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
19 |
-
"X-Poedit-Basepath: ..\n"
|
20 |
-
"X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
|
21 |
-
"X-Poedit-SearchPath-0: .\n"
|
22 |
-
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
23 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
24 |
-
|
25 |
-
#: includes/admin/class-admin-texts.php62,
|
26 |
-
#: includes/forms/views/edit-form.php:6
|
27 |
-
msgid "Settings"
|
28 |
-
msgstr "Настройки"
|
29 |
-
|
30 |
-
#: includes/admin/class-admin-texts.php:80
|
31 |
-
msgid "Documentation"
|
32 |
-
msgstr "Документация"
|
33 |
-
|
34 |
-
#: includes/admin/class-admin.php:204
|
35 |
-
msgid ""
|
36 |
-
"Success! The cached configuration for your Mailchimp lists has been renewed."
|
37 |
-
msgstr "Поздравления! Кеширанота конфигурация за вашите Mailchimp списъци беше подновена."
|
38 |
-
|
39 |
-
#: includes/admin/class-admin.php:304
|
40 |
-
msgid ""
|
41 |
-
"This is a pro-only feature. Please upgrade to the premium version to be able"
|
42 |
-
" to use it."
|
43 |
-
msgstr "Тази функция може да бъде изпълна само от PRO версията на плъгин-a. Моля ъпгрейднете плъгина, за да можете да я използвате"
|
44 |
-
|
45 |
-
#: includes/admin/class-admin.php305,
|
46 |
-
#: includes/views/parts/lists-overview.php10,
|
47 |
-
#: includes/forms/views/parts/add-fields-help.php:43
|
48 |
-
msgid "Renew Mailchimp lists"
|
49 |
-
msgstr "Обновете Mailchimp списъците"
|
50 |
-
|
51 |
-
#: includes/admin/class-admin.php:306
|
52 |
-
msgid "Fetching Mailchimp lists"
|
53 |
-
msgstr "Изтегляне на Mailchimp списъците"
|
54 |
-
|
55 |
-
#: includes/admin/class-admin.php:307
|
56 |
-
msgid "Done! Mailchimp lists renewed."
|
57 |
-
msgstr "Готово! Mailchimp списъците бяха подновени."
|
58 |
-
|
59 |
-
#: includes/admin/class-admin.php:308
|
60 |
-
msgid "This can take a while if you have many Mailchimp lists."
|
61 |
-
msgstr "Операцията може да отнеме известно време ако имате много списъци в Mailchimp."
|
62 |
-
|
63 |
-
#: includes/admin/class-admin.php336, includes/views/general-settings.php:31
|
64 |
-
msgid "Mailchimp API Settings"
|
65 |
-
msgstr "Mailchimp API Настройки"
|
66 |
-
|
67 |
-
#: includes/admin/class-admin.php:337
|
68 |
-
msgid "Mailchimp"
|
69 |
-
msgstr "МейлЧимп"
|
70 |
-
|
71 |
-
#: includes/admin/class-admin.php343, includes/views/other-settings.php60,
|
72 |
-
#: includes/views/other-settings.php:70
|
73 |
-
msgid "Other Settings"
|
74 |
-
msgstr "Други настройки"
|
75 |
-
|
76 |
-
#: includes/admin/class-admin.php:344
|
77 |
-
msgid "Other"
|
78 |
-
msgstr "Други"
|
79 |
-
|
80 |
-
#: includes/admin/class-admin.php:458
|
81 |
-
msgid "Log successfully emptied."
|
82 |
-
msgstr "Лог файла беше изтрит успешно."
|
83 |
-
|
84 |
-
#: includes/admin/class-admin.php:488
|
85 |
-
msgid ""
|
86 |
-
"To get started with Mailchimp for WordPress, please <a href=\"%s\">enter "
|
87 |
-
"your Mailchimp API key on the settings page of the plugin</a>."
|
88 |
-
msgstr "За да стартирате с MailChamp за WordPress, моля <a href=\"%s\"> въведете Вашият API ключ на страницата за опциите на добавката</a>."
|
89 |
-
|
90 |
-
#: includes/admin/class-ads.php:39
|
91 |
-
msgid ""
|
92 |
-
"Want to customize the style of your form? <a href=\"%s\">Try our Styles "
|
93 |
-
"Builder</a> & edit the look of your forms with just a few clicks."
|
94 |
-
msgstr "Искате да модифицирате стила на Вашата форма? <a href=\"%s\">Опитайте нашият Стил конструктор </a> и променете на Вашита форма само с няколко щраквания."
|
95 |
-
|
96 |
-
#: includes/admin/class-ads.php:54
|
97 |
-
msgid ""
|
98 |
-
"Be notified whenever someone subscribes? <a href=\"%s\">Mailchimp for "
|
99 |
-
"WordPress Premium</a> allows you to set up email notifications for your "
|
100 |
-
"forms."
|
101 |
-
msgstr "Бъдете уведомени, когато някой се абонира. <a href=\"%s\">Mailchimp за WordPress Premium </a>Ви позволява да изберете уведомяване по електронна поща за Вашите форми."
|
102 |
-
|
103 |
-
#: includes/admin/class-ads.php:56
|
104 |
-
msgid ""
|
105 |
-
"Increased conversions? <a href=\"%s\">Mailchimp for WordPress Premium</a> "
|
106 |
-
"submits forms without reloading the entire page, resulting in a much better "
|
107 |
-
"experience for your visitors."
|
108 |
-
msgstr ""
|
109 |
-
|
110 |
-
#: includes/admin/class-ads.php:70
|
111 |
-
msgid "Upgrade to Premium"
|
112 |
-
msgstr "Обновете до платена версия."
|
113 |
-
|
114 |
-
#: includes/admin/class-ads.php:83
|
115 |
-
msgid ""
|
116 |
-
"Do you want translated forms for all of your languages? <a href=\"%s\">Try "
|
117 |
-
"Mailchimp for WordPress Premium</a>, which does just that plus more."
|
118 |
-
msgstr "Желаете ли преведени форми за всички езици, които имате инсталирани? <a href=\"%s\">Пробвайте Mailchimp за WordPress Premium</a>, който прави всичко това, че и повече."
|
119 |
-
|
120 |
-
#: includes/admin/class-ads.php:88
|
121 |
-
msgid ""
|
122 |
-
"Do you want to create more than one form? Our Premium add-on does just that!"
|
123 |
-
" <a href=\"%s\">Have a look at all Premium benefits</a>."
|
124 |
-
msgstr "Искате да създадете повече от една форма? Нашата платена версия на добавка може да се справи с това <a href=\"%s\">. Проверете за всички други възможности в платената версия </a>."
|
125 |
-
|
126 |
-
#: includes/admin/class-ads.php:93
|
127 |
-
msgid ""
|
128 |
-
"Are you enjoying this plugin? The Premium add-on unlocks several powerful "
|
129 |
-
"features. <a href=\"%s\">Find out about all benefits now</a>."
|
130 |
-
msgstr "Харесва ли Ви нашата добавка? Платената версия предлага няколко допълнителни дункции. <a href=\"%s\"> Научете всичко за тях сега </a>."
|
131 |
-
|
132 |
-
#: includes/admin/class-ads.php:112
|
133 |
-
msgid "More subscribers, better newsletters."
|
134 |
-
msgstr "Повече абонати, по-добри новини по имейл."
|
135 |
-
|
136 |
-
#: includes/admin/class-ads.php:113
|
137 |
-
msgid ""
|
138 |
-
"Learn how to best grow your lists & write better emails by subscribing to "
|
139 |
-
"our monthly tips."
|
140 |
-
msgstr "Научете се как да увеличите абонатите си по най-добрият начин и да пишете по-хубави новинарски имейли, като се абонирате за нашето месечно издание."
|
141 |
-
|
142 |
-
#: includes/admin/class-ads.php:116
|
143 |
-
msgid "Email Address"
|
144 |
-
msgstr "Имейл адрес"
|
145 |
-
|
146 |
-
#: includes/admin/class-ads.php:120
|
147 |
-
msgid "First Name"
|
148 |
-
msgstr "Име"
|
149 |
-
|
150 |
-
#: includes/admin/class-ads.php127, includes/forms/class-admin.php:94
|
151 |
-
msgid "Subscribe"
|
152 |
-
msgstr "Абонирай се"
|
153 |
-
|
154 |
-
#: includes/admin/class-ads.php:150
|
155 |
-
msgid ""
|
156 |
-
"Do you want to track all WooCommerce orders in Mailchimp so you can send "
|
157 |
-
"emails based on the purchase activity of your subscribers?"
|
158 |
-
msgstr "Искате ли да следите всички WooCommerce поръчки през Mailchimp, така че да можете да изпращате имейли, в зависимост от покупателната активността на всички Вашите абонати?"
|
159 |
-
|
160 |
-
#: includes/admin/class-ads.php:153
|
161 |
-
msgid ""
|
162 |
-
"<a href=\"%s\">Upgrade to Mailchimp for WordPress Premium</a> or <a "
|
163 |
-
"href=\"%s\">read more about Mailchimp's E-Commerce features</a>."
|
164 |
-
msgstr "<a href=\"%s\">Обновете до MailChim за WordPress Premium </a> или <a href=\"%s\"> прочетете повече за Mailchimp функциите за електронна търговия </a>."
|
165 |
-
|
166 |
-
#: includes/admin/class-review-notice.php:68
|
167 |
-
msgid ""
|
168 |
-
"You've been using Mailchimp for WordPress for some time now; we hope you "
|
169 |
-
"love it!"
|
170 |
-
msgstr "Вие вече използвате Mailchimp за WordPress от известно време; надяваме се, че Ви харесва!"
|
171 |
-
|
172 |
-
#: includes/admin/class-review-notice.php:69
|
173 |
-
msgid ""
|
174 |
-
"If you do, please <a href=\"%s\">leave us a 5★ rating on WordPress.org</a>. "
|
175 |
-
"It would be of great help to us."
|
176 |
-
msgstr "Ако е така, моля <a href=\"%s\">гласувайте с 5★ на WordPress.org</a>. Това ще ни помогно много."
|
177 |
-
|
178 |
-
#: includes/admin/class-review-notice.php:71
|
179 |
-
msgid "Dismiss this notice."
|
180 |
-
msgstr "Игнорирайте това съобщение."
|
181 |
-
|
182 |
-
#: includes/api/class-api.php:84
|
183 |
-
msgid "Read more about common connectivity issues."
|
184 |
-
msgstr "Прочетете повече за основни проблеми със свързването."
|
185 |
-
|
186 |
-
#: includes/forms/class-admin.php:62
|
187 |
-
msgid "Add to form"
|
188 |
-
msgstr "Добави към формата"
|
189 |
-
|
190 |
-
#: includes/forms/class-admin.php:63
|
191 |
-
msgid "City"
|
192 |
-
msgstr "Град"
|
193 |
-
|
194 |
-
#: includes/forms/class-admin.php:64
|
195 |
-
msgid "Checkboxes"
|
196 |
-
msgstr "Кутийки за отбелязване"
|
197 |
-
|
198 |
-
#: includes/forms/class-admin.php:65
|
199 |
-
msgid "Choices"
|
200 |
-
msgstr "Предложения"
|
201 |
-
|
202 |
-
#: includes/forms/class-admin.php:66
|
203 |
-
msgid "Choice type"
|
204 |
-
msgstr "Тип предложение"
|
205 |
-
|
206 |
-
#: includes/forms/class-admin.php:67
|
207 |
-
msgid "Choose a field to add to the form"
|
208 |
-
msgstr "Изберете поле за добавяне към формата"
|
209 |
-
|
210 |
-
#: includes/forms/class-admin.php:68
|
211 |
-
msgid "Close"
|
212 |
-
msgstr "Затвори"
|
213 |
-
|
214 |
-
#: includes/forms/class-admin.php:69
|
215 |
-
msgid "Country"
|
216 |
-
msgstr "Държава"
|
217 |
-
|
218 |
-
#: includes/forms/class-admin.php:70
|
219 |
-
msgid "Dropdown"
|
220 |
-
msgstr "Падащо меню"
|
221 |
-
|
222 |
-
#: includes/forms/class-admin.php:71
|
223 |
-
msgid "Field type"
|
224 |
-
msgstr "Тип поле"
|
225 |
-
|
226 |
-
#: includes/forms/class-admin.php:72
|
227 |
-
msgid "Field label"
|
228 |
-
msgstr "Етикет на полето"
|
229 |
-
|
230 |
-
#: includes/forms/class-admin.php:73
|
231 |
-
msgid "Form action"
|
232 |
-
msgstr "Действие на формата"
|
233 |
-
|
234 |
-
#: includes/forms/class-admin.php:74
|
235 |
-
msgid ""
|
236 |
-
"This field will allow your visitors to choose whether they would like to "
|
237 |
-
"subscribe or unsubscribe"
|
238 |
-
msgstr "Това поле ще позволи на посетители Ви да изберат дали искат да се абонират или откажат от абонамент"
|
239 |
-
|
240 |
-
#: includes/forms/class-admin.php:75
|
241 |
-
msgid "Form fields"
|
242 |
-
msgstr "Полета на формата"
|
243 |
-
|
244 |
-
#: includes/forms/class-admin.php:76
|
245 |
-
msgid "This field is marked as required in Mailchimp."
|
246 |
-
msgstr "Това поле е отбелязано като задължително в Mailchimp."
|
247 |
-
|
248 |
-
#: includes/forms/class-admin.php:77
|
249 |
-
msgid "Initial value"
|
250 |
-
msgstr "Първоначална стойност"
|
251 |
-
|
252 |
-
#: includes/forms/class-admin.php:78
|
253 |
-
msgid "Interest categories"
|
254 |
-
msgstr "Категории на интереси"
|
255 |
-
|
256 |
-
#: includes/forms/class-admin.php:79
|
257 |
-
msgid "Is this field required?"
|
258 |
-
msgstr "Задължително ли е това поле?"
|
259 |
-
|
260 |
-
#: includes/forms/class-admin.php:80
|
261 |
-
msgid "List choice"
|
262 |
-
msgstr "Списък с предложения"
|
263 |
-
|
264 |
-
#: includes/forms/class-admin.php:81
|
265 |
-
msgid "This field will allow your visitors to choose a list to subscribe to."
|
266 |
-
msgstr "Това поле ще позволи на посетителите Ви да изберат списък, за който да се абонират."
|
267 |
-
|
268 |
-
#: includes/forms/class-admin.php:82
|
269 |
-
msgid "List fields"
|
270 |
-
msgstr "Полета в списъка"
|
271 |
-
|
272 |
-
#: includes/forms/class-admin.php:83
|
273 |
-
msgid "Min"
|
274 |
-
msgstr "Минимум"
|
275 |
-
|
276 |
-
#: includes/forms/class-admin.php:84
|
277 |
-
msgid "Max"
|
278 |
-
msgstr "Максимум"
|
279 |
-
|
280 |
-
#: includes/forms/class-admin.php:85
|
281 |
-
msgid ""
|
282 |
-
"No available fields. Did you select a Mailchimp list in the form settings?"
|
283 |
-
msgstr "Няма налични полета. Избрали ли сте Mailchimp списък от настройките на формата?"
|
284 |
-
|
285 |
-
#: includes/forms/class-admin.php:86
|
286 |
-
msgid "Optional"
|
287 |
-
msgstr "Пожелателно"
|
288 |
-
|
289 |
-
#: includes/forms/class-admin.php:87
|
290 |
-
msgid "Placeholder"
|
291 |
-
msgstr ""
|
292 |
-
|
293 |
-
#: includes/forms/class-admin.php:88
|
294 |
-
msgid "Text to show when field has no value."
|
295 |
-
msgstr "Текст, който се показва, когато полета няма стойност."
|
296 |
-
|
297 |
-
#: includes/forms/class-admin.php:89
|
298 |
-
msgid "Preselect"
|
299 |
-
msgstr "Предварително избрано"
|
300 |
-
|
301 |
-
#: includes/forms/class-admin.php:90
|
302 |
-
msgid "Remove"
|
303 |
-
msgstr "Изтрий"
|
304 |
-
|
305 |
-
#: includes/forms/class-admin.php:91
|
306 |
-
msgid "Radio buttons"
|
307 |
-
msgstr "Радио бутон"
|
308 |
-
|
309 |
-
#: includes/forms/class-admin.php:92
|
310 |
-
msgid "Street Address"
|
311 |
-
msgstr "Адрес, улица"
|
312 |
-
|
313 |
-
#: includes/forms/class-admin.php:93
|
314 |
-
msgid "State"
|
315 |
-
msgstr "Щат"
|
316 |
-
|
317 |
-
#: includes/forms/class-admin.php:95
|
318 |
-
msgid "Submit button"
|
319 |
-
msgstr "Бутон за изпращане"
|
320 |
-
|
321 |
-
#: includes/forms/class-admin.php:96
|
322 |
-
msgid "Wrap in paragraph tags?"
|
323 |
-
msgstr ""
|
324 |
-
|
325 |
-
#: includes/forms/class-admin.php:97
|
326 |
-
msgid "Value"
|
327 |
-
msgstr "Стойност"
|
328 |
-
|
329 |
-
#: includes/forms/class-admin.php:98
|
330 |
-
msgid "Text to prefill this field with."
|
331 |
-
msgstr "Текст, с който да запълните предварително това поле."
|
332 |
-
|
333 |
-
#: includes/forms/class-admin.php:99
|
334 |
-
msgid "ZIP"
|
335 |
-
msgstr "Пощенски код"
|
336 |
-
|
337 |
-
#: includes/forms/class-admin.php111, includes/forms/class-admin.php112,
|
338 |
-
#: includes/forms/views/edit-form.php:24
|
339 |
-
msgid "Forms"
|
340 |
-
msgstr "Форми"
|
341 |
-
|
342 |
-
#: includes/forms/class-admin.php152, includes/forms/class-admin.php:276
|
343 |
-
msgid "<strong>Success!</strong> Form successfully saved."
|
344 |
-
msgstr "<strong>Успех!</strong> Формата беше записана."
|
345 |
-
|
346 |
-
#: includes/forms/class-admin.php:276
|
347 |
-
msgid "Preview form"
|
348 |
-
msgstr "Преглед на формата"
|
349 |
-
|
350 |
-
#: includes/forms/class-admin.php449, includes/forms/class-widget.php:30
|
351 |
-
msgid "Mailchimp Sign-Up Form"
|
352 |
-
msgstr "Mailchimp форма за регистрация"
|
353 |
-
|
354 |
-
#: includes/forms/class-admin.php:453
|
355 |
-
msgid "Select the form to show"
|
356 |
-
msgstr "Изберете формата за показване"
|
357 |
-
|
358 |
-
#: includes/forms/class-form-previewer.php:146
|
359 |
-
msgid "Form preview"
|
360 |
-
msgstr "Форма за преглеждане"
|
361 |
-
|
362 |
-
#: includes/forms/class-form-tags.php:60
|
363 |
-
msgid "Replaced with the form response (error or success messages)."
|
364 |
-
msgstr "Заместено с отговора от формата (грешка или успех)."
|
365 |
-
|
366 |
-
#: includes/forms/class-form-tags.php:65
|
367 |
-
msgid "Data from the URL or a submitted form."
|
368 |
-
msgstr "Данни от URL или изпратената форма."
|
369 |
-
|
370 |
-
#: includes/forms/class-form-tags.php:71
|
371 |
-
msgid "Data from a cookie."
|
372 |
-
msgstr "Данни от бисквитки."
|
373 |
-
|
374 |
-
#: includes/forms/class-form-tags.php77,
|
375 |
-
#: includes/integrations/class-integration-tags.php:45
|
376 |
-
msgid "Replaced with the number of subscribers on the selected list(s)"
|
377 |
-
msgstr "Заместено с броя на абонатите от избрания списък или (списъци)"
|
378 |
-
|
379 |
-
#: includes/forms/class-form-tags.php:82
|
380 |
-
msgid "The email address of the current visitor (if known)."
|
381 |
-
msgstr "Имейл адреса на текущият посетител (ако се знае)."
|
382 |
-
|
383 |
-
#: includes/forms/class-form-tags.php:87
|
384 |
-
msgid "The URL of the page."
|
385 |
-
msgstr "URL на страницата."
|
386 |
-
|
387 |
-
#: includes/forms/class-form-tags.php:92
|
388 |
-
msgid "The path of the page."
|
389 |
-
msgstr "Пътечката към тази страница."
|
390 |
-
|
391 |
-
#: includes/forms/class-form-tags.php:97
|
392 |
-
msgid "The current date. Example: %s."
|
393 |
-
msgstr "Днешна дата. Пример: %s."
|
394 |
-
|
395 |
-
#: includes/forms/class-form-tags.php:102
|
396 |
-
msgid "The current time. Example: %s."
|
397 |
-
msgstr "Текущо време. Пример: %s."
|
398 |
-
|
399 |
-
#: includes/forms/class-form-tags.php:107
|
400 |
-
msgid "The site's language. Example: %s."
|
401 |
-
msgstr "Език на страницата. Пример: %s."
|
402 |
-
|
403 |
-
#: includes/forms/class-form-tags.php:112
|
404 |
-
msgid "The visitor's IP address. Example: %s."
|
405 |
-
msgstr ""
|
406 |
-
|
407 |
-
#: includes/forms/class-form-tags.php:117
|
408 |
-
msgid "The property of the currently logged-in user."
|
409 |
-
msgstr ""
|
410 |
-
|
411 |
-
#: includes/forms/class-form-tags.php:123
|
412 |
-
msgid "Property of the current page or post."
|
413 |
-
msgstr ""
|
414 |
-
|
415 |
-
#: includes/forms/class-form.php:133
|
416 |
-
msgid "There is no form with ID %d, perhaps it was deleted?"
|
417 |
-
msgstr ""
|
418 |
-
|
419 |
-
#: includes/forms/class-widget.php:26
|
420 |
-
msgid "Newsletter"
|
421 |
-
msgstr "Бюлетин"
|
422 |
-
|
423 |
-
#: includes/forms/class-widget.php:32
|
424 |
-
msgid "Displays your Mailchimp for WordPress sign-up form"
|
425 |
-
msgstr "Показва вашият Mailchimp за формата за регистрация на WordPress"
|
426 |
-
|
427 |
-
#: includes/forms/class-widget.php:75
|
428 |
-
msgid "Title:"
|
429 |
-
msgstr "Заглавие:"
|
430 |
-
|
431 |
-
#: includes/forms/class-widget.php:92
|
432 |
-
msgid ""
|
433 |
-
"You can edit your sign-up form in the <a href=\"%s\">Mailchimp for WordPress"
|
434 |
-
" form settings</a>."
|
435 |
-
msgstr ""
|
436 |
-
|
437 |
-
#: includes/integrations/class-admin.php79,
|
438 |
-
#: includes/integrations/class-admin.php80,
|
439 |
-
#: includes/integrations/views/integration-settings.php10,
|
440 |
-
#: includes/integrations/views/integrations.php57,
|
441 |
-
#: includes/integrations/views/integrations.php:65
|
442 |
-
msgid "Integrations"
|
443 |
-
msgstr ""
|
444 |
-
|
445 |
-
#: includes/views/general-settings.php7, includes/views/other-settings.php58,
|
446 |
-
#: includes/forms/views/edit-form.php22,
|
447 |
-
#: includes/integrations/views/integration-settings.php8,
|
448 |
-
#: includes/integrations/views/integrations.php:55
|
449 |
-
msgid "You are here: "
|
450 |
-
msgstr ""
|
451 |
-
|
452 |
-
#: includes/views/general-settings.php:18
|
453 |
-
msgid "General Settings"
|
454 |
-
msgstr "Основни настройки"
|
455 |
-
|
456 |
-
#: includes/views/general-settings.php:38
|
457 |
-
msgid "Status"
|
458 |
-
msgstr "Статус"
|
459 |
-
|
460 |
-
#: includes/views/general-settings.php:42
|
461 |
-
msgid "CONNECTED"
|
462 |
-
msgstr "СВЪРЗАН"
|
463 |
-
|
464 |
-
#: includes/views/general-settings.php:44
|
465 |
-
msgid "NOT CONNECTED"
|
466 |
-
msgstr "НЯМА ВРЪЗКА"
|
467 |
-
|
468 |
-
#: includes/views/general-settings.php:51
|
469 |
-
msgid "API Key"
|
470 |
-
msgstr "API ключ"
|
471 |
-
|
472 |
-
#: includes/views/general-settings.php:53
|
473 |
-
msgid "Your Mailchimp API key"
|
474 |
-
msgstr "Вашият Mailchimp API ключ"
|
475 |
-
|
476 |
-
#: includes/views/general-settings.php:55
|
477 |
-
msgid "The API key for connecting with your Mailchimp account."
|
478 |
-
msgstr ""
|
479 |
-
|
480 |
-
#: includes/views/general-settings.php:56
|
481 |
-
msgid "Get your API key here."
|
482 |
-
msgstr "Вземете API ключ оттук."
|
483 |
-
|
484 |
-
#: includes/views/other-settings.php:14
|
485 |
-
msgid "Miscellaneous settings"
|
486 |
-
msgstr ""
|
487 |
-
|
488 |
-
#: includes/views/other-settings.php:17
|
489 |
-
msgid "Usage Tracking"
|
490 |
-
msgstr ""
|
491 |
-
|
492 |
-
#: includes/views/other-settings.php:29
|
493 |
-
msgid ""
|
494 |
-
"Allow us to anonymously track how this plugin is used to help us make it "
|
495 |
-
"better fit your needs."
|
496 |
-
msgstr ""
|
497 |
-
|
498 |
-
#: includes/views/other-settings.php:31
|
499 |
-
msgid "This is what we track."
|
500 |
-
msgstr "Това, което следим."
|
501 |
-
|
502 |
-
#: includes/views/other-settings.php:37
|
503 |
-
msgid "Logging"
|
504 |
-
msgstr ""
|
505 |
-
|
506 |
-
#: includes/views/other-settings.php:44
|
507 |
-
msgid ""
|
508 |
-
"Determines what events should be written to <a href=\"%s\">the debug log</a>"
|
509 |
-
" (see below)."
|
510 |
-
msgstr ""
|
511 |
-
|
512 |
-
#: includes/views/other-settings.php:99
|
513 |
-
msgid "Debug Log"
|
514 |
-
msgstr ""
|
515 |
-
|
516 |
-
#: includes/views/other-settings.php:99
|
517 |
-
msgid "Filter.."
|
518 |
-
msgstr ""
|
519 |
-
|
520 |
-
#: includes/views/other-settings.php:104
|
521 |
-
msgid "Log file is not writable."
|
522 |
-
msgstr ""
|
523 |
-
|
524 |
-
#: includes/views/other-settings.php:105
|
525 |
-
msgid "Please ensure %s has the proper <a href=\"%s\">file permissions</a>."
|
526 |
-
msgstr ""
|
527 |
-
|
528 |
-
#: includes/views/other-settings.php:123
|
529 |
-
msgid "Nothing here. Which means there are no errors!"
|
530 |
-
msgstr ""
|
531 |
-
|
532 |
-
#: includes/views/other-settings.php:133
|
533 |
-
msgid "Empty Log"
|
534 |
-
msgstr ""
|
535 |
-
|
536 |
-
#: includes/views/other-settings.php:141
|
537 |
-
msgid "Right now, the plugin is configured to only log errors and warnings."
|
538 |
-
msgstr ""
|
539 |
-
|
540 |
-
#: includes/admin/migrations/3.0.0-form-1-post-type.php:35
|
541 |
-
msgid "Default sign-up form"
|
542 |
-
msgstr ""
|
543 |
-
|
544 |
-
#: includes/forms/views/add-form.php10, includes/forms/views/add-form.php:60
|
545 |
-
msgid "Add new form"
|
546 |
-
msgstr ""
|
547 |
-
|
548 |
-
#: includes/forms/views/add-form.php:27
|
549 |
-
msgid "What is the name of this form?"
|
550 |
-
msgstr ""
|
551 |
-
|
552 |
-
#: includes/forms/views/add-form.php:30
|
553 |
-
msgid "Enter your form title.."
|
554 |
-
msgstr ""
|
555 |
-
|
556 |
-
#: includes/forms/views/add-form.php:37
|
557 |
-
msgid "To which Mailchimp lists should this form subscribe?"
|
558 |
-
msgstr ""
|
559 |
-
|
560 |
-
#: includes/forms/views/add-form.php:54
|
561 |
-
msgid "No lists found. Did you <a href=\"%s\">connect with Mailchimp</a>?"
|
562 |
-
msgstr ""
|
563 |
-
|
564 |
-
#: includes/forms/views/edit-form.php:4
|
565 |
-
msgid "Fields"
|
566 |
-
msgstr "Полета"
|
567 |
-
|
568 |
-
#: includes/forms/views/edit-form.php:5
|
569 |
-
msgid "Messages"
|
570 |
-
msgstr "Съобщения"
|
571 |
-
|
572 |
-
#: includes/forms/views/edit-form.php:7
|
573 |
-
msgid "Appearance"
|
574 |
-
msgstr "Облик"
|
575 |
-
|
576 |
-
#: includes/forms/views/edit-form.php:25
|
577 |
-
msgid "Form"
|
578 |
-
msgstr ""
|
579 |
-
|
580 |
-
#: includes/forms/views/edit-form.php:34
|
581 |
-
msgid "Edit Form"
|
582 |
-
msgstr ""
|
583 |
-
|
584 |
-
#: includes/forms/views/edit-form.php:58
|
585 |
-
msgid "Enter form title here"
|
586 |
-
msgstr ""
|
587 |
-
|
588 |
-
#: includes/forms/views/edit-form.php:59
|
589 |
-
msgid "Enter the title of your sign-up form"
|
590 |
-
msgstr ""
|
591 |
-
|
592 |
-
#: includes/forms/views/edit-form.php:65
|
593 |
-
msgid "Shortcode"
|
594 |
-
msgstr ""
|
595 |
-
|
596 |
-
#: includes/forms/views/edit-form.php:67
|
597 |
-
msgid "Get shortcode"
|
598 |
-
msgstr ""
|
599 |
-
|
600 |
-
#: includes/forms/views/edit-form.php:72
|
601 |
-
msgid "Preview this form"
|
602 |
-
msgstr ""
|
603 |
-
|
604 |
-
#: includes/integrations/views/integration-settings.php:20
|
605 |
-
msgid "%s integration"
|
606 |
-
msgstr ""
|
607 |
-
|
608 |
-
#: includes/integrations/views/integration-settings.php:27
|
609 |
-
msgid ""
|
610 |
-
"The selected Mailchimp lists require non-default fields, which may prevent "
|
611 |
-
"this integration from working."
|
612 |
-
msgstr ""
|
613 |
-
|
614 |
-
#: includes/integrations/views/integration-settings.php:28
|
615 |
-
msgid ""
|
616 |
-
"Please ensure you <a href=\"%s\">configure the plugin to send all required "
|
617 |
-
"fields</a> or <a href=\"%s\">log into your Mailchimp account</a> and make "
|
618 |
-
"sure only the email & name fields are marked as required fields for the "
|
619 |
-
"selected list(s)."
|
620 |
-
msgstr ""
|
621 |
-
|
622 |
-
#: includes/integrations/views/integration-settings.php:62
|
623 |
-
msgid "Enabled?"
|
624 |
-
msgstr "Включено?"
|
625 |
-
|
626 |
-
#: includes/integrations/views/integration-settings.php:66
|
627 |
-
msgid ""
|
628 |
-
"Enable the %s integration? This will add a sign-up checkbox to the form."
|
629 |
-
msgstr ""
|
630 |
-
|
631 |
-
#: includes/integrations/views/integration-settings.php:76
|
632 |
-
msgid "Implicit?"
|
633 |
-
msgstr "Изрично?"
|
634 |
-
|
635 |
-
#: includes/integrations/views/integration-settings.php:80
|
636 |
-
msgid ""
|
637 |
-
"Select \"no\" if you want to ask your visitors before they are subscribed "
|
638 |
-
"(recommended)."
|
639 |
-
msgstr ""
|
640 |
-
|
641 |
-
#: includes/integrations/views/integration-settings.php:90
|
642 |
-
msgid "Mailchimp Lists"
|
643 |
-
msgstr "Mailchimp списъци"
|
644 |
-
|
645 |
-
#: includes/integrations/views/integration-settings.php:103
|
646 |
-
msgid ""
|
647 |
-
"Select the list(s) to which people who check the checkbox should be "
|
648 |
-
"subscribed."
|
649 |
-
msgstr "Изберете списък(ци) към които посетителите, маркирали отметката, ще бъдат абонирани."
|
650 |
-
|
651 |
-
#: includes/integrations/views/integration-settings.php107,
|
652 |
-
#: includes/forms/views/tabs/form-settings.php:18
|
653 |
-
msgid "No lists found, <a href=\"%s\">are you connected to Mailchimp</a>?"
|
654 |
-
msgstr ""
|
655 |
-
|
656 |
-
#: includes/integrations/views/integration-settings.php:116
|
657 |
-
msgid "Checkbox label text"
|
658 |
-
msgstr "Текст за етикетите на отметките"
|
659 |
-
|
660 |
-
#: includes/integrations/views/integration-settings.php:119
|
661 |
-
msgid "HTML tags like %s are allowed in the label text."
|
662 |
-
msgstr "HTML тагове като %s са разрешени в текста."
|
663 |
-
|
664 |
-
#: includes/integrations/views/integration-settings.php:129
|
665 |
-
msgid "Pre-check the checkbox?"
|
666 |
-
msgstr "Предварителен преглед на отметката?"
|
667 |
-
|
668 |
-
#: includes/integrations/views/integration-settings.php:133
|
669 |
-
msgid "Select \"yes\" if the checkbox should be pre-checked."
|
670 |
-
msgstr "Изберете \"да\" ако отметката трябва да е попълнена предварително."
|
671 |
-
|
672 |
-
#: includes/integrations/views/integration-settings.php:141
|
673 |
-
msgid "Load some default CSS?"
|
674 |
-
msgstr "Зареди CSS по подразбиране?"
|
675 |
-
|
676 |
-
#: includes/integrations/views/integration-settings.php:145
|
677 |
-
msgid "Select \"yes\" if the checkbox appears in a weird place."
|
678 |
-
msgstr "Изберете \"да\" ако отметката не изглежда на правилното място."
|
679 |
-
|
680 |
-
#: includes/integrations/views/integration-settings.php:152
|
681 |
-
msgid "Double opt-in?"
|
682 |
-
msgstr "Двойна верификация?"
|
683 |
-
|
684 |
-
#: includes/integrations/views/integration-settings.php:163
|
685 |
-
msgid ""
|
686 |
-
"Select \"yes\" if you want people to confirm their email address before "
|
687 |
-
"being subscribed (recommended)"
|
688 |
-
msgstr "Изберете \"да\" ако искате посетителите да потвърждават техния email преди да бъдат абонирани (препоръчително)"
|
689 |
-
|
690 |
-
#: includes/integrations/views/integration-settings.php171,
|
691 |
-
#: includes/forms/views/tabs/form-settings.php:52
|
692 |
-
msgid "Update existing subscribers?"
|
693 |
-
msgstr ""
|
694 |
-
|
695 |
-
#: includes/integrations/views/integration-settings.php181,
|
696 |
-
#: includes/forms/views/tabs/form-settings.php:62
|
697 |
-
msgid ""
|
698 |
-
"Select \"yes\" if you want to update existing subscribers with the data that"
|
699 |
-
" is sent."
|
700 |
-
msgstr ""
|
701 |
-
|
702 |
-
#: includes/integrations/views/integration-settings.php190,
|
703 |
-
#: includes/forms/views/tabs/form-settings.php:68
|
704 |
-
msgid "Replace interest groups?"
|
705 |
-
msgstr ""
|
706 |
-
|
707 |
-
#: includes/integrations/views/integration-settings.php201,
|
708 |
-
#: includes/forms/views/tabs/form-settings.php:79
|
709 |
-
msgid ""
|
710 |
-
"Select \"no\" if you want to add the selected interests to any previously "
|
711 |
-
"selected interests when updating a subscriber."
|
712 |
-
msgstr ""
|
713 |
-
|
714 |
-
#: includes/integrations/views/integration-settings.php202,
|
715 |
-
#: includes/forms/views/tabs/form-settings.php:80
|
716 |
-
msgid "What does this do?"
|
717 |
-
msgstr ""
|
718 |
-
|
719 |
-
#: includes/integrations/views/integrations.php:17
|
720 |
-
msgid "Name"
|
721 |
-
msgstr "Име"
|
722 |
-
|
723 |
-
#: includes/integrations/views/integrations.php:18
|
724 |
-
msgid "Description"
|
725 |
-
msgstr "Описание"
|
726 |
-
|
727 |
-
#: includes/integrations/views/integrations.php:35
|
728 |
-
msgid "Configure this integration"
|
729 |
-
msgstr "Конфигурирай интеграцията"
|
730 |
-
|
731 |
-
#: includes/integrations/views/integrations.php:71
|
732 |
-
msgid "The table below shows all available integrations."
|
733 |
-
msgstr ""
|
734 |
-
|
735 |
-
#: includes/integrations/views/integrations.php:72
|
736 |
-
msgid ""
|
737 |
-
"Click on the name of an integration to edit all settings specific to that "
|
738 |
-
"integration."
|
739 |
-
msgstr ""
|
740 |
-
|
741 |
-
#: includes/integrations/views/integrations.php:79
|
742 |
-
msgid "Enabled integrations"
|
743 |
-
msgstr ""
|
744 |
-
|
745 |
-
#: includes/integrations/views/integrations.php:84
|
746 |
-
msgid "Available integrations"
|
747 |
-
msgstr ""
|
748 |
-
|
749 |
-
#: includes/views/parts/admin-footer.php:15
|
750 |
-
msgid ""
|
751 |
-
"Mailchimp for WordPress is in need of translations. Is the plugin not "
|
752 |
-
"translated in your language or do you spot errors with the current "
|
753 |
-
"translations? Helping out is easy! Head over to <a href=\"%s\">the "
|
754 |
-
"translation project and click \"help translate\"</a>."
|
755 |
-
msgstr ""
|
756 |
-
|
757 |
-
#: includes/views/parts/admin-footer.php:35
|
758 |
-
msgid ""
|
759 |
-
"This plugin is not developed by or affiliated with Mailchimp in any way."
|
760 |
-
msgstr ""
|
761 |
-
|
762 |
-
#: includes/views/parts/admin-sidebar.php:11
|
763 |
-
msgid "Looking for help?"
|
764 |
-
msgstr ""
|
765 |
-
|
766 |
-
#: includes/views/parts/admin-sidebar.php:12
|
767 |
-
msgid "We have some resources available to help you in the right direction."
|
768 |
-
msgstr ""
|
769 |
-
|
770 |
-
#: includes/views/parts/admin-sidebar.php:14
|
771 |
-
msgid "Knowledge Base"
|
772 |
-
msgstr ""
|
773 |
-
|
774 |
-
#: includes/views/parts/admin-sidebar.php:15
|
775 |
-
msgid "Frequently Asked Questions"
|
776 |
-
msgstr ""
|
777 |
-
|
778 |
-
#: includes/views/parts/admin-sidebar.php:16
|
779 |
-
msgid "Code reference for developers"
|
780 |
-
msgstr ""
|
781 |
-
|
782 |
-
#: includes/views/parts/admin-sidebar.php:36
|
783 |
-
msgid "Looking to improve your sign-up rates?"
|
784 |
-
msgstr ""
|
785 |
-
|
786 |
-
#: includes/views/parts/admin-sidebar.php:37
|
787 |
-
msgid ""
|
788 |
-
"Our <a href=\"%s\">Boxzilla plugin</a> allows you to create pop-ups or "
|
789 |
-
"slide-ins with a subscribe form. A sure way to grow your lists faster."
|
790 |
-
msgstr ""
|
791 |
-
|
792 |
-
#: includes/views/parts/lists-overview.php:1
|
793 |
-
msgid "Your Mailchimp Account"
|
794 |
-
msgstr "Вашият Mailchimp Акаунт"
|
795 |
-
|
796 |
-
#: includes/views/parts/lists-overview.php:2
|
797 |
-
msgid ""
|
798 |
-
"The table below shows your Mailchimp lists and their details. If you just "
|
799 |
-
"applied changes to your Mailchimp lists, please use the following button to "
|
800 |
-
"renew the cached lists configuration."
|
801 |
-
msgstr ""
|
802 |
-
|
803 |
-
#: includes/views/parts/lists-overview.php:17
|
804 |
-
msgid "No lists were found in your Mailchimp account"
|
805 |
-
msgstr "Не бяха открити списъци във вашия Mailchimp акаунт."
|
806 |
-
|
807 |
-
#: includes/views/parts/lists-overview.php:19
|
808 |
-
msgid "A total of %d lists were found in your Mailchimp account."
|
809 |
-
msgstr ""
|
810 |
-
|
811 |
-
#: includes/views/parts/lists-overview.php:24
|
812 |
-
msgid "List Name"
|
813 |
-
msgstr ""
|
814 |
-
|
815 |
-
#: includes/views/parts/lists-overview.php:25
|
816 |
-
msgid "ID"
|
817 |
-
msgstr ""
|
818 |
-
|
819 |
-
#: includes/views/parts/lists-overview.php:26
|
820 |
-
msgid "Subscribers"
|
821 |
-
msgstr ""
|
822 |
-
|
823 |
-
#: includes/views/parts/lists-overview.php:48
|
824 |
-
msgid "Edit this list in Mailchimp"
|
825 |
-
msgstr ""
|
826 |
-
|
827 |
-
#: includes/views/parts/lists-overview.php:62
|
828 |
-
msgid "%s (%s) with field type %s."
|
829 |
-
msgstr ""
|
830 |
-
|
831 |
-
#: includes/forms/views/parts/add-fields-help.php4,
|
832 |
-
#: includes/forms/views/tabs/form-fields.php:10
|
833 |
-
msgid "Add more fields"
|
834 |
-
msgstr "Добавете още полета"
|
835 |
-
|
836 |
-
#: includes/forms/views/parts/add-fields-help.php:9
|
837 |
-
msgid ""
|
838 |
-
"To add more fields to your form, you will need to create those fields in "
|
839 |
-
"Mailchimp first."
|
840 |
-
msgstr ""
|
841 |
-
|
842 |
-
#: includes/forms/views/parts/add-fields-help.php:12
|
843 |
-
msgid "Here's how:"
|
844 |
-
msgstr "Ето как:"
|
845 |
-
|
846 |
-
#: includes/forms/views/parts/add-fields-help.php:17
|
847 |
-
msgid "Log in to your Mailchimp account."
|
848 |
-
msgstr ""
|
849 |
-
|
850 |
-
#: includes/forms/views/parts/add-fields-help.php:22
|
851 |
-
msgid "Add list fields to any of your selected lists."
|
852 |
-
msgstr ""
|
853 |
-
|
854 |
-
#: includes/forms/views/parts/add-fields-help.php:23
|
855 |
-
msgid "Clicking the following links will take you to the right screen."
|
856 |
-
msgstr ""
|
857 |
-
|
858 |
-
#: includes/forms/views/parts/add-fields-help.php:29
|
859 |
-
msgid "Edit list fields for"
|
860 |
-
msgstr ""
|
861 |
-
|
862 |
-
#: includes/forms/views/parts/add-fields-help.php:38
|
863 |
-
msgid ""
|
864 |
-
"Click the following button to have Mailchimp for WordPress pick up on your "
|
865 |
-
"changes."
|
866 |
-
msgstr ""
|
867 |
-
|
868 |
-
#: includes/forms/views/parts/dynamic-content-tags.php:6
|
869 |
-
msgid "Add dynamic form variable"
|
870 |
-
msgstr ""
|
871 |
-
|
872 |
-
#: includes/forms/views/parts/dynamic-content-tags.php:8
|
873 |
-
msgid ""
|
874 |
-
"The following list of variables can be used to <a href=\"%s\">add some "
|
875 |
-
"dynamic content to your form or success and error messages</a>."
|
876 |
-
msgstr ""
|
877 |
-
|
878 |
-
#: includes/forms/views/parts/dynamic-content-tags.php:8
|
879 |
-
msgid "This allows you to personalise your form or response messages."
|
880 |
-
msgstr ""
|
881 |
-
|
882 |
-
#: includes/forms/views/tabs/form-appearance.php:5
|
883 |
-
msgid "Inherit from %s theme"
|
884 |
-
msgstr ""
|
885 |
-
|
886 |
-
#: includes/forms/views/tabs/form-appearance.php:6
|
887 |
-
msgid "Basic"
|
888 |
-
msgstr ""
|
889 |
-
|
890 |
-
#: includes/forms/views/tabs/form-appearance.php:7
|
891 |
-
msgid "Form Themes"
|
892 |
-
msgstr ""
|
893 |
-
|
894 |
-
#: includes/forms/views/tabs/form-appearance.php:8
|
895 |
-
msgid "Light Theme"
|
896 |
-
msgstr "Светла Тема"
|
897 |
-
|
898 |
-
#: includes/forms/views/tabs/form-appearance.php:9
|
899 |
-
msgid "Dark Theme"
|
900 |
-
msgstr "Тъмна Тема"
|
901 |
-
|
902 |
-
#: includes/forms/views/tabs/form-appearance.php:10
|
903 |
-
msgid "Red Theme"
|
904 |
-
msgstr "Червена Тема"
|
905 |
-
|
906 |
-
#: includes/forms/views/tabs/form-appearance.php:11
|
907 |
-
msgid "Green Theme"
|
908 |
-
msgstr ""
|
909 |
-
|
910 |
-
#: includes/forms/views/tabs/form-appearance.php:12
|
911 |
-
msgid "Blue Theme"
|
912 |
-
msgstr ""
|
913 |
-
|
914 |
-
#: includes/forms/views/tabs/form-appearance.php:25
|
915 |
-
msgid "Form Appearance"
|
916 |
-
msgstr ""
|
917 |
-
|
918 |
-
#: includes/forms/views/tabs/form-appearance.php:29
|
919 |
-
msgid "Form Style"
|
920 |
-
msgstr ""
|
921 |
-
|
922 |
-
#: includes/forms/views/tabs/form-appearance.php:48
|
923 |
-
msgid ""
|
924 |
-
"If you want to load some default CSS styles, select \"basic formatting "
|
925 |
-
"styles\" or choose one of the color themes"
|
926 |
-
msgstr ""
|
927 |
-
|
928 |
-
#: includes/forms/views/tabs/form-fields.php:6
|
929 |
-
msgid "Form variables"
|
930 |
-
msgstr ""
|
931 |
-
|
932 |
-
#: includes/forms/views/tabs/form-fields.php:13
|
933 |
-
msgid "Form Fields"
|
934 |
-
msgstr "Полета във формата"
|
935 |
-
|
936 |
-
#: includes/forms/views/tabs/form-fields.php:19
|
937 |
-
msgid "Enter the HTML code for your form fields.."
|
938 |
-
msgstr ""
|
939 |
-
|
940 |
-
#: includes/forms/views/tabs/form-fields.php:26
|
941 |
-
msgid ""
|
942 |
-
"Use the shortcode %s to display this form inside a post, page or text "
|
943 |
-
"widget."
|
944 |
-
msgstr ""
|
945 |
-
|
946 |
-
#: includes/forms/views/tabs/form-messages.php:6
|
947 |
-
msgid "Form Messages"
|
948 |
-
msgstr ""
|
949 |
-
|
950 |
-
#: includes/forms/views/tabs/form-messages.php:16
|
951 |
-
msgid "Successfully subscribed"
|
952 |
-
msgstr ""
|
953 |
-
|
954 |
-
#: includes/forms/views/tabs/form-messages.php:19
|
955 |
-
msgid ""
|
956 |
-
"The text that shows when an email address is successfully subscribed to the "
|
957 |
-
"selected list(s)."
|
958 |
-
msgstr ""
|
959 |
-
|
960 |
-
#: includes/forms/views/tabs/form-messages.php:23
|
961 |
-
msgid "Invalid email address"
|
962 |
-
msgstr "Невалиден имейл адрес"
|
963 |
-
|
964 |
-
#: includes/forms/views/tabs/form-messages.php:26
|
965 |
-
msgid "The text that shows when an invalid email address is given."
|
966 |
-
msgstr ""
|
967 |
-
|
968 |
-
#: includes/forms/views/tabs/form-messages.php:30
|
969 |
-
msgid "Required field missing"
|
970 |
-
msgstr ""
|
971 |
-
|
972 |
-
#: includes/forms/views/tabs/form-messages.php:33
|
973 |
-
msgid ""
|
974 |
-
"The text that shows when a required field for the selected list(s) is "
|
975 |
-
"missing."
|
976 |
-
msgstr ""
|
977 |
-
|
978 |
-
#: includes/forms/views/tabs/form-messages.php:37
|
979 |
-
msgid "Already subscribed"
|
980 |
-
msgstr ""
|
981 |
-
|
982 |
-
#: includes/forms/views/tabs/form-messages.php:40
|
983 |
-
msgid ""
|
984 |
-
"The text that shows when the given email is already subscribed to the "
|
985 |
-
"selected list(s)."
|
986 |
-
msgstr ""
|
987 |
-
|
988 |
-
#: includes/forms/views/tabs/form-messages.php:44
|
989 |
-
msgid "General error"
|
990 |
-
msgstr "Обща грешка"
|
991 |
-
|
992 |
-
#: includes/forms/views/tabs/form-messages.php:47
|
993 |
-
msgid "The text that shows when a general error occured."
|
994 |
-
msgstr ""
|
995 |
-
|
996 |
-
#: includes/forms/views/tabs/form-messages.php:51
|
997 |
-
msgid "Unsubscribed"
|
998 |
-
msgstr "Отписан/и"
|
999 |
-
|
1000 |
-
#: includes/forms/views/tabs/form-messages.php:54
|
1001 |
-
msgid ""
|
1002 |
-
"When using the unsubscribe method, this is the text that shows when the "
|
1003 |
-
"given email address is successfully unsubscribed from the selected list(s)."
|
1004 |
-
msgstr ""
|
1005 |
-
|
1006 |
-
#: includes/forms/views/tabs/form-messages.php:58
|
1007 |
-
msgid "Not subscribed"
|
1008 |
-
msgstr ""
|
1009 |
-
|
1010 |
-
#: includes/forms/views/tabs/form-messages.php:61
|
1011 |
-
msgid ""
|
1012 |
-
"When using the unsubscribe method, this is the text that shows when the "
|
1013 |
-
"given email address is not on the selected list(s)."
|
1014 |
-
msgstr ""
|
1015 |
-
|
1016 |
-
#: includes/forms/views/tabs/form-messages.php:65
|
1017 |
-
msgid "No list selected"
|
1018 |
-
msgstr ""
|
1019 |
-
|
1020 |
-
#: includes/forms/views/tabs/form-messages.php:68
|
1021 |
-
msgid ""
|
1022 |
-
"When offering a list choice, this is the text that shows when no lists were "
|
1023 |
-
"selected."
|
1024 |
-
msgstr ""
|
1025 |
-
|
1026 |
-
#: includes/forms/views/tabs/form-messages.php:74
|
1027 |
-
msgid "Updated"
|
1028 |
-
msgstr ""
|
1029 |
-
|
1030 |
-
#: includes/forms/views/tabs/form-messages.php:77
|
1031 |
-
msgid "The text that shows when an existing subscriber is updated."
|
1032 |
-
msgstr ""
|
1033 |
-
|
1034 |
-
#: includes/forms/views/tabs/form-messages.php:89
|
1035 |
-
msgid "HTML tags like %s are allowed in the message fields."
|
1036 |
-
msgstr ""
|
1037 |
-
|
1038 |
-
#: includes/forms/views/tabs/form-settings.php:1
|
1039 |
-
msgid "Form Settings"
|
1040 |
-
msgstr "Настройки на формите"
|
1041 |
-
|
1042 |
-
#: includes/forms/views/tabs/form-settings.php:5
|
1043 |
-
msgid "Mailchimp specific settings"
|
1044 |
-
msgstr ""
|
1045 |
-
|
1046 |
-
#: includes/forms/views/tabs/form-settings.php:15
|
1047 |
-
msgid "Lists this form subscribes to"
|
1048 |
-
msgstr ""
|
1049 |
-
|
1050 |
-
#: includes/forms/views/tabs/form-settings.php:31
|
1051 |
-
msgid ""
|
1052 |
-
"Select the list(s) to which people who submit this form should be "
|
1053 |
-
"subscribed."
|
1054 |
-
msgstr ""
|
1055 |
-
|
1056 |
-
#: includes/forms/views/tabs/form-settings.php:37
|
1057 |
-
msgid "Use double opt-in?"
|
1058 |
-
msgstr ""
|
1059 |
-
|
1060 |
-
#: includes/forms/views/tabs/form-settings.php:44
|
1061 |
-
msgid "Are you sure you want to disable double opt-in?"
|
1062 |
-
msgstr ""
|
1063 |
-
|
1064 |
-
#: includes/forms/views/tabs/form-settings.php:47
|
1065 |
-
msgid ""
|
1066 |
-
"We strongly suggest keeping double opt-in enabled. Disabling double opt-in "
|
1067 |
-
"may result in abuse."
|
1068 |
-
msgstr ""
|
1069 |
-
|
1070 |
-
#: includes/forms/views/tabs/form-settings.php:94
|
1071 |
-
msgid "Form behaviour"
|
1072 |
-
msgstr "Поведение на формата"
|
1073 |
-
|
1074 |
-
#: includes/forms/views/tabs/form-settings.php:104
|
1075 |
-
msgid "Hide form after a successful sign-up?"
|
1076 |
-
msgstr ""
|
1077 |
-
|
1078 |
-
#: includes/forms/views/tabs/form-settings.php:115
|
1079 |
-
msgid "Select \"yes\" to hide the form fields after a successful sign-up."
|
1080 |
-
msgstr ""
|
1081 |
-
|
1082 |
-
#: includes/forms/views/tabs/form-settings.php:120
|
1083 |
-
msgid "Redirect to URL after successful sign-ups"
|
1084 |
-
msgstr ""
|
1085 |
-
|
1086 |
-
#: includes/forms/views/tabs/form-settings.php:122
|
1087 |
-
msgid "Example: %s"
|
1088 |
-
msgstr "Пример: %s"
|
1089 |
-
|
1090 |
-
#: includes/forms/views/tabs/form-settings.php:123
|
1091 |
-
msgid ""
|
1092 |
-
"Leave empty or enter <code>0</code> for no redirect. Otherwise, use complete"
|
1093 |
-
" (absolute) URLs, including <code>http://</code>."
|
1094 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/mailchimp-for-wp-ca_ES.mo
DELETED
Binary file
|
languages/mailchimp-for-wp-ca_ES.po
DELETED
@@ -1,1092 +0,0 @@
|
|
1 |
-
# Copyright (C) 2017 mailchimp-for-wp
|
2 |
-
# This file is distributed under the same license as the mailchimp-for-wp package.
|
3 |
-
# Translators:
|
4 |
-
# Miceno Atreides <miceno.atreides@gmail.com>, 2016
|
5 |
-
# Xavier Gimeno Torrent, 2015-2017
|
6 |
-
msgid ""
|
7 |
-
msgstr ""
|
8 |
-
"Project-Id-Version: Mailchimp for WordPress\n"
|
9 |
-
"PO-Revision-Date: 2017-09-23 20:54+0000\n"
|
10 |
-
"Last-Translator: Xavier Gimeno Torrent\n"
|
11 |
-
"Language-Team: Catalan (Spain) (http://www.transifex.com/ibericode/mailchimp-for-wordpress/language/ca_ES/)\n"
|
12 |
-
"MIME-Version: 1.0\n"
|
13 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
-
"Content-Transfer-Encoding: 8bit\n"
|
15 |
-
"Language: ca_ES\n"
|
16 |
-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
17 |
-
"X-Poedit-Basepath: ..\n"
|
18 |
-
"X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
|
19 |
-
"X-Poedit-SearchPath-0: .\n"
|
20 |
-
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
21 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
22 |
-
|
23 |
-
#: includes/admin/class-admin-texts.php62,
|
24 |
-
#: includes/forms/views/edit-form.php:6
|
25 |
-
msgid "Settings"
|
26 |
-
msgstr "Configuració"
|
27 |
-
|
28 |
-
#: includes/admin/class-admin-texts.php:80
|
29 |
-
msgid "Documentation"
|
30 |
-
msgstr "Documentació"
|
31 |
-
|
32 |
-
#: includes/admin/class-admin.php:204
|
33 |
-
msgid ""
|
34 |
-
"Success! The cached configuration for your Mailchimp lists has been renewed."
|
35 |
-
msgstr "Enhorabona! La configuració emmagatzemada a la memòria cau de les teves llistes de Mailchimp s'ha actualitzat."
|
36 |
-
|
37 |
-
#: includes/admin/class-admin.php:304
|
38 |
-
msgid ""
|
39 |
-
"This is a pro-only feature. Please upgrade to the premium version to be able"
|
40 |
-
" to use it."
|
41 |
-
msgstr "Aquesta característica només està disponible a la versió premium. Sisplau, actualitza a la versió premium per a poder utilitzar-la."
|
42 |
-
|
43 |
-
#: includes/admin/class-admin.php305,
|
44 |
-
#: includes/views/parts/lists-overview.php10,
|
45 |
-
#: includes/forms/views/parts/add-fields-help.php:43
|
46 |
-
msgid "Renew Mailchimp lists"
|
47 |
-
msgstr "Actualitzar les llistes de Mailchimp"
|
48 |
-
|
49 |
-
#: includes/admin/class-admin.php:306
|
50 |
-
msgid "Fetching Mailchimp lists"
|
51 |
-
msgstr "Obtenir les llistes de Mailchimp"
|
52 |
-
|
53 |
-
#: includes/admin/class-admin.php:307
|
54 |
-
msgid "Done! Mailchimp lists renewed."
|
55 |
-
msgstr "Ja està! Les llistes de Mailchimp s'han actualitzat."
|
56 |
-
|
57 |
-
#: includes/admin/class-admin.php:308
|
58 |
-
msgid "This can take a while if you have many Mailchimp lists."
|
59 |
-
msgstr "Si tens moltes llistes de Mailchimp això pot trigar una mica."
|
60 |
-
|
61 |
-
#: includes/admin/class-admin.php336, includes/views/general-settings.php:31
|
62 |
-
msgid "Mailchimp API Settings"
|
63 |
-
msgstr "Configuració d'API de Mailchimp"
|
64 |
-
|
65 |
-
#: includes/admin/class-admin.php:337
|
66 |
-
msgid "Mailchimp"
|
67 |
-
msgstr "Mailchimp"
|
68 |
-
|
69 |
-
#: includes/admin/class-admin.php343, includes/views/other-settings.php60,
|
70 |
-
#: includes/views/other-settings.php:70
|
71 |
-
msgid "Other Settings"
|
72 |
-
msgstr "Altres configuracions"
|
73 |
-
|
74 |
-
#: includes/admin/class-admin.php:344
|
75 |
-
msgid "Other"
|
76 |
-
msgstr "Altre/a(s)"
|
77 |
-
|
78 |
-
#: includes/admin/class-admin.php:458
|
79 |
-
msgid "Log successfully emptied."
|
80 |
-
msgstr "El registre s'ha buidat correctament."
|
81 |
-
|
82 |
-
#: includes/admin/class-admin.php:488
|
83 |
-
msgid ""
|
84 |
-
"To get started with Mailchimp for WordPress, please <a href=\"%s\">enter "
|
85 |
-
"your Mailchimp API key on the settings page of the plugin</a>."
|
86 |
-
msgstr "Per començar a utilitzar Mailchimp per a WordPress, sisplau <a href=\"%s\">introdueix la teva Clau API a la pàgina de configuracions del plugin</a>."
|
87 |
-
|
88 |
-
#: includes/admin/class-ads.php:39
|
89 |
-
msgid ""
|
90 |
-
"Want to customize the style of your form? <a href=\"%s\">Try our Styles "
|
91 |
-
"Builder</a> & edit the look of your forms with just a few clicks."
|
92 |
-
msgstr "Vols personalitzar l'estil del teu formulari? <a href=\"%s\">Prova el Creador d'Estils</a> i edita l'aparença dels teus formularis amb uns pocs clics."
|
93 |
-
|
94 |
-
#: includes/admin/class-ads.php:54
|
95 |
-
msgid ""
|
96 |
-
"Be notified whenever someone subscribes? <a href=\"%s\">Mailchimp for "
|
97 |
-
"WordPress Premium</a> allows you to set up email notifications for your "
|
98 |
-
"forms."
|
99 |
-
msgstr "Vols que t'ho notifiquem quan algú es subscrigui? <a href=\"%s\">Mailchimp per a WordPress Premium</a> et permet configurar les notificacions per correu electrònic dels teus formularis."
|
100 |
-
|
101 |
-
#: includes/admin/class-ads.php:56
|
102 |
-
msgid ""
|
103 |
-
"Increased conversions? <a href=\"%s\">Mailchimp for WordPress Premium</a> "
|
104 |
-
"submits forms without reloading the entire page, resulting in a much better "
|
105 |
-
"experience for your visitors."
|
106 |
-
msgstr "Vols que augmentin les conversions? Amb <a href=\"%s\">Mailchimp per a WordPress Premium</a> els formularis es carreguen sense haver de tornar a carregar la pàgina, amb el que s'obté una millor experiència pels teus visitants."
|
107 |
-
|
108 |
-
#: includes/admin/class-ads.php:70
|
109 |
-
msgid "Upgrade to Premium"
|
110 |
-
msgstr "Actualitzar a Premium."
|
111 |
-
|
112 |
-
#: includes/admin/class-ads.php:83
|
113 |
-
msgid ""
|
114 |
-
"Do you want translated forms for all of your languages? <a href=\"%s\">Try "
|
115 |
-
"Mailchimp for WordPress Premium</a>, which does just that plus more."
|
116 |
-
msgstr "Vols formularis traduïts a tots els idiomes de la teva pàgina? <a href=\"%s\">Prova Mailchimp per a WordPress Premium</a>, que fa això i molt més."
|
117 |
-
|
118 |
-
#: includes/admin/class-ads.php:88
|
119 |
-
msgid ""
|
120 |
-
"Do you want to create more than one form? Our Premium add-on does just that!"
|
121 |
-
" <a href=\"%s\">Have a look at all Premium benefits</a>."
|
122 |
-
msgstr "Vols crear més d'un formulari? La versió Premium et permet fer-ho! <a href=\"%s\">Consulta els avantatges de la versió Premium</a>."
|
123 |
-
|
124 |
-
#: includes/admin/class-ads.php:93
|
125 |
-
msgid ""
|
126 |
-
"Are you enjoying this plugin? The Premium add-on unlocks several powerful "
|
127 |
-
"features. <a href=\"%s\">Find out about all benefits now</a>."
|
128 |
-
msgstr "T'agrada aquest plugin? La versió Premium inclou moltes més capacitats. <a href=\"%s\">Descobreix-ne tots els avantatges ara</a>."
|
129 |
-
|
130 |
-
#: includes/admin/class-ads.php:112
|
131 |
-
msgid "More subscribers, better newsletters."
|
132 |
-
msgstr "Més subscriptors, millors butlletins."
|
133 |
-
|
134 |
-
#: includes/admin/class-ads.php:113
|
135 |
-
msgid ""
|
136 |
-
"Learn how to best grow your lists & write better emails by subscribing to "
|
137 |
-
"our monthly tips."
|
138 |
-
msgstr "Aprèn a tenir més subscriptors i a redactar millors campanyes de correu electrònic subscribint-te al nostre butlletí mensual."
|
139 |
-
|
140 |
-
#: includes/admin/class-ads.php:116
|
141 |
-
msgid "Email Address"
|
142 |
-
msgstr "Adreça de correu electrònic"
|
143 |
-
|
144 |
-
#: includes/admin/class-ads.php:120
|
145 |
-
msgid "First Name"
|
146 |
-
msgstr "Nom"
|
147 |
-
|
148 |
-
#: includes/admin/class-ads.php127, includes/forms/class-admin.php:94
|
149 |
-
msgid "Subscribe"
|
150 |
-
msgstr "Subscriure's"
|
151 |
-
|
152 |
-
#: includes/admin/class-ads.php:150
|
153 |
-
msgid ""
|
154 |
-
"Do you want to track all WooCommerce orders in Mailchimp so you can send "
|
155 |
-
"emails based on the purchase activity of your subscribers?"
|
156 |
-
msgstr "Vols fer el seguiment de totes les comandes de WooCommerce de manera que puguis enviar correus electrònics basats en les compres dels teus subscriptors?"
|
157 |
-
|
158 |
-
#: includes/admin/class-ads.php:153
|
159 |
-
msgid ""
|
160 |
-
"<a href=\"%s\">Upgrade to Mailchimp for WordPress Premium</a> or <a "
|
161 |
-
"href=\"%s\">read more about Mailchimp's E-Commerce features</a>."
|
162 |
-
msgstr "<a href=\"%s\">Actualitza't a Mailchimp per a WordPress Premium</a> o <a href=\"%s\">llegeix més sobre les capacitats E-Commerce de Mailchimp</a>."
|
163 |
-
|
164 |
-
#: includes/admin/class-review-notice.php:68
|
165 |
-
msgid ""
|
166 |
-
"You've been using Mailchimp for WordPress for some time now; we hope you "
|
167 |
-
"love it!"
|
168 |
-
msgstr "Ja fa algun temps que utilitzes Mailchimp per a Wordpress; esperem que t'agradi!"
|
169 |
-
|
170 |
-
#: includes/admin/class-review-notice.php:69
|
171 |
-
msgid ""
|
172 |
-
"If you do, please <a href=\"%s\">leave us a 5★ rating on WordPress.org</a>. "
|
173 |
-
"It would be of great help to us."
|
174 |
-
msgstr "Si vols, sisplau <a href=\"%s\">posa'ns 5★ punts de puntuació a WordPress.org</a>. Ens ajudaràs molt."
|
175 |
-
|
176 |
-
#: includes/admin/class-review-notice.php:71
|
177 |
-
msgid "Dismiss this notice."
|
178 |
-
msgstr "Descartar aquest avís."
|
179 |
-
|
180 |
-
#: includes/api/class-api.php:84
|
181 |
-
msgid "Read more about common connectivity issues."
|
182 |
-
msgstr "Saber-ne més sobre els problemes de connectivitat més habituals."
|
183 |
-
|
184 |
-
#: includes/forms/class-admin.php:62
|
185 |
-
msgid "Add to form"
|
186 |
-
msgstr "Afegir al formulari"
|
187 |
-
|
188 |
-
#: includes/forms/class-admin.php:63
|
189 |
-
msgid "City"
|
190 |
-
msgstr "Població"
|
191 |
-
|
192 |
-
#: includes/forms/class-admin.php:64
|
193 |
-
msgid "Checkboxes"
|
194 |
-
msgstr "Caselles"
|
195 |
-
|
196 |
-
#: includes/forms/class-admin.php:65
|
197 |
-
msgid "Choices"
|
198 |
-
msgstr "Opcions"
|
199 |
-
|
200 |
-
#: includes/forms/class-admin.php:66
|
201 |
-
msgid "Choice type"
|
202 |
-
msgstr "Tipus d'opció"
|
203 |
-
|
204 |
-
#: includes/forms/class-admin.php:67
|
205 |
-
msgid "Choose a field to add to the form"
|
206 |
-
msgstr "Tria un camp per afegir al formulari"
|
207 |
-
|
208 |
-
#: includes/forms/class-admin.php:68
|
209 |
-
msgid "Close"
|
210 |
-
msgstr "Tancar"
|
211 |
-
|
212 |
-
#: includes/forms/class-admin.php:69
|
213 |
-
msgid "Country"
|
214 |
-
msgstr "País"
|
215 |
-
|
216 |
-
#: includes/forms/class-admin.php:70
|
217 |
-
msgid "Dropdown"
|
218 |
-
msgstr "Desplegable"
|
219 |
-
|
220 |
-
#: includes/forms/class-admin.php:71
|
221 |
-
msgid "Field type"
|
222 |
-
msgstr "Tipus de camp"
|
223 |
-
|
224 |
-
#: includes/forms/class-admin.php:72
|
225 |
-
msgid "Field label"
|
226 |
-
msgstr "Etiqueta de camp"
|
227 |
-
|
228 |
-
#: includes/forms/class-admin.php:73
|
229 |
-
msgid "Form action"
|
230 |
-
msgstr "Acció del formulari"
|
231 |
-
|
232 |
-
#: includes/forms/class-admin.php:74
|
233 |
-
msgid ""
|
234 |
-
"This field will allow your visitors to choose whether they would like to "
|
235 |
-
"subscribe or unsubscribe"
|
236 |
-
msgstr "Aquest camp permetrà als teus visitants escollir si volen subscriure's o dessubscriure's."
|
237 |
-
|
238 |
-
#: includes/forms/class-admin.php:75
|
239 |
-
msgid "Form fields"
|
240 |
-
msgstr "Camps del formulari"
|
241 |
-
|
242 |
-
#: includes/forms/class-admin.php:76
|
243 |
-
msgid "This field is marked as required in Mailchimp."
|
244 |
-
msgstr "Aquest camp està marcat per Mailchimp com a obligatori."
|
245 |
-
|
246 |
-
#: includes/forms/class-admin.php:77
|
247 |
-
msgid "Initial value"
|
248 |
-
msgstr "Valor inicial"
|
249 |
-
|
250 |
-
#: includes/forms/class-admin.php:78
|
251 |
-
msgid "Interest categories"
|
252 |
-
msgstr "Categories d'interès"
|
253 |
-
|
254 |
-
#: includes/forms/class-admin.php:79
|
255 |
-
msgid "Is this field required?"
|
256 |
-
msgstr "Aquest camp és obligatori?"
|
257 |
-
|
258 |
-
#: includes/forms/class-admin.php:80
|
259 |
-
msgid "List choice"
|
260 |
-
msgstr "Opcions de la llista"
|
261 |
-
|
262 |
-
#: includes/forms/class-admin.php:81
|
263 |
-
msgid "This field will allow your visitors to choose a list to subscribe to."
|
264 |
-
msgstr "Aquest camp permetrà als teus visitants triar una llista on subscriure's."
|
265 |
-
|
266 |
-
#: includes/forms/class-admin.php:82
|
267 |
-
msgid "List fields"
|
268 |
-
msgstr "Camps de la llista"
|
269 |
-
|
270 |
-
#: includes/forms/class-admin.php:83
|
271 |
-
msgid "Min"
|
272 |
-
msgstr "Mínim"
|
273 |
-
|
274 |
-
#: includes/forms/class-admin.php:84
|
275 |
-
msgid "Max"
|
276 |
-
msgstr "Màxim"
|
277 |
-
|
278 |
-
#: includes/forms/class-admin.php:85
|
279 |
-
msgid ""
|
280 |
-
"No available fields. Did you select a Mailchimp list in the form settings?"
|
281 |
-
msgstr "No hi ha camps disponibles. Has seleccionat una llista de Mailchimp a la configuració del formulari?"
|
282 |
-
|
283 |
-
#: includes/forms/class-admin.php:86
|
284 |
-
msgid "Optional"
|
285 |
-
msgstr "Opcional"
|
286 |
-
|
287 |
-
#: includes/forms/class-admin.php:87
|
288 |
-
msgid "Placeholder"
|
289 |
-
msgstr "Posició"
|
290 |
-
|
291 |
-
#: includes/forms/class-admin.php:88
|
292 |
-
msgid "Text to show when field has no value."
|
293 |
-
msgstr "Text a mostrar quan no s'assigni cap valor al camp."
|
294 |
-
|
295 |
-
#: includes/forms/class-admin.php:89
|
296 |
-
msgid "Preselect"
|
297 |
-
msgstr "Preseleccionar"
|
298 |
-
|
299 |
-
#: includes/forms/class-admin.php:90
|
300 |
-
msgid "Remove"
|
301 |
-
msgstr "Esborrar"
|
302 |
-
|
303 |
-
#: includes/forms/class-admin.php:91
|
304 |
-
msgid "Radio buttons"
|
305 |
-
msgstr "Botons de ràdio"
|
306 |
-
|
307 |
-
#: includes/forms/class-admin.php:92
|
308 |
-
msgid "Street Address"
|
309 |
-
msgstr "Adreça"
|
310 |
-
|
311 |
-
#: includes/forms/class-admin.php:93
|
312 |
-
msgid "State"
|
313 |
-
msgstr "Província"
|
314 |
-
|
315 |
-
#: includes/forms/class-admin.php:95
|
316 |
-
msgid "Submit button"
|
317 |
-
msgstr "Botó d'enviar"
|
318 |
-
|
319 |
-
#: includes/forms/class-admin.php:96
|
320 |
-
msgid "Wrap in paragraph tags?"
|
321 |
-
msgstr "Vols que les etiquetes de paràgraf vagin dins d'un contenidor (wrap)?"
|
322 |
-
|
323 |
-
#: includes/forms/class-admin.php:97
|
324 |
-
msgid "Value"
|
325 |
-
msgstr "Valor"
|
326 |
-
|
327 |
-
#: includes/forms/class-admin.php:98
|
328 |
-
msgid "Text to prefill this field with."
|
329 |
-
msgstr "Text per mostrar per defecte en aquest camp."
|
330 |
-
|
331 |
-
#: includes/forms/class-admin.php:99
|
332 |
-
msgid "ZIP"
|
333 |
-
msgstr "Codi Postal"
|
334 |
-
|
335 |
-
#: includes/forms/class-admin.php111, includes/forms/class-admin.php112,
|
336 |
-
#: includes/forms/views/edit-form.php:24
|
337 |
-
msgid "Forms"
|
338 |
-
msgstr "Formularis"
|
339 |
-
|
340 |
-
#: includes/forms/class-admin.php152, includes/forms/class-admin.php:276
|
341 |
-
msgid "<strong>Success!</strong> Form successfully saved."
|
342 |
-
msgstr "<strong>Enhorabona!</strong> Formulari guardat correctament."
|
343 |
-
|
344 |
-
#: includes/forms/class-admin.php:276
|
345 |
-
msgid "Preview form"
|
346 |
-
msgstr "Previsualitzar el formulari"
|
347 |
-
|
348 |
-
#: includes/forms/class-admin.php449, includes/forms/class-widget.php:30
|
349 |
-
msgid "Mailchimp Sign-Up Form"
|
350 |
-
msgstr "Formulari de subscripció de Mailchimp"
|
351 |
-
|
352 |
-
#: includes/forms/class-admin.php:453
|
353 |
-
msgid "Select the form to show"
|
354 |
-
msgstr "Selecciona el formulari a mostrar"
|
355 |
-
|
356 |
-
#: includes/forms/class-form-previewer.php:146
|
357 |
-
msgid "Form preview"
|
358 |
-
msgstr "Previsualització del formulari"
|
359 |
-
|
360 |
-
#: includes/forms/class-form-tags.php:60
|
361 |
-
msgid "Replaced with the form response (error or success messages)."
|
362 |
-
msgstr "Es substitueix per la resposta del formulari (missatges d'error o èxit)."
|
363 |
-
|
364 |
-
#: includes/forms/class-form-tags.php:65
|
365 |
-
msgid "Data from the URL or a submitted form."
|
366 |
-
msgstr "Dades de la URL o del formulari enviat."
|
367 |
-
|
368 |
-
#: includes/forms/class-form-tags.php:71
|
369 |
-
msgid "Data from a cookie."
|
370 |
-
msgstr "Dades d'una galleta."
|
371 |
-
|
372 |
-
#: includes/forms/class-form-tags.php77,
|
373 |
-
#: includes/integrations/class-integration-tags.php:45
|
374 |
-
msgid "Replaced with the number of subscribers on the selected list(s)"
|
375 |
-
msgstr "Es substitueix pel nombre de subscriptors de la(es) llista(es) seleccionada(es)"
|
376 |
-
|
377 |
-
#: includes/forms/class-form-tags.php:82
|
378 |
-
msgid "The email address of the current visitor (if known)."
|
379 |
-
msgstr "L'adreça de correu electrònic (si es coneix) del visitant actual."
|
380 |
-
|
381 |
-
#: includes/forms/class-form-tags.php:87
|
382 |
-
msgid "The URL of the page."
|
383 |
-
msgstr "La URL de la pàgina."
|
384 |
-
|
385 |
-
#: includes/forms/class-form-tags.php:92
|
386 |
-
msgid "The path of the page."
|
387 |
-
msgstr "El camí de la pàgina."
|
388 |
-
|
389 |
-
#: includes/forms/class-form-tags.php:97
|
390 |
-
msgid "The current date. Example: %s."
|
391 |
-
msgstr "La data actual. Exemple: %s."
|
392 |
-
|
393 |
-
#: includes/forms/class-form-tags.php:102
|
394 |
-
msgid "The current time. Example: %s."
|
395 |
-
msgstr "L'hora actual. Exemple: %s."
|
396 |
-
|
397 |
-
#: includes/forms/class-form-tags.php:107
|
398 |
-
msgid "The site's language. Example: %s."
|
399 |
-
msgstr "L'idioma del lloc web. Exemple: %s."
|
400 |
-
|
401 |
-
#: includes/forms/class-form-tags.php:112
|
402 |
-
msgid "The visitor's IP address. Example: %s."
|
403 |
-
msgstr "L'adreça IP del visitant. Exemple: %s."
|
404 |
-
|
405 |
-
#: includes/forms/class-form-tags.php:117
|
406 |
-
msgid "The property of the currently logged-in user."
|
407 |
-
msgstr "La propietat de l'usuari que ha iniciat sessió."
|
408 |
-
|
409 |
-
#: includes/forms/class-form-tags.php:123
|
410 |
-
msgid "Property of the current page or post."
|
411 |
-
msgstr "La propietat de la pàgina o entrada actuals."
|
412 |
-
|
413 |
-
#: includes/forms/class-form.php:133
|
414 |
-
msgid "There is no form with ID %d, perhaps it was deleted?"
|
415 |
-
msgstr "No hi ha cap formulari amb la ID %d. Pot ser que s'hagi eliminat?"
|
416 |
-
|
417 |
-
#: includes/forms/class-widget.php:26
|
418 |
-
msgid "Newsletter"
|
419 |
-
msgstr "Butlletí"
|
420 |
-
|
421 |
-
#: includes/forms/class-widget.php:32
|
422 |
-
msgid "Displays your Mailchimp for WordPress sign-up form"
|
423 |
-
msgstr "Mostra el teu formulari de subscripció de Mailchimp per a WordPress"
|
424 |
-
|
425 |
-
#: includes/forms/class-widget.php:75
|
426 |
-
msgid "Title:"
|
427 |
-
msgstr "Títol:"
|
428 |
-
|
429 |
-
#: includes/forms/class-widget.php:92
|
430 |
-
msgid ""
|
431 |
-
"You can edit your sign-up form in the <a href=\"%s\">Mailchimp for WordPress"
|
432 |
-
" form settings</a>."
|
433 |
-
msgstr "Pots editar el teu formulari de subscripció a la <a href=\"%s\">configuració dels formularis de Mailchimp per a Wordpress</a>."
|
434 |
-
|
435 |
-
#: includes/integrations/class-admin.php79,
|
436 |
-
#: includes/integrations/class-admin.php80,
|
437 |
-
#: includes/integrations/views/integration-settings.php10,
|
438 |
-
#: includes/integrations/views/integrations.php57,
|
439 |
-
#: includes/integrations/views/integrations.php:65
|
440 |
-
msgid "Integrations"
|
441 |
-
msgstr "Integracions"
|
442 |
-
|
443 |
-
#: includes/views/general-settings.php7, includes/views/other-settings.php58,
|
444 |
-
#: includes/forms/views/edit-form.php22,
|
445 |
-
#: includes/integrations/views/integration-settings.php8,
|
446 |
-
#: includes/integrations/views/integrations.php:55
|
447 |
-
msgid "You are here: "
|
448 |
-
msgstr "Ets aquí: "
|
449 |
-
|
450 |
-
#: includes/views/general-settings.php:18
|
451 |
-
msgid "General Settings"
|
452 |
-
msgstr "Ajustos generals"
|
453 |
-
|
454 |
-
#: includes/views/general-settings.php:38
|
455 |
-
msgid "Status"
|
456 |
-
msgstr "Status"
|
457 |
-
|
458 |
-
#: includes/views/general-settings.php:42
|
459 |
-
msgid "CONNECTED"
|
460 |
-
msgstr "CONNECTAT"
|
461 |
-
|
462 |
-
#: includes/views/general-settings.php:44
|
463 |
-
msgid "NOT CONNECTED"
|
464 |
-
msgstr "NO CONNECTAT"
|
465 |
-
|
466 |
-
#: includes/views/general-settings.php:51
|
467 |
-
msgid "API Key"
|
468 |
-
msgstr "Clau API"
|
469 |
-
|
470 |
-
#: includes/views/general-settings.php:53
|
471 |
-
msgid "Your Mailchimp API key"
|
472 |
-
msgstr "La teva clau API de Mailchimp"
|
473 |
-
|
474 |
-
#: includes/views/general-settings.php:55
|
475 |
-
msgid "The API key for connecting with your Mailchimp account."
|
476 |
-
msgstr "La clau API per connectar amb el teu compte de Mailchimp."
|
477 |
-
|
478 |
-
#: includes/views/general-settings.php:56
|
479 |
-
msgid "Get your API key here."
|
480 |
-
msgstr "Obté la teva clau API aquí."
|
481 |
-
|
482 |
-
#: includes/views/other-settings.php:14
|
483 |
-
msgid "Miscellaneous settings"
|
484 |
-
msgstr "Altres configuracions"
|
485 |
-
|
486 |
-
#: includes/views/other-settings.php:17
|
487 |
-
msgid "Usage Tracking"
|
488 |
-
msgstr "Seguiment de l'ús"
|
489 |
-
|
490 |
-
#: includes/views/other-settings.php:29
|
491 |
-
msgid ""
|
492 |
-
"Allow us to anonymously track how this plugin is used to help us make it "
|
493 |
-
"better fit your needs."
|
494 |
-
msgstr "Dona'ns permís per fer el seguiment anònim de com uses el plugin per tal d'ajudar-nos a que s'ajusti millor a les teves necessitats."
|
495 |
-
|
496 |
-
#: includes/views/other-settings.php:31
|
497 |
-
msgid "This is what we track."
|
498 |
-
msgstr "Fem el seguiment d'això."
|
499 |
-
|
500 |
-
#: includes/views/other-settings.php:37
|
501 |
-
msgid "Logging"
|
502 |
-
msgstr "Registre"
|
503 |
-
|
504 |
-
#: includes/views/other-settings.php:44
|
505 |
-
msgid ""
|
506 |
-
"Determines what events should be written to <a href=\"%s\">the debug log</a>"
|
507 |
-
" (see below)."
|
508 |
-
msgstr "Estableix els esdeveniments que s'enregistren al <a href=\"%s\">registre d'errors</a> (vegi's a continuació)."
|
509 |
-
|
510 |
-
#: includes/views/other-settings.php:99
|
511 |
-
msgid "Debug Log"
|
512 |
-
msgstr "Registre d'errors"
|
513 |
-
|
514 |
-
#: includes/views/other-settings.php:99
|
515 |
-
msgid "Filter.."
|
516 |
-
msgstr "Filtrar.."
|
517 |
-
|
518 |
-
#: includes/views/other-settings.php:104
|
519 |
-
msgid "Log file is not writable."
|
520 |
-
msgstr "No es pot escriure a l'arxiu de registre."
|
521 |
-
|
522 |
-
#: includes/views/other-settings.php:105
|
523 |
-
msgid "Please ensure %s has the proper <a href=\"%s\">file permissions</a>."
|
524 |
-
msgstr "Sisplau, assegura't que %s té els <a href=\"%s\">permissos d'arxiu</a> adients."
|
525 |
-
|
526 |
-
#: includes/views/other-settings.php:123
|
527 |
-
msgid "Nothing here. Which means there are no errors!"
|
528 |
-
msgstr "Res de res. El que vol dir que no hi ha cap error!"
|
529 |
-
|
530 |
-
#: includes/views/other-settings.php:133
|
531 |
-
msgid "Empty Log"
|
532 |
-
msgstr "Registre buit"
|
533 |
-
|
534 |
-
#: includes/views/other-settings.php:141
|
535 |
-
msgid "Right now, the plugin is configured to only log errors and warnings."
|
536 |
-
msgstr "En aquest moment, el plugin està configurat per enregistrar només errors i avisos."
|
537 |
-
|
538 |
-
#: includes/admin/migrations/3.0.0-form-1-post-type.php:35
|
539 |
-
msgid "Default sign-up form"
|
540 |
-
msgstr "Formulari de subscripció per defecte"
|
541 |
-
|
542 |
-
#: includes/forms/views/add-form.php10, includes/forms/views/add-form.php:60
|
543 |
-
msgid "Add new form"
|
544 |
-
msgstr "Afegir nou formulari"
|
545 |
-
|
546 |
-
#: includes/forms/views/add-form.php:27
|
547 |
-
msgid "What is the name of this form?"
|
548 |
-
msgstr "Quin nom li posem a aquest formulari?"
|
549 |
-
|
550 |
-
#: includes/forms/views/add-form.php:30
|
551 |
-
msgid "Enter your form title.."
|
552 |
-
msgstr "Introdueix el títol del formulari.."
|
553 |
-
|
554 |
-
#: includes/forms/views/add-form.php:37
|
555 |
-
msgid "To which Mailchimp lists should this form subscribe?"
|
556 |
-
msgstr "A quines llistes de Mailchimp subscriurà aquest formulari? "
|
557 |
-
|
558 |
-
#: includes/forms/views/add-form.php:54
|
559 |
-
msgid "No lists found. Did you <a href=\"%s\">connect with Mailchimp</a>?"
|
560 |
-
msgstr "No s'han trobat llistes. T'has <a href=\"%s\">connectat a Mailchimp</a>? "
|
561 |
-
|
562 |
-
#: includes/forms/views/edit-form.php:4
|
563 |
-
msgid "Fields"
|
564 |
-
msgstr "Camps"
|
565 |
-
|
566 |
-
#: includes/forms/views/edit-form.php:5
|
567 |
-
msgid "Messages"
|
568 |
-
msgstr "Missatges"
|
569 |
-
|
570 |
-
#: includes/forms/views/edit-form.php:7
|
571 |
-
msgid "Appearance"
|
572 |
-
msgstr "Aparença"
|
573 |
-
|
574 |
-
#: includes/forms/views/edit-form.php:25
|
575 |
-
msgid "Form"
|
576 |
-
msgstr "Formulari"
|
577 |
-
|
578 |
-
#: includes/forms/views/edit-form.php:34
|
579 |
-
msgid "Edit Form"
|
580 |
-
msgstr "Editar el formulari"
|
581 |
-
|
582 |
-
#: includes/forms/views/edit-form.php:58
|
583 |
-
msgid "Enter form title here"
|
584 |
-
msgstr "Introdueix el títol del formulari aquí"
|
585 |
-
|
586 |
-
#: includes/forms/views/edit-form.php:59
|
587 |
-
msgid "Enter the title of your sign-up form"
|
588 |
-
msgstr "Introdueix el títol del teu formulari de subscripció"
|
589 |
-
|
590 |
-
#: includes/forms/views/edit-form.php:65
|
591 |
-
msgid "Shortcode"
|
592 |
-
msgstr "Codi abreviat (shortcode)"
|
593 |
-
|
594 |
-
#: includes/forms/views/edit-form.php:67
|
595 |
-
msgid "Get shortcode"
|
596 |
-
msgstr "Obtenir el codi abreviat (shortcode)"
|
597 |
-
|
598 |
-
#: includes/forms/views/edit-form.php:72
|
599 |
-
msgid "Preview this form"
|
600 |
-
msgstr "Previsualitzar aquest formulari"
|
601 |
-
|
602 |
-
#: includes/integrations/views/integration-settings.php:20
|
603 |
-
msgid "%s integration"
|
604 |
-
msgstr "Integració %s"
|
605 |
-
|
606 |
-
#: includes/integrations/views/integration-settings.php:27
|
607 |
-
msgid ""
|
608 |
-
"The selected Mailchimp lists require non-default fields, which may prevent "
|
609 |
-
"this integration from working."
|
610 |
-
msgstr "Les llistes de Mailchimp seleccionades requereixen que no hi hagi camps per-defecte, ja que aquests poden impedir que aquesta integració funcioni correctament."
|
611 |
-
|
612 |
-
#: includes/integrations/views/integration-settings.php:28
|
613 |
-
msgid ""
|
614 |
-
"Please ensure you <a href=\"%s\">configure the plugin to send all required "
|
615 |
-
"fields</a> or <a href=\"%s\">log into your Mailchimp account</a> and make "
|
616 |
-
"sure only the email & name fields are marked as required fields for the "
|
617 |
-
"selected list(s)."
|
618 |
-
msgstr "Sisplau, assegura't de <a href=\"%s\">configurar el plugin per enviar tots els camps obligatoris</a> o <a href=\"%s\">d'iniciar sessió al teu compte de Mailchimp</a> per assegurar-te que només els camps \"correu electrònic\" i \"nom\" siguin obligatoris per a la(es) llista(es) seleccionada(es)."
|
619 |
-
|
620 |
-
#: includes/integrations/views/integration-settings.php:62
|
621 |
-
msgid "Enabled?"
|
622 |
-
msgstr "Habilitat?"
|
623 |
-
|
624 |
-
#: includes/integrations/views/integration-settings.php:66
|
625 |
-
msgid ""
|
626 |
-
"Enable the %s integration? This will add a sign-up checkbox to the form."
|
627 |
-
msgstr "Habilitar la integració %s? Això afegirà una casella de subscripció al formulari."
|
628 |
-
|
629 |
-
#: includes/integrations/views/integration-settings.php:76
|
630 |
-
msgid "Implicit?"
|
631 |
-
msgstr "Implícit?"
|
632 |
-
|
633 |
-
#: includes/integrations/views/integration-settings.php:80
|
634 |
-
msgid ""
|
635 |
-
"Select \"no\" if you want to ask your visitors before they are subscribed "
|
636 |
-
"(recommended)."
|
637 |
-
msgstr "Selecciona \"no\" si vols preguntar als teus visitants abans de subscriure's (recomanat)."
|
638 |
-
|
639 |
-
#: includes/integrations/views/integration-settings.php:90
|
640 |
-
msgid "Mailchimp Lists"
|
641 |
-
msgstr "Llistes de Mailchimp"
|
642 |
-
|
643 |
-
#: includes/integrations/views/integration-settings.php:103
|
644 |
-
msgid ""
|
645 |
-
"Select the list(s) to which people who check the checkbox should be "
|
646 |
-
"subscribed."
|
647 |
-
msgstr "Selecciona la(es) llista(es) a què es subscriuran els que marquin les caselles de subscripció."
|
648 |
-
|
649 |
-
#: includes/integrations/views/integration-settings.php107,
|
650 |
-
#: includes/forms/views/tabs/form-settings.php:18
|
651 |
-
msgid "No lists found, <a href=\"%s\">are you connected to Mailchimp</a>?"
|
652 |
-
msgstr "No s'han trobat llistes, t'has <a href=\"%s\">connectat a Mailchimp</a>?"
|
653 |
-
|
654 |
-
#: includes/integrations/views/integration-settings.php:116
|
655 |
-
msgid "Checkbox label text"
|
656 |
-
msgstr "Text de la casella de subscripció."
|
657 |
-
|
658 |
-
#: includes/integrations/views/integration-settings.php:119
|
659 |
-
msgid "HTML tags like %s are allowed in the label text."
|
660 |
-
msgstr "Les etiquetes HTML com %s estan permeses en el text de l'etiqueta."
|
661 |
-
|
662 |
-
#: includes/integrations/views/integration-settings.php:129
|
663 |
-
msgid "Pre-check the checkbox?"
|
664 |
-
msgstr "Deixem pre-marcada la casella de subscripció?"
|
665 |
-
|
666 |
-
#: includes/integrations/views/integration-settings.php:133
|
667 |
-
msgid "Select \"yes\" if the checkbox should be pre-checked."
|
668 |
-
msgstr "Selecciona \"sí\" si vols deixar pre-marcada la casella de subscripció."
|
669 |
-
|
670 |
-
#: includes/integrations/views/integration-settings.php:141
|
671 |
-
msgid "Load some default CSS?"
|
672 |
-
msgstr "Carreguem alguns estils CSS per defecte?"
|
673 |
-
|
674 |
-
#: includes/integrations/views/integration-settings.php:145
|
675 |
-
msgid "Select \"yes\" if the checkbox appears in a weird place."
|
676 |
-
msgstr "Selecciona \"sí\" si la casella de subscripció apareix en un lloc inadequat."
|
677 |
-
|
678 |
-
#: includes/integrations/views/integration-settings.php:152
|
679 |
-
msgid "Double opt-in?"
|
680 |
-
msgstr "Vols que confirmin el registre?"
|
681 |
-
|
682 |
-
#: includes/integrations/views/integration-settings.php:163
|
683 |
-
msgid ""
|
684 |
-
"Select \"yes\" if you want people to confirm their email address before "
|
685 |
-
"being subscribed (recommended)"
|
686 |
-
msgstr "Selecciona \"sí\" si vols que els subscriptors confirmin la seva adreça de correu electrònic abans de subscriure's (recomanat)"
|
687 |
-
|
688 |
-
#: includes/integrations/views/integration-settings.php171,
|
689 |
-
#: includes/forms/views/tabs/form-settings.php:52
|
690 |
-
msgid "Update existing subscribers?"
|
691 |
-
msgstr "Vols actualitzar els subscriptors existents?"
|
692 |
-
|
693 |
-
#: includes/integrations/views/integration-settings.php181,
|
694 |
-
#: includes/forms/views/tabs/form-settings.php:62
|
695 |
-
msgid ""
|
696 |
-
"Select \"yes\" if you want to update existing subscribers with the data that"
|
697 |
-
" is sent."
|
698 |
-
msgstr "Selecciona \"sí\" si vols actualitzar els subscriptors existents amb les dades enviades."
|
699 |
-
|
700 |
-
#: includes/integrations/views/integration-settings.php190,
|
701 |
-
#: includes/forms/views/tabs/form-settings.php:68
|
702 |
-
msgid "Replace interest groups?"
|
703 |
-
msgstr "Vols reemplaçar els grups d'interessos?"
|
704 |
-
|
705 |
-
#: includes/integrations/views/integration-settings.php201,
|
706 |
-
#: includes/forms/views/tabs/form-settings.php:79
|
707 |
-
msgid ""
|
708 |
-
"Select \"no\" if you want to add the selected interests to any previously "
|
709 |
-
"selected interests when updating a subscriber."
|
710 |
-
msgstr "Selecciona \"no\" si vols afegir els interessos seleccionats als interessos prèviament seleccionats a l'actualitzar un subscriptor."
|
711 |
-
|
712 |
-
#: includes/integrations/views/integration-settings.php202,
|
713 |
-
#: includes/forms/views/tabs/form-settings.php:80
|
714 |
-
msgid "What does this do?"
|
715 |
-
msgstr "Què fa això?"
|
716 |
-
|
717 |
-
#: includes/integrations/views/integrations.php:17
|
718 |
-
msgid "Name"
|
719 |
-
msgstr "Nom"
|
720 |
-
|
721 |
-
#: includes/integrations/views/integrations.php:18
|
722 |
-
msgid "Description"
|
723 |
-
msgstr "Descripció"
|
724 |
-
|
725 |
-
#: includes/integrations/views/integrations.php:35
|
726 |
-
msgid "Configure this integration"
|
727 |
-
msgstr "Configurar aquesta integració"
|
728 |
-
|
729 |
-
#: includes/integrations/views/integrations.php:71
|
730 |
-
msgid "The table below shows all available integrations."
|
731 |
-
msgstr "La següent taula mostra totes les integracions disponibles."
|
732 |
-
|
733 |
-
#: includes/integrations/views/integrations.php:72
|
734 |
-
msgid ""
|
735 |
-
"Click on the name of an integration to edit all settings specific to that "
|
736 |
-
"integration."
|
737 |
-
msgstr "Clica al nom d'una integració per editar totes les configuracions específiques d'aquesta integració."
|
738 |
-
|
739 |
-
#: includes/integrations/views/integrations.php:79
|
740 |
-
msgid "Enabled integrations"
|
741 |
-
msgstr "Integracions habilitades"
|
742 |
-
|
743 |
-
#: includes/integrations/views/integrations.php:84
|
744 |
-
msgid "Available integrations"
|
745 |
-
msgstr "Integracions disponibles"
|
746 |
-
|
747 |
-
#: includes/views/parts/admin-footer.php:15
|
748 |
-
msgid ""
|
749 |
-
"Mailchimp for WordPress is in need of translations. Is the plugin not "
|
750 |
-
"translated in your language or do you spot errors with the current "
|
751 |
-
"translations? Helping out is easy! Head over to <a href=\"%s\">the "
|
752 |
-
"translation project and click \"help translate\"</a>."
|
753 |
-
msgstr "Mailchimp per a Wordpress necessita que el tradueixin. No està traduït al teu idioma o hi ha errors en la traducció actual? Ajudar-nos és fàcil. Visita <a href=\"%s\">el projecte de traducció i selecciona \"help translate\"</a>."
|
754 |
-
|
755 |
-
#: includes/views/parts/admin-footer.php:35
|
756 |
-
msgid ""
|
757 |
-
"This plugin is not developed by or affiliated with Mailchimp in any way."
|
758 |
-
msgstr "Aquest plugin no està desenvolupat per ni està afiliat a Mailchimp en cap sentit."
|
759 |
-
|
760 |
-
#: includes/views/parts/admin-sidebar.php:11
|
761 |
-
msgid "Looking for help?"
|
762 |
-
msgstr "Necessites ajut?"
|
763 |
-
|
764 |
-
#: includes/views/parts/admin-sidebar.php:12
|
765 |
-
msgid "We have some resources available to help you in the right direction."
|
766 |
-
msgstr "Disposem d'alguns recursos per ajudar-te a anar en la bona direcció."
|
767 |
-
|
768 |
-
#: includes/views/parts/admin-sidebar.php:14
|
769 |
-
msgid "Knowledge Base"
|
770 |
-
msgstr "Base de coneixements"
|
771 |
-
|
772 |
-
#: includes/views/parts/admin-sidebar.php:15
|
773 |
-
msgid "Frequently Asked Questions"
|
774 |
-
msgstr "Preguntes freqüents"
|
775 |
-
|
776 |
-
#: includes/views/parts/admin-sidebar.php:16
|
777 |
-
msgid "Code reference for developers"
|
778 |
-
msgstr "Codi de referència per a desenvolupadors"
|
779 |
-
|
780 |
-
#: includes/views/parts/admin-sidebar.php:36
|
781 |
-
msgid "Looking to improve your sign-up rates?"
|
782 |
-
msgstr "Vols millorar les teves taxes de subscripció?"
|
783 |
-
|
784 |
-
#: includes/views/parts/admin-sidebar.php:37
|
785 |
-
msgid ""
|
786 |
-
"Our <a href=\"%s\">Boxzilla plugin</a> allows you to create pop-ups or "
|
787 |
-
"slide-ins with a subscribe form. A sure way to grow your lists faster."
|
788 |
-
msgstr "El nostre <a href=\"%s\">plugin Boxzilla</a> et permet crear finestres emergents (pop-ups) o slide-ins amb un formulari de subscripció. Una manera segura de tenir més subscriptors ràpidament."
|
789 |
-
|
790 |
-
#: includes/views/parts/lists-overview.php:1
|
791 |
-
msgid "Your Mailchimp Account"
|
792 |
-
msgstr "El teu compte de Mailchimp"
|
793 |
-
|
794 |
-
#: includes/views/parts/lists-overview.php:2
|
795 |
-
msgid ""
|
796 |
-
"The table below shows your Mailchimp lists and their details. If you just "
|
797 |
-
"applied changes to your Mailchimp lists, please use the following button to "
|
798 |
-
"renew the cached lists configuration."
|
799 |
-
msgstr "La taula següent mostra les teves llistes de Mailchimp i les seves dades. Si has efectuat canvis a les teves llistes de Mailchimp, sisplau empra el botó següent per actualitzar la configuració de les teves llistes guardades."
|
800 |
-
|
801 |
-
#: includes/views/parts/lists-overview.php:17
|
802 |
-
msgid "No lists were found in your Mailchimp account"
|
803 |
-
msgstr "No s'ha trobat cap llista al teu compte de Mailchimp"
|
804 |
-
|
805 |
-
#: includes/views/parts/lists-overview.php:19
|
806 |
-
msgid "A total of %d lists were found in your Mailchimp account."
|
807 |
-
msgstr "Al teu compte de Mailchimp s'han trobat %d llistes en total."
|
808 |
-
|
809 |
-
#: includes/views/parts/lists-overview.php:24
|
810 |
-
msgid "List Name"
|
811 |
-
msgstr "Nom de la llista"
|
812 |
-
|
813 |
-
#: includes/views/parts/lists-overview.php:25
|
814 |
-
msgid "ID"
|
815 |
-
msgstr "Identificador"
|
816 |
-
|
817 |
-
#: includes/views/parts/lists-overview.php:26
|
818 |
-
msgid "Subscribers"
|
819 |
-
msgstr "Subscriptors"
|
820 |
-
|
821 |
-
#: includes/views/parts/lists-overview.php:48
|
822 |
-
msgid "Edit this list in Mailchimp"
|
823 |
-
msgstr "Editar aquesta llista a Mailchimp"
|
824 |
-
|
825 |
-
#: includes/views/parts/lists-overview.php:62
|
826 |
-
msgid "%s (%s) with field type %s."
|
827 |
-
msgstr "%s (%s) amb camp del tipus %s."
|
828 |
-
|
829 |
-
#: includes/forms/views/parts/add-fields-help.php4,
|
830 |
-
#: includes/forms/views/tabs/form-fields.php:10
|
831 |
-
msgid "Add more fields"
|
832 |
-
msgstr "Afegir més camps"
|
833 |
-
|
834 |
-
#: includes/forms/views/parts/add-fields-help.php:9
|
835 |
-
msgid ""
|
836 |
-
"To add more fields to your form, you will need to create those fields in "
|
837 |
-
"Mailchimp first."
|
838 |
-
msgstr "Per afegir més camps al teu formulari, primer hauràs de crear-los a Mailchimp. "
|
839 |
-
|
840 |
-
#: includes/forms/views/parts/add-fields-help.php:12
|
841 |
-
msgid "Here's how:"
|
842 |
-
msgstr "Heus aquí com:"
|
843 |
-
|
844 |
-
#: includes/forms/views/parts/add-fields-help.php:17
|
845 |
-
msgid "Log in to your Mailchimp account."
|
846 |
-
msgstr "Inicia sessió al teu compte de Mailchimp."
|
847 |
-
|
848 |
-
#: includes/forms/views/parts/add-fields-help.php:22
|
849 |
-
msgid "Add list fields to any of your selected lists."
|
850 |
-
msgstr "Afegir camps a qualsevol de les teves llistes seleccionades."
|
851 |
-
|
852 |
-
#: includes/forms/views/parts/add-fields-help.php:23
|
853 |
-
msgid "Clicking the following links will take you to the right screen."
|
854 |
-
msgstr "Clicant als següents enllaços aniràs a la pantalla correcta."
|
855 |
-
|
856 |
-
#: includes/forms/views/parts/add-fields-help.php:29
|
857 |
-
msgid "Edit list fields for"
|
858 |
-
msgstr "Editar camps per"
|
859 |
-
|
860 |
-
#: includes/forms/views/parts/add-fields-help.php:38
|
861 |
-
msgid ""
|
862 |
-
"Click the following button to have Mailchimp for WordPress pick up on your "
|
863 |
-
"changes."
|
864 |
-
msgstr "Clica al botó següent perquè Mailchimp per a WordPress registri els teus canvis."
|
865 |
-
|
866 |
-
#: includes/forms/views/parts/dynamic-content-tags.php:6
|
867 |
-
msgid "Add dynamic form variable"
|
868 |
-
msgstr "Afegir variable de formulari dinàmica. "
|
869 |
-
|
870 |
-
#: includes/forms/views/parts/dynamic-content-tags.php:8
|
871 |
-
msgid ""
|
872 |
-
"The following list of variables can be used to <a href=\"%s\">add some "
|
873 |
-
"dynamic content to your form or success and error messages</a>."
|
874 |
-
msgstr "La següent llista de variables es pot emprar per a <a href=\"%s\">afegir continguts dinàmics al teu formulari o als seus missatges d'éxit i error</a>."
|
875 |
-
|
876 |
-
#: includes/forms/views/parts/dynamic-content-tags.php:8
|
877 |
-
msgid "This allows you to personalise your form or response messages."
|
878 |
-
msgstr "Això et permet personalitzar el formulari o els seus missatges de resposta."
|
879 |
-
|
880 |
-
#: includes/forms/views/tabs/form-appearance.php:5
|
881 |
-
msgid "Inherit from %s theme"
|
882 |
-
msgstr "Heretat del tema %s"
|
883 |
-
|
884 |
-
#: includes/forms/views/tabs/form-appearance.php:6
|
885 |
-
msgid "Basic"
|
886 |
-
msgstr "Bàsic"
|
887 |
-
|
888 |
-
#: includes/forms/views/tabs/form-appearance.php:7
|
889 |
-
msgid "Form Themes"
|
890 |
-
msgstr "Temes del formulari"
|
891 |
-
|
892 |
-
#: includes/forms/views/tabs/form-appearance.php:8
|
893 |
-
msgid "Light Theme"
|
894 |
-
msgstr "Tema clar"
|
895 |
-
|
896 |
-
#: includes/forms/views/tabs/form-appearance.php:9
|
897 |
-
msgid "Dark Theme"
|
898 |
-
msgstr "Tema fosc"
|
899 |
-
|
900 |
-
#: includes/forms/views/tabs/form-appearance.php:10
|
901 |
-
msgid "Red Theme"
|
902 |
-
msgstr "Tema vermell"
|
903 |
-
|
904 |
-
#: includes/forms/views/tabs/form-appearance.php:11
|
905 |
-
msgid "Green Theme"
|
906 |
-
msgstr "Tema verd"
|
907 |
-
|
908 |
-
#: includes/forms/views/tabs/form-appearance.php:12
|
909 |
-
msgid "Blue Theme"
|
910 |
-
msgstr "Tema blau"
|
911 |
-
|
912 |
-
#: includes/forms/views/tabs/form-appearance.php:25
|
913 |
-
msgid "Form Appearance"
|
914 |
-
msgstr "Aparença del formulari"
|
915 |
-
|
916 |
-
#: includes/forms/views/tabs/form-appearance.php:29
|
917 |
-
msgid "Form Style"
|
918 |
-
msgstr "Estil del formulari"
|
919 |
-
|
920 |
-
#: includes/forms/views/tabs/form-appearance.php:48
|
921 |
-
msgid ""
|
922 |
-
"If you want to load some default CSS styles, select \"basic formatting "
|
923 |
-
"styles\" or choose one of the color themes"
|
924 |
-
msgstr "Si vols carregar els fulls d'estils CSS per defecte, selecciona \"Estils de formulari bàsics\" o escull un dels temes de colors."
|
925 |
-
|
926 |
-
#: includes/forms/views/tabs/form-fields.php:6
|
927 |
-
msgid "Form variables"
|
928 |
-
msgstr "Variables del formulari"
|
929 |
-
|
930 |
-
#: includes/forms/views/tabs/form-fields.php:13
|
931 |
-
msgid "Form Fields"
|
932 |
-
msgstr "Camps del formulari"
|
933 |
-
|
934 |
-
#: includes/forms/views/tabs/form-fields.php:19
|
935 |
-
msgid "Enter the HTML code for your form fields.."
|
936 |
-
msgstr "Introdueix el codi HTML pels camps del teu formulari.."
|
937 |
-
|
938 |
-
#: includes/forms/views/tabs/form-fields.php:26
|
939 |
-
msgid ""
|
940 |
-
"Use the shortcode %s to display this form inside a post, page or text "
|
941 |
-
"widget."
|
942 |
-
msgstr "Insereix el codi abreviat (shortcode) %s per mostrar aquest formulari en una entrada, article o giny de text."
|
943 |
-
|
944 |
-
#: includes/forms/views/tabs/form-messages.php:6
|
945 |
-
msgid "Form Messages"
|
946 |
-
msgstr "Missatges del formulari"
|
947 |
-
|
948 |
-
#: includes/forms/views/tabs/form-messages.php:16
|
949 |
-
msgid "Successfully subscribed"
|
950 |
-
msgstr "Subscripció satisfactòria"
|
951 |
-
|
952 |
-
#: includes/forms/views/tabs/form-messages.php:19
|
953 |
-
msgid ""
|
954 |
-
"The text that shows when an email address is successfully subscribed to the "
|
955 |
-
"selected list(s)."
|
956 |
-
msgstr "Text a mostrar quan una adreça de correu electrònic s'ha subscrit correctament a la(es) llista(es) seleccionada(es)."
|
957 |
-
|
958 |
-
#: includes/forms/views/tabs/form-messages.php:23
|
959 |
-
msgid "Invalid email address"
|
960 |
-
msgstr "Adreça de correu electrònic no vàlida"
|
961 |
-
|
962 |
-
#: includes/forms/views/tabs/form-messages.php:26
|
963 |
-
msgid "The text that shows when an invalid email address is given."
|
964 |
-
msgstr "Text a mostrar quan es proporciona una adreça de correu electrònic no vàlida."
|
965 |
-
|
966 |
-
#: includes/forms/views/tabs/form-messages.php:30
|
967 |
-
msgid "Required field missing"
|
968 |
-
msgstr "Introdueix el camp requerit"
|
969 |
-
|
970 |
-
#: includes/forms/views/tabs/form-messages.php:33
|
971 |
-
msgid ""
|
972 |
-
"The text that shows when a required field for the selected list(s) is "
|
973 |
-
"missing."
|
974 |
-
msgstr "Text a mostrar quan no s'ha introduït un camp obligatori per a la(es) llista(es) seleccionada(es)."
|
975 |
-
|
976 |
-
#: includes/forms/views/tabs/form-messages.php:37
|
977 |
-
msgid "Already subscribed"
|
978 |
-
msgstr "Ja estàs subscrit"
|
979 |
-
|
980 |
-
#: includes/forms/views/tabs/form-messages.php:40
|
981 |
-
msgid ""
|
982 |
-
"The text that shows when the given email is already subscribed to the "
|
983 |
-
"selected list(s)."
|
984 |
-
msgstr "Text a mostrar quan l'adreça de correu electrònic proporcionada ja està subscrita a la(es) llista(es) seleccionada(es)."
|
985 |
-
|
986 |
-
#: includes/forms/views/tabs/form-messages.php:44
|
987 |
-
msgid "General error"
|
988 |
-
msgstr "Error general"
|
989 |
-
|
990 |
-
#: includes/forms/views/tabs/form-messages.php:47
|
991 |
-
msgid "The text that shows when a general error occured."
|
992 |
-
msgstr "Text a mostrar quan es produeix un error general."
|
993 |
-
|
994 |
-
#: includes/forms/views/tabs/form-messages.php:51
|
995 |
-
msgid "Unsubscribed"
|
996 |
-
msgstr "Dessubscrit"
|
997 |
-
|
998 |
-
#: includes/forms/views/tabs/form-messages.php:54
|
999 |
-
msgid ""
|
1000 |
-
"When using the unsubscribe method, this is the text that shows when the "
|
1001 |
-
"given email address is successfully unsubscribed from the selected list(s)."
|
1002 |
-
msgstr "Quan s'empra el mètode dessubscriure's, aquest és el text a mostrar quan l'adreça de correu electrònic facilitada s'ha dessubscrit correctament de la(es) llista(es) seleccionada(es)."
|
1003 |
-
|
1004 |
-
#: includes/forms/views/tabs/form-messages.php:58
|
1005 |
-
msgid "Not subscribed"
|
1006 |
-
msgstr "No subscrit"
|
1007 |
-
|
1008 |
-
#: includes/forms/views/tabs/form-messages.php:61
|
1009 |
-
msgid ""
|
1010 |
-
"When using the unsubscribe method, this is the text that shows when the "
|
1011 |
-
"given email address is not on the selected list(s)."
|
1012 |
-
msgstr "Quan s'empra el mètode dessubscriure's, aquest és el text a mostrar quan l'adreça de correu electrònic facilitada no és a la(es) llista(es) seleccionada(es)."
|
1013 |
-
|
1014 |
-
#: includes/forms/views/tabs/form-messages.php:65
|
1015 |
-
msgid "No list selected"
|
1016 |
-
msgstr "No s'ha seleccionat cap llista"
|
1017 |
-
|
1018 |
-
#: includes/forms/views/tabs/form-messages.php:68
|
1019 |
-
msgid ""
|
1020 |
-
"When offering a list choice, this is the text that shows when no lists were "
|
1021 |
-
"selected."
|
1022 |
-
msgstr "Quan s'ofereix la opció de llista, es mostra aquest text quan no es selecciona cap llista."
|
1023 |
-
|
1024 |
-
#: includes/forms/views/tabs/form-messages.php:74
|
1025 |
-
msgid "Updated"
|
1026 |
-
msgstr "Actualitzat"
|
1027 |
-
|
1028 |
-
#: includes/forms/views/tabs/form-messages.php:77
|
1029 |
-
msgid "The text that shows when an existing subscriber is updated."
|
1030 |
-
msgstr "Quan s'actualitza un subscriptor ja existent, es mostra aquest text."
|
1031 |
-
|
1032 |
-
#: includes/forms/views/tabs/form-messages.php:89
|
1033 |
-
msgid "HTML tags like %s are allowed in the message fields."
|
1034 |
-
msgstr "Les etiquetes HTML com %s estan permeses en els camps del missatge."
|
1035 |
-
|
1036 |
-
#: includes/forms/views/tabs/form-settings.php:1
|
1037 |
-
msgid "Form Settings"
|
1038 |
-
msgstr "Ajustos del formulari"
|
1039 |
-
|
1040 |
-
#: includes/forms/views/tabs/form-settings.php:5
|
1041 |
-
msgid "Mailchimp specific settings"
|
1042 |
-
msgstr "Ajustos de Mailchimp"
|
1043 |
-
|
1044 |
-
#: includes/forms/views/tabs/form-settings.php:15
|
1045 |
-
msgid "Lists this form subscribes to"
|
1046 |
-
msgstr "Les llistes d'aquest formulari subscriuen a"
|
1047 |
-
|
1048 |
-
#: includes/forms/views/tabs/form-settings.php:31
|
1049 |
-
msgid ""
|
1050 |
-
"Select the list(s) to which people who submit this form should be "
|
1051 |
-
"subscribed."
|
1052 |
-
msgstr "Selecciona la(es) llista(es) a què es subscriuran els que usin aquest formulari."
|
1053 |
-
|
1054 |
-
#: includes/forms/views/tabs/form-settings.php:37
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|