PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.7.2
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.7.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/Categories.php +13 -10 3.0.53.7.2 View file →
@@ -16,16 +16,8 @@
16 16 $this->get( $this->endpoint, [ $this, 'get_categories' ] );
17 17 }
18 18
19 19 public function get_categories() {
20 - /**
21 - * Return if there is any cache data.
22 - */
23 - $types = Database::get_transient( $this->endpoint );
24 - if( ! empty( $types ) ){
25 - return $this->success( $types );
26 - }
27 -
28 20 /** @noinspection SpellCheckingInspection */
29 21 $id = $this->get_param( 'id', 0, 'intval' );
30 22 $funcArgs = [];
31 23
@@ -32,15 +24,26 @@
32 24 if ( $id > 0 ) {
33 25 $funcArgs['id'] = $id;
34 26 }
35 27
36 - $response = $this->http()->query( $this->endpoint, 'id, name, slug, status', $funcArgs )->post();
28 + $fields = 'id, name, slug, status, packs_count';
29 + $transient_key = $this->endpoint . '_' . md5( $fields . json_encode( $funcArgs ) );
30 +
37 31 /**
32 + * Return if there is any cache data.
33 + */
34 + $types = Database::get_transient( $transient_key );
35 + if( ! empty( $types ) ){
36 + return $this->success( $types );
37 + }
38 +
39 + $response = $this->http()->query( $this->endpoint, $fields, $funcArgs )->post();
40 + /**
38 41 * Caching the response in transient.
39 42 */
40 43 if( ! is_wp_error( $response ) ) {
41 - Database::set_transient( $this->endpoint, $response );
44 + Database::set_transient( $transient_key, $response );
42 45 }
43 46
44 47 return $response;
45 48 }
46 49 }