Skip to content

Commit 954cf1d

Browse files
committed
Add guard to model args for meta
1 parent ad6c87f commit 954cf1d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/Features/Meta/MetaFieldProvider.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ public function all_post_type_meta( Modeler $modeler, ?ModelRestPolicy $policy,
3232
}
3333

3434
$args = $this->get_model_args( $model, $policy );
35+
$meta = isset( $args['meta'] ) && \is_array( $args['meta'] ) ? $args['meta'] : [];
3536

3637
$post_types[] = [
3738
'post_type' => (string) $post_type,
3839
'label_singular' => $args['label_singular'] ?? '',
3940
'label_plural' => $args['label_plural'] ?? '',
40-
'meta' => $args['meta'] ?? [],
41-
'normalized' => $this->normalize_meta_fields( $args['meta'] ?? [] ),
41+
'meta' => $meta,
42+
'normalized' => $this->normalize_meta_fields( $meta ),
4243
];
4344
}
4445

@@ -62,7 +63,7 @@ public function post_type_meta( Modeler $modeler, ?ModelRestPolicy $policy, stri
6263
__( 'Model not found.', 'saltus-framework' ),
6364
[
6465
'status' => 404,
65-
'hint' => sprintf(
66+
'hint' => \sprintf(
6667
/* translators: %s: post type slug */
6768
__( "Model '%s' is not registered or the post type is not enabled. Check the model slug and ensure it has 'saltus_rest' => [ 'capabilities' => [ 'meta' => true ] ] in src/models/.", 'saltus-framework' ),
6869
$post_type

0 commit comments

Comments
 (0)