From d15e7ce50a5816b30bb21e0d15213ffeb5cfa8a4 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 4 Aug 2016 16:01:54 +0100 Subject: [PATCH 01/14] Improved sentence structure for various localised strings. --- admin/constants.php | 49 ++++++++++++++++++++++++++------ admin/faq.php | 18 +++++++++--- admin/page.php | 2 +- admin/schedule-form-excludes.php | 2 +- classes/class-email-service.php | 6 +++- 5 files changed, 61 insertions(+), 16 deletions(-) diff --git a/admin/constants.php b/admin/constants.php index 330e47ef..6b8ef2b4 100644 --- a/admin/constants.php +++ b/admin/constants.php @@ -6,7 +6,11 @@
-

define', '' . __( 'Constants', 'backupwordpress' ) . '', 'wp-config.php', '' . __( 'The Codex can help', 'backupwordpress' ) . '', '' . __( 'Constants', 'backupwordpress' ) . '' ); ?>

+

The Codex can help. Defined constants will be highlighted.', 'backupwordpress' ), + 'wp-config.php', + 'https://codex.wordpress.org/Editing_wp-config.php' + ); ?>

@@ -20,7 +24,11 @@

' . esc_html( HMBKP_PATH ) . '' ); ?>

-

' . esc_html( Path::get_path() ) . '' ); ?> define( 'HMBKP_PATH', '/home/willmot/backups' );

+

' . esc_html( Path::get_path() ) . '', + "define( 'HMBKP_PATH', '/home/willmot/backups' );" + ); ?>

@@ -36,7 +44,11 @@

' . esc_html( HMBKP_MYSQLDUMP_PATH ) . '' ); ?>

-

mysqldump', '' . __( 'database', 'backupwordpress' ) . '' ); ?> define( 'HMBKP_MYSQLDUMP_PATH', '/opt/local/bin/mysqldump' );

+

mysqldump', + "define( 'HMBKP_MYSQLDUMP_PATH', '/opt/local/bin/mysqldump' );" + ); ?>

@@ -52,7 +64,11 @@

' . esc_html( HMBKP_ZIP_PATH ) . '' ); ?>

-

zip', '' . __( 'files', 'backupwordpress' ) . '', '' . __( 'database', 'backupwordpress' ) . '' ); ?> define( 'HMBKP_ZIP_PATH', '/opt/local/bin/zip' );

+

zip', + "define( 'HMBKP_ZIP_PATH', '/opt/local/bin/zip' );" + ); ?>

@@ -68,7 +84,10 @@

' . esc_html( HMBKP_EXCLUDE ) . '' ); ?>

-

define( 'HMBKP_EXCLUDE', '/wp-content/uploads/, /stats/, .svn/, *.txt' );

+

define( 'HMBKP_EXCLUDE', '/wp-content/uploads/, /stats/, .svn/, *.txt' );" + ); ?>

@@ -84,7 +103,11 @@

' . esc_html( HMBKP_CAPABILITY ) . '' ); ?>

-

add_menu_page', 'manage_options' ); ?> define( 'HMBKP_CAPABILITY', 'edit_posts' );

+

manage_options', + "define( 'HMBKP_CAPABILITY', 'edit_posts' );" + ); ?>

@@ -100,7 +123,11 @@

' . esc_html( HMBKP_ROOT ) . '' ); ?>

-

' . Path::get_home_path() . '' ); ?> define( 'HMBKP_ROOT', ABSPATH . 'wp/' );

+

' . esc_html( Path::get_home_path() ) . '', + "define( 'HMBKP_ROOT', ABSPATH . 'wp/' );" + ); ?>

@@ -116,14 +143,18 @@

' . esc_html( HMBKP_SCHEDULE_TIME ) . '' ); ?>

-

23:00' ); ?> define( 'HMBKP_SCHEDULE_TIME', '07:30' );

+

23:00', + "define( 'HMBKP_SCHEDULE_TIME', '07:30' );" + ); ?>

$service ) : - echo wp_kses_post( call_user_func( array( $service, 'constant' ) ) ); + call_user_func( array( $service, 'constant' ) ); endforeach; ?>
diff --git a/admin/faq.php b/admin/faq.php index 187b729f..edede638 100644 --- a/admin/faq.php +++ b/admin/faq.php @@ -7,13 +7,19 @@ '

