applyFilters( "set_data", value, key );
applyFilters( "set_data_{key}", value, key );
Filters a value that will be written to a Cookie or the localStorage.
The dynamic part of the filter name is the sanitized entry name. See DiviArea.Utils.sanitizeHookName()
for details.
Returns
The filtered value.
Examples
// Example 1: Output data to the console before it will be saved.
DiviArea.addFilter( 'set_data', function( value, key ) {
console.log('Saving local variable', key, 'with value', value);
return value;
});
// Example 2: Disable local data
DiviArea.addFilter( 'set_data', function( value, key ) {
return false;
});
Notes
The DiviArea.Utils.setLocalData()
method will decide, whether to write a Cookie or to save data to the localStorage instead.
When this filter returns boolean false, then no entry is saved in the localStorage (and no Cookie will be changed)