WC_REST_System_Status_Controller
extends WC_REST_System_Status_V2_Controller
in package
System status controller class.
Tags
Table of Contents
- $namespace : string
- Endpoint namespace.
- $rest_base : string
- Route base.
- $_fields : null|array
- Used to cache computed return fields.
- $_request : null|WP_REST_Request
- Used to verify if cached fields are for correct request object.
- batch_items() : array
- Bulk create, update and delete items.
- get_active_plugins() : array
- Get a list of plugins active on the site.
- get_collection_params() : array
- Get any query params needed.
- get_database_info() : array
- Get array of database information. Version, prefix, and table existence.
- get_dropins_mu_plugins() : array
- Get a list of Dropins and MU plugins.
- get_endpoint_args_for_item_schema() : array
- Compatibility functions for WP 5.5, since custom types are not supported anymore.
- get_environment_info() : array
- Get array of environment information. Includes thing like software versions, and various server settings.
- get_environment_info_per_fields() : array
- Get array of environment information. Includes thing like software versions, and various server settings.
- get_fields_for_response() : array
- Gets an array of fields to be included on the response.
- get_inactive_plugins() : array
- Get a list of inplugins active on the site.
- get_item_mappings() : array
- Return an array of sections and the data associated with each.
- get_item_mappings_per_fields() : array
- Return an array of sections and the data associated with each.
- get_item_schema() : array
- Get the system status schema, conforming to JSON Schema.
- get_items() : WP_Error|WP_REST_Response
- Get a system status info, by section.
- get_items_permissions_check() : WP_Error|bool
- Check whether a given request has permission to view system status.
- get_pages() : array
- Returns a mini-report on WC pages and if they are configured correctly: Present, visible, and including the correct shortcode.
- get_post_type_counts() : array
- Get array of counts of objects. Orders, products, etc.
- get_public_batch_schema() : array
- Get the batch schema, conforming to JSON Schema.
- get_security_info() : array
- Returns security tips.
- get_settings() : array
- Get some setting values for the site that are useful for debugging purposes. For full settings access, use the settings api.
- get_theme_info() : array
- Get info on the current active theme, info on parent theme (if presnet) and a list of template overrides.
- prepare_item_for_response() : WP_REST_Response
- Prepare the system status response
- register_routes() : mixed
- Register the route for /system_status
- validate_setting_checkbox_field() : string|WP_Error
- Validate checkbox based settings.
- validate_setting_image_width_field() : string|WP_Error
- Validate image_width based settings.
- validate_setting_multiselect_field() : array|WP_Error
- Validate multiselect based settings.
- validate_setting_radio_field() : string|WP_Error
- Validate radio based settings.
- validate_setting_select_field() : string|WP_Error
- Validate select based settings.
- validate_setting_text_field() : string
- Validate a text value for a text based setting.
- validate_setting_textarea_field() : string
- Validate textarea based settings.
- add_additional_fields_schema() : array
- Add the schema from additional fields to an schema array.
- add_db_table_prefix() : stromg
- Add prefix to table.
- add_meta_query() : array
- Add meta query.
- adjust_wp_5_5_datatype_compatibility() : mixed
- Change datatypes `date-time` to string, and `mixed` to composite of all built in types. This is required for maintaining forward compatibility with WP 5.5 since custom post types are not supported anymore.
- check_batch_limit() : bool|WP_Error
- Check batch limit.
- format_plugin_data() : array
- Format plugin data, including data on updates, into a standard format.
- get_normalized_rest_base() : string
- Get normalized rest base.
- check_if_field_item_exists() : bool
- Check if field item exists.
Properties
$namespace
Endpoint namespace.
protected
string
$namespace
= 'wc/v3'
$rest_base
Route base.
protected
string
$rest_base
= ''
$_fields
Used to cache computed return fields.
private
null|array
$_fields
=
ull
$_request
Used to verify if cached fields are for correct request object.
private
null|WP_REST_Request
$_request
=
ull
Methods
batch_items()
Bulk create, update and delete items.
public
batch_items(WP_REST_Request $request) : array
Parameters
- $request : WP_REST_Request
-
Full details about the request.
Return values
array — Of WP_Error or WP_REST_Response.get_active_plugins()
Get a list of plugins active on the site.
public
get_active_plugins() : array
Return values
arrayget_collection_params()
Get any query params needed.
public
get_collection_params() : array
Return values
arrayget_database_info()
Get array of database information. Version, prefix, and table existence.
public
get_database_info() : array
Return values
arrayget_dropins_mu_plugins()
Get a list of Dropins and MU plugins.
public
get_dropins_mu_plugins() : array
Tags
Return values
arrayget_endpoint_args_for_item_schema()
Compatibility functions for WP 5.5, since custom types are not supported anymore.
public
get_endpoint_args_for_item_schema([string $method = WP_REST_Server::CREATABLE ]) : array
Parameters
- $method : string = WP_REST_Server::CREATABLE
-
Optional. HTTP method of the request.
Return values
array — Endpoint arguments.get_environment_info()
Get array of environment information. Includes thing like software versions, and various server settings.
public
get_environment_info() : array
Tags
Return values
arrayget_environment_info_per_fields()
Get array of environment information. Includes thing like software versions, and various server settings.
public
get_environment_info_per_fields(array $fields) : array
Parameters
- $fields : array
-
List of fields to be included on the response.
Return values
arrayget_fields_for_response()
Gets an array of fields to be included on the response.
public
get_fields_for_response(WP_REST_Request $request) : array
Included fields are based on item schema and _fields=
request argument.
Updated from WordPress 5.3, included into this class to support old versions.
Parameters
- $request : WP_REST_Request
-
Full details about the request.
Tags
Return values
array — Fields to be included in the response.get_inactive_plugins()
Get a list of inplugins active on the site.
public
get_inactive_plugins() : array
Return values
arrayget_item_mappings()
Return an array of sections and the data associated with each.
public
get_item_mappings() : array
Tags
Return values
arrayget_item_mappings_per_fields()
Return an array of sections and the data associated with each.
public
get_item_mappings_per_fields(array $fields) : array
Parameters
- $fields : array
-
List of fields to be included on the response.
Tags
Return values
arrayget_item_schema()
Get the system status schema, conforming to JSON Schema.
public
get_item_schema() : array
Return values
arrayget_items()
Get a system status info, by section.
public
get_items(WP_REST_Request $request) : WP_Error|WP_REST_Response
Parameters
- $request : WP_REST_Request
-
Full details about the request.
Return values
WP_Error|WP_REST_Responseget_items_permissions_check()
Check whether a given request has permission to view system status.
public
get_items_permissions_check(WP_REST_Request $request) : WP_Error|bool
Parameters
- $request : WP_REST_Request
-
Full details about the request.
Return values
WP_Error|boolget_pages()
Returns a mini-report on WC pages and if they are configured correctly: Present, visible, and including the correct shortcode.
public
get_pages() : array
Return values
arrayget_post_type_counts()
Get array of counts of objects. Orders, products, etc.
public
get_post_type_counts() : array
Return values
arrayget_public_batch_schema()
Get the batch schema, conforming to JSON Schema.
public
get_public_batch_schema() : array
Return values
arrayget_security_info()
Returns security tips.
public
get_security_info() : array
Return values
arrayget_settings()
Get some setting values for the site that are useful for debugging purposes. For full settings access, use the settings api.
public
get_settings() : array
Return values
arrayget_theme_info()
Get info on the current active theme, info on parent theme (if presnet) and a list of template overrides.
public
get_theme_info() : array
Return values
arrayprepare_item_for_response()
Prepare the system status response
public
prepare_item_for_response(array $system_status, WP_REST_Request $request) : WP_REST_Response
Parameters
- $system_status : array
-
System status data.
- $request : WP_REST_Request
-
Request object.
Return values
WP_REST_Responseregister_routes()
Register the route for /system_status
public
register_routes() : mixed
Return values
mixedvalidate_setting_checkbox_field()
Validate checkbox based settings.
public
validate_setting_checkbox_field(string $value, array $setting) : string|WP_Error
Parameters
- $value : string
-
Value.
- $setting : array
-
Setting.
Tags
Return values
string|WP_Errorvalidate_setting_image_width_field()
Validate image_width based settings.
public
validate_setting_image_width_field(array $values, array $setting) : string|WP_Error
Parameters
- $values : array
-
Values.
- $setting : array
-
Setting.
Tags
Return values
string|WP_Errorvalidate_setting_multiselect_field()
Validate multiselect based settings.
public
validate_setting_multiselect_field(array $values, array $setting) : array|WP_Error
Parameters
- $values : array
-
Values.
- $setting : array
-
Setting.
Tags
Return values
array|WP_Errorvalidate_setting_radio_field()
Validate radio based settings.
public
validate_setting_radio_field(string $value, array $setting) : string|WP_Error
Parameters
- $value : string
-
Value.
- $setting : array
-
Setting.
Tags
Return values
string|WP_Errorvalidate_setting_select_field()
Validate select based settings.
public
validate_setting_select_field(string $value, array $setting) : string|WP_Error
Parameters
- $value : string
-
Value.
- $setting : array
-
Setting.
Tags
Return values
string|WP_Errorvalidate_setting_text_field()
Validate a text value for a text based setting.
public
validate_setting_text_field(string $value, array $setting) : string
Parameters
- $value : string
-
Value.
- $setting : array
-
Setting.
Tags
Return values
stringvalidate_setting_textarea_field()
Validate textarea based settings.
public
validate_setting_textarea_field(string $value, array $setting) : string
Parameters
- $value : string
-
Value.
- $setting : array
-
Setting.
Tags
Return values
stringadd_additional_fields_schema()
Add the schema from additional fields to an schema array.
protected
add_additional_fields_schema(array $schema) : array
The type of object is inferred from the passed schema.
Parameters
- $schema : array
-
Schema array.
Return values
arrayadd_db_table_prefix()
Add prefix to table.
protected
add_db_table_prefix(string $table) : stromg
Parameters
- $table : string
-
Table name.
Return values
stromgadd_meta_query()
Add meta query.
protected
add_meta_query(array $args, array $meta_query) : array
Parameters
- $args : array
-
Query args.
- $meta_query : array
-
Meta query.
Tags
Return values
arrayadjust_wp_5_5_datatype_compatibility()
Change datatypes `date-time` to string, and `mixed` to composite of all built in types. This is required for maintaining forward compatibility with WP 5.5 since custom post types are not supported anymore.
protected
adjust_wp_5_5_datatype_compatibility(array $endpoint_args) : mixed
See @link https://core.trac.wordpress.org/changeset/48306
We still use the 'mixed' type, since if we convert to composite type everywhere, it won't work in 5.4 anymore because they require to define the full schema.
Parameters
- $endpoint_args : array
-
Schema with datatypes to convert.
Return values
mixed — Schema with converted datatype.check_batch_limit()
Check batch limit.
protected
check_batch_limit(array $items) : bool|WP_Error
Parameters
- $items : array
-
Request items.
Return values
bool|WP_Errorformat_plugin_data()
Format plugin data, including data on updates, into a standard format.
protected
format_plugin_data(string $plugin, array $data) : array
Parameters
- $plugin : string
-
Plugin directory/file.
- $data : array
-
Plugin data from WP.
Tags
Return values
array — Formatted data.get_normalized_rest_base()
Get normalized rest base.
protected
get_normalized_rest_base() : string
Return values
stringcheck_if_field_item_exists()
Check if field item exists.
private
check_if_field_item_exists(string $section, array $items, array $fields) : bool
Parameters
- $section : string
-
Fields section.
- $items : array
-
List of items to check for.
- $fields : array
-
List of fields to be included on the response.