Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
LinkPrefetchHealthCheck
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 test
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace NewfoldLabs\WP\Module\Performance\HealthChecks;
4
5use NewfoldLabs\WP\Module\Performance\LinkPrefetch\LinkPrefetch;
6
7/**
8 * Health check for link prefetching.
9 */
10class LinkPrefetchHealthCheck extends HealthCheck {
11    /**
12     * Constructor.
13     */
14    public function __construct() {
15        $this->id           = 'newfold-link-prefetch';
16        $this->title        = esc_html__( 'Link Prefetching', 'wp-module-performance' );
17        $this->passing_text = esc_html__( 'Link prefetching is enabled', 'wp-module-performance' );
18        $this->failing_text = esc_html__( 'Link prefetching is disabled', 'wp-module-performance' );
19        $this->description  = esc_html__( 'Link prefetching can improve performance by loading pages immediately before they are requested.', 'wp-module-performance' );
20    }
21
22    /**
23     * Test if link prefetching is enabled.
24     *
25     * @return bool
26     */
27    public function test() {
28        $enabled = get_option( LinkPrefetch::$option_name, array() );
29        return isset( $enabled['activeOnDesktop'] ) && $enabled['activeOnDesktop'];
30    }
31}