PluginProbe
Elementor Website Builder – more than just a page builder / 3.16.3
Elementor Website Builder – more than just a page builder v3.16.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 / icons.php

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

239 lines 7.6 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 use Elementor\Modules\DynamicTags\Module as TagsModule;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly.
8 }
9
10 /**
11 * Elementor Icons control.
12 *
13 * A base control for creating a Icons chooser control.
14 * Used to select an Icon.
15 *
16 * Usage: @see https://developers.elementor.com/elementor-controls/icons-control
17 *
18 * @since 2.6.0
19 */
20 class Control_Icons extends Control_Base_Multiple {
21
22 /**
23 * Get media control type.
24 *
25 * Retrieve the control type, in this case `media`.
26 *
27 * @access public
28 * @since 2.6.0
29 * @return string Control type.
30 */
31 public function get_type() {
32 return 'icons';
33 }
34
35 /**
36 * Get Icons control default values.
37 *
38 * Retrieve the default value of the Icons control. Used to return the default
39 * values while initializing the Icons control.
40 *
41 * @access public
42 * @since 2.6.0
43 * @return array Control default value.
44 */
45 public function get_default_value() {
46 return [
47 'value' => '',
48 'library' => '',
49 ];
50 }
51
52 /**
53 * Render Icons control output in the editor.
54 *
55 * Used to generate the control HTML in the editor using Underscore JS
56 * template. The variables for the class are available using `data` JS
57 * object.
58 *
59 * @since 2.6.0
60 * @access public
61 */
62 public function content_template() {
63 ?>
64 <# if ( 'inline' === data.skin ) { #>
65 <?php $this->render_inline_skin(); ?>
66 <# } else { #>
67 <?php $this->render_media_skin(); ?>
68 <# } #>
69 <?php
70 }
71
72 public function render_media_skin() {
73 ?>
74 <div class="elementor-control-field elementor-control-media">
75 <label class="elementor-control-title">{{{ data.label }}}</label>
76 <div class="elementor-control-input-wrapper">
77 <div class="elementor-control-media__content elementor-control-tag-area elementor-control-preview-area">
78 <div class="elementor-control-media-upload-button elementor-control-media__content__upload-button">
79 <i class="eicon-plus-circle" aria-hidden="true"></i>
80 <span class="elementor-screen-only"><?php echo esc_html__( 'Add', 'elementor' ); ?></span>
81 </div>
82 <div class="elementor-control-media-area">
83 <div class="elementor-control-media__remove elementor-control-media__content__remove" title="<?php echo esc_attr__( 'Remove', 'elementor' ); ?>">
84 <i class="eicon-trash-o" aria-hidden="true"></i>
85 <span class="elementor-screen-only"><?php echo esc_html__( 'Remove', 'elementor' ); ?></span>
86 </div>
87 <div class="elementor-control-media__preview"></div>
88 </div>
89 <div class="elementor-control-media__tools elementor-control-dynamic-switcher-wrapper">
90 <div class="elementor-control-icon-picker elementor-control-media__tool"><?php echo esc_html__( 'Icon Library', 'elementor' ); ?></div>
91 <div class="elementor-control-svg-uploader elementor-control-media__tool"><?php echo esc_html__( 'Upload SVG', 'elementor' ); ?></div>
92 </div>
93 </div>
94 </div>
95 <# if ( data.description ) { #>
96 <div class="elementor-control-field-description">{{{ data.description }}}</div>
97 <# } #>
98 <input type="hidden" data-setting="{{ data.name }}"/>
99 </div>
100 <?php
101 }
102
103 public function render_inline_skin() {
104 ?>
105 <#
106 const defaultSkinSettings = {
107 none: {
108 label: '<?php echo esc_html__( 'None', 'elementor' ); ?>',
109 icon: 'eicon-ban',
110 },
111 svg: {
112 label: '<?php echo esc_html__( 'Upload SVG', 'elementor' ); ?>',
113 icon: 'eicon-upload',
114 },
115 icon: {
116 label: '<?php echo esc_html__( 'Icon Library', 'elementor' ); ?>',
117 icon: 'eicon-circle',
118 }
119 };
120
121 const skinSettings = data.skin_settings.inline;
122
123 const get = ( type, key ) => {
124 if ( skinSettings[ type ] ) {
125 return skinSettings[ type ]?.[ key ] || defaultSkinSettings[ type ][ key ];
126 }
127
128 return defaultSkinSettings[ type ][ key ];
129 }
130 #>
131 <div class="elementor-control-field elementor-control-inline-icon">
132 <label class="elementor-control-title">{{{ data.label }}}</label>
133 <div class="elementor-control-input-wrapper">
134 <div class="elementor-choices">
135 <input id="<?php $this->print_control_uid(); ?>-none" type="radio" value="none">
136 <label class="elementor-choices-label elementor-control-unit-1 tooltip-target elementor-control-icons--inline__none" for="<?php $this->print_control_uid(); ?>-none" data-tooltip="{{ get( 'none', 'label' ) }}" title="{{ get( 'none', 'label' ) }}">
137 <i class="{{ get( 'none', 'icon' ) }}" aria-hidden="true"></i>
138 <span class="elementor-screen-only">{{ get( 'none', 'label' ) }}</span>
139 </label>
140 <# if ( ! data.exclude_inline_options.includes( 'svg' ) ) { #>
141 <input id="<?php $this->print_control_uid(); ?>-svg" type="radio" value="svg">
142 <label class="elementor-choices-label elementor-control-unit-1 tooltip-target elementor-control-icons--inline__svg" for="<?php $this->print_control_uid(); ?>-svg" data-tooltip="{{ get( 'svg', 'label' ) }}" title="{{ get( 'svg', 'label' ) }}">
143 <i class="{{ get( 'svg', 'icon' ) }}" aria-hidden="true"></i>
144 <span class="elementor-screen-only">{{ get( 'svg', 'label' ) }}</span>
145 </label>
146 <# }
147 if ( ! data.exclude_inline_options.includes( 'icon' ) ) { #>
148 <input id="<?php $this->print_control_uid(); ?>-icon" type="radio" value="icon">
149 <label class="elementor-choices-label elementor-control-unit-1 tooltip-target elementor-control-icons--inline__icon" for="<?php $this->print_control_uid(); ?>-icon" data-tooltip="{{ get( 'icon', 'label' ) }}" title="{{ get( 'icon', 'label' ) }}">
150 <span class="elementor-control-icons--inline__displayed-icon">
151 <i class="{{ get( 'icon', 'icon' ) }}" aria-hidden="true"></i>
152 </span>
153 <span class="elementor-screen-only">{{ get( 'icon', 'label' ) }}</span>
154 </label>
155 <# } #>
156 </div>
157 </div>
158 </div>
159
160 <# if ( data.description ) { #>
161 <div class="elementor-control-field-description">{{{ data.description }}}</div>
162 <# } #>
163 <?php
164 }
165
166 /**
167 * Get Icons control default settings.
168 *
169 * Retrieve the default settings of the Icons control. Used to return the default
170 * settings while initializing the Icons control.
171 *
172 * @since 2.6.0
173 * @access protected
174 *
175 * @return array Control default settings.
176 */
177 protected function get_default_settings() {
178 return [
179 'label_block' => true,
180 'dynamic' => [
181 'categories' => [ TagsModule::IMAGE_CATEGORY ],
182 'returnType' => 'object',
183 ],
184 'search_bar' => true,
185 'recommended' => false,
186 'skin' => 'media',
187 'exclude_inline_options' => [],
188 'disable_initial_active_state' => false,
189 'skin_settings' => [
190 'inline' => [
191 'none' => [
192 'label' => esc_html__( 'None', 'elementor' ),
193 'icon' => 'eicon-ban',
194 ],
195 'svg' => [
196 'label' => esc_html__( 'Upload SVG', 'elementor' ),
197 'icon' => 'eicon-upload',
198 ],
199 'icon' => [
200 'label' => esc_html__( 'Icon Library', 'elementor' ),
201 'icon' => 'eicon-circle',
202 ],
203 ],
204 ],
205 ];
206 }
207
208 /**
209 * Support SVG Import
210 *
211 * @deprecated 3.5.0
212 *
213 * @param $mimes
214 * @return mixed
215 */
216 public function support_svg_import( $mimes ) {
217 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' );
218
219 $mimes['svg'] = 'image/svg+xml';
220 return $mimes;
221 }
222
223 public function on_import( $settings ) {
224 if ( empty( $settings['library'] ) || 'svg' !== $settings['library'] || empty( $settings['value']['url'] ) ) {
225 return $settings;
226 }
227
228 $imported = Plugin::$instance->templates_manager->get_import_images_instance()->import( $settings['value'] );
229
230 if ( ! $imported ) {
231 $settings['value'] = '';
232 $settings['library'] = '';
233 } else {
234 $settings['value'] = $imported;
235 }
236 return $settings;
237 }
238 }
239