Skip to content

Commit

Permalink
Added: Autoptimize compatibility for Minimal Analytics.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan0sz committed Oct 7, 2024
1 parent 7513528 commit 693bac6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions includes/class-compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public function __construct() {
* @return void
*/
private function init() {
if ( defined( 'AUTOPTIMIZE_PLUGIN_VERSION' ) ) {
new CAOS_Compatibility_Autoptimize();
}

if ( defined( 'LSCWP_V' ) ) {
new CAOS_Compatibility_Litespeed();
}
Expand Down
43 changes: 43 additions & 0 deletions includes/compatibility/class-autoptimize.php
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;
}
}

0 comments on commit 693bac6

Please sign in to comment.