Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
PersistentObjectCacheHealthCheck
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
1
 test
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace NewfoldLabs\WP\Module\Performance\HealthChecks;
4
5/**
6 * Health check for persistent object cache.
7 */
8class PersistentObjectCacheHealthCheck extends HealthCheck {
9    /**
10     * Constructor.
11     */
12    public function __construct() {
13        $this->id           = 'persistent_object_cache'; // Same as the core ID so that we can override the core health check.
14        $this->title        = esc_html__( 'Object Caching', 'wp-module-performance' );
15        $this->passing_text = esc_html__( 'Object caching is enabled', 'wp-module-performance' );
16        $this->failing_text = esc_html__( 'Object caching is disabled', 'wp-module-performance' );
17        $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' );
18        $this->actions      = sprintf(
19            '<a href="%1$s" target="_blank" rel="noopener">%2$s</a><span class="screen-reader-text"> (%3$s)</span><span aria-hidden="true" class="dashicons dashicons-external"></span>',
20            'https://www.bluehost.com/help/article/object-caching',
21            esc_html__( 'Learn more about object caching', 'wp-module-performance' ),
22            __( 'opens in a new tab', 'wp-module-performance' )
23        );
24    }
25
26    /**
27     * Test the object cache.
28     *
29     * @return bool
30     */
31    public function test() {
32        return wp_using_ext_object_cache();
33    }
34}