' . __( 'What if I want to back up my site to another destination?', 'backupwordpress' ) . '

' . - '

' . __( 'BackUpWordPress Pro supports Dropbox, Google Drive, Amazon S3, Rackspace, Azure, DreamObjects and FTP/SFTP. Check it out here: https://bwp.hmn.md', 'backupwordpress' ) . '

' . + '

' . sprintf( + __( 'BackUpWordPress Pro supports Dropbox, Google Drive, Amazon S3, Rackspace, Azure, DreamObjects and FTP/SFTP. Check it out at bwp.hmn.md', 'backupwordpress' ), + 'https://bwp.hmn.md/?utm_source=wordpress-org&utm_medium=plugin-page&utm_campaign=freeplugin' + ) . '

' . '

' . __( 'How do I restore my site from a backup?', 'backupwordpress' ) . '

' . - '

' . __( 'You need to download the latest backup file either by clicking download on the backups page or via FTP. Unzip the files and upload all the files to your server overwriting your site. You can then import the database using your hosts database management tool (likely phpMyAdmin).', 'backupwordpress' ) . '

' . + '

' . __( 'You need to download the latest backup file either by clicking download on the backups page or via FTP. Unzip the files and upload all the files to your server overwriting your site. You can then import the database using your hosts database management tool (likely phpMyAdmin).', 'backupwordpress' ) . '

' . - '

' . __( 'See this guide for more details - How to restore from backup.', 'backupwordpress' ) . '

' . + '

' . sprintf( + __( 'See this guide for more details - How to restore from backup.', 'backupwordpress' ), + 'https://bwp.hmn.md/support-center/restore-backup/' + ) . '

' . '

' . __( 'Does BackUpWordPress back up the backups directory?', 'backupwordpress' ) . '

