SLP_Power_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
- $category_data : mixed
- $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 : mixed
- $short_action : string
- $slplus : SLPlus
- $uses_myslp : bool
- $uses_slplus : bool
- $valid_actions : mixed
- $slug : mixed
- $location_manager : mixed
- $upload_transient : mixed
Methods
- __construct() : mixed
- __get() : SLPlus_BaseClass_Object
- __isset() : bool
- add_ajax_hooks() : mixed
- Add our specific AJAX filters.
- add_category_count_to_orderby() : mixed
- Change the results order.
- add_global_hooks() : mixed
- Global hooks, exposed possibly even outside AJAX.
- create_page() : mixed
- Create A Store Page
- createstring_TagSelectionWhereClause() : array<string|int, string>
- Add the tags condition to the MySQL statement used to fetch locations with JSONP.
- do_ajax_startup() : mixed
- Things we want our add on packs to do when they start in AJAX mode.
- download_locations_csv() : mixed
- Process incoming AJAX request to download the CSV file.
- filter_AJAX_AddHavingClause() : array<string|int, mixed>
- Add to the AJAX having clause
- filter_JSONP_SearchByCategory() : string
- Add the category condition to the MySQL statement used to fetch locations with JSONP.
- filter_JSONP_SearchFilters() : mixed
- Add the selected filters to the search results.
- get_country_list() : mixed
- Return a list of current countries
- get_instance() : static
- Return an instance of the object which is also registered to the slplus global less the SLP_ part.
- get_location_marker() : mixed
- Set the location marker based on categories.
- get_state_list() : mixed
- Return a list of current states
- initialize() : mixed
- Set up our environment.
- is_valid_ajax_action() : mixed
- Return true if the AJAX action is one we process.
- location_download_in_background() : mixed
- Start the process to download the locations in the background.
- log_locations_for_reporting() : mixed
- New method to log location processing results.
- log_search_queries_and_results() : void
- Log the search query and results into the reporting tables.
- modify_ajax_markers() : mixed
- Modify the marker data.
- modify_formdata() : array<string|int, mixed>
- Modify the AJAX received form data.
- modify_js_response() : array<string|int, mixed>
- Add the data_type to the JSON response meta.
- process_slp_clear_import_messages() : mixed
- Clear the import messages transient.
- 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.
- clean_request() : mixed
- Clean the $_REQUEST array of some things we don't want to track.
- create_location_manager() : mixed
- Attach the location_manager object.
- format_meta_for_media_library() : string
- Format interesting meta into a string for the media library.
- log_search_query() : int
- Log the search query that was used.
- log_search_results() : mixed
- Log the search results that were returned.
- set_contact_fields() : array<string|int, mixed>
- Set the special contact fields to be returned by AJAX for this location.
- set_location_category_properties() : array<string|int, mixed>
- Set the category properties to be returned by AJAX for this location.
- set_location_pages_properties() : array<string|int, mixed>
- Modify the marker if pages is active.
- set_location_tags() : array<string|int, mixed>
- Set the tags property to be returned by AJAX for this location.
- set_pages_url() : string
- Set the pages URL for the given location, only if the page status is PUBLISH.
Properties
$addon
public
mixed
$addon
$category_data
public
mixed
$category_data
$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
mixed
$query_params_valid
= array('options')
$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_background_location_download', 'slp_change_option', 'slp_clear_import_messages', 'slp_create_page', 'slp_download_locations_csv', 'slp_get_country_list', 'slp_get_state_list')
$slug
protected
mixed
$slug
$location_manager
private
mixed
$location_manager
$upload_transient
private
mixed
$upload_transient
= 'slp_uploads_path'
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
Tags
add_category_count_to_orderby()
Change the results order.
public
add_category_count_to_orderby() : mixed
Precedence is given to the order by category count option over all other extensions that came before it. This is enacted by placing the special category count clause as the first parameter of extend_OrderBy, and by setting the filter to a high priority (run last).
add_global_hooks()
Global hooks, exposed possibly even outside AJAX.
public
add_global_hooks() : mixed
create_page()
Create A Store Page
public
create_page() : mixed
Tags
createstring_TagSelectionWhereClause()
Add the tags condition to the MySQL statement used to fetch locations with JSONP.
public
createstring_TagSelectionWhereClause(array<string|int, string> $currentFilters) : array<string|int, string>
Parameters
- $currentFilters : array<string|int, string>
Return values
array<string|int, string>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
download_locations_csv()
Process incoming AJAX request to download the CSV file.
public
download_locations_csv() : mixed
TODO: use locations extended class
filter_AJAX_AddHavingClause()
Add to the AJAX having clause
public
filter_AJAX_AddHavingClause(array<string|int, mixed> $clauseArray) : array<string|int, mixed>
Parameters
- $clauseArray : array<string|int, mixed>
Return values
array<string|int, mixed>filter_JSONP_SearchByCategory()
Add the category condition to the MySQL statement used to fetch locations with JSONP.
public
filter_JSONP_SearchByCategory(string $currentFilters) : string
Parameters
- $currentFilters : string
Tags
Return values
stringfilter_JSONP_SearchFilters()
Add the selected filters to the search results.
public
filter_JSONP_SearchFilters(mixed $where) : mixed
Do not modify the search if the request did not come through AJAX.
Parameters
- $where : mixed
get_country_list()
Return a list of current countries
public
get_country_list() : 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
staticget_location_marker()
Set the location marker based on categories.
public
get_location_marker() : mixed
get_state_list()
Return a list of current states
public
get_state_list() : mixed
initialize()
Set up our environment.
public
final initialize() : mixed
Tags
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
location_download_in_background()
Start the process to download the locations in the background.
public
location_download_in_background() : mixed
log_locations_for_reporting()
New method to log location processing results.
public
log_locations_for_reporting(mixed $results) : mixed
Parameters
- $results : mixed
log_search_queries_and_results()
Log the search query and results into the reporting tables.
public
log_search_queries_and_results(array<string|int, mixed> $query_params, array<string|int, string> $results) : void
$query_params['QUERY_STRING'] => 'the query string';
$query_params['tags'] => 'tags,used,for,this,query';
$query_params['address'] => 'address for, the search';
$query_params['radius'] => 'radius_of_search';
Parameters
- $query_params : array<string|int, mixed>
-
Contain query sql, tags, address and radius
- $results : array<string|int, string>
-
Query result row id (integers) array.
modify_ajax_markers()
Modify the marker data.
public
modify_ajax_markers(array<string|int, mixed> $marker) : mixed
Parameters
- $marker : array<string|int, mixed>
-
the current marker data
Tags
modify_formdata()
Modify the AJAX received form data.
public
modify_formdata(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>modify_js_response()
Add the data_type to the JSON response meta.
public
modify_js_response(array<string|int, mixed> $response, int|object $attachment, array<string|int, mixed> $meta) : array<string|int, mixed>
Parameters
- $response : array<string|int, mixed>
-
Array of prepared attachment data.
- $attachment : int|object
-
Attachment ID or object.
- $meta : array<string|int, mixed>
-
Array of attachment meta data.
Return values
array<string|int, mixed>process_slp_clear_import_messages()
Clear the import messages transient.
public
process_slp_clear_import_messages() : mixed
Runs via do_ajax_startup() in the base class.
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
clean_request()
Clean the $_REQUEST array of some things we don't want to track.
private
clean_request() : mixed
Tags
create_location_manager()
Attach the location_manager object.
private
create_location_manager() : mixed
format_meta_for_media_library()
Format interesting meta into a string for the media library.
private
format_meta_for_media_library(mixed $meta) : string
Parameters
- $meta : mixed
Return values
stringlog_search_query()
Log the search query that was used.
private
log_search_query(array<string|int, mixed> $query_params) : int
Parameters
- $query_params : array<string|int, mixed>
-
Contain query sql, tags, address and radius
Return values
int —the insert ID for this record.
log_search_results()
Log the search results that were returned.
private
log_search_results(array<string|int, string> $location_ids, int $inserted_query_id) : mixed
Parameters
- $location_ids : array<string|int, string>
- $inserted_query_id : int
set_contact_fields()
Set the special contact fields to be returned by AJAX for this location.
private
set_contact_fields(array<string|int, mixed> $marker) : array<string|int, mixed>
Parameters
- $marker : array<string|int, mixed>
Return values
array<string|int, mixed>set_location_category_properties()
Set the category properties to be returned by AJAX for this location.
private
set_location_category_properties(array<string|int, mixed> $marker) : array<string|int, mixed>
Parameters
- $marker : array<string|int, mixed>
Return values
array<string|int, mixed>set_location_pages_properties()
Modify the marker if pages is active.
private
set_location_pages_properties(array<string|int, mixed> $marker) : array<string|int, mixed>
Parameters
- $marker : array<string|int, mixed>
Return values
array<string|int, mixed>set_location_tags()
Set the tags property to be returned by AJAX for this location.
private
set_location_tags(array<string|int, mixed> $marker) : array<string|int, mixed>
Parameters
- $marker : array<string|int, mixed>
Return values
array<string|int, mixed> —mixed
set_pages_url()
Set the pages URL for the given location, only if the page status is PUBLISH.
private
set_pages_url(array<string|int, mixed> $marker) : string
Parameters
- $marker : array<string|int, mixed>