PluginProbe
Elementor Website Builder – more than just a page builder / 3.11.2
Elementor Website Builder – more than just a page builder v3.11.2
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
← All changes | includes/controls/media.php +15 -130 4.2.23.11.2 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2 namespace Elementor;
3 3
4 -use Elementor\Core\Utils\Hints;
4 +use Elementor\Core\Files\Uploads_Manager;
5 5 use Elementor\Modules\DynamicTags\Module as TagsModule;
6 6
7 7 if ( ! defined( 'ABSPATH' ) ) {
8 8 exit; // Exit if accessed directly.
@@ -50,16 +50,8 @@
50 50 'size' => '',
51 51 ];
52 52 }
53 53
54 - public function on_export( $settings ) {
55 - if ( ! empty( $settings['url'] ) ) {
56 - do_action( 'elementor/templates/collect_media_url', $settings['url'], $settings );
57 - }
58 -
59 - return $settings;
60 - }
61 -
62 54 /**
63 55 * Import media images.
64 56 *
65 57 * Used to import media control files from external sites while importing
@@ -67,9 +59,9 @@
67 59 *
68 60 * @since 1.0.0
69 61 * @access public
70 62 *
71 - * @param array $settings Control settings.
63 + * @param array $settings Control settings
72 64 *
73 65 * @return array Control settings.
74 66 */
75 67 public function on_import( $settings ) {
@@ -76,19 +68,8 @@
76 68 if ( empty( $settings['url'] ) ) {
77 69 return $settings;
78 70 }
79 71
80 - $local_file_path = \Elementor\TemplateLibrary\Classes\Media_Mapper::get_local_file_path( $settings['url'] );
81 - $imported_attachment = false;
82 -
83 - if ( $local_file_path !== $settings['url'] && file_exists( $local_file_path ) ) {
84 - $imported_attachment = Plugin::$instance->templates_manager->get_import_images_instance()->import_local_file( $local_file_path );
85 - }
86 -
87 - if ( $imported_attachment ) {
88 - return $imported_attachment;
89 - }
90 -
91 72 $settings = Plugin::$instance->templates_manager->get_import_images_instance()->import( $settings );
92 73
93 74 if ( ! $settings ) {
94 75 $settings = [
@@ -107,9 +88,9 @@
107 88 *
108 89 * @since 3.4.6
109 90 * @deprecated 3.5.0
110 91 *
111 - * @param mixed $mimes
92 + * @param $mimes
112 93 * @return mixed
113 94 */
114 95 public function support_svg_and_json_import( $mimes ) {
115 96 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' );
@@ -128,9 +109,9 @@
128 109 */
129 110 public function enqueue() {
130 111 global $wp_version;
131 112
132 - $suffix = Utils::is_script_debug() ? '' : '.min';
113 + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
133 114 wp_enqueue_media();
134 115
135 116 wp_enqueue_style(
136 117 'media',
@@ -230,11 +211,10 @@
230 211 #>
231 212 <div class="{{{ inputWrapperClasses }}}">
232 213 <div class="elementor-control-media__content elementor-control-tag-area elementor-control-preview-area">
233 214 <div class="elementor-control-media-area">
234 - <div class="elementor-control-media__remove elementor-control-media__content__remove" data-tooltip="<?php echo esc_attr__( 'Remove', 'elementor' ); ?>">
235 - <i class="eicon-trash-o" aria-hidden="true"></i>
236 - <span class="elementor-screen-only"><?php echo esc_html__( 'Remove', 'elementor' ); ?></span>
215 + <div class="elementor-control-media__remove elementor-control-media__content__remove" title="<?php echo esc_html__( 'Remove', 'elementor' ); ?>">
216 + <i class="eicon-trash-o"></i>
237 217 </div>
238 218 <#
239 219 switch( getPreviewType() ) {
240 220 case 'image':
@@ -245,9 +225,9 @@
245 225
246 226 case 'video':
247 227 #>
248 228 <video class="elementor-control-media-video" preload="metadata"></video>
249 - <i class="eicon-video-camera" aria-hidden="true"></i>
229 + <i class="eicon-video-camera"></i>
250 230 <#
251 231 break;
252 232 }
253 233 #>
@@ -253,9 +233,8 @@
253 233 #>
254 234 </div>
255 235 <div class="elementor-control-media-upload-button elementor-control-media__content__upload-button">
256 236 <i class="eicon-plus-circle" aria-hidden="true"></i>
257 - <span class="elementor-screen-only"><?php echo esc_html__( 'Add', 'elementor' ); ?></span>
258 237 </div>
259 238 <div class="elementor-control-media__tools elementor-control-dynamic-switcher-wrapper">
260 239 <#
261 240 data.media_types.forEach( ( type ) => {
@@ -265,24 +244,8 @@
265 244 } );
266 245 #>
267 246 </div>
268 247 </div>
269 -
270 - <?php
271 - /*
272 - ?>
273 - <div class="elementor-control-media__warnings" role="alert" style="display: none;">
274 - <?php
275 - Hints::get_notice_template( [
276 - 'type' => 'warning',
277 - 'content' => esc_html__( 'This image doesn’t contain ALT text - which is necessary for accessibility and SEO.', 'elementor' ),
278 - 'icon' => true,
279 - ] );
280 - ?>
281 - </div>
282 - <?php
283 - */ ?>
284 - <?php $this->maybe_display_io_hints(); ?>
285 248 </div>
286 249 <# } /* endif isViewable() */ else { #>
287 250 <div class="elementor-control-media__file elementor-control-preview-area">
288 251 <div class="elementor-control-media__file__content">
@@ -294,15 +257,13 @@
294 257 <div class="elementor-control-media__file__content__info__name"></div>
295 258 </div>
296 259 </div>
297 260 <div class="elementor-control-media__file__controls">
298 - <div class="elementor-control-media__remove elementor-control-media__file__controls__remove" data-tooltip="<?php echo esc_attr__( 'Remove', 'elementor' ); ?>">
299 - <i class="eicon-trash-o" aria-hidden="true"></i>
300 - <span class="elementor-screen-only"><?php echo esc_html__( 'Remove', 'elementor' ); ?></span>
261 + <div class="elementor-control-media__remove elementor-control-media__file__controls__remove" title="<?php echo esc_html__( 'Remove', 'elementor' ); ?>">
262 + <i class="eicon-trash-o"></i>
301 263 </div>
302 - <div class="elementor-control-media__file__controls__upload-button elementor-control-media-upload-button" data-tooltip="<?php echo esc_attr__( 'Upload', 'elementor' ); ?>">
303 - <i class="eicon-upload" aria-hidden="true"></i>
304 - <span class="elementor-screen-only"><?php echo esc_html__( 'Upload', 'elementor' ); ?></span>
264 + <div class="elementor-control-media__file__controls__upload-button elementor-control-media-upload-button" title="<?php echo esc_html__( 'Upload', 'elementor' ); ?>">
265 + <i class="eicon-upload"></i>
305 266 </div>
306 267 </div>
307 268 </div>
308 269 <# } #>
@@ -312,9 +273,9 @@
312 273
313 274 <# if ( data.has_sizes ) { #>
314 275 <div class="elementor-control-type-select e-control-image-size">
315 276 <div class="elementor-control-field">
316 - <label class="elementor-control-title" data-e-responsive-switcher-sibling="false" for="<?php $this->print_control_uid( 'size' ); ?>"><?php echo esc_html__( 'Image Resolution', 'elementor' ); ?></label>
277 + <label class="elementor-control-title" data-e-responsive-switcher-sibling="false" for="<?php $this->print_control_uid( 'size' ); ?>"><?php echo esc_html__( 'Image Size', 'elementor' ); ?></label>
317 278 <div class="elementor-control-input-wrapper elementor-control-unit-5">
318 279 <select class="e-image-size-select" id="<?php $this->print_control_uid( 'size' ); ?>" data-setting="size">
319 280 <?php foreach ( $this->get_image_sizes() as $size_key => $size_title ) : ?>
320 281 <option value="<?php echo esc_attr( $size_key ); ?>"><?php echo esc_html( $size_title ); ?></option>
@@ -321,10 +282,8 @@
321 282 <?php endforeach; ?>
322 283 </select>
323 284 </div>
324 285 </div>
325 -
326 - <div class="elementor-control-field-description"><?php echo esc_html__( 'Image size settings don’t apply to Dynamic Images.', 'elementor' ); ?></div>
327 286 </div>
328 287 <# } #>
329 288
330 289 <input type="hidden" data-setting="{{ data.name }}"/>
@@ -331,70 +290,9 @@
331 290 </div>
332 291 <?php
333 292 }
334 293
335 - private function maybe_display_io_hints() {
336 - $plugin_slug = 'image-optimization';
337 -
338 - if ( ! Hints::should_display_hint( $plugin_slug ) ) {
339 - return;
340 - }
341 -
342 - $one_subscription = Hints::is_plugin_connected_to_one_subscription();
343 - $is_installed = Hints::is_plugin_installed( $plugin_slug );
344 - $is_active = Hints::is_plugin_active( $plugin_slug );
345 -
346 - if ( $is_active ) {
347 - return;
348 - }
349 -
350 - if ( $one_subscription ) {
351 - if ( ! $is_installed ) {
352 - $content = esc_html__( 'Optimize your images to improve site speed and performance. Image Optimization is included in your ONE subscription.', 'elementor' );
353 - $button_text = esc_html__( 'Install now', 'elementor' );
354 - $button_url = Hints::get_plugin_install_url( $plugin_slug );
355 - $source = 'io-editor-image-one-install';
356 - } elseif ( ! $is_active ) {
357 - $content = esc_html__( 'Your ONE subscription includes Image Optimization. Activate it to optimize images and improve site performance.', 'elementor' );
358 - $button_text = esc_html__( 'Activate now', 'elementor' );
359 - $button_url = Hints::get_plugin_activate_url( $plugin_slug );
360 - $source = 'io-editor-image-one-activate';
361 - }
362 - } else {
363 - $content = esc_html__( 'Optimize your images to enhance site performance by using Image Optimization.', 'elementor' );
364 - if ( ! $is_installed ) {
365 - $button_text = esc_html__( 'Install now', 'elementor' );
366 - $button_url = Hints::get_plugin_install_url( $plugin_slug );
367 - $source = 'io-editor-image-install';
368 - } elseif ( ! $is_active ) {
369 - $button_text = esc_html__( 'Activate now', 'elementor' );
370 - $button_url = Hints::get_plugin_activate_url( $plugin_slug );
371 - $source = 'io-editor-image-activate';
372 - }
373 - }
374 - ?>
375 - <div class="elementor-control-media__promotions" role="alert">
376 - <?php
377 - Hints::get_notice_template( [
378 - 'display' => ! Hints::is_dismissed( $plugin_slug ),
379 - 'type' => 'info',
380 - 'icon' => true,
381 - 'heading' => '',
382 - 'content' => $content,
383 - 'dismissible' => 'image_optimizer_hint',
384 - 'button_text' => $button_text,
385 - 'button_event' => 'image_optimizer_hint',
386 - 'button_data' => [
387 - 'action_url' => $button_url,
388 - 'source' => $source,
389 - ],
390 - ] );
391 - ?>
392 - </div>
393 - <?php
394 - }
395 -
396 - private function get_image_sizes(): array {
294 + private function get_image_sizes() : array {
397 295 $wp_image_sizes = Group_Control_Image_Size::get_all_image_sizes();
398 296
399 297 $image_sizes = [];
400 298
@@ -426,13 +324,8 @@
426 324 protected function get_default_settings() {
427 325 return [
428 326 'label_block' => true,
429 327 'has_sizes' => false,
430 - 'ai' => [
431 - 'active' => true,
432 - 'type' => 'media',
433 - 'category' => 'photographic',
434 - ],
435 328 'media_types' => [
436 329 'image',
437 330 ],
438 331 'dynamic' => [
@@ -478,9 +371,9 @@
478 371 */
479 372 public static function get_image_alt( $instance ) {
480 373 if ( empty( $instance['id'] ) ) {
481 374 // For `Insert From URL` images.
482 - return isset( $instance['alt'] ) ? trim( self::sanitise_text( $instance['alt'] ) ) : '';
375 + return isset( $instance['alt'] ) ? trim( strip_tags( $instance['alt'] ) ) : '';
483 376 }
484 377
485 378 $attachment_id = $instance['id'];
486 379 if ( ! $attachment_id ) {
@@ -493,18 +386,14 @@
493 386 }
494 387
495 388 $alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true );
496 389 if ( ! $alt ) {
497 - if ( Utils::has_invalid_post_permissions( $attachment ) ) {
498 - return '';
499 - }
500 -
501 390 $alt = $attachment->post_excerpt;
502 391 if ( ! $alt ) {
503 392 $alt = $attachment->post_title;
504 393 }
505 394 }
506 - return trim( self::sanitise_text( $alt ) );
395 + return trim( strip_tags( $alt ) );
507 396 }
508 397
509 398 public function get_style_value( $css_property, $control_value, array $control_data ) {
510 399 if ( 'URL' !== $css_property || empty( $control_value['id'] ) ) {
@@ -515,10 +404,6 @@
515 404 $control_value['size'] = 'full';
516 405 }
517 406
518 407 return wp_get_attachment_image_url( $control_value['id'], $control_value['size'] );
519 - }
520 -
521 - public static function sanitise_text( $text ) {
522 - return esc_attr( strip_tags( $text ) );
523 408 }
524 409 }