Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function perflab_oc_health_persistent_object_cache() {
'label' => __( 'A persistent object cache is being used', 'performance-lab' ),
'description' => sprintf(
'<p>%s</p>',
__( "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(
'<p><a href="%s" target="_blank" rel="noopener">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
Expand All @@ -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 object caches are able to be enabled on your site.', 'performance-lab' );

if ( ! empty( $available_services ) ) {
$notes .= ' ' . sprintf(
Expand Down
13 changes: 8 additions & 5 deletions modules/site-health/audit-autoloaded-options/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ 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', 'performance-lab' ),
'label' => esc_html__( 'Autoloaded options are acceptable', '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. */
'<p>' . esc_html__( 'The amount of %1$s autoloaded options (size: %2$s) in options table is acceptable.', 'performance-lab' ) . '</p>',
/* 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>',
$autoloaded_options_count,
size_format( $autoloaded_options_size )
),
Expand All @@ -69,9 +71,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. */
'<p>' . 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' ) . '</p>',
/* 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>',
$autoloaded_options_count,
size_format( $autoloaded_options_size )
);
Expand Down
4 changes: 2 additions & 2 deletions modules/site-health/webp-support/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function webp_uploads_check_webp_supported_test() {
),
'description' => sprintf(
'<p>%s</p>',
__( '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',
Expand All @@ -56,7 +56,7 @@ function webp_uploads_check_webp_supported_test() {
$result['actions'] = sprintf(
'<p>%s</p>',
/* 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' )
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'] );
}

/**
Expand Down Expand Up @@ -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. */
'<p>' . esc_html__( 'The amount of %1$s autoloaded options (size: %2$s) in options table is acceptable.', 'performance-lab' ) . '</p>',
$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. */
'<p>' . 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' ) . '</p>',
$autoloaded_options_count,
size_format( $autoloaded_options_size )
);

$result['actions'] = sprintf(
/* 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/', 'performance-lab' ) ),
esc_html__( 'More info about performance optimization', 'performance-lab' )
);

return array( array( $result ) );
}


}