| @@ -19,29 +19,27 @@ | ||
| 19 | 19 | |
| 20 | 20 | add_action( 'rest_api_init', array( $this, 'rest_api_init' ) ); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | + | |
| 23 | 24 | function rest_api_init() { |
| 24 | - if ( !current_user_can( 'upload_files' ) ) { | |
| 25 | - return; | |
| 26 | - } | |
| 27 | 25 | |
| 28 | - // SETTINGS | |
| 26 | + // Settings | |
| 29 | 27 | register_rest_route( $this->namespace, '/update_option/', array( |
| 30 | 28 | 'methods' => 'POST', |
| 31 | - 'permission_callback' => '__return_true', | |
| 29 | + 'permission_callback' => array( $this->core, 'can_access_settings' ), | |
| 32 | 30 | 'callback' => array( $this, 'rest_update_option' ) |
| 33 | 31 | ) ); |
| 34 | 32 | register_rest_route( $this->namespace, '/all_settings/', array( |
| 35 | 33 | 'methods' => 'GET', |
| 36 | - 'permission_callback' => '__return_true', | |
| 34 | + 'permission_callback' => array( $this->core, 'can_access_settings' ), | |
| 37 | 35 | 'callback' => array( $this, 'rest_all_settings' ) |
| 38 | 36 | ) ); |
| 39 | 37 | |
| 40 | - // BLOCK | |
| 38 | + // Gutenberg Block | |
| 41 | 39 | register_rest_route( $this->namespace, '/preview', array( |
| 42 | 40 | 'methods' => 'POST', |
| 43 | - 'permission_callback' => '__return_true', | |
| 41 | + 'permission_callback' => array( $this->core, 'can_access_features' ), | |
| 44 | 42 | 'callback' => array( $this, 'preview' ), |
| 45 | 43 | ) ); |
| 46 | 44 | } |
| 47 | 45 | |
| @@ -49,9 +47,10 @@ | ||
| 49 | 47 | $params = $request->get_body(); |
| 50 | 48 | $params = json_decode( $params ); |
| 51 | 49 | $params->ids = implode( ',', $params->ids ); |
| 52 | 50 | $atts = (array) $params; |
| 53 | - return $this->core->gallery( $atts, true ); | |
| 51 | + $html = $this->core->gallery( $atts, true ); | |
| 52 | + return new WP_REST_Response( [ 'success' => true, 'data' => $html ], 200 ); | |
| 54 | 53 | } |
| 55 | 54 | |
| 56 | 55 | function rest_all_settings() { |
| 57 | 56 | return new WP_REST_Response( [ 'success' => true, 'data' => $this->get_all_options() ], 200 ); |