PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.0-dev2
Elementor Website Builder – more than just a page builder v4.1.0-dev2
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / modules / atomic-widgets / styles / cache-validity / cache-validity.php

cache-validity.php in Elementor Website Builder – more than just a page builder 4.1.0-dev2, at modules/atomic-widgets/styles/cache-validity/cache-validity.php

81 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\AtomicWidgets\Styles\CacheValidity;
4
5 use Elementor\Modules\AtomicWidgets\Styles\CacheValidity\Cache_Validity_Item;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11
12 class Cache_Validity {
13 /**
14 * @param array<string> $keys
15 * @return bool
16 */
17 public function is_valid( $keys ): bool {
18 $root = array_shift( $keys );
19 $cache_item = new Cache_Validity_Item( $root );
20
21 $item = $cache_item->get( $keys );
22
23 if ( ! $item ) {
24 return false;
25 }
26
27 return $item['state'] ?? false;
28 }
29
30 /**
31 * @param array<string> $keys
32 * @return mixed | null
33 */
34 public function get_meta( array $keys ) {
35 $root = array_shift( $keys );
36 $cache_item = new Cache_Validity_Item( $root );
37
38 $item = $cache_item->get( $keys );
39
40 if ( ! $item || is_bool( $item ) ) {
41 return null;
42 }
43
44 return $item['meta'] ?? null;
45 }
46
47 /**
48 * @param array<string> $keys
49 * @param mixed | null $meta
50 * @return void
51 */
52 public function validate( $keys, $meta = null ): void {
53 $root = array_shift( $keys );
54 $cache_item = new Cache_Validity_Item( $root );
55
56 $cache_item->validate( $keys, $meta );
57 }
58
59 /**
60 * @param array<string> $keys
61 * @return void
62 */
63 public function invalidate( array $keys ): void {
64 $root = array_shift( $keys );
65 $cache_item = new Cache_Validity_Item( $root );
66
67 $cache_item->invalidate( $keys );
68 }
69
70 /**
71 * @param array<string> $keys
72 * @return array{state: boolean, meta: array<string, mixed> | null, children: array<string, self>} | null
73 */
74 public function get_node( array $keys ): ?array {
75 $root = array_shift( $keys );
76 $cache_item = new Cache_Validity_Item( $root );
77
78 return $cache_item->get( $keys );
79 }
80 }
81