Date: Fri, 28 Jun 2024 11:38:36 -0600
Subject: [PATCH] Ensure we use esc_html__ where possible, to be consistent.
Ensure all strings are passed through translation
---
mailchimp.php | 60 ++++++++++++++++++++++----------------------
mailchimp_widget.php | 56 +++++++++++++++++++++++++++--------------
views/setup_page.php | 53 ++++++++++++++++++++++----------------
3 files changed, 98 insertions(+), 71 deletions(-)
diff --git a/mailchimp.php b/mailchimp.php
index 7f939b3..636ba20 100644
--- a/mailchimp.php
+++ b/mailchimp.php
@@ -61,7 +61,6 @@
/**
* Do the following plugin setup steps here
*
- * Internationalization
* Resource (JS & CSS) enqueuing
*
* @return void
@@ -200,8 +199,8 @@ function mailchimp_sf_main_css() {
function mailchimp_sf_add_pages() {
// Add settings page for users who can edit plugins
add_menu_page(
- __( 'Mailchimp Setup', 'mailchimp' ),
- __( 'Mailchimp', 'mailchimp' ),
+ esc_html__( 'Mailchimp Setup', 'mailchimp' ),
+ esc_html__( 'Mailchimp', 'mailchimp' ),
MCSF_CAP_THRESHOLD,
'mailchimp_sf_options',
'mailchimp_sf_setup_page',
@@ -479,8 +478,8 @@ function mailchimp_sf_global_msg( $msg = null ) {
* @return void
*/
function mailchimp_sf_set_form_defaults( $list_name = '' ) {
- update_option( 'mc_header_content', __( 'Sign up for', 'mailchimp' ) . ' ' . $list_name );
- update_option( 'mc_submit_text', __( 'Subscribe', 'mailchimp' ) );
+ update_option( 'mc_header_content', esc_html__( 'Sign up for', 'mailchimp' ) . ' ' . $list_name );
+ update_option( 'mc_submit_text', esc_html__( 'Subscribe', 'mailchimp' ) );
update_option( 'mc_use_datepicker', 'on' );
update_option( 'mc_custom_style', 'off' );
@@ -508,64 +507,64 @@ function mailchimp_sf_save_general_form_settings() {
// IF NOT DEV MODE
if ( isset( $_POST['mc_use_javascript'] ) ) {
update_option( 'mc_use_javascript', 'on' );
- $msg = '' . __( 'Fancy Javascript submission turned On!', 'mailchimp' ) . '
';
+ $msg = '' . esc_html__( 'Fancy Javascript submission turned On!', 'mailchimp' ) . '
';
mailchimp_sf_global_msg( $msg );
} elseif ( get_option( 'mc_use_javascript' ) !== 'off' ) {
update_option( 'mc_use_javascript', 'off' );
- $msg = '' . __( 'Fancy Javascript submission turned Off!', 'mailchimp' ) . '
';
+ $msg = '' . esc_html__( 'Fancy Javascript submission turned Off!', 'mailchimp' ) . '
';
mailchimp_sf_global_msg( $msg );
}
if ( isset( $_POST['mc_use_datepicker'] ) ) {
update_option( 'mc_use_datepicker', 'on' );
- $msg = '' . __( 'Datepicker turned On!', 'mailchimp' ) . '
';
+ $msg = '' . esc_html__( 'Datepicker turned On!', 'mailchimp' ) . '
';
mailchimp_sf_global_msg( $msg );
} elseif ( get_option( 'mc_use_datepicker' ) !== 'off' ) {
update_option( 'mc_use_datepicker', 'off' );
- $msg = '' . __( 'Datepicker turned Off!', 'mailchimp' ) . '
';
+ $msg = '' . esc_html__( 'Datepicker turned Off!', 'mailchimp' ) . '
';
mailchimp_sf_global_msg( $msg );
}
/*Enable double optin toggle*/
if ( isset( $_POST['mc_double_optin'] ) ) {
update_option( 'mc_double_optin', true );
- $msg = '' . __( 'Double opt-in turned On!', 'mailchimp' ) . '
';
+ $msg = '' . esc_html__( 'Double opt-in turned On!', 'mailchimp' ) . '
';
mailchimp_sf_global_msg( $msg );
} elseif ( get_option( 'mc_double_optin' ) !== false ) {
update_option( 'mc_double_optin', false );
- $msg = '' . __( 'Double opt-in turned Off!', 'mailchimp' ) . '
';
+ $msg = '' . esc_html__( 'Double opt-in turned Off!', 'mailchimp' ) . '
';
mailchimp_sf_global_msg( $msg );
}
/* NUKE the CSS! */
if ( isset( $_POST['mc_nuke_all_styles'] ) ) {
update_option( 'mc_nuke_all_styles', true );
- $msg = '' . __( 'Mailchimp CSS turned Off!', 'mailchimp' ) . '
';
+ $msg = '' . esc_html__( 'Mailchimp CSS turned Off!', 'mailchimp' ) . '
';
mailchimp_sf_global_msg( $msg );
} elseif ( get_option( 'mc_nuke_all_styles' ) !== false ) {
update_option( 'mc_nuke_all_styles', false );
- $msg = '' . __( 'Mailchimp CSS turned On!', 'mailchimp' ) . '
';
+ $msg = '' . esc_html__( 'Mailchimp CSS turned On!', 'mailchimp' ) . '
';
mailchimp_sf_global_msg( $msg );
}
/* Update existing */
if ( isset( $_POST['mc_update_existing'] ) ) {
update_option( 'mc_update_existing', true );
- $msg = '' . __( 'Update existing subscribers turned On!' ) . '
';
+ $msg = '' . esc_html__( 'Update existing subscribers turned On!' ) . '
';
mailchimp_sf_global_msg( $msg );
} elseif ( get_option( 'mc_update_existing' ) !== false ) {
update_option( 'mc_update_existing', false );
- $msg = '' . __( 'Update existing subscribers turned Off!' ) . '
';
+ $msg = '' . esc_html__( 'Update existing subscribers turned Off!' ) . '
';
mailchimp_sf_global_msg( $msg );
}
if ( isset( $_POST['mc_use_unsub_link'] ) ) {
update_option( 'mc_use_unsub_link', 'on' );
- $msg = '' . __( 'Unsubscribe link turned On!', 'mailchimp' ) . '
';
+ $msg = '' . esc_html__( 'Unsubscribe link turned On!', 'mailchimp' ) . '
';
mailchimp_sf_global_msg( $msg );
} elseif ( get_option( 'mc_use_unsub_link' ) !== 'off' ) {
update_option( 'mc_use_unsub_link', 'off' );
- $msg = '' . __( 'Unsubscribe link turned Off!', 'mailchimp' ) . '
';
+ $msg = '' . esc_html__( 'Unsubscribe link turned Off!', 'mailchimp' ) . '
';
mailchimp_sf_global_msg( $msg );
}
@@ -623,7 +622,7 @@ function mailchimp_sf_save_general_form_settings() {
}
}
- $msg = '' . esc_html( __( 'Successfully Updated your List Subscribe Form Settings!', 'mailchimp' ) ) . '
';
+ $msg = '' . esc_html__( 'Successfully Updated your List Subscribe Form Settings!', 'mailchimp' ) . '
';
mailchimp_sf_global_msg( $msg );
}
@@ -682,7 +681,7 @@ function mailchimp_sf_change_list_if_necessary() {
$igs_text = ' ';
if ( is_array( $igs ) ) {
/* translators: %s: count (number) */
- $igs_text .= sprintf( __( 'and %s Sets of Interest Groups', 'mailchimp' ), count( $igs ) );
+ $igs_text .= sprintf( esc_html__( 'and %s Sets of Interest Groups', 'mailchimp' ), count( $igs ) );
}
$msg = '' .
@@ -691,8 +690,9 @@ function mailchimp_sf_change_list_if_necessary() {
__( 'Success! Loaded and saved the info for %d Merge Variables', 'mailchimp' ) . $igs_text,
count( $mv )
) . ' ' .
- __( 'from your list' ) . ' "' . $list_name . '"
' .
- __( 'Now you should either Turn On the Mailchimp Widget or change your options below, then turn it on.', 'mailchimp' ) . '
';
+ esc_html__( 'from your list' ) . ' "' . $list_name . '"
' .
+ esc_html__( 'Now you should either Turn On the Mailchimp Widget or change your options below, then turn it on.', 'mailchimp' ) . '