From b272620ddb73e4ad2874da18623e282c719910e4 Mon Sep 17 00:00:00 2001 From: Bethany Chobanian Lang Date: Mon, 28 Mar 2022 09:23:17 -0400 Subject: [PATCH 1/8] Update autoloaded options title and descriptions per #229 --- modules/site-health/audit-autoloaded-options/load.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/site-health/audit-autoloaded-options/load.php b/modules/site-health/audit-autoloaded-options/load.php index e78571edf9..83a24a0735 100644 --- a/modules/site-health/audit-autoloaded-options/load.php +++ b/modules/site-health/audit-autoloaded-options/load.php @@ -38,7 +38,7 @@ function perflab_aao_autoloaded_options_test() { $autoloaded_options_count = count( wp_load_alloptions() ); $result = array( - 'label' => esc_html__( 'Autoloaded options', 'performance-lab' ), + 'label' => esc_html__( 'Autoloaded options are acceptable', 'performance-lab' ), 'status' => 'good', 'badge' => array( 'label' => esc_html__( 'Performance', 'performance-lab' ), @@ -46,7 +46,7 @@ function perflab_aao_autoloaded_options_test() { ), 'description' => sprintf( /* translators: 1: Number of autoloaded options. 2.Autoloaded options size. */ - '

' . esc_html__( 'The amount of %1$s autoloaded options (size: %2$s) in options table is acceptable.', 'performance-lab' ) . '

', + '

' . esc_html__( '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. Your site has %1$s autoloaded options (size: %2$s) in the options table, which is acceptable.', 'performance-lab' ) . '

', $autoloaded_options_count, size_format( $autoloaded_options_size ) ), @@ -69,9 +69,10 @@ function perflab_aao_autoloaded_options_test() { $result['status'] = 'critical'; $result['badge']['color'] = 'red'; + $result['label'] = esc_html__( 'Autoloaded options could affect performance', 'performance-lab' ); $result['description'] = sprintf( /* translators: 1: Number of autoloaded options. 2.Autoloaded options size. */ - '

' . esc_html__( 'Your website uses %1$s autoloaded options (size: %2$s). Try to reduce the number of autoloaded options or performance will be affected.', 'performance-lab' ) . '

', + '

' . esc_html__( 'Autoloaded options are configuration settings for plugins and themes that are automatically loaded with every page load in WordPress. 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' ) . '

', $autoloaded_options_count, size_format( $autoloaded_options_size ) ); From 52130d957bdb0ffebb6b26d2d6e5e382814b06fe Mon Sep 17 00:00:00 2001 From: Bethany Chobanian Lang Date: Mon, 28 Mar 2022 09:27:04 -0400 Subject: [PATCH 2/8] Update autoloaded options title and descriptions per #229 --- modules/site-health/audit-autoloaded-options/load.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/site-health/audit-autoloaded-options/load.php b/modules/site-health/audit-autoloaded-options/load.php index 83a24a0735..e989426317 100644 --- a/modules/site-health/audit-autoloaded-options/load.php +++ b/modules/site-health/audit-autoloaded-options/load.php @@ -69,7 +69,7 @@ function perflab_aao_autoloaded_options_test() { $result['status'] = 'critical'; $result['badge']['color'] = 'red'; - $result['label'] = esc_html__( 'Autoloaded options could affect performance', 'performance-lab' ); + $result['label'] = esc_html__( 'Autoloaded options could affect performance', 'performance-lab' ); $result['description'] = sprintf( /* translators: 1: Number of autoloaded options. 2.Autoloaded options size. */ '

' . esc_html__( 'Autoloaded options are configuration settings for plugins and themes that are automatically loaded with every page load in WordPress. 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' ) . '

', From c761c60d9113237401e171c5bdf69d71aee8e102 Mon Sep 17 00:00:00 2001 From: Bethany Chobanian Lang Date: Tue, 29 Mar 2022 10:33:28 -0400 Subject: [PATCH 3/8] Update WebP module copy --- modules/site-health/webp-support/load.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/site-health/webp-support/load.php b/modules/site-health/webp-support/load.php index 5e2e8bde61..9917ef880e 100644 --- a/modules/site-health/webp-support/load.php +++ b/modules/site-health/webp-support/load.php @@ -42,7 +42,7 @@ function webp_uploads_check_webp_supported_test() { ), 'description' => sprintf( '

%s

