LLMS_REST_Posts_Controller::get_item_schema()
Get the LLMS Posts’s schema, conforming to JSON Schema.
Return Return
(array)
Source Source
File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-posts-controller.php
return $prepared_item;
}
/**
* Get the LLMS Posts's schema, conforming to JSON Schema.
*
* @since 1.0.0-beta.27
*
* @return array
*/
protected function get_item_schema_base() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => $this->post_type,
'type' => 'object',
'properties' => array(
'id' => array(
'description' => __( 'Unique Identifier. The WordPress Post ID.', 'lifterlms' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'date_created' => array(
'description' => __( 'Creation date. Format: Y-m-d H:i:s', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'date_created_gmt' => array(
'description' => __( 'Creation date (in GMT). Format: Y-m-d H:i:s', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'date_updated' => array(
'description' => __( 'Date last modified. Format: Y-m-d H:i:s', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'date_updated_gmt' => array(
'description' => __( 'Date last modified (in GMT). Format: Y-m-d H:i:s', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'menu_order' => array(
'description' => __( 'Creation date (in GMT). Format: Y-m-d H:i:s', 'lifterlms' ),
'type' => 'integer',
'default' => 0,
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => 'absint',
),
),
'title' => array(
'description' => __( 'Post title.', 'lifterlms' ),
'type' => 'object',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database().
'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database().
),
'required' => true,
'properties' => array(
'raw' => array(
'description' => __( 'Raw title. Useful when displaying title in the WP Block Editor. Only returned in edit context.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'edit' ),
),
'rendered' => array(
'description' => __( 'Rendered title.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
),
),
'content' => array(
'type' => 'object',
'description' => __( 'The HTML content of the post.', 'lifterlms' ),
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database().
'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database().
),
'required' => true,
'properties' => array(
'rendered' => array(
'description' => __( 'Rendered HTML content.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'raw' => array(
'description' => __( 'Raw HTML content. Useful when displaying title in the WP Block Editor. Only returned in edit context.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'edit' ),
),
'protected' => array(
'description' => __( 'Whether the content is protected with a password.', 'lifterlms' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
),
),
'excerpt' => array(
'type' => 'object',
'description' => __( 'The HTML excerpt of the post.', 'lifterlms' ),
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database().
'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database().
),
'properties' => array(
'rendered' => array(
'description' => __( 'Rendered HTML excerpt.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'raw' => array(
'description' => __( 'Raw HTML excerpt. Useful when displaying title in the WP Block Editor. Only returned in edit context.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'edit' ),
),
'protected' => array(
'description' => __( 'Whether the excerpt is protected with a password.', 'lifterlms' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
),
),
'permalink' => array(
'description' => __( 'Post URL.', 'lifterlms' ),
'type' => 'string',
'format' => 'uri',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'slug' => array(
'description' => __( 'Post URL slug.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => array( $this, 'sanitize_slug' ),
),
),
'post_type' => array(
'description' => __( 'LifterLMS custom post type', 'lifterlms' ),
'type' => 'string',
'readonly' => true,
'context' => array( 'view', 'edit' ),
),
'status' => array(
'description' => __( 'The publication status of the post.', 'lifterlms' ),
'type' => 'string',
'default' => 'publish',
'enum' => array_keys(
get_post_stati(
array(
'_builtin' => true,
'internal' => false,
)
)
),
'context' => array( 'view', 'edit' ),
),
'password' => array(
'description' => __( 'Password used to protect access to the content.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'edit' ),
),
'featured_media' => array(
'description' => __( 'Featured image ID.', 'lifterlms' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'comment_status' => array(
'description' => __( 'Post comment status. Default comment status dependent upon general WordPress post discussion settings.', 'lifterlms' ),
'type' => 'string',
'default' => 'open',
'enum' => array( 'open', 'closed' ),
'context' => array( 'view', 'edit' ),
),
'ping_status' => array(
'description' => __( 'Post ping status. Default ping status dependent upon general WordPress post discussion settings.', 'lifterlms' ),
'type' => 'string',
'default' => 'open',
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0-beta.19 | Allow only _built_in and not internal post status (see WordPress get_post_stati() ). |
| 1.0.0-beta.1 | Introduced. |