PluginProbe
Elementor Website Builder – more than just a page builder / 4.2.3
Elementor Website Builder – more than just a page builder v4.2.3
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 / dimensions.php

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

161 lines 5.0 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 dimension control.
10 *
11 * A base control for creating dimension control. Displays input fields for top,
12 * right, bottom, left and the option to link them together.
13 *
14 * @since 1.0.0
15 */
16 class Control_Dimensions extends Control_Base_Units {
17
18 /**
19 * Get dimensions control type.
20 *
21 * Retrieve the control type, in this case `dimensions`.
22 *
23 * @since 1.0.0
24 * @access public
25 *
26 * @return string Control type.
27 */
28 public function get_type() {
29 return 'dimensions';
30 }
31
32 /**
33 * Get dimensions control default values.
34 *
35 * Retrieve the default value of the dimensions control. Used to return the
36 * default values while initializing the dimensions control.
37 *
38 * @since 1.0.0
39 * @access public
40 *
41 * @return array Control default value.
42 */
43 public function get_default_value() {
44 return array_merge(
45 parent::get_default_value(), [
46 'top' => '',
47 'right' => '',
48 'bottom' => '',
49 'left' => '',
50 'isLinked' => true,
51 ]
52 );
53 }
54
55 public function get_singular_name() {
56 return 'dimension';
57 }
58
59 /**
60 * Get dimensions control default settings.
61 *
62 * Retrieve the default settings of the dimensions control. Used to return the
63 * default settings while initializing the dimensions control.
64 *
65 * @since 1.0.0
66 * @access protected
67 *
68 * @return array Control default settings.
69 */
70 protected function get_default_settings() {
71 return array_merge(
72 parent::get_default_settings(), [
73 'label_block' => true,
74 'allowed_dimensions' => 'all',
75 'placeholder' => '',
76 ]
77 );
78 }
79
80 protected function get_dimensions() {
81 return [
82 'top' => __( 'Top', 'elementor' ),
83 'right' => __( 'Right', 'elementor' ),
84 'bottom' => __( 'Bottom', 'elementor' ),
85 'left' => __( 'Left', 'elementor' ),
86 ];
87 }
88
89 /**
90 * Render dimensions control output in the editor.
91 *
92 * Used to generate the control HTML in the editor using Underscore JS
93 * template. The variables for the class are available using `data` JS
94 * object.
95 *
96 * @since 1.0.0
97 * @access public
98 */
99 public function content_template() {
100 $class_name = $this->get_singular_name();
101 ?>
102 <div class="elementor-control-field">
103 <label class="elementor-control-title">{{{ data.label }}}</label>
104 <?php $this->print_units_template(); ?>
105 <div class="elementor-control-input-wrapper">
106 <ul class="elementor-control-<?php echo esc_attr( $class_name ); ?>s">
107 <?php
108 foreach ( $this->get_dimensions() as $dimension_key => $dimension_title ) :
109 ?>
110 <li class="elementor-control-<?php echo esc_attr( $class_name ); ?>">
111 <input id="<?php $this->print_control_uid( $dimension_key ); ?>" type="text" data-setting="<?php
112 // PHPCS - the variable $dimension_key is a plain text.
113 echo $dimension_key; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
114 ?>" placeholder="<#
115 placeholder = view.getControlPlaceholder();
116 if ( _.isObject( placeholder ) && ! _.isUndefined( placeholder.<?php
117 // PHPCS - the variable $dimension_key is a plain text.
118 echo $dimension_key; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
119 ?> ) ) {
120 print( encodeURIComponent( placeholder.<?php
121 // PHPCS - the variable $dimension_key is a plain text.
122 echo $dimension_key; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
123 ?> ) );
124 } else {
125 print( placeholder ? encodeURIComponent( placeholder ) : '' );
126 } #>"
127 <# if ( -1 === _.indexOf( allowed_dimensions, '<?php
128 // PHPCS - the variable $dimension_key is a plain text.
129 echo $dimension_key; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
130 ?>' ) ) { #>
131 disabled
132 <# } #>
133 />
134 <label for="<?php $this->print_control_uid( $dimension_key ); ?>" class="elementor-control-<?php echo esc_attr( $class_name ); ?>-label"><?php
135 // PHPCS - the variable $dimension_title holds an escaped translated value.
136 echo $dimension_title; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
137 ?></label>
138 </li>
139 <?php endforeach; ?>
140 <li>
141 <button class="elementor-link-<?php echo esc_attr( $class_name ); ?>s tooltip-target" data-tooltip="<?php echo esc_attr__( 'Link values together', 'elementor' ); ?>">
142 <span class="elementor-linked">
143 <i class="eicon-link" aria-hidden="true"></i>
144 <span class="elementor-screen-only"><?php echo esc_html__( 'Link values together', 'elementor' ); ?></span>
145 </span>
146 <span class="elementor-unlinked">
147 <i class="eicon-chain-broken" aria-hidden="true"></i>
148 <span class="elementor-screen-only"><?php echo esc_html__( 'Unlinked values', 'elementor' ); ?></span>
149 </span>
150 </button>
151 </li>
152 </ul>
153 </div>
154 </div>
155 <# if ( data.description ) { #>
156 <div class="elementor-control-field-description">{{{ data.description }}}</div>
157 <# } #>
158 <?php
159 }
160 }
161