1. Go to this page and download the library: Download digitoimistodude/air-cookie library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
digitoimistodude / air-cookie example snippets
add_filter( 'air_cookie\categories', 'my_add_cookie_category' );
function my_add_cookie_category( $categories ) {
$categories[] = [
'key' => 'ads',
'enabled' => false, // it is advised to have categories disabled by default
'readonly' => false, // user should have always control over categories
'title' => 'Ads',
'description' => 'This site uses external services to display ads, and they might set some cookies.',
];
return $categories;
}
add_action( 'air_cookie_js_analytics', 'my_add_js_for_analytics' );
function my_add_js_for_analytics() {
ob_start();
add_action( 'air_cookie_js_analytics', 'my_add_js_for_analytics' );
function my_add_js_for_analytics() {
ob_start();
add_action( 'air_cookie_js_analytics', 'my_add_js_for_analytics' );
function my_add_js_for_analytics() {
ob_start();
add_action( 'air_cookie_js_analytics', 'my_add_js_for_analytics' );
function my_add_js_for_analytics() {
ob_start();
// Disable script by nulling the tag on latest possible chance
add_filter( 'script_loader_tag', function( $tag, $handle ) {
if ( 'our-script-handle' === $handle ) {
return '';
}
return $tag;
}, 10, 2 );
// Load stamped.io script on air cookie
add_action( 'air_cookie_js_functional', function() {
$stampedio_url = get_script_src_by_handle( 'our-script-handle' );
if ( empty( $stampedio_url ) ) {
return;
}
ob_start();
add_action( 'air_cookie_js_<category-key>', 'my_add_js_for_<category-key>' );
function my_add_js_for_<category-key>() {
ob_start();
add_filter( 'air_cookie\embeds\thumbnail', 'my_maybe_add_thumbnail', 10, 2 );
function my_maybe_add_thumbnail( $thumbnail, $src ) {
// If thumbnail is already set, bail.
if ( ! empty( $thumbnail ) ) {
return $thumbnail;
}
// Do your magic to get the thumbnail
return 'https://your.thumbna.il/location.jpg';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.