function _cookie_content_blocker_settings_decode in Cookie Content Blocker 7
Decode a encoded settings string to a settings array.
Parameters
string $settings: The settings string to decode.
Return value
array The decoded settings or an empty array if decoding failed.
1 call to _cookie_content_blocker_settings_decode()
- _cookie_content_blocker_replace_tags in ./
cookie_content_blocker.module - Replaces cookie content blocker tags for the given text.
File
- ./
cookie_content_blocker.module, line 443 - Contains the main module code for Cookie content blocker.
Code
function _cookie_content_blocker_settings_decode($settings) {
// Check if we need to decode the settings first. This way we support
// both base64 encoded strings and settings already in a JSON-string format.
$decoded_settings = base64_decode($settings);
$needs_decode = base64_encode($decoded_settings) === $settings;
if ($needs_decode) {
$settings = $decoded_settings;
}
$settings = filter_xss($settings, array());
$settings = drupal_json_decode($settings);
return !empty($settings) ? $settings : array();
}