Kindly EditDocumentationTry the editor

element-source REST endpoint

List the posts a custom element's item can fill from, or one post's values for its fields.

Endpoint#

List the posts a custom element's item can fill from, or one post's values for its fields. Available from Kindly Edit 0.11.0.

/wp-json/cantata-edit/v1/element-source

GET#

This operation uses a server permission callback. Browser clients need an authenticated WordPress session and REST nonce.

Permission expression in this release:

'permission_callback' => static fn() => current_user_can( 'edit_posts' ),

The callback also reads only the post types the element's definition names, and only posts the caller may read (read_post).

Registered argument schema#

{
  "element": { "type": "string", "required": true },
  "id": { "type": "integer", "minimum": 0 },
  "search": { "type": "string" }
}
  • element: the definition's slug, the file name without its number (11-featured-events.json is featured-events).
  • Without id: up to 30 posts, [ { "id", "title", "when" } ], sorted as the definition's source.sort says, and only upcoming ones when it sets upcoming. search narrows them.
  • With id: { "id", "title", "values" }, where values maps each field key in the definition's fill to its value: words, { "start": "Y-m-d", "end": "Y-m-d" } for a date field, or { "id", "src", "srcset", "width", "height", "alt" } for an image field. Addresses are relative to the site.

Errors#

Status Code When
401 rest_forbidden Not signed in.
403 rest_forbidden Signed in without edit_posts.
404 cantata_edit_no_source No such element, or it has nothing to fill from.
404 cantata_edit_source_missing The post is gone, is another type, or the caller can't read it.

Implementation#

cantata_edit_custom_elements, cantata_edit_custom_candidates and cantata_edit_custom_fill in includes/custom-elements.php.

Client handling#

The editor calls it from an item's Fill from control. Filling copies the values into the page once; nothing updates by itself.

About this page

Documents Kindly Edit 0.9.16. Source: includes/custom-elements.php. Theme choices and account permissions can change which controls appear.

Type a word or phrase to search the full documentation.