Action Reference - Backend
List of all Action Hooks in the backend of Borlabs Cookie.
Content Blocker
borlabsCookie/contentBlocker/edit/template/settings/{$content_blocker_id}
Allows you to add additional input fields to a Content Blocker.
$contentBlockerData contains all information about the current Content Blocker.
add_action('borlabsCookie/contentBlocker/edit/template/settings/my-content-blocker', function ($contentBlockerData) {
$inputCustomValue = esc_html(!empty($contentBlockerData->settings['customValue']) ? $contentBlockerData->settings['customValue'] : '');
echo '<div class="form-group row">'
echo '<label for="customValue" class="col-sm-4 col-form-label">Custom Value</label>';
echo '<div class="col-sm-8">'
echo '<input type="text" class="form-control form-control-sm d-inline-block w-75 mr-2" id="customValue" name="settings[customValue]" value="'.$inputCustomValue.'">';
echo '<span data-toggle="tooltip" title="Your Tooltip Text"><i class="fas fa-lg fa-question-circle text-dark"></i></span>';
echo '</div>';
echo '</div>';
});
borlabsCookie/contentBlocker/edit/template/settings/help/{$content_blocker_id}
Allows you to add a tips section to a Content Blocker.
$contentBlockerData contains all information about the current Content Blocker.
add_action('borlabsCookie/contentBlocker/edit/template/settings/help/my-content-blocker', function ($contentBlockerData) {
echo '<div class="col-12 col-md-4 rounded-right shadow-sm bg-tips text-light">'
echo '<div class="px-3 pt-3 pb-3 mb-4">'
echo '<h3 class="border-bottom mb-3">Tips</h3>';
echo '<h4>How My Content Blocker works</h4>';
echo '<p>Lorem ipsum dolor.</p>';
echo '</div>';
echo '</div>';
});
Cookies
borlabsCookie/cookie/edit/template/settings/{$service}
Allows you to add additional input fields to a Cookie Service.
$cookieData contains all information about the current Cookie.
add_action('borlabsCookie/cookie/edit/template/settings/MyService', function ($cookieData) {
$inputCustomValue = esc_html(!empty($cookieData->settings['customValue']) ? $cookieData->settings['customValue'] : '');
echo '<div class="form-group row">'
echo '<label for="customValue" class="col-sm-4 col-form-label">Custom Value</label>';
echo '<div class="col-sm-8">'
echo '<input type="text" class="form-control form-control-sm d-inline-block w-75 mr-2" id="customValue" name="settings[customValue]" value="'.$inputCustomValue.'">';
echo '<span data-toggle="tooltip" title="Your Tooltip Text"><i class="fas fa-lg fa-question-circle text-dark"></i></span>';
echo '</div>';
echo '</div>';
});
borlabsCookie/cookie/edit/template/settings/help/{$service}
Allows you to add a tips section to a Cookie Service.
$cookieData contains all information about the current Cookie.
add_action('borlabsCookie/cookie/edit/template/settings/help/MyService', function ($cookieData) {
echo '<div class="col-12 col-md-4 rounded-right shadow-sm bg-tips text-light">'
echo '<div class="px-3 pt-3 pb-3 mb-4">'
echo '<h3 class="border-bottom mb-3">Tips</h3>';
echo '<h4>How MyService works</h4>';
echo '<p>Lorem ipsum dolor.</p>';
echo '</div>';
echo '</div>';
});
Filter Reference - Backend
List of all filters in the backend of Borlabs Cookie.
Content Blocker
borlabsCookie/contentBlocker/save
Allows you to modify the Content Blocker data before saving.
add_filter('borlabsCookie/contentBlocker/save', function ($formData) {
// Sanitize or modify $formData, e.g. $formData['settings']['customValue']
return $formData;
});
borlabsCookie/contentBlocker/validate
Allows you to validate the Content Blocker data before saving.
add_filter('borlabsCookie/contentBlocker/validate', function ($errorStatus, $formData) {
// Validate $formData, e.g. $formData['settings']['customValue']
// Set $errorStatus true, if data is not valid. Do not set $errorStatus false!
return $errorStatus;
}, 10, 2);
Cookies
borlabsCookie/cookie/service/defaultData
Allows you to set the default values of a new service.
add_filter('borlabsCookie/cookie/service/defaultData', function ($serviceDefaultData, $formData) {
// Check if the selected service is your service
if (!empty($formData['service']) && $formData['service'] === 'MyService') {
// $serviceDefaultData has to contain these informations
$serviceDefaultData = [
'cookieId' => 'my-service',
'service' => 'MyService',
'name' => 'My Service',
'provider' => '',
'purpose' => '',
'privacyPolicyURL' => '',
'hosts' => [],
'cookieName' => '',
'cookieExpiry' => '',
'optInJS' => '',
'optOutJS' => '',
'fallbackJS' => '',
'settings' => [
'customValue' => '',
],
'status' => true,
'undeletetable' => false,
];
}
return $serviceDefaultData;
}, 10, 2);
borlabsCookie/cookie/save
Allows you to modify the Cookie data before saving it.
add_filter('borlabsCookie/cookie/save', function ($formData) {
// Sanitize or modify $formData, e.g. $formData['settings']['customValue']
return $formData;
});
borlabsCookie/cookie/service/selection
Allows you to add a service to the list of selectable services.
add_filter('borlabsCookie/cookie/service/selection', function ($cookieServices) {
// Add your service to the list of services
$cookieServices['MyService'] = 'My Service';
return $cookieServices;
});
borlabsCookie/cookie/validate
Allows you to validate the Cookie data before storing it.
add_filter('borlabsCookie/cookie/validate', function ($errorStatus, $formData) {
// Validate $formData, e.g. $formData['settings']['customValue']
// Set $errorStatus true, if data is not valid. Do not set $errorStatus false!
return $errorStatus;
}, 10, 2);
Cookie Groups
borlabsCookie/contentBlocker/save
Allows you to modify the Cookie Group's data before saving.
add_filter('borlabsCookie/cookieGroup/save', function ($formData) {
// Sanitize or modify $formData, e.g. $formData['settings']['customValue']
return $formData;
});
borlabsCookie/contentBlocker/validate
Allows you to validate the Cookie Group's data before saving.
add_filter('borlabsCookie/cookieGroup/validate', function ($errorStatus, $formData) {
// Validate $formData, e.g. $formData['settings']['customValue']
// Set $errorStatus true, if data is not valid. Do not set $errorStatus false!
return $errorStatus;
}, 10, 2);
Filter Reference - Frontend
List of all filters in the frontend of Borlabs Cookie.
Content Blocker
borlabsCookie/contentBlocker/modify/content/{$content_blocker_id}
Allows you to modify the preview of the blocked content and the blocked content itself.
add_filter('borlabsCookie/contentBlocker/modify/content/my-service', function ($content) {
// Get settings of the Content Blocker
$contentBlockerData = BorlabsCookieHelper()->getContentBlockerData('my-service');
// Do what ever you have to do
// Return the preview of the blocked content
return $contentBlockerData['previewHTML'];
});
borlabsCookie/contentBlocker/modify/settings/{$content_blocker_id}
Allows you to modify the additional settings of the Content Blocker.
add_filter('borlabsCookie/contentBlocker/modify/settings/my-service', function ($settings) {
// Modify $settings, e.g. $settings['customValue']
return $settings;
});
Cookie Settings
borlabsCookie/settings
Allows you to modify the JavaScript API settings of Borlabs Cookie.
add_filter('borlabsCookie/settings', function ($jsConfig) {
// Modify the JavaScript API config of Borlabs Cookie, e.g. $jsConfig['showCookieBox']
return $jsConfig;
});
System
borlabsCookie/javascript/disabledOnRestRequest
For REST requests, no JavaScript files are registered via wp_enqueue_script
, this can be deactivated with the help of the filter.
add_filter('borlabsCookie/javascript/disabledOnRestRequest', function () {
// Enqueue Borlabs Cookie JavaScript files on REST request.
return false;
});
borlabsCookie/style/disabledOnRestRequest
For REST requests, no CSS files are registered via wp_enqueue_script
, this can be deactivated with the help of the filter.
add_filter('borlabsCookie/style/disabledOnRestRequest', function () {
// Enqueue Borlabs Cookie CSS files on REST request.
return false;
}, 10, 2);