toria_add_ajax

				
					function toria_add_ajax(
	$action,
	$php_callback,
	$script_path,
	$mode = 'private',
	$ajax_variables = array(),
	$nonce = 'my_custom_value_submission_test',
	$ajax_object = 'toria',
	$ajax_handle = '',
	$script_depends = array(),
	$script_version = false,
	$script_in_footer = true
)
				
			

Description

Adds Ajax scripts and their associated actions and callback

Parameters

$action

The name of the Ajax action.

$php_callback

PHP function to respond to ajax calls.

$script_path

File path containing you Javascript file.

$mode

(string) Determines if the script will be exposed to authenticated Ajax actions for logged-in users or non-authenticated Ajax actions for logged-out users or both. Using both, private, and public.

$ajax_variables

Variables to be passed to be available for JS to utilize.

$nonce

(string) Used to create WP nonce for verification on PHP callback.

$ajax_object

(string) Name of object to be storing JS variables.

$ajax_handle

Name of script.

$script_depends

(string[]) (Optional) An array of registered script handles this script depends on. Default value: array().

 $script_version

A string specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If the version is set to false, a version number is automatically added equal to the current installed Tori Ajax version. If set to null, no version is added. Default value: false.

$script_in_footer

(bool) (Optional) Whether to enqueue the script before <body> instead of in the <head>. Default ‘false’.

Return

(bool) Whether it is added or not.