get_schema_links example

return $links;
    }

    /** * Retrieves Link Description Objects that should be added to the Schema for the posts collection. * * @since 5.9.0 * * @return array */
    protected function get_schema_links() {
        $links   = parent::get_schema_links();
        $href    = rest_url( "{$this->namespace}/{$this->rest_base}/{id}" );
        $links[] = array(
            'rel'          => 'https://api.w.org/menu-item-object',
            'title'        => __( 'Get linked object.' ),
            'href'         => $href,
            'targetSchema' => array(
                'type'       => 'object',
                'properties' => array(
                    'object' => array(
                        'type' => 'integer',
                    ),
                ),
$schema['properties'][ $base ] = array(
                /* translators: %s: Taxonomy name. */
                'description' => sprintf( __( 'The terms assigned to the post in the %s taxonomy.' )$taxonomy->name ),
                'type'        => 'array',
                'items'       => array(
                    'type' => 'integer',
                ),
                'context'     => array( 'view', 'edit' ),
            );
        }

        $schema_links = $this->get_schema_links();

        if ( $schema_links ) {
            $schema['links'] = $schema_links;
        }

        // Take a snapshot of which fields are in the schema pre-filtering.         $schema_fields = array_keys( $schema['properties'] );

        /** * Filters the post's schema. * * The dynamic portion of the filter, `$this->post_type`, refers to the * post type slug for the controller. * * Possible hook names include: * * - `rest_post_item_schema` * - `rest_page_item_schema` * - `rest_attachment_item_schema` * * @since 5.4.0 * * @param array $schema Item schema data. */
Home | Imprint | This part of the site doesn't use cookies.