| @@ -11,9 +11,9 @@ | ||
| 11 | 11 | public function permission_check( WP_REST_Request $request ) { |
| 12 | 12 | $this->request = $request; |
| 13 | 13 | |
| 14 | 14 | $_route = $request->get_route(); |
| 15 | - if( $_route === '/templately/v1/items/favourite' || $_route === '/templately/v1/items/rating' ) { | |
| 15 | + if( $_route === '/templately/v1/items/favourite' ) { | |
| 16 | 16 | return parent::permission_check( $request ); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | return true; |
| @@ -59,9 +59,8 @@ | ||
| 59 | 59 | ], |
| 60 | 60 | ] ); |
| 61 | 61 | |
| 62 | 62 | $this->post( 'items/favourite', [ $this, 'set_favourite' ] ); |
| 63 | - $this->post( 'items/rating', [ $this, 'set_rating' ] ); | |
| 64 | 63 | $this->get( 'items-count', [ $this, 'get_counts' ] ); |
| 65 | 64 | $this->get( 'featured-items', [ $this, 'featured_items' ] ); |
| 66 | 65 | } |
| 67 | 66 | |
| @@ -81,9 +80,8 @@ | ||
| 81 | 80 | $plan = $this->get_param( 'plan', 'all' ); |
| 82 | 81 | $plan_type = $this->get_plan( $plan ); |
| 83 | 82 | $platform = $this->get_param( 'platform', 'elementor' ); |
| 84 | 83 | $search = $this->get_param( 'search' ); |
| 85 | - $include_search = $this->get_param( 'include_search' ); | |
| 86 | 84 | $page = $this->get_param( 'page', 1, 'intval' ); |
| 87 | 85 | $per_page = $this->get_param( 'per_page', 40, 'intval' ); |
| 88 | 86 | $template_type_id = $this->get_param( 'template_type_id', 0, 'intval' ); |
| 89 | 87 | $category_id = $this->get_param( 'category_id', 0, 'intval' ); |
| @@ -117,13 +115,9 @@ | ||
| 117 | 115 | if ( ! empty( $search ) ) { |
| 118 | 116 | $funcArgs['search'] = $search; |
| 119 | 117 | } |
| 120 | 118 | |
| 121 | - if ( ! empty( $include_search ) ) { | |
| 122 | - $funcArgs['include_search'] = $include_search; | |
| 123 | - } | |
| 124 | - | |
| 125 | - $query = 'total_page, current_page, data { id, fullsite_import, name, price, rating, downloads, type, template_type{ slug }, slug, favourite_count, thumbnail, thumbnail2, thumbnail3 }'; | |
| 119 | + $query = 'total_page, current_page, data { id, name, price, rating, downloads, type, template_type{ slug }, slug, favourite_count, thumbnail, thumbnail2, thumbnail3 }'; | |
| 126 | 120 | if( $type !== 'packs' ) { |
| 127 | 121 | $query = 'total_page, current_page, data { id, name, price, rating, downloads, type, template_type{ slug }, slug, favourite_count, dependencies{ id, name, icon, plugin_file, plugin_original_slug, is_pro, link }, thumbnail }'; |
| 128 | 122 | } |
| 129 | 123 | |
| @@ -156,12 +150,12 @@ | ||
| 156 | 150 | return $this->error( 'invalid_type_call', __( 'Invalid Type Call', 'templately' ) ); |
| 157 | 151 | } |
| 158 | 152 | |
| 159 | 153 | $items_params = 'id, name, rating, type, description, slug, price, features, favourite_count, thumbnail, downloads, categories{ id, name, slug }, dependencies{ id, name, icon, plugin_file, plugin_original_slug, is_pro, link }, tags{ name, id }, categories{ name, id }, screenshots{ url }, banner, pack{ id, name, slug, items{ id, price, name, type, slug, thumbnail } }, live_url, template_type{ id, name, slug }'; |
| 160 | - $params = 'data { ' . $items_params . ', variations { name, slug, type, platform } }'; | |
| 154 | + $params = 'data { ' . $items_params . ' }'; | |
| 161 | 155 | |
| 162 | 156 | if ( $type == 'packs' ) { |
| 163 | - $params = 'data { id, fullsite_import, has_settings, name, rating, type, slug, live_url, price, features, favourite_count, thumbnail, downloads, categories{ id, name, slug }, items { ' . $items_params . ' }, variations { name, slug, type, platform } }'; | |
| 157 | + $params = 'data { id, name, rating, type, slug, live_url, price, features, favourite_count, thumbnail, downloads, categories{ id, name, slug }, items { ' . $items_params . ' } }'; | |
| 164 | 158 | } |
| 165 | 159 | |
| 166 | 160 | $response = $this->http()->query( $type, $params, [ 'slug' => $slug ] )->post(); |
| 167 | 161 | |
| @@ -288,56 +282,8 @@ | ||
| 288 | 282 | } |
| 289 | 283 | } |
| 290 | 284 | |
| 291 | 285 | return $_response; |
| 292 | - } | |
| 293 | - | |
| 294 | - public function set_rating(){ | |
| 295 | - $type_id = $this->get_param( 'type_id', 0, 'intval' ); | |
| 296 | - $itemType = $this->get_param( 'itemType', 'pack' ); | |
| 297 | - $rating = $this->get_param( 'rating', 5, 'intval' ); | |
| 298 | - | |
| 299 | - $query = 'status, message, data'; | |
| 300 | - | |
| 301 | - $funcArgs = [ | |
| 302 | - 'api_key' => $this->api_key, | |
| 303 | - 'type_id' => $type_id, | |
| 304 | - 'type' => $itemType, | |
| 305 | - 'rating' => $rating, | |
| 306 | - ]; | |
| 307 | - | |
| 308 | - $response = $this->http()->mutation( | |
| 309 | - 'review', | |
| 310 | - $query, | |
| 311 | - $funcArgs | |
| 312 | - )->post(); | |
| 313 | - | |
| 314 | - if( is_wp_error( $response ) ) { | |
| 315 | - return $response; | |
| 316 | - } | |
| 317 | - | |
| 318 | - if( empty( $response['data'] ) ) { | |
| 319 | - return $this->error( | |
| 320 | - 'invalid_response', | |
| 321 | - __('Something went wrong.', 'templately'), | |
| 322 | - '/items\/rating', | |
| 323 | - '404' | |
| 324 | - ); | |
| 325 | - } | |
| 326 | - | |
| 327 | - if( ! empty( $response['data'] ) && $response['status'] === 'success' ) { | |
| 328 | - $response['data'] = json_decode( $response['data'], true ); | |
| 329 | - | |
| 330 | - $_ratings = $this->utils('options')->get('reviews', []); | |
| 331 | - // $_reviews = $this->utils( 'helper' )->normalizeReviews( $response['user']['reviews'] ); | |
| 332 | - $_ratings[ $itemType ][ $type_id ] = $rating; | |
| 333 | - $this->utils('options')->set('reviews', $_ratings); | |
| 334 | - | |
| 335 | - $_ratings[ $itemType ][ "avg_$type_id" ] = (float) $response['data']['avg_rating']; | |
| 336 | - $response['data']['reviews'] = $_ratings; | |
| 337 | - } | |
| 338 | - | |
| 339 | - return $response; | |
| 340 | 286 | } |
| 341 | 287 | |
| 342 | 288 | public function get_counts(){ |
| 343 | 289 | $defaults = Database::get_transient( 'counts' ); |