register_meta( string $object_type, string $meta_key, array $args, string|array $deprecated = null ): bool
- Since
- 3.3.0, 4.6.0, 4.9.8, 5.3.0, 5.5.0, 6.4.0, 6.7.0
- Source
wp-includes/meta.php:1435
Description
It is recommended to register meta keys for a specific combination of object type and object subtype. If passing an object subtype is omitted, the meta key will be registered for the entire object type, however it can be partly overridden in case a more specific meta key of the same name exists for the same object type and a subtype.
If an object type does not support any subtypes, such as blogs, users, or comments, you should commonly call this function without passing a subtype.
Compatibility
- WordPress
- since 6.7.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$object_typestring- Type of object metadata is for. Accepts 'blog', 'post', 'comment', 'term', 'user', or any other object type with an associated meta table.
$meta_keystring- Meta key to register.
$argsarray- Data used to describe the meta key when registered.
$object_subtypestringdefault: emptyA subtype; e.g. if the object type is "post", the post type. If left empty, the meta key will be registered on the entire object type.$typestringThe type of data associated with this meta key. Valid values are 'string', 'boolean', 'integer', 'number', 'array', and 'object'.$labelstringA human-readable label of the data attached to this meta key.$descriptionstringA description of the data attached to this meta key.$singleboolWhether the meta key has one value per object, or an array of values per object.$defaultmixedThe default value returned from get_metadata() if no value has been set yet. When using a non-single meta key, the default value is for the first entry. In other words, when calling get_metadata() with$singleset tofalse, the default value given here will be wrapped in an array.$sanitize_callbackcallableA function or method to call when sanitizing$meta_keydata.$auth_callbackcallableOptional. A function or method to call when performing edit_post_meta, add_post_meta, and delete_post_meta capability checks.$show_in_restbool|arrayWhether data associated with this meta key can be considered public and should be accessible via the REST API. A custom post type must also declare support for custom fields for registered meta to be accessible via REST. When registering complex meta values this argument may optionally be an array with 'schema' or 'prepare_callback' keys instead of a boolean.$revisions_enabledboolWhether to enable revisions support for this meta_key. Can only be used when the object type is 'post'.
$deprecatedstring|arrayoptional- Deprecated. Use
$argsinstead.Default:null
Return value
bool- True if the meta key was successfully registered in the global array, false if not.
Registering a meta key with distinct sanitize and auth callbacks will fire those callbacks, but will not add to the global registry.
Performance profile
How much work a call to register_meta() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 54–159
- Plugin surface
- 1 hook
- Called by
- 4
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 241.
Third-party callbacks on 'register_meta_args' run inside this call, and their cost is not bounded by anything here.
4 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly
Further down the call graph this can also reach option, cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 114 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost register_meta() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
is_array($wp_meta_keys) && !is_callable() && $args && $object_type !== "post" | 54–55 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !is_callable() && !$args && !empty($args) | 59–70 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable() |
is_array($wp_meta_keys) && !is_callable() && $args && $object_type === "post" && !empty($object_subtype) && !post_type_supports() | 61–62 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && !$args | 66–78 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable() |
is_array($wp_meta_keys) && !is_callable() && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) | 68–75 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable() |
is_array($wp_meta_keys) && !$args && !empty($args) | 73–87 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), add_filter() |
is_array($wp_meta_keys) && !$args && !empty($args) | 73–87 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $object_type === "post" && !empty($object_subtype) && post_type_supports() | 75–83 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable() |
is_array($wp_meta_keys) && empty($args) && !$args | 80–95 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), add_filter() |
is_array($wp_meta_keys) && empty($args) && !$args | 80–95 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable() |
is_array($wp_meta_keys) && !is_callable() && !empty($args) && $args && is_wp_error() | 81–89 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) | 82–92 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), add_filter() |
102 further outcomes, up to 159 instructions
is_array($wp_meta_keys) && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) | 82–92 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable() |
is_array($wp_meta_keys) && !is_callable() && !empty($args) && $args && !is_wp_error() && has_filter() | 82–96 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !$args && !empty($args) | 87–104 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), add_filter() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $args && is_wp_error() | 88–97 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $object_type === "post" && !empty($object_subtype) && post_type_supports() | 89–100 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $object_type === "post" && !empty($object_subtype) && post_type_supports() | 89–100 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $args && !is_wp_error() && has_filter() | 89–104 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !is_callable() && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && is_wp_error() | 90–94 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !is_callable() && !empty($args) && $args && !is_wp_error() && !has_filter() | 91–105 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && !is_callable() && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && !is_wp_error() && has_filter() | 91–101 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !is_callable() && !empty($args) && $args && isset($value) && is_wp_error() | 91–96 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !is_callable() && !empty($args) && $args && isset($value) && !is_wp_error() && has_filter() | 92–103 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && empty($args) && !$args | 94–112 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter() |
is_array($wp_meta_keys) && !empty($args) && $args && is_wp_error() | 95–106 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !empty($args) && $args && is_wp_error() | 95–106 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) | 96–109 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), add_filter() |
is_array($wp_meta_keys) && !empty($args) && $args && !is_wp_error() && has_filter() | 96–113 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !empty($args) && $args && !is_wp_error() && has_filter() | 96–113 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && is_wp_error() | 97–102 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $args && !is_wp_error() && !has_filter() | 98–113 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !is_wp_error() && has_filter() | 98–109 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $args && isset($value) && is_wp_error() | 98–104 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $args && isset($value) && !is_wp_error() && has_filter() | 99–111 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !is_callable() && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && !is_wp_error() && !has_filter() | 100–110 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && !is_callable() && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && isset($value) && is_wp_error() | 100–101 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !is_callable() && !empty($args) && $args && isset($value) && !is_wp_error() && !has_filter() | 101–112 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && !is_callable() && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && isset($value) && !is_wp_error() && has_filter() | 101–108 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && empty($args) && $args && is_wp_error() | 102–114 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $args && is_wp_error() | 102–114 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $object_type === "post" && !empty($object_subtype) && post_type_supports() | 103–117 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && !is_wp_error() && has_filter() | 103–121 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && empty($args) && $args && !is_wp_error() && has_filter() | 103–121 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && is_wp_error() | 104–111 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && is_wp_error() | 104–111 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !empty($args) && $args && !is_wp_error() && !has_filter() | 105–122 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && !empty($args) && $args && !is_wp_error() && !has_filter() | 105–122 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && !is_wp_error() && has_filter() | 105–118 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && !is_wp_error() && has_filter() | 105–118 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !empty($args) && $args && isset($value) && is_wp_error() | 105–113 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !empty($args) && $args && isset($value) && is_wp_error() | 105–113 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !empty($args) && $args && isset($value) && !is_wp_error() && has_filter() | 106–120 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !empty($args) && $args && isset($value) && !is_wp_error() && has_filter() | 106–120 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !is_wp_error() && !has_filter() | 107–118 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && isset($value) && is_wp_error() | 107–109 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $args && isset($value) && !is_wp_error() && !has_filter() | 108–120 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && isset($value) && !is_wp_error() && has_filter() | 108–116 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !empty($args) && $args && is_wp_error() | 109–123 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !empty($args) && $args && !is_wp_error() && has_filter() | 110–130 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !is_callable() && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && isset($value) && !is_wp_error() && !has_filter() | 110–117 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && is_wp_error() | 111–119 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && is_wp_error() | 111–119 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $args && !is_wp_error() && !has_filter() | 112–130 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && !is_wp_error() && !has_filter() | 112–130 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !is_wp_error() && has_filter() | 112–126 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !is_wp_error() && has_filter() | 112–126 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && empty($args) && $args && isset($value) && is_wp_error() | 112–121 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $args && isset($value) && is_wp_error() | 112–121 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $args && isset($value) && !is_wp_error() && has_filter() | 113–128 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && empty($args) && $args && isset($value) && !is_wp_error() && has_filter() | 113–128 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && !is_wp_error() && !has_filter() | 114–127 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && !is_wp_error() && !has_filter() | 114–127 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && isset($value) && is_wp_error() | 114–118 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && isset($value) && is_wp_error() | 114–118 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !empty($args) && $args && isset($value) && !is_wp_error() && !has_filter() | 115–129 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && !empty($args) && $args && isset($value) && !is_wp_error() && !has_filter() | 115–129 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && isset($value) && !is_wp_error() && has_filter() | 115–125 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && isset($value) && !is_wp_error() && has_filter() | 115–125 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && empty($args) && $args && is_wp_error() | 116–131 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $args && !is_wp_error() && has_filter() | 117–138 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !is_callable() && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && isset($value) && !is_wp_error() && !has_filter() | 117–125 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && is_wp_error() | 118–128 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !empty($args) && $args && !is_wp_error() && !has_filter() | 119–139 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && !is_wp_error() && has_filter() | 119–135 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && !empty($args) && $args && isset($value) && is_wp_error() | 119–130 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !empty($args) && $args && isset($value) && !is_wp_error() && has_filter() | 120–137 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !is_wp_error() && !has_filter() | 121–135 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !is_wp_error() && !has_filter() | 121–135 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && isset($value) && is_wp_error() | 121–126 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && isset($value) && is_wp_error() | 121–126 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $args && isset($value) && !is_wp_error() && !has_filter() | 122–137 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && isset($value) && !is_wp_error() && !has_filter() | 122–137 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && isset($value) && !is_wp_error() && has_filter() | 122–133 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && isset($value) && !is_wp_error() && has_filter() | 122–133 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && isset($value) && !is_wp_error() && !has_filter() | 124–134 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && isset($value) && !is_wp_error() && !has_filter() | 124–134 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && is_wp_error() | 125–136 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $args && !is_wp_error() && !has_filter() | 126–147 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !is_wp_error() && has_filter() | 126–143 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && empty($args) && $args && isset($value) && is_wp_error() | 126–138 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $args && isset($value) && !is_wp_error() && has_filter() | 127–145 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && !is_wp_error() && !has_filter() | 128–144 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && isset($value) && is_wp_error() | 128–135 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && !empty($args) && $args && isset($value) && !is_wp_error() && !has_filter() | 129–146 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), add_filter(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && isset($value) && !is_wp_error() && has_filter() | 129–142 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && isset($value) && !is_wp_error() && !has_filter() | 131–142 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && isset($value) && !is_wp_error() && !has_filter() | 131–142 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !is_wp_error() && !has_filter() | 135–152 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && isset($value) && is_wp_error() | 135–143 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), __(), _doing_it_wrong() |
is_array($wp_meta_keys) && empty($args) && $args && isset($value) && !is_wp_error() && !has_filter() | 136–154 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && isset($value) && !is_wp_error() && has_filter() | 136–150 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter() |
is_array($wp_meta_keys) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && !empty($args) && isset($value) && !is_wp_error() && !has_filter() | 138–151 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), add_filter(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
is_array($wp_meta_keys) && empty($args) && $args && $object_type === "post" && !empty($object_subtype) && post_type_supports() && isset($value) && !is_wp_error() && !has_filter() | 145–159 | is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_protected_meta(), is_callable(), add_filter(), is_callable(), add_filter(), array_merge(), rest_validate_value_from_schema(), is_wp_error(), has_filter(), add_filter() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 241 | 54–159 | 25 | |
| 8.5 | 241 | 54–159 | 25 | |
| 8.4 | 241 | 54–159 | 25 | |
| 8.3 | 241 | 54–159 | 25 | |
| 8.2 | 241 | 54–159 | 25 | |
| 8.1 | 241 | 54–159 | 25 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 242 | 54–160 | 25 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 1
One hook fires while register_meta() runs, in this order:
- apply_filters( register_meta_args )filterline 1485 (+50 into the body)
Filters the registration arguments when registering meta.
Uses · 10
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_parse_args()Merges user defined arguments into defaults array.
- _doing_it_wrong()Marks something as being incorrectly called.
- __()Retrieves the translation of $text.
- post_type_supports()Checks a post type's support for a given feature.
- is_protected_meta()Determines whether a meta key is considered protected.
- add_filter()Adds a callback function to a filter hook.
- rest_validate_value_from_schema()Validate a value based on a schema.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- has_filter()Checks if any filter has been registered for a hook.
Used by · 4
- register_post_meta()Registers a meta key for posts.
- register_term_meta()Registers a meta key for terms.
- wp_create_initial_comment_meta()Register initial note status meta.
- wp_register_persisted_preferences_meta()Registers the user meta property for persisted preferences.
Source code
function register_meta( $object_type, $meta_key, $args, $deprecated = null ) { global $wp_meta_keys; if ( ! is_array( $wp_meta_keys ) ) { $wp_meta_keys = array(); } $defaults = array( 'object_subtype' => '', 'type' => 'string', 'label' => '', 'description' => '', 'default' => '', 'single' => false, 'sanitize_callback' => null, 'auth_callback' => null, 'show_in_rest' => false, 'revisions_enabled' => false, ); // There used to be individual args for sanitize and auth callbacks. $has_old_sanitize_cb = false; $has_old_auth_cb = false; if ( is_callable( $args ) ) { $args = array( 'sanitize_callback' => $args, ); $has_old_sanitize_cb = true; } else { $args = (array) $args; } if ( is_callable( $deprecated ) ) { $args['auth_callback'] = $deprecated; $has_old_auth_cb = true; } /** * Filters the registration arguments when registering meta. * * @since 4.6.0 * * @param array $args Array of meta registration arguments. * @param array $defaults Array of default arguments. * @param string $object_type Type of object metadata is for. Accepts 'blog', 'post', 'comment', 'term', * 'user', or any other object type with an associated meta table. * @param string $meta_key Meta key. */ $args = apply_filters( 'register_meta_args', $args, $defaults, $object_type, $meta_key ); unset( $defaults['default'] ); $args = wp_parse_args( $args, $defaults ); // Require an item schema when registering array meta. if ( false !== $args['show_in_rest'] && 'array' === $args['type'] ) { if ( ! is_array( $args['show_in_rest'] ) || ! isset( $args['show_in_rest']['schema']['items'] ) ) { _doing_it_wrong( __FUNCTION__, __( 'When registering an "array" meta type to show in the REST API, you must specify the schema for each array item in "show_in_rest.schema.items".' ), '5.3.0' ); return false; } } $object_subtype = ! empty( $args['object_subtype'] ) ? $args['object_subtype'] : ''; if ( $args['revisions_enabled'] ) { if ( 'post' !== $object_type ) { _doing_it_wrong( __FUNCTION__, __( 'Meta keys cannot enable revisions support unless the object type supports revisions.' ), '6.4.0' ); return false; } elseif ( ! empty( $object_subtype ) && ! post_type_supports( $object_subtype, 'revisions' ) ) { _doing_it_wrong( __FUNCTION__, __( 'Meta keys cannot enable revisions support unless the object subtype supports revisions.' ), '6.4.0' ); return false; } } // If `auth_callback` is not provided, fall back to `is_protected_meta()`. if ( empty( $args['auth_callback'] ) ) { if ( is_protected_meta( $meta_key, $object_type ) ) { $args['auth_callback'] = '__return_false';Changelog
Introduced in 3.3.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
label argument was added to the arguments array.from the docblock$revisions_enabled argument was added to the arguments array.from the docblock$default argument was added to the arguments array.from the docblock$object_subtype argument was added to the arguments array.from the docblock$sanitize_callback and $auth_callback have been folded into this array.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/meta.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.