HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: /volume1/web/wordpress/wp-content/plugins/instant-images/api/test.php
<?php

/*
*  rest_api_init
*  Custom /resize route
*
*  @since 3.0
*/

add_action( 'rest_api_init', function () {
   $my_namespace = 'instant-images';
   $my_endpoint = '/test';
   register_rest_route( $my_namespace, $my_endpoint, 
      array(
         'methods' => 'GET',
         'callback' => 'instant_images_test',
      )
   );
});



/*
*  test
*  Test REST API access
*
*  @param $request      $_POST
*  @return $response    json
*  @since 3.2

*/

function instant_images_test( WP_REST_Request $request ) {
   
   if (is_user_logged_in() && current_user_can( apply_filters('instant_images_user_role', 'edit_theme_options') )){
   
      error_reporting(E_ALL|E_STRICT);		          
      
      // Access is enable, send the response
      $response = array(
         'success' => true
      );   
      
      // Send response as JSON
      wp_send_json($response);
   
   }
}