SLP® phpDocs

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

$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?

$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_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

Methods

__construct()

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

__isset()

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

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
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_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
used-by

\SLP_AJAX::execute_location_query via Filter slp_location_filters_for_AJAX

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
string

filter_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
string

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
static

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

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
string

remove_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|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_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

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
string

create_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
string

init_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.

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
bool

radius_behavior_ignores_radius()

Does the current radius behavior mean we should ignore the radius?

private radius_behavior_ignores_radius() : bool
Return values
bool

set_autocomplete_vars()

For autocomplete entries just jam the $_REQUEST variables into the formdata property.

private set_autocomplete_vars() : mixed

        
On this page

Search results