/var/www/html_us/wp-content/plugins/elementor/includes/base/skin-base.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<?php
namespace Elementor;

if ( ! 
defined'ABSPATH' ) ) {
    exit; 
// Exit if accessed directly.
}

/**
 * Elementor skin base.
 *
 * An abstract class to register new skins for Elementor widgets. Skins allows
 * you to add new templates, set custom controls and more.
 *
 * To register new skins for your widget use the `add_skin()` method inside the
 * widget's `register_skins()` method.
 *
 * @since 1.0.0
 * @abstract
 */
abstract class Skin_Base extends Sub_Controls_Stack {

    
/**
     * Parent widget.
     *
     * Holds the parent widget of the skin. Default value is null, no parent widget.
     *
     * @access protected
     *
     * @var Widget_Base|null
     */
    
protected $parent null;

    
/**
     * Skin base constructor.
     *
     * Initializing the skin base class by setting parent widget and registering
     * controls actions.
     *
     * @since 1.0.0
     * @access public
     * @param Widget_Base $parent
     */
    
public function __constructWidget_Base $parent ) {
        
parent::__construct$parent );

        
$this->_register_controls_actions();
    }

    
/**
     * Render skin.
     *
     * Generates the final HTML on the frontend.
     *
     * @since 1.0.0
     * @access public
     * @abstract
     */
    
abstract public function render();

    
/**
     * Render element in static mode.
     *
     * If not inherent will call the base render.
     */
    
public function render_static() {
        
$this->render();
    }

    
/**
     * Determine the render logic.
     */
    
public function render_by_mode() {
        if ( 
Plugin::$instance->frontend->is_static_render_mode() ) {
            
$this->render_static();

            return;
        }

        
$this->render();
    }

    
/**
     * Register skin controls actions.
     *
     * Run on init and used to register new skins to be injected to the widget.
     * This method is used to register new actions that specify the location of
     * the skin in the widget.
     *
     * Example usage:
     * `add_action( 'elementor/element/{widget_id}/{section_id}/before_section_end', [ $this, 'register_controls' ] );`
     *
     * @since 1.0.0
     * @access protected
     */
    
protected function _register_controls_actions() {}

    
/**
     * Get skin control ID.
     *
     * Retrieve the skin control ID. Note that skin controls have special prefix
     * to distinguish them from regular controls, and from controls in other
     * skins.
     *
     * @since 1.0.0
     * @access protected
     *
     * @param string $control_base_id Control base ID.
     *
     * @return string Control ID.
     */
    
protected function get_control_id$control_base_id ) {
        
$skin_id str_replace'-''_'$this->get_id() );
        return 
$skin_id '_' $control_base_id;
    }

    
/**
     * Get skin settings.
     *
     * Retrieve all the skin settings or, when requested, a specific setting.
     *
     * @since 1.0.0
     * @TODO: rename to get_setting() and create backward compatibility.
     *
     * @access public
     *
     * @param string $control_base_id Control base ID.
     *
     * @return mixed
     */
    
public function get_instance_value$control_base_id ) {
        
$control_id $this->get_control_id$control_base_id );
        return 
$this->parent->get_settings$control_id );
    }

    
/**
     * Start skin controls section.
     *
     * Used to add a new section of controls to the skin.
     *
     * @since 1.3.0
     * @access public
     *
     * @param string $id   Section ID.
     * @param array  $args Section arguments.
     */
    
public function start_controls_section$id$args = [] ) {
        
$args['condition']['_skin'] = $this->get_id();
        
parent::start_controls_section$id$args );
    }

    
/**
     * Add new skin control.
     *
     * Register a single control to the allow the user to set/update skin data.
     *
     * @param string $id   Control ID.
     * @param array  $args Control arguments.
     * @param array  $options
     *
     * @return bool True if skin added, False otherwise.

     * @since 3.0.0 New `$options` parameter added.
     * @access public
     *
     */
    
public function add_control$id$args = [], $options = [] ) {
        
$args['condition']['_skin'] = $this->get_id();
        return 
parent::add_control$id$args$options );
    }

    
/**
     * Update skin control.
     *
     * Change the value of an existing skin control.
     *
     * @since 1.3.0
     * @since 1.8.1 New `$options` parameter added.
     *
     * @access public
     *
     * @param string $id      Control ID.
     * @param array  $args    Control arguments. Only the new fields you want to update.
     * @param array  $options Optional. Some additional options.
     */
    
public function update_control$id$args, array $options = [] ) {
        
$args['condition']['_skin'] = $this->get_id();
        
parent::update_control$id$args$options );
    }

    
/**
     * Add new responsive skin control.
     *
     * Register a set of controls to allow editing based on user screen size.
     *
     * @param string $id   Responsive control ID.
     * @param array  $args Responsive control arguments.
     * @param array  $options
     *
     * @since  1.0.5
     * @access public
     *
     */
    
public function add_responsive_control$id$args$options = [] ) {
        
$args['condition']['_skin'] = $this->get_id();
        
parent::add_responsive_control$id$args );
    }

    
/**
     * Start skin controls tab.
     *
     * Used to add a new tab inside a group of tabs.
     *
     * @since 1.5.0
     * @access public
     *
     * @param string $id   Control ID.
     * @param array  $args Control arguments.
     */
    
public function start_controls_tab$id$args ) {
        
$args['condition']['_skin'] = $this->get_id();
        
parent::start_controls_tab$id$args );
    }

    
/**
     * Start skin controls tabs.
     *
     * Used to add a new set of tabs inside a section.
     *
     * @since 1.5.0
     * @access public
     *
     * @param string $id Control ID.
     */
    
public function start_controls_tabs$id ) {
        
$args['condition']['_skin'] = $this->get_id();
        
parent::start_controls_tabs$id );
    }

    
/**
     * Add new group control.
     *
     * Register a set of related controls grouped together as a single unified
     * control.
     *
     * @param string $group_name Group control name.
     * @param array  $args       Group control arguments. Default is an empty array.
     * @param array  $options
     *
     * @since  1.0.0
     * @access public
     *
     */
    
final public function add_group_control$group_name$args = [], $options = [] ) {
        
$args['condition']['_skin'] = $this->get_id();
        
parent::add_group_control$group_name$args );
    }

    
/**
     * Set parent widget.
     *
     * Used to define the parent widget of the skin.
     *
     * @since 1.0.0
     * @access public
     *
     * @param Widget_Base $parent Parent widget.
     */
    
public function set_parent$parent ) {
        
$this->parent $parent;
    }
}