CoreFiles by mySites.guru
class-wp-rest-blocks-controller.php39 lines, 976 bytes, from wordpress-5.0-beta4.zip
Raw History Compare with 5.0-beta3
md5
c1f363b60248f2f2ad1675b9fd0147b3
sha1
6a951f20b6ca096f14df2092a6c357970852fdac
sha256
6c2be99469d75d99289ce7d2c70fd20768e01c8f3566e7b10684f71442ec122e
<?php
/**
 * Reusable blocks REST API: WP_REST_Blocks_Controller class
 *
 * @package WordPress
 * @subpackage REST_API
 * @since 5.0.0
 */

/**
 * Controller which provides a REST endpoint for the editor to read, create,
 * edit and delete reusable blocks. Blocks are stored as posts with the wp_block
 * post type.
 *
 * @since 5.0.0
 *
 * @see WP_REST_Posts_Controller
 * @see WP_REST_Controller
 */
class WP_REST_Blocks_Controller extends WP_REST_Posts_Controller {

	/**
	 * Checks if a block can be read.
	 *
	 * @since 5.0.0
	 *
	 * @param object $post Post object that backs the block.
	 * @return bool Whether the block can be read.
	 */
	public function check_read_permission( $post ) {
		// Ensure that the user is logged in and has the read_blocks capability.
		$post_type = get_post_type_object( $post->post_type );
		if ( ! current_user_can( $post_type->cap->read_post, $post->ID ) ) {
			return false;
		}

		return parent::check_read_permission( $post );
	}
}

The same content is in 5 releases, WordPress 5.0-beta1 to 5.0-beta5. See them all, or every version of this file.