| 1 |
<?php |
| 2 |
|
| 3 |
namespace cybot\cookiebot\addons\controller\addons\wp_rocket; |
| 4 |
|
| 5 |
use cybot\cookiebot\addons\controller\addons\Base_Cookiebot_Plugin_Addon; |
| 6 |
|
| 7 |
class Wp_Rocket extends Base_Cookiebot_Plugin_Addon { |
| 8 |
|
| 9 |
|
| 10 |
const ADDON_NAME = 'WP Rocket'; |
| 11 |
const OPTION_NAME = 'wp_rocket'; |
| 12 |
const PLUGIN_FILE_PATH = 'wp-rocket/wp-rocket.php'; |
| 13 |
const DEFAULT_COOKIE_TYPES = array( 'statistics' ); |
| 14 |
const ENABLE_ADDON_BY_DEFAULT = true; |
| 15 |
|
| 16 |
/** |
| 17 |
* Loads addon configuration |
| 18 |
* |
| 19 |
* @since 1.3.0 |
| 20 |
*/ |
| 21 |
public function load_addon_configuration() { |
| 22 |
/** |
| 23 |
* Exclude Cookiebot files from defer setting |
| 24 |
*/ |
| 25 |
add_filter( 'rocket_exclude_defer_js', array( $this, 'exclude_files' ) ); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Exclude scripts from WP Rocket’s defer JS option. |
| 30 |
* |
| 31 |
* @param array $excluded_files Array of script URLs to be excluded |
| 32 |
* |
| 33 |
* @return array Extended array script URLs to be excluded |
| 34 |
* |
| 35 |
* @author Caspar Hübinger |
| 36 |
* @since 3.6.2 |
| 37 |
*/ |
| 38 |
public function exclude_files( $excluded_files = array() ) { |
| 39 |
$excluded_files[] = 'consent.cookiebot.com'; |
| 40 |
|
| 41 |
return $excluded_files; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* @return array |
| 46 |
*/ |
| 47 |
public function get_extra_information() { |
| 48 |
return array( |
| 49 |
__( |
| 50 |
'Excludes cookiebot javascript files when the WP-Rocket deter option is enabled.', |
| 51 |
'cookiebot' |
| 52 |
), |
| 53 |
); |
| 54 |
} |
| 55 |
} |
| 56 |
|