', - __( 'WebP image format is used by WordPress to improve the performance of your site by generating smaller images than it usually could with the JPEG format. This means your pages will load faster and consume less bandwidth.', 'performance-lab' ) + __( 'The WebP image format produces images that are usually smaller in size than JPEG images, which can reduce page load time and consume less bandwidth.', 'performance-lab' ) ), 'actions' => '', 'test' => 'is_webp_uploads_enabled', @@ -56,7 +56,7 @@ function webp_uploads_check_webp_supported_test() { $result['actions'] = sprintf( '

%s

', /* translators: Accessibility text. */ - __( 'Please contact your host and ask them to add WebP support.', 'performance-lab' ) + __( 'WebP support can only be enabled by your hosting provider, so contact them for more information.', 'performance-lab' ) ); } From b2418c4ebb88a24a8b8cfb453f5e6e045aa3fb79 Mon Sep 17 00:00:00 2001 From: Bethany Chobanian Lang Date: Tue, 29 Mar 2022 10:35:59 -0400 Subject: [PATCH 4/8] Update autoloaded options copy per feedback --- modules/site-health/audit-autoloaded-options/load.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/site-health/audit-autoloaded-options/load.php b/modules/site-health/audit-autoloaded-options/load.php index e989426317..74f5a4f7eb 100644 --- a/modules/site-health/audit-autoloaded-options/load.php +++ b/modules/site-health/audit-autoloaded-options/load.php @@ -45,7 +45,7 @@ function perflab_aao_autoloaded_options_test() { 'color' => 'blue', ), 'description' => sprintf( - /* translators: 1: Number of autoloaded options. 2.Autoloaded options size. */ + /* translators: 1. Number of autoloaded options. 2. Autoloaded options size. */ '

' . esc_html__( '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. Your site has %1$s autoloaded options (size: %2$s) in the options table, which is acceptable.', 'performance-lab' ) . '

', $autoloaded_options_count, size_format( $autoloaded_options_size ) @@ -71,8 +71,8 @@ function perflab_aao_autoloaded_options_test() { $result['badge']['color'] = 'red'; $result['label'] = esc_html__( 'Autoloaded options could affect performance', 'performance-lab' ); $result['description'] = sprintf( - /* translators: 1: Number of autoloaded options. 2.Autoloaded options size. */ - '

' . esc_html__( 'Autoloaded options are configuration settings for plugins and themes that are automatically loaded with every page load in WordPress. 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' ) . '

', + /* translators: 1. Number of autoloaded options. 2. Autoloaded options size. */ + '

' . esc_html__( '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. 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' ) . '

', $autoloaded_options_count, size_format( $autoloaded_options_size ) ); From c1f939231a01979fc3f57626f4a5950c7dde4481 Mon Sep 17 00:00:00 2001 From: Bethany Chobanian Lang Date: Tue, 29 Mar 2022 10:43:55 -0400 Subject: [PATCH 5/8] Updating persistent object cache report copy --- .../persistent-object-cache-health-check/load.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/object-cache/persistent-object-cache-health-check/load.php b/modules/object-cache/persistent-object-cache-health-check/load.php index edeb28cefa..752b3bf380 100644 --- a/modules/object-cache/persistent-object-cache-health-check/load.php +++ b/modules/object-cache/persistent-object-cache-health-check/load.php @@ -59,7 +59,7 @@ function perflab_oc_health_persistent_object_cache() { 'label' => __( 'A persistent object cache is being used', 'performance-lab' ), 'description' => sprintf( '

%s

', - __( "WordPress performs at its best when a persistent object cache is used. A persistent object cache helps to reduce load on your SQL server significantly and allows WordPress to retrieve your site's content and settings much faster.", 'performance-lab' ) + __( "A persistent object cache makes your site's database more efficient, resulting in faster load times because WordPress can retrieve your site's content and settings much more quickly.", 'performance-lab' ) ), 'actions' => sprintf( '

%s %s

