PluginProbe
Elementor Website Builder – more than just a page builder / 3.7.4
Elementor Website Builder – more than just a page builder v3.7.4
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.7.4, at includes/controls/icons.php

237 lines 7.5 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 elementor-aspect-ratio-219">
77 <div class="elementor-control-media__content elementor-control-tag-area elementor-control-preview-area elementor-fit-aspect-ratio">
78 <div class="elementor-control-media-upload-button elementor-control-media__content__upload-button elementor-fit-aspect-ratio">
79 <i class="eicon-plus-circle" aria-hidden="true"></i>
80 </div>
81 <div class="elementor-control-media-area elementor-fit-aspect-ratio">
82 <div class="elementor-control-media__remove elementor-control-media__content__remove" title="<?php echo esc_html__( 'Remove', 'elementor' ); ?>">
83 <i class="eicon-trash-o"></i>
84 </div>
85 <div class="elementor-control-media__preview elementor-fit-aspect-ratio"></div>
86 </div>
87 <div class="elementor-control-media__tools elementor-control-dynamic-switcher-wrapper">
88 <div class="elementor-control-icon-picker elementor-control-media__tool"><?php echo esc_html__( 'Icon Library', 'elementor' ); ?></div>
89 <div class="elementor-control-svg-uploader elementor-control-media__tool"><?php echo esc_html__( 'Upload SVG', 'elementor' ); ?></div>
90 </div>
91 </div>
92 </div>
93 <# if ( data.description ) { #>
94 <div class="elementor-control-field-description">{{{ data.description }}}</div>
95 <# } #>
96 <input type="hidden" data-setting="{{ data.name }}"/>
97 </div>
98 <?php
99 }
100
101 public function render_inline_skin() {
102 ?>
103 <#
104 const defaultSkinSettings = {
105 none: {
106 label: '<?php echo esc_html__( 'None', 'elementor' ); ?>',
107 icon: 'eicon-ban',
108 },
109 svg: {
110 label: '<?php echo esc_html__( 'Upload SVG', 'elementor' ); ?>',
111 icon: 'eicon-upload',
112 },
113 icon: {
114 label: '<?php echo esc_html__( 'Icon Library', 'elementor' ); ?>',
115 icon: 'eicon-circle',
116 }
117 };
118
119 const skinSettings = data.skin_settings.inline;
120
121 const get = ( type, key ) => {
122 if ( skinSettings[ type ] ) {
123 return skinSettings[ type ]?.[ key ] || defaultSkinSettings[ type ][ key ];
124 }
125
126 return defaultSkinSettings[ type ][ key ];
127 }
128 #>
129 <div class="elementor-control-field elementor-control-inline-icon">
130 <label class="elementor-control-title">{{{ data.label }}}</label>
131 <div class="elementor-control-input-wrapper">
132 <div class="elementor-choices">
133 <input id="<?php $this->print_control_uid(); ?>-none" type="radio" value="none">
134 <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' ) }}">
135 <i class="{{ get( 'none', 'icon' ) }}" aria-hidden="true"></i>
136 <span class="elementor-screen-only">{{ get( 'none', 'label' ) }}</span>
137 </label>
138 <# if ( ! data.exclude_inline_options.includes( 'svg' ) ) { #>
139 <input id="<?php $this->print_control_uid(); ?>-svg" type="radio" value="svg">
140 <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' ) }}">
141 <i class="{{ get( 'svg', 'icon' ) }}" aria-hidden="true"></i>
142 <span class="elementor-screen-only">{{ get( 'svg', 'label' ) }}</span>
143 </label>
144 <# }
145 if ( ! data.exclude_inline_options.includes( 'icon' ) ) { #>
146 <input id="<?php $this->print_control_uid(); ?>-icon" type="radio" value="icon">
147 <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' ) }}">
148 <span class="elementor-control-icons--inline__displayed-icon">
149 <i class="{{ get( 'icon', 'icon' ) }}" aria-hidden="true"></i>
150 </span>
151 <span class="elementor-screen-only">{{ get( 'icon', 'label' ) }}</span>
152 </label>
153 <# } #>
154 </div>
155 </div>
156 </div>
157
158 <# if ( data.description ) { #>
159 <div class="elementor-control-field-description">{{{ data.description }}}</div>
160 <# } #>
161 <?php
162 }
163
164 /**
165 * Get Icons control default settings.
166 *
167 * Retrieve the default settings of the Icons control. Used to return the default
168 * settings while initializing the Icons control.
169 *
170 * @since 2.6.0
171 * @access protected
172 *
173 * @return array Control default settings.
174 */
175 protected function get_default_settings() {
176 return [
177 'label_block' => true,
178 'dynamic' => [
179 'categories' => [ TagsModule::IMAGE_CATEGORY ],
180 'returnType' => 'object',
181 ],
182 'search_bar' => true,
183 'recommended' => false,
184 'skin' => 'media',
185 'exclude_inline_options' => [],
186 'disable_initial_active_state' => false,
187 'skin_settings' => [
188 'inline' => [
189 'none' => [
190 'label' => esc_html__( 'None', 'elementor' ),
191 'icon' => 'eicon-ban',
192 ],
193 'svg' => [
194 'label' => esc_html__( 'Upload SVG', 'elementor' ),
195 'icon' => 'eicon-upload',
196 ],
197 'icon' => [
198 'label' => esc_html__( 'Icon Library', 'elementor' ),
199 'icon' => 'eicon-circle',
200 ],
201 ],
202 ],
203 ];
204 }
205
206 /**
207 * Support SVG Import
208 *
209 * @deprecated 3.5.0
210 *
211 * @param $mimes
212 * @return mixed
213 */
214 public function support_svg_import( $mimes ) {
215 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' );
216
217 $mimes['svg'] = 'image/svg+xml';
218 return $mimes;
219 }
220
221 public function on_import( $settings ) {
222 if ( empty( $settings['library'] ) || 'svg' !== $settings['library'] || empty( $settings['value']['url'] ) ) {
223 return $settings;
224 }
225
226 $imported = Plugin::$instance->templates_manager->get_import_images_instance()->import( $settings['value'] );
227
228 if ( ! $imported ) {
229 $settings['value'] = '';
230 $settings['library'] = '';
231 } else {
232 $settings['value'] = $imported;
233 }
234 return $settings;
235 }
236 }
237