mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-04 11:51:19 +02:00
REST API: Declare unfiltered_html
capability in links.
Because user capabilities can be modified at runtime, the REST API needs to expose them in some evaluated but declarative manner for clients to interpret. JSON Hyper Schema `targetSchema` provides an appropriate paradigm for doing so. Props timothyblynjacobs. Fixes #45014. Built from https://develop.svn.wordpress.org/branches/5.0@43682 git-svn-id: http://core.svn.wordpress.org/branches/5.0@43511 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c1ddf45869
commit
bc07c9dd9f
|
@ -1770,6 +1770,10 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
$rels[] = 'https://api.w.org/action-publish';
|
||||
}
|
||||
|
||||
if ( current_user_can( 'unfiltered_html' ) ) {
|
||||
$rels[] = 'https://api.w.org/action-unfiltered-html';
|
||||
}
|
||||
|
||||
if ( 'post' === $post_type->name ) {
|
||||
if ( current_user_can( $post_type->cap->edit_others_posts ) && current_user_can( $post_type->cap->publish_posts ) ) {
|
||||
$rels[] = 'https://api.w.org/action-sticky';
|
||||
|
@ -2179,6 +2183,22 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
);
|
||||
}
|
||||
|
||||
$links[] = array(
|
||||
'rel' => 'https://api.w.org/action-unfiltered-html',
|
||||
'title' => __( 'The current user can post unfiltered HTML markup and JavaScript.' ),
|
||||
'href' => $href,
|
||||
'targetSchema' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'content' => array(
|
||||
'raw' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if ( 'post' === $this->post_type ) {
|
||||
$links[] = array(
|
||||
'rel' => 'https://api.w.org/action-sticky',
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-43681';
|
||||
$wp_version = '5.0-alpha-43682';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue
Block a user