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

123 lines 2.1 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 /**
25 * Get scheme type.
26 *
27 * Retrieve the scheme type.
28 *
29 * @since 2.8.0
30 * @access public
31 * @static
32 */
33 public static function get_type() {
34 return '';
35 }
36
37 /**
38 * Get default scheme.
39 *
40 * Retrieve the default scheme.
41 *
42 * @since 2.8.0
43 * @access public
44 */
45 abstract public function get_default_scheme();
46
47 /**
48 * Get description.
49 *
50 * Retrieve the scheme description.
51 *
52 * @since 1.0.0
53 * @access public
54 * @static
55 *
56 * @return string Scheme description.
57 */
58 public static function get_description() {
59 return '';
60 }
61
62 /**
63 * Get scheme value.
64 *
65 * Retrieve the scheme value.
66 *
67 * @since 1.0.0
68 * @access public
69 *
70 * @return array Scheme value.
71 */
72 public function get_scheme_value() {
73 $scheme_value = get_option( 'elementor_scheme_' . static::get_type() );
74
75 if ( ! $scheme_value ) {
76 $scheme_value = $this->get_default_scheme();
77
78 update_option( 'elementor_scheme_' . static::get_type(), $scheme_value );
79 }
80
81 return $scheme_value;
82 }
83
84 /**
85 * Save scheme.
86 *
87 * Update Elementor scheme in the database, and update the last updated
88 * scheme time.
89 *
90 * @since 1.0.0
91 * @access public
92 *
93 * @param array $posted
94 */
95 public function save_scheme( array $posted ) {
96 update_option( 'elementor_scheme_' . static::get_type(), $posted );
97
98 update_option( self::LAST_UPDATED_META, time() );
99 }
100
101 /**
102 * Get scheme.
103 *
104 * Retrieve the scheme.
105 *
106 * @since 1.0.0
107 * @access public
108 *
109 * @return array The scheme.
110 */
111 public function get_scheme() {
112 $scheme = [];
113
114 foreach ( $this->get_scheme_value() as $scheme_key => $scheme_value ) {
115 $scheme[ $scheme_key ] = [
116 'value' => $scheme_value,
117 ];
118 }
119
120 return $scheme;
121 }
122 }
123