Completed
Push — develop ( c614b1...023ff7 )
by David
03:14
created

Wordlift_WpRocket_Adapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A exclude_defer_js() 0 5 1
1
<?php
2
/**
3
 * Adapters: WP-Rocket Adapter.
4
 *
5
 * The WP-Rocket Adapter tunes the Apdex index for Wordlift.
6
 *
7
 * @since   3.19.4
8
 *
9
 * @see https://github.com/insideout10/wordlift-plugin/issues/842.
10
 * @see https://github.com/wp-media/wp-rocket-helpers/blob/master/static-files/wp-rocket-static-exclude-defer-js/wp-rocket-static-exclude-defer-js.php.
11
 *
12
 * @package Wordlift
13
 * @subpackage Wordlift/includes
14
 */
15
16
/**
17
 * Define the {@link Wordlift_WP-Rocket_Adapter} class.
18
 *
19
 * @since   3.19.4
20
 */
21
class Wordlift_WpRocket_Adapter {
22
23
	/**
24
	 * Create a {@link Wordlift_WpRocket_Adapter} instance.
25
	 *
26
	 * @since 3.19.4
27
	 */
28
	public function __construct() {
29
30
		add_filter( 'rocket_exclude_defer_js', array( $this, 'exclude_defer_js' ) );
31
32
	}
33
34
	/**
35
	 * Hook to `rocket_exclude_defer_js` filter.
36
	 *
37
	 * @since 3.19.4
38
	 *
39
	 * @param array $excluded_files The preset excluded files.
40
	 *
41
	 * @return array The updated excluded files array.
42
	 */
43
	public function exclude_defer_js( $excluded_files = array() ) {
44
45
		// Exclude our own public JS.
46
		return array_merge( $excluded_files, array( Wordlift_Public::get_public_js_url(), ) );
47
	}
48
49
}
50