WP_REST_Posts_Controller::get_item_schema()
Повертає схему для записів, що відповідає схемі JSON.
Які дані перебувають у схемі дивіться у матеріалі REST для записів WordPress .
Це метод класу: WP_REST_Posts_Controller
{} Це метод класу: WP_REST_Posts_Controller{}
Хуки з методу
Array ( [$schema] => http://json-schema.org/draft-04/schema# [title] => post [type] => object [properties] => Array ( [date] => Array ( [description] => Дата публікації об'єкта за тимчасовою зоною сайту. [type] => string [format] => date-time [context] => Array ( [0] => view [1] => edit [2] => embed ) ) [date_gmt] => Array ( [description] => Час публікації об'єкта, за GMT. [type] => string [format] => date-time [context] => Array ( [0] => view [1] => edit ) ) [guid] => Array ( [description] => Глобальний унікальний ідентифікатор об'єкта. [type] => object [context] => Array ( [0] => view [1] => edit ) [readonly] => 1 [properties] => Array ( [raw] => Array ( [description] => GUID для об'єкта, як він існує у базі даних. [type] => string [context] => Array ( [0] => edit ) [readonly] => 1 ) [rendered] => Array ( [description] => GUID для об'єкта, перетворений на показ. [type] => string [context] => Array ( [0] => view [1] => edit ) [readonly] => 1 ) ) ) [id] => Array ( [description] => Унікальний ідентифікатор об'єкта. [type] => integer [context] => Array ( [0] => view [1] => edit [2] => embed ) [readonly] => 1 ) [link] => Array ( [description] => URL об'єкта. [type] => string [format] => uri [context] => Array ( [0] => view [1] => edit [2] => embed ) [readonly] => 1 ) [modified] => Array ( [description] => Дата останньої зміни об'єкта за тимчасовою зоною сайту. [type] => string [format] => date-time [context] => Array ( [0] => view [1] => edit ) [readonly] => 1 ) [modified_gmt] => Array ( [description] => Дата останньої зміни об'єкта в GMT. [type] => string [format] => date-time [context] => Array ( [0] => view [1] => edit ) [readonly] => 1 ) [slug] => Array ( [description] => Буквенно-цифровий ідентифікатор для об'єкта є унікальним для його типу. [type] => string [context] => Array ( [0] => view [1] => edit [2] => embed ) [arg_options] => Array ( [sanitize_callback] => Array ( [0] => WP_REST_Posts_Controller Object ( [post_type:protected] => post [meta:protected] => WP_REST_Post_Meta_Fields Object ( [post_type:protected] => post ) [namespace:protected] => wp/v2 [rest_base:protected] => posts ) [1] => sanitize_slug ) ) ) [status] => Array ( [description] => Іменований статус об'єкта. [type] => string [enum] => Array ( [0] => publish [1] => future [2] => draft [3] => pending [4] => private ) [context] => Array ( [0] => view [1] => edit ) ) [type] => Array ( [description] => Тип запису об'єкта. [type] => string [context] => Array ( [0] => view [1] => edit [2] => embed ) [readonly] => 1 ) [password] => Array ( [description] => Пароль для захисту змісту та уривка. [type] => string [context] => Array ( [0] => edit ) ) [title] => Array ( [description] => Назва об'єкта. [type] => object [context] => Array ( [0] => view [1] => edit [2] => embed ) [arg_options] => Array ( [sanitize_callback] => [validate_callback] => ) [properties] => Array ( [raw] => Array ( [description] => Назва об'єкта як воно існує у базі даних. [type] => string [context] => Array ( [0] => edit ) ) [rendered] => Array ( [description] => HTML назва об'єкта, перетворена для показу. [type] => string [context] => Array ( [0] => view [1] => edit [2] => embed ) [readonly] => 1 ) ) ) [content] => Array ( [description] => Вміст об'єкта. [type] => object [context] => Array ( [0] => view [1] => edit ) [arg_options] => Array ( [sanitize_callback] => [validate_callback] => ) [properties] => Array ( [raw] => Array ( [description] => Вміст об'єкта, як він існує в базі даних. [type] => string [context] => Array ( [0] => edit ) ) [rendered] => Array ( [description] => HTML вміст об'єкта перетворений для показу. [type] => string [context] => Array ( [0] => view [1] => edit ) [readonly] => 1 ) [protected] => Array ( [description] => Чи захищений вміст паролем. [type] => boolean [context] => Array ( [0] => view [1] => edit [2] => embed ) [readonly] => 1 ) ) ) [author] => Array ( [description] => ID автора об'єкта. [type] => integer [context] => Array ( [0] => view [1] => edit [2] => embed ) ) [excerpt] => Array ( [description] => Уривок об'єкта. [type] => object [context] => Array ( [0] => view [1] => edit [2] => embed ) [arg_options] => Array ( [sanitize_callback] => [validate_callback] => ) [properties] => Array ( [raw] => Array ( [description] => Уривок об'єкта, як він існує в базі даних. [type] => string [context] => Array ( [0] => edit ) ) [rendered] => Array ( [description] => HTML уривок об'єкта, перетворений для показу. [type] => string [context] => Array ( [0] => view [1] => edit [2] => embed ) [readonly] => 1 ) [protected] => Array ( [description] => Чи захищати паролем уривок. [type] => boolean [context] => Array ( [0] => view [1] => edit [2] => embed ) [readonly] => 1 ) ) ) [featured_media] => Array ( [description] => ID вибраного медіа для об'єкта. [type] => integer [context] => Array ( [0] => view [1] => edit [2] => embed ) ) [comment_status] => Array ( [description] => Чи відкриті коментарі для об'єкта. [type] => string [enum] => Array ( [0] => open [1] => closed ) [context] => Array ( [0] => view [1] => edit ) ) [ping_status] => Array ( [description] => Чи приймає об'єкт сповіщення. [type] => string [enum] => Array ( [0] => open [1] => closed ) [context] => Array ( [0] => view [1] => edit ) ) [format] => Array ( [description] => Формат об'єкта. [type] => string [enum] => Array ( [0] => standard [1] => aside [2] => chat [3] => галерея [4] => link [5] => image [6] => quote [7] => status [8] => video [9] => audio ) [context] => Array ( [0] => view [1] => edit ) ) [meta] => Array ( [description] => Мета поля. [type] => object [context] => Array ( [0] => view [1] => edit ) [properties] => Array ( ) [arg_options] => Array ( [sanitize_callback] => [validate_callback] => Array ( [0] => WP_REST_Post_Meta_Fields Object ( [post_type:protected] => post ) [1] => check_meta_is_array ) ) ) [sticky] => Array ( [description] => Вважати об'єкт приліпленим чи ні. [type] => boolean [context] => Array ( [0] => view [1] => edit ) ) [template] => Array ( [description] => Файл теми, що використовується для показу об'єкта. [type] => string [context] => Array ( [0] => view [1] => edit ) [arg_options] => Array ( [validate_callback] => Array ( [0] => WP_REST_Posts_Controller Object ( [post_type:protected] => post [meta:protected] => WP_REST_Post_Meta_Fields Object ( [post_type:protected] => post ) [namespace:protected] => wp/v2 [rest_base:protected] => posts ) [1] => check_template ) ) ) [categories] => Array ( [description] => Елементи призначені об'єкту в таксономії категорії. [type] => array [items] => Array ( [type] => integer ) [context] => Array ( [0] => view [1] => edit ) ) [tags] => Array ( [description] => Елементи призначені об'єкту в таксономії post_tag. [type] => array [items] => Array ( [type] => integer ) [context] => Array ( [0] => view [1] => edit ) ) ) [links] => Array ( [0] => Array ( [rel] => https://api.w.org/action-publish [title] => Поточний користувач може опублікувати цей запис. [href] => http://wp-test.ru/wp-json/wp/v2/posts/{id} [targetSchema] => Array ( [type] => object [properties] => Array ( [status] => Array ( [type] => string [enum] => Array ( [0] => publish [1] => future ) ) ) ) ) [1] => Array ( [rel] => https://api.w.org/action-sticky [title] => Поточний користувач може зробити цей запис прикріпленим. [href] => http://wp-test.ru/wp-json/wp/v2/posts/{id} [targetSchema] => Array ( [type] => object [properties] => Array ( [sticky] => Array ( [type] => boolean ) ) ) ) [2] => Array ( [rel] => https://api.w.org/action-assign-author [title] => Поточний користувач може змінити автора цього запису. [href] => http://wp-test.ru/wp-json/wp/v2/posts/{id} [targetSchema] => Array ( [type] => object [properties] => Array ( [author] => Array ( [type] => integer ) ) ) ) [3] => Array ( [rel] => https://api.w.org/action-assign-categories [title] => Поточний користувач може призначати елементи в таксономії категорії. [href] => http://wp-test.ru/wp-json/wp/v2/posts/{id} [targetSchema] => Array ( [type] => object [properties] => Array ( [categories] => Array ( [type] => array [items] => Array ( [type] => integer ) ) ) ) ) [4] => Array ( [rel] => https://api.w.org/action-create-categories [title] => Поточний користувач може створювати елементи в таксономії категорії. [href] => http://wp-test.ru/wp-json/wp/v2/posts/{id} [targetSchema] => Array ( [type] => object [properties] => Array ( [categories] => Array ( [type] => array [items] => Array ( [type] => integer ) ) ) ) ) [5] => Array ( [rel] => https://api.w.org/action-assign-tags [title] => Поточний користувач може призначати елементи таксономії post_tag. [href] => http://wp-test.ru/wp-json/wp/v2/posts/{id} [targetSchema] => Array ( [type] => object [properties] => Array ( [tags] => Array ( [type] => array [items] => Array ( [type] => integer ) ) ) ) ) [6] => Array ( [rel] => https://api.w.org/action-create-tags [title] => Поточний користувач може створювати елементи у таксономії post_tag. [href] => http://wp-test.ru/wp-json/wp/v2/posts/{id} [targetSchema] => Array ( [type] => object [properties] => Array ( [tags] => Array ( [type] => array [items] => Array ( [type] => integer ) ) ) ) ) ) )
Використання
$WP_REST_Posts_Controller = новий WP_REST_Posts_Controller(); $var = $WP_REST_Posts_Controller->get_item_schema();
Приклади
#1 Приклад з ядра WP
Метод WP_REST_Menus_Controller::prepare_item_for_database :
... /** * Prepares a single term for create or update. * * @ Since 5.9.0 * * @param WP_REST_Request $request Request object. * @return object Prepared term data. */ public function prepare_item_for_database( $request ) { $prepared_term = parent::prepare_item_for_database( $request ); $schema = $this->get_item_schema(); if ( isset( $request['name'] ) && ! empty( $schema['properties']['name'] ) ) { $prepared_term->{'menu-name'} = $request['name']; } return $prepared_term; } ...
список змін
З версії 4.7.0 | Введено. |