SLPĀ® phpDocs

MySLP_REST_API
in package

Class MySLP_REST_API

Table of Contents

Constants

ACCOUNT_ENDPOINT  : string = 'account'
REST_NAMESPACE  : string = 'myslp-signup/v2'
SITE_ARCHITECT_ENDPOINT  : string = 'site-architect'
API_REST_NAMESPACE  : string = 'myslp/v2'

Properties

$DSIGN_key  : mixed
$myslp  : MySLP
$options  : string|null
$paypal_options  : mixed
$slplus  : SLPlus
$status  : array<string, bool>
$user  : int|null

Methods

__construct()  : mixed
Default things to do/load when running this plugin
activate()  : void
Plugin activation function.
add_account()  : WP_REST_Response
Start adding new sub site here
add_hooks()  : void
Adding hooks
admin_script()  : void
Include scripts/style for this plugin
bulk_action_customers()  : array<string|int, mixed>|WP_Error
Handle bulk actions on the customer's list (React UI).
can_manage_accounting()  : bool
Verify the current user can manage accounting data.
create_accounting_key()  : WP_REST_Response|WP_Error
Create an accounting key row.
create_accounting_monthly_history()  : WP_REST_Response|WP_Error
Create an accounting monthly history row.
delete_accounting_key()  : WP_REST_Response|WP_Error
Delete an accounting key row.
delete_accounting_monthly_history()  : WP_REST_Response|WP_Error
Delete an accounting monthly history row.
delete_location()  : WP_Error|array<string|int, mixed>
Delete location
edit_account()  : WP_Error|bool|string
Edit user metadata
edit_location()  : mixed
Edit location
flush_customer_cache()  : WP_REST_Response|WP_Error
REST permissions and cookie-auth nonces are enforced before this callback.
generate_api_key()  : string
Generate randomize string for an API key
get_account_plan()  : mixed
Get Site Architect Levels
get_accounting_keys()  : WP_REST_Response
List accounting key records.
get_accounting_monthly_history()  : WP_REST_Response
List accounting monthly history rows.
get_accounting_monthly_history_keys()  : WP_REST_Response
Return the distinct ledger keys for quick-fill UIs.
get_accounting_monthly_matrix()  : WP_REST_Response
Return a gap-free monthly summary matrix grouped by entry_key.
get_accounting_revenue_series()  : WP_REST_Response
Return the SAAS_REVENUE series for chart rendering.
get_active_customer_stats()  : WP_REST_Response
Return the total count of active customer accounts and the sum of their payments.
get_customer_details()  : array<string|int, mixed>|WP_Error
Get the primary account properties and user meta for one MySLP customer.
get_customer_history()  : WP_REST_Response|WP_Error
Return customer profile history rows for the given blog_id.
get_customer_monthly_views_report()  : WP_REST_Response|WP_Error
Return a monthly map-views report for a single customer blog.
get_customer_subscriptions()  : WP_REST_Response|WP_Error
Retrieve the subscriptions associated with the logged-in Stripe customer.
get_customers()  : array<string|int, mixed>
Get a paginated, filtered, sorted list of MySLP customers.
get_endpoint()  : string
Get Endpoint
get_invoices()  : array<string|int, mixed>|WP_Error
Retrieve a list of invoices.
get_locations()  : WP_Error|StdClass
Get all locations
get_locations_limit()  : WP_Error|WP_REST_Response
Callback for locations-limit route
get_map_options()  : StdClass
Get options if api key is active
get_payment_meta()  : array<string|int, mixed>|WP_Error
Get Payment Meta.
get_signup_endpoint_url()  : string
Return the sign-up REST endpoint URL.
get_site_architect_endpoint_url()  : string
Return the Site Architect REST endpoint URL.
get_subscription_customer()  : WP_REST_Response|WP_Error
Retrieve the logged-in customer's Stripe details.
get_subscription_details()  : WP_REST_Response|WP_Error
Retrieve an authorized Stripe subscription and normalize its detail fields.
get_subscription_invoice()  : WP_REST_Response|WP_Error
Retrieve a Stripe invoice associated with the logged-in customer.
get_user_account_info()  : array<string|int, mixed>
Get user account info
myslp_email_reg_data()  : mixed
Email user regarding registration data
myslp_get_base_email()  : array<string|int, mixed>|string
Create username based on email
register_dsra_routes()  : void
Register the necessary routes in here
register_routes()  : void
Register the necessary routes in here
render_rest_endpoints()  : void
Render the REST endpoint settings panel with explicit view data.
rest_api_options()  : void
Network admin page for generating API key
search_map()  : WP_Error|StdClass
Search map locations if api key is active
system_settings()  : void
API setting page
update_accounting_key()  : WP_REST_Response|WP_Error
Update an accounting key row.
update_accounting_monthly_history()  : WP_REST_Response|WP_Error
Update an accounting monthly history row.
attach_core_scripts()  : string
Return the MySLP and Core JavaScript as a string.
build_active_customer_stats()  : array<string|int, mixed>
Query the global active-account summary only on a cache miss.
build_customer_list()  : array<string|int, mixed>
Build neutral grid data only on a cache miss; retain existing query semantics.
catch_addon_scripts()  : array<string|int, mixed>
Get add on scripts.
catch_addon_styles()  : array<string|int, mixed>
check_activation()  : bool
Check if the api key is active
get_accounting_keys_store()  : string
Load the accounting key helper and return the class name.
get_accounting_monthly_history_store()  : string
Load the accounting monthly history helper and return the class name.
get_api_key()  : mixed
Return our API key (and cache it).
get_inline_style()  : string
get_layout_data()  : false|string
Get the DIV HTML for SLPLUS
get_location_count_for_user()  : void
Get location count for a user, handling multisite blog switching.
get_map_locations()  : array<string|int, mixed>
Get map locations, with its map positions
get_options()  : StdClass
Get options
get_options_data()  : false|string
Set the option data in the SLP scripts.
get_sa_allowed_plugins()  : array<string|int, mixed>
Get Site Architect Levels
get_stripe_object_id()  : string
Extract a Stripe object ID from either an ID string or expanded object.
get_subscription_customer_id()  : string
Return the Stripe customer ID associated with the current subscription.
has_valid_api_key()  : bool
Return true if the specified API key is valid.
myslp_get_dep_scripts()  : array<string|int, mixed>
Get dependent scripts.
normalize_stripe_default_source_details()  : array<string|int, mixed>
Return the non-sensitive default source fields needed by the profile UI.
prepare_customer_list_response()  : array<string|int, mixed>
Add administrator-specific links and time/locale-dependent status after caching.
save_setting()  : void
Save an admin tab setting.
send_error()  : WP_Error
Send back an error.
set_options()  : void
Set db prefix according to the user, who got api key provided in the request
validate_subscription_customer_request()  : string|WP_Error
Validate that a customer request belongs to the current subscription.

