PluginProbe
Elementor Website Builder – more than just a page builder / 3.20.2
Elementor Website Builder – more than just a page builder v3.20.2
4.3.0-beta3 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 All 452 releases
← All changes | includes/controls/media.php +54 -108 4.1.33.20.2 View file →
@@ -1,7 +1,8 @@
1 1 <?php
2 2 namespace Elementor;
3 3
4 +use Elementor\Core\Files\Uploads_Manager;
4 5 use Elementor\Core\Utils\Hints;
5 6 use Elementor\Modules\DynamicTags\Module as TagsModule;
6 7
7 8 if ( ! defined( 'ABSPATH' ) ) {
@@ -50,16 +51,8 @@
50 51 'size' => '',
51 52 ];
52 53 }
53 54
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 55 /**
63 56 * Import media images.
64 57 *
65 58 * Used to import media control files from external sites while importing
@@ -67,9 +60,9 @@
67 60 *
68 61 * @since 1.0.0
69 62 * @access public
70 63 *
71 - * @param array $settings Control settings.
64 + * @param array $settings Control settings
72 65 *
73 66 * @return array Control settings.
74 67 */
75 68 public function on_import( $settings ) {
@@ -76,19 +69,8 @@
76 69 if ( empty( $settings['url'] ) ) {
77 70 return $settings;
78 71 }
79 72
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 73 $settings = Plugin::$instance->templates_manager->get_import_images_instance()->import( $settings );
92 74
93 75 if ( ! $settings ) {
94 76 $settings = [
@@ -107,9 +89,9 @@
107 89 *
108 90 * @since 3.4.6
109 91 * @deprecated 3.5.0
110 92 *
111 - * @param mixed $mimes
93 + * @param $mimes
112 94 * @return mixed
113 95 */
114 96 public function support_svg_and_json_import( $mimes ) {
115 97 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' );
@@ -128,9 +110,9 @@
128 110 */
129 111 public function enqueue() {
130 112 global $wp_version;
131 113
132 - $suffix = Utils::is_script_debug() ? '' : '.min';
114 + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
133 115 wp_enqueue_media();
134 116
135 117 wp_enqueue_style(
136 118 'media',
@@ -230,9 +212,9 @@
230 212 #>
231 213 <div class="{{{ inputWrapperClasses }}}">
232 214 <div class="elementor-control-media__content elementor-control-tag-area elementor-control-preview-area">
233 215 <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' ); ?>">
216 + <div class="elementor-control-media__remove elementor-control-media__content__remove" title="<?php echo esc_attr__( 'Remove', 'elementor' ); ?>">
235 217 <i class="eicon-trash-o" aria-hidden="true"></i>
236 218 <span class="elementor-screen-only"><?php echo esc_html__( 'Remove', 'elementor' ); ?></span>
237 219 </div>
238 220 <#
@@ -265,24 +247,55 @@
265 247 } );
266 248 #>
267 249 </div>
268 250 </div>
269 -
270 - <?php
271 - /*
272 - ?>
273 - <div class="elementor-control-media__warnings" role="alert" style="display: none;">
251 + <?php if ( ! Hints::should_display_hint( 'image-optimization-once' ) && ! Hints::should_display_hint( 'image-optimization' ) ) { ?>
252 + <div class="elementor-control-media__warnings elementor-descriptor" role="alert" style="display: none;">
274 253 <?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 - ] );
254 + Hints::get_notice_template( [
255 + 'type' => 'warning',
256 + 'content' => esc_html__( 'This image doesn’t contain ALT text - which is necessary for accessibility and SEO.', 'elementor' ),
257 + 'icon' => true,
258 + ] );
280 259 ?>
281 260 </div>
282 - <?php
283 - */ ?>
284 - <?php $this->maybe_display_io_hints(); ?>
261 + <?php } ?>
262 + <?php if ( Hints::should_display_hint( 'image-optimization-once' ) || Hints::should_display_hint( 'image-optimization' ) ) { ?>
263 + <div class="elementor-control-media__promotions elementor-descriptor" role="alert" style="display: none;">
264 + <?php
265 + $once_dismissed = Hints::is_dismissed( 'image-optimization-once' );
266 + if ( $once_dismissed ) {
267 + if ( Hints::is_plugin_installed( 'image-optimization' ) ) {
268 + $content = sprintf(
269 + __( 'This image is large and may slow things down. %1$sActivate Image Optimizer%2$s to reduce size without losing quality.', 'elementor' ),
270 + '<a href="' . Hints::get_plugin_action_url( 'image-optimization' ) . '" target="_blank">',
271 + '</a>'
272 + );
273 + } else {
274 + $content = sprintf(
275 + __( 'This image is large and may slow things down. %1$sInstall Image Optimizer%2$s to reduce size without losing quality.', 'elementor' ),
276 + '<a href="' . Hints::get_plugin_action_url( 'image-optimization' ) . '" target="_blank">',
277 + '</a>'
278 + );
279 + }
280 + } else {
281 + $content = sprintf(
282 + '%1$s <a href="%2$s" target="_blank">%3$s</a>',
283 + esc_html__( 'Don’t let unoptimized images be the downfall of your site’s performance.', 'elementor' ),
284 + Hints::get_plugin_action_url( 'image-optimization' ),
285 + Hints::is_plugin_installed( 'image-optimization' ) ? esc_html__( 'Activate Image Optimizer!', 'elementor' ) : esc_html__( 'Install Image Optimizer!', 'elementor' )
286 + );
287 + }
288 + $dismissible = $once_dismissed ? 'image_optimizer_hint' : 'image-optimization-once';
289 + Hints::get_notice_template( [
290 + 'display' => ! $once_dismissed,
291 + 'type' => $once_dismissed ? 'warning' : 'info',
292 + 'content' => $content,
293 + 'icon' => true,
294 + 'dismissible' => $dismissible,
295 + ] ); ?>
296 + </div>
297 + <?php } ?>
285 298 </div>
286 299 <# } /* endif isViewable() */ else { #>
287 300 <div class="elementor-control-media__file elementor-control-preview-area">
288 301 <div class="elementor-control-media__file__content">
@@ -294,13 +307,13 @@
294 307 <div class="elementor-control-media__file__content__info__name"></div>
295 308 </div>
296 309 </div>
297 310 <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' ); ?>">
311 + <div class="elementor-control-media__remove elementor-control-media__file__controls__remove" title="<?php echo esc_attr__( 'Remove', 'elementor' ); ?>">
299 312 <i class="eicon-trash-o" aria-hidden="true"></i>
300 313 <span class="elementor-screen-only"><?php echo esc_html__( 'Remove', 'elementor' ); ?></span>
301 314 </div>
302 - <div class="elementor-control-media__file__controls__upload-button elementor-control-media-upload-button" data-tooltip="<?php echo esc_attr__( 'Upload', 'elementor' ); ?>">
315 + <div class="elementor-control-media__file__controls__upload-button elementor-control-media-upload-button" title="<?php echo esc_attr__( 'Upload', 'elementor' ); ?>">
303 316 <i class="eicon-upload" aria-hidden="true"></i>
304 317 <span class="elementor-screen-only"><?php echo esc_html__( 'Upload', 'elementor' ); ?></span>
305 318 </div>
306 319 </div>
@@ -321,10 +334,8 @@
321 334 <?php endforeach; ?>
322 335 </select>
323 336 </div>
324 337 </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 338 </div>
328 339 <# } #>
329 340
330 341 <input type="hidden" data-setting="{{ data.name }}"/>
@@ -331,70 +342,9 @@
331 342 </div>
332 343 <?php
333 344 }
334 345
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 Optimizer 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 Optimizer. 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 Optimizer.', '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 {
346 + private function get_image_sizes() : array {
397 347 $wp_image_sizes = Group_Control_Image_Size::get_all_image_sizes();
398 348
399 349 $image_sizes = [];
400 350
@@ -493,12 +443,8 @@
493 443 }
494 444
495 445 $alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true );
496 446 if ( ! $alt ) {
497 - if ( Utils::has_invalid_post_permissions( $attachment ) ) {
498 - return '';
499 - }
500 -
501 447 $alt = $attachment->post_excerpt;
502 448 if ( ! $alt ) {
503 449 $alt = $attachment->post_title;
504 450 }
@@ -517,8 +463,8 @@
517 463
518 464 return wp_get_attachment_image_url( $control_value['id'], $control_value['size'] );
519 465 }
520 466
521 - public static function sanitise_text( $text ) {
522 - return esc_attr( strip_tags( $text ) );
467 + public static function sanitise_text( $string ) {
468 + return esc_attr( strip_tags( $string ) );
523 469 }
524 470 }