' . @@ -43,7 +49,11 @@ '
  • ' . __( 'If you click manual backup, does it work?', 'backupwordpress' ) . '
  • ' . - '
  • ' . __( 'Try adding define( \'ALTERNATE_WP_CRON\', true ); to your wp-config.php. Do automatic backups work?', 'backupwordpress' ) . '
  • ' . + '
  • ' . sprintf( + __( 'Try adding %1$s to your %2$s file. Do automatic backups work?', 'backupwordpress' ), + "define( 'ALTERNATE_WP_CRON', true );", + 'wp-config.php' + ) . '
  • ' . '
  • ' . __( 'Is your site private (i.e. is it behind some kind of authentication, maintenance plugin, .htaccess)? If so, wp-cron won\'t work until you remove it. If you are and you temporarily remove the authentication, do backups start working?', 'backupwordpress' ) . '
  • ' . diff --git a/admin/page.php b/admin/page.php index ed948a65..088ee1c5 100755 --- a/admin/page.php +++ b/admin/page.php @@ -26,7 +26,7 @@ -

    ', '' ); ?>

    +

    rate it on the plugin directory', 'backupwordpress' ), 'https://wordpress.org/support/view/plugin-reviews/backupwordpress' ); ?>

    diff --git a/admin/schedule-form-excludes.php b/admin/schedule-form-excludes.php index 07ed705e..972c9547 100644 --- a/admin/schedule-form-excludes.php +++ b/admin/schedule-form-excludes.php @@ -56,7 +56,7 @@ - + wp-config.php' ); ?> diff --git a/classes/class-email-service.php b/classes/class-email-service.php index 30934c19..739608af 100644 --- a/classes/class-email-service.php +++ b/classes/class-email-service.php @@ -64,7 +64,11 @@ public static function constant() {

    ' . HMBKP_ATTACHMENT_MAX_FILESIZE . '' ); ?>

    -

    10MB' ); ?> define( 'HMBKP_ATTACHMENT_MAX_FILESIZE', '25MB' );

    +

    10MB', + "define( 'HMBKP_ATTACHMENT_MAX_FILESIZE', '25MB' );" + ); ?>

    From 3f87b15b9cd50ab62261d04a58207f0fb159464b Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 4 Aug 2016 16:02:42 +0100 Subject: [PATCH 02/14] Echo the text directly instead of unnecessarily assigning to a variable. Maintains late escaping discipline. --- admin/extensions.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/admin/extensions.php b/admin/extensions.php index 6cadee1a..e05a7a5e 100644 --- a/admin/extensions.php +++ b/admin/extensions.php @@ -122,24 +122,20 @@ title->rendered ), array_keys( $installed_plugins ) ) ) { $current_version = $installed_plugins[ strtolower( $extension->title->rendered ) ]; if ( version_compare( $current_version, $extension->_edd_sl_version, '<' ) ) { - $text = sprintf( __( 'A newer version (%1$s) is available. Update now!', 'backupwordpress' ), esc_html( $extension->_edd_sl_version ), esc_url( admin_url( 'update-core.php' ) ) ); + printf( __( 'A newer version (%1$s) is available. Update now!', 'backupwordpress' ), esc_html( $extension->_edd_sl_version ), esc_url( admin_url( 'update-core.php' ) ) ); } else { - $text = esc_html__( 'You have the latest version', 'backupwordpress' ); + esc_html_e( 'You have the latest version', 'backupwordpress' ); } } - echo $text; - ?>
    From aa294c297f7ba408e3a91f67e64c19a08d9a9131 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 4 Aug 2016 16:04:29 +0100 Subject: [PATCH 03/14] Add some missing escaping. --- admin/extensions.php | 4 ++-- classes/class-email-service.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/extensions.php b/admin/extensions.php index e05a7a5e..8a5b9a04 100644 --- a/admin/extensions.php +++ b/admin/extensions.php @@ -72,7 +72,7 @@
  • title->rendered ), array_keys( $installed_plugins ) ) ) : ?> - + @@ -84,7 +84,7 @@
  • - +
  • diff --git a/classes/class-email-service.php b/classes/class-email-service.php index 739608af..c40babeb 100644 --- a/classes/class-email-service.php +++ b/classes/class-email-service.php @@ -61,7 +61,7 @@ public static function constant() { -

    ' . HMBKP_ATTACHMENT_MAX_FILESIZE . '' ); ?>

    +

    ' . esc_html( HMBKP_ATTACHMENT_MAX_FILESIZE ) . '' ); ?>

    Date: Thu, 4 Aug 2016 16:05:32 +0100 Subject: [PATCH 04/14] Add some missing i18n. --- admin/extensions.php | 5 ++++- admin/page.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/admin/extensions.php b/admin/extensions.php index 8a5b9a04..bd3476c0 100644 --- a/admin/extensions.php +++ b/admin/extensions.php @@ -76,7 +76,10 @@ - edd_price ); ?> + edd_price ); ?> diff --git a/admin/page.php b/admin/page.php index 088ee1c5..1e3fe48c 100755 --- a/admin/page.php +++ b/admin/page.php @@ -10,7 +10,7 @@ BackUpWordPress - Extensions + From 65501d5427dbd974a18f32c9f5aa52c7ac511a30 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 4 Aug 2016 16:06:13 +0100 Subject: [PATCH 05/14] Correct a typo. --- admin/faq.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/faq.php b/admin/faq.php index edede638..765c2fa5 100644 --- a/admin/faq.php +++ b/admin/faq.php @@ -27,7 +27,7 @@ '

    ' . __( 'I\'m not receiving my backups by email', 'backupwordpress' ) . '

    ' . - '

    ' . __( 'Most servers have a filesize limit on email attachments, it\'s generally about 10mb. If your backup file is over that limit, it won\'t be sent attached to the email. Instead, you should receive an email with a link to download the backup. If you aren\'t even receiving that, then you likely have a mail issue on your server that you\'ll need to contact your host about.', 'backupwordpress' ) . '

    ' . + '

    ' . __( 'Most servers have a file size limit on email attachments, it\'s generally about 10mb. If your backup file is over that limit, it won\'t be sent attached to the email. Instead, you should receive an email with a link to download the backup. If you aren\'t even receiving that, then you likely have a mail issue on your server that you\'ll need to contact your host about.', 'backupwordpress' ) . '

    ' . '

    ' . __( 'How many backups are stored by default?', 'backupwordpress' ) . '

    ' . From fda22db7c052cb15719662fa02e735b3dbe33aff Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 4 Aug 2016 16:07:06 +0100 Subject: [PATCH 06/14] Correct some mis-used i18n function usage. --- admin/extensions.php | 2 +- admin/schedule-form.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/extensions.php b/admin/extensions.php index bd3476c0..520fd43c 100644 --- a/admin/extensions.php +++ b/admin/extensions.php @@ -117,7 +117,7 @@
    - _edd_sl_version ) ); ?> + _edd_sl_version ) ); ?>
    diff --git a/admin/schedule-form.php b/admin/schedule-form.php index cfed4d54..01b52abc 100644 --- a/admin/schedule-form.php +++ b/admin/schedule-form.php @@ -74,7 +74,7 @@ From 2f1f5daef8731c8b1e9be8496630c8082e4267a6 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 4 Aug 2016 16:08:38 +0100 Subject: [PATCH 07/14] Escape once instead of thrice. --- admin/schedule-form-excludes.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/admin/schedule-form-excludes.php b/admin/schedule-form-excludes.php index 972c9547..027f22e0 100644 --- a/admin/schedule-form-excludes.php +++ b/admin/schedule-form-excludes.php @@ -183,12 +183,12 @@ @@ -307,12 +307,12 @@ $excluded_size = is_same_size_format( $size, $excluded_size ) ? (int) size_format( $excluded_size ) : size_format( $excluded_size ); - /* translators: 1: Excluded size 2: Overall site size */ - printf( - esc_html__( '%1$s of %2$s', 'backupwordpress' ), - esc_html( $excluded_size ), - esc_html( size_format( $size ) ) - ); + echo esc_html( sprintf( + /* translators: 1: Excluded size 2: Overall site size */ + __( '%1$s of %2$s', 'backupwordpress' ), + $excluded_size, + size_format( $size ) + ) ); elseif ( ! $is_unreadable ) : echo esc_html( size_format( $size ) ); From 538624c3453197ec7012aa3ba5653702e9858ae3 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 4 Aug 2016 16:09:47 +0100 Subject: [PATCH 08/14] Weekday names are provided by `WP_Locale`. --- admin/schedule-form.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/admin/schedule-form.php b/admin/schedule-form.php index 01b52abc..e5ce91e1 100644 --- a/admin/schedule-form.php +++ b/admin/schedule-form.php @@ -2,6 +2,8 @@ namespace HM\BackUpWordPress; +global $wp_locale; + ?>

    @@ -103,13 +105,13 @@ -

    ' . size_format( get_max_attachment_size() ) . '' ); ?>

    +

    ' . size_format( get_max_attachment_size() ) . '' ); ?>

    @@ -61,14 +61,19 @@ public static function constant() { -

    ' . esc_html( HMBKP_ATTACHMENT_MAX_FILESIZE ) . '' ); ?>

    +

    ' . esc_html( HMBKP_ATTACHMENT_MAX_FILESIZE ) . '' + ); ?>

    10MB', "define( 'HMBKP_ATTACHMENT_MAX_FILESIZE', '25MB' );" - ); ?>

    + ); ?>

    @@ -87,7 +92,11 @@ public function display() { $email = '' . implode( ', ', array_map( 'esc_html', $emails ) ) . ''; - return sprintf( __( 'Send an email notification to %s', 'backupwordpress' ), $email ); + return sprintf( + /* translators: List of email addresses */ + esc_html__( 'Send an email notification to %s', 'backupwordpress' ), + $email + ); } @@ -122,7 +131,7 @@ public function update( &$new_data, $old_data ) { $email = trim( $email ); if ( ! is_email( $email ) ) { - $errors['email'] = sprintf( __( '%s isn\'t a valid email', 'backupwordpress' ), $email ); + $errors['email'] = sprintf( esc_html__( '%s isn\'t a valid email', 'backupwordpress' ), $email ); } } } @@ -178,9 +187,21 @@ public function action( $action, Backup $backup ) { $error_message = ' - ' . $error_message; } - $subject = sprintf( __( 'Backup of %s Failed', 'backupwordpress' ), $domain ); - - $message = sprintf( __( 'BackUpWordPress was unable to backup your site %1$s.', 'backupwordpress' ) . "\n\n" . __( 'Here are the errors that we\'ve encountered:', 'backupwordpress' ) . "\n\n" . '%2$s' . "\n\n" . __( 'If the errors above look like Martian, forward this email to %3$s and we\'ll take a look', 'backupwordpress' ) . "\n\n" . __( "Kind Regards,\nThe Apologetic BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), home_url(), $error_message, 'backupwordpress@hmn.md' ); + $subject = sprintf( + /* translators: Domain URL */ + esc_html__( 'Backup of %s Failed', 'backupwordpress' ), + $domain + ); + + $message = sprintf( + /* translators: 1: Site URL */ + esc_html__( 'BackUpWordPress was unable to backup your site %1$s.', 'backupwordpress' ) . "\n\n" . + esc_html__( 'Here are the errors that we\'ve encountered:', 'backupwordpress' ) . "\n\n" . '%2$s' . "\n\n" . + esc_html__( 'If the errors above look like Martian, forward this email to %3$s and we\'ll take a look', 'backupwordpress' ) . "\n\n" . + home_url(), + $error_message, + 'backupwordpress@hmn.md' + ); wp_mail( $this->get_email_address_array(), $subject, $message, $headers ); @@ -188,12 +209,25 @@ public function action( $action, Backup $backup ) { } - $subject = sprintf( __( 'Backup of %s', 'backupwordpress' ), $domain ); + $subject = sprintf( + /* translators: Domain URL */ + esc_html__( 'Backup of %s', 'backupwordpress' ), + $domain + ); // If it's larger than the max attachment size limit assume it's not going to be able to send the backup if ( @filesize( $file ) < get_max_attachment_size() ) { - $message = sprintf( __( 'BackUpWordPress has completed a backup of your site %1$s.', 'backupwordpress' ) . "\n\n" . __( 'The backup file should be attached to this email.', 'backupwordpress' ) . "\n\n" . __( 'You can download the backup file by clicking the link below:', 'backupwordpress' ) . "\n\n" . '%2$s' . "\n\n" . __( "Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), home_url(), $download ); + $message = sprintf( + /* translators: 1: Site URL */ + esc_html__( 'BackUpWordPress has completed a backup of your site %1$s.', 'backupwordpress' ) . "\n\n" . + esc_html__( 'The backup file should be attached to this email.', 'backupwordpress' ) . "\n\n" . + /* translators: 2: WordPress admin URL to BackupWordPress page */ + esc_html__( 'You can download the backup file by clicking the link below:', 'backupwordpress' ) . "\n\n" . '%2$s' . "\n\n" . + esc_html__( "Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), + home_url(), + $download + ); $sent = wp_mail( $this->get_email_address_array(), $subject, $message, $headers, $file ); @@ -202,7 +236,16 @@ public function action( $action, Backup $backup ) { // If we didn't send the email above then send just the notification if ( ! $sent ) { - $message = sprintf( __( 'BackUpWordPress has completed a backup of your site %1$s.', 'backupwordpress' ) . "\n\n" . __( 'Unfortunately, the backup file was too large to attach to this email.', 'backupwordpress' ) . "\n\n" . __( 'You can download the backup file by clicking the link below:', 'backupwordpress' ) . "\n\n" . '%2$s' . "\n\n" . __( "Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), home_url(), $download ); + $message = sprintf( + /* translators: 1: Site URL */ + esc_html__( 'BackUpWordPress has completed a backup of your site %1$s.', 'backupwordpress' ) . "\n\n" . + esc_html__( 'Unfortunately, the backup file was too large to attach to this email.', 'backupwordpress' ) . "\n\n" . + /* translators: 2: WordPress admin URL to BackupWordPress page */ + esc_html__( 'You can download the backup file by clicking the link below:', 'backupwordpress' ) . "\n\n" . '%2$s' . "\n\n" . + esc_html__( "Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), + home_url(), + $download + ); wp_mail( $this->get_email_address_array(), $subject, $message, $headers ); } From 22515c63fe9eb85f7bb34b08b4d606f442f6b5a2 Mon Sep 17 00:00:00 2001 From: dashaluna Date: Fri, 5 Aug 2016 09:31:46 +0100 Subject: [PATCH 10/14] Add escaping to translations --- admin/extensions.php | 47 ++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/admin/extensions.php b/admin/extensions.php index 520fd43c..7810c56c 100644 --- a/admin/extensions.php +++ b/admin/extensions.php @@ -8,14 +8,14 @@

    - + - +

    -

    +

    -

    +

    -

    +

    @@ -72,14 +72,17 @@
  • title->rendered ), array_keys( $installed_plugins ) ) ) : ?> - + - edd_price ); ?> + ); ?>" data-name="title->rendered ); ?>">edd_price ); ?> @@ -87,7 +90,7 @@
  • - +
  • @@ -117,7 +120,10 @@
    - _edd_sl_version ) ); ?> + _edd_sl_version + ); ?>
    @@ -131,7 +137,18 @@ if ( version_compare( $current_version, $extension->_edd_sl_version, '<' ) ) { - printf( __( 'A newer version (%1$s) is available. Update now!', 'backupwordpress' ), esc_html( $extension->_edd_sl_version ), esc_url( admin_url( 'update-core.php' ) ) ); + printf( + wp_kses( + __( 'A newer version (%1$s) is available. Update now!', 'backupwordpress' ), + array( + 'a' => array( + 'href' => array(), + ), + ) + ), + esc_html( $extension->_edd_sl_version ), + esc_url( admin_url( 'update-core.php' ) ) + ); } else { esc_html_e( 'You have the latest version', 'backupwordpress' ); @@ -147,7 +164,11 @@
    - modified ) ) ); ?> + modified ) ) + ); ?>
    From 35c8c615c87cd4f20b94d4b697188f7e894720aa Mon Sep 17 00:00:00 2001 From: dashaluna Date: Wed, 30 Aug 2017 13:31:25 +0100 Subject: [PATCH 11/14] Remove redundant new lines (introed after merge) --- admin/extensions.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/admin/extensions.php b/admin/extensions.php index 20a0bc59..22b13e69 100644 --- a/admin/extensions.php +++ b/admin/extensions.php @@ -163,7 +163,6 @@ class="thickbox" data-title="title->rendered ); ?>"> -
    @@ -192,7 +191,6 @@ class="thickbox" ), esc_html( human_time_diff( strtotime( $extension->modified ) ) ) ); ?> - From fe8b6f2f651345b54ef9851e3617b3bbe59d3324 Mon Sep 17 00:00:00 2001 From: dashaluna Date: Wed, 30 Aug 2017 14:12:01 +0100 Subject: [PATCH 12/14] Fix translations in email services --- classes/class-email-service.php | 64 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/classes/class-email-service.php b/classes/class-email-service.php index 2764d502..74415d0f 100644 --- a/classes/class-email-service.php +++ b/classes/class-email-service.php @@ -33,7 +33,7 @@ public function field() { -

    ' . size_format( get_max_attachment_size() ) . '' ); ?>

    +

    < ' . esc_html( size_format( get_max_attachment_size() ) ) . '' ); ?>

    @@ -187,67 +187,65 @@ public function action( $action, Backup $backup ) { $error_message = ' - ' . $error_message; } - $subject = sprintf( + $subject = wp_strip_all_tags( sprintf( /* translators: Domain URL */ - esc_html__( 'Backup of %s Failed', 'backupwordpress' ), + __( 'Backup of %s failed', 'backupwordpress' ), $domain - ); + ) ); $message = sprintf( - /* translators: 1: Site URL */ - esc_html__( 'BackUpWordPress was unable to backup your site %1$s.', 'backupwordpress' ) . "\n\n" . - esc_html__( 'Here are the errors that we\'ve encountered:', 'backupwordpress' ) . "\n\n" . '%2$s' . "\n\n" . - esc_html__( 'If the errors above look like Martian, forward this email to %3$s and we\'ll take a look', 'backupwordpress' ) . "\n\n" . - home_url(), - $error_message, - 'backupwordpress@hmn.md' + esc_html__( + 'BackUpWordPress was unable to backup your site %1$s.' . "\n\n" . + 'Here are the errors that we\'ve encountered: %2$s' . "\n\n" . + 'If the errors above look like Martian, forward this email to %3$s and we\'ll take a look.' . "\n\n", 'backupwordpress' ), + esc_url( home_url() ), + $error_message, + 'backupwordpress@hmn.md' ); wp_mail( $this->get_email_address_array(), $subject, $message, $headers ); return; - } - $subject = sprintf( + $subject = wp_strip_all_tags( sprintf( /* translators: Domain URL */ - esc_html__( 'Backup of %s', 'backupwordpress' ), + __( 'Backup of %s', 'backupwordpress' ), $domain - ); + ) ); // If it's larger than the max attachment size limit assume it's not going to be able to send the backup if ( @filesize( $file ) < get_max_attachment_size() ) { $message = sprintf( - /* translators: 1: Site URL */ - esc_html__( 'BackUpWordPress has completed a backup of your site %1$s.', 'backupwordpress' ) . "\n\n" . - esc_html__( 'The backup file should be attached to this email.', 'backupwordpress' ) . "\n\n" . - /* translators: 2: WordPress admin URL to BackupWordPress page */ - esc_html__( 'You can download the backup file by clicking the link below:', 'backupwordpress' ) . "\n\n" . '%2$s' . "\n\n" . - esc_html__( "Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), - home_url(), - $download + /* translators: 1: Site URL 2: WordPress admin URL to BackupWordPress page */ + esc_html__( + 'BackUpWordPress has completed a backup of your site %1$s'. "\n\n" . + "The backup file should be attached to this email. \n\n" . + "You can download the backup file by clicking the link below: \n\n" . '%2$s' . "\n\n" . + "Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), + esc_url( home_url() ), + esc_url( $download ) ); $sent = wp_mail( $this->get_email_address_array(), $subject, $message, $headers, $file ); - } // If we didn't send the email above then send just the notification if ( ! $sent ) { $message = sprintf( - /* translators: 1: Site URL */ - esc_html__( 'BackUpWordPress has completed a backup of your site %1$s.', 'backupwordpress' ) . "\n\n" . - esc_html__( 'Unfortunately, the backup file was too large to attach to this email.', 'backupwordpress' ) . "\n\n" . - /* translators: 2: WordPress admin URL to BackupWordPress page */ - esc_html__( 'You can download the backup file by clicking the link below:', 'backupwordpress' ) . "\n\n" . '%2$s' . "\n\n" . - esc_html__( "Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), - home_url(), - $download + /* translators: 1: Site URL 2: WordPress admin URL to BackupWordPress page */ + esc_html__( + 'BackUpWordPress has completed a backup of your site %1$s' . "\n\n" . + "Unfortunately, the backup file was too large to attach to this email. \n\n" . + 'You can download the backup file by clicking the link below:' . "\n\n" . '%2$s' . "\n\n" . + "Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), + esc_url( home_url() ), + esc_url( $download ) ); - wp_mail( $this->get_email_address_array(), $subject, $message, $headers ); + wp_mail( $this->get_email_address_array(), $subject, $message, $headers ); } } } From 7199380144a29a75ae7c6c52f412e36031b5093a Mon Sep 17 00:00:00 2001 From: dashaluna Date: Thu, 31 Aug 2017 10:51:37 +0100 Subject: [PATCH 13/14] Unify email notification format for translation - always append line breaks in double quotes --- classes/class-email-service.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/classes/class-email-service.php b/classes/class-email-service.php index 74415d0f..d861b40c 100644 --- a/classes/class-email-service.php +++ b/classes/class-email-service.php @@ -194,6 +194,7 @@ public function action( $action, Backup $backup ) { ) ); $message = sprintf( + /* translators: 1: Site URL 2: List of errors */ esc_html__( 'BackUpWordPress was unable to backup your site %1$s.' . "\n\n" . 'Here are the errors that we\'ve encountered: %2$s' . "\n\n" . @@ -221,9 +222,9 @@ public function action( $action, Backup $backup ) { /* translators: 1: Site URL 2: WordPress admin URL to BackupWordPress page */ esc_html__( 'BackUpWordPress has completed a backup of your site %1$s'. "\n\n" . - "The backup file should be attached to this email. \n\n" . - "You can download the backup file by clicking the link below: \n\n" . '%2$s' . "\n\n" . - "Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), + 'The backup file should be attached to this email.' . "\n\n" . + 'You can download the backup file by clicking the link below:' . "\n\n" . '%2$s' . "\n\n" . + 'Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot', 'backupwordpress' ), esc_url( home_url() ), esc_url( $download ) ); @@ -238,9 +239,9 @@ public function action( $action, Backup $backup ) { /* translators: 1: Site URL 2: WordPress admin URL to BackupWordPress page */ esc_html__( 'BackUpWordPress has completed a backup of your site %1$s' . "\n\n" . - "Unfortunately, the backup file was too large to attach to this email. \n\n" . + 'Unfortunately, the backup file was too large to attach to this email.' . "\n\n" . 'You can download the backup file by clicking the link below:' . "\n\n" . '%2$s' . "\n\n" . - "Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), + 'Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot', 'backupwordpress' ), esc_url( home_url() ), esc_url( $download ) ); From d1a87b54f20c28f4fa95f59828c2ffd52fc0623c Mon Sep 17 00:00:00 2001 From: dashaluna Date: Fri, 1 Sep 2017 09:29:07 +0100 Subject: [PATCH 14/14] Fix spacing in class-email-service around email messages code --- classes/class-email-service.php | 37 ++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/classes/class-email-service.php b/classes/class-email-service.php index d861b40c..e2ecdc0b 100644 --- a/classes/class-email-service.php +++ b/classes/class-email-service.php @@ -198,7 +198,8 @@ public function action( $action, Backup $backup ) { esc_html__( 'BackUpWordPress was unable to backup your site %1$s.' . "\n\n" . 'Here are the errors that we\'ve encountered: %2$s' . "\n\n" . - 'If the errors above look like Martian, forward this email to %3$s and we\'ll take a look.' . "\n\n", 'backupwordpress' ), + 'If the errors above look like Martian, forward this email to %3$s and we\'ll take a look.' . "\n\n", 'backupwordpress' + ), esc_url( home_url() ), $error_message, 'backupwordpress@hmn.md' @@ -219,14 +220,15 @@ public function action( $action, Backup $backup ) { if ( @filesize( $file ) < get_max_attachment_size() ) { $message = sprintf( - /* translators: 1: Site URL 2: WordPress admin URL to BackupWordPress page */ - esc_html__( - 'BackUpWordPress has completed a backup of your site %1$s'. "\n\n" . - 'The backup file should be attached to this email.' . "\n\n" . - 'You can download the backup file by clicking the link below:' . "\n\n" . '%2$s' . "\n\n" . - 'Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot', 'backupwordpress' ), - esc_url( home_url() ), - esc_url( $download ) + /* translators: 1: Site URL 2: WordPress admin URL to BackupWordPress page */ + esc_html__( + 'BackUpWordPress has completed a backup of your site %1$s' . "\n\n" . + 'The backup file should be attached to this email.' . "\n\n" . + 'You can download the backup file by clicking the link below:' . "\n\n" . '%2$s' . "\n\n" . + 'Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot', 'backupwordpress' + ), + esc_url( home_url() ), + esc_url( $download ) ); $sent = wp_mail( $this->get_email_address_array(), $subject, $message, $headers, $file ); @@ -236,14 +238,15 @@ public function action( $action, Backup $backup ) { if ( ! $sent ) { $message = sprintf( - /* translators: 1: Site URL 2: WordPress admin URL to BackupWordPress page */ - esc_html__( - 'BackUpWordPress has completed a backup of your site %1$s' . "\n\n" . - 'Unfortunately, the backup file was too large to attach to this email.' . "\n\n" . - 'You can download the backup file by clicking the link below:' . "\n\n" . '%2$s' . "\n\n" . - 'Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot', 'backupwordpress' ), - esc_url( home_url() ), - esc_url( $download ) + /* translators: 1: Site URL 2: WordPress admin URL to BackupWordPress page */ + esc_html__( + 'BackUpWordPress has completed a backup of your site %1$s' . "\n\n" . + 'Unfortunately, the backup file was too large to attach to this email.' . "\n\n" . + 'You can download the backup file by clicking the link below:' . "\n\n" . '%2$s' . "\n\n" . + 'Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot', 'backupwordpress' + ), + esc_url( home_url() ), + esc_url( $download ) ); wp_mail( $this->get_email_address_array(), $subject, $message, $headers );