-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: Autoptimize compatibility for Minimal Analytics.
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/* * * * * * * * * * * * * * * * * * * * | ||
* ██████╗ █████╗ ██████╗ ███████╗ | ||
* ██╔════╝██╔══██╗██╔═══██╗██╔════╝ | ||
* ██║ ███████║██║ ██║███████╗ | ||
* ██║ ██╔══██║██║ ██║╚════██║ | ||
* ╚██████╗██║ ██║╚██████╔╝███████║ | ||
* ╚═════╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝ | ||
* | ||
* @author : Daan van den Bergh | ||
* @url : https://daan.dev/wordpress/caos/ | ||
* @copyright: © 2021 - 2024 Daan van den Bergh | ||
* @license : GPL2v2 or later | ||
* * * * * * * * * * * * * * * * * * * */ | ||
|
||
class CAOS_Compatibility_Autoptimize { | ||
/** | ||
* Build class. | ||
*/ | ||
public function __construct() { | ||
$this->init(); | ||
} | ||
|
||
/** | ||
* Action and filter hooks. | ||
* | ||
* @return void | ||
*/ | ||
private function init() { | ||
add_filter( 'caos_script_custom_attributes', [ $this, 'exclude_from_autoptimize' ] ); | ||
} | ||
|
||
/** | ||
* Add data-no-optimize="1" attribute to script if LiteSpeed Cache is enabled. | ||
* | ||
* @param $attributes | ||
* | ||
* @return string | ||
*/ | ||
public function exclude_from_autoptimize( $attributes ) { | ||
return 'data-noptimize="true" ' . $attributes; | ||
} | ||
} |