Store Locator Plus®

SLP_AJAX extends SLP_BaseClass_AJAX
in package

Holds the ajax-only code.

This allows the main plugin to only include this file in AJAX mode via the slp_init when DOING_AJAX is true.

Table of Contents

Properties

$addon  : mixed
$addon  : SLP_BaseClass_Addon
$basic_query  : string
$direct_call  : mixed
$distance_param_removed  : bool
$formdata  : array<string|int, mixed>
$formdata_defaults  : mixed
$formdata_defaults  : array<string|int, mixed>
$formdata_defaults  : array<string|int, mixed>
$formdata_set  : bool
$location_queries  : array<string|int, mixed>
$name  : string
$name  : mixed
$options  : array<string|int, mixed>
$options  : mixed
$plugin  : SLPlus
$plugin  : mixed
$query_limit  : int
$query_limit  : mixed
$query_params  : mixed
$query_params  : array<string|int, mixed>
$query_params_valid  : mixed
$query_params_valid  : array<string|int, string>
$short_action  : string
$slplus  : SLPlus
$uses_slplus  : bool
$valid_actions  : mixed
$valid_actions  : array<string|int, string>
$valid_actions  : array<string|int, string>
$formdata  : mixed
$slplus  : mixed
$uses_slplus  : mixed
$basic_query  : mixed
$distance_param_removed  : mixed
$formdata_set  : mixed
$location_queries  : mixed
$set_query_params_done  : mixed
$short_action  : mixed

Methods

__construct()  : mixed
Instantiate a new AJAX handler object.
__get()  : SLPlus_BaseClass_Object
__isset()  : bool
add_ajax_hooks()  : mixed
Add our AJAX hooks.
add_distance_sort_to_orderby()  : mixed
Add sort by distance ASC as default order.
add_initial_distance_sort_to_orderby()  : mixed
Add sort by distance ASC as default order.
csl_ajax_onload()  : string|null
Handle AJAX request for OnLoad action.
csl_ajax_search()  : mixed
Handle AJAX request for Search calls.
do_ajax_startup()  : mixed
Things we want our add on packs to do when they start in AJAX mode.
filter_out_private_locations()  : string
Do not return private locations by default.
find_locations()  : string|null
Find locations
get_instance()  : SLPlus_BaseClass_Object
Return an instance of the object which is also registered to the slplus global less the SLP_ part.
is_valid_ajax_action()  : mixed
Return true if the AJAX action is one we process.
process_location_manager()  : mixed
Process the location manager requests.
process_slp_clear_schedule_messages()  : mixed
Clear the import messages transient.
remove_distance_clauses()  : bool
Remove any having clauses with sl_distance in them from the DB Query.
remove_SQL_distance_param()  : mixed
Remove the distance parameter from the SQL params list.
renderJSON_Response()  : null
Output a JSON response based on the incoming data and die.
sanitize_query_params()  : mixed|string
A less aggressive query param processor.
send_JSON_response()  : mixed
Output a JSON response based on the incoming data and die.
set_properties()  : mixed
Set our properties.
set_QueryParams()  : mixed
Set incoming query and request parameters into object properties.
set_valid_query_params()  : array<string|int, mixed>
Set the valid AJAX params based on the incoming action.
slp_add_marker()  : array<string|int, mixed>
Format the result data into a named array.
slp_change_option()  : mixed
Change a single option via immediate AJAX mode.
slp_delete_location()  : mixed
Delete a single location.
initialize()  : mixed
Do these things when this object is invoked. Override in your class.
execute_location_query()  : object
Run a database query to fetch the locations the user asked for.
update_slp_user_meta()  : bool|int
Update valid SLP user meta keys only.
user_can_manage_slp()  : bool
Return true if user can manage SLP.

Properties

$basic_query read-only

public string $basic_query

The basic query string before the prepare.

$direct_call

public mixed $direct_call = \false

$distance_param_removed read-only

