Skip to content
Docs
Get RestroPress

Filter

rpress_frontend_script_vars

Updated
On this page

Filters the data localised to the main frontend script.

Runs in RP_Frontend_Scripts::load_scripts() just before the array is passed to wp_localize_script() as the rp_scripts JavaScript object for the rp-frontend script. The array holds nonces, AJAX URL, labels, price formatting settings and cart data. The second argument is the current service type taken from the cookie after the rpress_current_service_type filter.

Parameters#

ParameterTypeDescription
$paramsarrayData for the rp_scripts JavaScript object.
$cookie_servicestringCurrent service type.

Return value#

array. The data for the rp_scripts object.

Example#

function my_frontend_script_vars( $params, $service_type ) {
	$params['my_flag'] = 'delivery' === $service_type ? 1 : 0;
	return $params;
}
add_filter( 'rpress_frontend_script_vars', 'my_frontend_script_vars', 10, 2 );

Source#

Applied in:

  • includes/class-rpress-frontend-scripts.php (line 402), in RP_Frontend_Scripts::load_scripts()

See also#

Was this page helpful?