equal
deleted
inserted
replaced
22 /** |
22 /** |
23 * Checks if a block can be read. |
23 * Checks if a block can be read. |
24 * |
24 * |
25 * @since 5.0.0 |
25 * @since 5.0.0 |
26 * |
26 * |
27 * @param object $post Post object that backs the block. |
27 * @param WP_Post $post Post object that backs the block. |
28 * @return bool Whether the block can be read. |
28 * @return bool Whether the block can be read. |
29 */ |
29 */ |
30 public function check_read_permission( $post ) { |
30 public function check_read_permission( $post ) { |
31 // Ensure that the user is logged in and has the read_blocks capability. |
31 // By default the read_post capability is mapped to edit_posts. |
32 $post_type = get_post_type_object( $post->post_type ); |
32 if ( ! current_user_can( 'read_post', $post->ID ) ) { |
33 if ( ! current_user_can( $post_type->cap->read_post, $post->ID ) ) { |
|
34 return false; |
33 return false; |
35 } |
34 } |
36 |
35 |
37 return parent::check_read_permission( $post ); |
36 return parent::check_read_permission( $post ); |
38 } |
37 } |
66 * @since 5.0.0 |
65 * @since 5.0.0 |
67 * |
66 * |
68 * @return array Item schema data. |
67 * @return array Item schema data. |
69 */ |
68 */ |
70 public function get_item_schema() { |
69 public function get_item_schema() { |
|
70 // Do not cache this schema because all properties are derived from parent controller. |
71 $schema = parent::get_item_schema(); |
71 $schema = parent::get_item_schema(); |
72 |
72 |
73 /* |
73 /* |
74 * Allow all contexts to access `title.raw` and `content.raw`. Clients always |
74 * Allow all contexts to access `title.raw` and `content.raw`. Clients always |
75 * need the raw markup of a reusable block to do anything useful, e.g. parse |
75 * need the raw markup of a reusable block to do anything useful, e.g. parse |