wppaste
WordPress

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
Registers a meta key.

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: empty

    A 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.
  • $typestring

    The type of data associated with this meta key. Valid values are 'string', 'boolean', 'integer', 'number', 'array', and 'object'.
  • $labelstring

    A human-readable label of the data attached to this meta key.
  • $descriptionstring

    A description of the data attached to this meta key.
  • $singlebool

    Whether the meta key has one value per object, or an array of values per object.
  • $defaultmixed

    The 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 $single set to false, the default value given here will be wrapped in an array.
  • $sanitize_callbackcallable

    A function or method to call when sanitizing $meta_key data.
  • $auth_callbackcallable

    Optional. A function or method to call when performing edit_post_meta, add_post_meta, and delete_post_meta capability checks.
  • $show_in_restbool|array

    Whether 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_enabledbool

    Whether to enable revisions support for this meta_key. Can only be used when the object type is 'post'.
$deprecatedstring|arrayoptional
Deprecated. Use $args instead.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

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
54–159

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 241.

Plugin surface
1 hook

Third-party callbacks on 'register_meta_args' run inside this call, and their cost is not bounded by anything here.

Called by
4

4 places in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_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.

WhenInstructionsCalls it makes
is_array($wp_meta_keys) && !is_callable() && $args && $object_type !== "post"54–55is_callable(), is_callable(), apply_filters(), wp_parse_args(), __(), _doing_it_wrong()
is_array($wp_meta_keys) && !is_callable() && !$args && !empty($args)59–70is_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–62is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), __(), _doing_it_wrong()
is_array($wp_meta_keys) && !is_callable() && empty($args) && !$args66–78is_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–75is_callable(), is_callable(), apply_filters(), wp_parse_args(), post_type_supports(), is_callable(), is_callable()
is_array($wp_meta_keys) && !$args && !empty($args)73–87is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_callable(), is_callable(), add_filter()
is_array($wp_meta_keys) && !$args && !empty($args)73–87is_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–83is_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) && !$args80–95is_callable(), is_callable(), apply_filters(), wp_parse_args(), is_protected_meta(), is_callable(), is_callable(), add_filter()
is_array($wp_meta_keys) && empty($args) && !$args80–95is_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–89is_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–92is_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–92is_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–96is_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–104is_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–97is_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–100is_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–100is_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–104is_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–94is_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–105is_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–101is_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–96is_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–103is_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) && !$args94–112is_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–106is_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–106is_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–109is_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–113is_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–113is_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–102is_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–113is_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–109is_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–104is_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–111is_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–110is_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–101is_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–112is_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–108is_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–114is_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–114is_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–117is_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–121is_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–121is_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–111is_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–111is_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–122is_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–122is_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–118is_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–118is_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–113is_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–113is_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–120is_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–120is_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–118is_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–109is_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–120is_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–116is_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–123is_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–130is_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–117is_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–119is_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–119is_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–130is_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–130is_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–126is_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–126is_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–121is_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–121is_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–128is_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–128is_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–127is_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–127is_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–118is_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–118is_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–129is_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–129is_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–125is_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–125is_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–131is_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–138is_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–125is_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–128is_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–139is_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–135is_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–130is_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–137is_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–135is_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–135is_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–126is_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–126is_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–137is_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–137is_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–133is_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–133is_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–134is_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–134is_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–136is_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–147is_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–143is_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–138is_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–145is_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–144is_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–135is_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–146is_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–142is_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–142is_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–142is_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–152is_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–143is_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–154is_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–150is_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–151is_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–159is_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

PHPCompiledExecutedBranchesNotes
8.6-dev24154–15925
8.524154–15925
8.424154–15925
8.324154–15925
8.224154–15925
8.124154–159251 fewer instruction than PHP 7.4
7.424254–16025

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:

  1. apply_filters( register_meta_args )filterline 1485 (+50 into the body)

    Filters the registration arguments when registering meta.

Uses · 10

Used by · 4

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

6.7.0
The label argument was added to the arguments array.from the docblock
6.4.0
The $revisions_enabled argument was added to the arguments array.from the docblock
5.5.0
The $default argument was added to the arguments array.from the docblock
5.3.0
Valid meta types expanded to include "array" and "object".from the docblock
4.9.8
The $object_subtype argument was added to the arguments array.from the docblock
4.6.0
https://core.trac.wordpress.org/ticket/35658 Modified to support an array of data to attach to registered meta keys. Previous arguments for $sanitize_callback and $auth_callback have been folded into this array.from the docblock
3.3.0
Introduced.from the docblock

About 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.