PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.4.9
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.4.9
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 +13 -49 3.6.23.4.9 View file →
@@ -35,15 +35,8 @@
35 35 'per_page' => [
36 36 'default' => 40,
37 37 'required' => false
38 38 ],
39 - 'sort_by' => [
40 - 'default' => 'latest',
41 - 'required' => false,
42 - 'validate_callback' => function( $param, $request, $key ){
43 - return empty( $param ) || in_array( $param, [ 'latest', 'rating', 'download' ], true );
44 - }
45 - ],
46 39 ] );
47 40
48 41 // only number
49 42 $this->get( 'items/(?P<id>[0-9]+)', [ $this, 'get_item_by_id' ], [
@@ -105,10 +98,9 @@
105 98 $include_search = $this->get_param( 'include_search' );
106 99 $page = $this->get_param( 'page', 1, 'intval' );
107 100 $per_page = $this->get_param( 'per_page', 40, 'intval' );
108 101 $template_type_id = $this->get_param( 'template_type_id', 0, 'intval' );
109 - $categories_raw = $this->get_param( 'categories' );
110 - $sort_by = $this->get_param( 'sort_by', 'latest' );
102 + $category_id = $this->get_param( 'category_id', 0, 'intval' );
111 103
112 104 $dependencies = $request->get_param( 'dependencies' );
113 105 $tags = $request->get_param( 'tags' );
114 106
@@ -115,9 +107,8 @@
115 107 $funcArgs = [
116 108 'page' => $page,
117 109 'per_page' => $per_page,
118 110 'platform' => $platform,
119 - 'sort_by' => $sort_by,
120 111 ];
121 112
122 113 if ( $plan_type > 1 ) {
123 114 $funcArgs['plan_type'] = $plan_type;
@@ -122,13 +113,10 @@
122 113 if ( $plan_type > 1 ) {
123 114 $funcArgs['plan_type'] = $plan_type;
124 115 }
125 116
126 - if ( ! empty( $categories_raw ) ) {
127 - $decoded = json_decode( $categories_raw, true );
128 - if ( is_array( $decoded ) && ! empty( $decoded ) ) {
129 - $funcArgs['categories'] = wp_slash( json_encode( array_values( array_filter( array_map( 'intval', $decoded ) ) ) ) );
130 - }
117 + if ( $category_id ) {
118 + $funcArgs['category_id'] = $category_id;
131 119 }
132 120 if ( $template_type_id > 0 ) {
133 121 $funcArgs['template_type_id'] = $template_type_id;
134 122 }
@@ -146,11 +134,11 @@
146 134 if ( ! empty( $include_search ) ) {
147 135 $funcArgs['include_search'] = $include_search;
148 136 }
149 137
150 - $query = 'total_page, current_page, data { id, fullsite_import, name, price, rating, downloads, type, template_type{ slug }, slug, favourite_count, thumbnail, thumbnail2, thumbnail3, badges }';
138 + $query = 'total_page, current_page, data { id, fullsite_import, name, price, rating, downloads, type, template_type{ slug }, slug, favourite_count, thumbnail, thumbnail2, thumbnail3 }';
151 139 if( $type !== 'packs' ) {
152 - $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, pack { id, has_settings }, badges }';
140 + $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 }';
153 141 }
154 142
155 143 if( $type === false ) {
156 144 return $this->error( 'invalid_type_call', __( 'Invalid Type Call', 'templately' ) );
@@ -155,24 +143,13 @@
155 143 if( $type === false ) {
156 144 return $this->error( 'invalid_type_call', __( 'Invalid Type Call', 'templately' ) );
157 145 }
158 146
159 - $transient_key = "_templately_items_" . md5(json_encode([$type, $query, $funcArgs]));
160 - $response = false;
161 -
162 - if ( defined( 'TEMPLATELY_ITEMS_TRANSIENT' ) && constant( 'TEMPLATELY_ITEMS_TRANSIENT' ) ) {
163 - $response = Database::get_transient( $transient_key );
164 - }
165 -
166 - if ( empty( $response ) ) {
167 - $response = $this->http()->query( $type, $query, $funcArgs )->post();
168 -
169 - if ( ! empty( $response ) && ! is_wp_error( $response ) && defined( 'TEMPLATELY_ITEMS_TRANSIENT' ) && constant( 'TEMPLATELY_ITEMS_TRANSIENT' ) ) {
170 - Database::set_transient( $transient_key, $response );
171 - }
172 - }
173 -
174 - return $response;
147 + return $this->http()->query(
148 + $type,
149 + $query,
150 + $funcArgs
151 + )->post();
175 152 }
176 153
177 154 public function get_item() {
178 155 $slug = $this->get_param( 'slug' );
@@ -191,9 +168,9 @@
191 168 if( $type === false ) {
192 169 return $this->error( 'invalid_type_call', __( 'Invalid Type Call', 'templately' ) );
193 170 }
194 171
195 - $items_params = 'id, name, rating, type, description, slug, price, features, favourite_count, is_favourite, is_reviewed, 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, published_at, updated_at, is_trending, badges, pack{ id, name, slug, items{ id, price, name, type, slug, thumbnail, badges }, has_settings }, live_url, template_type{ id, name, slug }';
172 + $items_params = 'id, name, rating, type, description, slug, price, features, favourite_count, is_favourite, is_reviewed, 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, published_at, updated_at, is_trending, badges, pack{ id, name, slug, items{ id, price, name, type, slug, thumbnail } }, live_url, template_type{ id, name, slug }';
196 173 $params = 'data { ' . $items_params . ', variations { name, slug, type, platform } }';
197 174
198 175 if ( $type == 'packs' ) {
199 176 $params = 'data { id, fullsite_import, ai_compatible, has_settings, has_attachments, name, rating, type, slug, live_url, price, features, favourite_count, is_favourite, is_reviewed, thumbnail, description, tags{ name, id }, banner, published_at, updated_at, is_trending, badges, template_type{ id, name, slug } downloads, categories{ id, name, slug }, items { ' . $items_params . ' }, variations { name, slug, type, platform } }';
@@ -205,23 +182,10 @@
205 182 if (!empty($this->api_key)) {
206 183 $args['api_key'] = $this->api_key;
207 184 }
208 185
209 - $transient_key = "_templately_items_" . md5(json_encode([$type, $params, $args]));
210 - $response = false;
186 + $response = $this->http()->query( $type, $params, $args )->post();
211 187
212 - if ( defined( 'TEMPLATELY_ITEMS_TRANSIENT' ) && constant( 'TEMPLATELY_ITEMS_TRANSIENT' ) ) {
213 - $response = Database::get_transient( $transient_key );
214 - }
215 -
216 - if ( empty( $response ) ) {
217 - $response = $this->http()->query( $type, $params, $args )->post();
218 -
219 - if ( ! empty( $response ) && ! is_wp_error( $response ) && defined( 'TEMPLATELY_ITEMS_TRANSIENT' ) && constant( 'TEMPLATELY_ITEMS_TRANSIENT' ) ) {
220 - Database::set_transient( $transient_key, $response );
221 - }
222 - }
223 -
224 188 if ( is_wp_error( $response ) ) {
225 189 return $response;
226 190 }
227 191
@@ -254,9 +218,9 @@
254 218 if( $type === false ) {
255 219 return $this->error( 'invalid_type_call', __( 'Invalid Type Call', 'templately' ) );
256 220 }
257 221
258 - $items_params = 'id, name, rating, type, description, slug, price, features, favourite_count, is_favourite, is_reviewed, 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, published_at, updated_at, is_trending, badges, pack{ id, name, slug, items{ id, price, name, type, slug, thumbnail, badges }, has_settings }, live_url, template_type{ id, name, slug }';
222 + $items_params = 'id, name, rating, type, description, slug, price, features, favourite_count, is_favourite, is_reviewed, 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, published_at, updated_at, is_trending, badges, pack{ id, name, slug, items{ id, price, name, type, slug, thumbnail } }, live_url, template_type{ id, name, slug }';
259 223 $params = 'data { ' . $items_params . ', variations { name, slug, type, platform } }';
260 224
261 225 if ( $type == 'packs' ) {
262 226 $params = 'data { id, fullsite_import, ai_compatible, has_settings, has_attachments, name, rating, type, slug, live_url, price, features, favourite_count, is_favourite, is_reviewed, thumbnail, description, tags{ name, id }, banner, published_at, updated_at, is_trending, badges, template_type{ id, name, slug } downloads, categories{ id, name, slug }, items { ' . $items_params . ' }, variations { name, slug, type, platform } }';