SLP® phpDocs

SLP_BaseClass_AJAX extends SLPlus_BaseClass_Object
in package

A base class that helps add-on packs separate AJAX functionality.

Add on packs should include and extend this class.

This allows the main plugin to only include this file in AJAX mode.

Table of Contents

Properties

$addon  : mixed
$myslp  : MySLP
$query_params  : mixed
$slplus  : SLPlus
$uses_myslp  : bool
$uses_slplus  : bool
$formdata  : mixed
$formdata_defaults  : mixed
$query_params_valid  : mixed
$slug  : mixed
$valid_actions  : mixed
$formdata_set  : mixed
$set_query_params_done  : mixed
$short_action  : mixed

Methods

__construct()  : mixed
__get()  : SLPlus_BaseClass_Object
__isset()  : bool
add_ajax_hooks()  : mixed
Override this with the WordPress AJAX hooks you want to invoke.
do_ajax_startup()  : mixed
Things we want our add on packs to do when they start in AJAX mode.
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.
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.

Properties

$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

protected mixed $valid_actions = array('csl_ajax_onload', 'csl_ajax_search')

$set_query_params_done

private mixed $set_query_params_done = \false

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_ajax_hooks()

Override this with the WordPress AJAX hooks you want to invoke.

public add_ajax_hooks() : mixed

example: add_action('wp_ajax_csl_ajax_search' , array( $this,'csl_ajax_search' )) // For logged in users add_action('wp_ajax_nopriv_csl_ajax_search' , array( $this,'csl_ajax_search' )) // Not logged-in users

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.

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

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

        
On this page

Search results