From cab16aa7c0a09519003372d838df7165223a5926 Mon Sep 17 00:00:00 2001 From: Derrick Koo Date: Mon, 19 Jul 2021 09:43:34 -0600 Subject: [PATCH] fix: avoid meta sync update error (#95) * fix: avoid meta sync update error when syncing unknown properties * fix: do not show synced meta values in REST, to avoid schema errors --- includes/class-newspack-listings-core.php | 116 ++-------------------- 1 file changed, 7 insertions(+), 109 deletions(-) diff --git a/includes/class-newspack-listings-core.php b/includes/class-newspack-listings-core.php index ad9fab90..61613fb4 100644 --- a/includes/class-newspack-listings-core.php +++ b/includes/class-newspack-listings-core.php @@ -307,14 +307,7 @@ public static function get_meta_fields( $post_type = null, $field_names_only = f 'type' => 'array', 'sanitize_callback' => 'Utils\sanitize_array', 'single' => false, - 'show_in_rest' => [ - 'schema' => [ - 'type' => 'array', - 'items' => [ - 'type' => 'string', - ], - ], - ], + 'show_in_rest' => false, 'auth_callback' => function() { return current_user_can( 'edit_posts' ); }, @@ -368,37 +361,7 @@ public static function get_meta_fields( $post_type = null, $field_names_only = f 'type' => 'array', 'sanitize_callback' => 'Utils\sanitize_array', 'single' => false, - 'show_in_rest' => [ - 'schema' => [ - 'type' => 'array', - 'items' => [ - 'type' => 'object', - 'properties' => [ - 'address' => [ - 'type' => 'string', - ], - 'addressLine2' => [ - 'type' => 'string', - ], - 'addressLine3' => [ - 'type' => 'string', - ], - 'city' => [ - 'type' => 'string', - ], - 'region' => [ - 'type' => 'string', - ], - 'postal' => [ - 'type' => 'string', - ], - 'country' => [ - 'type' => 'string', - ], - ], - ], - ], - ], + 'show_in_rest' => false, ], ], 'newspack_listings_business_hours' => [ @@ -419,33 +382,7 @@ public static function get_meta_fields( $post_type = null, $field_names_only = f 'type' => 'array', 'sanitize_callback' => 'Utils\sanitize_array', 'single' => false, - 'show_in_rest' => [ - 'schema' => [ - 'type' => 'array', - 'items' => [ - 'type' => 'object', - 'properties' => [ - 'name' => [ - 'type' => 'string', - ], - 'hours' => [ - 'type' => 'array', - 'items' => [ - 'type' => 'object', - 'properties' => [ - 'opening' => [ - 'type' => 'string', - ], - 'closing' => [ - 'type' => 'string', - ], - ], - ], - ], - ], - ], - ], - ], + 'show_in_rest' => false, ], ], 'newspack_listings_locations' => [ @@ -467,39 +404,7 @@ public static function get_meta_fields( $post_type = null, $field_names_only = f 'type' => 'array', 'sanitize_callback' => 'Utils\sanitize_array', 'single' => false, - 'show_in_rest' => [ - 'schema' => [ - 'type' => 'array', - 'items' => [ - 'type' => 'object', - 'properties' => [ - 'placeTitle' => [ - 'type' => 'string', - ], - 'title' => [ - 'type' => 'string', - ], - 'caption' => [ - 'type' => 'string', - ], - 'id' => [ - 'type' => 'string', - ], - 'coordinates' => [ - 'type' => 'object', - 'properties' => [ - 'latitude' => [ - 'type' => 'number', - ], - 'longitude' => [ - 'type' => 'number', - ], - ], - ], - ], - ], - ], - ], + 'show_in_rest' => false, 'auth_callback' => function() { return current_user_can( 'edit_posts' ); }, @@ -522,7 +427,7 @@ public static function get_meta_fields( $post_type = null, $field_names_only = f 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'single' => true, - 'show_in_rest' => true, + 'show_in_rest' => false, 'auth_callback' => function() { return current_user_can( 'edit_posts' ); }, @@ -545,7 +450,7 @@ public static function get_meta_fields( $post_type = null, $field_names_only = f 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'single' => true, - 'show_in_rest' => true, + 'show_in_rest' => false, 'auth_callback' => function() { return current_user_can( 'edit_posts' ); }, @@ -587,14 +492,7 @@ public static function get_meta_fields( $post_type = null, $field_names_only = f 'type' => 'array', 'sanitize_callback' => 'Utils\sanitize_array', 'single' => false, - 'show_in_rest' => [ - 'schema' => [ - 'type' => 'array', - 'items' => [ - 'type' => 'integer', - ], - ], - ], + 'show_in_rest' => false, 'auth_callback' => function() { return current_user_can( 'edit_posts' ); },