Retrieves the post’s schema, conforming to JSON Schema.
Source
public function get_item_schema() {
if ( $this->schema ) {
return $this->add_additional_fields_schema( $this->schema );
}
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => $this->post_type,
'type' => 'object',
// Base properties for every Post.
'properties' => array(
'id' => array(
'description' => __( 'Unique identifier for the post.', 'default' ),
'type' => 'integer',
'context' => array( 'view', 'edit', 'embed' ),
'readonly' => true,
),
'theme_json_version' => array(
'description' => __( 'Version of the theme.json schema used for the typography settings.' ),
'type' => 'integer',
'default' => static::LATEST_THEME_JSON_VERSION_SUPPORTED,
'minimum' => 2,
'maximum' => static::LATEST_THEME_JSON_VERSION_SUPPORTED,
'context' => array( 'view', 'edit', 'embed' ),
),
'font_faces' => array(
'description' => __( 'The IDs of the child font faces in the font family.' ),
'type' => 'array',
'context' => array( 'view', 'edit', 'embed' ),
'items' => array(
'type' => 'integer',
),
),
// Font family settings come directly from theme.json schema
// See https://schemas.wp.org/trunk/theme.json
'font_family_settings' => array(
'description' => __( 'font-face definition in theme.json format.' ),
'type' => 'object',
'context' => array( 'view', 'edit', 'embed' ),
'properties' => array(
'name' => array(
'description' => __( 'Name of the font family preset, translatable.' ),
'type' => 'string',
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
),
'slug' => array(
'description' => __( 'Kebab-case unique identifier for the font family preset.' ),
'type' => 'string',
'arg_options' => array(
'sanitize_callback' => 'sanitize_title',
),
),
'fontFamily' => array(
'description' => __( 'CSS font-family value.' ),
'type' => 'string',
'arg_options' => array(
'sanitize_callback' => array( 'WP_Font_Utils', 'sanitize_font_family' ),
),
),
'preview' => array(
'description' => __( 'URL to a preview image of the font family.' ),
'type' => 'string',
'format' => 'uri',
'default' => '',
'arg_options' => array(
'sanitize_callback' => 'sanitize_url',
),
),
),
'required' => array( 'name', 'slug', 'fontFamily' ),
'additionalProperties' => false,
),
),
);
$this->schema = $schema;
return $this->add_additional_fields_schema( $this->schema );
}
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.