', @@ -82,7 +82,7 @@ function perflab_oc_health_persistent_object_cache() { $available_services = perflab_oc_health_available_object_cache_services(); - $notes = __( 'Speak to your web host about what persistent object caches are available and how to enable them.', 'performance-lab' ); + $notes = __( 'Your hosting provider can tell you if persistent objects caches are able to be enabled on your site.', 'performance-lab' ); if ( ! empty( $available_services ) ) { $notes .= ' ' . sprintf( From 46ad3f464ab99fc80781ba03c13d5f8bbffa831e Mon Sep 17 00:00:00 2001 From: Bethany Chobanian Lang Date: Fri, 1 Apr 2022 10:43:57 -0400 Subject: [PATCH 6/8] Typo fix in Persistent Object Cache Health Check --- .../object-cache/persistent-object-cache-health-check/load.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/object-cache/persistent-object-cache-health-check/load.php b/modules/object-cache/persistent-object-cache-health-check/load.php index 752b3bf380..fd661722d6 100644 --- a/modules/object-cache/persistent-object-cache-health-check/load.php +++ b/modules/object-cache/persistent-object-cache-health-check/load.php @@ -82,7 +82,7 @@ function perflab_oc_health_persistent_object_cache() { $available_services = perflab_oc_health_available_object_cache_services(); - $notes = __( 'Your hosting provider can tell you if persistent objects caches are able to be enabled on your site.', 'performance-lab' ); + $notes = __( 'Your hosting provider can tell you if persistent object caches are able to be enabled on your site.', 'performance-lab' ); if ( ! empty( $available_services ) ) { $notes .= ' ' . sprintf( From bfcf1f418eb600fb0ba2f6220cb7b7dbb623293c Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Thu, 7 Apr 2022 14:34:39 -0700 Subject: [PATCH 7/8] Combine duplicate sentences into a single translation string in autoloaded options Site Health module. --- modules/site-health/audit-autoloaded-options/load.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/site-health/audit-autoloaded-options/load.php b/modules/site-health/audit-autoloaded-options/load.php index 74f5a4f7eb..8b7a5e6083 100644 --- a/modules/site-health/audit-autoloaded-options/load.php +++ b/modules/site-health/audit-autoloaded-options/load.php @@ -37,6 +37,8 @@ function perflab_aao_autoloaded_options_test() { $autoloaded_options_size = perflab_aao_autoloaded_options_size(); $autoloaded_options_count = count( wp_load_alloptions() ); + $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' ), 'status' => 'good', @@ -45,8 +47,8 @@ function perflab_aao_autoloaded_options_test() { 'color' => 'blue', ), 'description' => sprintf( - /* translators: 1. Number of autoloaded options. 2. Autoloaded options size. */ - '

' . esc_html__( '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. Your site has %1$s autoloaded options (size: %2$s) in the options table, which is acceptable.', 'performance-lab' ) . '

', + /* translators: 1. Number of autoloaded options. 2. Autoloaded options size. */ + '

' . 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' ) . '

', $autoloaded_options_count, size_format( $autoloaded_options_size ) ), @@ -71,8 +73,8 @@ function perflab_aao_autoloaded_options_test() { $result['badge']['color'] = 'red'; $result['label'] = esc_html__( 'Autoloaded options could affect performance', 'performance-lab' ); $result['description'] = sprintf( - /* translators: 1. Number of autoloaded options. 2. Autoloaded options size. */ - '

' . esc_html__( '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. 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' ) . '

', + /* translators: 1. Number of autoloaded options. 2. Autoloaded options size. */ + '

' . 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' ) . '