Constants

SITE_ARCHITECT_ENDPOINT

public string SITE_ARCHITECT_ENDPOINT = 'site-architect'

API_REST_NAMESPACE

private string API_REST_NAMESPACE = 'myslp/v2'

Properties

$paypal_options

private mixed $paypal_options = array('api_username' => '', 'api_password' => '', 'api_signature' => '', 'use_ec_sandbox' => '', 'version' => '', 'sbncode' => '', 'use_proxy' => '', 'proxy_host' => '', 'proxy_port' => '')

Methods

__construct()

Default things to do/load when running this plugin

public __construct() : mixed

activate()

Plugin activation function.

public static activate() : void

add_account()

Start adding new sub site here

public add_account(WP_REST_Request $request) : WP_REST_Response
Parameters
$request : WP_REST_Request
Tags
rest-route

/myslp-signup/v2/account/

throws
ApiErrorException
Return values
WP_REST_Response

admin_script()

Include scripts/style for this plugin

public admin_script(mixed $hook) : void
Parameters
$hook : mixed

bulk_action_customers()

Handle bulk actions on the customer's list (React UI).

public bulk_action_customers(WP_REST_Request $request) : array<string|int, mixed>|WP_Error
Parameters
$request : WP_REST_Request
Return values
array<string|int, mixed>|WP_Error

can_manage_accounting()

Verify the current user can manage accounting data.

public can_manage_accounting() : bool
Return values
bool

create_accounting_key()

Create an accounting key row.

