MySLP_REST_API_Customers
extends MySLP_REST_API_Endpoint
in package
REST routes and handlers for customers.
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
- $coordinator : MySLP_REST_API|null
- The manager used by endpoint groups for compatibility calls.
- $myslp : MySLP
- $slplus : SLPlus
Methods
- __construct() : mixed
- Initialize an endpoint group with the existing application objects.
- activate() : void
- Plugin activation function.
- add_account() : WP_REST_Response
- Delegate to the account group for existing PHP callers.
- 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
- Delegate to the accounting group for existing PHP callers.
- create_accounting_key() : WP_REST_Response|WP_Error
- Delegate to the accounting group for existing PHP callers.
- create_accounting_monthly_history() : WP_REST_Response|WP_Error
- Delegate to the accounting group for existing PHP callers.
- delete_accounting_key() : WP_REST_Response|WP_Error
- Delegate to the accounting group for existing PHP callers.
- delete_accounting_monthly_history() : WP_REST_Response|WP_Error
- Delegate to the accounting group for existing PHP callers.
- delete_location() : WP_Error|array<string|int, mixed>
- Delegate to the locations group for existing PHP callers.
- edit_account() : WP_Error|bool|string
- Delegate to the account group for existing PHP callers.
- edit_location() : WP_Error|WP_REST_Response
- Delegate to the locations group for existing PHP callers.
- 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() : array<string|int, mixed>
- Get Site Architect levels from the current network, including on customer blogs.
- get_accounting_keys() : WP_REST_Response
- Delegate to the accounting group for existing PHP callers.
- get_accounting_monthly_history() : WP_REST_Response
- Delegate to the accounting group for existing PHP callers.
- get_accounting_monthly_history_keys() : WP_REST_Response
- Delegate to the accounting group for existing PHP callers.
- get_accounting_monthly_matrix() : WP_REST_Response
- Delegate to the accounting group for existing PHP callers.
- get_accounting_revenue_series() : WP_REST_Response
- Delegate to the accounting group for existing PHP callers.
- 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
- Delegate to the history group for existing PHP callers.
- get_customer_monthly_views_report() : WP_REST_Response|WP_Error
- Return a monthly map-views report for a single customer blog.
- get_customer_overages() : array<string|int, mixed>|WP_Error
- Return monthly overages for a customer. This endpoint uses the same network administrator capability as Manage Customers and never changes billing.
- get_customer_subscriptions() : WP_REST_Response|WP_Error
- Delegate to the subscription group for existing PHP callers.
- get_customers() : array<string|int, mixed>
- Get a paginated, filtered, sorted list of MySLP customers.
- get_endpoint() : string
- Get Endpoint
- get_invoices() : WP_Error|array<string|int, mixed>
- Delegate to the invoices group for existing PHP callers.
- get_locations() : WP_Error|StdClass
- Delegate to the locations group for existing PHP callers.
- get_locations_limit() : WP_Error|WP_REST_Response
- Delegate to the locations group for existing PHP callers.
- get_map_options() : StdClass
- Delegate to the locations group for existing PHP callers.
- get_payment_meta() : WP_Error|array<string|int, mixed>
- Delegate to the account group for existing PHP callers.
- 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
- Delegate to the subscription group for existing PHP callers.
- get_subscription_details() : WP_REST_Response|WP_Error
- Delegate to the subscription group for existing PHP callers.
- get_subscription_invoice() : WP_REST_Response|WP_Error
- Delegate to the subscription group for existing PHP callers.
- get_user_account_info() : array<string|int, mixed>
- Delegate to the accounts group for existing PHP callers.
- myslp_get_base_email() : array<string|int, mixed>|string
- Delegate to the account group for existing PHP callers.
- register_dsra_routes() : void
- Retain the signup and Site Architect registration entry point for PHP callers.
- register_routes() : void
- Register this endpoint group without adding WordPress hooks.
- remote_add_location() : WP_Error|WP_REST_Response
- Create a location using the core location save pipeline.
- render_rest_endpoints() : void
- Render the REST endpoint settings panel with explicit view data.
- rest_api_options() : void
- Network admin page for generating an API key
- run_database_management_action() : array<string|int, mixed>|WP_Error
- Delegate to the database management group for existing PHP callers.
- search_map() : WP_Error|StdClass
- Delegate to the locations group for existing PHP callers.
- system_settings() : void
- API setting page
- update_accounting_key() : WP_REST_Response|WP_Error
- Delegate to the accounting group for existing PHP callers.
- update_accounting_monthly_history() : WP_REST_Response|WP_Error
- Delegate to the accounting group for existing PHP callers.
- get_endpoint_controller() : MySLP_REST_API_Endpoint
- Load each endpoint group once and share the existing application context.
- has_valid_api_key() : bool
- Return true if the specified API key is valid.
- send_error() : WP_Error
- Send back an error.
- 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.
- get_customer_search_user_ids() : array<string|int, int>
- Find customers by WordPress account fields and name-related user meta.
- get_location_count_for_user() : void
- Get location count for a user, handling multisite blog switching.
- prepare_customer_list_response() : array<string|int, mixed>
- Add administrator-specific links and time/locale-dependent status after caching.
Constants
ACCOUNT_ENDPOINT
public
string
ACCOUNT_ENDPOINT
= 'account'
REST_NAMESPACE
public
string
REST_NAMESPACE
= 'myslp-signup/v2'
SITE_ARCHITECT_ENDPOINT
public
string
SITE_ARCHITECT_ENDPOINT
= 'site-architect'
API_REST_NAMESPACE
protected
string
API_REST_NAMESPACE
= 'myslp/v2'
Properties
$coordinator
The manager used by endpoint groups for compatibility calls.
protected
MySLP_REST_API|null
$coordinator
= \null
$myslp
protected
MySLP
$myslp
$slplus
protected
SLPlus
$slplus
Methods
__construct()
Initialize an endpoint group with the existing application objects.
public
__construct(MySLP_REST_API $coordinator) : mixed
Parameters
- $coordinator : MySLP_REST_API
activate()
Plugin activation function.
public
static activate() : void
add_account()
Delegate to the account group for existing PHP callers.
public
add_account(WP_REST_Request $request) : WP_REST_Response
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Responseadd_hooks()
Adding hooks
public
add_hooks() : void
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
Tags
Return values
array<string|int, mixed>|WP_Errorcan_manage_accounting()
Delegate to the accounting group for existing PHP callers.
public
can_manage_accounting() : bool
Return values
boolcreate_accounting_key()
Delegate to the accounting group for existing PHP callers.
public
create_accounting_key(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Response|WP_Errorcreate_accounting_monthly_history()
Delegate to the accounting group for existing PHP callers.
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_Errordelete_accounting_key()
Delegate to the accounting group for existing PHP callers.
public
delete_accounting_key(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Response|WP_Errordelete_accounting_monthly_history()
Delegate to the accounting group for existing PHP callers.
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_Errordelete_location()
Delegate to the locations group for existing PHP callers.
public
delete_location(mixed $data) : WP_Error|array<string|int, mixed>
Parameters
- $data : mixed
Return values
WP_Error|array<string|int, mixed>edit_account()
Delegate to the account group for existing PHP callers.
public
edit_account(WP_REST_Request $request) : WP_Error|bool|string
Parameters
- $request : WP_REST_Request
Return values
WP_Error|bool|stringedit_location()
Delegate to the locations group for existing PHP callers.
public
edit_location(mixed $data) : WP_Error|WP_REST_Response
Parameters
- $data : mixed
Return values
WP_Error|WP_REST_Responseflush_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_Errorgenerate_api_key()
Generate randomize string for an API key
public
generate_api_key() : string
Return values
stringget_account_plan()
Get Site Architect levels from the current network, including on customer blogs.
public
get_account_plan() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —The configured levels, or an empty array when unavailable.
get_accounting_keys()
Delegate to the accounting group for existing PHP callers.
public
get_accounting_keys(WP_REST_Request $request) : WP_REST_Response
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Responseget_accounting_monthly_history()
Delegate to the accounting group for existing PHP callers.
public
get_accounting_monthly_history(WP_REST_Request $request) : WP_REST_Response
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Responseget_accounting_monthly_history_keys()
Delegate to the accounting group for existing PHP callers.
public
get_accounting_monthly_history_keys() : WP_REST_Response
Return values
WP_REST_Responseget_accounting_monthly_matrix()
Delegate to the accounting group for existing PHP callers.
public
get_accounting_monthly_matrix() : WP_REST_Response
Return values
WP_REST_Responseget_accounting_revenue_series()
Delegate to the accounting group for existing PHP callers.
public
get_accounting_revenue_series(WP_REST_Request $request) : WP_REST_Response
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Responseget_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_Responseget_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_Errorget_customer_history()
Delegate to the history group for existing PHP callers.
public
get_customer_history(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Response|WP_Errorget_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_Errorget_customer_overages()
Return monthly overages for a customer. This endpoint uses the same network administrator capability as Manage Customers and never changes billing.
public
get_customer_overages(WP_REST_Request $request) : array<string|int, mixed>|WP_Error
Parameters
- $request : WP_REST_Request
Return values
array<string|int, mixed>|WP_Errorget_customer_subscriptions()
Delegate to the subscription group for existing PHP callers.
public
get_customer_subscriptions(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Response|WP_Errorget_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(string $endpoint) : string
Parameters
- $endpoint : string
Return values
stringget_invoices()
Delegate to the invoices group for existing PHP callers.
public
get_invoices() : WP_Error|array<string|int, mixed>
Return values
WP_Error|array<string|int, mixed>get_locations()
Delegate to the locations group for existing PHP callers.
public
get_locations(WP_REST_Request $request) : WP_Error|StdClass
Parameters
- $request : WP_REST_Request
Return values
WP_Error|StdClassget_locations_limit()
Delegate to the locations group for existing PHP callers.
public
get_locations_limit() : WP_Error|WP_REST_Response
Return values
WP_Error|WP_REST_Responseget_map_options()
Delegate to the locations group for existing PHP callers.
public
get_map_options(WP_REST_Request $request) : StdClass
Parameters
- $request : WP_REST_Request
Return values
StdClassget_payment_meta()
Delegate to the account group for existing PHP callers.
public
get_payment_meta(WP_REST_Request $request) : WP_Error|array<string|int, mixed>
Parameters
- $request : WP_REST_Request
Return values
WP_Error|array<string|int, mixed>get_signup_endpoint_url()
Return the sign-up REST endpoint URL.
public
get_signup_endpoint_url() : string
Return values
stringget_site_architect_endpoint_url()
Return the Site Architect REST endpoint URL.
public
get_site_architect_endpoint_url() : string
Return values
stringget_subscription_customer()
Delegate to the subscription group for existing PHP callers.
public
get_subscription_customer(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Response|WP_Errorget_subscription_details()
Delegate to the subscription group for existing PHP callers.
public
get_subscription_details(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Response|WP_Errorget_subscription_invoice()
Delegate to the subscription group for existing PHP callers.
public
get_subscription_invoice(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Response|WP_Errorget_user_account_info()
Delegate to the accounts group for existing PHP callers.
public
get_user_account_info() : array<string|int, mixed>
Return values
array<string|int, mixed>myslp_get_base_email()
Delegate to the account group for existing PHP callers.
public
myslp_get_base_email(mixed $email) : array<string|int, mixed>|string
Parameters
- $email : mixed
Return values
array<string|int, mixed>|stringregister_dsra_routes()
Retain the signup and Site Architect registration entry point for PHP callers.
public
register_dsra_routes() : void
register_routes()
Register this endpoint group without adding WordPress hooks.
public
register_routes() : void
remote_add_location()
Create a location using the core location save pipeline.
public
remote_add_location(WP_REST_Request $request) : WP_Error|WP_REST_Response
Parameters
- $request : WP_REST_Request
Return values
WP_Error|WP_REST_Responserender_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 an API key
public
rest_api_options() : void
run_database_management_action()
Delegate to the database management group for existing PHP callers.
public
run_database_management_action(WP_REST_Request $request) : array<string|int, mixed>|WP_Error
Parameters
- $request : WP_REST_Request
Return values
array<string|int, mixed>|WP_Errorsearch_map()
Delegate to the locations group for existing PHP callers.
public
search_map(WP_REST_Request $request) : WP_Error|StdClass
Parameters
- $request : WP_REST_Request
Return values
WP_Error|StdClasssystem_settings()
API setting page
public
system_settings() : void
Tags
update_accounting_key()
Delegate to the accounting group for existing PHP callers.
public
update_accounting_key(WP_REST_Request $request) : WP_REST_Response|WP_Error
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Response|WP_Errorupdate_accounting_monthly_history()
Delegate to the accounting group for existing PHP callers.
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_Errorget_endpoint_controller()
Load each endpoint group once and share the existing application context.
protected
get_endpoint_controller(string $group) : MySLP_REST_API_Endpoint
Parameters
- $group : string
Return values
MySLP_REST_API_Endpointhas_valid_api_key()
Return true if the specified API key is valid.
protected
has_valid_api_key(string $key) : bool
Parameters
- $key : string
Return values
boolsend_error()
Send back an error.
protected
send_error() : WP_Error
Return values
WP_Errorbuild_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>get_customer_search_user_ids()
Find customers by WordPress account fields and name-related user meta.
private
get_customer_search_user_ids(string $search) : array<string|int, int>
WP_User_Query's native search does not include first_name, last_name, or nickname user meta. Query both sources independently, then let the caller apply the resulting IDs to its existing paginated customer query.
Parameters
- $search : string
-
Search text from the Manage Customers grid.
Return values
array<string|int, int> —Matching user IDs.
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
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>