Opened 6 years ago
Last modified 6 years ago
#44238 new enhancement
Add protected param to register meta
Reported by: | spacedmonkey | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 3.1.3 |
Component: | Options, Meta APIs | Keywords: | has-patch |
Focuses: | Cc: |
Description
It has been possible for developers to make meta keys protected / not protected since 3.2.0,
when the is_protected_meta filter was added. By default all meta keys that start with an underscore as seen as protected,
all those this overriden by the filter. There should be a way to a meta key as protected while using register_meta function.
This would make the register meta function, a point of truth for all meta keys / meta type, where a state, type and access
are defined in one place.
Attachments (5)
Change History (16)
This ticket was mentioned in Slack in #core-multisite by spacedmonkey. View the logs.
6 years ago
This ticket was mentioned in Slack in #core-restapi by spacedmonkey. View the logs.
6 years ago
This ticket was mentioned in Slack in #core-restapi by spacedmonkey. View the logs.
6 years ago
This ticket was mentioned in Slack in #core-restapi by kadamwhite. View the logs.
6 years ago
This ticket was mentioned in Slack in #core-restapi by spacedmonkey. View the logs.
6 years ago
This ticket was mentioned in Slack in #core-restapi by desrosj. View the logs.
6 years ago
#10
@
6 years ago
Could the two approaches be combined? If a boolean value is passed for protected
changes it to the __return_true
or __return_false
callbacks, otherwise add it as a callback. That'd make the usage easy for most cases, but still simplify the API for users that need the advanced control of a custom callback.
@spacedmonkey What is the reason for the second (.2) patch? Should that be a separate ticket? Or resolved first?
#11
@
6 years ago
@TimothyBlynJacobs Thanks for the feedback.
In 44238.4.diff allows for boolean and callback to be passed.
This patch now applies against current trunk.
I have written two ways of the doing this.
The first patch, 44238.diff added a param of
protected_callback
which, if set is passed onto the new protected_{$meta_type}_meta_{$meta_key} filter.This is inline with other params on the register meta api, that allow developers to write there own logic. If they don't want to write there own logic there they can always use the helper functions
__return_true
and__return_false
.The second patch, 44238.1.diff is much more simple implementation, that added a boolean
protected
. This is much more defined if something is or is not conditional, but it much more restrictive. However, it makes the definition of a meta_key much cleaner if you look it up.Not sure which is better, please comment below with feedback.