public create_accounting_key(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
$request : WP_REST_Request
Return values
WP_REST_Response|WP_Error

create_accounting_monthly_history()

Create an accounting monthly history row.

public create_accounting_monthly_history(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
$request : WP_REST_Request
Return values
WP_REST_Response|WP_Error

delete_accounting_key()

Delete an accounting key row.

public delete_accounting_key(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
$request : WP_REST_Request
Return values
WP_REST_Response|WP_Error

delete_accounting_monthly_history()

Delete an accounting monthly history row.

public delete_accounting_monthly_history(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
$request : WP_REST_Request
Return values
WP_REST_Response|WP_Error

delete_location()

Delete location

public delete_location(mixed $data) : WP_Error|array<string|int, mixed>
Parameters
$data : mixed
Return values
WP_Error|array<string|int, mixed>

edit_account()

Edit user metadata

public edit_account(WP_REST_Request $request) : WP_Error|bool|string
Parameters
$request : WP_REST_Request
Tags
Param

: id user ID account_status customer account status plan customer subscription plan

Return values
WP_Error|bool|string

edit_location()

Edit location

public edit_location(mixed $data) : mixed
Parameters
$data : mixed

flush_customer_cache()

REST permissions and cookie-auth nonces are enforced before this callback.

public flush_customer_cache() : WP_REST_Response|WP_Error
Return values
WP_REST_Response|WP_Error

generate_api_key()

Generate randomize string for an API key

public generate_api_key() : string
Return values
string

get_account_plan()

Get Site Architect Levels

public get_account_plan() : mixed
Tags
used-by

WP_REST_Server::dispatch()

get_accounting_keys()

List accounting key records.

public get_accounting_keys(WP_REST_Request $request) : WP_REST_Response
Parameters
$request : WP_REST_Request
Return values
WP_REST_Response

get_accounting_monthly_history()

List accounting monthly history rows.

public get_accounting_monthly_history(WP_REST_Request $request) : WP_REST_Response
Parameters
$request : WP_REST_Request
Return values
WP_REST_Response

get_accounting_monthly_history_keys()

Return the distinct ledger keys for quick-fill UIs.

public get_accounting_monthly_history_keys() : WP_REST_Response
Return values
WP_REST_Response

get_accounting_monthly_matrix()

Return a gap-free monthly summary matrix grouped by entry_key.

public get_accounting_monthly_matrix() : WP_REST_Response
Return values
WP_REST_Response

get_accounting_revenue_series()

Return the SAAS_REVENUE series for chart rendering.

public get_accounting_revenue_series(WP_REST_Request $request) : WP_REST_Response
Parameters
$request : WP_REST_Request
Return values
WP_REST_Response

get_active_customer_stats()

Return the total count of active customer accounts and the sum of their payments.

public get_active_customer_stats() : WP_REST_Response

Used by the Manage Customers React UI to populate the persistent summary chips. Always queries the active account_status — independent of the current filter tab.

Return values
WP_REST_Response

get_customer_details()

Get the primary account properties and user meta for one MySLP customer.

public get_customer_details(WP_REST_Request $request) : array<string|int, mixed>|WP_Error
Parameters
$request : WP_REST_Request
Return values
array<string|int, mixed>|WP_Error

get_customer_history()

Return customer profile history rows for the given blog_id.

public get_customer_history(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
$request : WP_REST_Request
Return values
WP_REST_Response|WP_Error

get_customer_monthly_views_report()

Return a monthly map-views report for a single customer blog.

public get_customer_monthly_views_report(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
$request : WP_REST_Request

REST request.

Return values
WP_REST_Response|WP_Error

get_customer_subscriptions()

Retrieve the subscriptions associated with the logged-in Stripe customer.

public get_customer_subscriptions(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
$request : WP_REST_Request

REST request.

Return values
WP_REST_Response|WP_Error

get_customers()

Get a paginated, filtered, sorted list of MySLP customers.

public get_customers(WP_REST_Request $request) : array<string|int, mixed>
Parameters
$request : WP_REST_Request
Return values
array<string|int, mixed>

get_endpoint()

Get Endpoint

public get_endpoint(mixed $endpoint) : string
Parameters
$endpoint : mixed
Return values
string

get_invoices()

Retrieve a list of invoices.

public get_invoices() : array<string|int, mixed>|WP_Error
APIYes
Return values
array<string|int, mixed>|WP_Error —

A list of invoices or a WP_Error instance if fetching fails.

get_locations()

Get all locations

public get_locations(WP_REST_Request $request) : WP_Error|StdClass
Parameters
$request : WP_REST_Request
Return values
WP_Error|StdClass

get_locations_limit()

Callback for locations-limit route

public get_locations_limit() : WP_Error|WP_REST_Response
Tags
global

type $myslp_current_blog_settings

Return values
WP_Error|WP_REST_Response —

location with its limit

get_map_options()

Get options if api key is active

public get_map_options(WP_REST_Request $request) : StdClass
Parameters
$request : WP_REST_Request
Return values
StdClass

get_payment_meta()

Get Payment Meta.

public get_payment_meta(WP_REST_Request $request) : array<string|int, mixed>|WP_Error
Parameters
$request : WP_REST_Request
Tags
used-by

MySLP_REST_API::register_dsra_routes

MySLP_Signup_Connector_Dashboard::get_rest

Return values
array<string|int, mixed>|WP_Error

get_signup_endpoint_url()

Return the sign-up REST endpoint URL.

public get_signup_endpoint_url() : string
Return values
string

get_site_architect_endpoint_url()

Return the Site Architect REST endpoint URL.

public get_site_architect_endpoint_url() : string
Return values
string

get_subscription_customer()

Retrieve the logged-in customer's Stripe details.

public get_subscription_customer(WP_REST_Request $request) : WP_REST_Response|WP_Error

The customer ID is validated against the account's subscription before the Stripe request so an authenticated user cannot query another customer.

Parameters
$request : WP_REST_Request

REST request.

Return values
WP_REST_Response|WP_Error

get_subscription_details()

Retrieve an authorized Stripe subscription and normalize its detail fields.

public get_subscription_details(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
$request : WP_REST_Request

REST request.

Return values
WP_REST_Response|WP_Error

get_subscription_invoice()

Retrieve a Stripe invoice associated with the logged-in customer.

public get_subscription_invoice(WP_REST_Request $request) : WP_REST_Response|WP_Error

The requested invoice must be returned by Stripe for the customer's own subscriptions. Only the fields needed by the profile UI are returned.

Parameters
$request : WP_REST_Request

REST request.

Return values
WP_REST_Response|WP_Error

get_user_account_info()

Get user account info

public get_user_account_info() : array<string|int, mixed>
Return values
array<string|int, mixed>

myslp_email_reg_data()

Email user regarding registration data

public myslp_email_reg_data(mixed $site_url, mixed $username, mixed $password, mixed $email) : mixed
Parameters
$site_url : mixed
$username : mixed
$password : mixed
$email : mixed

myslp_get_base_email()

Create username based on email

public myslp_get_base_email(mixed $email) : array<string|int, mixed>|string
Parameters
$email : mixed
Return values
array<string|int, mixed>|string

register_dsra_routes()

Register the necessary routes in here

public register_dsra_routes() : void

register_routes()

Register the necessary routes in here

public register_routes() : void

render_rest_endpoints()

Render the REST endpoint settings panel with explicit view data.

public render_rest_endpoints([string|null $form_slug = null ][, string|null $current = null ]) : void
Parameters
$form_slug : string|null = null
$current : string|null = null

rest_api_options()

Network admin page for generating API key

public rest_api_options() : void

search_map()

Search map locations if api key is active

public search_map(WP_REST_Request $request) : WP_Error|StdClass
Parameters
$request : WP_REST_Request
Return values
WP_Error|StdClass

system_settings()

API setting page

public system_settings() : void

update_accounting_key()

Update an accounting key row.

public update_accounting_key(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
$request : WP_REST_Request
Return values
WP_REST_Response|WP_Error

update_accounting_monthly_history()

Update an accounting monthly history row.

public update_accounting_monthly_history(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
$request : WP_REST_Request
Return values
WP_REST_Response|WP_Error

attach_core_scripts()

Return the MySLP and Core JavaScript as a string.

private attach_core_scripts() : string
Return values
string

build_active_customer_stats()

Query the global active-account summary only on a cache miss.

private build_active_customer_stats() : array<string|int, mixed>
Return values
array<string|int, mixed>

build_customer_list()

Build neutral grid data only on a cache miss; retain existing query semantics.

private build_customer_list(array<string|int, mixed> $parameters) : array<string|int, mixed>
Parameters
$parameters : array<string|int, mixed>
Return values
array<string|int, mixed>

catch_addon_scripts()

Get add on scripts.

private catch_addon_scripts() : array<string|int, mixed>
Return values
array<string|int, mixed>

catch_addon_styles()

private catch_addon_styles() : array<string|int, mixed>
Return values
array<string|int, mixed>

check_activation()

Check if the api key is active

private check_activation(string $API_key) : bool
Parameters
$API_key : string

The api key

Return values
bool —

True if the api key is active, else false

get_accounting_keys_store()

Load the accounting key helper and return the class name.

private get_accounting_keys_store() : string
Return values
string

get_accounting_monthly_history_store()

Load the accounting monthly history helper and return the class name.

private get_accounting_monthly_history_store() : string
Return values
string

get_api_key()

Return our API key (and cache it).

private get_api_key() : mixed

get_inline_style()

private get_inline_style() : string
Return values
string

get_layout_data()

Get the DIV HTML for SLPLUS

private get_layout_data(array<string|int, mixed> $attributes) : false|string
Parameters
$attributes : array<string|int, mixed>
Return values
false|string

get_location_count_for_user()

Get location count for a user, handling multisite blog switching.

private get_location_count_for_user(int $user_id) : void
Parameters
$user_id : int

get_map_locations()

Get map locations, with its map positions

private get_map_locations(array<string|int, mixed> $query) : array<string|int, mixed>
Parameters
$query : array<string|int, mixed>

The executable query params | null to get from default options

Return values
array<string|int, mixed> —

Locations

get_options()

Get options

private get_options(array<string|int, mixed> $attributes) : StdClass
Parameters
$attributes : array<string|int, mixed>
Tags
used-by

get_map_options

Return values
StdClass —

The all map options.

get_options_data()

Set the option data in the SLP scripts.

private get_options_data() : false|string
Tags
uses
SLP_Actions::wp_enqueue_scripts
Return values
false|string

get_sa_allowed_plugins()

Get Site Architect Levels

private get_sa_allowed_plugins() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_stripe_object_id()

Extract a Stripe object ID from either an ID string or expanded object.

private get_stripe_object_id(mixed $value) : string
Parameters
$value : mixed

Stripe API value.

Return values
string

get_subscription_customer_id()

Return the Stripe customer ID associated with the current subscription.

private get_subscription_customer_id() : string
Return values
string

has_valid_api_key()

Return true if the specified API key is valid.

private has_valid_api_key(string $key) : bool
Parameters
$key : string
Return values
bool

myslp_get_dep_scripts()

Get dependent scripts.

private myslp_get_dep_scripts(mixed $deps[, array<string|int, mixed> $return = array() ]) : array<string|int, mixed>
Parameters
$deps : mixed
$return : array<string|int, mixed> = array()
Return values
array<string|int, mixed>

normalize_stripe_default_source_details()

Return the non-sensitive default source fields needed by the profile UI.

private normalize_stripe_default_source_details(array<string|int, mixed> $source) : array<string|int, mixed>
Parameters
$source : array<string|int, mixed>

Stripe source or card data.

Return values
array<string|int, mixed>

prepare_customer_list_response()

Add administrator-specific links and time/locale-dependent status after caching.

private prepare_customer_list_response(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>
Return values
array<string|int, mixed>

save_setting()

Save an admin tab setting.

private save_setting(mixed $message) : void
Parameters
$message : mixed

send_error()

Send back an error.

private send_error() : WP_Error
Return values
WP_Error

set_options()

Set db prefix according to the user, who got api key provided in the request

private set_options() : void

validate_subscription_customer_request()

Validate that a customer request belongs to the current subscription.

private validate_subscription_customer_request(WP_REST_Request $request) : string|WP_Error
Parameters
$request : WP_REST_Request

REST request.

Return values
string|WP_Error
On this page

Search results