PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 2.2.2
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v2.2.2
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | includes/API/Items.php +6 -68 3.0.32.2.2 View file →
@@ -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, 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
@@ -290,56 +284,8 @@
290 284
291 285 return $_response;
292 286 }
293 287
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 - }
341 -
342 288 public function get_counts(){
343 289 $defaults = Database::get_transient( 'counts' );
344 290 if( $defaults ) {
345 291 return $defaults;
@@ -431,27 +377,19 @@
431 377 }
432 378
433 379 /**
434 380 * Get Featured Item List
435 - * @param WP_REST_Request $request
436 381 * @return mixed
437 382 */
438 - public function featured_items(WP_REST_Request $request){
383 + public function featured_items(){
439 384 $defaults = Database::get_transient( 'featuredItems' );
440 385 if( $defaults ) {
441 386 return $defaults;
442 387 }
443 388
444 - $platform = $request->get_param( 'platform' );
445 - $funcArgs = [
446 - // 'page' => 1,
447 - // 'per_page' => 10,
448 - 'platform' => $platform,
449 - ];
450 389 $response = $this->http()->query(
451 390 'featuredItems',
452 - 'data{ id, name, slug, price, type, thumbnail }',
453 - $funcArgs
391 + 'data{ id, name, slug, price, type, thumbnail }'
454 392 )->post();
455 393
456 394 if( ! is_wp_error( $response ) ) {
457 395 Database::set_transient( 'featuredItems', $response );