=' ) ) {
add_filter( 'wp_script_attributes', array( $this, 'cookiebot_add_consent_attribute_to_script_tag' ), 10, 1 );
add_filter( 'wp_inline_script_attributes', array( $this, 'cookiebot_add_consent_attribute_to_inline_script_tag' ), 10, 2 );
} else {
add_filter( 'script_loader_tag', array( $this, 'cookiebot_add_consent_attribute_to_tag' ), 10, 3 );
}
}
/**
* Initialize the list of scripts to ignore cookiebot scan.
*/
public function initialize_ignore_scripts() {
$this->ignore_scripts = apply_filters( 'cybot_cookiebot_ignore_scripts', $this->ignore_scripts );
}
/**
* Adds enqueue script handle tag to the array of tags.
* So that the script can be updated with cookieconsent attribute.
*
* @param $tag string Enqueue script handle name
* @param $type array
*
* @since 1.2.0
*/
public function add_tag( $tag, $type ) {
$this->tags[ $tag ] = $type;
}
public function ignore_script( $script ) {
array_push( $this->ignore_scripts, $script );
}
/**
* Modifies external links to google analytics
*
* @param $tag
* @param $handle
* @param $src
*
* @return string
*
* @since 1.2.0
*/
public function cookiebot_add_consent_attribute_to_tag( $tag, $handle, $src ) {
if ( array_key_exists( $handle, $this->tags ) && ! empty( $this->tags[ $handle ] ) ) {
//phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript
return '';
}
if ( $this->check_ignore_script( $src ) ) {
return preg_replace_callback(
'/