Блоки (blocks)

Эти маршруты позволяют получить/создать/обновить/удалить блоки или отдельный блок (запись). Добавлено в WP 5.0.

Возможные маршруты (конечные точки маршрутов описаны ниже):

/wp/v2/blocks       // работает со всеми блоками (типами записей)
/wp/v2/blocks/{ID}  // работает с указанным вместо {ID} блоком

Класс контроллера: WP_REST_Blocks_Controller{}

Схема ресурса

"date": {
	"description": "The date the object was published, in the site's timezone.",
	"type": "string",
	"format": "date-time",
	"context": [
		"view",
		"edit",
		"embed"
	]
},
"date_gmt": {
	"description": "The date the object was published, as GMT.",
	"type": "string",
	"format": "date-time",
	"context": [
		"view",
		"edit"
	]
},
"guid": {
	"description": "The globally unique identifier for the object.",
	"type": "object",
	"context": [
		"view",
		"edit"
	],
	"readonly": true,
	"properties": {
		"raw": {
			"description": "GUID for the object, as it exists in the database.",
			"type": "string",
			"context": [
				"edit"
			],
			"readonly": true
		},
		"rendered": {
			"description": "GUID for the object, transformed for display.",
			"type": "string",
			"context": [
				"view",
				"edit"
			],
			"readonly": true
		}
	}
},
"id": {
	"description": "Unique identifier for the object.",
	"type": "integer",
	"context": [
		"view",
		"edit",
		"embed"
	],
	"readonly": true
},
"link": {
	"description": "URL to the object.",
	"type": "string",
	"format": "uri",
	"context": [
		"view",
		"edit",
		"embed"
	],
	"readonly": true
},
"modified": {
	"description": "The date the object was last modified, in the site's timezone.",
	"type": "string",
	"format": "date-time",
	"context": [
		"view",
		"edit"
	],
	"readonly": true
},
"modified_gmt": {
	"description": "The date the object was last modified, as GMT.",
	"type": "string",
	"format": "date-time",
	"context": [
		"view",
		"edit"
	],
	"readonly": true
},
"slug": {
	"description": "An alphanumeric identifier for the object unique to its type.",
	"type": "string",
	"context": [
		"view",
		"edit",
		"embed"
	]
},
"status": {
	"description": "A named status for the object.",
	"type": "string",
	"enum": [
		"publish",
		"future",
		"draft",
		"pending",
		"private"
	],
	"context": [
		"view",
		"edit"
	]
},
"type": {
	"description": "Type of Post for the object.",
	"type": "string",
	"context": [
		"view",
		"edit",
		"embed"
	],
	"readonly": true
},
"password": {
	"description": "A password to protect access to the content and excerpt.",
	"type": "string",
	"context": [
		"edit"
	]
},
"title": {
	"description": "The title for the object.",
	"type": "object",
	"context": [
		"view",
		"edit",
		"embed"
	],
	"properties": {
		"raw": {
			"description": "Title for the object, as it exists in the database.",
			"type": "string",
			"context": [
				"view",
				"edit"
			]
		}
	}
},
"content": {
	"description": "The content for the object.",
	"type": "object",
	"context": [
		"view",
		"edit"
	],
	"properties": {
		"raw": {
			"description": "Content for the object, as it exists in the database.",
			"type": "string",
			"context": [
				"view",
				"edit"
			]
		},
		"block_version": {
			"description": "Version of the content block format used by the object.",
			"type": "integer",
			"context": [
				"edit"
			],
			"readonly": true
		},
		"protected": {
			"description": "Whether the content is protected with a password.",
			"type": "boolean",
			"context": [
				"view",
				"edit",
				"embed"
			],
			"readonly": true
		}
	}
},
"template": {
	"description": "The theme file to use to display the object.",
	"type": "string",
	"context": [
		"view",
		"edit"
	]
}

wp/v2/blocks

Запрос OPTIONS к маршруту вернет полное описание этого маршрута: эндпоинты их параметры, схему.

$ curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/blocks
GitHub
{
    "namespace": "wp/v2",
    "methods": [
        "GET",
        "POST"
    ],
    "endpoints": [
        {
            "methods": [
                "GET"
            ],
            "args": {
                "context": {
                    "required": false,
                    "default": "view",
                    "enum": [
                        "view",
                        "embed",
                        "edit"
                    ],
                    "description": "Scope under which the request is made; determines fields present in response.",
                    "type": "string"
                },
                "page": {
                    "required": false,
                    "default": 1,
                    "description": "Current page of the collection.",
                    "type": "integer"
                },
                "per_page": {
                    "required": false,
                    "default": 10,
                    "description": "Maximum number of items to be returned in result set.",
                    "type": "integer"
                },
                "search": {
                    "required": false,
                    "description": "Limit results to those matching a string.",
                    "type": "string"
                },
                "after": {
                    "required": false,
                    "description": "Limit response to posts published after a given ISO8601 compliant date.",
                    "type": "string"
                },
                "before": {
                    "required": false,
                    "description": "Limit response to posts published before a given ISO8601 compliant date.",
                    "type": "string"
                },
                "exclude": {
                    "required": false,
                    "default": [],
                    "description": "Ensure result set excludes specific IDs.",
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "include": {
                    "required": false,
                    "default": [],
                    "description": "Limit result set to specific IDs.",
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "offset": {
                    "required": false,
                    "description": "Offset the result set by a specific number of items.",
                    "type": "integer"
                },
                "order": {
                    "required": false,
                    "default": "desc",
                    "enum": [
                        "asc",
                        "desc"
                    ],
                    "description": "Order sort attribute ascending or descending.",
                    "type": "string"
                },
                "orderby": {
                    "required": false,
                    "default": "date",
                    "enum": [
                        "author",
                        "date",
                        "id",
                        "include",
                        "modified",
                        "parent",
                        "relevance",
                        "slug",
                        "include_slugs",
                        "title"
                    ],
                    "description": "Sort collection by object attribute.",
                    "type": "string"
                },
                "slug": {
                    "required": false,
                    "description": "Limit result set to posts with one or more specific slugs.",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "status": {
                    "required": false,
                    "default": "publish",
                    "description": "Limit result set to posts assigned one or more statuses.",
                    "type": "array",
                    "items": {
                        "enum": [
                            "publish",
                            "future",
                            "draft",
                            "pending",
                            "private",
                            "trash",
                            "auto-draft",
                            "inherit",
                            "request-pending",
                            "request-confirmed",
                            "request-failed",
                            "request-completed",
                            "any"
                        ],
                        "type": "string"
                    }
                }
            }
        },
        {
            "methods": [
                "POST"
            ],
            "args": {
                "date": {
                    "required": false,
                    "description": "The date the object was published, in the site's timezone.",
                    "type": "string"
                },
                "date_gmt": {
                    "required": false,
                    "description": "The date the object was published, as GMT.",
                    "type": "string"
                },
                "slug": {
                    "required": false,
                    "description": "An alphanumeric identifier for the object unique to its type.",
                    "type": "string"
                },
                "status": {
                    "required": false,
                    "enum": [
                        "publish",
                        "future",
                        "draft",
                        "pending",
                        "private"
                    ],
                    "description": "A named status for the object.",
                    "type": "string"
                },
                "password": {
                    "required": false,
                    "description": "A password to protect access to the content and excerpt.",
                    "type": "string"
                },
                "title": {
                    "required": false,
                    "description": "The title for the object.",
                    "type": "object"
                },
                "content": {
                    "required": false,
                    "description": "The content for the object.",
                    "type": "object"
                },
                "template": {
                    "required": false,
                    "description": "The theme file to use to display the object.",
                    "type": "string"
                }
            }
        }
    ],
    "schema": {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "title": "wp_block",
        "type": "object",
        "properties": {
            "date": {
                "description": "The date the object was published, in the site's timezone.",
                "type": "string",
                "format": "date-time",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ]
            },
            "date_gmt": {
                "description": "The date the object was published, as GMT.",
                "type": "string",
                "format": "date-time",
                "context": [
                    "view",
                    "edit"
                ]
            },
            "guid": {
                "description": "The globally unique identifier for the object.",
                "type": "object",
                "context": [
                    "view",
                    "edit"
                ],
                "readonly": true,
                "properties": {
                    "raw": {
                        "description": "GUID for the object, as it exists in the database.",
                        "type": "string",
                        "context": [
                            "edit"
                        ],
                        "readonly": true
                    },
                    "rendered": {
                        "description": "GUID for the object, transformed for display.",
                        "type": "string",
                        "context": [
                            "view",
                            "edit"
                        ],
                        "readonly": true
                    }
                }
            },
            "id": {
                "description": "Unique identifier for the object.",
                "type": "integer",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ],
                "readonly": true
            },
            "link": {
                "description": "URL to the object.",
                "type": "string",
                "format": "uri",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ],
                "readonly": true
            },
            "modified": {
                "description": "The date the object was last modified, in the site's timezone.",
                "type": "string",
                "format": "date-time",
                "context": [
                    "view",
                    "edit"
                ],
                "readonly": true
            },
            "modified_gmt": {
                "description": "The date the object was last modified, as GMT.",
                "type": "string",
                "format": "date-time",
                "context": [
                    "view",
                    "edit"
                ],
                "readonly": true
            },
            "slug": {
                "description": "An alphanumeric identifier for the object unique to its type.",
                "type": "string",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ]
            },
            "status": {
                "description": "A named status for the object.",
                "type": "string",
                "enum": [
                    "publish",
                    "future",
                    "draft",
                    "pending",
                    "private"
                ],
                "context": [
                    "view",
                    "edit"
                ]
            },
            "type": {
                "description": "Type of Post for the object.",
                "type": "string",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ],
                "readonly": true
            },
            "password": {
                "description": "A password to protect access to the content and excerpt.",
                "type": "string",
                "context": [
                    "edit"
                ]
            },
            "title": {
                "description": "The title for the object.",
                "type": "object",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ],
                "properties": {
                    "raw": {
                        "description": "Title for the object, as it exists in the database.",
                        "type": "string",
                        "context": [
                            "view",
                            "edit"
                        ]
                    }
                }
            },
            "content": {
                "description": "The content for the object.",
                "type": "object",
                "context": [
                    "view",
                    "edit"
                ],
                "properties": {
                    "raw": {
                        "description": "Content for the object, as it exists in the database.",
                        "type": "string",
                        "context": [
                            "view",
                            "edit"
                        ]
                    },
                    "block_version": {
                        "description": "Version of the content block format used by the object.",
                        "type": "integer",
                        "context": [
                            "edit"
                        ],
                        "readonly": true
                    },
                    "protected": {
                        "description": "Whether the content is protected with a password.",
                        "type": "boolean",
                        "context": [
                            "view",
                            "edit",
                            "embed"
                        ],
                        "readonly": true
                    }
                }
            },
            "template": {
                "description": "The theme file to use to display the object.",
                "type": "string",
                "context": [
                    "view",
                    "edit"
                ]
            }
        },
        "links": [
            {
                "rel": "https://api.w.org/action-publish",
                "title": "The current user can publish this post.",
                "href": "https://demo.wp-api.org/wp-json/wp/v2/blocks/{id}",
                "targetSchema": {
                    "type": "object",
                    "properties": {
                        "status": {
                            "type": "string",
                            "enum": [
                                "publish",
                                "future"
                            ]
                        }
                    }
                }
            },
            {
                "rel": "https://api.w.org/action-unfiltered-html",
                "title": "The current user can post unfiltered HTML markup and JavaScript.",
                "href": "https://demo.wp-api.org/wp-json/wp/v2/blocks/{id}",
                "targetSchema": {
                    "type": "object",
                    "properties": {
                        "content": {
                            "raw": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        ]
    },
    "_links": {
        "self": "https://demo.wp-api.org/wp-json/wp/v2/blocks"
    }
}

Список записей

Смотрите описание эндпоинта записей (постов).

Создание записи

Смотрите описание эндпоинта записей (постов).

wp/v2/posts/{id}

Запрос OPTIONS к маршруту вернет полное описание этого маршрута: эндпоинты их параметры, схему.

$ curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/blocks/1
GitHub
{
    "namespace": "wp/v2",
    "methods": [
        "GET",
        "POST",
        "PUT",
        "PATCH",
        "DELETE"
    ],
    "endpoints": [
        {
            "methods": [
                "GET"
            ],
            "args": {
                "id": {
                    "required": false,
                    "description": "Unique identifier for the object.",
                    "type": "integer"
                },
                "context": {
                    "required": false,
                    "default": "view",
                    "enum": [
                        "view",
                        "embed",
                        "edit"
                    ],
                    "description": "Scope under which the request is made; determines fields present in response.",
                    "type": "string"
                },
                "password": {
                    "required": false,
                    "description": "The password for the post if it is password protected.",
                    "type": "string"
                }
            }
        },
        {
            "methods": [
                "POST",
                "PUT",
                "PATCH"
            ],
            "args": {
                "id": {
                    "required": false,
                    "description": "Unique identifier for the object.",
                    "type": "integer"
                },
                "date": {
                    "required": false,
                    "description": "The date the object was published, in the site's timezone.",
                    "type": "string"
                },
                "date_gmt": {
                    "required": false,
                    "description": "The date the object was published, as GMT.",
                    "type": "string"
                },
                "slug": {
                    "required": false,
                    "description": "An alphanumeric identifier for the object unique to its type.",
                    "type": "string"
                },
                "status": {
                    "required": false,
                    "enum": [
                        "publish",
                        "future",
                        "draft",
                        "pending",
                        "private"
                    ],
                    "description": "A named status for the object.",
                    "type": "string"
                },
                "password": {
                    "required": false,
                    "description": "A password to protect access to the content and excerpt.",
                    "type": "string"
                },
                "title": {
                    "required": false,
                    "description": "The title for the object.",
                    "type": "object"
                },
                "content": {
                    "required": false,
                    "description": "The content for the object.",
                    "type": "object"
                },
                "template": {
                    "required": false,
                    "description": "The theme file to use to display the object.",
                    "type": "string"
                }
            }
        },
        {
            "methods": [
                "DELETE"
            ],
            "args": {
                "id": {
                    "required": false,
                    "description": "Unique identifier for the object.",
                    "type": "integer"
                },
                "force": {
                    "required": false,
                    "default": false,
                    "description": "Whether to bypass trash and force deletion.",
                    "type": "boolean"
                }
            }
        }
    ],
    "schema": {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "title": "wp_block",
        "type": "object",
        "properties": {
            "date": {
                "description": "The date the object was published, in the site's timezone.",
                "type": "string",
                "format": "date-time",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ]
            },
            "date_gmt": {
                "description": "The date the object was published, as GMT.",
                "type": "string",
                "format": "date-time",
                "context": [
                    "view",
                    "edit"
                ]
            },
            "guid": {
                "description": "The globally unique identifier for the object.",
                "type": "object",
                "context": [
                    "view",
                    "edit"
                ],
                "readonly": true,
                "properties": {
                    "raw": {
                        "description": "GUID for the object, as it exists in the database.",
                        "type": "string",
                        "context": [
                            "edit"
                        ],
                        "readonly": true
                    },
                    "rendered": {
                        "description": "GUID for the object, transformed for display.",
                        "type": "string",
                        "context": [
                            "view",
                            "edit"
                        ],
                        "readonly": true
                    }
                }
            },
            "id": {
                "description": "Unique identifier for the object.",
                "type": "integer",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ],
                "readonly": true
            },
            "link": {
                "description": "URL to the object.",
                "type": "string",
                "format": "uri",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ],
                "readonly": true
            },
            "modified": {
                "description": "The date the object was last modified, in the site's timezone.",
                "type": "string",
                "format": "date-time",
                "context": [
                    "view",
                    "edit"
                ],
                "readonly": true
            },
            "modified_gmt": {
                "description": "The date the object was last modified, as GMT.",
                "type": "string",
                "format": "date-time",
                "context": [
                    "view",
                    "edit"
                ],
                "readonly": true
            },
            "slug": {
                "description": "An alphanumeric identifier for the object unique to its type.",
                "type": "string",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ]
            },
            "status": {
                "description": "A named status for the object.",
                "type": "string",
                "enum": [
                    "publish",
                    "future",
                    "draft",
                    "pending",
                    "private"
                ],
                "context": [
                    "view",
                    "edit"
                ]
            },
            "type": {
                "description": "Type of Post for the object.",
                "type": "string",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ],
                "readonly": true
            },
            "password": {
                "description": "A password to protect access to the content and excerpt.",
                "type": "string",
                "context": [
                    "edit"
                ]
            },
            "title": {
                "description": "The title for the object.",
                "type": "object",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ],
                "properties": {
                    "raw": {
                        "description": "Title for the object, as it exists in the database.",
                        "type": "string",
                        "context": [
                            "view",
                            "edit"
                        ]
                    }
                }
            },
            "content": {
                "description": "The content for the object.",
                "type": "object",
                "context": [
                    "view",
                    "edit"
                ],
                "properties": {
                    "raw": {
                        "description": "Content for the object, as it exists in the database.",
                        "type": "string",
                        "context": [
                            "view",
                            "edit"
                        ]
                    },
                    "block_version": {
                        "description": "Version of the content block format used by the object.",
                        "type": "integer",
                        "context": [
                            "edit"
                        ],
                        "readonly": true
                    },
                    "protected": {
                        "description": "Whether the content is protected with a password.",
                        "type": "boolean",
                        "context": [
                            "view",
                            "edit",
                            "embed"
                        ],
                        "readonly": true
                    }
                }
            },
            "template": {
                "description": "The theme file to use to display the object.",
                "type": "string",
                "context": [
                    "view",
                    "edit"
                ]
            }
        },
        "links": [
            {
                "rel": "https://api.w.org/action-publish",
                "title": "The current user can publish this post.",
                "href": "https://demo.wp-api.org/wp-json/wp/v2/blocks/{id}",
                "targetSchema": {
                    "type": "object",
                    "properties": {
                        "status": {
                            "type": "string",
                            "enum": [
                                "publish",
                                "future"
                            ]
                        }
                    }
                }
            },
            {
                "rel": "https://api.w.org/action-unfiltered-html",
                "title": "The current user can post unfiltered HTML markup and JavaScript.",
                "href": "https://demo.wp-api.org/wp-json/wp/v2/blocks/{id}",
                "targetSchema": {
                    "type": "object",
                    "properties": {
                        "content": {
                            "raw": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        ]
    }
}

Получение записи

Смотрите описание эндпоинта записей (постов).

Обновление записи

Смотрите описание эндпоинта записей (постов).

Удаление записи

Смотрите описание эндпоинта записей (постов).