Блоки (блоки)

Ці маршрути дозволяють отримати/створити/оновити/видалити блоки чи окремий блок (запис). Додано до 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 для об'єкта, як він існує в 데이터베이스.",
			"type": "string",
			"context": [
				"edit"
			],
			"readonly": true
		},
		"rendered": {
			"description": "GUID для об'єкта, 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": "Візьміть час, який буде змінений, в зоні часу.",
	"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": "Ан alphanumeric identifier для object unique to type.",
	"type": "string",
	"context": [
		"view",
		"edit",
		"embed"
	]
},
"status": {
	"description": "Назва статуя для об'єкта.",
	"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": "Наявність для 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 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": "Коррентна сторінка колекції.",
                    "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": "Звичайні результати для того, щоб matching a string.",
                    "type": "string"
                },
                "after": {
                    "required": false,
                    "description": "Limit response to posts published af 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 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": "Звичайний результат надається для повідомлень з однією або більше конкретних slugs.",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "status": {
                    "required": false,
                    "default": "publish",
                    "description": "Звичайний результат встановлюється для повідомлень одного або більше статей.",
                    "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": "Ан alphanumeric identifier для object unique to type.",
                    "type": "string"
                },
                "status": {
                    "required": false,
                    "enum": [
                        "Publish",
                        "Future",
                        "draft",
                        "pending",
                        "private"
                    ],
                    "description": "Назва статуя для об'єкта.",
                    "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": "Наявність для 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 для об'єкта, як він існує в 데이터베이스.",
                        "type": "string",
                        "context": [
                            "edit"
                        ],
                        "readonly": true
                    },
                    "rendered": {
                        "description": "GUID для об'єкта, 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": "Візьміть час, який буде змінений, в зоні часу.",
                "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": "Ан alphanumeric identifier для object unique to type.",
                "type": "string",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ]
            },
            "status": {
                "description": "Назва статуя для об'єкта.",
                "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": "Наявність для 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 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": "На даний момент користувач може публікувати це повідомлення.",
                "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": "Теперний користувач може 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": "Повідомляйте про те, що повідомлення повідомлене про те, що воно є.",
                    "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": "Ан alphanumeric identifier для object unique to type.",
                    "type": "string"
                },
                "status": {
                    "required": false,
                    "enum": [
                        "Publish",
                        "Future",
                        "draft",
                        "pending",
                        "private"
                    ],
                    "description": "Назва статуя для об'єкта.",
                    "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": "Наявність для 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 для об'єкта, як він існує в 데이터베이스.",
                        "type": "string",
                        "context": [
                            "edit"
                        ],
                        "readonly": true
                    },
                    "rendered": {
                        "description": "GUID для об'єкта, 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": "Візьміть час, який буде змінений, в зоні часу.",
                "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": "Ан alphanumeric identifier для object unique to type.",
                "type": "string",
                "context": [
                    "view",
                    "edit",
                    "embed"
                ]
            },
            "status": {
                "description": "Назва статуя для об'єкта.",
                "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": "Наявність для 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 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": "На даний момент користувач може публікувати це повідомлення.",
                "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": "Теперний користувач може 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"
                            }
                        }
                    }
                }
            }
        ]
    }
}

Отримання запису

Дивіться опис ендпоінта записів (постів) .

Оновлення запису

Дивіться опис ендпоінта записів (постів) .

Видалення запису

Дивіться опис ендпоінта записів (постів) .

Залишити відповідь

Ваша e-mail адреса не оприлюднюватиметься. Обов’язкові поля позначені *