Remove array control on metrics data and add an autoconversion of PHP Object in PHP array.

For json request, i use the variable instead of label in metrics.

The variable names are lower case, without accent, without space (more stable than a label in a site).
This commit is contained in:
Kef
2019-04-22 10:41:20 +02:00
parent 81b4f0143b
commit e2aeaf4fc9
2 changed files with 6 additions and 2 deletions

View File

@@ -430,7 +430,6 @@ class SP_REST_API {
'update_callback' => 'SP_REST_API::update_post_meta_array',
'schema' => array(
'description' => __( 'Metrics', 'sportspress' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => 'rest_sanitize_request_arg',
@@ -564,6 +563,11 @@ class SP_REST_API {
* @return bool|int
*/
public static function update_post_meta_array( $value, $object, $field_name ) {
// Convert PHP object to array
if ( is_object( $value ) ) {
$value = (array) $value;
}
if ( ! is_array( $value ) ) return false;
$type = $object->post_type;