register_rest_field example

/** * Registers the meta field. * * @since 4.7.0 * @deprecated 5.6.0 * * @see register_rest_field() */
    public function register_field() {
        _deprecated_function( __METHOD__, '5.6.0' );

        register_rest_field(
            $this->get_rest_field_type(),
            'meta',
            array(
                'get_callback'    => array( $this, 'get_value' ),
                'update_callback' => array( $this, 'update_value' ),
                'schema'          => $this->get_field_schema(),
            )
        );
    }

    /** * Retrieves the meta field value. * * @since 4.7.0 * * @param int $object_id Object ID to fetch meta for. * @param WP_REST_Request $request Full details about the request. * @return array Array containing the meta values keyed by name. */
Home | Imprint | This part of the site doesn't use cookies.