Skip to content

Commit

Permalink
fix: avoid meta sync update error (#95)
Browse files Browse the repository at this point in the history
* fix: avoid meta sync update error when syncing unknown properties

* fix: do not show synced meta values in REST, to avoid schema errors
  • Loading branch information
dkoo authored Jul 19, 2021
1 parent 7716775 commit cab16aa
Showing 1 changed file with 7 additions and 109 deletions.
116 changes: 7 additions & 109 deletions includes/class-newspack-listings-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
},
Expand Down Expand Up @@ -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' => [
Expand All @@ -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' => [
Expand All @@ -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' );
},
Expand All @@ -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' );
},
Expand All @@ -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' );
},
Expand Down Expand Up @@ -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' );
},
Expand Down

0 comments on commit cab16aa

Please sign in to comment.