- File:
-
- 1 edited
-
nextgen-gallery/trunk/src/REST/Admin/Block.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nextgen-gallery/trunk/src/REST/Admin/Block.php
r3003333 r3063940 1 1 <?php 2 /** 3 * REST API for the NextGEN Gallery Block 4 * 5 * @package NextGEN Gallery 6 */ 2 7 3 8 namespace Imagely\NGG\REST\Admin; … … 6 11 use Imagely\NGG\DataStorage\Manager as StorageManager; 7 12 13 /** 14 * Class Block represents the REST API for the NextGEN Gallery Block 15 */ 8 16 class Block extends \WP_REST_Controller { 9 17 18 /** 19 * Block constructor. 20 */ 10 21 public function __construct() { 11 22 $this->namespace = 'ngg/v1'; … … 13 24 } 14 25 26 /** 27 * Register the routes for the objects of the controller. 28 */ 15 29 public function register_routes() { 16 30 \register_rest_route( … … 28 42 'methods' => \WP_REST_Server::READABLE, 29 43 'callback' => [ $this, 'get_item' ], 30 'permission_callback' => '__return_true',44 'permission_callback' => [ $this, 'get_item_permissions_check' ], 31 45 ], 32 46 ] … … 35 49 36 50 /** 37 * @param \WP_REST_Request $request 51 * Check if a given request has access to get information about a specific item. 52 * 53 * @param \WP_REST_Request $request Full data about the request. 54 * 55 * @return bool 56 */ 57 public function get_item_permissions_check( $request ): bool { 58 global $post; 59 return current_user_can( 'edit_post', $post->ID ); 60 } 61 62 /** Get the specific image. 63 * 64 * @param \WP_REST_Request $request Full data about the request. 38 65 * @return \WP_Error|\WP_REST_Response 39 66 */
Note: See TracChangeset
for help on using the changeset viewer.