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

189 lines 6.4 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 __( '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 __( 'Icon Library', 'elementor' ); ?></div>
89 <div class="elementor-control-svg-uploader elementor-control-media__tool"><?php echo __( '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 $control_uid = $this->get_control_uid();
103 ?>
104 <div class="elementor-control-field elementor-control-inline-icon">
105 <label class="elementor-control-title">{{{ data.label }}}</label>
106 <div class="elementor-control-input-wrapper">
107 <div class="elementor-choices">
108 <input id="<?php echo $control_uid; ?>-none" type="radio" value="none">
109 <label class="elementor-choices-label elementor-control-unit-1 tooltip-target elementor-control-icons--inline__none" for="<?php echo $control_uid; ?>-none" data-tooltip="<?php echo __( 'None', 'elementor' ); ?>" title="<?php echo __( 'None', 'elementor' ); ?>">
110 <i class="eicon-ban" aria-hidden="true"></i>
111 <span class="elementor-screen-only"><?php echo __( 'None', 'elementor' ); ?></span>
112 </label>
113 <# if ( ! data.exclude_inline_options.includes( 'svg' ) ) { #>
114 <input id="<?php echo $control_uid; ?>-svg" type="radio" value="svg">
115 <label class="elementor-choices-label elementor-control-unit-1 tooltip-target elementor-control-icons--inline__svg" for="<?php echo $control_uid; ?>-svg" data-tooltip="<?php echo __( 'Upload SVG', 'elementor' ); ?>" title="<?php echo __( 'Upload SVG', 'elementor' ); ?>">
116 <i class="eicon-upload" aria-hidden="true"></i>
117 <span class="elementor-screen-only"><?php echo __( 'Upload SVG', 'elementor' ); ?></span>
118 </label>
119 <# }
120 if ( ! data.exclude_inline_options.includes( 'icon' ) ) { #>
121 <input id="<?php echo $control_uid; ?>-icon" type="radio" value="icon">
122 <label class="elementor-choices-label elementor-control-unit-1 tooltip-target elementor-control-icons--inline__icon" for="<?php echo $control_uid; ?>-icon" data-tooltip="<?php echo __( 'Icon Library', 'elementor' ); ?>" title="<?php echo __( 'Icon Library', 'elementor' ); ?>">
123 <span class="elementor-control-icons--inline__displayed-icon">
124 <i class="eicon-circle" aria-hidden="true"></i>
125 </span>
126 <span class="elementor-screen-only"><?php echo __( 'Icon Library', 'elementor' ); ?></span>
127 </label>
128 <# } #>
129 </div>
130 </div>
131 </div>
132
133 <# if ( data.description ) { #>
134 <div class="elementor-control-field-description">{{{ data.description }}}</div>
135 <# } #>
136 <?php
137 }
138
139 /**
140 * Get Icons control default settings.
141 *
142 * Retrieve the default settings of the Icons control. Used to return the default
143 * settings while initializing the Icons control.
144 *
145 * @since 2.6.0
146 * @access protected
147 *
148 * @return array Control default settings.
149 */
150 protected function get_default_settings() {
151 return [
152 'label_block' => true,
153 'dynamic' => [
154 'categories' => [ TagsModule::IMAGE_CATEGORY ],
155 'returnType' => 'object',
156 ],
157 'search_bar' => true,
158 'recommended' => false,
159 'skin' => 'media',
160 'exclude_inline_options' => [],
161 ];
162 }
163
164 public function support_svg_import( $mimes ) {
165 $mimes['svg'] = 'image/svg+xml';
166 return $mimes;
167 }
168
169 public function on_import( $settings ) {
170 if ( empty( $settings['library'] ) || 'svg' !== $settings['library'] || empty( $settings['value']['url'] ) ) {
171 return $settings;
172 }
173
174 add_filter( 'upload_mimes', [ $this, 'support_svg_import' ], 100 );
175
176 $imported = Plugin::$instance->templates_manager->get_import_images_instance()->import( $settings['value'] );
177
178 remove_filter( 'upload_mimes', [ $this, 'support_svg_import' ], 100 );
179
180 if ( ! $imported ) {
181 $settings['value'] = '';
182 $settings['library'] = '';
183 } else {
184 $settings['value'] = $imported;
185 }
186 return $settings;
187 }
188 }
189