Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: register_meta_args

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
1478       *
1479       * @since 4.6.0
1480       *
1481       * @param array  $args        Array of meta registration arguments.
1482       * @param array  $defaults    Array of default arguments.
1483       * @param string $object_type Type of object metadata is for. Accepts 'blog', 'post', 'comment', 'term',
1484       *                            'user', or any other object type with an associated meta table.
1485       * @param string $meta_key    Meta key.
1486       */
1487      $args = apply_filters( 'register_meta_args', $args, $defaults, $object_type, $meta_key );
1488      unset( $defaults['default'] );
1489      $args = wp_parse_args( $args, $defaults );
1490
1491      // Require an item schema when registering array meta.
1492      if ( false !== $args['show_in_rest'] && 'array' === $args['type'] ) {
1493           if ( ! is_array( $args['show_in_rest'] ) || ! isset( $args['show_in_rest']['schema']['items'] ) ) {
1494                _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' );
1495
1496                return false;