Hook type: filter
Customize the filters’ main awf_data frontend JavaScript object used by the plugin’s frontend script. The filter allows the customization of the AJAX and frontend related settings, such as products, pagination, sorting and “no results” selectors, AJAX pagination settings, togglable preset behavior and more.
Parameters
(array)$js_data – array of the filters’ settings
Behavior keys that can be changed using the $js_data array:
| Key | Default | Effect |
|---|---|---|
togglable_preset['insert_btn_before_container'] | The Position before custom selector setting | Selector of the element the togglable preset button is inserted before |
togglable_preset['close_preset_on_ajax_update'] | true | Close the togglable preset after each AJAX update |
ajax_scroll | The AJAX scroll adjustment setting, if scrolling is on | Offset in px for the scroll to the products after filtering |
i18n | Array of settings’ labels | Texts of the badge reset, the togglable button, the children collapse button and the “Load more products” button |
Usage Example:
$js_data['togglable_preset']['close_preset_on_ajax_update'] = false;
Optional switches
The following keys are never set by the plugin, but can switch certain behavior on or off:
| Key | Value | Effect |
|---|---|---|
debug | any | Log AJAX errors to the console instead of falling back to a page reload |
skip_loader_adjustment | any | Keep the loading spinner where the theme’s CSS puts it; by default it is moved toward the visible part of the products |
disable_accessibility_support | any | Turn off screen reader alerts, keyboard handling of badges and focus moves |
disable_thousand_separator | any | Remove the thousand separator from range slider values |
ajax_pagination['block_pagination'] | any | Treat next / prev links as siblings of the page numbers, as in the block pagination markup (the Twenty Twenty-Five support sets it) |
ajax_extras | any scalar | Sent back to the server as $_GET['awf_ajax_extras'] with every filtering, counts and autocomplete request, for your own PHP to read |
title_badges_insert_before | a selector | (premium) Where the active filter badges are inserted above the products, e.g. .products, .woocommerce-info |
enable_interactive_tooltips_thousand_separator | any | (premium) Show the thousand separator in the range slider tooltips |
af_margins_adjustment | any | (premium) Add the awf-af-adjusted-margin class to the lists that hold the visible active items, so their margins can be adjusted in CSS |
Whenever the property accepts “any” value, its mere presence in the $js_data array acts as a switch. You can set it like so:
$js_data['disable_accessibility_support'] = true;
Return
array — the modified $js_data array.
Example
Note: the plugin also calls this filter with an empty array on some admin settings pages, so please check that a key exists before modifying it.
add_filter( 'awf_js_data', function( $js_data ) {
if( isset( $js_data['products_container'] ) ) {
$js_data['products_container'] = '.my-theme-products';
}
return $js_data;
} );
