Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Replace unnecessary usage of esc_html__.
  • Loading branch information
felixarntz committed Aug 12, 2022
commit 22c84071f43bd946bb8d6603fb94cc4ad7040c98
10 changes: 5 additions & 5 deletions modules/site-health/audit-autoloaded-options/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ function perflab_aao_autoloaded_options_test() {
$base_description = __( 'Autoloaded options are configuration settings for plugins and themes that are automatically loaded with every page load in WordPress. Having too many autoloaded options can slow down your site.', 'performance-lab' );

$result = array(
'label' => esc_html__( 'Autoloaded options are acceptable', 'performance-lab' ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed we are applying esc_html__ inconsistently to translations and that you removed a bunch in this PR.

For core, we don't escape translations, however for plugins I generally recommend escaping (as 10up recommends).

Maybe rather than changing here we can open a follow issue to use a uniform approach and change throughout the plugin?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While escaping is recommended for plugins more than core, the rules also say that escaping should happen at the output level. In all the places here though, we're only writing data into an array, so per those guidelines escaping here would not follow the best practice.

All escaping for Site Health check content should happen in WordPress core per that definition, since that's where the data is being output.

'label' => __( 'Autoloaded options are acceptable', 'performance-lab' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Performance', 'performance-lab' ),
'color' => 'blue',
),
'description' => sprintf(
/* translators: 1. Number of autoloaded options. 2. Autoloaded options size. */
'<p>' . esc_html( $base_description ) . ' ' . esc_html__( 'Your site has %1$s autoloaded options (size: %2$s) in the options table, which is acceptable.', 'performance-lab' ) . '</p>',
'<p>' . esc_html( $base_description ) . ' ' . __( 'Your site has %1$s autoloaded options (size: %2$s) in the options table, which is acceptable.', 'performance-lab' ) . '</p>',
$autoloaded_options_count,
size_format( $autoloaded_options_size )
),
Expand All @@ -70,10 +70,10 @@ function perflab_aao_autoloaded_options_test() {
}

$result['status'] = 'critical';
$result['label'] = esc_html__( 'Autoloaded options could affect performance', 'performance-lab' );
$result['label'] = __( 'Autoloaded options could affect performance', 'performance-lab' );
$result['description'] = sprintf(
/* translators: 1. Number of autoloaded options. 2. Autoloaded options size. */
'<p>' . esc_html( $base_description ) . ' ' . esc_html__( 'Your site has %1$s autoloaded options (size: %2$s) in the options table, which could cause your site to be slow. You can reduce the number of autoloaded options by cleaning up your site\'s options table.', 'performance-lab' ) . '</p>',
'<p>' . esc_html( $base_description ) . ' ' . __( 'Your site has %1$s autoloaded options (size: %2$s) in the options table, which could cause your site to be slow. You can reduce the number of autoloaded options by cleaning up your site\'s options table.', 'performance-lab' ) . '</p>',
$autoloaded_options_count,
size_format( $autoloaded_options_size )
);
Expand All @@ -91,7 +91,7 @@ function perflab_aao_autoloaded_options_test() {
/* translators: 1: HelpHub URL. 2: Link description. */
'<p><a target="_blank" href="%1$s">%2$s</a></p>',
esc_url( __( 'https://wordpress.org/support/article/optimization/#autoloaded-options', 'performance-lab' ) ),
esc_html__( 'More info about performance optimization', 'performance-lab' )
__( 'More info about performance optimization', 'performance-lab' )
);

/**
Expand Down
12 changes: 6 additions & 6 deletions modules/site-health/audit-enqueued-assets/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function perflab_aea_enqueued_js_assets_test() {
}

$result = array(
'label' => esc_html__( 'Enqueued scripts', 'performance-lab' ),
'label' => __( 'Enqueued scripts', 'performance-lab' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Performance', 'performance-lab' ),
Expand Down Expand Up @@ -209,9 +209,9 @@ function perflab_aea_enqueued_js_assets_test() {
/* translators: 1: HelpHub URL. 2: Link description. 3.URL to clean cache. 4. Clean Cache text. */
'<p><a target="_blank" href="%1$s">%2$s</a></p><p><a href="%3$s">%4$s</a></p>',
esc_url( __( 'https://wordpress.org/support/article/optimization/', 'performance-lab' ) ),
esc_html__( 'More info about performance optimization', 'performance-lab' ),
__( 'More info about performance optimization', 'performance-lab' ),
esc_url( add_query_arg( 'action', 'clean_aea_audit', wp_nonce_url( admin_url( 'site-health.php' ), 'clean_aea_audit' ) ) ),
esc_html__( 'Clean Test Cache', 'performance-lab' )
__( 'Clean Test Cache', 'performance-lab' )
);
}

Expand All @@ -234,7 +234,7 @@ function perflab_aea_enqueued_css_assets_test() {
return array();
}
$result = array(
'label' => esc_html__( 'Enqueued styles', 'performance-lab' ),
'label' => __( 'Enqueued styles', 'performance-lab' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Performance', 'performance-lab' ),
Expand Down Expand Up @@ -301,9 +301,9 @@ function perflab_aea_enqueued_css_assets_test() {
/* translators: 1: HelpHub URL. 2: Link description. 3.URL to clean cache. 4. Clean Cache text. */
'<p><a target="_blank" href="%1$s">%2$s</a></p><p><a href="%3$s">%4$s</a></p>',
esc_url( __( 'https://wordpress.org/support/article/optimization/', 'performance-lab' ) ),
esc_html__( 'More info about performance optimization', 'performance-lab' ),
__( 'More info about performance optimization', 'performance-lab' ),
esc_url( add_query_arg( 'action', 'clean_aea_audit', wp_nonce_url( admin_url( 'site-health.php' ), 'clean_aea_audit' ) ) ),
esc_html__( 'Clean Test Cache', 'performance-lab' )
__( 'Clean Test Cache', 'performance-lab' )
);
}

Expand Down