awf_js_data

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
  1. (array) $js_data – array of the filters’ settings

Behavior keys that can be changed using the $js_data array:

KeyDefaultEffect
togglable_preset['insert_btn_before_container']The Position before custom selector settingSelector of the element the togglable preset button is inserted before
togglable_preset['close_preset_on_ajax_update']trueClose the togglable preset after each AJAX update
ajax_scrollThe AJAX scroll adjustment setting, if scrolling is onOffset in px for the scroll to the products after filtering
i18nArray of settings’ labelsTexts 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:

KeyValueEffect
debuganyLog AJAX errors to the console instead of falling back to a page reload
skip_loader_adjustmentanyKeep the loading spinner where the theme’s CSS puts it; by default it is moved toward the visible part of the products
disable_accessibility_supportanyTurn off screen reader alerts, keyboard handling of badges and focus moves
disable_thousand_separatoranyRemove the thousand separator from range slider values
ajax_pagination['block_pagination']anyTreat next / prev links as siblings of the page numbers, as in the block pagination markup (the Twenty Twenty-Five support sets it)
ajax_extrasany scalarSent 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_beforea selector(premium) Where the active filter badges are inserted above the products, e.g. .products, .woocommerce-info
enable_interactive_tooltips_thousand_separatorany(premium) Show the thousand separator in the range slider tooltips
af_margins_adjustmentany(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;
} );