PluginProbe
Elementor Website Builder – more than just a page builder / 3.34.1
Elementor Website Builder – more than just a page builder v3.34.1
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 / variables / storage / variables-repository.php

variables-repository.php in Elementor Website Builder – more than just a page builder 3.34.1, at modules/variables/storage/variables-repository.php

43 lines 1006 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\Variables\Storage;
4
5 use Elementor\Core\Kits\Documents\Kit;
6 use Elementor\Modules\Variables\Adapters\Prop_Type_Adapter;
7
8 class Variables_Repository {
9 private const VARIABLES_META_KEY = '_elementor_global_variables';
10
11 private Kit $kit;
12
13 public function __construct( Kit $kit ) {
14 $this->kit = $kit;
15 }
16
17 public function load(): Variables_Collection {
18 $db_record = $this->kit->get_json_meta( self::VARIABLES_META_KEY );
19
20 if ( is_array( $db_record ) && ! empty( $db_record ) ) {
21 $collection = Variables_Collection::hydrate( $db_record );
22
23 Prop_Type_Adapter::from_storage( $collection );
24
25 return $collection;
26 }
27
28 return Variables_Collection::default();
29 }
30
31 public function save( Variables_Collection $collection ) {
32 $collection->increment_watermark();
33
34 $record = Prop_Type_Adapter::to_storage( $collection );
35
36 if ( $this->kit->update_json_meta( static::VARIABLES_META_KEY, $record ) ) {
37 return $collection->watermark();
38 }
39
40 return false;
41 }
42 }
43