applyFilters( “get_data” )

  1. Home
  2. Knowledge Base
  3. Codex
  4. JS API
  5. JS Filters
  6. applyFilters( “get_data” )
DiviArea.applyFilters( "get_data", value, key );
DiviArea.applyFilters( "get_data_{key}", value, 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 {key} part in the hook name is the sanitized variable-name (all lower case, dashes changed to underscores).

Params

value
(string|false) The value that was read from the Cookie or localStorage.
key
(string) The unsanitized variable name.

Source

This filter is called inside DiviArea.Utils.getLocalData().

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