public bool $distance_param_removed

true if we already removed the distance param

$formdata

public array<string|int, mixed> $formdata

Form data that comes into the AJAX request in the formdata variable.

$formdata_defaults

public mixed $formdata_defaults = array('addressInput' => '', 'addressInputState' => '')

$formdata_defaults

public array<string|int, mixed> $formdata_defaults

Default formdata values.

$formdata_defaults

public array<string|int, mixed> $formdata_defaults

The formdata default values.

$formdata_set read-only

public bool $formdata_set

Has the formdata been set already?

$location_queries read-only

public array<string|int, mixed> $location_queries

The executed queries as formatted

$name

public string $name

TODO: LEGACY support for 4.2 addons

$name

public mixed $name = 'AjaxHandler'

$options

public array<string|int, mixed> $options

TODO: LEGACY support for 4.2 addons

$options

public mixed $options = array('installed_version' => \SLPLUS_VERSION)

$plugin

public SLPlus $plugin

TODO: LEGACY support for 4.2 addons : DIR, GFI

$query_limit

public int $query_limit

The query limit.

$query_params_valid

public mixed $query_params_valid = array()

$query_params_valid

public array<string|int, string> $query_params_valid

Array of valid AJAX query parameters

$short_action read-only

public string $short_action

The shortened (csl_ajax prefix dropped) AJAX action.

$uses_slplus

public bool $uses_slplus

Set to true (default) if the object needs access to the SLPlus plugin object.

$valid_actions

public mixed $valid_actions = array('csl_ajax_onload', 'csl_ajax_search', 'slp_clear_schedule_messages', 'slp_delete_location', 'slp_change_option')

$valid_actions

public array<string|int, string> $valid_actions

$valid_actions

public array<string|int, string> $valid_actions

What AJAX actions are valid for this add on to process? Override in the extended class if not serving the default SLP actions: csl_ajax_onload csl_ajax_search

$distance_param_removed

private mixed $distance_param_removed = \false

$location_queries

private mixed $location_queries = array()

$set_query_params_done

private mixed $set_query_params_done = \false

Methods

__construct()

Instantiate a new AJAX handler object.

public __construct() : mixed

__isset()

public __isset(string $property) : bool
Parameters
$property : string
Return values
bool

add_ajax_hooks()

Add our AJAX hooks.

public add_ajax_hooks() : mixed
Tags
uses
SLP_AJAX::slp_delete_location

for the AJAX 'slp_delete_location' action

add_distance_sort_to_orderby()

Add sort by distance ASC as default order.

public add_distance_sort_to_orderby() : mixed

add_initial_distance_sort_to_orderby()

Add sort by distance ASC as default order.

public add_initial_distance_sort_to_orderby() : mixed

csl_ajax_onload()

Handle AJAX request for OnLoad action.

public csl_ajax_onload() : string|null
Return values
string|null

Handle AJAX request for Search calls.

public csl_ajax_search() : mixed

do_ajax_startup()

Things we want our add on packs to do when they start in AJAX mode.

public do_ajax_startup() : mixed

Add methods named process_{short_action_name} to the extended class, or override this method.

Tags
uses
SLP_AJAX::process_location_manager

NOTE: If you name something with process_{short_action_name} this will bypass the WordPress AJAX hooks and will run IMMEDIATELY when this class is instantiated.

filter_out_private_locations()

Do not return private locations by default.

public filter_out_private_locations(string $where) : string
Parameters
$where : string

the current where clause

Return values
string

the extended where clause

find_locations()

Find locations

public find_locations([string $mode = 'search' ]) : string|null
Parameters
$mode : string = 'search'

which mode are we in, usually 'search' or 'load'

Return values
string|null

get_instance()

Return an instance of the object which is also registered to the slplus global less the SLP_ part.

public static get_instance([bool $no_global = false ][, mixed $params = array() ]) : SLPlus_BaseClass_Object

