PluginProbe
Gutenberg / 4.1.0
Gutenberg v4.1.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / class-wp-rest-blocks-controller.php

class-wp-rest-blocks-controller.php in Gutenberg 4.1.0, at lib/class-wp-rest-blocks-controller.php

37 lines 919 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Reusable blocks REST API: WP_REST_Blocks_Controller class
4 *
5 * @package gutenberg
6 * @since 0.10.0
7 */
8
9 /**
10 * Controller which provides a REST endpoint for Gutenberg to read, create,
11 * edit and delete reusable blocks. Blocks are stored as posts with the wp_block
12 * post type.
13 *
14 * @since 0.10.0
15 *
16 * @see WP_REST_Controller
17 */
18 class WP_REST_Blocks_Controller extends WP_REST_Posts_Controller {
19 /**
20 * Checks if a block can be read.
21 *
22 * @since 2.1.0
23 *
24 * @param object $post Post object that backs the block.
25 * @return bool Whether the block can be read.
26 */
27 public function check_read_permission( $post ) {
28 // Ensure that the user is logged in and has the read_blocks capability.
29 $post_type = get_post_type_object( $post->post_type );
30 if ( ! current_user_can( $post_type->cap->read_post, $post->ID ) ) {
31 return false;
32 }
33
34 return parent::check_read_permission( $post );
35 }
36 }
37