| @@ -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 | <# |
| @@ -266,11 +248,9 @@ | ||
| 266 | 248 | #> |
| 267 | 249 | </div> |
| 268 | 250 | </div> |
| 269 | 251 | |
| 270 | - <?php | |
| 271 | - /* | |
| 272 | - ?> | |
| 252 | + <?php /* ?> | |
| 273 | 253 | <div class="elementor-control-media__warnings" role="alert" style="display: none;"> |
| 274 | 254 | <?php |
| 275 | 255 | Hints::get_notice_template( [ |
| 276 | 256 | 'type' => 'warning', |
| @@ -278,11 +258,28 @@ | ||
| 278 | 258 | 'icon' => true, |
| 279 | 259 | ] ); |
| 280 | 260 | ?> |
| 281 | 261 | </div> |
| 282 | - <?php | |
| 283 | - */ ?> | |
| 284 | - <?php $this->maybe_display_io_hints(); ?> | |
| 262 | + <?php */ ?> | |
| 263 | + | |
| 264 | + <?php if ( Hints::should_display_hint( 'image-optimization' ) ) : ?> | |
| 265 | + <div class="elementor-control-media__promotions" role="alert" style="display: none;"> | |
| 266 | + <?php | |
| 267 | + Hints::get_notice_template( [ | |
| 268 | + 'display' => ! Hints::is_dismissed( 'image-optimization' ), | |
| 269 | + 'type' => 'info', | |
| 270 | + 'content' => __( 'Don’t let unoptimized images be the downfall of your site’s performance. Use Image Optimizer!', 'elementor' ), | |
| 271 | + 'icon' => true, | |
| 272 | + 'dismissible' => 'image_optimizer_hint', | |
| 273 | + 'button_text' => Hints::is_plugin_installed( 'image-optimization' ) ? __( 'Activate Plugin', 'elementor' ) : __( 'Install Plugin', 'elementor' ), | |
| 274 | + 'button_event' => 'image_optimizer_hint', | |
| 275 | + 'button_data' => [ | |
| 276 | + 'action_url' => Hints::get_plugin_action_url( 'image-optimization' ), | |
| 277 | + ], | |
| 278 | + ] ); ?> | |
| 279 | + </div> | |
| 280 | + <?php endif; ?> | |
| 281 | + | |
| 285 | 282 | </div> |
| 286 | 283 | <# } /* endif isViewable() */ else { #> |
| 287 | 284 | <div class="elementor-control-media__file elementor-control-preview-area"> |
| 288 | 285 | <div class="elementor-control-media__file__content"> |
| @@ -294,13 +291,13 @@ | ||
| 294 | 291 | <div class="elementor-control-media__file__content__info__name"></div> |
| 295 | 292 | </div> |
| 296 | 293 | </div> |
| 297 | 294 | <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' ); ?>"> | |
| 295 | + <div class="elementor-control-media__remove elementor-control-media__file__controls__remove" title="<?php echo esc_attr__( 'Remove', 'elementor' ); ?>"> | |
| 299 | 296 | <i class="eicon-trash-o" aria-hidden="true"></i> |
| 300 | 297 | <span class="elementor-screen-only"><?php echo esc_html__( 'Remove', 'elementor' ); ?></span> |
| 301 | 298 | </div> |
| 302 | - <div class="elementor-control-media__file__controls__upload-button elementor-control-media-upload-button" data-tooltip="<?php echo esc_attr__( 'Upload', 'elementor' ); ?>"> | |
| 299 | + <div class="elementor-control-media__file__controls__upload-button elementor-control-media-upload-button" title="<?php echo esc_attr__( 'Upload', 'elementor' ); ?>"> | |
| 303 | 300 | <i class="eicon-upload" aria-hidden="true"></i> |
| 304 | 301 | <span class="elementor-screen-only"><?php echo esc_html__( 'Upload', 'elementor' ); ?></span> |
| 305 | 302 | </div> |
| 306 | 303 | </div> |
| @@ -321,10 +318,8 @@ | ||
| 321 | 318 | <?php endforeach; ?> |
| 322 | 319 | </select> |
| 323 | 320 | </div> |
| 324 | 321 | </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 | 322 | </div> |
| 328 | 323 | <# } #> |
| 329 | 324 | |
| 330 | 325 | <input type="hidden" data-setting="{{ data.name }}"/> |
| @@ -331,70 +326,9 @@ | ||
| 331 | 326 | </div> |
| 332 | 327 | <?php |
| 333 | 328 | } |
| 334 | 329 | |
| 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 { | |
| 330 | + private function get_image_sizes() : array { | |
| 397 | 331 | $wp_image_sizes = Group_Control_Image_Size::get_all_image_sizes(); |
| 398 | 332 | |
| 399 | 333 | $image_sizes = []; |
| 400 | 334 | |
| @@ -493,12 +427,8 @@ | ||
| 493 | 427 | } |
| 494 | 428 | |
| 495 | 429 | $alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ); |
| 496 | 430 | if ( ! $alt ) { |
| 497 | - if ( Utils::has_invalid_post_permissions( $attachment ) ) { | |
| 498 | - return ''; | |
| 499 | - } | |
| 500 | - | |
| 501 | 431 | $alt = $attachment->post_excerpt; |
| 502 | 432 | if ( ! $alt ) { |
| 503 | 433 | $alt = $attachment->post_title; |
| 504 | 434 | } |
| @@ -517,8 +447,8 @@ | ||
| 517 | 447 | |
| 518 | 448 | return wp_get_attachment_image_url( $control_value['id'], $control_value['size'] ); |
| 519 | 449 | } |
| 520 | 450 | |
| 521 | - public static function sanitise_text( $text ) { | |
| 522 | - return esc_attr( strip_tags( $text ) ); | |
| 451 | + public static function sanitise_text( $string ) { | |
| 452 | + return esc_attr( strip_tags( $string ) ); | |
| 523 | 453 | } |
| 524 | 454 | } |