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 : SLP_BaseClass_Addon
- $direct_call : mixed
- $formdata : array<string|int, mixed>
- $formdata_defaults : mixed
- $formdata_set : bool
- $myslp : MySLP
- $name : mixed
- $options : mixed
- $plugin : mixed
- $query_limit : mixed
- $query_params : array<string|int, mixed>
- $query_params_valid : mixed
- $short_action : string
- $slplus : SLPlus
- $uses_myslp : bool
- $uses_slplus : bool
- $valid_actions : mixed
- $slug : mixed
- $basic_query : mixed
- $distance_param_removed : mixed
- $location_queries : 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() : mixed
- 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() : mixed
- Find locations
- get_instance() : static
- Return an instance of the object which is also registered to the slplus global less the SLP_ part.
- getLimitBasedOnMode() : mixed
- Retrieves the limit based on the specified mode.
- initialize() : mixed
- Instantiate the admin panel object.
- 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.
- 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.
- execute_location_query() : object
- Run a database query to fetch the locations the user asked for.
- renderJSON_Response() : null
- Output a JSON response based on the incoming data and die.
- 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
$addon
public
SLP_BaseClass_Addon
$addon
This addon pack.
$direct_call
public
mixed
$direct_call
= \false
$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_set read-only
public
bool
$formdata_set
Has the formdata been set already?
$myslp
public
MySLP
$myslp
$name
public
mixed
$name
= 'AJAX'
$options
public
mixed
$options
= array('installed_version' => \SLPLUS_VERSION)
$plugin
public
mixed
$plugin
$query_limit
public
mixed
$query_limit
$query_params
public
array<string|int, mixed>
$query_params
$query_params_valid
public
mixed
$query_params_valid
= array()
$short_action read-only
public
string
$short_action
The shortened (csl_ajax prefix dropped) AJAX action.
$slplus
public
SLPlus
$slplus
$uses_myslp
public
bool
$uses_myslp
Set to true to add a $myslp property pointing to global $myslp
$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')
$slug
protected
mixed
$slug
$basic_query
private
mixed
$basic_query
$distance_param_removed
private
mixed
$distance_param_removed
= \false
$location_queries
private
mixed
$location_queries
= array()
Methods
__construct()
Instantiate a new AJAX handler object.
public
__construct() : mixed
__get()
public
__get(string $property) : SLPlus_BaseClass_Object
Parameters
- $property : string
Return values
SLPlus_BaseClass_Object__isset()
public
__isset(string $property) : bool
Parameters
- $property : string
Return values
booladd_ajax_hooks()
Add our AJAX hooks.
public
add_ajax_hooks() : mixed
Tags
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() : mixed
Tags
csl_ajax_search()
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
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' ]) : mixed
Parameters
- $mode : string = 'search'
-
which mode are we in, usually 'search' or 'load'
Tags
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() ]) : static
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
staticgetLimitBasedOnMode()
Retrieves the limit based on the specified mode.
public
getLimitBasedOnMode(string $mode) : mixed
Parameters
- $mode : string
-
The mode to determine the limit ('load', 'csl_ajax_onload', or other modes).
Return values
mixed —The limit value based on the mode.
initialize()
Instantiate the admin panel object.
public
initialize() : mixed
Sets short_action property. Calls do_ajax_startup.
- sets Query Params (formdata)
- Calls process_{short_action} if method exists.
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
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(mixed $query_params) : mixed
Distance param is assumed to be the second-to-last param.
Parameters
- $query_params : mixed
sanitize_query_params()
A less aggressive query param processor.
public
sanitize_query_params(mixed $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 : mixed
Return values
mixed|stringsend_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(mixed $valid_params) : array<string|int, mixed>
Parameters
- $valid_params : mixed
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
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
renderJSON_Response()
Output a JSON response based on the incoming data and die.
private
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
update_slp_user_meta()
Update valid SLP user meta keys only.
private
update_slp_user_meta(mixed $user_id, mixed $key, mixed $value) : bool|int
Parameters
- $user_id : mixed
- $key : mixed
- $value : mixed
Return values
bool|intuser_can_manage_slp()
Return true if user can manage SLP.
private
user_can_manage_slp() : bool