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