| @@ -124,30 +124,12 @@ | ||
| 124 | 124 | * @param $request WP_REST_Request for getting all route request in time. |
| 125 | 125 | * |
| 126 | 126 | * @return WP_Error|boolean |
| 127 | 127 | */ |
| 128 | - public function _permission_check( WP_REST_Request $request ) { | |
| 129 | - $this->request = $request; | |
| 130 | - $this->api_key = $this->utils('options')->get( 'api_key' ); | |
| 131 | - if(!current_user_can('delete_posts')){ | |
| 132 | - return false; | |
| 133 | - } | |
| 134 | - | |
| 135 | - add_filter('wp_redirect', '__return_false', 999); | |
| 136 | - | |
| 137 | - return $this->permission_check( $request ); | |
| 138 | - } | |
| 139 | - | |
| 140 | - /** | |
| 141 | - * @param $request WP_REST_Request for getting all route request in time. | |
| 142 | - * | |
| 143 | - * @return WP_Error|boolean | |
| 144 | - */ | |
| 145 | 128 | public function permission_check( WP_REST_Request $request ) { |
| 146 | 129 | $this->request = $request; |
| 147 | 130 | $this->api_key = $this->utils('options')->get( 'api_key' ); |
| 148 | 131 | |
| 149 | - | |
| 150 | 132 | if ( ! empty( $this->api_key ) ) { |
| 151 | 133 | return true; |
| 152 | 134 | } |
| 153 | 135 | |
| @@ -177,13 +159,12 @@ | ||
| 177 | 159 | // Delete user logged meta data |
| 178 | 160 | $this->utils('options') |
| 179 | 161 | ->remove('user') |
| 180 | 162 | ->remove('favourites') |
| 181 | - ->remove('reviews') | |
| 182 | 163 | ->remove('cloud_activity') |
| 183 | 164 | ->remove('api_key'); |
| 184 | 165 | |
| 185 | - if( $this->utils('options')->who_am_i() === 'global' ) { | |
| 166 | + if( $this->utils('options')->whoami() === 'global' ) { | |
| 186 | 167 | $this->utils('options')->remove_global_login(); |
| 187 | 168 | } |
| 188 | 169 | |
| 189 | 170 | return new WP_Error( 'invalid_api_key', $message, $_additional_data ); |
| @@ -202,9 +183,9 @@ | ||
| 202 | 183 | $endpoint, |
| 203 | 184 | [ |
| 204 | 185 | 'methods' => $methods, |
| 205 | 186 | 'callback' => $callback, |
| 206 | - 'permission_callback' => [ $this, '_permission_check' ], | |
| 187 | + 'permission_callback' => [ $this, 'permission_check' ], | |
| 207 | 188 | 'args' => $args, |
| 208 | 189 | ] |
| 209 | 190 | ); |
| 210 | 191 | } |
| @@ -229,24 +210,8 @@ | ||
| 229 | 210 | * @return WP_REST_Response |
| 230 | 211 | */ |
| 231 | 212 | public function success( $data ) { |
| 232 | 213 | return new WP_REST_Response( $data, 200 ); |
| 233 | - } | |
| 234 | - | |
| 235 | - /** | |
| 236 | - * Enhanced success response wrapper that automatically adds success flag and wraps data | |
| 237 | - * | |
| 238 | - * @param $data mixed The data to be wrapped in the response | |
| 239 | - * | |
| 240 | - * @return WP_REST_Response | |
| 241 | - */ | |
| 242 | - public function successWithData( $data ) { | |
| 243 | - $enhanced_response = [ | |
| 244 | - 'success' => true, | |
| 245 | - 'data' => $data | |
| 246 | - ]; | |
| 247 | - | |
| 248 | - return $this->success( $enhanced_response ); | |
| 249 | 214 | } |
| 250 | 215 | /** |
| 251 | 216 | * @param $error_code string |
| 252 | 217 | * @param $error_message string|array |