Plugin Directory


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • nextgen-gallery/trunk/src/REST/Admin/Block.php

    r3003333 r3063940  
    11<?php
     2/**
     3 * REST API for the NextGEN Gallery Block
     4 *
     5 * @package NextGEN Gallery
     6 */
    27
    38namespace Imagely\NGG\REST\Admin;
     
    611use Imagely\NGG\DataStorage\Manager as StorageManager;
    712
     13/**
     14 * Class Block represents the REST API for the NextGEN Gallery Block
     15 */
    816class Block extends \WP_REST_Controller {
    917
     18    /**
     19     * Block constructor.
     20     */
    1021    public function __construct() {
    1122        $this->namespace = 'ngg/v1';
     
    1324    }
    1425
     26    /**
     27     * Register the routes for the objects of the controller.
     28     */
    1529    public function register_routes() {
    1630        \register_rest_route(
     
    2842                    'methods'             => \WP_REST_Server::READABLE,
    2943                    'callback'            => [ $this, 'get_item' ],
    30                     'permission_callback' => '__return_true',
     44                    'permission_callback' => [ $this, 'get_item_permissions_check' ],
    3145                ],
    3246            ]
     
    3549
    3650    /**
    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.
    3865     * @return \WP_Error|\WP_REST_Response
    3966     */
Note: See TracChangeset for help on using the changeset viewer.