applyFilters( “get_data” )

applyFilters( "get_data", retVal, key);
applyFilters( "get_data_{key}", retVal, key);

Filters a value that was just read from a Cookie or the localStorage. When no value exists (or it expired), the value is set to boolean false.

The dynamic part of the filter name is the sanitized entry name. See DiviArea.Utils.sanitizeHookName() for details.

Params

retVal false|string, required
The value that was read from the Cookie or localStorage.
When no Cookie or localStorage entry exists, the value is false. Otherwise it is a string representing the actual value.
key string, required
The un-sanitized variable name.

Examples

// Example 1: Return the string "no" instead of all boolean false values.
DiviArea.addFilter( 'get_data', function( value, key ) {
    if ( false === value ) {
        value = 'no';
    }
    return value;
});
// Example 2: Output all local data to the console.
DiviArea.addFilter( 'get_data', function( value, key ) {
    console.log('Local variable', key, 'has value', value);
    return value;
});

Notes

No notes

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Get in touch with us