Skip to content

Commit 00726cf

Browse files
committed
Merge branch 'develop' into fix/header-spacing
2 parents 378a4be + fb2b4b8 commit 00726cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+392
-10101
lines changed

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,6 @@ Currently we have the plugin configured so it can be translated and the followin
8989
* sv_SE - Swedish in Sweden (thanks to [Sebastian Johnsson](http://www.agiley.se/) for contributing)
9090
* tr_TR - Turkish in Turkey (thanks to [Hakan E.](http://kazancexpert.com/) for contributing)
9191

92-
If your language is not listed above, feel free to create a translation. Here are the basic steps:
93-
94-
1. Copy "mailchimp_i18n-en_US.po" to "mailchimp_i18n-LANG_COUNTRY.po" - fill in LANG and COUNTRY with whatever you use for WPLANG in wp-config.php
95-
2. Grab a translation editor. [POedit](http://www.poedit.net/) works for us
96-
3. Translate each line - if you need some context, open up mailchimp.php and search for the line number or text
97-
4. [Fork](http://help.github.com/fork-a-repo/) the [repository on github](https://github.com/mailchimp/wordpress)
98-
5. [Clone](http://help.github.com/remotes/#clone) the _develop_ branch
99-
6. Add the appropriately named files to the /po/ directory and edit the /readme.txt to include how you'd like to be attributed
100-
7. Make a [pull request](http://help.github.com/send-pull-requests/)
101-
10292
## Support Level
10393

10494
**Active:** Mailchimp is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome.

includes/blocks/mailchimp/block.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"text": true
3636
}
3737
},
38-
"textdomain": "mailchimp_i18n",
38+
"textdomain": "mailchimp",
3939
"editorScript": "file:./index.js",
4040
"render": "file:./markup.php",
4141
"editorStyle": "file:./editor.css"

includes/blocks/mailchimp/edit.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export const BlockEdit = ({ isSelected }) => {
3131
{isSelected || isDisallowedThemeSSR ? (
3232
<Placeholder
3333
icon={Icon}
34-
label={__('Mailchimp Block', 'mailchimp_i18n')}
35-
instructions={__('Great work! Your block is ready to go.', 'mailchimp_i18n')}
34+
label={__('Mailchimp Block', 'mailchimp')}
35+
instructions={__('Great work! Your block is ready to go.', 'mailchimp')}
3636
>
3737
<div>
3838
<Button
@@ -42,7 +42,7 @@ export const BlockEdit = ({ isSelected }) => {
4242
>
4343
{__(
4444
"Head over here if you'd like to adjust your settings.",
45-
'mailchimp_i18n',
45+
'mailchimp',
4646
)}
4747
</Button>
4848
</div>

lib/mailchimp/mailchimp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public function __construct( $api_key ) {
5050
throw new Exception(
5151
esc_html(
5252
sprintf(
53-
// translators: placeholder is an api key
54-
__( 'Invalid API Key: %s', 'mailchimp_i18n' ),
53+
/* translators: %s: api key */
54+
__( 'Invalid API Key: %s', 'mailchimp' ),
5555
$api_key
5656
)
5757
)

mailchimp.php

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Plugin Name: Mailchimp
44
* Plugin URI: https://mailchimp.com/help/connect-or-disconnect-list-subscribe-for-wordpress/
55
* Description: Add a Mailchimp signup form widget to your WordPress site.
6+
* Text Domain: mailchimp
67
* Version: 1.5.8
78
* Requires at least: 6.1
89
* Requires PHP: 7.0
@@ -60,16 +61,11 @@
6061
/**
6162
* Do the following plugin setup steps here
6263
*
63-
* Internationalization
6464
* Resource (JS & CSS) enqueuing
6565
*
6666
* @return void
6767
*/
6868
function mailchimp_sf_plugin_init() {
69-
// Internationalize the plugin
70-
$textdomain = 'mailchimp_i18n';
71-
$locale = apply_filters( 'plugin_locale', get_locale(), $textdomain );
72-
load_textdomain( 'mailchimp_i18n', MCSF_LANG_DIR . $textdomain . '-' . $locale . '.mo' );
7369

7470
// Remove Sopresto check. If user does not have API key, make them authenticate.
7571

@@ -91,7 +87,7 @@ function mailchimp_sf_plugin_init() {
9187
*/
9288
function mailchimp_sf_plugin_action_links( $links ) {
9389
$settings_page = add_query_arg( array( 'page' => 'mailchimp_sf_options' ), admin_url( 'admin.php' ) );
94-
$settings_link = '<a href="' . esc_url( $settings_page ) . '">' . esc_html__( 'Settings', 'mailchimp_i18n' ) . '</a>';
90+
$settings_link = '<a href="' . esc_url( $settings_page ) . '">' . esc_html__( 'Settings', 'mailchimp' ) . '</a>';
9591
array_unshift( $links, $settings_link );
9692
return $links;
9793
}
@@ -203,8 +199,8 @@ function mailchimp_sf_main_css() {
203199
function mailchimp_sf_add_pages() {
204200
// Add settings page for users who can edit plugins
205201
add_menu_page(
206-
__( 'Mailchimp Setup', 'mailchimp_i18n' ),
207-
__( 'Mailchimp', 'mailchimp_i18n' ),
202+
esc_html__( 'Mailchimp Setup', 'mailchimp' ),
203+
esc_html__( 'Mailchimp', 'mailchimp' ),
208204
MCSF_CAP_THRESHOLD,
209205
'mailchimp_sf_options',
210206
'mailchimp_sf_setup_page',
@@ -482,8 +478,8 @@ function mailchimp_sf_global_msg( $msg = null ) {
482478
* @return void
483479
*/
484480
function mailchimp_sf_set_form_defaults( $list_name = '' ) {
485-
update_option( 'mc_header_content', __( 'Sign up for', 'mailchimp_i18n' ) . ' ' . $list_name );
486-
update_option( 'mc_submit_text', __( 'Subscribe', 'mailchimp_i18n' ) );
481+
update_option( 'mc_header_content', esc_html__( 'Sign up for', 'mailchimp' ) . ' ' . $list_name );
482+
update_option( 'mc_submit_text', esc_html__( 'Subscribe', 'mailchimp' ) );
487483

488484
update_option( 'mc_use_datepicker', 'on' );
489485
update_option( 'mc_custom_style', 'off' );
@@ -511,64 +507,64 @@ function mailchimp_sf_save_general_form_settings() {
511507
// IF NOT DEV MODE
512508
if ( isset( $_POST['mc_use_javascript'] ) ) {
513509
update_option( 'mc_use_javascript', 'on' );
514-
$msg = '<p class="success_msg">' . __( 'Fancy Javascript submission turned On!', 'mailchimp_i18n' ) . '</p>';
510+
$msg = '<p class="success_msg">' . esc_html__( 'Fancy Javascript submission turned On!', 'mailchimp' ) . '</p>';
515511
mailchimp_sf_global_msg( $msg );
516512
} elseif ( get_option( 'mc_use_javascript' ) !== 'off' ) {
517513
update_option( 'mc_use_javascript', 'off' );
518-
$msg = '<p class="success_msg">' . __( 'Fancy Javascript submission turned Off!', 'mailchimp_i18n' ) . '</p>';
514+
$msg = '<p class="success_msg">' . esc_html__( 'Fancy Javascript submission turned Off!', 'mailchimp' ) . '</p>';
519515
mailchimp_sf_global_msg( $msg );
520516
}
521517

522518
if ( isset( $_POST['mc_use_datepicker'] ) ) {
523519
update_option( 'mc_use_datepicker', 'on' );
524-
$msg = '<p class="success_msg">' . __( 'Datepicker turned On!', 'mailchimp_i18n' ) . '</p>';
520+
$msg = '<p class="success_msg">' . esc_html__( 'Datepicker turned On!', 'mailchimp' ) . '</p>';
525521
mailchimp_sf_global_msg( $msg );
526522
} elseif ( get_option( 'mc_use_datepicker' ) !== 'off' ) {
527523
update_option( 'mc_use_datepicker', 'off' );
528-
$msg = '<p class="success_msg">' . __( 'Datepicker turned Off!', 'mailchimp_i18n' ) . '</p>';
524+
$msg = '<p class="success_msg">' . esc_html__( 'Datepicker turned Off!', 'mailchimp' ) . '</p>';
529525
mailchimp_sf_global_msg( $msg );
530526
}
531527

532528
/*Enable double optin toggle*/
533529
if ( isset( $_POST['mc_double_optin'] ) ) {
534530
update_option( 'mc_double_optin', true );
535-
$msg = '<p class="success_msg">' . __( 'Double opt-in turned On!', 'mailchimp_i18n' ) . '</p>';
531+
$msg = '<p class="success_msg">' . esc_html__( 'Double opt-in turned On!', 'mailchimp' ) . '</p>';
536532
mailchimp_sf_global_msg( $msg );
537533
} elseif ( get_option( 'mc_double_optin' ) !== false ) {
538534
update_option( 'mc_double_optin', false );
539-
$msg = '<p class="success_msg">' . __( 'Double opt-in turned Off!', 'mailchimp_i18n' ) . '</p>';
535+
$msg = '<p class="success_msg">' . esc_html__( 'Double opt-in turned Off!', 'mailchimp' ) . '</p>';
540536
mailchimp_sf_global_msg( $msg );
541537
}
542538

543539
/* NUKE the CSS! */
544540
if ( isset( $_POST['mc_nuke_all_styles'] ) ) {
545541
update_option( 'mc_nuke_all_styles', true );
546-
$msg = '<p class="success_msg">' . __( 'Mailchimp CSS turned Off!', 'mailchimp_i18n' ) . '</p>';
542+
$msg = '<p class="success_msg">' . esc_html__( 'Mailchimp CSS turned Off!', 'mailchimp' ) . '</p>';
547543
mailchimp_sf_global_msg( $msg );
548544
} elseif ( get_option( 'mc_nuke_all_styles' ) !== false ) {
549545
update_option( 'mc_nuke_all_styles', false );
550-
$msg = '<p class="success_msg">' . __( 'Mailchimp CSS turned On!', 'mailchimp_i18n' ) . '</p>';
546+
$msg = '<p class="success_msg">' . esc_html__( 'Mailchimp CSS turned On!', 'mailchimp' ) . '</p>';
551547
mailchimp_sf_global_msg( $msg );
552548
}
553549

554550
/* Update existing */
555551
if ( isset( $_POST['mc_update_existing'] ) ) {
556552
update_option( 'mc_update_existing', true );
557-
$msg = '<p class="success_msg">' . __( 'Update existing subscribers turned On!' ) . '</p>';
553+
$msg = '<p class="success_msg">' . esc_html__( 'Update existing subscribers turned On!' ) . '</p>';
558554
mailchimp_sf_global_msg( $msg );
559555
} elseif ( get_option( 'mc_update_existing' ) !== false ) {
560556
update_option( 'mc_update_existing', false );
561-
$msg = '<p class="success_msg">' . __( 'Update existing subscribers turned Off!' ) . '</p>';
557+
$msg = '<p class="success_msg">' . esc_html__( 'Update existing subscribers turned Off!' ) . '</p>';
562558
mailchimp_sf_global_msg( $msg );
563559
}
564560

565561
if ( isset( $_POST['mc_use_unsub_link'] ) ) {
566562
update_option( 'mc_use_unsub_link', 'on' );
567-
$msg = '<p class="success_msg">' . __( 'Unsubscribe link turned On!', 'mailchimp_i18n' ) . '</p>';
563+
$msg = '<p class="success_msg">' . esc_html__( 'Unsubscribe link turned On!', 'mailchimp' ) . '</p>';
568564
mailchimp_sf_global_msg( $msg );
569565
} elseif ( get_option( 'mc_use_unsub_link' ) !== 'off' ) {
570566
update_option( 'mc_use_unsub_link', 'off' );
571-
$msg = '<p class="success_msg">' . __( 'Unsubscribe link turned Off!', 'mailchimp_i18n' ) . '</p>';
567+
$msg = '<p class="success_msg">' . esc_html__( 'Unsubscribe link turned Off!', 'mailchimp' ) . '</p>';
572568
mailchimp_sf_global_msg( $msg );
573569
}
574570

@@ -626,14 +622,24 @@ function mailchimp_sf_save_general_form_settings() {
626622
}
627623
}
628624

629-
$msg = '<p class="success_msg">' . esc_html( __( 'Successfully Updated your List Subscribe Form Settings!', 'mailchimp_i18n' ) ) . '</p>';
625+
$msg = '<p class="success_msg">' . esc_html__( 'Successfully Updated your List Subscribe Form Settings!', 'mailchimp' ) . '</p>';
630626
mailchimp_sf_global_msg( $msg );
631627
}
632628

633629
/**
634630
* Sees if the user changed the list, and updates options accordingly
635631
**/
636632
function mailchimp_sf_change_list_if_necessary() {
633+
if ( ! isset( $_POST['mc_list_id'] ) ) {
634+
return;
635+
}
636+
637+
if ( empty( $_POST['mc_list_id'] ) ) {
638+
$msg = '<p class="error_msg">' . esc_html__( 'Please choose a valid list', 'mailchimp' ) . '</p>';
639+
mailchimp_sf_global_msg( $msg );
640+
return;
641+
}
642+
637643
// Simple permission check before going through all this
638644
if ( ! current_user_can( MCSF_CAP_THRESHOLD ) ) { return; }
639645

@@ -649,7 +655,7 @@ function mailchimp_sf_change_list_if_necessary() {
649655

650656
$lists = $lists['lists'];
651657

652-
if ( is_array( $lists ) && ! empty( $lists ) && isset( $_POST['mc_list_id'] ) ) {
658+
if ( is_array( $lists ) && ! empty( $lists ) ) {
653659

654660
/**
655661
* If our incoming list ID (the one chosen in the select dropdown)
@@ -684,18 +690,19 @@ function mailchimp_sf_change_list_if_necessary() {
684690

685691
$igs_text = ' ';
686692
if ( is_array( $igs ) ) {
687-
// translators: placeholder is a count (number)
688-
$igs_text .= sprintf( __( 'and %s Sets of Interest Groups', 'mailchimp_i18n' ), count( $igs ) );
693+
/* translators: %s: count (number) */
694+
$igs_text .= sprintf( esc_html__( 'and %s Sets of Interest Groups', 'mailchimp' ), count( $igs ) );
689695
}
690696

691697
$msg = '<p class="success_msg">' .
692698
sprintf(
693-
// translators: placeholder is a count (number)
694-
__( '<b>Success!</b> Loaded and saved the info for %d Merge Variables', 'mailchimp_i18n' ) . $igs_text,
699+
/* translators: %s: count (number) */
700+
__( '<b>Success!</b> Loaded and saved the info for %d Merge Variables', 'mailchimp' ) . $igs_text,
695701
count( $mv )
696702
) . ' ' .
697-
__( 'from your list' ) . ' "' . $list_name . '"<br/><br/>' .
698-
__( 'Now you should either Turn On the Mailchimp Widget or change your options below, then turn it on.', 'mailchimp_i18n' ) . '</p>';
703+
esc_html__( 'from your list' ) . ' "' . $list_name . '"<br/><br/>' .
704+
esc_html__( 'Now you should either Turn On the Mailchimp Widget or change your options below, then turn it on.', 'mailchimp' ) . '</p>';
705+
699706
mailchimp_sf_global_msg( $msg );
700707
}
701708
}
@@ -738,7 +745,7 @@ function mailchimp_sf_get_merge_vars( $list_id, $new_list ) {
738745
function mailchimp_sf_add_email_field( $merge ) {
739746
$email = array(
740747
'tag' => 'EMAIL',
741-
'name' => __( 'Email Address', 'mailchimp_i18n' ),
748+
'name' => esc_html__( 'Email Address', 'mailchimp' ),
742749
'type' => 'email',
743750
'required' => true,
744751
'public' => true,
@@ -896,17 +903,17 @@ function mailchimp_sf_signup_submit() {
896903
'<strong class="mc_error_msg">%s</strong>',
897904
wp_kses(
898905
sprintf(
899-
// translators: first placeholder is email address, second is url
906+
/* translators: 1: email address 2: url */
900907
__(
901908
'We encountered a problem adding %1$s to the list. Please <a href="%2$s">sign up here.</a>',
902-
'mailchimp_i18n'
909+
'mailchimp'
903910
),
904911
esc_html( $email ),
905912
esc_url( $url )
906913
),
907914
[
908915
'a' => [
909-
'href',
916+
'href' => [],
910917
],
911918
]
912919
)
@@ -920,7 +927,7 @@ function mailchimp_sf_signup_submit() {
920927

921928
// If update existing is turned off and the subscriber exists, error out.
922929
if ( get_option( 'mc_update_existing' ) === false && 'subscribed' === $status ) {
923-
$msg = 'This email address is already subscribed to the list.';
930+
$msg = esc_html__( 'This email address is already subscribed to the list.', 'mailchimp' );
924931
$error = new WP_Error( 'mailchimp-update-existing', $msg );
925932
mailchimp_sf_global_msg( '<strong class="mc_error_msg">' . $msg . '</strong>' );
926933
return false;
@@ -937,10 +944,10 @@ function mailchimp_sf_signup_submit() {
937944
}
938945

939946
if ( 'subscribed' === $retval['status'] ) {
940-
$esc = __( 'Success, you\'ve been signed up.', 'mailchimp_i18n' );
947+
$esc = esc_html__( 'Success, you\'ve been signed up.', 'mailchimp' );
941948
$msg = "<strong class='mc_success_msg'>{$esc}</strong>";
942949
} else {
943-
$esc = __( 'Success, you\'ve been signed up! Please look for our confirmation email.', 'mailchimp_i18n' );
950+
$esc = esc_html__( 'Success, you\'ve been signed up! Please look for our confirmation email.', 'mailchimp' );
944951
$msg = "<strong class='mc_success_msg'>{$esc}</strong>";
945952
}
946953

@@ -1044,8 +1051,8 @@ function mailchimp_sf_merge_submit( $mv ) {
10441051
}
10451052

10461053
if ( 'Y' === $mv_var['required'] && trim( $opt_val ) === '' ) {
1047-
// translators: placeholder is field name
1048-
$message = sprintf( __( 'You must fill in %s.', 'mailchimp_i18n' ), esc_html( $mv_var['name'] ) );
1054+
/* translators: %s: field name */
1055+
$message = sprintf( esc_html__( 'You must fill in %s.', 'mailchimp' ), esc_html( $mv_var['name'] ) );
10491056
$error = new WP_Error( 'missing_required_field', $message );
10501057
return $error;
10511058
} elseif ( 'EMAIL' !== $tag ) {
@@ -1076,8 +1083,8 @@ function mailchimp_sf_merge_validate_phone( $opt_val, $data ) {
10761083
}
10771084

10781085
if ( ! preg_match( '/[0-9]{0,3}-[0-9]{0,3}-[0-9]{0,4}/A', $opt_val ) ) {
1079-
// translators: placeholder is field name
1080-
$message = sprintf( __( '%s must consist of only numbers', 'mailchimp_i18n' ), esc_html( $data['name'] ) );
1086+
/* translators: %s: field name */
1087+
$message = sprintf( esc_html__( '%s must consist of only numbers', 'mailchimp' ), esc_html( $data['name'] ) );
10811088
$error = new WP_Error( 'mc_phone_validation', $message );
10821089
return $error;
10831090
}
@@ -1095,8 +1102,8 @@ function mailchimp_sf_merge_validate_phone( $opt_val, $data ) {
10951102
function mailchimp_sf_merge_validate_address( $opt_val, $data ) {
10961103
if ( 'Y' === $data['required'] ) {
10971104
if ( empty( $opt_val['addr1'] ) || empty( $opt_val['city'] ) ) {
1098-
// translators: placeholder is field name
1099-
$message = sprintf( __( 'You must fill in %s.', 'mailchimp_i18n' ), esc_html( $data['name'] ) );
1105+
/* translators: %s: field name */
1106+
$message = sprintf( esc_html__( 'You must fill in %s.', 'mailchimp' ), esc_html( $data['name'] ) );
11001107
$error = new WP_Error( 'invalid_address_merge', $message );
11011108
return $error;
11021109
}
@@ -1222,7 +1229,7 @@ function mailchimp_sf_verify_key( $api ) {
12221229
update_option( 'mc_datacenter', $api->datacenter );
12231230

12241231
} else {
1225-
$msg = __( 'API Key must belong to "Owner", "Admin", or "Manager."', 'mailchimp_i18n' );
1232+
$msg = esc_html__( 'API Key must belong to "Owner", "Admin", or "Manager."', 'mailchimp' );
12261233
return new WP_Error( 'mc-invalid-role', $msg );
12271234
}
12281235
}
@@ -1315,12 +1322,6 @@ function mailchimp_sf_where_am_i() {
13151322
// Define our complete filesystem path
13161323
define( 'MCSF_DIR', $mscf_dir );
13171324

1318-
/**
1319-
* Lang location needs to be relative *from* ABSPATH,
1320-
* so strip it out of our language dir location
1321-
*/
1322-
define( 'MCSF_LANG_DIR', trailingslashit( MCSF_DIR ) . 'po/' );
1323-
13241325
// Define our complete URL to the plugin folder
13251326
define( 'MCSF_URL', $mscf_url );
13261327
}

0 commit comments

Comments
 (0)