Use objects, rather than arrays in schema when properties are defined

This commit is contained in:
Mike Jolley 2016-12-07 11:36:46 +00:00
parent 7583965af2
commit ba62599da0
9 changed files with 166 additions and 166 deletions

View File

@ -502,7 +502,7 @@ class WC_REST_Coupons_Controller extends WC_REST_Posts_Controller {
),
'meta_data' => array(
'description' => __( 'Order meta data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(

View File

@ -206,7 +206,7 @@ class WC_REST_Customer_Downloads_Controller extends WC_REST_Controller {
),
'file' => array(
'description' => __( 'File details.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view' ),
'readonly' => true,
'properties' => array(

View File

@ -676,7 +676,7 @@ class WC_REST_Customers_Controller extends WC_REST_Controller {
),
'billing' => array(
'description' => __( 'List of billing address data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'first_name' => array(
@ -739,7 +739,7 @@ class WC_REST_Customers_Controller extends WC_REST_Controller {
),
'shipping' => array(
'description' => __( 'List of shipping address data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'first_name' => array(
@ -797,7 +797,7 @@ class WC_REST_Customers_Controller extends WC_REST_Controller {
),
'meta_data' => array(
'description' => __( 'Order meta data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(

View File

@ -334,7 +334,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Orders_Controller {
),
'meta_data' => array(
'description' => __( 'Order meta data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -357,7 +357,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Orders_Controller {
),
'line_items' => array(
'description' => __( 'Line items data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -415,7 +415,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Orders_Controller {
),
'taxes' => array(
'description' => __( 'Line taxes.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'readonly' => true,
'properties' => array(
@ -438,7 +438,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Orders_Controller {
),
'meta_data' => array(
'description' => __( 'Order item meta data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -473,7 +473,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Orders_Controller {
),
'meta' => array(
'description' => __( 'Order item meta data (formatted).', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'readonly' => true,
'properties' => array(

View File

@ -885,7 +885,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'billing' => array(
'description' => __( 'Billing address.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'first_name' => array(
@ -948,7 +948,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'shipping' => array(
'description' => __( 'Shipping address.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'first_name' => array(
@ -1060,7 +1060,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'meta_data' => array(
'description' => __( 'Order meta data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -1083,7 +1083,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'line_items' => array(
'description' => __( 'Line items data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -1141,7 +1141,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'taxes' => array(
'description' => __( 'Line taxes.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'readonly' => true,
'properties' => array(
@ -1164,7 +1164,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'meta_data' => array(
'description' => __( 'Order item meta data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -1199,7 +1199,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'meta' => array(
'description' => __( 'Order item meta data (formatted).', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'readonly' => true,
'properties' => array(
@ -1227,7 +1227,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'tax_lines' => array(
'description' => __( 'Tax lines data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'readonly' => true,
'properties' => array(
@ -1275,7 +1275,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'meta_data' => array(
'description' => __( 'Order item meta data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -1300,7 +1300,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'shipping_lines' => array(
'description' => __( 'Shipping lines data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -1332,7 +1332,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'taxes' => array(
'description' => __( 'Line taxes.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'readonly' => true,
'properties' => array(
@ -1352,7 +1352,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'meta_data' => array(
'description' => __( 'Order item meta data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -1377,7 +1377,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'fee_lines' => array(
'description' => __( 'Fee lines data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -1415,7 +1415,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'taxes' => array(
'description' => __( 'Line taxes.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'readonly' => true,
'properties' => array(
@ -1441,7 +1441,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'meta_data' => array(
'description' => __( 'Order item meta data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -1466,7 +1466,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'coupon_lines' => array(
'description' => __( 'Coupons line data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -1493,7 +1493,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'meta_data' => array(
'description' => __( 'Order item meta data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -1518,7 +1518,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'refunds' => array(
'description' => __( 'List of refunds.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'readonly' => true,
'properties' => array(

View File

@ -210,7 +210,7 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Terms_Controller {
),
'image' => array(
'description' => __( 'Image data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(

View File

@ -403,7 +403,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
),
'downloads' => array(
'description' => __( 'List of downloadable files.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -492,7 +492,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
),
'dimensions' => array(
'description' => __( 'Variation dimensions.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'length' => array(
@ -528,7 +528,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
),
'image' => array(
'description' => __( 'Variation image data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -573,7 +573,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
),
'attributes' => array(
'description' => __( 'List of attributes.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(

View File

@ -1860,7 +1860,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
),
'downloads' => array(
'description' => __( 'List of downloadable files.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -1973,7 +1973,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
),
'dimensions' => array(
'description' => __( 'Product dimensions.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'length' => array(
@ -2065,7 +2065,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
),
'categories' => array(
'description' => __( 'List of categories.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -2089,7 +2089,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
),
'tags' => array(
'description' => __( 'List of tags.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -2113,7 +2113,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
),
'images' => array(
'description' => __( 'List of images.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -2158,7 +2158,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
),
'attributes' => array(
'description' => __( 'List of attributes.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -2197,7 +2197,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
),
'default_attributes' => array(
'description' => __( 'Defaults variation attributes.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -2219,7 +2219,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
),
'variations' => array(
'description' => __( 'List of variations.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -2314,7 +2314,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
),
'downloads' => array(
'description' => __( 'List of downloadable files.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -2403,7 +2403,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
),
'dimensions' => array(
'description' => __( 'Variation dimensions.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'length' => array(
@ -2439,7 +2439,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
),
'image' => array(
'description' => __( 'Variation image data.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(
@ -2484,7 +2484,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
),
'attributes' => array(
'description' => __( 'List of attributes.', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'id' => array(

View File

@ -38,31 +38,31 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
* Register the route for /system_status
*/
public function register_routes() {
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_items' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
'args' => $this->get_collection_params(),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
}
/**
/**
* Check whether a given request has permission to view system status.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function get_items_permissions_check( $request ) {
if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
/**
* Get a system status info, by section.
*
* @param WP_REST_Request $request Full details about the request.
@ -74,19 +74,19 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
$response = array();
foreach ( $mappings as $section => $values ) {
settype( $values, $schema['properties'][ $section ]['type'] );
foreach ( $values as $key => $value ) {
if ( isset( $schema['properties'][ $section ]['properties'][ $key ]['type'] ) ) {
settype( $values[ $key ], $schema['properties'][ $section ]['properties'][ $key ]['type'] );
}
}
settype( $values, $schema['properties'][ $section ]['type'] );
$response[ $section ] = $values;
}
return rest_ensure_response( $response );
}
/**
/**
* Get the system status schema, conforming to JSON Schema.
*
* @return array
@ -99,96 +99,96 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'properties' => array(
'environment' => array(
'description' => __( 'Environment', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'home_url' => array(
'description' => __( 'Home URL', 'woocommerce' ),
'type' => 'string',
'format' => 'uri',
'format' => 'uri',
'context' => array( 'view', 'edit' ),
),
'site_url' => array(
'description' => __( 'Site URL', 'woocommerce' ),
'type' => 'string',
'format' => 'uri',
'context' => array( 'view', 'edit' ),
),
'wc_version' => array(
'description' => __( 'WooCommerce version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'log_directory' => array(
'description' => __( 'Log directory', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'log_directory_writable' => array(
'description' => __( 'Is log directory writable?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'wp_version' => array(
'description' => __( 'WordPress version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'wp_multisite' => array(
'description' => __( 'Is WordPress multisite?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'wp_memory_limit' => array(
'description' => __( 'WordPress memory limit', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'wp_debug_mode' => array(
'description' => __( 'Is WordPress debug mode active?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'wp_cron' => array(
'description' => __( 'Are WordPress cron jobs enabled?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'language' => array(
'description' => __( 'WordPress language', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'server_info' => array(
'description' => __( 'Server info', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'php_version' => array(
'description' => __( 'PHP version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'php_post_max_size' => array(
'description' => __( 'PHP post max size', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'php_max_execution_time' => array(
'description' => __( 'PHP max execution time', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'php_max_input_vars' => array(
'description' => __( 'PHP max input vars', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'curl_version' => array(
'description' => __( 'cURL version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'site_url' => array(
'description' => __( 'Site URL', 'woocommerce' ),
'type' => 'string',
'format' => 'uri',
'context' => array( 'view', 'edit' ),
),
'wc_version' => array(
'description' => __( 'WooCommerce version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'log_directory' => array(
'description' => __( 'Log directory', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'log_directory_writable' => array(
'description' => __( 'Is log directory writable?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'wp_version' => array(
'description' => __( 'WordPress version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'wp_multisite' => array(
'description' => __( 'Is WordPress multisite?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'wp_memory_limit' => array(
'description' => __( 'WordPress memory limit', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'wp_debug_mode' => array(
'description' => __( 'Is WordPress debug mode active?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'wp_cron' => array(
'description' => __( 'Are WordPress cron jobs enabled?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'language' => array(
'description' => __( 'WordPress language', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'server_info' => array(
'description' => __( 'Server info', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'php_version' => array(
'description' => __( 'PHP version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'php_post_max_size' => array(
'description' => __( 'PHP post max size', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'php_max_execution_time' => array(
'description' => __( 'PHP max execution time', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'php_max_input_vars' => array(
'description' => __( 'PHP max input vars', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'curl_version' => array(
'description' => __( 'cURL version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'suhosin_installed' => array(
'description' => __( 'Is SUHOSIN installed?', 'woocommerce' ),
'type' => 'boolean',
@ -258,7 +258,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
),
'database' => array(
'description' => __( 'Database', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'wc_database_version' => array(
@ -290,7 +290,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
),
'theme' => array(
'description' => __( 'Theme', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'name' => array(
@ -359,7 +359,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
),
'settings' => array(
'description' => __( 'Settings', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'api_enabled' => array(
@ -416,7 +416,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
),
'security' => array(
'description' => __( 'Security', 'woocommerce' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'secure_connection' => array(
@ -442,7 +442,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
return $this->add_additional_fields_schema( $schema );
}
/**
/**
* Return an array of sections and the data associated with each.
*
* @return array
@ -471,15 +471,15 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
// Figure out cURL version, if installed.
$curl_version = '';
if ( function_exists( 'curl_version' ) ) {
$curl_version = curl_version();
$curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version'];
}
$curl_version = curl_version();
$curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version'];
}
// WP memory limit
$wp_memory_limit = wc_let_to_num( WP_MEMORY_LIMIT );
if ( function_exists( 'memory_get_usage' ) ) {
$wp_memory_limit = max( $wp_memory_limit, wc_let_to_num( @ini_get( 'memory_limit' ) ) );
}
$wp_memory_limit = wc_let_to_num( WP_MEMORY_LIMIT );
if ( function_exists( 'memory_get_usage' ) ) {
$wp_memory_limit = max( $wp_memory_limit, wc_let_to_num( @ini_get( 'memory_limit' ) ) );
}
// Test POST requests
$post_response = wp_safe_remote_post( 'https://www.paypal.com/cgi-bin/webscr', array(
@ -504,23 +504,23 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
// Return all environment info. Described by JSON Schema.
return array(
'home_url' => get_option( 'home' ),
'site_url' => get_option( 'siteurl' ),
'version' => WC()->version,
'log_directory' => WC_LOG_DIR,
'log_directory_writable' => ( @fopen( WC_LOG_DIR . 'test-log.log', 'a' ) ? true : false ),
'wp_version' => get_bloginfo( 'version' ),
'wp_multisite' => is_multisite(),
'wp_memory_limit' => $wp_memory_limit,
'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ),
'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ),
'language' => get_locale(),
'server_info' => $_SERVER['SERVER_SOFTWARE'],
'php_version' => phpversion(),
'php_post_max_size' => wc_let_to_num( ini_get( 'post_max_size' ) ),
'php_max_execution_time' => ini_get( 'max_execution_time' ),
'php_max_input_vars' => ini_get( 'max_input_vars' ),
'curl_version' => $curl_version,
'home_url' => get_option( 'home' ),
'site_url' => get_option( 'siteurl' ),
'version' => WC()->version,
'log_directory' => WC_LOG_DIR,
'log_directory_writable' => ( @fopen( WC_LOG_DIR . 'test-log.log', 'a' ) ? true : false ),
'wp_version' => get_bloginfo( 'version' ),
'wp_multisite' => is_multisite(),
'wp_memory_limit' => $wp_memory_limit,
'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ),
'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ),
'language' => get_locale(),
'server_info' => $_SERVER['SERVER_SOFTWARE'],
'php_version' => phpversion(),
'php_post_max_size' => wc_let_to_num( ini_get( 'post_max_size' ) ),
'php_max_execution_time' => ini_get( 'max_execution_time' ),
'php_max_input_vars' => ini_get( 'max_input_vars' ),
'curl_version' => $curl_version,
'suhosin_installed' => extension_loaded( 'suhosin' ),
'max_upload_size' => wp_max_upload_size(),
'mysql_version' => ( ! empty( $wpdb->is_mysql ) ? $wpdb->db_version() : '' ),
@ -534,7 +534,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'remote_post_response' => ( is_wp_error( $post_response ) ? $post_response->get_error_message() : $post_response['response']['code'] ),
'remote_get_successful' => $get_response_successful,
'remote_get_response' => ( is_wp_error( $get_response ) ? $get_response->get_error_message() : $get_response['response']['code'] ),
);
);
}
/**