PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.8
Elementor Website Builder – more than just a page builder v3.0.8
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 / includes / base / skin-base.php

skin-base.php in Elementor Website Builder – more than just a page builder 3.0.8, at includes/base/skin-base.php

250 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 /**
9 * Elementor skin base.
10 *
11 * An abstract class to register new skins for Elementor widgets. Skins allows
12 * you to add new templates, set custom controls and more.
13 *
14 * To register new skins for your widget use the `add_skin()` method inside the
15 * widget's `_register_skins()` method.
16 *
17 * @since 1.0.0
18 * @abstract
19 */
20 abstract class Skin_Base extends Sub_Controls_Stack {
21
22 /**
23 * Parent widget.
24 *
25 * Holds the parent widget of the skin. Default value is null, no parent widget.
26 *
27 * @access protected
28 *
29 * @var Widget_Base|null
30 */
31 protected $parent = null;
32
33 /**
34 * Skin base constructor.
35 *
36 * Initializing the skin base class by setting parent widget and registering
37 * controls actions.
38 *
39 * @since 1.0.0
40 * @access public
41 * @param Widget_Base $parent
42 */
43 public function __construct( Widget_Base $parent ) {
44 parent::__construct( $parent );
45
46 $this->_register_controls_actions();
47 }
48
49 /**
50 * Render skin.
51 *
52 * Generates the final HTML on the frontend.
53 *
54 * @since 1.0.0
55 * @access public
56 * @abstract
57 */
58 abstract public function render();
59
60 /**
61 * Register skin controls actions.
62 *
63 * Run on init and used to register new skins to be injected to the widget.
64 * This method is used to register new actions that specify the location of
65 * the skin in the widget.
66 *
67 * Example usage:
68 * `add_action( 'elementor/element/{widget_id}/{section_id}/before_section_end', [ $this, 'register_controls' ] );`
69 *
70 * @since 1.0.0
71 * @access protected
72 */
73 protected function _register_controls_actions() {}
74
75 /**
76 * Get skin control ID.
77 *
78 * Retrieve the skin control ID. Note that skin controls have special prefix
79 * to distinguish them from regular controls, and from controls in other
80 * skins.
81 *
82 * @since 1.0.0
83 * @access protected
84 *
85 * @param string $control_base_id Control base ID.
86 *
87 * @return string Control ID.
88 */
89 protected function get_control_id( $control_base_id ) {
90 $skin_id = str_replace( '-', '_', $this->get_id() );
91 return $skin_id . '_' . $control_base_id;
92 }
93
94 /**
95 * Get skin settings.
96 *
97 * Retrieve all the skin settings or, when requested, a specific setting.
98 *
99 * @since 1.0.0
100 * @TODO: rename to get_setting() and create backward compatibility.
101 *
102 * @access public
103 *
104 * @param string $control_base_id Control base ID.
105 *
106 * @return Widget_Base Widget instance.
107 */
108 public function get_instance_value( $control_base_id ) {
109 $control_id = $this->get_control_id( $control_base_id );
110 return $this->parent->get_settings( $control_id );
111 }
112
113 /**
114 * Start skin controls section.
115 *
116 * Used to add a new section of controls to the skin.
117 *
118 * @since 1.3.0
119 * @access public
120 *
121 * @param string $id Section ID.
122 * @param array $args Section arguments.
123 */
124 public function start_controls_section( $id, $args = [] ) {
125 $args['condition']['_skin'] = $this->get_id();
126 parent::start_controls_section( $id, $args );
127 }
128
129 /**
130 * Add new skin control.
131 *
132 * Register a single control to the allow the user to set/update skin data.
133 *
134 * @param string $id Control ID.
135 * @param array $args Control arguments.
136 * @param array $options
137 *
138 * @return bool True if skin added, False otherwise.
139
140 * @since 3.0.0 New `$options` parameter added.
141 * @access public
142 *
143 */
144 public function add_control( $id, $args = [], $options = [] ) {
145 $args['condition']['_skin'] = $this->get_id();
146 return parent::add_control( $id, $args, $options );
147 }
148
149 /**
150 * Update skin control.
151 *
152 * Change the value of an existing skin control.
153 *
154 * @since 1.3.0
155 * @since 1.8.1 New `$options` parameter added.
156 *
157 * @access public
158 *
159 * @param string $id Control ID.
160 * @param array $args Control arguments. Only the new fields you want to update.
161 * @param array $options Optional. Some additional options.
162 */
163 public function update_control( $id, $args, array $options = [] ) {
164 $args['condition']['_skin'] = $this->get_id();
165 parent::update_control( $id, $args, $options );
166 }
167
168 /**
169 * Add new responsive skin control.
170 *
171 * Register a set of controls to allow editing based on user screen size.
172 *
173 * @param string $id Responsive control ID.
174 * @param array $args Responsive control arguments.
175 * @param array $options
176 *
177 * @since 1.0.5
178 * @access public
179 *
180 */
181 public function add_responsive_control( $id, $args, $options = [] ) {
182 $args['condition']['_skin'] = $this->get_id();
183 parent::add_responsive_control( $id, $args );
184 }
185
186 /**
187 * Start skin controls tab.
188 *
189 * Used to add a new tab inside a group of tabs.
190 *
191 * @since 1.5.0
192 * @access public
193 *
194 * @param string $id Control ID.
195 * @param array $args Control arguments.
196 */
197 public function start_controls_tab( $id, $args ) {
198 $args['condition']['_skin'] = $this->get_id();
199 parent::start_controls_tab( $id, $args );
200 }
201
202 /**
203 * Start skin controls tabs.
204 *
205 * Used to add a new set of tabs inside a section.
206 *
207 * @since 1.5.0
208 * @access public
209 *
210 * @param string $id Control ID.
211 */
212 public function start_controls_tabs( $id ) {
213 $args['condition']['_skin'] = $this->get_id();
214 parent::start_controls_tabs( $id );
215 }
216
217 /**
218 * Add new group control.
219 *
220 * Register a set of related controls grouped together as a single unified
221 * control.
222 *
223 * @param string $group_name Group control name.
224 * @param array $args Group control arguments. Default is an empty array.
225 * @param array $options
226 *
227 * @since 1.0.0
228 * @access public
229 *
230 */
231 final public function add_group_control( $group_name, $args = [], $options = [] ) {
232 $args['condition']['_skin'] = $this->get_id();
233 parent::add_group_control( $group_name, $args );
234 }
235
236 /**
237 * Set parent widget.
238 *
239 * Used to define the parent widget of the skin.
240 *
241 * @since 1.0.0
242 * @access public
243 *
244 * @param Widget_Base $parent Parent widget.
245 */
246 public function set_parent( $parent ) {
247 $this->parent = $parent;
248 }
249 }
250