Skip to content

Commit 1cff7dd

Browse files
leonardolaa-danae
andauthored
Removed html inside translatable strings. (#2210)
* removed html from translatable strings that are still in use #2199 * add changelog #2199 * Removed scaping where it was not needed and added on some places that it was needed. * standardized all translators: comments #2199 * Removed htlm scape on where it was unecessary #2199 * added url escape to get_setting_link #2199 Co-authored-by: Danae Millan <[email protected]>
1 parent aef667e commit 1cff7dd

26 files changed

+226
-102
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Changelog ***
22

33
= 6.3.0 - 2022-xx-xx =
4+
* Tweak - Remove html from translatable strings
45

56
= 6.2.0 - 2022-02-17 =
67
* Add - Add onboarding payment gateway setup methods.

includes/abstracts/abstract-wc-stripe-payment-gateway-voucher.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,13 @@ abstract class WC_Stripe_Payment_Gateway_Voucher extends WC_Stripe_Payment_Gatew
104104
* @since 5.8.0
105105
*/
106106
public function __construct() {
107-
/* translators: link */
108-
$this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
109-
$this->supports = [
107+
$this->method_description = sprintf(
108+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
109+
__( 'All other general Stripe settings can be adjusted %1$shere%2$s ', 'woocommerce-gateway-stripe' ),
110+
'<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) ) . '">',
111+
'</a>'
112+
);
113+
$this->supports = [
110114
'products',
111115
];
112116

includes/admin/class-wc-stripe-admin-notices.php

Lines changed: 76 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,23 @@ public function stripe_check_environment() {
132132
if ( empty( $show_3ds_notice ) && $three_d_secure ) {
133133
$url = 'https://stripe.com/docs/payments/3d-secure#three-ds-radar';
134134

135-
/* translators: 1) A URL that explains Stripe Radar. */
136-
$message = __( 'WooCommerce Stripe - We see that you had the "Require 3D secure when applicable" setting turned on. This setting is not available here anymore, because it is now replaced by Stripe Radar. You can learn more about it <a href="%s" target="_blank">here</a>.', 'woocommerce-gateway-stripe' );
137-
138-
$this->add_admin_notice( '3ds', 'notice notice-warning', sprintf( $message, $url ), true );
135+
$message = sprintf(
136+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
137+
__( 'WooCommerce Stripe - We see that you had the "Require 3D secure when applicable" setting turned on. This setting is not available here anymore, because it is now replaced by Stripe Radar. You can learn more about it %1$shere%2$s ', 'woocommerce-gateway-stripe' ),
138+
'<a href="' . $url . '" target="_blank">',
139+
'</a>'
140+
);
141+
142+
$this->add_admin_notice( '3ds', 'notice notice-warning', $message, true );
139143
}
140144

141145
if ( empty( $show_style_notice ) ) {
142-
/* translators: 1) int version 2) int version */
143-
$message = __( 'WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://woocommerce.com/document/stripe/#new-checkout-experience" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe' );
146+
$message = sprintf(
147+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
148+
__( 'WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these %1$sinstructions%2$s to fix.', 'woocommerce-gateway-stripe' ),
149+
'<a href="https://woocommerce.com/document/stripe/#new-checkout-experience" target="_blank">',
150+
'</a>'
151+
);
144152

145153
$this->add_admin_notice( 'style', 'notice notice-warning', $message, true );
146154

@@ -172,17 +180,23 @@ public function stripe_check_environment() {
172180
$this->add_admin_notice( 'curl', 'notice notice-warning', __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' ), true );
173181
}
174182
}
175-
// @codeCoverageIgnoreEnd
176183

184+
// @codeCoverageIgnoreEnd
177185
if ( empty( $show_keys_notice ) ) {
178186
$secret = WC_Stripe_API::get_secret_key();
179187
// phpcs:ignore
180188
$should_show_notice_on_page = ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 0 === strpos( $_GET['section'], 'stripe' ) );
181189

182190
if ( empty( $secret ) && $should_show_notice_on_page ) {
183191
$setting_link = $this->get_setting_link();
184-
/* translators: 1) link */
185-
$this->add_admin_notice( 'keys', 'notice notice-warning', sprintf( __( 'Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
192+
193+
$notice_message = sprintf(
194+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
195+
__( 'Stripe is almost ready. To get started, %1$sset your Stripe account keys%2$s.', 'woocommerce-gateway-stripe' ),
196+
'<a href="' . $setting_link . '">',
197+
'</a>'
198+
);
199+
$this->add_admin_notice( 'keys', 'notice notice-warning', $notice_message, true );
186200
}
187201

188202
// Check if keys are entered properly per live/test mode.
@@ -191,44 +205,83 @@ public function stripe_check_environment() {
191205
$is_test_secret_key = ! empty( $test_secret_key ) && preg_match( '/^[rs]k_test_/', $test_secret_key );
192206
if ( ! $is_test_pub_key || ! $is_test_secret_key ) {
193207
$setting_link = $this->get_setting_link();
194-
/* translators: 1) link */
195-
$this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
208+
209+
$notice_message = sprintf(
210+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
211+
__( 'Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, %1$sset your Stripe account keys%2$s.', 'woocommerce-gateway-stripe' ),
212+
'<a href="' . $setting_link . '">',
213+
'</a>'
214+
);
215+
216+
$this->add_admin_notice( 'keys', 'notice notice-error', $notice_message, true );
196217
}
197218
} else {
198219
$is_live_pub_key = ! empty( $live_pub_key ) && preg_match( '/^pk_live_/', $live_pub_key );
199220
$is_live_secret_key = ! empty( $live_secret_key ) && preg_match( '/^[rs]k_live_/', $live_secret_key );
200221
if ( ! $is_live_pub_key || ! $is_live_secret_key ) {
201222
$setting_link = $this->get_setting_link();
202-
/* translators: 1) link */
203-
$this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in live mode however your live keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
223+
224+
$message = sprintf(
225+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
226+
__( 'Stripe is in live mode however your live keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, %1$sset your Stripe account keys%2$s.', 'woocommerce-gateway-stripe' ),
227+
'<a href="' . $setting_link . '">',
228+
'</a>'
229+
);
230+
231+
$this->add_admin_notice( 'keys', 'notice notice-error', $message, true );
204232
}
205233
}
206234

207235
// Check if Stripe Account data was successfully fetched.
208236
$account_data = WC_Stripe::get_instance()->account->get_cached_account_data();
209237
if ( ! empty( $secret ) && empty( $account_data ) ) {
210238
$setting_link = $this->get_setting_link();
211-
/* translators: 1) link */
212-
$this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Your customers cannot use Stripe on checkout, because we couldn\'t connect to your account. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
239+
240+
$message = sprintf(
241+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
242+
__( 'Your customers cannot use Stripe on checkout, because we couldn\'t connect to your account. Please go to your settings and, %1$sset your Stripe account keys%2$s.', 'woocommerce-gateway-stripe' ),
243+
'<a href="' . $setting_link . '">',
244+
'</a>'
245+
);
246+
247+
$this->add_admin_notice( 'keys', 'notice notice-error', $message, true );
213248
}
214249
}
215250

216251
if ( empty( $show_ssl_notice ) ) {
217252
// Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected.
218253
if ( ! wc_checkout_is_https() ) {
219-
/* translators: 1) link */
220-
$this->add_admin_notice( 'ssl', 'notice notice-warning', sprintf( __( 'Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe' ), 'https://en.wikipedia.org/wiki/Transport_Layer_Security' ), true );
254+
$message = sprintf(
255+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
256+
__( 'Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid %1$sSSL certificate%2$s.', 'woocommerce-gateway-stripe' ),
257+
'<a href="https://en.wikipedia.org/wiki/Transport_Layer_Security" target="_blank">',
258+
'</a>'
259+
);
260+
261+
$this->add_admin_notice( 'ssl', 'notice notice-warning', $message, true );
221262
}
222263
}
223264

224265
if ( empty( $show_sca_notice ) ) {
225-
/* translators: %1 is the URL for the link */
226-
$this->add_admin_notice( 'sca', 'notice notice-success', sprintf( __( 'Stripe is now ready for Strong Customer Authentication (SCA) and 3D Secure 2! <a href="%1$s" target="_blank">Read about SCA</a>', 'woocommerce-gateway-stripe' ), 'https://woocommerce.com/posts/introducing-strong-customer-authentication-sca/' ), true );
266+
$message = sprintf(
267+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
268+
__( 'Stripe is now ready for Strong Customer Authentication (SCA) and 3D Secure 2! %1$sRead about SCA%2$s.', 'woocommerce-gateway-stripe' ),
269+
'<a href="https://woocommerce.com/posts/introducing-strong-customer-authentication-sca/" target="_blank">',
270+
'</a>'
271+
);
272+
273+
$this->add_admin_notice( 'sca', 'notice notice-success', $message, true );
227274
}
228275

229276
if ( 'yes' === $changed_keys_notice ) {
230-
// translators: %s is a the URL for the link.
231-
$this->add_admin_notice( 'changed_keys', 'notice notice-warning', sprintf( __( 'The public and/or secret keys for the Stripe gateway have been changed. This might cause errors for existing customers and saved payment methods. <a href="%s" target="_blank">Click here to learn more</a>.', 'woocommerce-gateway-stripe' ), 'https://woocommerce.com/document/stripe-fixing-customer-errors' ), true );
277+
$message = sprintf(
278+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
279+
__( 'The public and/or secret keys for the Stripe gateway have been changed. This might cause errors for existing customers and saved payment methods. %1$sClick here to learn more%2$s.', 'woocommerce-gateway-stripe' ),
280+
'<a href="https://woocommerce.com/document/stripe-fixing-customer-errors" target="_blank">',
281+
'</a>'
282+
);
283+
284+
$this->add_admin_notice( 'changed_keys', 'notice notice-warning', $message, true );
232285
}
233286
}
234287
}
@@ -250,7 +303,7 @@ public function payment_methods_check_environment() {
250303
}
251304

252305
if ( ! in_array( get_woocommerce_currency(), $gateway->get_supported_currency(), true ) ) {
253-
/* translators: %1$s Payment method, %2$s List of supported currencies */
306+
/* translators: 1) Payment method, 2) List of supported currencies */
254307
$this->add_admin_notice( $method, 'notice notice-error', sprintf( __( '%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe' ), $gateway->get_method_title(), implode( ', ', $gateway->get_supported_currency() ) ), true );
255308
}
256309
}
@@ -366,7 +419,7 @@ public function hide_notices() {
366419
* @return string Setting link
367420
*/
368421
public function get_setting_link() {
369-
return admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe&panel=settings' );
422+
return esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe&panel=settings' ) );
370423
}
371424

372425
/**

includes/admin/class-wc-stripe-privacy.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,15 @@ protected function get_stripe_orders( $email_address, $page ) {
8989
* Gets the message of the privacy to display.
9090
*/
9191
public function get_privacy_message() {
92-
/* translators: %s URL to docs */
93-
return wpautop( sprintf( __( 'By using this extension, you may be storing personal data or sharing data with an external service. <a href="%s" target="_blank">Learn more about how this works, including what you may want to include in your privacy policy.</a>', 'woocommerce-gateway-stripe' ), 'https://woocommerce.com/document/privacy-payments/#section-3' ) );
92+
93+
$message = sprintf(
94+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
95+
esc_html__( 'By using this extension, you may be storing personal data or sharing data with an external service. %1$sLearn more about how this works, including what you may want to include in your privacy policy%2$s.', 'woocommerce-gateway-stripe' ),
96+
'<a href="https://woocommerce.com/document/privacy-payments/#section-3" target="_blank">',
97+
'</a>'
98+
);
99+
100+
return wpautop( $message );
94101
}
95102

96103
/**

includes/admin/class-wc-stripe-settings-controller.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct( WC_Stripe_Account $account ) {
3636
*/
3737
public function admin_options( WC_Stripe_Payment_Gateway $gateway ) {
3838
global $hide_save_button;
39-
$hide_save_button = true;
39+
$hide_save_button = true;
4040

4141
echo '<h2>' . esc_html( $gateway->get_method_title() );
4242
wc_back_link( __( 'Return to payments', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout' ) );
@@ -102,12 +102,16 @@ public function admin_scripts( $hook_suffix ) {
102102
$oauth_url = '';
103103
}
104104

105+
$message = sprintf(
106+
/* translators: 1) Html strong opening tag 2) Html strong closing tag */
107+
esc_html__( '%1$sWarning:%2$s your site\'s time does not match the time on your browser and may be incorrect. Some payment methods depend on webhook verification and verifying webhooks with a signing secret depends on your site\'s time being correct, so please check your site\'s time before setting a webhook secret. You may need to contact your site\'s hosting provider to correct the site\'s time.', 'woocommerce-gateway-stripe' ),
108+
'<strong>',
109+
'</strong>'
110+
);
111+
105112
$params = [
106113
'time' => time(),
107-
'i18n_out_of_sync' => wp_kses(
108-
__( '<strong>Warning:</strong> your site\'s time does not match the time on your browser and may be incorrect. Some payment methods depend on webhook verification and verifying webhooks with a signing secret depends on your site\'s time being correct, so please check your site\'s time before setting a webhook secret. You may need to contact your site\'s hosting provider to correct the site\'s time.', 'woocommerce-gateway-stripe' ),
109-
[ 'strong' => [] ]
110-
),
114+
'i18n_out_of_sync' => $message,
111115
'is_upe_checkout_enabled' => WC_Stripe_Feature_Flags::is_upe_checkout_enabled(),
112116
'stripe_oauth_url' => $oauth_url,
113117
];

includes/class-wc-stripe-intent-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ public function update_order_status_ajax() {
576576
if ( empty( $intent_id_received ) || $intent_id_received !== $intent_id ) {
577577
$note = sprintf(
578578
/* translators: %1: transaction ID of the payment or a translated string indicating an unknown ID. */
579-
esc_html__( 'A payment with ID %s was used in an attempt to pay for this order. This payment intent ID does not match any payments for this order, so it was ignored and the order was not updated.', 'woocommerce-gateway-stripe' ),
579+
__( 'A payment with ID %s was used in an attempt to pay for this order. This payment intent ID does not match any payments for this order, so it was ignored and the order was not updated.', 'woocommerce-gateway-stripe' ),
580580
$intent_id_received
581581
);
582582
$order->add_order_note( $note );

includes/class-wc-stripe-webhook-handler.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,13 @@ public function process_webhook_dispute( $notification ) {
312312

313313
$order->update_meta_data( '_stripe_status_before_hold', $order->get_status() );
314314

315-
/* translators: 1) The URL to the order. */
316-
$message = sprintf( __( 'A dispute was created for this order. Response is needed. Please go to your <a href="%s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review this dispute.', 'woocommerce-gateway-stripe' ), $this->get_transaction_url( $order ) );
315+
$message = sprintf(
316+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
317+
__( 'A dispute was created for this order. Response is needed. Please go to your %1$sStripe Dashboard%2$s to review this dispute.', 'woocommerce-gateway-stripe' ),
318+
'<a href="' . esc_url( $this->get_transaction_url( $order ) ) . '" title="Stripe Dashboard" target="_blank">',
319+
'</a>'
320+
);
321+
317322
if ( ! $order->get_meta( '_stripe_status_final', false ) ) {
318323
$order->update_status( 'on-hold', $message );
319324
} else {
@@ -700,8 +705,13 @@ public function process_review_opened( $notification ) {
700705

701706
$order->update_meta_data( '_stripe_status_before_hold', $order->get_status() );
702707

703-
/* translators: 1) The URL to the order. 2) The reason type. */
704-
$message = sprintf( __( 'A review has been opened for this order. Action is needed. Please go to your <a href="%1$s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review the issue. Reason: (%2$s)', 'woocommerce-gateway-stripe' ), $this->get_transaction_url( $order ), $notification->data->object->reason );
708+
$message = sprintf(
709+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag 3) The reason type. */
710+
__( 'A review has been opened for this order. Action is needed. Please go to your %1$sStripe Dashboard%2$s to review the issue. Reason: (%3$s).', 'woocommerce-gateway-stripe' ),
711+
'<a href="' . esc_url( $this->get_transaction_url( $order ) ) . '" title="Stripe Dashboard" target="_blank">',
712+
'</a>',
713+
esc_html( $notification->data->object->reason )
714+
);
705715

706716
if ( apply_filters( 'wc_stripe_webhook_review_change_order_status', true, $order, $notification ) && ! $order->get_meta( '_stripe_status_final', false ) ) {
707717
$order->update_status( 'on-hold', $message );

includes/notes/class-wc-stripe-upe-availability-note.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ public static function get_note() {
3636
$note = new $note_class();
3737

3838
$note->set_title( __( 'Boost your sales with the new payment experience in Stripe', 'woocommerce-gateway-stripe' ) );
39-
$note->set_content( __( 'Get early access to an improved checkout experience, now available to select merchants. <a href="https://woocommerce.com/document/stripe/#new-checkout-experience" target="_blank">Learn more</a>.', 'woocommerce-gateway-stripe' ) );
39+
$message = sprintf(
40+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
41+
__( 'Get early access to an improved checkout experience, now available to select merchants. %1$sLearn more%2$s.', 'woocommerce-gateway-stripe' ),
42+
'<a href="https://woocommerce.com/document/stripe/#new-checkout-experience" target="_blank">',
43+
'</a>'
44+
);
45+
$note->set_content( $message );
4046
$note->set_type( $note_class::E_WC_ADMIN_NOTE_INFORMATIONAL );
4147
$note->set_name( self::NOTE_NAME );
4248
$note->set_source( 'woocommerce-gateway-stripe' );

includes/payment-methods/class-wc-gateway-stripe-alipay.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@ class WC_Gateway_Stripe_Alipay extends WC_Stripe_Payment_Gateway {
6060
* Constructor
6161
*/
6262
public function __construct() {
63-
$this->id = self::ID;
64-
$this->method_title = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' );
65-
/* translators: link */
66-
$this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
67-
$this->supports = [
63+
$this->id = self::ID;
64+
$this->method_title = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' );
65+
$this->method_description = sprintf(
66+
/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
67+
__( 'All other general Stripe settings can be adjusted %1$shere%2$s.', 'woocommerce-gateway-stripe' ),
68+
'<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) ) . '">',
69+
'</a>'
70+
);
71+
$this->supports = [
6872
'products',
6973
'refunds',
7074
];

0 commit comments

Comments
 (0)