Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 27 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| HealthChecks | |
0.00% |
0 / 27 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| add_hooks | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| add_health_checks | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace NewfoldLabs\WP\Module\Performance; |
| 4 | |
| 5 | use NewfoldLabs\WP\Module\Performance\HealthChecks\AutosaveIntervalHealthCheck; |
| 6 | use NewfoldLabs\WP\Module\Performance\HealthChecks\BrowserCachingHealthCheck; |
| 7 | use NewfoldLabs\WP\Module\Performance\HealthChecks\CloudflareHealthCheck; |
| 8 | use NewfoldLabs\WP\Module\Performance\HealthChecks\ConcatenateCssHealthCheck; |
| 9 | use NewfoldLabs\WP\Module\Performance\HealthChecks\ConcatenateJsHealthCheck; |
| 10 | use NewfoldLabs\WP\Module\Performance\HealthChecks\CronLockTimeoutHealthCheck; |
| 11 | use NewfoldLabs\WP\Module\Performance\HealthChecks\DeferNonEssentialJsHealthCheck; |
| 12 | use NewfoldLabs\WP\Module\Performance\HealthChecks\EmptyTrashDaysHealthCheck; |
| 13 | use NewfoldLabs\WP\Module\Performance\HealthChecks\LazyLoadingHealthCheck; |
| 14 | use NewfoldLabs\WP\Module\Performance\HealthChecks\LinkPrefetchHealthCheck; |
| 15 | use NewfoldLabs\WP\Module\Performance\HealthChecks\PageCachingHealthCheck; |
| 16 | use NewfoldLabs\WP\Module\Performance\HealthChecks\PermalinksHealthCheck; |
| 17 | use NewfoldLabs\WP\Module\Performance\HealthChecks\PersistentObjectCacheHealthCheck; |
| 18 | use NewfoldLabs\WP\Module\Performance\HealthChecks\PostRevisionsHealthCheck; |
| 19 | use NewfoldLabs\WP\Module\Performance\HealthChecks\PrioritizeCssHealthCheck; |
| 20 | |
| 21 | /** |
| 22 | * Add performance health checks. |
| 23 | */ |
| 24 | class HealthChecks { |
| 25 | /** |
| 26 | * Container. |
| 27 | * |
| 28 | * @var Container |
| 29 | */ |
| 30 | private $container; |
| 31 | |
| 32 | /** |
| 33 | * Constructor. |
| 34 | * |
| 35 | * @param Container $container Container. |
| 36 | */ |
| 37 | public function __construct( $container ) { |
| 38 | $this->container = $container; |
| 39 | if ( function_exists( 'add_filter' ) ) { |
| 40 | $this->add_hooks(); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Add hooks. |
| 46 | */ |
| 47 | public function add_hooks() { |
| 48 | add_filter( 'site_status_tests', array( $this, 'add_health_checks' ) ); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Add health checks. |
| 53 | * |
| 54 | * @param array $tests Site status tests. |
| 55 | * |
| 56 | * @return array Site status tests. |
| 57 | */ |
| 58 | public function add_health_checks( $tests ) { |
| 59 | $health_checks = array( |
| 60 | new AutosaveIntervalHealthCheck(), |
| 61 | new PostRevisionsHealthCheck(), |
| 62 | new AutosaveIntervalHealthCheck(), |
| 63 | new BrowserCachingHealthCheck(), |
| 64 | new CloudflareHealthCheck(), |
| 65 | new ConcatenateCssHealthCheck(), |
| 66 | new ConcatenateJsHealthCheck(), |
| 67 | new CronLockTimeoutHealthCheck(), |
| 68 | new DeferNonEssentialJsHealthCheck(), |
| 69 | new EmptyTrashDaysHealthCheck(), |
| 70 | new LazyLoadingHealthCheck(), |
| 71 | new LinkPrefetchHealthCheck(), |
| 72 | new PageCachingHealthCheck(), |
| 73 | new PermalinksHealthCheck(), |
| 74 | new PostRevisionsHealthCheck(), |
| 75 | new PrioritizeCssHealthCheck(), |
| 76 | ); |
| 77 | |
| 78 | // Override the core persistent object cache health check, but only for Bluehost. |
| 79 | if ( 'bluehost' === $this->container->plugin()->brand ) { |
| 80 | $health_checks[] = new PersistentObjectCacheHealthCheck(); |
| 81 | } |
| 82 | |
| 83 | foreach ( $health_checks as $health_check ) { |
| 84 | $tests = $health_check->register_health_check( $tests ); |
| 85 | } |
| 86 | |
| 87 | return $tests; |
| 88 | } |
| 89 | } |