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 -954
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 |
|