$def ) { if ( substr( $name, - $len ) == $method ) { if ( is_array( $def['function'] ) ) { if ( is_string( $def['function'][0] ) !== false ) { $def_class = $def['function'][0]; } else { $def_class = get_class( $def['function'][0] ); } if ( $def_class == $class ) { if ( is_object( $wp_filter[ $action ] ) && isset( $wp_filter[ $action ]->callbacks ) ) { $wp_filter[ $action ]->remove_filter( $action, $name, $priority ); $deleted = true; } else { unset( $wp_filter[ $action ][ $priority ][ $name ] ); $deleted = true; } } } } } } return $deleted; } /** * Custom manipulation of the script * * @param $buffer * @param $keywords * @param $cookie_type * * @return mixed|null|string|string[] * * @version 2.0.4 * @since 1.2.0 */ function cookiebot_addons_manipulate_script( $buffer, $keywords ) { /** * Pattern to get all scripts * * @version 2.0.4 * @since 1.2.0 */ $pattern = "/[\s\S]*?<\/script>/i"; /** * Get all scripts and add cookieconsent if it does match with the criterion */ $updated_scripts = preg_replace_callback( $pattern, function ( $matches ) use ( $keywords ) { /** * Matched script data */ $data = ( isset( $matches[0] ) ) ? $matches[0] : ''; /** * Check if the script contains the keywords, checks keywords one by one * * If one match, then the rest of the keywords will be skipped. **/ foreach ( $keywords as $needle => $cookie_type ) { /** * The script contains the needle **/ if ( strpos( $data, $needle ) !== false ) { $data = preg_replace( '/\