Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Only allow custom meta of types string, number and boolean #2850

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

joehoyle
Copy link
Member

Currently we handle registering meta even if your register the type as
anything other than boolean number and string, however we don't
currently have great ways to handle non-scaler meta. For now, let's
whitelist these types and throw a doing_it_wrong if meta is registered
with an invalid type.

Currently we handle registering meta even if your register the type as
anything other than `boolean` `number` and `string`, however we don't
currently have great ways to handle non-scaler meta. For now, let's
whitelist these types and throw a `doing_it_wrong` if meta is registered
with an invalid type.
@kadamwhite
Copy link
Contributor

How do we handle namespacing of objects in meta? e.g., if I'm an seo plugin and I have a "score" meta value, but there's also a keyword-bingo plugin that also has a "score," and I only have a numeric meta field to put them in -- not an object -- how do I ensure there won't be a conflict?

@@ -294,6 +300,10 @@ protected function get_registered_fields() {
'type' => $args['type'],
);
}
} else {
if ( ! in_array( $rest_args['schema']['type'], array( 'number', 'string', 'boolean' ), true ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elseif?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants