PluginProbe
Elementor Website Builder – more than just a page builder / 3.3.1
Elementor Website Builder – more than just a page builder v3.3.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 / includes / controls / switcher.php

switcher.php in Elementor Website Builder – more than just a page builder 3.3.1, at includes/controls/switcher.php

80 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;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 /**
9 * Elementor switcher control.
10 *
11 * A base control for creating switcher control. Displays an on/off switcher,
12 * basically a fancy UI representation of a checkbox.
13 *
14 * @since 1.0.0
15 */
16 class Control_Switcher extends Base_Data_Control {
17
18 /**
19 * Get switcher control type.
20 *
21 * Retrieve the control type, in this case `switcher`.
22 *
23 * @since 1.0.0
24 * @access public
25 *
26 * @return string Control type.
27 */
28 public function get_type() {
29 return 'switcher';
30 }
31
32 /**
33 * Render switcher control output in the editor.
34 *
35 * Used to generate the control HTML in the editor using Underscore JS
36 * template. The variables for the class are available using `data` JS
37 * object.
38 *
39 * @since 1.0.0
40 * @access public
41 */
42 public function content_template() {
43 $control_uid = $this->get_control_uid();
44 ?>
45 <div class="elementor-control-field">
46 <label for="<?php echo $control_uid; ?>" class="elementor-control-title">{{{ data.label }}}</label>
47 <div class="elementor-control-input-wrapper">
48 <label class="elementor-switch elementor-control-unit-2">
49 <input id="<?php echo $control_uid; ?>" type="checkbox" data-setting="{{ data.name }}" class="elementor-switch-input" value="{{ data.return_value }}">
50 <span class="elementor-switch-label" data-on="{{ data.label_on }}" data-off="{{ data.label_off }}"></span>
51 <span class="elementor-switch-handle"></span>
52 </label>
53 </div>
54 </div>
55 <# if ( data.description ) { #>
56 <div class="elementor-control-field-description">{{{ data.description }}}</div>
57 <# } #>
58 <?php
59 }
60
61 /**
62 * Get switcher control default settings.
63 *
64 * Retrieve the default settings of the switcher control. Used to return the
65 * default settings while initializing the switcher control.
66 *
67 * @since 1.0.0
68 * @access protected
69 *
70 * @return array Control default settings.
71 */
72 protected function get_default_settings() {
73 return [
74 'label_off' => __( 'No', 'elementor' ),
75 'label_on' => __( 'Yes', 'elementor' ),
76 'return_value' => 'yes',
77 ];
78 }
79 }
80