TODO: PHP7.4 and PHP8.0 the static instance variable returns an object matching $class TODO: PHP8.1 the static instance continually returns the FIRST object (SLP_Admin_Helper) every time -- it is like PHP8.1 static instance is bound to base_class-object versus the calling class object

Parameters
$no_global : bool = false

set to true to skip assigning object to SLP global as a property.

$params : mixed = array()

object init params

Return values
SLPlus_BaseClass_Object

is_valid_ajax_action()

Return true if the AJAX action is one we process.

public is_valid_ajax_action() : mixed

process_location_manager()

Process the location manager requests.

public process_location_manager() : mixed
Tags
used-by

\SLP_BaseClass_AJAX::do_ajax_startup default for AJAX action 'location_manager'

process_slp_clear_schedule_messages()

Clear the import messages transient.

public process_slp_clear_schedule_messages() : mixed

Runs via do_ajax_startup() in the base class.

remove_distance_clauses()

Remove any having clauses with sl_distance in them from the DB Query.

public remove_distance_clauses(string $array_value) : bool
Parameters
$array_value : string
Return values
bool

when used with array_filter this will keep an array element if the return is .t. , remove it if .f.

remove_SQL_distance_param()

Remove the distance parameter from the SQL params list.

public remove_SQL_distance_param( $query_params) : mixed

Distance param is assumed to be the second-to-last param.

Parameters
$query_params :

renderJSON_Response()

Output a JSON response based on the incoming data and die.

public renderJSON_Response(array<string|int, mixed> $data) : null

Used for AJAX processing in WordPress where a remote listener expects JSON data.

Parameters
$data : array<string|int, mixed>

named array of keys and values to turn into JSON data

Return values
null

dies on execution

sanitize_query_params()

A less aggressive query param processor.

public sanitize_query_params( $str) : mixed|string

We need to keep & as & for query strings. We also need to allow some form posts to send allowed HTML tags (layout settings).

Parameters
$str :
Return values
mixed|string

send_JSON_response()

Output a JSON response based on the incoming data and die.

public send_JSON_response(array<string|int, mixed> $data) : mixed

Used for AJAX processing in WordPress where a remote listener expects JSON data.

Parameters
$data : array<string|int, mixed>

named array of keys and values to turn into JSON data

set_properties()

Set our properties.

public set_properties([array<string|int, mixed> $options = array() ]) : mixed
Parameters
$options : array<string|int, mixed> = array()

set_QueryParams()

Set incoming query and request parameters into object properties.

public set_QueryParams() : mixed

set_valid_query_params()

Set the valid AJAX params based on the incoming action.

public set_valid_query_params( $valid_params) : array<string|int, mixed>
Parameters
$valid_params :
Return values
array<string|int, mixed>

slp_add_marker()

Format the result data into a named array.

public slp_add_marker([mixed $row = null ]) : array<string|int, mixed>

We will later use this to build our JSONP response.

Parameters
$row : mixed = null
Return values
array<string|int, mixed>

slp_change_option()

Change a single option via immediate AJAX mode.

public slp_change_option() : mixed

slp_delete_location()

Delete a single location.

public slp_delete_location() : mixed

initialize()

Do these things when this object is invoked. Override in your class.

protected initialize() : mixed

execute_location_query()

Run a database query to fetch the locations the user asked for.

private execute_location_query(string $query_slug, array<string|int, string> $query_statements) : object
Parameters
$query_slug : string

the slug for this query

$query_statements : array<string|int, string>

an array of query statement slugs to run as the main query

Return values
object

a MySQL result object

update_slp_user_meta()

Update valid SLP user meta keys only.

private update_slp_user_meta( $user_id,  $key,  $value) : bool|int
Parameters
$user_id :
$key :
$value :
Return values
bool|int

user_can_manage_slp()

Return true if user can manage SLP.

private user_can_manage_slp() : bool
Return values
bool

        
On this page

Search results