From b3b3f20739c9342df728ffb1ea2a6741937bbba2 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Tue, 3 Dec 2024 14:17:10 -0600 Subject: [PATCH 01/24] Add Health Checks --- includes/HealthCheckManager.php | 141 ++++++++++++++++++++ includes/HealthChecks.php | 230 ++++++++++++++++++++++++++++++++ includes/Performance.php | 7 + 3 files changed, 378 insertions(+) create mode 100644 includes/HealthCheckManager.php create mode 100644 includes/HealthChecks.php diff --git a/includes/HealthCheckManager.php b/includes/HealthCheckManager.php new file mode 100644 index 0000000..53ac3d2 --- /dev/null +++ b/includes/HealthCheckManager.php @@ -0,0 +1,141 @@ +container = $container; + + if ( function_exists( 'add_filter' ) ) { + $this->addHooks(); + } + } + + /** + * Add hooks. + */ + public function addHooks() { + add_filter( 'site_status_tests', array( $this, 'registerHealthChecks' ) ); + } + + /** + * Add a health check. + * + * @param array $options Health check options. + */ + public function addHealthCheck( $options ) { + $options = wp_parse_args( + $options, + array( + 'id' => '', + 'title' => '', + 'test' => '', + 'label' => false, // Setting this will override pass/fail labels. + 'pass' => '', + 'fail' => '', + 'text' => '', + 'status' => false, // Override the status of the health check: default is good for pass, critical for fail. + 'badge_label' => __( 'Performance', 'newfold-labs' ), + 'badge_color' => 'blue', + 'actions' => '', + ) + ); + + // Make sure the health check is valid. + if ( ! ( empty( $options['id'] ) || empty( $options['title'] ) || ! is_callable( $options['test'] ) ) ) { + $this->checks[ $this->prefix . $options['id'] ] = $options; + } + } + + /** + * Run a health check. + * + * @param string $id Health check ID. + * + * @return array Health check results. + */ + public function runHealthCheck( $id ) { + $check = $this->checks[ $id ]; + + // Execute the test. + $passed = call_user_func( $check['test'] ); + + // Return the health check results. + return array( + 'label' => $check['label'] ? $check['label'] : ( $passed ? $check['pass'] : $check['fail'] ), + 'status' => $check['status'] ? $check['status'] : ( $passed ? 'good' : 'critical' ), + 'description' => $check['text'] ? $check['text'] : '', + 'actions' => $check['actions'] ? $check['actions'] : '', + 'test' => $check['id'], + 'badge' => array( + 'label' => $check['badge_label'], + 'color' => $check['badge_color'], + ), + ); + } + + /** + * Add health checks. + * + * @param array $tests Site Health tests. + * + * @return array Site Health tests. + */ + public function registerHealthChecks( $tests ) { + // If there are no health checks, don't add any. + if ( ! is_array( $this->checks ) || empty( $this->checks ) ) { + return $tests; + } + + foreach ( $this->checks as $id => $check ) { + /** + * Filter to enable/disable a health check. + * + * @param bool $do_check Whether to run the health check. + */ + $do_check = apply_filters( 'newfold/features/filter/isEnabled:healthChecks:' . $id, true ); // phpcs:ignore + if ( $do_check ) { + $tests['direct'][ $id ] = array( + 'label' => $check['title'], + 'test' => function () use ( $id ) { + return $this->runHealthCheck( $id ); + }, + ); + } + } + + return $tests; + } +} diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php new file mode 100644 index 0000000..d0b405c --- /dev/null +++ b/includes/HealthChecks.php @@ -0,0 +1,230 @@ +container = $container; + } + + /** + * Add health checks. + */ + public function addHealthChecks() { + $manager = $this->container->get( 'healthCheckManager' ); + + $manager->addHealthCheck( + array( + 'id' => 'autosave_interval', + 'title' => __( 'Autosave Interval', 'newfold-performance-module' ), + 'pass' => __( 'Autosaving is set to happen every 30 seconds or more.', 'newfold-performance-module' ), + 'fail' => __( 'Autosaving is set to be frequent, less than every 30 seconds.', 'newfold-performance-module' ), + 'text' => __( 'Setting the autosave interval to a longer period can reduce server load, it is recommended to set it to 30 seconds or more.', 'newfold-performance-module' ), + 'test' => function () { + return ( defined( 'AUTOSAVE_INTERVAL' ) && AUTOSAVE_INTERVAL >= 30 ); + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'post-revisions', + 'title' => __( 'Post Revisions', 'newfold-performance-module' ), + 'pass' => __( 'Number of post revisions is limited to 5 or less.', 'newfold-performance-module' ), + 'fail' => __( 'Number of post revisions is set to a high number.', 'newfold-performance-module' ), + 'text' => __( 'Setting the number of post revisions to a lower number can reduce database bloat.', 'newfold-performance-module' ), + 'test' => function () { + return ( defined( 'WP_POST_REVISIONS' ) && WP_POST_REVISIONS <= 5 ); + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'empty-trash-days', + 'title' => __( 'Empty Trash Days', 'newfold-performance-module' ), + 'pass' => __( 'Trash is emptied every 30 days or less.', 'newfold-performance-module' ), + 'fail' => __( 'Trash is emptied less frequently than every 30 days.', 'newfold-performance-module' ), + 'text' => __( 'Emptying the trash more frequently can reduce database bloat.', 'newfold-performance-module' ), + 'test' => function () { + return ( defined( 'EMPTY_TRASH_DAYS' ) && EMPTY_TRASH_DAYS <= 30 ); + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'wp-cron-lock-timeout', + 'title' => __( 'WP Cron Lock Timeout', 'newfold-performance-module' ), + 'pass' => __( 'Cron lock timeout is set to 60 seconds or less.', 'newfold-performance-module' ), + 'fail' => __( 'Cron lock timeout is set to a high number.', 'newfold-performance-module' ), + 'text' => __( 'Cron lock timeout affects how long a cron job can run for, setting it to a lower number can improve performance.', 'newfold-performance-module' ), + 'test' => function () { + return ( defined( 'WP_CRON_LOCK_TIMEOUT' ) && WP_CRON_LOCK_TIMEOUT <= 60 ); + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'permalinks', + 'title' => __( 'Permalinks', 'newfold-performance-module' ), + 'pass' => __( 'Permalinks are pretty', 'newfold-performance-module' ), + 'fail' => __( 'Permalinks are not set up', 'newfold-performance-module' ), + 'text' => __( 'Setting permalinks to anything other than plain can improve performance and SEO.', 'newfold-performance-module' ), + 'test' => function () { + return empty( get_option( 'permalink_structure' ) ); + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'page-caching', + 'title' => __( 'Page Caching', 'newfold-performance-module' ), + 'pass' => __( 'Page caching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Page caching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Page caching can improve performance by bypassing PHP and database queries for faster page loads.', 'newfold-performance-module' ), + 'test' => function () { + return ( get_option( 'newfold_cache_level' ) >= 1 ); + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'browser-caching', + 'title' => __( 'Browser Caching', 'newfold-performance-module' ), + 'pass' => __( 'Browser caching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Browser caching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Enabling browser caching can improve performance by storing static assets in the browser for faster page loads.', 'newfold-performance-module' ), + 'test' => function () { + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'object-caching', + 'title' => __( 'Object Caching', 'newfold-performance-module' ), + 'pass' => __( 'Object caching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Object caching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Object caching can improve performance by storing database queries in memory for faster page loads.', 'newfold-performance-module' ), + 'test' => function () { + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'cloudflare_active', + 'title' => __( 'Cloudflare enabled', 'newfold-performance-module' ), + 'pass' => __( 'Cloudflare integration is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Cloudflare integration is disabled', 'newfold-performance-module' ), + 'text' => __( 'Cloudflare integration can improve performance and security.', 'newfold-performance-module' ), + 'test' => function () { + // return $this->container->get( 'cacheManager' )->isEnabled( 'cloudflare' ); + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'lazy-loading', + 'title' => __( 'Lazy Loading', 'newfold-performance-module' ), + 'pass' => __( 'Lazy loading is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Lazy loading is disabled', 'newfold-performance-module' ), + 'text' => __( 'Lazy loading can improve performance by only loading images when they are in view.', 'newfold-performance-module' ), + 'test' => function () { + // TODO: https://github.com/newfold-labs/wp-module-performance/pull/32 + // nfd_image_optimization + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'link-prefetch', + 'title' => __( 'Link Prefetching', 'newfold-performance-module' ), + 'pass' => __( 'Link prefetching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Link prefetching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'newfold-performance-module' ), + 'test' => function () { + // TODO: https://github.com/newfold-labs/wp-module-performance/pull/26 + // nfd_link_prefetch_settings + }, + ) + ); + + + $manager->addHealthCheck( + array( + 'id' => 'prioritize-critical-css', + 'title' => __( 'Prioritize Critical CSS', 'newfold-performance-module' ), + 'pass' => __( 'Critical CSS is prioritized', 'newfold-performance-module' ), + 'fail' => __( 'Critical CSS is not prioritized', 'newfold-performance-module' ), + 'text' => __( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'newfold-performance-module' ), + 'test' => function () { + // TODO: https://github.com/newfold-labs/wp-module-performance/pull/25 + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'defer-non-essential-javascript', + 'title' => __( 'Defer Non-Essential JavaScript', 'newfold-performance-module' ), + 'pass' => __( 'Non-essential JavaScript is deferred', 'newfold-performance-module' ), + 'fail' => __( 'Non-essential JavaScript is not deferred', 'newfold-performance-module' ), + 'text' => __( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'newfold-performance-module' ), + 'test' => function () { + // TODO: https://github.com/newfold-labs/wp-module-performance/pull/25 + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'concatenate js', + 'title' => __( 'Concatenate JavaScript', 'newfold-performance-module' ), + 'pass' => __( 'JavaScript files are concatenated', 'newfold-performance-module' ), + 'fail' => __( 'JavaScript files are not concatenated', 'newfold-performance-module' ), + 'text' => __( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-performance-module' ), + 'test' => function () { + // TODO: https://github.com/newfold-labs/wp-module-performance/pull/25 + }, + ) + ); + + $manager->addHealthCheck( + array( + 'id' => 'concatenate-css', + 'title' => __( 'Concatenate CSS', 'newfold-performance-module' ), + 'pass' => __( 'CSS files are concatenated', 'newfold-performance-module' ), + 'fail' => __( 'CSS files are not concatenated', 'newfold-performance-module' ), + 'text' => __( 'Concatenating CSS can improve performance by reducing the number of requests.', 'newfold-performance-module' ), + 'test' => function () { + // TODO: https://github.com/newfold-labs/wp-module-performance/pull/25 + }, + ) + ); + } +} diff --git a/includes/Performance.php b/includes/Performance.php index ac50c2f..da4a805 100644 --- a/includes/Performance.php +++ b/includes/Performance.php @@ -3,6 +3,7 @@ namespace NewfoldLabs\WP\Module\Performance; use NewfoldLabs\WP\Module\Performance\CacheTypes\Browser; +use NewfoldLabs\WP\Module\Performance\CacheTypes\Cloudflare; use NewfoldLabs\WP\Module\Performance\CacheTypes\File; use NewfoldLabs\WP\Module\Performance\CacheTypes\Skip404; use NewfoldLabs\WP\ModuleLoader\Container; @@ -71,6 +72,8 @@ public function __construct( Container $container ) { $cacheManager = new CacheManager( $container ); $cachePurger = new CachePurgingService( $cacheManager->getInstances() ); + $healthCheckManager = new HealthCheckManager( $container ); + $healthChecks = new HealthChecks( $container ); // Ensure that purgeable cache types are enabled before showing the UI. if ( $cachePurger->canPurge() ) { @@ -80,6 +83,10 @@ public function __construct( Container $container ) { $container->set( 'cachePurger', $cachePurger ); $container->set( 'hasMustUsePlugin', file_exists( WPMU_PLUGIN_DIR . '/endurance-page-cache.php' ) ); + + $container->set( 'healthCheckManager', $healthCheckManager ); + + $healthChecks->addHealthChecks(); } /** From 7e384b322aeb3fb86475297b8bd441e361f1f4b8 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Tue, 10 Dec 2024 11:40:54 -0600 Subject: [PATCH 02/24] Tidy up --- includes/HealthChecks.php | 9 ++++----- includes/Performance.php | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index d0b405c..0d12f98 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -33,7 +33,7 @@ public function addHealthChecks() { $manager->addHealthCheck( array( - 'id' => 'autosave_interval', + 'id' => 'autosave-interval', 'title' => __( 'Autosave Interval', 'newfold-performance-module' ), 'pass' => __( 'Autosaving is set to happen every 30 seconds or more.', 'newfold-performance-module' ), 'fail' => __( 'Autosaving is set to be frequent, less than every 30 seconds.', 'newfold-performance-module' ), @@ -135,7 +135,7 @@ public function addHealthChecks() { $manager->addHealthCheck( array( - 'id' => 'cloudflare_active', + 'id' => 'cloudflare-active', 'title' => __( 'Cloudflare enabled', 'newfold-performance-module' ), 'pass' => __( 'Cloudflare integration is enabled', 'newfold-performance-module' ), 'fail' => __( 'Cloudflare integration is disabled', 'newfold-performance-module' ), @@ -174,7 +174,6 @@ public function addHealthChecks() { ) ); - $manager->addHealthCheck( array( 'id' => 'prioritize-critical-css', @@ -203,14 +202,14 @@ public function addHealthChecks() { $manager->addHealthCheck( array( - 'id' => 'concatenate js', + 'id' => 'concatenate-js', 'title' => __( 'Concatenate JavaScript', 'newfold-performance-module' ), 'pass' => __( 'JavaScript files are concatenated', 'newfold-performance-module' ), 'fail' => __( 'JavaScript files are not concatenated', 'newfold-performance-module' ), 'text' => __( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-performance-module' ), 'test' => function () { // TODO: https://github.com/newfold-labs/wp-module-performance/pull/25 - }, + }, ) ); diff --git a/includes/Performance.php b/includes/Performance.php index da4a805..24545c8 100644 --- a/includes/Performance.php +++ b/includes/Performance.php @@ -70,10 +70,10 @@ public function __construct( Container $container ) { $this->hooks( $container ); - $cacheManager = new CacheManager( $container ); - $cachePurger = new CachePurgingService( $cacheManager->getInstances() ); + $cacheManager = new CacheManager( $container ); + $cachePurger = new CachePurgingService( $cacheManager->getInstances() ); $healthCheckManager = new HealthCheckManager( $container ); - $healthChecks = new HealthChecks( $container ); + $healthChecks = new HealthChecks( $container ); // Ensure that purgeable cache types are enabled before showing the UI. if ( $cachePurger->canPurge() ) { From a39d90247829889aa05c3eb5fc66fb3be5d04697 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Tue, 10 Dec 2024 12:41:27 -0600 Subject: [PATCH 03/24] Update text --- includes/HealthChecks.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index 0d12f98..53a6825 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -48,8 +48,8 @@ public function addHealthChecks() { array( 'id' => 'post-revisions', 'title' => __( 'Post Revisions', 'newfold-performance-module' ), - 'pass' => __( 'Number of post revisions is limited to 5 or less.', 'newfold-performance-module' ), - 'fail' => __( 'Number of post revisions is set to a high number.', 'newfold-performance-module' ), + 'pass' => __( 'Number of post revisions is limited to 5 or less', 'newfold-performance-module' ), + 'fail' => __( 'Number of post revisions is set to a high number', 'newfold-performance-module' ), 'text' => __( 'Setting the number of post revisions to a lower number can reduce database bloat.', 'newfold-performance-module' ), 'test' => function () { return ( defined( 'WP_POST_REVISIONS' ) && WP_POST_REVISIONS <= 5 ); @@ -61,7 +61,7 @@ public function addHealthChecks() { array( 'id' => 'empty-trash-days', 'title' => __( 'Empty Trash Days', 'newfold-performance-module' ), - 'pass' => __( 'Trash is emptied every 30 days or less.', 'newfold-performance-module' ), + 'pass' => __( 'Trash is emptied every 30 days or less', 'newfold-performance-module' ), 'fail' => __( 'Trash is emptied less frequently than every 30 days.', 'newfold-performance-module' ), 'text' => __( 'Emptying the trash more frequently can reduce database bloat.', 'newfold-performance-module' ), 'test' => function () { @@ -78,7 +78,7 @@ public function addHealthChecks() { 'fail' => __( 'Cron lock timeout is set to a high number.', 'newfold-performance-module' ), 'text' => __( 'Cron lock timeout affects how long a cron job can run for, setting it to a lower number can improve performance.', 'newfold-performance-module' ), 'test' => function () { - return ( defined( 'WP_CRON_LOCK_TIMEOUT' ) && WP_CRON_LOCK_TIMEOUT <= 60 ); + return ( defined( 'WP_CRON_LOCK_TIMEOUT' ) && WP_CRON_LOCK_TIMEOUT <= 300 ); }, ) ); From cccc5bb2a776bf9ab607ad64200f497e87a57b8e Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Tue, 10 Dec 2024 13:20:11 -0600 Subject: [PATCH 04/24] Implement remaining checks --- includes/HealthChecks.php | 52 +++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index 53a6825..35f74f2 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -104,7 +104,7 @@ public function addHealthChecks() { 'fail' => __( 'Page caching is disabled', 'newfold-performance-module' ), 'text' => __( 'Page caching can improve performance by bypassing PHP and database queries for faster page loads.', 'newfold-performance-module' ), 'test' => function () { - return ( get_option( 'newfold_cache_level' ) >= 1 ); + return ( get_option( 'newfold_cache_level' ) >= 2 ); }, ) ); @@ -117,21 +117,26 @@ public function addHealthChecks() { 'fail' => __( 'Browser caching is disabled', 'newfold-performance-module' ), 'text' => __( 'Enabling browser caching can improve performance by storing static assets in the browser for faster page loads.', 'newfold-performance-module' ), 'test' => function () { + return ( get_option( 'newfold_cache_level' ) >= 1 ); }, ) ); - $manager->addHealthCheck( - array( - 'id' => 'object-caching', - 'title' => __( 'Object Caching', 'newfold-performance-module' ), - 'pass' => __( 'Object caching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Object caching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Object caching can improve performance by storing database queries in memory for faster page loads.', 'newfold-performance-module' ), - 'test' => function () { - }, - ) - ); + // Only show object caching health check for Bluehost brand. + if ( 'bluehost' === $this->container->plugin()->brand ) { + $manager->addHealthCheck( + array( + 'id' => 'persistent_object_cache', // Replaces the default test. + 'title' => __( 'Object Caching', 'newfold-performance-module' ), + 'pass' => __( 'Object caching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Object caching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-performance-module' ), + 'test' => function () { + return wp_using_ext_object_cache(); + }, + ) + ); + } $manager->addHealthCheck( array( @@ -141,7 +146,7 @@ public function addHealthChecks() { 'fail' => __( 'Cloudflare integration is disabled', 'newfold-performance-module' ), 'text' => __( 'Cloudflare integration can improve performance and security.', 'newfold-performance-module' ), 'test' => function () { - // return $this->container->get( 'cacheManager' )->isEnabled( 'cloudflare' ); + return isset( $_SERVER['HTTP_CF_RAY'] ); }, ) ); @@ -154,8 +159,8 @@ public function addHealthChecks() { 'fail' => __( 'Lazy loading is disabled', 'newfold-performance-module' ), 'text' => __( 'Lazy loading can improve performance by only loading images when they are in view.', 'newfold-performance-module' ), 'test' => function () { - // TODO: https://github.com/newfold-labs/wp-module-performance/pull/32 - // nfd_image_optimization + $enabled = get_option( 'nfd_image_optimization', array() ); + return ( isset( $enabled['lazy_loading'], $enabled['lazy_loading']['enabled'] ) && $enabled['lazy_loading']['enabled'] ); }, ) ); @@ -168,8 +173,9 @@ public function addHealthChecks() { 'fail' => __( 'Link prefetching is disabled', 'newfold-performance-module' ), 'text' => __( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'newfold-performance-module' ), 'test' => function () { - // TODO: https://github.com/newfold-labs/wp-module-performance/pull/26 - // nfd_link_prefetch_settings + https://github.com/newfold-labs/wp-module-performance/pull/26 + $enabled = get_option( 'nfd_link_prefetch_settings', array() ); + return ( isset( $enabled['activeOnDesktop'] ) && $enabled['activeOnDesktop'] ); }, ) ); @@ -182,7 +188,8 @@ public function addHealthChecks() { 'fail' => __( 'Critical CSS is not prioritized', 'newfold-performance-module' ), 'text' => __( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'newfold-performance-module' ), 'test' => function () { - // TODO: https://github.com/newfold-labs/wp-module-performance/pull/25 + https://github.com/newfold-labs/wp-module-performance/pull/25 + return get_option( 'jetpack_boost_status_critical-css', false ); }, ) ); @@ -195,7 +202,8 @@ public function addHealthChecks() { 'fail' => __( 'Non-essential JavaScript is not deferred', 'newfold-performance-module' ), 'text' => __( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'newfold-performance-module' ), 'test' => function () { - // TODO: https://github.com/newfold-labs/wp-module-performance/pull/25 + https://github.com/newfold-labs/wp-module-performance/pull/25 + return get_option( 'jetpack_boost_status_render-blocking-js', false ); }, ) ); @@ -208,7 +216,8 @@ public function addHealthChecks() { 'fail' => __( 'JavaScript files are not concatenated', 'newfold-performance-module' ), 'text' => __( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-performance-module' ), 'test' => function () { - // TODO: https://github.com/newfold-labs/wp-module-performance/pull/25 + https://github.com/newfold-labs/wp-module-performance/pull/25 + return ( ! empty( get_option( 'jetpack_boost_status_minify-js', array() ) ) ); }, ) ); @@ -221,7 +230,8 @@ public function addHealthChecks() { 'fail' => __( 'CSS files are not concatenated', 'newfold-performance-module' ), 'text' => __( 'Concatenating CSS can improve performance by reducing the number of requests.', 'newfold-performance-module' ), 'test' => function () { - // TODO: https://github.com/newfold-labs/wp-module-performance/pull/25 + https://github.com/newfold-labs/wp-module-performance/pull/25 + return ( ! empty( get_option( 'jetpack_boost_status_minify-css', array() ) ) ); }, ) ); From 84f195c474673390f3249c08992421891e9b2dfd Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Tue, 10 Dec 2024 13:21:39 -0600 Subject: [PATCH 05/24] Comment each check --- includes/HealthChecks.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index 35f74f2..e0b2708 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -31,6 +31,7 @@ public function __construct( Container $container ) { public function addHealthChecks() { $manager = $this->container->get( 'healthCheckManager' ); + // PRESS7-108: Autosave Interval. $manager->addHealthCheck( array( 'id' => 'autosave-interval', @@ -44,6 +45,7 @@ public function addHealthChecks() { ) ); + // PRESS7-109: Post Revisions. $manager->addHealthCheck( array( 'id' => 'post-revisions', @@ -57,6 +59,7 @@ public function addHealthChecks() { ) ); + // PRESS7-110: Empty Trash Days. $manager->addHealthCheck( array( 'id' => 'empty-trash-days', @@ -70,6 +73,7 @@ public function addHealthChecks() { ) ); + // PRESS7-111: Cron Lock Timeout. $manager->addHealthCheck( array( 'id' => 'wp-cron-lock-timeout', @@ -83,6 +87,7 @@ public function addHealthChecks() { ) ); + // PRESS7-118: Permalinks. $manager->addHealthCheck( array( 'id' => 'permalinks', @@ -96,6 +101,7 @@ public function addHealthChecks() { ) ); + // PRESS7-112: Page Caching. $manager->addHealthCheck( array( 'id' => 'page-caching', @@ -109,6 +115,7 @@ public function addHealthChecks() { ) ); + // PRESS7-113: Browser Caching. $manager->addHealthCheck( array( 'id' => 'browser-caching', @@ -122,6 +129,7 @@ public function addHealthChecks() { ) ); + // PRESS7-121: Object Caching. // Only show object caching health check for Bluehost brand. if ( 'bluehost' === $this->container->plugin()->brand ) { $manager->addHealthCheck( @@ -138,6 +146,7 @@ public function addHealthChecks() { ); } + // PRESS7-107: Cloudflare. $manager->addHealthCheck( array( 'id' => 'cloudflare-active', @@ -151,6 +160,7 @@ public function addHealthChecks() { ) ); + // PRESS7-119: Lazy Loading. $manager->addHealthCheck( array( 'id' => 'lazy-loading', @@ -165,6 +175,7 @@ public function addHealthChecks() { ) ); + // PRESS7-120: Link Prefetching. $manager->addHealthCheck( array( 'id' => 'link-prefetch', @@ -180,6 +191,7 @@ public function addHealthChecks() { ) ); + // PRESS7-114: Prioritize Critical CSS. $manager->addHealthCheck( array( 'id' => 'prioritize-critical-css', @@ -194,6 +206,7 @@ public function addHealthChecks() { ) ); + // PRESS7-115: Defer Non-Essential JavaScript. $manager->addHealthCheck( array( 'id' => 'defer-non-essential-javascript', @@ -208,6 +221,7 @@ public function addHealthChecks() { ) ); + // PRESS7-116: Concatenate JavaScript. $manager->addHealthCheck( array( 'id' => 'concatenate-js', @@ -222,6 +236,7 @@ public function addHealthChecks() { ) ); + // PRESS7-117: Concatenate CSS. $manager->addHealthCheck( array( 'id' => 'concatenate-css', From 63facc4d55238d9cf8bf8fbbb1e43bae6a679816 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Tue, 10 Dec 2024 13:21:47 -0600 Subject: [PATCH 06/24] Disabled checks for non-merged PRs --- includes/HealthChecks.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index e0b2708..e665826 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -160,6 +160,8 @@ public function addHealthChecks() { ) ); + /* // phpcs:ignore Squiz.PHP.CommentedOutCode + Enable when https://github.com/newfold-labs/wp-module-performance/pull/32 is merged. // PRESS7-119: Lazy Loading. $manager->addHealthCheck( array( @@ -174,7 +176,10 @@ public function addHealthChecks() { }, ) ); + */ + /* // phpcs:ignore Squiz.PHP.CommentedOutCode + Enable when https://github.com/newfold-labs/wp-module-performance/pull/26 is merged. // PRESS7-120: Link Prefetching. $manager->addHealthCheck( array( @@ -189,8 +194,10 @@ public function addHealthChecks() { return ( isset( $enabled['activeOnDesktop'] ) && $enabled['activeOnDesktop'] ); }, ) - ); + );*/ + /* // phpcs:ignore Squiz.PHP.CommentedOutCode + Enable when https://github.com/newfold-labs/wp-module-performance/pull/25 is merged. // PRESS7-114: Prioritize Critical CSS. $manager->addHealthCheck( array( @@ -249,6 +256,6 @@ public function addHealthChecks() { return ( ! empty( get_option( 'jetpack_boost_status_minify-css', array() ) ) ); }, ) - ); + );*/ } } From df09f81180cab56ce71f5f6ae2751e54004a91f5 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Tue, 10 Dec 2024 17:56:05 -0600 Subject: [PATCH 07/24] Update docblock --- includes/HealthCheckManager.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/includes/HealthCheckManager.php b/includes/HealthCheckManager.php index 53ac3d2..7dadf51 100644 --- a/includes/HealthCheckManager.php +++ b/includes/HealthCheckManager.php @@ -53,6 +53,22 @@ public function addHooks() { /** * Add a health check. * + * To add a health check, simply call this with the options you want to use. + * + * Example: + * + * $healthCheckManager->addHealthCheck( [ + * 'id' => 'example', + * 'title' => 'Example Health Check', + * 'pass' => 'This is the user-facing text for a passing health check', + * 'fail' => 'This is the user-facing text for a failing health check', + * 'text' => 'This is the user-facing description of the health check', + * 'badge_label' => 'Label', // Optional, defaults to 'Performance'. + * 'badge_color' => 'blue', // Optional, defaults to 'blue'. + * 'test' => function() { + * return true; // This is the test that will be run. and should return true or false for pass/fail. + * ] ); + * * @param array $options Health check options. */ public function addHealthCheck( $options ) { From b1fb76c7d2cc9f9c6f10f1ca169e7da468363761 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Tue, 10 Dec 2024 17:56:37 -0600 Subject: [PATCH 08/24] Update text --- includes/HealthChecks.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index e665826..88fac4e 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -36,8 +36,8 @@ public function addHealthChecks() { array( 'id' => 'autosave-interval', 'title' => __( 'Autosave Interval', 'newfold-performance-module' ), - 'pass' => __( 'Autosaving is set to happen every 30 seconds or more.', 'newfold-performance-module' ), - 'fail' => __( 'Autosaving is set to be frequent, less than every 30 seconds.', 'newfold-performance-module' ), + 'pass' => __( 'Autosaving is set to happen every 30 seconds or more', 'newfold-performance-module' ), + 'fail' => __( 'Autosaving is set to be frequent, less than every 30 seconds', 'newfold-performance-module' ), 'text' => __( 'Setting the autosave interval to a longer period can reduce server load, it is recommended to set it to 30 seconds or more.', 'newfold-performance-module' ), 'test' => function () { return ( defined( 'AUTOSAVE_INTERVAL' ) && AUTOSAVE_INTERVAL >= 30 ); @@ -134,12 +134,20 @@ public function addHealthChecks() { if ( 'bluehost' === $this->container->plugin()->brand ) { $manager->addHealthCheck( array( - 'id' => 'persistent_object_cache', // Replaces the default test. - 'title' => __( 'Object Caching', 'newfold-performance-module' ), - 'pass' => __( 'Object caching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Object caching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-performance-module' ), - 'test' => function () { + 'id' => 'persistent_object_cache', // Replaces the default test. + 'title' => __( 'Object Caching', 'newfold-performance-module' ), + 'pass' => __( 'Object caching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Object caching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-performance-module' ), + 'actions' => sprintf( + '%1$s%2$s', + __( 'Learn more about Bluehost Cloud Hosting.', 'newfold-performance-module' ), + sprintf( + ' (%s)', + __( 'opens in a new tab', 'newfold-performance-module' ) + ) + ), + 'test' => function () { return wp_using_ext_object_cache(); }, ) From 629d15be73e5c0773577f117b7a0df65567ea6b7 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Tue, 10 Dec 2024 21:11:46 -0600 Subject: [PATCH 09/24] Update text, remove extra PR links --- includes/HealthChecks.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index 88fac4e..d617d29 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -135,10 +135,10 @@ public function addHealthChecks() { $manager->addHealthCheck( array( 'id' => 'persistent_object_cache', // Replaces the default test. - 'title' => __( 'Object Caching', 'newfold-performance-module' ), - 'pass' => __( 'Object caching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Object caching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-performance-module' ), + 'title' => __( 'Object Caching', 'newfold-performance-module' ), + 'pass' => __( 'Object caching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Object caching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-performance-module' ), 'actions' => sprintf( '%1$s%2$s', __( 'Learn more about Bluehost Cloud Hosting.', 'newfold-performance-module' ), @@ -147,7 +147,7 @@ public function addHealthChecks() { __( 'opens in a new tab', 'newfold-performance-module' ) ) ), - 'test' => function () { + 'test' => function () { return wp_using_ext_object_cache(); }, ) @@ -197,7 +197,6 @@ public function addHealthChecks() { 'fail' => __( 'Link prefetching is disabled', 'newfold-performance-module' ), 'text' => __( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'newfold-performance-module' ), 'test' => function () { - https://github.com/newfold-labs/wp-module-performance/pull/26 $enabled = get_option( 'nfd_link_prefetch_settings', array() ); return ( isset( $enabled['activeOnDesktop'] ) && $enabled['activeOnDesktop'] ); }, @@ -215,7 +214,6 @@ public function addHealthChecks() { 'fail' => __( 'Critical CSS is not prioritized', 'newfold-performance-module' ), 'text' => __( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'newfold-performance-module' ), 'test' => function () { - https://github.com/newfold-labs/wp-module-performance/pull/25 return get_option( 'jetpack_boost_status_critical-css', false ); }, ) @@ -230,7 +228,6 @@ public function addHealthChecks() { 'fail' => __( 'Non-essential JavaScript is not deferred', 'newfold-performance-module' ), 'text' => __( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'newfold-performance-module' ), 'test' => function () { - https://github.com/newfold-labs/wp-module-performance/pull/25 return get_option( 'jetpack_boost_status_render-blocking-js', false ); }, ) @@ -245,7 +242,6 @@ public function addHealthChecks() { 'fail' => __( 'JavaScript files are not concatenated', 'newfold-performance-module' ), 'text' => __( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-performance-module' ), 'test' => function () { - https://github.com/newfold-labs/wp-module-performance/pull/25 return ( ! empty( get_option( 'jetpack_boost_status_minify-js', array() ) ) ); }, ) @@ -260,7 +256,6 @@ public function addHealthChecks() { 'fail' => __( 'CSS files are not concatenated', 'newfold-performance-module' ), 'text' => __( 'Concatenating CSS can improve performance by reducing the number of requests.', 'newfold-performance-module' ), 'test' => function () { - https://github.com/newfold-labs/wp-module-performance/pull/25 return ( ! empty( get_option( 'jetpack_boost_status_minify-css', array() ) ) ); }, ) From 0c27530175ceb5838fcdc5ad6513ff9c7664432a Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Wed, 11 Dec 2024 13:40:17 -0600 Subject: [PATCH 10/24] Update HealthCheckManager to allow passing an array of url, label, and external to build the links automatically. --- includes/HealthCheckManager.php | 57 ++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/includes/HealthCheckManager.php b/includes/HealthCheckManager.php index 7dadf51..5e65899 100644 --- a/includes/HealthCheckManager.php +++ b/includes/HealthCheckManager.php @@ -53,22 +53,6 @@ public function addHooks() { /** * Add a health check. * - * To add a health check, simply call this with the options you want to use. - * - * Example: - * - * $healthCheckManager->addHealthCheck( [ - * 'id' => 'example', - * 'title' => 'Example Health Check', - * 'pass' => 'This is the user-facing text for a passing health check', - * 'fail' => 'This is the user-facing text for a failing health check', - * 'text' => 'This is the user-facing description of the health check', - * 'badge_label' => 'Label', // Optional, defaults to 'Performance'. - * 'badge_color' => 'blue', // Optional, defaults to 'blue'. - * 'test' => function() { - * return true; // This is the test that will be run. and should return true or false for pass/fail. - * ] ); - * * @param array $options Health check options. */ public function addHealthCheck( $options ) { @@ -95,6 +79,41 @@ public function addHealthCheck( $options ) { } } + /** + * Concatenate actions array into a string. + * + * @param array $actions Actions to concatenate. Should contain an array of 'label', 'url', and 'external'. + * + * @return string Concatenated actions. + */ + public function concatActions( $actions ) { + $actions_string = ''; + + foreach ( $actions as $action ) { + $action = wp_parse_args( + $action, + array( + 'label' => '', + 'url' => '', + 'external' => false, + ) + ); + + $actions_string .= sprintf( + '%2$s%4$s', + esc_url( $action['url'] ), + esc_html( $action['label'] ), + $action['external'] ? 'target="_blank" rel="noopener"' : '', + $action['external'] ? sprintf( + ' (%s)', + __( 'opens in a new tab', 'newfold-performance-module' ) + ) : '' + ); + } + + return $actions_string; + } + /** * Run a health check. * @@ -111,9 +130,9 @@ public function runHealthCheck( $id ) { // Return the health check results. return array( 'label' => $check['label'] ? $check['label'] : ( $passed ? $check['pass'] : $check['fail'] ), - 'status' => $check['status'] ? $check['status'] : ( $passed ? 'good' : 'critical' ), - 'description' => $check['text'] ? $check['text'] : '', - 'actions' => $check['actions'] ? $check['actions'] : '', + 'status' => $passed ? 'good' : ( 'critical' === $check['status'] ? 'critical' : 'recommended' ), // Will default to 'recommended', unless 'critical' is passed. + 'description' => sprintf( '

%s

', $check['text'] ? $check['text'] : '' ), + 'actions' => is_array( $check['actions'] ) ? $this->concatActions( $check['actions'] ) : ( $check['actions'] ? $check['actions'] : '' ), 'test' => $check['id'], 'badge' => array( 'label' => $check['badge_label'], From 9871e74851ca49e58485bc9f126651ee649d51b2 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Wed, 11 Dec 2024 13:40:25 -0600 Subject: [PATCH 11/24] Update Health Checks with consistent punctuation, link directly to the settings --- includes/HealthChecks.php | 188 ++++++++++++++++++++++++++------------ 1 file changed, 128 insertions(+), 60 deletions(-) diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index d617d29..2c58a37 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -67,6 +67,13 @@ public function addHealthChecks() { 'pass' => __( 'Trash is emptied every 30 days or less', 'newfold-performance-module' ), 'fail' => __( 'Trash is emptied less frequently than every 30 days.', 'newfold-performance-module' ), 'text' => __( 'Emptying the trash more frequently can reduce database bloat.', 'newfold-performance-module' ), + 'actions' => array( + array( + 'label' => __( 'Configure trash settings.', 'newfold-performance-module' ), + 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=content-section#/performance' ), + 'external' => false, + ), + ), 'test' => function () { return ( defined( 'EMPTY_TRASH_DAYS' ) && EMPTY_TRASH_DAYS <= 30 ); }, @@ -95,6 +102,13 @@ public function addHealthChecks() { 'pass' => __( 'Permalinks are pretty', 'newfold-performance-module' ), 'fail' => __( 'Permalinks are not set up', 'newfold-performance-module' ), 'text' => __( 'Setting permalinks to anything other than plain can improve performance and SEO.', 'newfold-performance-module' ), + 'actions' => array( + array( + 'label' => __( 'Set up permalinks.', 'newfold-performance-module' ), + 'url' => admin_url( 'options-permalink.php' ), + 'external' => false, + ), + ), 'test' => function () { return empty( get_option( 'permalink_structure' ) ); }, @@ -104,11 +118,18 @@ public function addHealthChecks() { // PRESS7-112: Page Caching. $manager->addHealthCheck( array( - 'id' => 'page-caching', - 'title' => __( 'Page Caching', 'newfold-performance-module' ), - 'pass' => __( 'Page caching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Page caching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Page caching can improve performance by bypassing PHP and database queries for faster page loads.', 'newfold-performance-module' ), + 'id' => 'page-caching', + 'title' => __( 'Page Caching', 'newfold-performance-module' ), + 'pass' => __( 'Page caching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Page caching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Page caching can improve performance by bypassing PHP and database queries for faster page loads.', 'newfold-performance-module' ), + 'actions' => array( + array( + 'label' => __( 'Configure caching.', 'newfold-performance-module' ), + 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=cache-type#/performance' ), + 'external' => false, + ), + ), 'test' => function () { return ( get_option( 'newfold_cache_level' ) >= 2 ); }, @@ -118,12 +139,19 @@ public function addHealthChecks() { // PRESS7-113: Browser Caching. $manager->addHealthCheck( array( - 'id' => 'browser-caching', - 'title' => __( 'Browser Caching', 'newfold-performance-module' ), - 'pass' => __( 'Browser caching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Browser caching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Enabling browser caching can improve performance by storing static assets in the browser for faster page loads.', 'newfold-performance-module' ), - 'test' => function () { + 'id' => 'browser-caching', + 'title' => __( 'Browser Caching', 'newfold-performance-module' ), + 'pass' => __( 'Browser caching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Browser caching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Enabling browser caching can improve performance by storing static assets in the browser for faster page loads.', 'newfold-performance-module' ), + 'actions' => array( + array( + 'label' => __( 'Configure caching.', 'newfold-performance-module' ), + 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=cache-type#/performance' ), + 'external' => false, + ), + ), + 'test' => function () { return ( get_option( 'newfold_cache_level' ) >= 1 ); }, ) @@ -135,19 +163,18 @@ public function addHealthChecks() { $manager->addHealthCheck( array( 'id' => 'persistent_object_cache', // Replaces the default test. - 'title' => __( 'Object Caching', 'newfold-performance-module' ), - 'pass' => __( 'Object caching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Object caching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-performance-module' ), - 'actions' => sprintf( - '%1$s%2$s', - __( 'Learn more about Bluehost Cloud Hosting.', 'newfold-performance-module' ), - sprintf( - ' (%s)', - __( 'opens in a new tab', 'newfold-performance-module' ) - ) + 'title' => __( 'Object Caching', 'newfold-performance-module' ), + 'pass' => __( 'Object caching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Object caching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-performance-module' ), + 'actions' => array( + array( + 'label' => __( 'Learn more about Bluehost Cloud Hosting.', 'newfold-performance-module' ), + 'url' => 'https://www.bluehost.com/hosting/cloud', + 'external' => true, + ), ), - 'test' => function () { + 'test' => function () { return wp_using_ext_object_cache(); }, ) @@ -169,50 +196,70 @@ public function addHealthChecks() { ); /* // phpcs:ignore Squiz.PHP.CommentedOutCode - Enable when https://github.com/newfold-labs/wp-module-performance/pull/32 is merged. + // Enable when https://github.com/newfold-labs/wp-module-performance/pull/32 is merged. // PRESS7-119: Lazy Loading. $manager->addHealthCheck( array( - 'id' => 'lazy-loading', - 'title' => __( 'Lazy Loading', 'newfold-performance-module' ), - 'pass' => __( 'Lazy loading is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Lazy loading is disabled', 'newfold-performance-module' ), - 'text' => __( 'Lazy loading can improve performance by only loading images when they are in view.', 'newfold-performance-module' ), + 'id' => 'lazy-loading', + 'title' => __( 'Lazy Loading', 'newfold-performance-module' ), + 'pass' => __( 'Lazy loading is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Lazy loading is disabled', 'newfold-performance-module' ), + 'text' => __( 'Lazy loading can improve performance by only loading images when they are in view.', 'newfold-performance-module' ), + 'actions' => array( + array( + 'label' => __( 'Configure lazy loading.', 'newfold-performance-module' ), + 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=lazy-loading-enabled#/performance' ), + 'external' => false, + ), + ), 'test' => function () { $enabled = get_option( 'nfd_image_optimization', array() ); return ( isset( $enabled['lazy_loading'], $enabled['lazy_loading']['enabled'] ) && $enabled['lazy_loading']['enabled'] ); }, ) - ); - */ + ); */ /* // phpcs:ignore Squiz.PHP.CommentedOutCode - Enable when https://github.com/newfold-labs/wp-module-performance/pull/26 is merged. + // Enable when https://github.com/newfold-labs/wp-module-performance/pull/26 is merged. // PRESS7-120: Link Prefetching. $manager->addHealthCheck( array( - 'id' => 'link-prefetch', - 'title' => __( 'Link Prefetching', 'newfold-performance-module' ), - 'pass' => __( 'Link prefetching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Link prefetching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'newfold-performance-module' ), + 'id' => 'link-prefetch', + 'title' => __( 'Link Prefetching', 'newfold-performance-module' ), + 'pass' => __( 'Link prefetching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Link prefetching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'newfold-performance-module' ), + 'actions' => array( + array( + 'label' => __( 'Configure Link prefetching.', 'newfold-performance-module' ), + 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=link-prefetch-behavior#/performance' ), + 'external' => false, + ), + ), 'test' => function () { $enabled = get_option( 'nfd_link_prefetch_settings', array() ); return ( isset( $enabled['activeOnDesktop'] ) && $enabled['activeOnDesktop'] ); }, ) - );*/ + ); */ /* // phpcs:ignore Squiz.PHP.CommentedOutCode - Enable when https://github.com/newfold-labs/wp-module-performance/pull/25 is merged. + // Enable when https://github.com/newfold-labs/wp-module-performance/pull/25 is merged. // PRESS7-114: Prioritize Critical CSS. $manager->addHealthCheck( array( - 'id' => 'prioritize-critical-css', - 'title' => __( 'Prioritize Critical CSS', 'newfold-performance-module' ), - 'pass' => __( 'Critical CSS is prioritized', 'newfold-performance-module' ), - 'fail' => __( 'Critical CSS is not prioritized', 'newfold-performance-module' ), - 'text' => __( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'newfold-performance-module' ), + 'id' => 'prioritize-critical-css', + 'title' => __( 'Prioritize Critical CSS', 'newfold-performance-module' ), + 'pass' => __( 'Critical CSS is prioritized', 'newfold-performance-module' ), + 'fail' => __( 'Critical CSS is not prioritized', 'newfold-performance-module' ), + 'text' => __( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'newfold-performance-module' ), + 'actions' => array( + array( + 'label' => __( 'Configure Critical CSS.', 'newfold-performance-module' ), + 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=critical-css#/performance' ), + 'external' => false, + ), + ), 'test' => function () { return get_option( 'jetpack_boost_status_critical-css', false ); }, @@ -222,11 +269,18 @@ public function addHealthChecks() { // PRESS7-115: Defer Non-Essential JavaScript. $manager->addHealthCheck( array( - 'id' => 'defer-non-essential-javascript', - 'title' => __( 'Defer Non-Essential JavaScript', 'newfold-performance-module' ), - 'pass' => __( 'Non-essential JavaScript is deferred', 'newfold-performance-module' ), - 'fail' => __( 'Non-essential JavaScript is not deferred', 'newfold-performance-module' ), - 'text' => __( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'newfold-performance-module' ), + 'id' => 'defer-non-essential-javascript', + 'title' => __( 'Defer Non-Essential JavaScript', 'newfold-performance-module' ), + 'pass' => __( 'Non-essential JavaScript is deferred', 'newfold-performance-module' ), + 'fail' => __( 'Non-essential JavaScript is not deferred', 'newfold-performance-module' ), + 'text' => __( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'newfold-performance-module' ), + 'actions' => array( + array( + 'label' => __( 'Configure JavaScript deferral.', 'newfold-performance-module' ), + 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=render-blocking-js#/performance' ), + 'external' => false, + ), + ), 'test' => function () { return get_option( 'jetpack_boost_status_render-blocking-js', false ); }, @@ -236,11 +290,18 @@ public function addHealthChecks() { // PRESS7-116: Concatenate JavaScript. $manager->addHealthCheck( array( - 'id' => 'concatenate-js', - 'title' => __( 'Concatenate JavaScript', 'newfold-performance-module' ), - 'pass' => __( 'JavaScript files are concatenated', 'newfold-performance-module' ), - 'fail' => __( 'JavaScript files are not concatenated', 'newfold-performance-module' ), - 'text' => __( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-performance-module' ), + 'id' => 'concatenate-js', + 'title' => __( 'Concatenate JavaScript', 'newfold-performance-module' ), + 'pass' => __( 'JavaScript files are concatenated', 'newfold-performance-module' ), + 'fail' => __( 'JavaScript files are not concatenated', 'newfold-performance-module' ), + 'text' => __( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-performance-module' ), + 'actions' => array( + array( + 'label' => __( 'Configure JavaScript deferral.', 'newfold-performance-module' ), + 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=minify-js#/performance' ), + 'external' => false, + ), + ), 'test' => function () { return ( ! empty( get_option( 'jetpack_boost_status_minify-js', array() ) ) ); }, @@ -250,15 +311,22 @@ public function addHealthChecks() { // PRESS7-117: Concatenate CSS. $manager->addHealthCheck( array( - 'id' => 'concatenate-css', - 'title' => __( 'Concatenate CSS', 'newfold-performance-module' ), - 'pass' => __( 'CSS files are concatenated', 'newfold-performance-module' ), - 'fail' => __( 'CSS files are not concatenated', 'newfold-performance-module' ), - 'text' => __( 'Concatenating CSS can improve performance by reducing the number of requests.', 'newfold-performance-module' ), + 'id' => 'concatenate-css', + 'title' => __( 'Concatenate CSS', 'newfold-performance-module' ), + 'pass' => __( 'CSS files are concatenated', 'newfold-performance-module' ), + 'fail' => __( 'CSS files are not concatenated', 'newfold-performance-module' ), + 'text' => __( 'Concatenating CSS can improve performance by reducing the number of requests.', 'newfold-performance-module' ), + 'actions' => array( + array( + 'label' => __( 'Configure JavaScript deferral.', 'newfold-performance-module' ), + 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=minify-csss#/performance' ), + 'external' => false, + ), + ), 'test' => function () { return ( ! empty( get_option( 'jetpack_boost_status_minify-css', array() ) ) ); }, ) - );*/ + ); */ } } From 9c1ce1bddd72502d717c45ee291b0dc759c75d0f Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Tue, 7 Jan 2025 20:07:16 -0600 Subject: [PATCH 12/24] Update Health Checks with consistent punctuation, link directly to the settings --- includes/HealthCheckManager.php | 53 +++++---- includes/HealthChecks.php | 185 ++++++++++++++++---------------- 2 files changed, 120 insertions(+), 118 deletions(-) diff --git a/includes/HealthCheckManager.php b/includes/HealthCheckManager.php index 5e65899..cfc864f 100644 --- a/includes/HealthCheckManager.php +++ b/includes/HealthCheckManager.php @@ -23,40 +23,43 @@ class HealthCheckManager { */ public $prefix = 'newfold_performance_'; - /** - * Dependency injection container. - * - * @var Container - */ - protected $container; - /** * Constructor. - * - * @param Container $container Dependency injection container. */ - public function __construct( Container $container ) { - $this->container = $container; - + public function __construct() { if ( function_exists( 'add_filter' ) ) { - $this->addHooks(); + $this->add_hooks(); } } /** * Add hooks. */ - public function addHooks() { - add_filter( 'site_status_tests', array( $this, 'registerHealthChecks' ) ); + public function add_hooks() { + add_filter( 'site_status_tests', array( $this, 'register_health_checks' ) ); } /** * Add a health check. * + * The options array can contain the following keys: + * - id: A unique identifier for the health check. + * - title: The title of the health check. + * - test: A callable function that will run the health check and return a boolean. + * - label: Optional. If set, it will display both for passed and failed. (User-facing text.) + * - pass: The label to display when the health check passes. (User-facing text.) + * - fail: The label to display when the health check fails. (User-facing text.) + * - text: Optional. Additional text to display below the health check results. (User-facing text.) + * - status: Optional. Used to override the status of the health check. Default is 'good' for pass, 'critical' for fail. + * - badge_label: Optional. The label to display on the badge. (User-facing text.) Default is 'Performance'. + * - badge_color: Optional. The color of the badge. Default is 'blue'. + * - actions: Optional. An array of actions to display below the health check results. Each action should contain a 'label' string, a 'url' string, and a 'external' boolean. + * * @param array $options Health check options. */ - public function addHealthCheck( $options ) { - $options = wp_parse_args( + public function add_health_check( $options ) { + $options = /* Explain keys and their impact */ + wp_parse_args( $options, array( 'id' => '', @@ -82,11 +85,15 @@ public function addHealthCheck( $options ) { /** * Concatenate actions array into a string. * + * Label, URL, and external are the keys that should be present in the actions array. The label is the text that is + * display as the link, the URL is the link that the label will point to, and external is a boolean that determines + * whether the link should show the external icon. + * * @param array $actions Actions to concatenate. Should contain an array of 'label', 'url', and 'external'. * * @return string Concatenated actions. */ - public function concatActions( $actions ) { + public function concat_actions_text_and_link( $actions ) { $actions_string = ''; foreach ( $actions as $action ) { @@ -106,7 +113,7 @@ public function concatActions( $actions ) { $action['external'] ? 'target="_blank" rel="noopener"' : '', $action['external'] ? sprintf( ' (%s)', - __( 'opens in a new tab', 'newfold-performance-module' ) + __( 'opens in a new tab', 'newfold-module-performance' ) ) : '' ); } @@ -121,7 +128,7 @@ public function concatActions( $actions ) { * * @return array Health check results. */ - public function runHealthCheck( $id ) { + public function run_health_check( $id ) { $check = $this->checks[ $id ]; // Execute the test. @@ -132,7 +139,7 @@ public function runHealthCheck( $id ) { 'label' => $check['label'] ? $check['label'] : ( $passed ? $check['pass'] : $check['fail'] ), 'status' => $passed ? 'good' : ( 'critical' === $check['status'] ? 'critical' : 'recommended' ), // Will default to 'recommended', unless 'critical' is passed. 'description' => sprintf( '

%s

', $check['text'] ? $check['text'] : '' ), - 'actions' => is_array( $check['actions'] ) ? $this->concatActions( $check['actions'] ) : ( $check['actions'] ? $check['actions'] : '' ), + 'actions' => is_array( $check['actions'] ) ? $this->concat_actions_text_and_link( $check['actions'] ) : ( $check['actions'] ? $check['actions'] : '' ), 'test' => $check['id'], 'badge' => array( 'label' => $check['badge_label'], @@ -148,7 +155,7 @@ public function runHealthCheck( $id ) { * * @return array Site Health tests. */ - public function registerHealthChecks( $tests ) { + public function register_health_checks( $tests ) { // If there are no health checks, don't add any. if ( ! is_array( $this->checks ) || empty( $this->checks ) ) { return $tests; @@ -165,7 +172,7 @@ public function registerHealthChecks( $tests ) { $tests['direct'][ $id ] = array( 'label' => $check['title'], 'test' => function () use ( $id ) { - return $this->runHealthCheck( $id ); + return $this->run_health_check( $id ); }, ); } diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index 2c58a37..18dfa3e 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -28,17 +28,17 @@ public function __construct( Container $container ) { /** * Add health checks. */ - public function addHealthChecks() { + public function add_health_checks() { $manager = $this->container->get( 'healthCheckManager' ); // PRESS7-108: Autosave Interval. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'autosave-interval', - 'title' => __( 'Autosave Interval', 'newfold-performance-module' ), - 'pass' => __( 'Autosaving is set to happen every 30 seconds or more', 'newfold-performance-module' ), - 'fail' => __( 'Autosaving is set to be frequent, less than every 30 seconds', 'newfold-performance-module' ), - 'text' => __( 'Setting the autosave interval to a longer period can reduce server load, it is recommended to set it to 30 seconds or more.', 'newfold-performance-module' ), + 'title' => __( 'Autosave Interval', 'newfold-module-performance' ), + 'pass' => __( 'Autosaving is set to happen every 30 seconds or more', 'newfold-module-performance' ), + 'fail' => __( 'Autosaving is set to be frequent, less than every 30 seconds', 'newfold-module-performance' ), + 'text' => __( 'Setting the autosave interval to a longer period can reduce server load, it is recommended to set it to 30 seconds or more.', 'newfold-module-performance' ), 'test' => function () { return ( defined( 'AUTOSAVE_INTERVAL' ) && AUTOSAVE_INTERVAL >= 30 ); }, @@ -46,13 +46,13 @@ public function addHealthChecks() { ); // PRESS7-109: Post Revisions. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'post-revisions', - 'title' => __( 'Post Revisions', 'newfold-performance-module' ), - 'pass' => __( 'Number of post revisions is limited to 5 or less', 'newfold-performance-module' ), - 'fail' => __( 'Number of post revisions is set to a high number', 'newfold-performance-module' ), - 'text' => __( 'Setting the number of post revisions to a lower number can reduce database bloat.', 'newfold-performance-module' ), + 'title' => __( 'Post Revisions', 'newfold-module-performance' ), + 'pass' => __( 'Number of post revisions is limited to 5 or less', 'newfold-module-performance' ), + 'fail' => __( 'Number of post revisions is set to a high number', 'newfold-module-performance' ), + 'text' => __( 'Setting the number of post revisions to a lower number can reduce database bloat.', 'newfold-module-performance' ), 'test' => function () { return ( defined( 'WP_POST_REVISIONS' ) && WP_POST_REVISIONS <= 5 ); }, @@ -60,16 +60,16 @@ public function addHealthChecks() { ); // PRESS7-110: Empty Trash Days. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'empty-trash-days', - 'title' => __( 'Empty Trash Days', 'newfold-performance-module' ), - 'pass' => __( 'Trash is emptied every 30 days or less', 'newfold-performance-module' ), - 'fail' => __( 'Trash is emptied less frequently than every 30 days.', 'newfold-performance-module' ), - 'text' => __( 'Emptying the trash more frequently can reduce database bloat.', 'newfold-performance-module' ), + 'title' => __( 'Empty Trash Days', 'newfold-module-performance' ), + 'pass' => __( 'Trash is emptied every 30 days or less', 'newfold-module-performance' ), + 'fail' => __( 'Trash is emptied less frequently than every 30 days', 'newfold-module-performance' ), + 'text' => __( 'Emptying the trash more frequently can reduce database bloat.', 'newfold-module-performance' ), 'actions' => array( array( - 'label' => __( 'Configure trash settings.', 'newfold-performance-module' ), + 'label' => __( 'Configure trash settings.', 'newfold-module-performance' ), 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=content-section#/performance' ), 'external' => false, ), @@ -81,13 +81,13 @@ public function addHealthChecks() { ); // PRESS7-111: Cron Lock Timeout. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'wp-cron-lock-timeout', - 'title' => __( 'WP Cron Lock Timeout', 'newfold-performance-module' ), - 'pass' => __( 'Cron lock timeout is set to 60 seconds or less.', 'newfold-performance-module' ), - 'fail' => __( 'Cron lock timeout is set to a high number.', 'newfold-performance-module' ), - 'text' => __( 'Cron lock timeout affects how long a cron job can run for, setting it to a lower number can improve performance.', 'newfold-performance-module' ), + 'title' => __( 'WP Cron Lock Timeout', 'newfold-module-performance' ), + 'pass' => __( 'Cron lock timeout is set to 60 seconds or less', 'newfold-module-performance' ), + 'fail' => __( 'Cron lock timeout is set to a high number', 'newfold-module-performance' ), + 'text' => __( 'Cron lock timeout affects how long a cron job can run for, setting it to a lower number can improve performance.', 'newfold-module-performance' ), 'test' => function () { return ( defined( 'WP_CRON_LOCK_TIMEOUT' ) && WP_CRON_LOCK_TIMEOUT <= 300 ); }, @@ -95,16 +95,16 @@ public function addHealthChecks() { ); // PRESS7-118: Permalinks. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'permalinks', - 'title' => __( 'Permalinks', 'newfold-performance-module' ), - 'pass' => __( 'Permalinks are pretty', 'newfold-performance-module' ), - 'fail' => __( 'Permalinks are not set up', 'newfold-performance-module' ), - 'text' => __( 'Setting permalinks to anything other than plain can improve performance and SEO.', 'newfold-performance-module' ), + 'title' => __( 'Permalinks', 'newfold-module-performance' ), + 'pass' => __( 'Permalinks are pretty', 'newfold-module-performance' ), + 'fail' => __( 'Permalinks are not set up', 'newfold-module-performance' ), + 'text' => __( 'Setting permalinks to anything other than plain can improve performance and SEO.', 'newfold-module-performance' ), 'actions' => array( array( - 'label' => __( 'Set up permalinks.', 'newfold-performance-module' ), + 'label' => __( 'Set up permalinks.', 'newfold-module-performance' ), 'url' => admin_url( 'options-permalink.php' ), 'external' => false, ), @@ -116,16 +116,16 @@ public function addHealthChecks() { ); // PRESS7-112: Page Caching. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'page-caching', - 'title' => __( 'Page Caching', 'newfold-performance-module' ), - 'pass' => __( 'Page caching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Page caching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Page caching can improve performance by bypassing PHP and database queries for faster page loads.', 'newfold-performance-module' ), + 'title' => __( 'Page Caching', 'newfold-module-performance' ), + 'pass' => __( 'Page caching is enabled', 'newfold-module-performance' ), + 'fail' => __( 'Page caching is disabled', 'newfold-module-performance' ), + 'text' => __( 'Page caching can improve performance by bypassing PHP and database queries for faster page loads.', 'newfold-module-performance' ), 'actions' => array( array( - 'label' => __( 'Configure caching.', 'newfold-performance-module' ), + 'label' => __( 'Configure caching.', 'newfold-module-performance' ), 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=cache-type#/performance' ), 'external' => false, ), @@ -137,16 +137,16 @@ public function addHealthChecks() { ); // PRESS7-113: Browser Caching. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'browser-caching', - 'title' => __( 'Browser Caching', 'newfold-performance-module' ), - 'pass' => __( 'Browser caching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Browser caching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Enabling browser caching can improve performance by storing static assets in the browser for faster page loads.', 'newfold-performance-module' ), + 'title' => __( 'Browser Caching', 'newfold-module-performance' ), + 'pass' => __( 'Browser caching is enabled', 'newfold-module-performance' ), + 'fail' => __( 'Browser caching is disabled', 'newfold-module-performance' ), + 'text' => __( 'Enabling browser caching can improve performance by storing static assets in the browser for faster page loads.', 'newfold-module-performance' ), 'actions' => array( array( - 'label' => __( 'Configure caching.', 'newfold-performance-module' ), + 'label' => __( 'Configure caching.', 'newfold-module-performance' ), 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=cache-type#/performance' ), 'external' => false, ), @@ -160,16 +160,16 @@ public function addHealthChecks() { // PRESS7-121: Object Caching. // Only show object caching health check for Bluehost brand. if ( 'bluehost' === $this->container->plugin()->brand ) { - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'persistent_object_cache', // Replaces the default test. - 'title' => __( 'Object Caching', 'newfold-performance-module' ), - 'pass' => __( 'Object caching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Object caching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-performance-module' ), + 'title' => __( 'Object Caching', 'newfold-module-performance' ), + 'pass' => __( 'Object caching is enabled', 'newfold-module-performance' ), + 'fail' => __( 'Object caching is disabled', 'newfold-module-performance' ), + 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-module-performance' ), 'actions' => array( array( - 'label' => __( 'Learn more about Bluehost Cloud Hosting.', 'newfold-performance-module' ), + 'label' => __( 'Learn more about Bluehost Cloud Hosting.', 'newfold-module-performance' ), 'url' => 'https://www.bluehost.com/hosting/cloud', 'external' => true, ), @@ -182,32 +182,31 @@ public function addHealthChecks() { } // PRESS7-107: Cloudflare. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'cloudflare-active', - 'title' => __( 'Cloudflare enabled', 'newfold-performance-module' ), - 'pass' => __( 'Cloudflare integration is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Cloudflare integration is disabled', 'newfold-performance-module' ), - 'text' => __( 'Cloudflare integration can improve performance and security.', 'newfold-performance-module' ), + 'title' => __( 'Cloudflare enabled', 'newfold-module-performance' ), + 'pass' => __( 'Cloudflare integration is enabled', 'newfold-module-performance' ), + 'fail' => __( 'Cloudflare integration is disabled', 'newfold-module-performance' ), + 'text' => __( 'Cloudflare integration can improve performance and security.', 'newfold-module-performance' ), 'test' => function () { return isset( $_SERVER['HTTP_CF_RAY'] ); }, ) ); - /* // phpcs:ignore Squiz.PHP.CommentedOutCode // Enable when https://github.com/newfold-labs/wp-module-performance/pull/32 is merged. // PRESS7-119: Lazy Loading. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'lazy-loading', - 'title' => __( 'Lazy Loading', 'newfold-performance-module' ), - 'pass' => __( 'Lazy loading is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Lazy loading is disabled', 'newfold-performance-module' ), - 'text' => __( 'Lazy loading can improve performance by only loading images when they are in view.', 'newfold-performance-module' ), + 'title' => __( 'Lazy Loading', 'newfold-module-performance' ), + 'pass' => __( 'Lazy loading is enabled', 'newfold-module-performance' ), + 'fail' => __( 'Lazy loading is disabled', 'newfold-module-performance' ), + 'text' => __( 'Lazy loading can improve performance by only loading images when they are in view.', 'newfold-module-performance' ), 'actions' => array( array( - 'label' => __( 'Configure lazy loading.', 'newfold-performance-module' ), + 'label' => __( 'Configure lazy loading.', 'newfold-module-performance' ), 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=lazy-loading-enabled#/performance' ), 'external' => false, ), @@ -217,21 +216,19 @@ public function addHealthChecks() { return ( isset( $enabled['lazy_loading'], $enabled['lazy_loading']['enabled'] ) && $enabled['lazy_loading']['enabled'] ); }, ) - ); */ + ); - /* // phpcs:ignore Squiz.PHP.CommentedOutCode - // Enable when https://github.com/newfold-labs/wp-module-performance/pull/26 is merged. // PRESS7-120: Link Prefetching. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'link-prefetch', - 'title' => __( 'Link Prefetching', 'newfold-performance-module' ), - 'pass' => __( 'Link prefetching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Link prefetching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'newfold-performance-module' ), + 'title' => __( 'Link Prefetching', 'newfold-module-performance' ), + 'pass' => __( 'Link prefetching is enabled', 'newfold-module-performance' ), + 'fail' => __( 'Link prefetching is disabled', 'newfold-module-performance' ), + 'text' => __( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'newfold-module-performance' ), 'actions' => array( array( - 'label' => __( 'Configure Link prefetching.', 'newfold-performance-module' ), + 'label' => __( 'Configure Link prefetching.', 'newfold-module-performance' ), 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=link-prefetch-behavior#/performance' ), 'external' => false, ), @@ -241,21 +238,19 @@ public function addHealthChecks() { return ( isset( $enabled['activeOnDesktop'] ) && $enabled['activeOnDesktop'] ); }, ) - ); */ + ); - /* // phpcs:ignore Squiz.PHP.CommentedOutCode - // Enable when https://github.com/newfold-labs/wp-module-performance/pull/25 is merged. // PRESS7-114: Prioritize Critical CSS. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'prioritize-critical-css', - 'title' => __( 'Prioritize Critical CSS', 'newfold-performance-module' ), - 'pass' => __( 'Critical CSS is prioritized', 'newfold-performance-module' ), - 'fail' => __( 'Critical CSS is not prioritized', 'newfold-performance-module' ), - 'text' => __( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'newfold-performance-module' ), + 'title' => __( 'Prioritize Critical CSS', 'newfold-module-performance' ), + 'pass' => __( 'Critical CSS is prioritized', 'newfold-module-performance' ), + 'fail' => __( 'Critical CSS is not prioritized', 'newfold-module-performance' ), + 'text' => __( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'newfold-module-performance' ), 'actions' => array( array( - 'label' => __( 'Configure Critical CSS.', 'newfold-performance-module' ), + 'label' => __( 'Configure Critical CSS.', 'newfold-module-performance' ), 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=critical-css#/performance' ), 'external' => false, ), @@ -267,16 +262,16 @@ public function addHealthChecks() { ); // PRESS7-115: Defer Non-Essential JavaScript. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'defer-non-essential-javascript', - 'title' => __( 'Defer Non-Essential JavaScript', 'newfold-performance-module' ), - 'pass' => __( 'Non-essential JavaScript is deferred', 'newfold-performance-module' ), - 'fail' => __( 'Non-essential JavaScript is not deferred', 'newfold-performance-module' ), - 'text' => __( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'newfold-performance-module' ), + 'title' => __( 'Defer Non-Essential JavaScript', 'newfold-module-performance' ), + 'pass' => __( 'Non-essential JavaScript is deferred', 'newfold-module-performance' ), + 'fail' => __( 'Non-essential JavaScript is not deferred', 'newfold-module-performance' ), + 'text' => __( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'newfold-module-performance' ), 'actions' => array( array( - 'label' => __( 'Configure JavaScript deferral.', 'newfold-performance-module' ), + 'label' => __( 'Configure JavaScript deferral.', 'newfold-module-performance' ), 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=render-blocking-js#/performance' ), 'external' => false, ), @@ -288,16 +283,16 @@ public function addHealthChecks() { ); // PRESS7-116: Concatenate JavaScript. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'concatenate-js', - 'title' => __( 'Concatenate JavaScript', 'newfold-performance-module' ), - 'pass' => __( 'JavaScript files are concatenated', 'newfold-performance-module' ), - 'fail' => __( 'JavaScript files are not concatenated', 'newfold-performance-module' ), - 'text' => __( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-performance-module' ), + 'title' => __( 'Concatenate JavaScript', 'newfold-module-performance' ), + 'pass' => __( 'JavaScript files are concatenated', 'newfold-module-performance' ), + 'fail' => __( 'JavaScript files are not concatenated', 'newfold-module-performance' ), + 'text' => __( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-module-performance' ), 'actions' => array( array( - 'label' => __( 'Configure JavaScript deferral.', 'newfold-performance-module' ), + 'label' => __( 'Configure JavaScript deferral.', 'newfold-module-performance' ), 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=minify-js#/performance' ), 'external' => false, ), @@ -309,16 +304,16 @@ public function addHealthChecks() { ); // PRESS7-117: Concatenate CSS. - $manager->addHealthCheck( + $manager->add_health_check( array( 'id' => 'concatenate-css', - 'title' => __( 'Concatenate CSS', 'newfold-performance-module' ), - 'pass' => __( 'CSS files are concatenated', 'newfold-performance-module' ), - 'fail' => __( 'CSS files are not concatenated', 'newfold-performance-module' ), - 'text' => __( 'Concatenating CSS can improve performance by reducing the number of requests.', 'newfold-performance-module' ), + 'title' => __( 'Concatenate CSS', 'newfold-module-performance' ), + 'pass' => __( 'CSS files are concatenated', 'newfold-module-performance' ), + 'fail' => __( 'CSS files are not concatenated', 'newfold-module-performance' ), + 'text' => __( 'Concatenating CSS can improve performance by reducing the number of requests.', 'newfold-module-performance' ), 'actions' => array( array( - 'label' => __( 'Configure JavaScript deferral.', 'newfold-performance-module' ), + 'label' => __( 'Configure JavaScript deferral.', 'newfold-module-performance' ), 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=minify-csss#/performance' ), 'external' => false, ), @@ -327,6 +322,6 @@ public function addHealthChecks() { return ( ! empty( get_option( 'jetpack_boost_status_minify-css', array() ) ) ); }, ) - ); */ + ); } } From 04fea843a077bbf47a4aed0118414d5bb3b3ed3b Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Thu, 23 Jan 2025 01:25:36 -0600 Subject: [PATCH 13/24] Update Performance.php --- includes/Performance.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/Performance.php b/includes/Performance.php index 24545c8..3748d6a 100644 --- a/includes/Performance.php +++ b/includes/Performance.php @@ -70,10 +70,10 @@ public function __construct( Container $container ) { $this->hooks( $container ); - $cacheManager = new CacheManager( $container ); - $cachePurger = new CachePurgingService( $cacheManager->getInstances() ); + $cacheManager = new CacheManager( $container ); + $cachePurger = new CachePurgingService( $cacheManager->getInstances() ); $healthCheckManager = new HealthCheckManager( $container ); - $healthChecks = new HealthChecks( $container ); + $healthChecks = new HealthChecks( $container ); // Ensure that purgeable cache types are enabled before showing the UI. if ( $cachePurger->canPurge() ) { From 8dda913d675650ef3e6c9fc45118157a74b45cb0 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Thu, 23 Jan 2025 01:27:23 -0600 Subject: [PATCH 14/24] Update HealthCheckManager.php --- includes/HealthCheckManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/HealthCheckManager.php b/includes/HealthCheckManager.php index cfc864f..dd15a8a 100644 --- a/includes/HealthCheckManager.php +++ b/includes/HealthCheckManager.php @@ -59,7 +59,7 @@ public function add_hooks() { */ public function add_health_check( $options ) { $options = /* Explain keys and their impact */ - wp_parse_args( + wp_parse_args( $options, array( 'id' => '', From 5f381b886cfe591b83dec40e1ee8440232f86e1b Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Thu, 23 Jan 2025 01:27:59 -0600 Subject: [PATCH 15/24] Update HealthCheckManager.php --- includes/HealthCheckManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/HealthCheckManager.php b/includes/HealthCheckManager.php index dd15a8a..c28c554 100644 --- a/includes/HealthCheckManager.php +++ b/includes/HealthCheckManager.php @@ -94,7 +94,7 @@ public function add_health_check( $options ) { * @return string Concatenated actions. */ public function concat_actions_text_and_link( $actions ) { - $actions_string = ''; + $actions_string = ''; foreach ( $actions as $action ) { $action = wp_parse_args( @@ -118,7 +118,7 @@ public function concat_actions_text_and_link( $actions ) { ); } - return $actions_string; + return $actions_string; } /** From 501075672ca5e493ec13cedc4fe93a228bbca1c5 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Thu, 23 Jan 2025 01:30:12 -0600 Subject: [PATCH 16/24] Update HealthChecks.php --- includes/HealthChecks.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index 18dfa3e..de87ef1 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -62,11 +62,11 @@ public function add_health_checks() { // PRESS7-110: Empty Trash Days. $manager->add_health_check( array( - 'id' => 'empty-trash-days', - 'title' => __( 'Empty Trash Days', 'newfold-module-performance' ), - 'pass' => __( 'Trash is emptied every 30 days or less', 'newfold-module-performance' ), - 'fail' => __( 'Trash is emptied less frequently than every 30 days', 'newfold-module-performance' ), - 'text' => __( 'Emptying the trash more frequently can reduce database bloat.', 'newfold-module-performance' ), + 'id' => 'empty-trash-days', + 'title' => __( 'Empty Trash Days', 'newfold-module-performance' ), + 'pass' => __( 'Trash is emptied every 30 days or less', 'newfold-module-performance' ), + 'fail' => __( 'Trash is emptied less frequently than every 30 days', 'newfold-module-performance' ), + 'text' => __( 'Emptying the trash more frequently can reduce database bloat.', 'newfold-module-performance' ), 'actions' => array( array( 'label' => __( 'Configure trash settings.', 'newfold-module-performance' ), @@ -74,7 +74,7 @@ public function add_health_checks() { 'external' => false, ), ), - 'test' => function () { + 'test' => function () { return ( defined( 'EMPTY_TRASH_DAYS' ) && EMPTY_TRASH_DAYS <= 30 ); }, ) @@ -97,11 +97,11 @@ public function add_health_checks() { // PRESS7-118: Permalinks. $manager->add_health_check( array( - 'id' => 'permalinks', - 'title' => __( 'Permalinks', 'newfold-module-performance' ), - 'pass' => __( 'Permalinks are pretty', 'newfold-module-performance' ), - 'fail' => __( 'Permalinks are not set up', 'newfold-module-performance' ), - 'text' => __( 'Setting permalinks to anything other than plain can improve performance and SEO.', 'newfold-module-performance' ), + 'id' => 'permalinks', + 'title' => __( 'Permalinks', 'newfold-module-performance' ), + 'pass' => __( 'Permalinks are pretty', 'newfold-module-performance' ), + 'fail' => __( 'Permalinks are not set up', 'newfold-module-performance' ), + 'text' => __( 'Setting permalinks to anything other than plain can improve performance and SEO.', 'newfold-module-performance' ), 'actions' => array( array( 'label' => __( 'Set up permalinks.', 'newfold-module-performance' ), @@ -109,7 +109,7 @@ public function add_health_checks() { 'external' => false, ), ), - 'test' => function () { + 'test' => function () { return empty( get_option( 'permalink_structure' ) ); }, ) @@ -130,7 +130,7 @@ public function add_health_checks() { 'external' => false, ), ), - 'test' => function () { + 'test' => function () { return ( get_option( 'newfold_cache_level' ) >= 2 ); }, ) @@ -211,7 +211,7 @@ public function add_health_checks() { 'external' => false, ), ), - 'test' => function () { + 'test' => function () { $enabled = get_option( 'nfd_image_optimization', array() ); return ( isset( $enabled['lazy_loading'], $enabled['lazy_loading']['enabled'] ) && $enabled['lazy_loading']['enabled'] ); }, @@ -233,7 +233,7 @@ public function add_health_checks() { 'external' => false, ), ), - 'test' => function () { + 'test' => function () { $enabled = get_option( 'nfd_link_prefetch_settings', array() ); return ( isset( $enabled['activeOnDesktop'] ) && $enabled['activeOnDesktop'] ); }, @@ -255,7 +255,7 @@ public function add_health_checks() { 'external' => false, ), ), - 'test' => function () { + 'test' => function () { return get_option( 'jetpack_boost_status_critical-css', false ); }, ) @@ -276,7 +276,7 @@ public function add_health_checks() { 'external' => false, ), ), - 'test' => function () { + 'test' => function () { return get_option( 'jetpack_boost_status_render-blocking-js', false ); }, ) @@ -297,7 +297,7 @@ public function add_health_checks() { 'external' => false, ), ), - 'test' => function () { + 'test' => function () { return ( ! empty( get_option( 'jetpack_boost_status_minify-js', array() ) ) ); }, ) @@ -318,7 +318,7 @@ public function add_health_checks() { 'external' => false, ), ), - 'test' => function () { + 'test' => function () { return ( ! empty( get_option( 'jetpack_boost_status_minify-css', array() ) ) ); }, ) From 1bc16b60d678b12a35f9b7e66744d07058fe1b87 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Thu, 23 Jan 2025 01:31:26 -0600 Subject: [PATCH 17/24] Update Performance.php --- includes/Performance.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/includes/Performance.php b/includes/Performance.php index 3748d6a..6cd1291 100644 --- a/includes/Performance.php +++ b/includes/Performance.php @@ -70,10 +70,10 @@ public function __construct( Container $container ) { $this->hooks( $container ); - $cacheManager = new CacheManager( $container ); - $cachePurger = new CachePurgingService( $cacheManager->getInstances() ); + $cacheManager = new CacheManager( $container ); + $cachePurger = new CachePurgingService( $cacheManager->getInstances() ); $healthCheckManager = new HealthCheckManager( $container ); - $healthChecks = new HealthChecks( $container ); + $healthChecks = new HealthChecks( $container ); // Ensure that purgeable cache types are enabled before showing the UI. if ( $cachePurger->canPurge() ) { @@ -112,10 +112,8 @@ function () { /** * Add hooks. - * - * @param Container $container the container */ - public function hooks( Container $container ) { + public function hooks() { add_action( 'admin_init', array( $this, 'registerSettings' ), 11 ); From bc5dbc2e3513ad60b64677c84594f8dc9fc11f1e Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Thu, 23 Jan 2025 01:35:58 -0600 Subject: [PATCH 18/24] Update Performance.php --- includes/Performance.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Performance.php b/includes/Performance.php index bf696d4..299688c 100644 --- a/includes/Performance.php +++ b/includes/Performance.php @@ -87,8 +87,8 @@ public function __construct( Container $container ) { new Constants( $container ); new ImageManager( $container ); - $container->set( 'healthCheckManager', $healthCheckManager ); - $healthChecks->addHealthChecks(); + $container->set( 'healthCheckManager', $healthCheckManager ); + $healthChecks->addHealthChecks(); add_action( 'admin_bar_menu', array( $this, 'adminBarMenu' ), 100 ); add_action( 'admin_menu', array( $this, 'add_sub_menu_page' ) ); From 8e3850e1ec9e215d15f81bbc9bba15f03b5f0fd9 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Thu, 23 Jan 2025 01:36:48 -0600 Subject: [PATCH 19/24] Update HealthChecks.php --- includes/HealthChecks.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index de87ef1..07bd6a1 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -130,7 +130,7 @@ public function add_health_checks() { 'external' => false, ), ), - 'test' => function () { + 'test' => function () { return ( get_option( 'newfold_cache_level' ) >= 2 ); }, ) @@ -169,8 +169,8 @@ public function add_health_checks() { 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-module-performance' ), 'actions' => array( array( - 'label' => __( 'Learn more about Bluehost Cloud Hosting.', 'newfold-module-performance' ), - 'url' => 'https://www.bluehost.com/hosting/cloud', + 'label' => __( 'Learn more about Bluehost Cloud Hosting.', 'newfold-module-performance' ), + 'url' => 'https://www.bluehost.com/hosting/cloud', 'external' => true, ), ), From c0043f0fb86f3067a54d10963d0bb5df9925b7da Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Thu, 23 Jan 2025 08:19:26 -0600 Subject: [PATCH 20/24] Fix method name --- includes/HealthChecks.php | 246 ++++++++++++++------------------------ 1 file changed, 88 insertions(+), 158 deletions(-) diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index 07bd6a1..4a3e9d7 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -35,10 +35,10 @@ public function add_health_checks() { $manager->add_health_check( array( 'id' => 'autosave-interval', - 'title' => __( 'Autosave Interval', 'newfold-module-performance' ), - 'pass' => __( 'Autosaving is set to happen every 30 seconds or more', 'newfold-module-performance' ), - 'fail' => __( 'Autosaving is set to be frequent, less than every 30 seconds', 'newfold-module-performance' ), - 'text' => __( 'Setting the autosave interval to a longer period can reduce server load, it is recommended to set it to 30 seconds or more.', 'newfold-module-performance' ), + 'title' => __( 'Autosave Interval', 'newfold-performance-module' ), + 'pass' => __( 'Autosaving is set to happen every 30 seconds or more', 'newfold-performance-module' ), + 'fail' => __( 'Autosaving is set to be frequent, less than every 30 seconds', 'newfold-performance-module' ), + 'text' => __( 'Setting the autosave interval to a longer period can reduce server load, it is recommended to set it to 30 seconds or more.', 'newfold-performance-module' ), 'test' => function () { return ( defined( 'AUTOSAVE_INTERVAL' ) && AUTOSAVE_INTERVAL >= 30 ); }, @@ -49,10 +49,10 @@ public function add_health_checks() { $manager->add_health_check( array( 'id' => 'post-revisions', - 'title' => __( 'Post Revisions', 'newfold-module-performance' ), - 'pass' => __( 'Number of post revisions is limited to 5 or less', 'newfold-module-performance' ), - 'fail' => __( 'Number of post revisions is set to a high number', 'newfold-module-performance' ), - 'text' => __( 'Setting the number of post revisions to a lower number can reduce database bloat.', 'newfold-module-performance' ), + 'title' => __( 'Post Revisions', 'newfold-performance-module' ), + 'pass' => __( 'Number of post revisions is limited to 5 or less', 'newfold-performance-module' ), + 'fail' => __( 'Number of post revisions is set to a high number', 'newfold-performance-module' ), + 'text' => __( 'Setting the number of post revisions to a lower number can reduce database bloat.', 'newfold-performance-module' ), 'test' => function () { return ( defined( 'WP_POST_REVISIONS' ) && WP_POST_REVISIONS <= 5 ); }, @@ -62,19 +62,12 @@ public function add_health_checks() { // PRESS7-110: Empty Trash Days. $manager->add_health_check( array( - 'id' => 'empty-trash-days', - 'title' => __( 'Empty Trash Days', 'newfold-module-performance' ), - 'pass' => __( 'Trash is emptied every 30 days or less', 'newfold-module-performance' ), - 'fail' => __( 'Trash is emptied less frequently than every 30 days', 'newfold-module-performance' ), - 'text' => __( 'Emptying the trash more frequently can reduce database bloat.', 'newfold-module-performance' ), - 'actions' => array( - array( - 'label' => __( 'Configure trash settings.', 'newfold-module-performance' ), - 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=content-section#/performance' ), - 'external' => false, - ), - ), - 'test' => function () { + 'id' => 'empty-trash-days', + 'title' => __( 'Empty Trash Days', 'newfold-performance-module' ), + 'pass' => __( 'Trash is emptied every 30 days or less', 'newfold-performance-module' ), + 'fail' => __( 'Trash is emptied less frequently than every 30 days.', 'newfold-performance-module' ), + 'text' => __( 'Emptying the trash more frequently can reduce database bloat.', 'newfold-performance-module' ), + 'test' => function () { return ( defined( 'EMPTY_TRASH_DAYS' ) && EMPTY_TRASH_DAYS <= 30 ); }, ) @@ -84,10 +77,10 @@ public function add_health_checks() { $manager->add_health_check( array( 'id' => 'wp-cron-lock-timeout', - 'title' => __( 'WP Cron Lock Timeout', 'newfold-module-performance' ), - 'pass' => __( 'Cron lock timeout is set to 60 seconds or less', 'newfold-module-performance' ), - 'fail' => __( 'Cron lock timeout is set to a high number', 'newfold-module-performance' ), - 'text' => __( 'Cron lock timeout affects how long a cron job can run for, setting it to a lower number can improve performance.', 'newfold-module-performance' ), + 'title' => __( 'WP Cron Lock Timeout', 'newfold-performance-module' ), + 'pass' => __( 'Cron lock timeout is set to 60 seconds or less.', 'newfold-performance-module' ), + 'fail' => __( 'Cron lock timeout is set to a high number.', 'newfold-performance-module' ), + 'text' => __( 'Cron lock timeout affects how long a cron job can run for, setting it to a lower number can improve performance.', 'newfold-performance-module' ), 'test' => function () { return ( defined( 'WP_CRON_LOCK_TIMEOUT' ) && WP_CRON_LOCK_TIMEOUT <= 300 ); }, @@ -97,19 +90,12 @@ public function add_health_checks() { // PRESS7-118: Permalinks. $manager->add_health_check( array( - 'id' => 'permalinks', - 'title' => __( 'Permalinks', 'newfold-module-performance' ), - 'pass' => __( 'Permalinks are pretty', 'newfold-module-performance' ), - 'fail' => __( 'Permalinks are not set up', 'newfold-module-performance' ), - 'text' => __( 'Setting permalinks to anything other than plain can improve performance and SEO.', 'newfold-module-performance' ), - 'actions' => array( - array( - 'label' => __( 'Set up permalinks.', 'newfold-module-performance' ), - 'url' => admin_url( 'options-permalink.php' ), - 'external' => false, - ), - ), - 'test' => function () { + 'id' => 'permalinks', + 'title' => __( 'Permalinks', 'newfold-performance-module' ), + 'pass' => __( 'Permalinks are pretty', 'newfold-performance-module' ), + 'fail' => __( 'Permalinks are not set up', 'newfold-performance-module' ), + 'text' => __( 'Setting permalinks to anything other than plain can improve performance and SEO.', 'newfold-performance-module' ), + 'test' => function () { return empty( get_option( 'permalink_structure' ) ); }, ) @@ -118,19 +104,12 @@ public function add_health_checks() { // PRESS7-112: Page Caching. $manager->add_health_check( array( - 'id' => 'page-caching', - 'title' => __( 'Page Caching', 'newfold-module-performance' ), - 'pass' => __( 'Page caching is enabled', 'newfold-module-performance' ), - 'fail' => __( 'Page caching is disabled', 'newfold-module-performance' ), - 'text' => __( 'Page caching can improve performance by bypassing PHP and database queries for faster page loads.', 'newfold-module-performance' ), - 'actions' => array( - array( - 'label' => __( 'Configure caching.', 'newfold-module-performance' ), - 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=cache-type#/performance' ), - 'external' => false, - ), - ), - 'test' => function () { + 'id' => 'page-caching', + 'title' => __( 'Page Caching', 'newfold-performance-module' ), + 'pass' => __( 'Page caching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Page caching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Page caching can improve performance by bypassing PHP and database queries for faster page loads.', 'newfold-performance-module' ), + 'test' => function () { return ( get_option( 'newfold_cache_level' ) >= 2 ); }, ) @@ -139,19 +118,12 @@ public function add_health_checks() { // PRESS7-113: Browser Caching. $manager->add_health_check( array( - 'id' => 'browser-caching', - 'title' => __( 'Browser Caching', 'newfold-module-performance' ), - 'pass' => __( 'Browser caching is enabled', 'newfold-module-performance' ), - 'fail' => __( 'Browser caching is disabled', 'newfold-module-performance' ), - 'text' => __( 'Enabling browser caching can improve performance by storing static assets in the browser for faster page loads.', 'newfold-module-performance' ), - 'actions' => array( - array( - 'label' => __( 'Configure caching.', 'newfold-module-performance' ), - 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=cache-type#/performance' ), - 'external' => false, - ), - ), - 'test' => function () { + 'id' => 'browser-caching', + 'title' => __( 'Browser Caching', 'newfold-performance-module' ), + 'pass' => __( 'Browser caching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Browser caching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Enabling browser caching can improve performance by storing static assets in the browser for faster page loads.', 'newfold-performance-module' ), + 'test' => function () { return ( get_option( 'newfold_cache_level' ) >= 1 ); }, ) @@ -163,18 +135,19 @@ public function add_health_checks() { $manager->add_health_check( array( 'id' => 'persistent_object_cache', // Replaces the default test. - 'title' => __( 'Object Caching', 'newfold-module-performance' ), - 'pass' => __( 'Object caching is enabled', 'newfold-module-performance' ), - 'fail' => __( 'Object caching is disabled', 'newfold-module-performance' ), - 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-module-performance' ), - 'actions' => array( - array( - 'label' => __( 'Learn more about Bluehost Cloud Hosting.', 'newfold-module-performance' ), - 'url' => 'https://www.bluehost.com/hosting/cloud', - 'external' => true, - ), + 'title' => __( 'Object Caching', 'newfold-performance-module' ), + 'pass' => __( 'Object caching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Object caching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-performance-module' ), + 'actions' => sprintf( + '%1$s%2$s', + __( 'Learn more about Bluehost Cloud Hosting.', 'newfold-performance-module' ), + sprintf( + ' (%s)', + __( 'opens in a new tab', 'newfold-performance-module' ) + ) ), - 'test' => function () { + 'test' => function () { return wp_using_ext_object_cache(); }, ) @@ -185,33 +158,25 @@ public function add_health_checks() { $manager->add_health_check( array( 'id' => 'cloudflare-active', - 'title' => __( 'Cloudflare enabled', 'newfold-module-performance' ), - 'pass' => __( 'Cloudflare integration is enabled', 'newfold-module-performance' ), - 'fail' => __( 'Cloudflare integration is disabled', 'newfold-module-performance' ), - 'text' => __( 'Cloudflare integration can improve performance and security.', 'newfold-module-performance' ), + 'title' => __( 'Cloudflare enabled', 'newfold-performance-module' ), + 'pass' => __( 'Cloudflare integration is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Cloudflare integration is disabled', 'newfold-performance-module' ), + 'text' => __( 'Cloudflare integration can improve performance and security.', 'newfold-performance-module' ), 'test' => function () { return isset( $_SERVER['HTTP_CF_RAY'] ); }, ) ); - // Enable when https://github.com/newfold-labs/wp-module-performance/pull/32 is merged. // PRESS7-119: Lazy Loading. $manager->add_health_check( array( - 'id' => 'lazy-loading', - 'title' => __( 'Lazy Loading', 'newfold-module-performance' ), - 'pass' => __( 'Lazy loading is enabled', 'newfold-module-performance' ), - 'fail' => __( 'Lazy loading is disabled', 'newfold-module-performance' ), - 'text' => __( 'Lazy loading can improve performance by only loading images when they are in view.', 'newfold-module-performance' ), - 'actions' => array( - array( - 'label' => __( 'Configure lazy loading.', 'newfold-module-performance' ), - 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=lazy-loading-enabled#/performance' ), - 'external' => false, - ), - ), - 'test' => function () { + 'id' => 'lazy-loading', + 'title' => __( 'Lazy Loading', 'newfold-performance-module' ), + 'pass' => __( 'Lazy loading is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Lazy loading is disabled', 'newfold-performance-module' ), + 'text' => __( 'Lazy loading can improve performance by only loading images when they are in view.', 'newfold-performance-module' ), + 'test' => function () { $enabled = get_option( 'nfd_image_optimization', array() ); return ( isset( $enabled['lazy_loading'], $enabled['lazy_loading']['enabled'] ) && $enabled['lazy_loading']['enabled'] ); }, @@ -221,19 +186,12 @@ public function add_health_checks() { // PRESS7-120: Link Prefetching. $manager->add_health_check( array( - 'id' => 'link-prefetch', - 'title' => __( 'Link Prefetching', 'newfold-module-performance' ), - 'pass' => __( 'Link prefetching is enabled', 'newfold-module-performance' ), - 'fail' => __( 'Link prefetching is disabled', 'newfold-module-performance' ), - 'text' => __( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'newfold-module-performance' ), - 'actions' => array( - array( - 'label' => __( 'Configure Link prefetching.', 'newfold-module-performance' ), - 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=link-prefetch-behavior#/performance' ), - 'external' => false, - ), - ), - 'test' => function () { + 'id' => 'link-prefetch', + 'title' => __( 'Link Prefetching', 'newfold-performance-module' ), + 'pass' => __( 'Link prefetching is enabled', 'newfold-performance-module' ), + 'fail' => __( 'Link prefetching is disabled', 'newfold-performance-module' ), + 'text' => __( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'newfold-performance-module' ), + 'test' => function () { $enabled = get_option( 'nfd_link_prefetch_settings', array() ); return ( isset( $enabled['activeOnDesktop'] ) && $enabled['activeOnDesktop'] ); }, @@ -243,19 +201,12 @@ public function add_health_checks() { // PRESS7-114: Prioritize Critical CSS. $manager->add_health_check( array( - 'id' => 'prioritize-critical-css', - 'title' => __( 'Prioritize Critical CSS', 'newfold-module-performance' ), - 'pass' => __( 'Critical CSS is prioritized', 'newfold-module-performance' ), - 'fail' => __( 'Critical CSS is not prioritized', 'newfold-module-performance' ), - 'text' => __( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'newfold-module-performance' ), - 'actions' => array( - array( - 'label' => __( 'Configure Critical CSS.', 'newfold-module-performance' ), - 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=critical-css#/performance' ), - 'external' => false, - ), - ), - 'test' => function () { + 'id' => 'prioritize-critical-css', + 'title' => __( 'Prioritize Critical CSS', 'newfold-performance-module' ), + 'pass' => __( 'Critical CSS is prioritized', 'newfold-performance-module' ), + 'fail' => __( 'Critical CSS is not prioritized', 'newfold-performance-module' ), + 'text' => __( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'newfold-performance-module' ), + 'test' => function () { return get_option( 'jetpack_boost_status_critical-css', false ); }, ) @@ -264,19 +215,12 @@ public function add_health_checks() { // PRESS7-115: Defer Non-Essential JavaScript. $manager->add_health_check( array( - 'id' => 'defer-non-essential-javascript', - 'title' => __( 'Defer Non-Essential JavaScript', 'newfold-module-performance' ), - 'pass' => __( 'Non-essential JavaScript is deferred', 'newfold-module-performance' ), - 'fail' => __( 'Non-essential JavaScript is not deferred', 'newfold-module-performance' ), - 'text' => __( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'newfold-module-performance' ), - 'actions' => array( - array( - 'label' => __( 'Configure JavaScript deferral.', 'newfold-module-performance' ), - 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=render-blocking-js#/performance' ), - 'external' => false, - ), - ), - 'test' => function () { + 'id' => 'defer-non-essential-javascript', + 'title' => __( 'Defer Non-Essential JavaScript', 'newfold-performance-module' ), + 'pass' => __( 'Non-essential JavaScript is deferred', 'newfold-performance-module' ), + 'fail' => __( 'Non-essential JavaScript is not deferred', 'newfold-performance-module' ), + 'text' => __( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'newfold-performance-module' ), + 'test' => function () { return get_option( 'jetpack_boost_status_render-blocking-js', false ); }, ) @@ -285,19 +229,12 @@ public function add_health_checks() { // PRESS7-116: Concatenate JavaScript. $manager->add_health_check( array( - 'id' => 'concatenate-js', - 'title' => __( 'Concatenate JavaScript', 'newfold-module-performance' ), - 'pass' => __( 'JavaScript files are concatenated', 'newfold-module-performance' ), - 'fail' => __( 'JavaScript files are not concatenated', 'newfold-module-performance' ), - 'text' => __( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-module-performance' ), - 'actions' => array( - array( - 'label' => __( 'Configure JavaScript deferral.', 'newfold-module-performance' ), - 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=minify-js#/performance' ), - 'external' => false, - ), - ), - 'test' => function () { + 'id' => 'concatenate-js', + 'title' => __( 'Concatenate JavaScript', 'newfold-performance-module' ), + 'pass' => __( 'JavaScript files are concatenated', 'newfold-performance-module' ), + 'fail' => __( 'JavaScript files are not concatenated', 'newfold-performance-module' ), + 'text' => __( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-performance-module' ), + 'test' => function () { return ( ! empty( get_option( 'jetpack_boost_status_minify-js', array() ) ) ); }, ) @@ -306,19 +243,12 @@ public function add_health_checks() { // PRESS7-117: Concatenate CSS. $manager->add_health_check( array( - 'id' => 'concatenate-css', - 'title' => __( 'Concatenate CSS', 'newfold-module-performance' ), - 'pass' => __( 'CSS files are concatenated', 'newfold-module-performance' ), - 'fail' => __( 'CSS files are not concatenated', 'newfold-module-performance' ), - 'text' => __( 'Concatenating CSS can improve performance by reducing the number of requests.', 'newfold-module-performance' ), - 'actions' => array( - array( - 'label' => __( 'Configure JavaScript deferral.', 'newfold-module-performance' ), - 'url' => admin_url( 'admin.php?page=' . $this->container->plugin()->id . '&nfd-target=minify-csss#/performance' ), - 'external' => false, - ), - ), - 'test' => function () { + 'id' => 'concatenate-css', + 'title' => __( 'Concatenate CSS', 'newfold-performance-module' ), + 'pass' => __( 'CSS files are concatenated', 'newfold-performance-module' ), + 'fail' => __( 'CSS files are not concatenated', 'newfold-performance-module' ), + 'text' => __( 'Concatenating CSS can improve performance by reducing the number of requests.', 'newfold-performance-module' ), + 'test' => function () { return ( ! empty( get_option( 'jetpack_boost_status_minify-css', array() ) ) ); }, ) From 3430f6856718575af47052f7bc26ce1894be09a0 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Thu, 23 Jan 2025 08:58:25 -0600 Subject: [PATCH 21/24] fix method name --- includes/Performance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Performance.php b/includes/Performance.php index 299688c..863ca6b 100644 --- a/includes/Performance.php +++ b/includes/Performance.php @@ -88,7 +88,7 @@ public function __construct( Container $container ) { new ImageManager( $container ); $container->set( 'healthCheckManager', $healthCheckManager ); - $healthChecks->addHealthChecks(); + $healthChecks->add_health_checks(); add_action( 'admin_bar_menu', array( $this, 'adminBarMenu' ), 100 ); add_action( 'admin_menu', array( $this, 'add_sub_menu_page' ) ); From 697409aff565fa7afd49a9999b2314bcb2d0132d Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Sun, 26 Jan 2025 23:00:47 -0600 Subject: [PATCH 22/24] Refactor Health Checks to use an abstract class and individual classes for each check for more organization --- includes/HealthCheckManager.php | 183 ------------ includes/HealthChecks.php | 282 ++++-------------- .../AutosaveIntervalHealthCheck.php | 28 ++ .../BrowserCachingHealthCheck.php | 28 ++ .../HealthChecks/CloudflareHealthCheck.php | 28 ++ .../ConcatenateCssHealthCheck.php | 28 ++ .../HealthChecks/ConcatenateJsHealthCheck.php | 28 ++ .../CronLockTimeoutHealthCheck.php | 28 ++ .../DeferNonEssentialJsHealthCheck.php | 28 ++ .../EmptyTrashDaysHealthCheck.php | 28 ++ includes/HealthChecks/HealthCheck.php | 107 +++++++ .../HealthChecks/LazyLoadingHealthCheck.php | 29 ++ .../HealthChecks/LinkPrefetchHealthCheck.php | 29 ++ .../HealthChecks/PageCachingHealthCheck.php | 28 ++ .../HealthChecks/PermalinksHealthCheck.php | 28 ++ .../PersistentObjectCacheHealthCheck.php | 34 +++ .../HealthChecks/PostRevisionsHealthCheck.php | 28 ++ .../HealthChecks/PrioritizeCssHealthCheck.php | 28 ++ includes/Performance.php | 19 +- 19 files changed, 598 insertions(+), 421 deletions(-) delete mode 100644 includes/HealthCheckManager.php create mode 100644 includes/HealthChecks/AutosaveIntervalHealthCheck.php create mode 100644 includes/HealthChecks/BrowserCachingHealthCheck.php create mode 100644 includes/HealthChecks/CloudflareHealthCheck.php create mode 100644 includes/HealthChecks/ConcatenateCssHealthCheck.php create mode 100644 includes/HealthChecks/ConcatenateJsHealthCheck.php create mode 100644 includes/HealthChecks/CronLockTimeoutHealthCheck.php create mode 100644 includes/HealthChecks/DeferNonEssentialJsHealthCheck.php create mode 100644 includes/HealthChecks/EmptyTrashDaysHealthCheck.php create mode 100644 includes/HealthChecks/HealthCheck.php create mode 100644 includes/HealthChecks/LazyLoadingHealthCheck.php create mode 100644 includes/HealthChecks/LinkPrefetchHealthCheck.php create mode 100644 includes/HealthChecks/PageCachingHealthCheck.php create mode 100644 includes/HealthChecks/PermalinksHealthCheck.php create mode 100644 includes/HealthChecks/PersistentObjectCacheHealthCheck.php create mode 100644 includes/HealthChecks/PostRevisionsHealthCheck.php create mode 100644 includes/HealthChecks/PrioritizeCssHealthCheck.php diff --git a/includes/HealthCheckManager.php b/includes/HealthCheckManager.php deleted file mode 100644 index c28c554..0000000 --- a/includes/HealthCheckManager.php +++ /dev/null @@ -1,183 +0,0 @@ -add_hooks(); - } - } - - /** - * Add hooks. - */ - public function add_hooks() { - add_filter( 'site_status_tests', array( $this, 'register_health_checks' ) ); - } - - /** - * Add a health check. - * - * The options array can contain the following keys: - * - id: A unique identifier for the health check. - * - title: The title of the health check. - * - test: A callable function that will run the health check and return a boolean. - * - label: Optional. If set, it will display both for passed and failed. (User-facing text.) - * - pass: The label to display when the health check passes. (User-facing text.) - * - fail: The label to display when the health check fails. (User-facing text.) - * - text: Optional. Additional text to display below the health check results. (User-facing text.) - * - status: Optional. Used to override the status of the health check. Default is 'good' for pass, 'critical' for fail. - * - badge_label: Optional. The label to display on the badge. (User-facing text.) Default is 'Performance'. - * - badge_color: Optional. The color of the badge. Default is 'blue'. - * - actions: Optional. An array of actions to display below the health check results. Each action should contain a 'label' string, a 'url' string, and a 'external' boolean. - * - * @param array $options Health check options. - */ - public function add_health_check( $options ) { - $options = /* Explain keys and their impact */ - wp_parse_args( - $options, - array( - 'id' => '', - 'title' => '', - 'test' => '', - 'label' => false, // Setting this will override pass/fail labels. - 'pass' => '', - 'fail' => '', - 'text' => '', - 'status' => false, // Override the status of the health check: default is good for pass, critical for fail. - 'badge_label' => __( 'Performance', 'newfold-labs' ), - 'badge_color' => 'blue', - 'actions' => '', - ) - ); - - // Make sure the health check is valid. - if ( ! ( empty( $options['id'] ) || empty( $options['title'] ) || ! is_callable( $options['test'] ) ) ) { - $this->checks[ $this->prefix . $options['id'] ] = $options; - } - } - - /** - * Concatenate actions array into a string. - * - * Label, URL, and external are the keys that should be present in the actions array. The label is the text that is - * display as the link, the URL is the link that the label will point to, and external is a boolean that determines - * whether the link should show the external icon. - * - * @param array $actions Actions to concatenate. Should contain an array of 'label', 'url', and 'external'. - * - * @return string Concatenated actions. - */ - public function concat_actions_text_and_link( $actions ) { - $actions_string = ''; - - foreach ( $actions as $action ) { - $action = wp_parse_args( - $action, - array( - 'label' => '', - 'url' => '', - 'external' => false, - ) - ); - - $actions_string .= sprintf( - '%2$s%4$s', - esc_url( $action['url'] ), - esc_html( $action['label'] ), - $action['external'] ? 'target="_blank" rel="noopener"' : '', - $action['external'] ? sprintf( - ' (%s)', - __( 'opens in a new tab', 'newfold-module-performance' ) - ) : '' - ); - } - - return $actions_string; - } - - /** - * Run a health check. - * - * @param string $id Health check ID. - * - * @return array Health check results. - */ - public function run_health_check( $id ) { - $check = $this->checks[ $id ]; - - // Execute the test. - $passed = call_user_func( $check['test'] ); - - // Return the health check results. - return array( - 'label' => $check['label'] ? $check['label'] : ( $passed ? $check['pass'] : $check['fail'] ), - 'status' => $passed ? 'good' : ( 'critical' === $check['status'] ? 'critical' : 'recommended' ), // Will default to 'recommended', unless 'critical' is passed. - 'description' => sprintf( '

%s

', $check['text'] ? $check['text'] : '' ), - 'actions' => is_array( $check['actions'] ) ? $this->concat_actions_text_and_link( $check['actions'] ) : ( $check['actions'] ? $check['actions'] : '' ), - 'test' => $check['id'], - 'badge' => array( - 'label' => $check['badge_label'], - 'color' => $check['badge_color'], - ), - ); - } - - /** - * Add health checks. - * - * @param array $tests Site Health tests. - * - * @return array Site Health tests. - */ - public function register_health_checks( $tests ) { - // If there are no health checks, don't add any. - if ( ! is_array( $this->checks ) || empty( $this->checks ) ) { - return $tests; - } - - foreach ( $this->checks as $id => $check ) { - /** - * Filter to enable/disable a health check. - * - * @param bool $do_check Whether to run the health check. - */ - $do_check = apply_filters( 'newfold/features/filter/isEnabled:healthChecks:' . $id, true ); // phpcs:ignore - if ( $do_check ) { - $tests['direct'][ $id ] = array( - 'label' => $check['title'], - 'test' => function () use ( $id ) { - return $this->run_health_check( $id ); - }, - ); - } - } - - return $tests; - } -} diff --git a/includes/HealthChecks.php b/includes/HealthChecks.php index 4a3e9d7..23b2194 100644 --- a/includes/HealthChecks.php +++ b/includes/HealthChecks.php @@ -2,256 +2,88 @@ namespace NewfoldLabs\WP\Module\Performance; -use NewfoldLabs\WP\ModuleLoader\Container; +use NewfoldLabs\WP\Module\Performance\HealthChecks\AutosaveIntervalHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\BrowserCachingHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\CloudflareHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\ConcatenateCssHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\ConcatenateJsHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\CronLockTimeoutHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\DeferNonEssentialJsHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\EmptyTrashDaysHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\LazyLoadingHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\LinkPrefetchHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\PageCachingHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\PermalinksHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\PersistentObjectCacheHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\PostRevisionsHealthCheck; +use NewfoldLabs\WP\Module\Performance\HealthChecks\PrioritizeCssHealthCheck; /** * Add performance health checks. */ class HealthChecks { - /** - * Dependency injection container. + * Container. * * @var Container */ - protected $container; + private $container; /** * Constructor. * - * @param Container $container Dependency injection container. + * @param Container $container Container. */ - public function __construct( Container $container ) { + public function __construct( $container ) { $this->container = $container; + if ( function_exists( 'add_filter' ) ) { + $this->add_hooks(); + } } /** - * Add health checks. + * Add hooks. */ - public function add_health_checks() { - $manager = $this->container->get( 'healthCheckManager' ); - - // PRESS7-108: Autosave Interval. - $manager->add_health_check( - array( - 'id' => 'autosave-interval', - 'title' => __( 'Autosave Interval', 'newfold-performance-module' ), - 'pass' => __( 'Autosaving is set to happen every 30 seconds or more', 'newfold-performance-module' ), - 'fail' => __( 'Autosaving is set to be frequent, less than every 30 seconds', 'newfold-performance-module' ), - 'text' => __( 'Setting the autosave interval to a longer period can reduce server load, it is recommended to set it to 30 seconds or more.', 'newfold-performance-module' ), - 'test' => function () { - return ( defined( 'AUTOSAVE_INTERVAL' ) && AUTOSAVE_INTERVAL >= 30 ); - }, - ) - ); - - // PRESS7-109: Post Revisions. - $manager->add_health_check( - array( - 'id' => 'post-revisions', - 'title' => __( 'Post Revisions', 'newfold-performance-module' ), - 'pass' => __( 'Number of post revisions is limited to 5 or less', 'newfold-performance-module' ), - 'fail' => __( 'Number of post revisions is set to a high number', 'newfold-performance-module' ), - 'text' => __( 'Setting the number of post revisions to a lower number can reduce database bloat.', 'newfold-performance-module' ), - 'test' => function () { - return ( defined( 'WP_POST_REVISIONS' ) && WP_POST_REVISIONS <= 5 ); - }, - ) - ); - - // PRESS7-110: Empty Trash Days. - $manager->add_health_check( - array( - 'id' => 'empty-trash-days', - 'title' => __( 'Empty Trash Days', 'newfold-performance-module' ), - 'pass' => __( 'Trash is emptied every 30 days or less', 'newfold-performance-module' ), - 'fail' => __( 'Trash is emptied less frequently than every 30 days.', 'newfold-performance-module' ), - 'text' => __( 'Emptying the trash more frequently can reduce database bloat.', 'newfold-performance-module' ), - 'test' => function () { - return ( defined( 'EMPTY_TRASH_DAYS' ) && EMPTY_TRASH_DAYS <= 30 ); - }, - ) - ); - - // PRESS7-111: Cron Lock Timeout. - $manager->add_health_check( - array( - 'id' => 'wp-cron-lock-timeout', - 'title' => __( 'WP Cron Lock Timeout', 'newfold-performance-module' ), - 'pass' => __( 'Cron lock timeout is set to 60 seconds or less.', 'newfold-performance-module' ), - 'fail' => __( 'Cron lock timeout is set to a high number.', 'newfold-performance-module' ), - 'text' => __( 'Cron lock timeout affects how long a cron job can run for, setting it to a lower number can improve performance.', 'newfold-performance-module' ), - 'test' => function () { - return ( defined( 'WP_CRON_LOCK_TIMEOUT' ) && WP_CRON_LOCK_TIMEOUT <= 300 ); - }, - ) - ); - - // PRESS7-118: Permalinks. - $manager->add_health_check( - array( - 'id' => 'permalinks', - 'title' => __( 'Permalinks', 'newfold-performance-module' ), - 'pass' => __( 'Permalinks are pretty', 'newfold-performance-module' ), - 'fail' => __( 'Permalinks are not set up', 'newfold-performance-module' ), - 'text' => __( 'Setting permalinks to anything other than plain can improve performance and SEO.', 'newfold-performance-module' ), - 'test' => function () { - return empty( get_option( 'permalink_structure' ) ); - }, - ) - ); - - // PRESS7-112: Page Caching. - $manager->add_health_check( - array( - 'id' => 'page-caching', - 'title' => __( 'Page Caching', 'newfold-performance-module' ), - 'pass' => __( 'Page caching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Page caching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Page caching can improve performance by bypassing PHP and database queries for faster page loads.', 'newfold-performance-module' ), - 'test' => function () { - return ( get_option( 'newfold_cache_level' ) >= 2 ); - }, - ) - ); + public function add_hooks() { + add_filter( 'site_status_tests', array( $this, 'add_health_checks' ) ); + } - // PRESS7-113: Browser Caching. - $manager->add_health_check( - array( - 'id' => 'browser-caching', - 'title' => __( 'Browser Caching', 'newfold-performance-module' ), - 'pass' => __( 'Browser caching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Browser caching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Enabling browser caching can improve performance by storing static assets in the browser for faster page loads.', 'newfold-performance-module' ), - 'test' => function () { - return ( get_option( 'newfold_cache_level' ) >= 1 ); - }, - ) + /** + * Add health checks. + * + * @param array $tests Site status tests. + * + * @return array Site status tests. + */ + public function add_health_checks( $tests ) { + $health_checks = array( + new AutosaveIntervalHealthCheck(), + new PostRevisionsHealthCheck(), + new AutosaveIntervalHealthCheck(), + new BrowserCachingHealthCheck(), + new CloudflareHealthCheck(), + new ConcatenateCssHealthCheck(), + new ConcatenateJsHealthCheck(), + new CronLockTimeoutHealthCheck(), + new DeferNonEssentialJsHealthCheck(), + new EmptyTrashDaysHealthCheck(), + new LazyLoadingHealthCheck(), + new LinkPrefetchHealthCheck(), + new PageCachingHealthCheck(), + new PermalinksHealthCheck(), + new PostRevisionsHealthCheck(), + new PrioritizeCssHealthCheck(), ); - // PRESS7-121: Object Caching. - // Only show object caching health check for Bluehost brand. + // Override the core persistent object cache health check, but only for Bluehost. if ( 'bluehost' === $this->container->plugin()->brand ) { - $manager->add_health_check( - array( - 'id' => 'persistent_object_cache', // Replaces the default test. - 'title' => __( 'Object Caching', 'newfold-performance-module' ), - 'pass' => __( 'Object caching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Object caching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-performance-module' ), - 'actions' => sprintf( - '%1$s%2$s', - __( 'Learn more about Bluehost Cloud Hosting.', 'newfold-performance-module' ), - sprintf( - ' (%s)', - __( 'opens in a new tab', 'newfold-performance-module' ) - ) - ), - 'test' => function () { - return wp_using_ext_object_cache(); - }, - ) - ); + $health_checks[] = new PersistentObjectCacheHealthCheck(); } - // PRESS7-107: Cloudflare. - $manager->add_health_check( - array( - 'id' => 'cloudflare-active', - 'title' => __( 'Cloudflare enabled', 'newfold-performance-module' ), - 'pass' => __( 'Cloudflare integration is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Cloudflare integration is disabled', 'newfold-performance-module' ), - 'text' => __( 'Cloudflare integration can improve performance and security.', 'newfold-performance-module' ), - 'test' => function () { - return isset( $_SERVER['HTTP_CF_RAY'] ); - }, - ) - ); - - // PRESS7-119: Lazy Loading. - $manager->add_health_check( - array( - 'id' => 'lazy-loading', - 'title' => __( 'Lazy Loading', 'newfold-performance-module' ), - 'pass' => __( 'Lazy loading is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Lazy loading is disabled', 'newfold-performance-module' ), - 'text' => __( 'Lazy loading can improve performance by only loading images when they are in view.', 'newfold-performance-module' ), - 'test' => function () { - $enabled = get_option( 'nfd_image_optimization', array() ); - return ( isset( $enabled['lazy_loading'], $enabled['lazy_loading']['enabled'] ) && $enabled['lazy_loading']['enabled'] ); - }, - ) - ); - - // PRESS7-120: Link Prefetching. - $manager->add_health_check( - array( - 'id' => 'link-prefetch', - 'title' => __( 'Link Prefetching', 'newfold-performance-module' ), - 'pass' => __( 'Link prefetching is enabled', 'newfold-performance-module' ), - 'fail' => __( 'Link prefetching is disabled', 'newfold-performance-module' ), - 'text' => __( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'newfold-performance-module' ), - 'test' => function () { - $enabled = get_option( 'nfd_link_prefetch_settings', array() ); - return ( isset( $enabled['activeOnDesktop'] ) && $enabled['activeOnDesktop'] ); - }, - ) - ); - - // PRESS7-114: Prioritize Critical CSS. - $manager->add_health_check( - array( - 'id' => 'prioritize-critical-css', - 'title' => __( 'Prioritize Critical CSS', 'newfold-performance-module' ), - 'pass' => __( 'Critical CSS is prioritized', 'newfold-performance-module' ), - 'fail' => __( 'Critical CSS is not prioritized', 'newfold-performance-module' ), - 'text' => __( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'newfold-performance-module' ), - 'test' => function () { - return get_option( 'jetpack_boost_status_critical-css', false ); - }, - ) - ); - - // PRESS7-115: Defer Non-Essential JavaScript. - $manager->add_health_check( - array( - 'id' => 'defer-non-essential-javascript', - 'title' => __( 'Defer Non-Essential JavaScript', 'newfold-performance-module' ), - 'pass' => __( 'Non-essential JavaScript is deferred', 'newfold-performance-module' ), - 'fail' => __( 'Non-essential JavaScript is not deferred', 'newfold-performance-module' ), - 'text' => __( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'newfold-performance-module' ), - 'test' => function () { - return get_option( 'jetpack_boost_status_render-blocking-js', false ); - }, - ) - ); - - // PRESS7-116: Concatenate JavaScript. - $manager->add_health_check( - array( - 'id' => 'concatenate-js', - 'title' => __( 'Concatenate JavaScript', 'newfold-performance-module' ), - 'pass' => __( 'JavaScript files are concatenated', 'newfold-performance-module' ), - 'fail' => __( 'JavaScript files are not concatenated', 'newfold-performance-module' ), - 'text' => __( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-performance-module' ), - 'test' => function () { - return ( ! empty( get_option( 'jetpack_boost_status_minify-js', array() ) ) ); - }, - ) - ); + foreach ( $health_checks as $health_check ) { + $tests = $health_check->register_health_check( $tests ); + } - // PRESS7-117: Concatenate CSS. - $manager->add_health_check( - array( - 'id' => 'concatenate-css', - 'title' => __( 'Concatenate CSS', 'newfold-performance-module' ), - 'pass' => __( 'CSS files are concatenated', 'newfold-performance-module' ), - 'fail' => __( 'CSS files are not concatenated', 'newfold-performance-module' ), - 'text' => __( 'Concatenating CSS can improve performance by reducing the number of requests.', 'newfold-performance-module' ), - 'test' => function () { - return ( ! empty( get_option( 'jetpack_boost_status_minify-css', array() ) ) ); - }, - ) - ); + return $tests; } } diff --git a/includes/HealthChecks/AutosaveIntervalHealthCheck.php b/includes/HealthChecks/AutosaveIntervalHealthCheck.php new file mode 100644 index 0000000..fc649cd --- /dev/null +++ b/includes/HealthChecks/AutosaveIntervalHealthCheck.php @@ -0,0 +1,28 @@ +id = 'newfold-autosave-interval'; + $this->title = esc_html__( 'Autosave Interval', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Autosaving is set to happen every 30 seconds or more', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Autosaving is set to be frequent, less than every 30 seconds', 'newfold-performance-module' ); + $this->description = esc_html__( 'Setting the autosave interval to a longer period can reduce server load. It is recommended to set it to 30 seconds or more.', 'newfold-performance-module' ); + } + + /** + * Test the autosave interval. + * + * @return bool + */ + public function test() { + return defined( 'AUTOSAVE_INTERVAL' ) && constant( 'AUTOSAVE_INTERVAL' ) >= 30; + } +} diff --git a/includes/HealthChecks/BrowserCachingHealthCheck.php b/includes/HealthChecks/BrowserCachingHealthCheck.php new file mode 100644 index 0000000..009781e --- /dev/null +++ b/includes/HealthChecks/BrowserCachingHealthCheck.php @@ -0,0 +1,28 @@ +id = 'newfold-browser-caching'; + $this->title = esc_html__( 'Browser Caching', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Browser caching is enabled', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Browser caching is disabled', 'newfold-performance-module' ); + $this->description = esc_html__( 'Enabling browser caching can improve performance by storing static assets in the browser for faster page loads.', 'newfold-performance-module' ); + } + + /** + * Test if browser caching is enabled. + * + * @return bool + */ + public function test() { + return get_option( 'newfold_cache_level' ) >= 1; + } +} diff --git a/includes/HealthChecks/CloudflareHealthCheck.php b/includes/HealthChecks/CloudflareHealthCheck.php new file mode 100644 index 0000000..3c3381e --- /dev/null +++ b/includes/HealthChecks/CloudflareHealthCheck.php @@ -0,0 +1,28 @@ +id = 'newfold-cloudflare'; + $this->title = esc_html__( 'Cloudflare enabled', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Cloudflare integration is enabled', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Cloudflare integration is disabled', 'newfold-performance-module' ); + $this->description = esc_html__( 'Cloudflare integration can improve performance and security.', 'newfold-performance-module' ); + } + + /** + * Test for Cloudflare integration. + * + * @return bool + */ + public function test() { + return isset( $_SERVER['HTTP_CF_RAY'] ); + } +} diff --git a/includes/HealthChecks/ConcatenateCssHealthCheck.php b/includes/HealthChecks/ConcatenateCssHealthCheck.php new file mode 100644 index 0000000..624a304 --- /dev/null +++ b/includes/HealthChecks/ConcatenateCssHealthCheck.php @@ -0,0 +1,28 @@ +id = 'newfold-concatenate-css'; + $this->title = esc_html__( 'Concatenate CSS', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'CSS files are concatenated', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'CSS files are not concatenated', 'newfold-performance-module' ); + $this->description = esc_html__( 'Concatenating CSS can improve performance by reducing the number of requests.', 'newfold-performance-module' ); + } + + /** + * Test if CSS files are concatenated. + * + * @return bool + */ + public function test() { + return ! empty( get_option( 'jetpack_boost_status_minify-css', array() ) ); + } +} diff --git a/includes/HealthChecks/ConcatenateJsHealthCheck.php b/includes/HealthChecks/ConcatenateJsHealthCheck.php new file mode 100644 index 0000000..e5ee819 --- /dev/null +++ b/includes/HealthChecks/ConcatenateJsHealthCheck.php @@ -0,0 +1,28 @@ +id = 'newfold-concatenate-js'; + $this->title = esc_html__( 'Concatenate JavaScript', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'JavaScript files are concatenated', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'JavaScript files are not concatenated', 'newfold-performance-module' ); + $this->description = esc_html__( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-performance-module' ); + } + + /** + * Test if JavaScript files are concatenated. + * + * @return bool + */ + public function test() { + return ! empty( get_option( 'jetpack_boost_status_minify-js', array() ) ); + } +} diff --git a/includes/HealthChecks/CronLockTimeoutHealthCheck.php b/includes/HealthChecks/CronLockTimeoutHealthCheck.php new file mode 100644 index 0000000..833fb02 --- /dev/null +++ b/includes/HealthChecks/CronLockTimeoutHealthCheck.php @@ -0,0 +1,28 @@ +id = 'wp-cron-lock-timeout'; + $this->title = esc_html__( 'WP Cron Lock Timeout', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Cron lock timeout is set to 60 seconds or less.', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Cron lock timeout is set to a high number.', 'newfold-performance-module' ); + $this->description = esc_html__( 'Cron lock timeout affects how long a cron job can run for. Setting it to a lower number can improve performance.', 'newfold-performance-module' ); + } + + /** + * Test the WP Cron lock timeout setting. + * + * @return bool + */ + public function test() { + return defined( 'WP_CRON_LOCK_TIMEOUT' ) && constant( 'WP_CRON_LOCK_TIMEOUT' ) <= 300; + } +} diff --git a/includes/HealthChecks/DeferNonEssentialJsHealthCheck.php b/includes/HealthChecks/DeferNonEssentialJsHealthCheck.php new file mode 100644 index 0000000..8cf2662 --- /dev/null +++ b/includes/HealthChecks/DeferNonEssentialJsHealthCheck.php @@ -0,0 +1,28 @@ +id = 'newfold-defer-non-essential-js'; + $this->title = esc_html__( 'Defer Non-Essential JavaScript', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Non-essential JavaScript is deferred', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Non-essential JavaScript is not deferred', 'newfold-performance-module' ); + $this->description = esc_html__( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'newfold-performance-module' ); + } + + /** + * Test if non-essential JavaScript is deferred. + * + * @return bool + */ + public function test() { + return get_option( 'jetpack_boost_status_render-blocking-js', false ); + } +} diff --git a/includes/HealthChecks/EmptyTrashDaysHealthCheck.php b/includes/HealthChecks/EmptyTrashDaysHealthCheck.php new file mode 100644 index 0000000..18942ec --- /dev/null +++ b/includes/HealthChecks/EmptyTrashDaysHealthCheck.php @@ -0,0 +1,28 @@ +id = 'newfold-empty-trash-days'; + $this->title = esc_html__( 'Empty Trash Days', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Trash is emptied every 30 days or less', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Trash is emptied less frequently than every 30 days.', 'newfold-performance-module' ); + $this->description = esc_html__( 'Emptying the trash more frequently can reduce database bloat.', 'newfold-performance-module' ); + } + + /** + * Test the empty trash days setting. + * + * @return bool + */ + public function test() { + return defined( 'EMPTY_TRASH_DAYS' ) && constant( 'EMPTY_TRASH_DAYS' ) <= 30; + } +} diff --git a/includes/HealthChecks/HealthCheck.php b/includes/HealthChecks/HealthCheck.php new file mode 100644 index 0000000..7b5667d --- /dev/null +++ b/includes/HealthChecks/HealthCheck.php @@ -0,0 +1,107 @@ +id, true ); // phpcs:ignore WordPress.NamingConventions.ValidHookName + if ( ! $do_check ) { + return $tests; + } + + // Right now, we're only supporting direct health checks. + $tests['direct'][ $this->id ] = array( + 'label' => $this->title, + 'test' => function () { + $passed = $this->test(); + + return array( + 'label' => $passed ? $this->passing_text : $this->failing_text, + 'status' => $passed ? 'good' : 'recommended', + 'description' => sprintf( '

%s

', $this->description ), + 'actions' => $this->actions, + 'test' => $this->id, + 'badge' => array( + 'label' => __( 'Performance' ), // No text domain, as we want to match the WP core badge text. + 'color' => $this->badge_color, + ), + ); + }, + ); + + return $tests; + } +} diff --git a/includes/HealthChecks/LazyLoadingHealthCheck.php b/includes/HealthChecks/LazyLoadingHealthCheck.php new file mode 100644 index 0000000..9e46cc6 --- /dev/null +++ b/includes/HealthChecks/LazyLoadingHealthCheck.php @@ -0,0 +1,29 @@ +id = 'newfold-lazy-loading'; + $this->title = esc_html__( 'Lazy Loading', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Lazy loading is enabled', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Lazy loading is disabled', 'newfold-performance-module' ); + $this->description = esc_html__( 'Lazy loading can improve performance by only loading images when they are in view.', 'newfold-performance-module' ); + } + + /** + * Test if lazy loading is enabled. + * + * @return bool + */ + public function test() { + $image_optimization = get_option( 'nfd_image_optimization', array() ); + return isset( $image_optimization['lazy_loading'], $image_optimization['lazy_loading']['enabled'] ) && $image_optimization['lazy_loading']['enabled']; + } +} diff --git a/includes/HealthChecks/LinkPrefetchHealthCheck.php b/includes/HealthChecks/LinkPrefetchHealthCheck.php new file mode 100644 index 0000000..e7e23e6 --- /dev/null +++ b/includes/HealthChecks/LinkPrefetchHealthCheck.php @@ -0,0 +1,29 @@ +id = 'newfold-link-prefetch'; + $this->title = esc_html__( 'Link Prefetching', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Link prefetching is enabled', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Link prefetching is disabled', 'newfold-performance-module' ); + $this->description = esc_html__( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'newfold-performance-module' ); + } + + /** + * Test if link prefetching is enabled. + * + * @return bool + */ + public function test() { + $enabled = get_option( 'nfd_link_prefetch_settings', array() ); + return isset( $enabled['activeOnDesktop'] ) && $enabled['activeOnDesktop']; + } +} diff --git a/includes/HealthChecks/PageCachingHealthCheck.php b/includes/HealthChecks/PageCachingHealthCheck.php new file mode 100644 index 0000000..09b1d4f --- /dev/null +++ b/includes/HealthChecks/PageCachingHealthCheck.php @@ -0,0 +1,28 @@ +id = 'newfold-page-caching'; + $this->title = esc_html__( 'Page Caching', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Page caching is enabled', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Page caching is disabled', 'newfold-performance-module' ); + $this->description = esc_html__( 'Page caching can improve performance by bypassing PHP and database queries for faster page loads.', 'newfold-performance-module' ); + } + + /** + * Test if page caching is enabled. + * + * @return bool + */ + public function test() { + return get_option( 'newfold_cache_level' ) >= 2; + } +} diff --git a/includes/HealthChecks/PermalinksHealthCheck.php b/includes/HealthChecks/PermalinksHealthCheck.php new file mode 100644 index 0000000..663c5f7 --- /dev/null +++ b/includes/HealthChecks/PermalinksHealthCheck.php @@ -0,0 +1,28 @@ +id = 'newfold-permalinks'; + $this->title = esc_html__( 'Permalinks', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Permalinks are pretty', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Permalinks are not set up', 'newfold-performance-module' ); + $this->description = esc_html__( 'Setting permalinks to anything other than plain can improve performance and SEO.', 'newfold-performance-module' ); + } + + /** + * Test the permalinks setting. + * + * @return bool + */ + public function test() { + return ! empty( get_option( 'permalink_structure' ) ); + } +} diff --git a/includes/HealthChecks/PersistentObjectCacheHealthCheck.php b/includes/HealthChecks/PersistentObjectCacheHealthCheck.php new file mode 100644 index 0000000..c180d77 --- /dev/null +++ b/includes/HealthChecks/PersistentObjectCacheHealthCheck.php @@ -0,0 +1,34 @@ +id = 'persistent_object_cache'; // Same as the core ID so that we can override the core health check. + $this->title = esc_html__( 'Object Caching', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Object caching is enabled', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Object caching is disabled', 'newfold-performance-module' ); + $this->description = esc_html__( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-performance-module' ); + $this->actions = sprintf( + '%2$s (%3$s)', + 'https://www.bluehost.com/help/article/object-caching', + esc_html__( 'Learn more about object caching', 'newfold-performance-module' ), + __( 'opens in a new tab', 'newfold-module-performance' ) + ); + } + + /** + * Test the object cache. + * + * @return bool + */ + public function test() { + return wp_using_ext_object_cache(); + } +} diff --git a/includes/HealthChecks/PostRevisionsHealthCheck.php b/includes/HealthChecks/PostRevisionsHealthCheck.php new file mode 100644 index 0000000..3db60ef --- /dev/null +++ b/includes/HealthChecks/PostRevisionsHealthCheck.php @@ -0,0 +1,28 @@ +id = 'newfold-post-revisions'; + $this->title = esc_html__( 'Post Revisions', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Number of post revisions is limited to 5 or less', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Number of post revisions is set to a high number', 'newfold-performance-module' ); + $this->description = esc_html__( 'Setting the number of post revisions to a lower number can reduce database bloat.', 'newfold-performance-module' ); + } + + /** + * Test the number of post revisions. + * + * @return bool + */ + public function test() { + return defined( 'WP_POST_REVISIONS' ) && constant( 'WP_POST_REVISIONS' ) <= 5; + } +} diff --git a/includes/HealthChecks/PrioritizeCssHealthCheck.php b/includes/HealthChecks/PrioritizeCssHealthCheck.php new file mode 100644 index 0000000..cf88b6c --- /dev/null +++ b/includes/HealthChecks/PrioritizeCssHealthCheck.php @@ -0,0 +1,28 @@ +id = 'newfold-prioritize-critical-css'; + $this->title = esc_html__( 'Prioritize Critical CSS', 'newfold-performance-module' ); + $this->passing_text = esc_html__( 'Critical CSS is prioritized', 'newfold-performance-module' ); + $this->failing_text = esc_html__( 'Critical CSS is not prioritized', 'newfold-performance-module' ); + $this->description = esc_html__( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'newfold-performance-module' ); + } + + /** + * Test if critical CSS is prioritized. + * + * @return bool + */ + public function test() { + return get_option( 'jetpack_boost_status_critical-css', false ); + } +} diff --git a/includes/Performance.php b/includes/Performance.php index 863ca6b..19ca7e9 100644 --- a/includes/Performance.php +++ b/includes/Performance.php @@ -10,10 +10,7 @@ use NewfoldLabs\WP\Module\Performance\Images\ImageManager; use NewfoldLabs\WP\Module\Performance\RestApi\RestApi; use NewfoldLabs\WP\Module\Performance\Data\Constants; -use NewfoldLabs\WP\Module\Performance\CacheTypes\Browser; -use NewfoldLabs\WP\Module\Performance\CacheTypes\Cloudflare; -use NewfoldLabs\WP\Module\Performance\CacheTypes\File; -use NewfoldLabs\WP\Module\Performance\CacheTypes\Skip404; +use NewfoldLabs\WP\Module\Performance\HealthChecks; use Automattic\Jetpack\Current_Plan; @@ -80,22 +77,18 @@ public function __construct( Container $container ) { $this->hooks( $container ); - $cacheManager = new CacheManager( $container ); - $cachePurger = new CachePurgingService( $cacheManager->getInstances() ); - $healthCheckManager = new HealthCheckManager( $container ); - $healthChecks = new HealthChecks( $container ); + $cacheManager = new CacheManager( $container ); + $cachePurger = new CachePurgingService( $cacheManager->getInstances() ); new Constants( $container ); new ImageManager( $container ); + new HealthChecks( $container ); - $container->set( 'healthCheckManager', $healthCheckManager ); - $healthChecks->add_health_checks(); + new LinkPrefetch( $container ); + new CacheExclusion( $container ); add_action( 'admin_bar_menu', array( $this, 'adminBarMenu' ), 100 ); add_action( 'admin_menu', array( $this, 'add_sub_menu_page' ) ); - new LinkPrefetch( $container ); - new CacheExclusion( $container ); - $container->set( 'cachePurger', $cachePurger ); $container->set( 'hasMustUsePlugin', file_exists( WPMU_PLUGIN_DIR . '/endurance-page-cache.php' ) ); From 791c80bc232013c1dfea0b5c64cf3f917eb17191 Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Sun, 26 Jan 2025 23:01:05 -0600 Subject: [PATCH 23/24] Add PHPUnit bootstrap and configuration files, add Health Check tests. --- composer.json | 12 +- composer.lock | 2423 +++++++++++++++++-- patchwork.json | 6 + phpunit.xml | 24 + tests/phpunit/bootstrap.php | 11 + tests/phpunit/includes/HealthChecksTest.php | 384 +++ 6 files changed, 2636 insertions(+), 224 deletions(-) create mode 100644 patchwork.json create mode 100644 phpunit.xml create mode 100644 tests/phpunit/bootstrap.php create mode 100644 tests/phpunit/includes/HealthChecksTest.php diff --git a/composer.json b/composer.json index 8f9dfcf..85b6840 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,15 @@ ] } ], + + "scripts": { + "test": [ + "phpunit --bootstrap tests/phpunit/bootstrap.php" + ] + }, + "scripts-descriptions": { + "test": "Run phpunit tests" + }, "require": { "newfold-labs/wp-module-context": "^1.0", "wp-forge/collection": "^1.0.2", @@ -36,7 +45,8 @@ "newfold-labs/wp-module-installer": "^1.3.0" }, "require-dev": { - "newfold-labs/wp-php-standards": "^1.2.4" + "newfold-labs/wp-php-standards": "^1.2.4", + "10up/wp_mock": "^1.0" }, "config": { "allow-plugins": { diff --git a/composer.lock b/composer.lock index 0003c07..609d6a9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9602237f7a761fdd4d6a07c7e39e5a91", + "content-hash": "ca2c8e02a0e2bd4dc2e2ec57eeb69aef", "packages": [ { "name": "doctrine/inflector", @@ -815,6 +815,108 @@ } ], "packages-dev": [ + { + "name": "10up/wp_mock", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/10up/wp_mock.git", + "reference": "48b7f22934a4351e45e336f09263ee27fc9ddcbe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/10up/wp_mock/zipball/48b7f22934a4351e45e336f09263ee27fc9ddcbe", + "reference": "48b7f22934a4351e45e336f09263ee27fc9ddcbe", + "shasum": "" + }, + "require": { + "antecedent/patchwork": "^2.1", + "mockery/mockery": "^1.6", + "php": ">=7.4 < 9", + "phpunit/phpunit": "^9.6" + }, + "require-dev": { + "behat/behat": "^v3.11.0", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "friendsofphp/php-cs-fixer": "^3.4", + "php-coveralls/php-coveralls": "^v2.7", + "php-stubs/wordpress-globals": "^0.2", + "php-stubs/wordpress-stubs": "^6.3", + "phpcompatibility/php-compatibility": "^9.3", + "phpstan/phpstan": "^1.10", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-phpunit": "^1.3", + "sebastian/comparator": "^4.0.8", + "sempro/phpunit-pretty-print": "^1.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "WP_Mock\\": "./php/WP_Mock" + }, + "classmap": [ + "php/WP_Mock.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "A mocking library to take the pain out of unit testing for WordPress", + "support": { + "issues": "https://github.com/10up/wp_mock/issues", + "source": "https://github.com/10up/wp_mock/tree/1.0.1" + }, + "time": "2024-01-22T02:22:57+00:00" + }, + { + "name": "antecedent/patchwork", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/antecedent/patchwork.git", + "reference": "1bf183a3e1bd094f231a2128b9ecc5363c269245" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/1bf183a3e1bd094f231a2128b9ecc5363c269245", + "reference": "1bf183a3e1bd094f231a2128b9ecc5363c269245", + "shasum": "" + }, + "require": { + "php": ">=7.1.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignas Rudaitis", + "email": "ignas.rudaitis@gmail.com" + } + ], + "description": "Method redefinition (monkey-patching) functionality for PHP.", + "homepage": "https://antecedent.github.io/patchwork/", + "keywords": [ + "aop", + "aspect", + "interception", + "monkeypatching", + "redefinition", + "runkit", + "testing" + ], + "support": { + "issues": "https://github.com/antecedent/patchwork/issues", + "source": "https://github.com/antecedent/patchwork/tree/2.2.1" + }, + "time": "2024-12-11T10:19:54+00:00" + }, { "name": "dealerdirect/phpcodesniffer-composer-installer", "version": "v1.0.0", @@ -893,6 +995,270 @@ }, "time": "2023-01-05T11:28:13+00:00" }, + { + "name": "doctrine/instantiator", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "doctrine/coding-standard": "^11", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2022-12-30T00:23:10+00:00" + }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0|^8.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "^1.4 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "support": { + "issues": "https://github.com/hamcrest/hamcrest-php/issues", + "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1" + }, + "time": "2020-07-09T08:09:16+00:00" + }, + { + "name": "mockery/mockery", + "version": "1.6.12", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "1f4efdd7d3beafe9807b08156dfcb176d18f1699" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/1f4efdd7d3beafe9807b08156dfcb176d18f1699", + "reference": "1f4efdd7d3beafe9807b08156dfcb176d18f1699", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "^2.0.1", + "lib-pcre": ">=7.0", + "php": ">=7.3" + }, + "conflict": { + "phpunit/phpunit": "<8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5 || ^9.6.17", + "symplify/easy-coding-standard": "^12.1.14" + }, + "type": "library", + "autoload": { + "files": [ + "library/helpers.php", + "library/Mockery.php" + ], + "psr-4": { + "Mockery\\": "library/Mockery" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "https://github.com/padraic", + "role": "Author" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "https://davedevelopment.co.uk", + "role": "Developer" + }, + { + "name": "Nathanael Esayeas", + "email": "nathanael.esayeas@protonmail.com", + "homepage": "https://github.com/ghostwriter", + "role": "Lead Developer" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "support": { + "docs": "https://docs.mockery.io/", + "issues": "https://github.com/mockery/mockery/issues", + "rss": "https://github.com/mockery/mockery/releases.atom", + "security": "https://github.com/mockery/mockery/security/advisories", + "source": "https://github.com/mockery/mockery" + }, + "time": "2024-05-16T03:13:13+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.12.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3 <3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2024-11-08T17:47:46+00:00" + }, { "name": "newfold-labs/wp-php-standards", "version": "1.2.4", @@ -931,374 +1297,1935 @@ "time": "2024-07-22T23:16:21+00:00" }, { - "name": "phpcompatibility/php-compatibility", - "version": "9.3.5", + "name": "nikic/php-parser", + "version": "v5.4.0", "source": { "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "447a020a1f875a434d62f2a401f53b82a396e494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", - "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494", + "reference": "447a020a1f875a434d62f2a401f53b82a396e494", "shasum": "" }, "require": { - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" - }, - "conflict": { - "squizlabs/php_codesniffer": "2.6.2" + "ext-ctype": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "php": ">=7.4" }, "require-dev": { - "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^9.0" }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } }, - "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0-or-later" + "BSD-3-Clause" ], "authors": [ { - "name": "Wim Godden", - "homepage": "https://github.com/wimg", - "role": "lead" - }, - { - "name": "Juliette Reinders Folmer", - "homepage": "https://github.com/jrfnl", - "role": "lead" - }, - { - "name": "Contributors", - "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + "name": "Nikita Popov" } ], - "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", - "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "description": "A PHP parser written in PHP", "keywords": [ - "compatibility", - "phpcs", - "standards" + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0" + }, + "time": "2024-12-30T11:07:19+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "54750ef60c58e43759730615a392c31c80e23176" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.3.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibility" + }, + "time": "2019-12-27T09:44:58+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-paragonie", + "version": "1.3.3", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", + "reference": "293975b465e0e709b571cbf0c957c6c0a7b9a2ac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/293975b465e0e709b571cbf0c957c6c0a7b9a2ac", + "reference": "293975b465e0e709b571cbf0c957c6c0a7b9a2ac", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "paragonie/random_compat": "dev-master", + "paragonie/sodium_compat": "dev-master" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "paragonie", + "phpcs", + "polyfill", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", + "security": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/security/policy", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" + }, + "funding": [ + { + "url": "https://github.com/PHPCompatibility", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-04-24T21:30:46+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-wp", + "version": "2.1.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", + "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/01c1ff2704a58e46f0cb1ca9d06aee07b3589082", + "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0", + "phpcompatibility/phpcompatibility-paragonie": "^1.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "phpcs", + "standards", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", + "security": "https://github.com/PHPCompatibility/PHPCompatibilityWP/security/policy", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + }, + "funding": [ + { + "url": "https://github.com/PHPCompatibility", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-04-24T21:37:59+00:00" + }, + { + "name": "phpcsstandards/phpcsextra", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", + "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", + "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.0.9", + "squizlabs/php_codesniffer": "^3.8.0" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "phpcsstandards/phpcsdevtools": "^1.2.1", + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" + } + ], + "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSExtra" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2023-12-08T16:49:07+00:00" + }, + { + "name": "phpcsstandards/phpcsutils", + "version": "1.0.12", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/87b233b00daf83fb70f40c9a28692be017ea7c6c", + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.10.0 || 4.0.x-dev@dev" + }, + "require-dev": { + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" + } + ], + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "phpcs3", + "standards", + "static analysis", + "tokens", + "utility" + ], + "support": { + "docs": "https://phpcsutils.com/", + "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSUtils" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-05-20T13:34:27+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "9.2.32", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.19.1 || ^5.1.0", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.6" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "9.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-08-22T04:23:01+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-12-02T12:48:52+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.6.22", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f80235cb4d3caa59ae09be3adf1ded27521d1a9c", + "reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.5.0 || ^2", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.12.1", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", + "php": ">=7.3", + "phpunit/php-code-coverage": "^9.2.32", + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", + "sebastian/comparator": "^4.0.8", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", + "sebastian/version": "^3.0.2" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.6-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.22" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2024-12-05T13:48:26+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:27:43+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:30:19+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2022-09-14T12:41:17+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:19:30+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:30:58+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:03:51+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:33:00+00:00" + }, + { + "name": "sebastian/global-state", + "version": "5.0.7", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:35:11+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:20:34+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:12:34+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibility" + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" }, - "time": "2019-12-27T09:44:58+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:14:26+00:00" }, { - "name": "phpcompatibility/phpcompatibility-paragonie", - "version": "1.3.3", + "name": "sebastian/recursion-context", + "version": "4.0.5", "source": { "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", - "reference": "293975b465e0e709b571cbf0c957c6c0a7b9a2ac" + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/293975b465e0e709b571cbf0c957c6c0a7b9a2ac", - "reference": "293975b465e0e709b571cbf0c957c6c0a7b9a2ac", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", "shasum": "" }, "require": { - "phpcompatibility/php-compatibility": "^9.0" + "php": ">=7.3" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "paragonie/random_compat": "dev-master", - "paragonie/sodium_compat": "dev-master" + "phpunit/phpunit": "^9.3" }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] }, - "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0-or-later" + "BSD-3-Clause" ], "authors": [ { - "name": "Wim Godden", - "role": "lead" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" }, { - "name": "Juliette Reinders Folmer", - "role": "lead" + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" } ], - "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", - "homepage": "http://phpcompatibility.com/", - "keywords": [ - "compatibility", - "paragonie", - "phpcs", - "polyfill", - "standards", - "static analysis" - ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", - "security": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/security/policy", - "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" }, "funding": [ { - "url": "https://github.com/PHPCompatibility", - "type": "github" - }, - { - "url": "https://github.com/jrfnl", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://opencollective.com/php_codesniffer", - "type": "open_collective" } ], - "time": "2024-04-24T21:30:46+00:00" + "time": "2023-02-03T06:07:39+00:00" }, { - "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.5", + "name": "sebastian/resource-operations", + "version": "3.0.4", "source": { "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082" + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/01c1ff2704a58e46f0cb1ca9d06aee07b3589082", - "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", "shasum": "" }, "require": { - "phpcompatibility/php-compatibility": "^9.0", - "phpcompatibility/phpcompatibility-paragonie": "^1.0" + "php": ">=7.3" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^1.0" + "phpunit/phpunit": "^9.0" }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] }, - "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0-or-later" + "BSD-3-Clause" ], "authors": [ { - "name": "Wim Godden", - "role": "lead" - }, - { - "name": "Juliette Reinders Folmer", - "role": "lead" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], - "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", - "homepage": "http://phpcompatibility.com/", - "keywords": [ - "compatibility", - "phpcs", - "standards", - "static analysis", - "wordpress" - ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", - "security": "https://github.com/PHPCompatibility/PHPCompatibilityWP/security/policy", - "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" }, "funding": [ { - "url": "https://github.com/PHPCompatibility", - "type": "github" - }, - { - "url": "https://github.com/jrfnl", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://opencollective.com/php_codesniffer", - "type": "open_collective" } ], - "time": "2024-04-24T21:37:59+00:00" + "time": "2024-03-14T16:00:52+00:00" }, { - "name": "phpcsstandards/phpcsextra", - "version": "1.2.1", + "name": "sebastian/type", + "version": "3.2.1", "source": { "type": "git", - "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", - "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489" + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", - "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", "shasum": "" }, "require": { - "php": ">=5.4", - "phpcsstandards/phpcsutils": "^1.0.9", - "squizlabs/php_codesniffer": "^3.8.0" + "php": ">=7.3" }, "require-dev": { - "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcsstandards/phpcsdevcs": "^1.1.6", - "phpcsstandards/phpcsdevtools": "^1.2.1", - "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.5" }, - "type": "phpcodesniffer-standard", + "type": "library", "extra": { "branch-alias": { - "dev-stable": "1.x-dev", - "dev-develop": "1.x-dev" + "dev-master": "3.2-dev" } }, + "autoload": { + "classmap": [ + "src/" + ] + }, "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0-or-later" + "BSD-3-Clause" ], "authors": [ { - "name": "Juliette Reinders Folmer", - "homepage": "https://github.com/jrfnl", + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", "role": "lead" - }, - { - "name": "Contributors", - "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" } ], - "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", - "keywords": [ - "PHP_CodeSniffer", - "phpcbf", - "phpcodesniffer-standard", - "phpcs", - "standards", - "static analysis" - ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", "support": { - "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", - "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", - "source": "https://github.com/PHPCSStandards/PHPCSExtra" + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" }, "funding": [ { - "url": "https://github.com/PHPCSStandards", - "type": "github" - }, - { - "url": "https://github.com/jrfnl", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://opencollective.com/php_codesniffer", - "type": "open_collective" } ], - "time": "2023-12-08T16:49:07+00:00" + "time": "2023-02-03T06:13:03+00:00" }, { - "name": "phpcsstandards/phpcsutils", - "version": "1.0.12", + "name": "sebastian/version", + "version": "3.0.2", "source": { "type": "git", - "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c" + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/87b233b00daf83fb70f40c9a28692be017ea7c6c", - "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", - "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.10.0 || 4.0.x-dev@dev" + "php": ">=7.3" }, - "require-dev": { - "ext-filter": "*", - "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcsstandards/phpcsdevcs": "^1.1.6", - "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" - }, - "type": "phpcodesniffer-standard", + "type": "library", "extra": { "branch-alias": { - "dev-stable": "1.x-dev", - "dev-develop": "1.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { "classmap": [ - "PHPCSUtils/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0-or-later" + "BSD-3-Clause" ], "authors": [ { - "name": "Juliette Reinders Folmer", - "homepage": "https://github.com/jrfnl", + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", "role": "lead" - }, - { - "name": "Contributors", - "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" } ], - "description": "A suite of utility functions for use with PHP_CodeSniffer", - "homepage": "https://phpcsutils.com/", - "keywords": [ - "PHP_CodeSniffer", - "phpcbf", - "phpcodesniffer-standard", - "phpcs", - "phpcs3", - "standards", - "static analysis", - "tokens", - "utility" - ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", "support": { - "docs": "https://phpcsutils.com/", - "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", - "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", - "source": "https://github.com/PHPCSStandards/PHPCSUtils" + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" }, "funding": [ { - "url": "https://github.com/PHPCSStandards", - "type": "github" - }, - { - "url": "https://github.com/jrfnl", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://opencollective.com/php_codesniffer", - "type": "open_collective" } ], - "time": "2024-05-20T13:34:27+00:00" + "time": "2020-09-28T06:39:44+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -1380,6 +3307,56 @@ ], "time": "2024-12-11T16:04:26+00:00" }, + { + "name": "theseer/tokenizer", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:36:25+00:00" + }, { "name": "wp-coding-standards/wpcs", "version": "3.1.0", @@ -1454,5 +3431,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/patchwork.json b/patchwork.json new file mode 100644 index 0000000..0947abb --- /dev/null +++ b/patchwork.json @@ -0,0 +1,6 @@ +{ + "redefinable-internals": [ + "defined", + "constant" + ] +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..729d50f --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,24 @@ + + + + + + + + + tests/phpunit + + + + + includes/ + + + diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php new file mode 100644 index 0000000..23bf4b3 --- /dev/null +++ b/tests/phpunit/bootstrap.php @@ -0,0 +1,11 @@ +assertTrue( $health_check->test(), 'Autosave interval should pass when set to 30 seconds or more.' ); + + Patchwork\redefine( + 'constant', + function ( $constant_name ) { + if ( 'AUTOSAVE_INTERVAL' === $constant_name ) { + return 10; + } + return Patchwork\relay(); + } + ); + + $this->assertFalse( $health_check->test(), 'Autosave interval should fail when set to less than 30 seconds.' ); + } + + /** + * Test PostRevisionsHealthCheck. + */ + public function test_post_revisions_health_check() { + Patchwork\redefine( + 'defined', + function ( $constant_name ) { + if ( 'WP_POST_REVISIONS' === $constant_name ) { + return true; + } + return Patchwork\relay(); + } + ); + + Patchwork\redefine( + 'constant', + function ( $constant_name ) { + if ( 'WP_POST_REVISIONS' === $constant_name ) { + return 5; + } + return Patchwork\relay(); + } + ); + + $health_check = new PostRevisionsHealthCheck(); + $this->assertTrue( $health_check->test(), 'Post revisions should pass when limited to 5 or less.' ); + + Patchwork\redefine( + 'constant', + function ( $constant_name ) { + if ( 'WP_POST_REVISIONS' === $constant_name ) { + return 10; + } + return Patchwork\relay(); + } + ); + + $this->assertFalse( $health_check->test(), 'Post revisions should fail when set to more than 5.' ); + } + + /** + * Test EmptyTrashDaysHealthCheck. + */ + public function test_empty_trash_days_health_check() { + Patchwork\redefine( + 'defined', + function ( $constant_name ) { + if ( 'EMPTY_TRASH_DAYS' === $constant_name ) { + return true; + } + return Patchwork\relay(); + } + ); + + Patchwork\redefine( + 'constant', + function ( $constant_name ) { + if ( 'EMPTY_TRASH_DAYS' === $constant_name ) { + return 30; + } + return Patchwork\relay(); + } + ); + + $health_check = new EmptyTrashDaysHealthCheck(); + $this->assertTrue( $health_check->test(), 'Empty trash days should pass when set to 30 days or less.' ); + + Patchwork\redefine( + 'constant', + function ( $constant_name ) { + if ( 'EMPTY_TRASH_DAYS' === $constant_name ) { + return 31; + } + return Patchwork\relay(); + } + ); + + $this->assertFalse( $health_check->test(), 'Empty trash days should fail when set to more than 30 days.' ); + } + + /** + * Test BrowserCachingHealthCheck. + */ + public function test_browser_caching_health_check() { + WP_Mock::userFunction( 'get_option' ) + ->with( 'newfold_cache_level' ) + ->once() + ->andReturn( 2 ); + + $health_check = new BrowserCachingHealthCheck(); + $this->assertTrue( $health_check->test(), 'Browser caching should pass when newfold_cache_level is 1 or more.' ); + + WP_Mock::userFunction( 'get_option' ) + ->with( 'newfold_cache_level' ) + ->once() + ->andReturn( 0 ); + + $this->assertFalse( $health_check->test(), 'Browser caching should fail when newfold_cache_level is less than 1.' ); + } + + /** + * Test LazyLoadingHealthCheck. + */ + public function test_lazy_loading_health_check() { + WP_Mock::userFunction( 'get_option' ) + ->with( 'nfd_image_optimization', array() ) + ->once() + ->andReturn( array( 'lazy_loading' => array( 'enabled' => true ) ) ); + + $health_check = new LazyLoadingHealthCheck(); + $this->assertTrue( $health_check->test(), 'Lazy loading should pass when enabled.' ); + + WP_Mock::userFunction( 'get_option' ) + ->with( 'nfd_image_optimization', array() ) + ->once() + ->andReturn( array( 'lazy_loading' => array( 'enabled' => false ) ) ); + + $this->assertFalse( $health_check->test(), 'Lazy loading should fail when not enabled.' ); + } + + /** + * Test LinkPrefetchHealthCheck. + */ + public function test_link_prefetch_health_check() { + WP_Mock::userFunction( 'get_option' ) + ->with( 'nfd_link_prefetch_settings', array() ) + ->once() + ->andReturn( array( 'activeOnDesktop' => true ) ); + + $health_check = new LinkPrefetchHealthCheck(); + $this->assertTrue( $health_check->test(), 'Link prefetch should pass when active on desktop.' ); + + WP_Mock::userFunction( 'get_option' ) + ->with( 'nfd_link_prefetch_settings', array() ) + ->once() + ->andReturn( array( 'activeOnDesktop' => false ) ); + + $this->assertFalse( $health_check->test(), 'Link prefetch should fail when not active on desktop.' ); + } + + /** + * Test PageCachingHealthCheck. + */ + public function test_page_caching_health_check() { + WP_Mock::userFunction( 'get_option' ) + ->with( 'newfold_cache_level' ) + ->once() + ->andReturn( 2 ); + + $health_check = new PageCachingHealthCheck(); + $this->assertTrue( $health_check->test(), 'Page caching should pass when newfold_cache_level is 2 or more.' ); + + WP_Mock::userFunction( 'get_option' ) + ->with( 'newfold_cache_level' ) + ->once() + ->andReturn( 0 ); + + $this->assertFalse( $health_check->test(), 'Page caching should fail when newfold_cache_level is less than 2.' ); + } + + /** + * Test ConcatenateCssHealthCheck. + */ + public function test_concatenate_css_health_check() { + WP_Mock::userFunction( 'get_option' ) + ->with( 'jetpack_boost_status_minify-css', false ) + ->once() + ->andReturn( true ); + + $health_check = new ConcatenateCssHealthCheck(); + $this->assertTrue( $health_check->test(), 'CSS concatenation should pass when enabled.' ); + + WP_Mock::userFunction( 'get_option' ) + ->with( 'jetpack_boost_status_minify-css', false ) + ->once() + ->andReturn( false ); + + $this->assertFalse( $health_check->test(), 'CSS concatenation should fail when not enabled.' ); + } + + /** + * Test ConcatenateJsHealthCheck. + */ + public function test_concatenate_js_health_check() { + WP_Mock::userFunction( 'get_option' ) + ->with( 'jetpack_boost_status_minify-js', false ) + ->once() + ->andReturn( true ); + + $health_check = new ConcatenateJsHealthCheck(); + $this->assertTrue( $health_check->test(), 'JS concatenation should pass when enabled.' ); + + WP_Mock::userFunction( 'get_option' ) + ->with( 'jetpack_boost_status_minify-js', false ) + ->once() + ->andReturn( false ); + + $this->assertFalse( $health_check->test(), 'JS concatenation should fail when not enabled.' ); + } + + /** + * Test CloudflareHealthCheck. + */ + public function test_cloudflare_health_check() { + $_SERVER['HTTP_CF_RAY'] = 'some-value'; + + $health_check = new CloudflareHealthCheck(); + $this->assertTrue( $health_check->test(), 'Cloudflare should pass when HTTP_CF_RAY is set.' ); + + unset( $_SERVER['HTTP_CF_RAY'] ); + + $this->assertFalse( $health_check->test(), 'Cloudflare should fail when HTTP_CF_RAY is not set.' ); + } + + /** + * Test PrioritizeCssHealthCheck. + */ + public function test_prioritize_css_health_check() { + WP_Mock::userFunction( 'get_option' ) + ->with( 'jetpack_boost_status_critical-css', false ) + ->once() + ->andReturn( true ); + + $health_check = new PrioritizeCssHealthCheck(); + $this->assertTrue( $health_check->test(), 'Prioritizing critical CSS should pass when enabled.' ); + + WP_Mock::userFunction( 'get_option' ) + ->with( 'jetpack_boost_status_critical-css', false ) + ->once() + ->andReturn( false ); + + $this->assertFalse( $health_check->test(), 'Prioritizing critical CSS should fail when not enabled.' ); + } + + /** + * Test DeferNonEssentialJsHealthCheck. + */ + public function test_defer_non_essential_js_health_check() { + WP_Mock::userFunction( 'get_option' ) + ->with( 'jetpack_boost_status_render-blocking-js', false ) + ->once() + ->andReturn( true ); + + $health_check = new DeferNonEssentialJsHealthCheck(); + $this->assertTrue( $health_check->test(), 'Deferring non-essential JS should pass when enabled.' ); + + WP_Mock::userFunction( 'get_option' ) + ->with( 'jetpack_boost_status_render-blocking-js', false ) + ->once() + ->andReturn( false ); + + $this->assertFalse( $health_check->test(), 'Deferring non-essential JS should fail when not enabled.' ); + } + + /** + * Test PersistentObjectCacheHealthCheck. + */ + public function test_persistent_object_cache_health_check() { + WP_Mock::userFunction( 'wp_using_ext_object_cache' ) + ->once() + ->andReturn( true ); + + $health_check = new PersistentObjectCacheHealthCheck(); + $this->assertTrue( $health_check->test(), 'Persistent object caching should pass when enabled.' ); + + WP_Mock::userFunction( 'wp_using_ext_object_cache' ) + ->once() + ->andReturn( false ); + + $this->assertFalse( $health_check->test(), 'Persistent object caching should fail when not enabled.' ); + } + + /** + * Test CronLockTimeoutHealthCheck. + */ + public function test_cron_lock_timeout_health_check() { + Patchwork\redefine( + 'defined', + function ( $constant_name ) { + if ( 'WP_CRON_LOCK_TIMEOUT' === $constant_name ) { + return true; + } + return Patchwork\relay(); + } + ); + + Patchwork\redefine( + 'constant', + function ( $constant_name ) { + if ( 'WP_CRON_LOCK_TIMEOUT' === $constant_name ) { + return 60; + } + return Patchwork\relay(); + } + ); + + $health_check = new CronLockTimeoutHealthCheck(); + $this->assertTrue( $health_check->test(), 'Cron lock timeout should pass when set to 60 seconds or less.' ); + + Patchwork\redefine( + 'constant', + function ( $constant_name ) { + if ( 'WP_CRON_LOCK_TIMEOUT' === $constant_name ) { + return 600; + } + return Patchwork\relay(); + } + ); + + $this->assertFalse( $health_check->test(), 'Cron lock timeout should fail when set to more than 60 seconds.' ); + } +} From aee37f123dc27fbb5e50afcea40de4d4ad3984e5 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Wed, 29 Jan 2025 14:11:10 +0530 Subject: [PATCH 24/24] Rename i18n namespace --- includes/HealthChecks/AutosaveIntervalHealthCheck.php | 8 ++++---- includes/HealthChecks/BrowserCachingHealthCheck.php | 8 ++++---- includes/HealthChecks/CloudflareHealthCheck.php | 8 ++++---- includes/HealthChecks/ConcatenateCssHealthCheck.php | 8 ++++---- includes/HealthChecks/ConcatenateJsHealthCheck.php | 8 ++++---- includes/HealthChecks/CronLockTimeoutHealthCheck.php | 8 ++++---- .../HealthChecks/DeferNonEssentialJsHealthCheck.php | 8 ++++---- includes/HealthChecks/EmptyTrashDaysHealthCheck.php | 8 ++++---- includes/HealthChecks/LazyLoadingHealthCheck.php | 8 ++++---- includes/HealthChecks/LinkPrefetchHealthCheck.php | 8 ++++---- includes/HealthChecks/PageCachingHealthCheck.php | 8 ++++---- includes/HealthChecks/PermalinksHealthCheck.php | 8 ++++---- .../HealthChecks/PersistentObjectCacheHealthCheck.php | 10 +++++----- includes/HealthChecks/PostRevisionsHealthCheck.php | 8 ++++---- includes/HealthChecks/PrioritizeCssHealthCheck.php | 8 ++++---- 15 files changed, 61 insertions(+), 61 deletions(-) diff --git a/includes/HealthChecks/AutosaveIntervalHealthCheck.php b/includes/HealthChecks/AutosaveIntervalHealthCheck.php index fc649cd..3c4beef 100644 --- a/includes/HealthChecks/AutosaveIntervalHealthCheck.php +++ b/includes/HealthChecks/AutosaveIntervalHealthCheck.php @@ -11,10 +11,10 @@ class AutosaveIntervalHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-autosave-interval'; - $this->title = esc_html__( 'Autosave Interval', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Autosaving is set to happen every 30 seconds or more', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Autosaving is set to be frequent, less than every 30 seconds', 'newfold-performance-module' ); - $this->description = esc_html__( 'Setting the autosave interval to a longer period can reduce server load. It is recommended to set it to 30 seconds or more.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Autosave Interval', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Autosaving is set to happen every 30 seconds or more', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Autosaving is set to be frequent, less than every 30 seconds', 'wp-module-performance' ); + $this->description = esc_html__( 'Setting the autosave interval to a longer period can reduce server load. It is recommended to set it to 30 seconds or more.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/BrowserCachingHealthCheck.php b/includes/HealthChecks/BrowserCachingHealthCheck.php index 009781e..32a844f 100644 --- a/includes/HealthChecks/BrowserCachingHealthCheck.php +++ b/includes/HealthChecks/BrowserCachingHealthCheck.php @@ -11,10 +11,10 @@ class BrowserCachingHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-browser-caching'; - $this->title = esc_html__( 'Browser Caching', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Browser caching is enabled', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Browser caching is disabled', 'newfold-performance-module' ); - $this->description = esc_html__( 'Enabling browser caching can improve performance by storing static assets in the browser for faster page loads.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Browser Caching', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Browser caching is enabled', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Browser caching is disabled', 'wp-module-performance' ); + $this->description = esc_html__( 'Enabling browser caching can improve performance by storing static assets in the browser for faster page loads.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/CloudflareHealthCheck.php b/includes/HealthChecks/CloudflareHealthCheck.php index 3c3381e..ac4d97e 100644 --- a/includes/HealthChecks/CloudflareHealthCheck.php +++ b/includes/HealthChecks/CloudflareHealthCheck.php @@ -11,10 +11,10 @@ class CloudflareHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-cloudflare'; - $this->title = esc_html__( 'Cloudflare enabled', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Cloudflare integration is enabled', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Cloudflare integration is disabled', 'newfold-performance-module' ); - $this->description = esc_html__( 'Cloudflare integration can improve performance and security.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Cloudflare enabled', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Cloudflare integration is enabled', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Cloudflare integration is disabled', 'wp-module-performance' ); + $this->description = esc_html__( 'Cloudflare integration can improve performance and security.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/ConcatenateCssHealthCheck.php b/includes/HealthChecks/ConcatenateCssHealthCheck.php index 624a304..e7a3be8 100644 --- a/includes/HealthChecks/ConcatenateCssHealthCheck.php +++ b/includes/HealthChecks/ConcatenateCssHealthCheck.php @@ -11,10 +11,10 @@ class ConcatenateCSSHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-concatenate-css'; - $this->title = esc_html__( 'Concatenate CSS', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'CSS files are concatenated', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'CSS files are not concatenated', 'newfold-performance-module' ); - $this->description = esc_html__( 'Concatenating CSS can improve performance by reducing the number of requests.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Concatenate CSS', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'CSS files are concatenated', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'CSS files are not concatenated', 'wp-module-performance' ); + $this->description = esc_html__( 'Concatenating CSS can improve performance by reducing the number of requests.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/ConcatenateJsHealthCheck.php b/includes/HealthChecks/ConcatenateJsHealthCheck.php index e5ee819..1b7f58e 100644 --- a/includes/HealthChecks/ConcatenateJsHealthCheck.php +++ b/includes/HealthChecks/ConcatenateJsHealthCheck.php @@ -11,10 +11,10 @@ class ConcatenateJsHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-concatenate-js'; - $this->title = esc_html__( 'Concatenate JavaScript', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'JavaScript files are concatenated', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'JavaScript files are not concatenated', 'newfold-performance-module' ); - $this->description = esc_html__( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Concatenate JavaScript', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'JavaScript files are concatenated', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'JavaScript files are not concatenated', 'wp-module-performance' ); + $this->description = esc_html__( 'Concatenating JavaScript can improve performance by reducing the number of requests.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/CronLockTimeoutHealthCheck.php b/includes/HealthChecks/CronLockTimeoutHealthCheck.php index 833fb02..b57066d 100644 --- a/includes/HealthChecks/CronLockTimeoutHealthCheck.php +++ b/includes/HealthChecks/CronLockTimeoutHealthCheck.php @@ -11,10 +11,10 @@ class CronLockTimeoutHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'wp-cron-lock-timeout'; - $this->title = esc_html__( 'WP Cron Lock Timeout', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Cron lock timeout is set to 60 seconds or less.', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Cron lock timeout is set to a high number.', 'newfold-performance-module' ); - $this->description = esc_html__( 'Cron lock timeout affects how long a cron job can run for. Setting it to a lower number can improve performance.', 'newfold-performance-module' ); + $this->title = esc_html__( 'WP Cron Lock Timeout', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Cron lock timeout is set to 60 seconds or less.', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Cron lock timeout is set to a high number.', 'wp-module-performance' ); + $this->description = esc_html__( 'Cron lock timeout affects how long a cron job can run for. Setting it to a lower number can improve performance.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/DeferNonEssentialJsHealthCheck.php b/includes/HealthChecks/DeferNonEssentialJsHealthCheck.php index 8cf2662..cd5fc25 100644 --- a/includes/HealthChecks/DeferNonEssentialJsHealthCheck.php +++ b/includes/HealthChecks/DeferNonEssentialJsHealthCheck.php @@ -11,10 +11,10 @@ class DeferNonEssentialJsHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-defer-non-essential-js'; - $this->title = esc_html__( 'Defer Non-Essential JavaScript', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Non-essential JavaScript is deferred', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Non-essential JavaScript is not deferred', 'newfold-performance-module' ); - $this->description = esc_html__( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Defer Non-Essential JavaScript', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Non-essential JavaScript is deferred', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Non-essential JavaScript is not deferred', 'wp-module-performance' ); + $this->description = esc_html__( 'JavaScript can be deferred to improve performance by loading it after the page has loaded.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/EmptyTrashDaysHealthCheck.php b/includes/HealthChecks/EmptyTrashDaysHealthCheck.php index 18942ec..90f21a4 100644 --- a/includes/HealthChecks/EmptyTrashDaysHealthCheck.php +++ b/includes/HealthChecks/EmptyTrashDaysHealthCheck.php @@ -11,10 +11,10 @@ class EmptyTrashDaysHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-empty-trash-days'; - $this->title = esc_html__( 'Empty Trash Days', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Trash is emptied every 30 days or less', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Trash is emptied less frequently than every 30 days.', 'newfold-performance-module' ); - $this->description = esc_html__( 'Emptying the trash more frequently can reduce database bloat.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Empty Trash Days', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Trash is emptied every 30 days or less', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Trash is emptied less frequently than every 30 days.', 'wp-module-performance' ); + $this->description = esc_html__( 'Emptying the trash more frequently can reduce database bloat.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/LazyLoadingHealthCheck.php b/includes/HealthChecks/LazyLoadingHealthCheck.php index 9e46cc6..84d2277 100644 --- a/includes/HealthChecks/LazyLoadingHealthCheck.php +++ b/includes/HealthChecks/LazyLoadingHealthCheck.php @@ -11,10 +11,10 @@ class LazyLoadingHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-lazy-loading'; - $this->title = esc_html__( 'Lazy Loading', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Lazy loading is enabled', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Lazy loading is disabled', 'newfold-performance-module' ); - $this->description = esc_html__( 'Lazy loading can improve performance by only loading images when they are in view.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Lazy Loading', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Lazy loading is enabled', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Lazy loading is disabled', 'wp-module-performance' ); + $this->description = esc_html__( 'Lazy loading can improve performance by only loading images when they are in view.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/LinkPrefetchHealthCheck.php b/includes/HealthChecks/LinkPrefetchHealthCheck.php index e7e23e6..ed7acfa 100644 --- a/includes/HealthChecks/LinkPrefetchHealthCheck.php +++ b/includes/HealthChecks/LinkPrefetchHealthCheck.php @@ -11,10 +11,10 @@ class LinkPrefetchHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-link-prefetch'; - $this->title = esc_html__( 'Link Prefetching', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Link prefetching is enabled', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Link prefetching is disabled', 'newfold-performance-module' ); - $this->description = esc_html__( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Link Prefetching', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Link prefetching is enabled', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Link prefetching is disabled', 'wp-module-performance' ); + $this->description = esc_html__( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/PageCachingHealthCheck.php b/includes/HealthChecks/PageCachingHealthCheck.php index 09b1d4f..36f3e8a 100644 --- a/includes/HealthChecks/PageCachingHealthCheck.php +++ b/includes/HealthChecks/PageCachingHealthCheck.php @@ -11,10 +11,10 @@ class PageCachingHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-page-caching'; - $this->title = esc_html__( 'Page Caching', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Page caching is enabled', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Page caching is disabled', 'newfold-performance-module' ); - $this->description = esc_html__( 'Page caching can improve performance by bypassing PHP and database queries for faster page loads.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Page Caching', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Page caching is enabled', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Page caching is disabled', 'wp-module-performance' ); + $this->description = esc_html__( 'Page caching can improve performance by bypassing PHP and database queries for faster page loads.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/PermalinksHealthCheck.php b/includes/HealthChecks/PermalinksHealthCheck.php index 663c5f7..11c1174 100644 --- a/includes/HealthChecks/PermalinksHealthCheck.php +++ b/includes/HealthChecks/PermalinksHealthCheck.php @@ -11,10 +11,10 @@ class PermalinksHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-permalinks'; - $this->title = esc_html__( 'Permalinks', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Permalinks are pretty', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Permalinks are not set up', 'newfold-performance-module' ); - $this->description = esc_html__( 'Setting permalinks to anything other than plain can improve performance and SEO.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Permalinks', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Permalinks are pretty', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Permalinks are not set up', 'wp-module-performance' ); + $this->description = esc_html__( 'Setting permalinks to anything other than plain can improve performance and SEO.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/PersistentObjectCacheHealthCheck.php b/includes/HealthChecks/PersistentObjectCacheHealthCheck.php index c180d77..0926c0c 100644 --- a/includes/HealthChecks/PersistentObjectCacheHealthCheck.php +++ b/includes/HealthChecks/PersistentObjectCacheHealthCheck.php @@ -11,14 +11,14 @@ class PersistentObjectCacheHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'persistent_object_cache'; // Same as the core ID so that we can override the core health check. - $this->title = esc_html__( 'Object Caching', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Object caching is enabled', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Object caching is disabled', 'newfold-performance-module' ); - $this->description = esc_html__( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Object Caching', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Object caching is enabled', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Object caching is disabled', 'wp-module-performance' ); + $this->description = esc_html__( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'wp-module-performance' ); $this->actions = sprintf( '%2$s (%3$s)', 'https://www.bluehost.com/help/article/object-caching', - esc_html__( 'Learn more about object caching', 'newfold-performance-module' ), + esc_html__( 'Learn more about object caching', 'wp-module-performance' ), __( 'opens in a new tab', 'newfold-module-performance' ) ); } diff --git a/includes/HealthChecks/PostRevisionsHealthCheck.php b/includes/HealthChecks/PostRevisionsHealthCheck.php index 3db60ef..d1a2e57 100644 --- a/includes/HealthChecks/PostRevisionsHealthCheck.php +++ b/includes/HealthChecks/PostRevisionsHealthCheck.php @@ -11,10 +11,10 @@ class PostRevisionsHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-post-revisions'; - $this->title = esc_html__( 'Post Revisions', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Number of post revisions is limited to 5 or less', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Number of post revisions is set to a high number', 'newfold-performance-module' ); - $this->description = esc_html__( 'Setting the number of post revisions to a lower number can reduce database bloat.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Post Revisions', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Number of post revisions is limited to 5 or less', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Number of post revisions is set to a high number', 'wp-module-performance' ); + $this->description = esc_html__( 'Setting the number of post revisions to a lower number can reduce database bloat.', 'wp-module-performance' ); } /** diff --git a/includes/HealthChecks/PrioritizeCssHealthCheck.php b/includes/HealthChecks/PrioritizeCssHealthCheck.php index cf88b6c..969c32d 100644 --- a/includes/HealthChecks/PrioritizeCssHealthCheck.php +++ b/includes/HealthChecks/PrioritizeCssHealthCheck.php @@ -11,10 +11,10 @@ class PrioritizeCssHealthCheck extends HealthCheck { */ public function __construct() { $this->id = 'newfold-prioritize-critical-css'; - $this->title = esc_html__( 'Prioritize Critical CSS', 'newfold-performance-module' ); - $this->passing_text = esc_html__( 'Critical CSS is prioritized', 'newfold-performance-module' ); - $this->failing_text = esc_html__( 'Critical CSS is not prioritized', 'newfold-performance-module' ); - $this->description = esc_html__( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'newfold-performance-module' ); + $this->title = esc_html__( 'Prioritize Critical CSS', 'wp-module-performance' ); + $this->passing_text = esc_html__( 'Critical CSS is prioritized', 'wp-module-performance' ); + $this->failing_text = esc_html__( 'Critical CSS is not prioritized', 'wp-module-performance' ); + $this->description = esc_html__( 'Prioritizing critical CSS can improve performance by loading the most important CSS first.', 'wp-module-performance' ); } /**