PluginProbe
Elementor Website Builder – more than just a page builder / 3.8.0
Elementor Website Builder – more than just a page builder v3.8.0
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 / core / schemes / base.php

base.php in Elementor Website Builder – more than just a page builder 3.8.0, at core/schemes/base.php

125 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Schemes;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 /**
9 * Elementor scheme base.
10 *
11 * An abstract class implementing the scheme interface, responsible for
12 * creating new schemes.
13 *
14 * @since 1.0.0
15 * @abstract
16 */
17 abstract class Base {
18
19 /**
20 * DB option name for the time when the scheme was last updated.
21 */
22 const LAST_UPDATED_META = '_elementor_scheme_last_updated';
23
24 const SCHEME_OPTION_PREFIX = 'elementor_scheme_';
25
26 /**
27 * Get scheme type.
28 *
29 * Retrieve the scheme type.
30 *
31 * @since 2.8.0
32 * @access public
33 * @static
34 */
35 public static function get_type() {
36 return '';
37 }
38
39 /**
40 * Get default scheme.
41 *
42 * Retrieve the default scheme.
43 *
44 * @since 2.8.0
45 * @access public
46 */
47 abstract public function get_default_scheme();
48
49 /**
50 * Get description.
51 *
52 * Retrieve the scheme description.
53 *
54 * @since 1.0.0
55 * @access public
56 * @static
57 *
58 * @return string Scheme description.
59 */
60 public static function get_description() {
61 return '';
62 }
63
64 /**
65 * Get scheme value.
66 *
67 * Retrieve the scheme value.
68 *
69 * @since 1.0.0
70 * @access public
71 *
72 * @return array Scheme value.
73 */
74 public function get_scheme_value() {
75 $scheme_value = get_option( self::SCHEME_OPTION_PREFIX . static::get_type() );
76
77 if ( ! $scheme_value ) {
78 $scheme_value = $this->get_default_scheme();
79
80 update_option( self::SCHEME_OPTION_PREFIX . static::get_type(), $scheme_value );
81 }
82
83 return $scheme_value;
84 }
85
86 /**
87 * Save scheme.
88 *
89 * Update Elementor scheme in the database, and update the last updated
90 * scheme time.
91 *
92 * @since 1.0.0
93 * @access public
94 *
95 * @param array $posted
96 */
97 public function save_scheme( array $posted ) {
98 update_option( self::SCHEME_OPTION_PREFIX . static::get_type(), $posted );
99
100 update_option( self::LAST_UPDATED_META, time() );
101 }
102
103 /**
104 * Get scheme.
105 *
106 * Retrieve the scheme.
107 *
108 * @since 1.0.0
109 * @access public
110 *
111 * @return array The scheme.
112 */
113 public function get_scheme() {
114 $scheme = [];
115
116 foreach ( $this->get_scheme_value() as $scheme_key => $scheme_value ) {
117 $scheme[ $scheme_key ] = [
118 'value' => $scheme_value,
119 ];
120 }
121
122 return $scheme;
123 }
124 }
125