', $autoloaded_options_count, size_format( $autoloaded_options_size ) ); From fbdf7cd6ae4631252be81b5c437514ff48e1a2f3 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Thu, 7 Apr 2022 14:50:20 -0700 Subject: [PATCH 8/8] Fix and simplify Site Health autoloaded options module tests. --- .../audit-autoloaded-options-test.php | 123 +++++------------- 1 file changed, 29 insertions(+), 94 deletions(-) diff --git a/tests/modules/site-health/audit-autoloaded-options/audit-autoloaded-options-test.php b/tests/modules/site-health/audit-autoloaded-options/audit-autoloaded-options-test.php index 48acbfc9a6..3a4a238d00 100644 --- a/tests/modules/site-health/audit-autoloaded-options/audit-autoloaded-options-test.php +++ b/tests/modules/site-health/audit-autoloaded-options/audit-autoloaded-options-test.php @@ -10,37 +10,48 @@ class Audit_Autoloaded_Options_Tests extends WP_UnitTestCase { const AUTOLOADED_OPTION_KEY = 'test_set_autoloaded_option'; /** - * @dataProvider provider_added_test_info_site_health - * * Tests perflab_aao_add_autoloaded_options_test() */ - public function test_perflab_aao_add_autoloaded_options_test( $provider_added_test_info_site_health ) { - $this->assertEqualSets( $provider_added_test_info_site_health, perflab_aao_add_autoloaded_options_test( array() ) ); + public function test_perflab_aao_add_autoloaded_options_test() { + $expected_test = array( + 'label' => esc_html__( 'Autoloaded options', 'performance-lab' ), + 'test' => 'perflab_aao_autoloaded_options_test', + ); + + $this->assertEquals( + array( + 'direct' => array( + 'autoloaded_options' => $expected_test, + ), + ), + perflab_aao_add_autoloaded_options_test( array() ) + ); } /** - * @dataProvider provider_autoloaded_options_less_than_limit - * * Tests perflab_aao_autoloaded_options_test() when autoloaded options less than warning size. */ - public function test_perflab_aao_autoloaded_options_test_no_warning( $provider_autoloaded_options_less_than_limit ) { - $this->assertEqualSets( - perflab_aao_autoloaded_options_test(), - $provider_autoloaded_options_less_than_limit - ); + public function test_perflab_aao_autoloaded_options_test_no_warning() { + $expected_label = esc_html__( 'Autoloaded options are acceptable', 'performance-lab' ); + $expected_status = 'good'; + + $result = perflab_aao_autoloaded_options_test(); + $this->assertSame( $expected_label, $result['label'] ); + $this->assertSame( $expected_status, $result['status'] ); } /** - * @dataProvider provider_autoloaded_options_bigger_than_limit - * * Tests perflab_aao_autoloaded_options_test() when autoloaded options more than warning size. */ - public function test_perflab_aao_autoloaded_options_test_warning( $provider_autoloaded_options_bigger_than_limit ) { + public function test_perflab_aao_autoloaded_options_test_warning() { self::set_autoloaded_option( self::WARNING_AUTOLOADED_SIZE_LIMIT_IN_BYTES ); - $this->assertEqualSets( - perflab_aao_autoloaded_options_test(), - $provider_autoloaded_options_bigger_than_limit - ); + + $expected_label = esc_html__( 'Autoloaded options could affect performance', 'performance-lab' ); + $expected_status = 'critical'; + + $result = perflab_aao_autoloaded_options_test(); + $this->assertSame( $expected_label, $result['label'] ); + $this->assertSame( $expected_status, $result['status'] ); } /** @@ -74,81 +85,5 @@ public static function set_autoloaded_option( $bytes = 800000 ) { public static function delete_autoloaded_option() { delete_option( self::AUTOLOADED_OPTION_KEY ); } - - /** - * This is the information we are adding into site_status_tests hook. - * - * @return array - */ - public function provider_added_test_info_site_health() { - $added_tests = array(); - $added_tests['direct']['autoloaded_options'] = array( - 'label' => esc_html__( 'Autoloaded options', 'performance-lab' ), - 'test' => 'perflab_aao_autoloaded_options_test', - ); - return array( array( $added_tests ) ); - } - - /** - * Data provider for perflab_aao_autoloaded_options_test if autoloaded options are less than the limit. - * - * @return array - */ - public function provider_autoloaded_options_less_than_limit() { - $autoloaded_options_size = perflab_aao_autoloaded_options_size(); - $autoloaded_options_count = count( wp_load_alloptions() ); - - $result = array( - 'label' => esc_html__( 'Autoloaded options', 'performance-lab' ), - 'status' => 'good', - 'badge' => array( - 'label' => esc_html__( 'Performance', 'performance-lab' ), - 'color' => 'blue', - ), - 'description' => sprintf( - /* translators: 1: Number of autoloaded options. 2.Autoloaded options size. */ - '

' . esc_html__( 'The amount of %1$s autoloaded options (size: %2$s) in options table is acceptable.', 'performance-lab' ) . '

', - $autoloaded_options_count, - size_format( $autoloaded_options_size ) - ), - 'actions' => '', - 'test' => 'autoloaded_options', - ); - return array( array( $result ) ); - } - - /** - * Data provider for perflab_aao_autoloaded_options_test if autoloaded options are more than the limit. - * - * @return array - */ - public function provider_autoloaded_options_bigger_than_limit() { - $result = perflab_aao_autoloaded_options_test(); - - self::set_autoloaded_option( self::WARNING_AUTOLOADED_SIZE_LIMIT_IN_BYTES ); - $autoloaded_options_size = perflab_aao_autoloaded_options_size(); - $autoloaded_options_count = count( wp_load_alloptions() ); - self::delete_autoloaded_option(); - - $result['status'] = 'critical'; - $result['badge']['color'] = 'red'; - $result['description'] = sprintf( - /* translators: 1: Number of autoloaded options. 2.Autoloaded options size. */ - '

' . esc_html__( 'Your website uses %1$s autoloaded options (size: %2$s). Try to reduce the number of autoloaded options or performance will be affected.', 'performance-lab' ) . '

', - $autoloaded_options_count, - size_format( $autoloaded_options_size ) - ); - - $result['actions'] = sprintf( - /* translators: 1: HelpHub URL. 2: Link description. */ - '

%2$s

', - esc_url( __( 'https://wordpress.org/support/article/optimization/', 'performance-lab' ) ), - esc_html__( 'More info about performance optimization', 'performance-lab' ) - ); - - return array( array( $result ) ); - } - - }