SLP_Experience_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
- $formdata : array<string|int, mixed>
- $formdata_defaults : array<string|int, mixed>
- $formdata_set : bool
- $myslp : MySLP
- $query_params : array<string|int, mixed>
- $query_params_valid : array<string|int, string>
- $short_action : string
- $slplus : SLPlus
- $uses_myslp : bool
- $uses_slplus : bool
- $valid_actions : array<string|int, string>
- $slug : mixed
Methods
- __construct() : mixed
- __get() : SLPlus_BaseClass_Object
- __isset() : bool
- add_ajax_hooks() : mixed
- Add our specific AJAX filters.
- add_custom_sort_to_orderby() : mixed
- Add custom ER sort to Order By clause.
- add_global_hooks() : mixed
- Global hooks, exposed possibly even outside AJAX.
- do_ajax_startup() : mixed
- Things we want our add on packs to do when they start in AJAX mode.
- filter_AJAX_ModifyResults() : array<string|int, mixed>
- Randomize the results order if random order is selected for search results output.
- filter_JSONP_SearchByStore() : string
- Add the store name condition to the MySQL statement used to fetch locations with JSONP.
- filter_JSONP_SearchFilters() : string
- Add the selected filters to the search results.
- filter_JSONP_SearchFilters_W() : string
- Add the selected filters to the search results.
- get_cities() : mixed
- Return a list of cities in JSONP
- get_instance() : static
- Return an instance of the object which is also registered to the slplus global less the SLP_ part.
- initialize() : mixed
- Instantiate the admin panel object.
- is_valid_ajax_action() : mixed
- Return true if the AJAX action is one we process.
- list_location_zips() : void
- List the zip codes for the locations in the system for autocomplete.
- modify_having_clause() : array<string|int, mixed>
- Add having clause to sql which do query work by ajaxhandler
- modify_marker() : array<string|int, mixed>
- Modify the marker data.
- process_popup_email_form() : mixed
- Process a popup email form.
- remove_SQL_limit() : string
- Strip out the SQL Limit
- remove_SQL_limit_param() : mixed
- Remove the limit 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_ValidOptions() : mixed
- Set valid options from the incoming REQUEST
- add_action_handlers() : mixed
- Add Action Handlers
- check_custom_fields() : string
- Check that ER extended data fields exist, if they do not then remove them from the order by clause.
- create_string_CustomSQLOrder() : array<string|int, mixed>|string|array<string|int, string>
- Replace the featured location sort order with the more advanced case statement.
- get_email_by_slid() : string
- Get the email address from the location's email field, fetch by id.
- init_OptionsViaAJAX() : mixed
- Set options based on the AJAX formdata properties.
- is_discrete_widget_search() : bool
- Check the nonce is valid and that the widget field is set for unlimited results within a region (state, country, etc.)
- radius_behavior_ignores_radius() : bool
- Does the current radius behavior mean we should ignore the radius?
- set_autocomplete_vars() : mixed
- For autocomplete entries just jam the $_REQUEST variables into the formdata property.
Properties
$addon
public
SLP_BaseClass_Addon
$addon
This addon pack.
$formdata
public
array<string|int, mixed>
$formdata
Form data that comes into the AJAX request in the formdata variable.
$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?
$myslp
public
MySLP
$myslp
$query_params
public
array<string|int, mixed>
$query_params
$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.
$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
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
$slug
protected
mixed
$slug
Methods
__construct()
public
__construct([array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $options : array<string|int, mixed> = array()
__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 specific AJAX filters.
public
add_ajax_hooks() : mixed
add_custom_sort_to_orderby()
Add custom ER sort to Order By clause.
public
add_custom_sort_to_orderby() : mixed
add_global_hooks()
Global hooks, exposed possibly even outside AJAX.
public
add_global_hooks() : 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_AJAX_ModifyResults()
Randomize the results order if random order is selected for search results output.
public
filter_AJAX_ModifyResults(array<string|int, mixed> $results) : array<string|int, mixed>
Parameters
- $results : array<string|int, mixed>
-
the named array location results from an AJAX search
Return values
array<string|int, mixed>filter_JSONP_SearchByStore()
Add the store name condition to the MySQL statement used to fetch locations with JSONP.
public
filter_JSONP_SearchByStore(string $currentFilters) : string
Parameters
- $currentFilters : string
Tags
Return values
string —the modified where clause
filter_JSONP_SearchFilters()
Add the selected filters to the search results.
public
filter_JSONP_SearchFilters(mixed $where) : string
Do not modify the search if the request did not come through AJAX.
Parameters
- $where : mixed
Return values
stringfilter_JSONP_SearchFilters_W()
Add the selected filters to the search results.
public
filter_JSONP_SearchFilters_W(mixed $where) : string
Do not modify the search if the request did not come through AJAX.
Parameters
- $where : mixed
Return values
stringget_cities()
Return a list of cities in JSONP
public
get_cities() : mixed
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
staticinitialize()
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
TODO: add a "source" parameter as well and set to "slp" then check that to make sure we only process SLP requests
list_location_zips()
List the zip codes for the locations in the system for autocomplete.
public
list_location_zips() : void
modify_having_clause()
Add having clause to sql which do query work by ajaxhandler
public
modify_having_clause(array<string|int, mixed> $having_clauses) : array<string|int, mixed>
Parameters
- $having_clauses : array<string|int, mixed>
Return values
array<string|int, mixed>modify_marker()
Modify the marker data.
public
modify_marker(array<string|int, mixed> $marker) : array<string|int, mixed>
Parameters
- $marker : array<string|int, mixed>
-
the current marker data
Return values
array<string|int, mixed>process_popup_email_form()
Process a popup email form.
public
process_popup_email_form() : mixed
remove_SQL_limit()
Strip out the SQL Limit
public
remove_SQL_limit(mixed $query) : string
Do this for the search and state queries.
Parameters
- $query : mixed
Return values
stringremove_SQL_limit_param()
Remove the limit parameter from the SQL params list.
public
remove_SQL_limit_param(mixed $query_params) : mixed
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_ValidOptions()
Set valid options from the incoming REQUEST
public
set_ValidOptions(mixed $val, string $key) : mixed
Parameters
- $val : mixed
-
- the value of a form var
- $key : string
-
- the key for that form var
add_action_handlers()
Add Action Handlers
private
add_action_handlers() : mixed
check_custom_fields()
Check that ER extended data fields exist, if they do not then remove them from the order by clause.
private
check_custom_fields(string $order_clause) : string
Also check if any extended data records exist.
Parameters
- $order_clause : string
Return values
stringcreate_string_CustomSQLOrder()
Replace the featured location sort order with the more advanced case statement.
private
create_string_CustomSQLOrder(mixed $our_order) : array<string|int, mixed>|string|array<string|int, string>
By default any pre-existing / non-edited locations will set the featured field to NULL Featured locations are set to 1 Non-featured locations are set to 0
MySQL sorts features in DESC order to be: 1, 0, NULL
That messes up order by featured DESC when you have order by featured desc, rank asc, sl_distance as any location that was marked featured then unmarked will come BEFORE all unedited (non-featured) locations that may be closer. This is not what the user expects.
As such we must weight NULL to be the same as not featured.
Parameters
- $our_order : mixed
Return values
array<string|int, mixed>|string|array<string|int, string>get_email_by_slid()
Get the email address from the location's email field, fetch by id.
private
get_email_by_slid(mixed $id) : string
Parameters
- $id : mixed
Return values
stringinit_OptionsViaAJAX()
Set options based on the AJAX formdata properties.
private
init_OptionsViaAJAX() : mixed
This will allow AJAX entries to take precedence over local options. Typically these are passed via slp.js by using hidden fields with the name attribute. The name must match the options available to this add-on pack for jQuery to pass them along.
is_discrete_widget_search()
Check the nonce is valid and that the widget field is set for unlimited results within a region (state, country, etc.)
private
is_discrete_widget_search(array<string|int, string> $field_list) : bool
Parameters
- $field_list : array<string|int, string>
Return values
boolradius_behavior_ignores_radius()
Does the current radius behavior mean we should ignore the radius?
private
radius_behavior_ignores_radius() : bool
Return values
boolset_autocomplete_vars()
For autocomplete entries just jam the $_REQUEST variables into the formdata property.
private
set_autocomplete_vars() : mixed