EWWW Image Optimizer - Version 6.4.2

Version Description

  • added: JS/Picture WebP rewriters support FacetWP AJAX responses
  • fixed: errors from posix_getpwuid() and posix_getgrgid() not handled correctly
  • fixed: PNGOUT download URLs were moved, causing auto-install to fail
  • fixed: Easy IO was adding srcset markup for SVG images
Download this release

Release Info

Developer nosilver4u
Plugin Icon 128x128 EWWW Image Optimizer
Version 6.4.2
Comparing to
See all releases

Code changes from version 6.4.1 to 6.4.2

aux-optimize.php CHANGED
@@ -29,14 +29,18 @@ function ewww_image_optimizer_aux_images() {
29
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
30
  ewwwio_debug_info();
31
  echo '<div style="clear:both;"></div>';
32
- echo '<p><b>' . esc_html__( 'Debugging Information', 'ewww-image-optimizer' ) . ':</b> <button id="ewww-copy-debug" class="button button-secondary" type="button">' . esc_html__( 'Copy', 'ewww-image-optimizer' ) . '</button>';
33
- if ( ewwwio_is_file( WP_CONTENT_DIR . '/ewww/debug.log' ) ) {
34
- echo "&emsp;<a href='" . esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_view_debug_log' ) ) . "'>" .
35
- esc_html( 'View Debug Log', 'ewww-image-optimizer' ) . "</a> - <a href='" .
36
- esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_delete_debug_log' ) ) . "'>" .
37
- esc_html( 'Remove Debug Log', 'ewww-image-optimizer' ) . '</a>';
 
 
 
38
  }
39
- echo '</p>';
 
40
  echo '<div id="ewww-debug-info" contenteditable="true">' .
41
  wp_kses(
42
  $eio_debug,
@@ -481,7 +485,7 @@ function ewww_image_optimizer_aux_images_webp_clean() {
481
  $completed++;
482
  $file = ewww_image_optimizer_absolutize_path( $optimized_image['path'] );
483
  ewwwio_debug_message( "looking for $file.webp" );
484
- if ( ! ewww_image_optimizer_stream_wrapped( $file ) && ewwwio_is_file( $file . '.webp' ) ) {
485
  ewwwio_debug_message( "removing: $file.webp" );
486
  if ( ewwwio_delete_file( $file . '.webp' ) ) {
487
  ewwwio_debug_message( "removed $file.webp" );
@@ -493,7 +497,7 @@ function ewww_image_optimizer_aux_images_webp_clean() {
493
  if ( ! empty( $optimized_image['converted'] ) ) {
494
  $file = ewww_image_optimizer_absolutize_path( $optimized_image['converted'] );
495
  ewwwio_debug_message( "$file was converted, checking if webp version exists" );
496
- if ( ! ewww_image_optimizer_stream_wrapped( $file ) && ewwwio_is_file( $file . '.webp' ) ) {
497
  ewwwio_debug_message( "removing: $file.webp" );
498
  if ( ewwwio_delete_file( $file . '.webp' ) ) {
499
  ewwwio_debug_message( "removed $file.webp" );
@@ -545,17 +549,21 @@ function ewww_image_optimizer_delete_webp() {
545
  $image['path'] = ewww_image_optimizer_absolutize_path( $image['path'] );
546
  }
547
  if ( ! empty( $image['path'] ) ) {
548
- if ( ewwwio_is_file( $image['path'] . '.webp' ) ) {
549
  ewwwio_debug_message( 'removing: ' . $image['path'] . '.webp' );
550
  ewwwio_delete_file( $image['path'] . '.webp' );
551
  }
552
  $webpfileold = preg_replace( '/\.\w+$/', '.webp', $image['path'] );
553
- if ( ewwwio_is_file( $webpfileold ) ) {
 
 
 
 
554
  ewwwio_debug_message( 'removing: ' . $webpfileold );
555
  ewwwio_delete_file( $webpfileold );
556
  }
557
  }
558
- if ( ! empty( $image['converted'] ) && ewwwio_is_file( $image['converted'] . '.webp' ) ) {
559
  ewwwio_debug_message( 'removing: ' . $image['converted'] . '.webp' );
560
  ewwwio_delete_file( $image['converted'] . '.webp' );
561
  }
@@ -583,11 +591,15 @@ function ewww_image_optimizer_delete_webp() {
583
  // Delete any residual webp versions.
584
  $webpfile = $file_path . '.webp';
585
  $webpfileold = preg_replace( '/\.\w+$/', '.webp', $file_path );
586
- if ( ewwwio_is_file( $webpfile ) ) {
587
  ewwwio_debug_message( 'removing: ' . $webpfile );
588
  ewwwio_delete_file( $webpfile );
589
  }
590
- if ( ewwwio_is_file( $webpfileold ) ) {
 
 
 
 
591
  ewwwio_debug_message( 'removing: ' . $webpfileold );
592
  ewwwio_delete_file( $webpfileold );
593
  }
@@ -601,7 +613,7 @@ function ewww_image_optimizer_delete_webp() {
601
  $orig_path = $base_dir . wp_basename( $meta['original_image'] );
602
  // Delete any residual webp versions.
603
  $webpfile = $orig_path . '.webp';
604
- if ( ewwwio_is_file( $webpfile ) ) {
605
  ewwwio_debug_message( 'removing: ' . $webpfile );
606
  ewwwio_delete_file( $webpfile );
607
  }
@@ -618,11 +630,15 @@ function ewww_image_optimizer_delete_webp() {
618
  // Delete any residual webp versions.
619
  $webpfile = $base_dir . wp_basename( $data['file'] ) . '.webp';
620
  $webpfileold = preg_replace( '/\.\w+$/', '.webp', $base_dir . wp_basename( $data['file'] ) );
621
- if ( ewwwio_is_file( $webpfile ) ) {
622
  ewwwio_debug_message( 'removing: ' . $webpfile );
623
  ewwwio_delete_file( $webpfile );
624
  }
625
- if ( ewwwio_is_file( $webpfileold ) ) {
 
 
 
 
626
  ewwwio_debug_message( 'removing: ' . $webpfileold );
627
  ewwwio_delete_file( $webpfileold );
628
  }
@@ -631,18 +647,26 @@ function ewww_image_optimizer_delete_webp() {
631
  unlink( $s3_dir . wp_basename( $data['file'] ) . '.webp' );
632
  }
633
  // If the original resize is set, and still exists.
634
- if ( ! empty( $data['orig_file'] ) && ewwwio_is_file( $base_dir . $data['orig_file'] ) . '.webp' ) {
 
 
 
 
635
  ewwwio_debug_message( 'removing: ' . $base_dir . $data['orig_file'] . '.webp' );
636
  ewwwio_delete_file( $base_dir . $data['orig_file'] . '.webp' );
637
  }
638
  }
639
  }
640
- if ( ewwwio_is_file( $file_path . '.webp' ) ) {
641
  ewwwio_debug_message( 'removing: ' . $file_path . '.webp' );
642
  ewwwio_delete_file( $image['path'] . '.webp' );
643
  }
644
  $webpfileold = preg_replace( '/\.\w+$/', '.webp', $file_path );
645
- if ( ewwwio_is_file( $webpfileold ) ) {
 
 
 
 
646
  ewwwio_debug_message( 'removing: ' . $webpfileold );
647
  ewwwio_delete_file( $webpfileold );
648
  }
29
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
30
  ewwwio_debug_info();
31
  echo '<div style="clear:both;"></div>';
32
+ if ( ewwwio_is_file( EWWWIO_CONTENT_DIR . 'debug.log' ) ) {
33
+ ?>
34
+ <h2><?php esc_html_e( 'Debug Log', 'ewww-image-optimizer' ); ?></h2>
35
+ <p>
36
+ <a target='_blank' href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_view_debug_log' ) ); ?>'><?php esc_html_e( 'View Log', 'ewww-image-optimizer' ); ?></a> -
37
+ <a href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_delete_debug_log' ) ); ?>'><?php esc_html_e( 'Clear Log', 'ewww-image-optimizer' ); ?></a>
38
+ </p>
39
+ <p><a class='button button-secondary' target='_blank' href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_download_debug_log' ) ); ?>'><?php esc_html_e( 'Download Log', 'ewww-image-optimizer' ); ?></a></p>
40
+ <?php
41
  }
42
+ echo '<h2>' . esc_html__( 'System Info', 'ewww-image-optimizer' ) . '</h2>';
43
+ echo '<p><button id="ewww-copy-debug" class="button button-secondary" type="button">' . esc_html__( 'Copy', 'ewww-image-optimizer' ) . '</button></p>';
44
  echo '<div id="ewww-debug-info" contenteditable="true">' .
45
  wp_kses(
46
  $eio_debug,
485
  $completed++;
486
  $file = ewww_image_optimizer_absolutize_path( $optimized_image['path'] );
487
  ewwwio_debug_message( "looking for $file.webp" );
488
+ if ( ! ewww_image_optimizer_stream_wrapped( $file ) && ewwwio_is_file( $file ) && ewwwio_is_file( $file . '.webp' ) ) {
489
  ewwwio_debug_message( "removing: $file.webp" );
490
  if ( ewwwio_delete_file( $file . '.webp' ) ) {
491
  ewwwio_debug_message( "removed $file.webp" );
497
  if ( ! empty( $optimized_image['converted'] ) ) {
498
  $file = ewww_image_optimizer_absolutize_path( $optimized_image['converted'] );
499
  ewwwio_debug_message( "$file was converted, checking if webp version exists" );
500
+ if ( ! ewww_image_optimizer_stream_wrapped( $file ) && ewwwio_is_file( $file ) && ewwwio_is_file( $file . '.webp' ) ) {
501
  ewwwio_debug_message( "removing: $file.webp" );
502
  if ( ewwwio_delete_file( $file . '.webp' ) ) {
503
  ewwwio_debug_message( "removed $file.webp" );
549
  $image['path'] = ewww_image_optimizer_absolutize_path( $image['path'] );
550
  }
551
  if ( ! empty( $image['path'] ) ) {
552
+ if ( ewwwio_is_file( $image['path'] ) && ewwwio_is_file( $image['path'] . '.webp' ) ) {
553
  ewwwio_debug_message( 'removing: ' . $image['path'] . '.webp' );
554
  ewwwio_delete_file( $image['path'] . '.webp' );
555
  }
556
  $webpfileold = preg_replace( '/\.\w+$/', '.webp', $image['path'] );
557
+ if (
558
+ ! preg_match( '/\.webp$/', $image['path'] ) &&
559
+ ewwwio_is_file( $image['path'] ) &&
560
+ ewwwio_is_file( $webpfileold )
561
+ ) {
562
  ewwwio_debug_message( 'removing: ' . $webpfileold );
563
  ewwwio_delete_file( $webpfileold );
564
  }
565
  }
566
+ if ( ! empty( $image['converted'] ) && ewwwio_is_file( $image['converted'] ) && ewwwio_is_file( $image['converted'] . '.webp' ) ) {
567
  ewwwio_debug_message( 'removing: ' . $image['converted'] . '.webp' );
568
  ewwwio_delete_file( $image['converted'] . '.webp' );
569
  }
591
  // Delete any residual webp versions.
592
  $webpfile = $file_path . '.webp';
593
  $webpfileold = preg_replace( '/\.\w+$/', '.webp', $file_path );
594
+ if ( ewwwio_is_file( $file_path ) && ewwwio_is_file( $webpfile ) ) {
595
  ewwwio_debug_message( 'removing: ' . $webpfile );
596
  ewwwio_delete_file( $webpfile );
597
  }
598
+ if (
599
+ ! preg_match( '/\.webp$/', $file_path ) &&
600
+ ewwwio_is_file( $file_path ) &&
601
+ ewwwio_is_file( $webpfileold )
602
+ ) {
603
  ewwwio_debug_message( 'removing: ' . $webpfileold );
604
  ewwwio_delete_file( $webpfileold );
605
  }
613
  $orig_path = $base_dir . wp_basename( $meta['original_image'] );
614
  // Delete any residual webp versions.
615
  $webpfile = $orig_path . '.webp';
616
+ if ( ewwwio_is_file( $orig_path ) && ewwwio_is_file( $webpfile ) ) {
617
  ewwwio_debug_message( 'removing: ' . $webpfile );
618
  ewwwio_delete_file( $webpfile );
619
  }
630
  // Delete any residual webp versions.
631
  $webpfile = $base_dir . wp_basename( $data['file'] ) . '.webp';
632
  $webpfileold = preg_replace( '/\.\w+$/', '.webp', $base_dir . wp_basename( $data['file'] ) );
633
+ if ( ewwwio_is_file( $base_dir . wp_basename( $data['file'] ) ) && ewwwio_is_file( $webpfile ) ) {
634
  ewwwio_debug_message( 'removing: ' . $webpfile );
635
  ewwwio_delete_file( $webpfile );
636
  }
637
+ if (
638
+ ! preg_match( '/\.webp$/', $base_dir . wp_basename( $data['file'] ) ) &&
639
+ ewwwio_is_file( $base_dir . wp_basename( $data['file'] ) ) &&
640
+ ewwwio_is_file( $webpfileold )
641
+ ) {
642
  ewwwio_debug_message( 'removing: ' . $webpfileold );
643
  ewwwio_delete_file( $webpfileold );
644
  }
647
  unlink( $s3_dir . wp_basename( $data['file'] ) . '.webp' );
648
  }
649
  // If the original resize is set, and still exists.
650
+ if (
651
+ ! empty( $data['orig_file'] ) &&
652
+ ewwwio_is_file( $base_dir . $data['orig_file'] ) &&
653
+ ewwwio_is_file( $base_dir . $data['orig_file'] . '.webp' )
654
+ ) {
655
  ewwwio_debug_message( 'removing: ' . $base_dir . $data['orig_file'] . '.webp' );
656
  ewwwio_delete_file( $base_dir . $data['orig_file'] . '.webp' );
657
  }
658
  }
659
  }
660
+ if ( ewwwio_is_file( $file_path ) && ewwwio_is_file( $file_path . '.webp' ) ) {
661
  ewwwio_debug_message( 'removing: ' . $file_path . '.webp' );
662
  ewwwio_delete_file( $image['path'] . '.webp' );
663
  }
664
  $webpfileold = preg_replace( '/\.\w+$/', '.webp', $file_path );
665
+ if (
666
+ ! preg_match( '/\.webp$/', $file_path ) &&
667
+ ewwwio_is_file( $file_path ) &&
668
+ ewwwio_is_file( $webpfileold )
669
+ ) {
670
  ewwwio_debug_message( 'removing: ' . $webpfileold );
671
  ewwwio_delete_file( $webpfileold );
672
  }
changelog.txt CHANGED
@@ -1,3 +1,9 @@
 
 
 
 
 
 
1
  = 6.4.1 =
2
  * added: use decoding=async to prevent images from blocking text render
3
  * fixed: database upgrade fails on MySQL 8.0.x
1
+ = 6.4.2 =
2
+ * added: JS/Picture WebP rewriters support FacetWP AJAX responses
3
+ * fixed: errors from posix_getpwuid() and posix_getgrgid() not handled correctly
4
+ * fixed: PNGOUT download URLs were moved, causing auto-install to fail
5
+ * fixed: Easy IO was adding srcset markup for SVG images
6
+
7
  = 6.4.1 =
8
  * added: use decoding=async to prevent images from blocking text render
9
  * fixed: database upgrade fails on MySQL 8.0.x
classes/class-eio-js-webp.php CHANGED
@@ -67,7 +67,11 @@ class EIO_JS_Webp extends EIO_Page_Parser {
67
  $this->debug_message( '<b>' . __METHOD__ . '()</b>' );
68
 
69
  $uri = add_query_arg( null, null );
70
- $this->debug_message( "request uri is $uri" );
 
 
 
 
71
 
72
  add_filter( 'eio_do_js_webp', array( $this, 'should_process_page' ), 10, 2 );
73
 
@@ -87,6 +91,8 @@ class EIO_JS_Webp extends EIO_Page_Parser {
87
  add_filter( 'ngg_pro_lightbox_images_queue', array( $this, 'ngg_pro_lightbox_images_queue' ), 11 );
88
  // Filter for WooCommerce product variations (individual items).
89
  add_filter( 'woocommerce_available_variation', array( $this, 'woocommerce_available_variation' ) );
 
 
90
 
91
  // Load up the minified check script.
92
  $this->check_webp_script = file_get_contents( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'includes/check-webp.min.js' );
@@ -844,13 +850,32 @@ class EIO_JS_Webp extends EIO_Page_Parser {
844
  $variation['image']['srcset_webp'] = $webp_srcset;
845
  }
846
  }
847
- if ( $this->function_exists( 'print_r' ) ) {
848
- $this->debug_message( print_r( $variation, true ) );
849
- }
850
  }
851
  return $variation;
852
  }
853
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
854
  /**
855
  * Converts a URL to a file-system path and checks if the resulting path exists.
856
  *
67
  $this->debug_message( '<b>' . __METHOD__ . '()</b>' );
68
 
69
  $uri = add_query_arg( null, null );
70
+ if ( false === strpos( $uri, 'page=ewww-image-optimizer-options' ) ) {
71
+ $this->debug_message( "request uri is $uri" );
72
+ } else {
73
+ $this->debug_message( 'request uri is EWWW IO settings' );
74
+ }
75
 
76
  add_filter( 'eio_do_js_webp', array( $this, 'should_process_page' ), 10, 2 );
77
 
91
  add_filter( 'ngg_pro_lightbox_images_queue', array( $this, 'ngg_pro_lightbox_images_queue' ), 11 );
92
  // Filter for WooCommerce product variations (individual items).
93
  add_filter( 'woocommerce_available_variation', array( $this, 'woocommerce_available_variation' ) );
94
+ // Filter for FacetWP JSON responses.
95
+ add_filter( 'facetwp_render_output', array( $this, 'filter_facetwp_json_output' ) );
96
 
97
  // Load up the minified check script.
98
  $this->check_webp_script = file_get_contents( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'includes/check-webp.min.js' );
850
  $variation['image']['srcset_webp'] = $webp_srcset;
851
  }
852
  }
 
 
 
853
  }
854
  return $variation;
855
  }
856
 
857
+ /**
858
+ * Parse template data from FacetWP that will be included in JSON response.
859
+ * https://facetwp.com/documentation/developers/output/facetwp_render_output/
860
+ *
861
+ * @param array $output The full array of FacetWP data.
862
+ * @return array The FacetWP data with WebP images.
863
+ */
864
+ function filter_facetwp_json_output( $output ) {
865
+ $this->debug_message( '<b>' . __METHOD__ . '()</b>' );
866
+ if ( empty( $output['template'] ) || ! is_string( $output['template'] ) ) {
867
+ return $output;
868
+ }
869
+
870
+ $template = $this->filter_page_output( $output['template'] );
871
+ if ( $template ) {
872
+ $this->debug_message( 'template data modified' );
873
+ $output['template'] = $template;
874
+ }
875
+
876
+ return $output;
877
+ }
878
+
879
  /**
880
  * Converts a URL to a file-system path and checks if the resulting path exists.
881
  *
classes/class-eio-lazy-load.php CHANGED
@@ -80,7 +80,11 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
80
  $this->debug_message( '<b>' . __METHOD__ . '()</b>' );
81
 
82
  $uri = add_query_arg( null, null );
83
- $this->debug_message( "request uri is $uri" );
 
 
 
 
84
 
85
  add_filter( 'eio_do_lazyload', array( $this, 'should_process_page' ), 10, 2 );
86
 
@@ -779,10 +783,6 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
779
  function filter_facetwp_json_output( $output ) {
780
  $this->debug_message( '<b>' . __METHOD__ . '()</b>' );
781
  if ( empty( $output['template'] ) || ! is_string( $output['template'] ) ) {
782
- $this->debug_message( 'no template data available' );
783
- if ( $this->function_exists( 'print_r' ) ) {
784
- $this->debug_message( print_r( $output, true ) );
785
- }
786
  return $output;
787
  }
788
 
@@ -1228,6 +1228,7 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
1228
  );
1229
  return;
1230
  }
 
1231
  /**
1232
  * Load minified inline version of lazysizes script.
1233
  */
80
  $this->debug_message( '<b>' . __METHOD__ . '()</b>' );
81
 
82
  $uri = add_query_arg( null, null );
83
+ if ( false === strpos( $uri, 'page=ewww-image-optimizer-options' ) ) {
84
+ $this->debug_message( "request uri is $uri" );
85
+ } else {
86
+ $this->debug_message( 'request uri is EWWW IO settings' );
87
+ }
88
 
89
  add_filter( 'eio_do_lazyload', array( $this, 'should_process_page' ), 10, 2 );
90
 
783
  function filter_facetwp_json_output( $output ) {
784
  $this->debug_message( '<b>' . __METHOD__ . '()</b>' );
785
  if ( empty( $output['template'] ) || ! is_string( $output['template'] ) ) {
 
 
 
 
786
  return $output;
787
  }
788
 
1228
  );
1229
  return;
1230
  }
1231
+
1232
  /**
1233
  * Load minified inline version of lazysizes script.
1234
  */
classes/class-eio-picture-webp.php CHANGED
@@ -46,7 +46,11 @@ class EIO_Picture_Webp extends EIO_Page_Parser {
46
  $this->debug_message( '<b>' . __METHOD__ . '()</b>' );
47
 
48
  $uri = add_query_arg( null, null );
49
- $this->debug_message( "request uri is $uri" );
 
 
 
 
50
 
51
  add_filter( 'eio_do_picture_webp', array( $this, 'should_process_page' ), 10, 2 );
52
 
@@ -68,6 +72,8 @@ class EIO_Picture_Webp extends EIO_Page_Parser {
68
  } else {
69
  add_filter( 'ewww_image_optimizer_filter_page_output', array( $this, 'filter_page_output' ), 10 );
70
  }
 
 
71
 
72
  $allowed_urls = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' );
73
  if ( $this->is_iterable( $allowed_urls ) ) {
@@ -338,6 +344,28 @@ class EIO_Picture_Webp extends EIO_Page_Parser {
338
  return $buffer;
339
  }
340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  /**
342
  * Converts a URL to a file-system path and checks if the resulting path exists.
343
  *
46
  $this->debug_message( '<b>' . __METHOD__ . '()</b>' );
47
 
48
  $uri = add_query_arg( null, null );
49
+ if ( false === strpos( $uri, 'page=ewww-image-optimizer-options' ) ) {
50
+ $this->debug_message( "request uri is $uri" );
51
+ } else {
52
+ $this->debug_message( 'request uri is EWWW IO settings' );
53
+ }
54
 
55
  add_filter( 'eio_do_picture_webp', array( $this, 'should_process_page' ), 10, 2 );
56
 
72
  } else {
73
  add_filter( 'ewww_image_optimizer_filter_page_output', array( $this, 'filter_page_output' ), 10 );
74
  }
75
+ // Filter for FacetWP JSON responses.
76
+ add_filter( 'facetwp_render_output', array( $this, 'filter_facetwp_json_output' ) );
77
 
78
  $allowed_urls = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' );
79
  if ( $this->is_iterable( $allowed_urls ) ) {
344
  return $buffer;
345
  }
346
 
347
+ /**
348
+ * Parse template data from FacetWP that will be included in JSON response.
349
+ * https://facetwp.com/documentation/developers/output/facetwp_render_output/
350
+ *
351
+ * @param array $output The full array of FacetWP data.
352
+ * @return array The FacetWP data with WebP images.
353
+ */
354
+ function filter_facetwp_json_output( $output ) {
355
+ $this->debug_message( '<b>' . __METHOD__ . '()</b>' );
356
+ if ( empty( $output['template'] ) || ! is_string( $output['template'] ) ) {
357
+ return $output;
358
+ }
359
+
360
+ $template = $this->filter_page_output( $output['template'] );
361
+ if ( $template ) {
362
+ $this->debug_message( 'template data modified' );
363
+ $output['template'] = $template;
364
+ }
365
+
366
+ return $output;
367
+ }
368
+
369
  /**
370
  * Converts a URL to a file-system path and checks if the resulting path exists.
371
  *
classes/class-ewww-image.php CHANGED
@@ -170,7 +170,7 @@ class EWWW_Image {
170
  ewwwio_debug_message( 'failed to find a pending image with the parameters supplied' );
171
  return;
172
  }
173
- if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
174
  ewwwio_debug_message( print_r( $new_image, true ) );
175
  }
176
  $this->id = $new_image['id'];
@@ -194,7 +194,7 @@ class EWWW_Image {
194
  public function update_converted_attachment( $meta ) {
195
  ewwwio_debug_message( '<b>' . __METHOD__ . '()</b>' );
196
  $this->url = wp_get_attachment_url( $this->attachment_id );
197
- if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
198
  ewwwio_debug_message( print_r( $this, true ) );
199
  }
200
  // Update the file location in the post metadata based on the new path stored in the attachment metadata.
170
  ewwwio_debug_message( 'failed to find a pending image with the parameters supplied' );
171
  return;
172
  }
173
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
174
  ewwwio_debug_message( print_r( $new_image, true ) );
175
  }
176
  $this->id = $new_image['id'];
194
  public function update_converted_attachment( $meta ) {
195
  ewwwio_debug_message( '<b>' . __METHOD__ . '()</b>' );
196
  $this->url = wp_get_attachment_url( $this->attachment_id );
197
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
198
  ewwwio_debug_message( print_r( $this, true ) );
199
  }
200
  // Update the file location in the post metadata based on the new path stored in the attachment metadata.
classes/class-ewww-nextcellent.php CHANGED
@@ -131,7 +131,9 @@ if ( ! class_exists( 'EWWW_Nextcellent' ) ) {
131
  ewwwio_debug_message( 'failed verification' );
132
  return;
133
  }
134
- ewwwio_debug_message( print_r( $_REQUEST, true ) );
 
 
135
  if ( file_exists( $filename ) ) {
136
  if ( ! empty( $_POST['id'] ) ) {
137
  $id = (int) $_POST['id'];
131
  ewwwio_debug_message( 'failed verification' );
132
  return;
133
  }
134
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
135
+ ewwwio_debug_message( print_r( $_REQUEST, true ) );
136
+ }
137
  if ( file_exists( $filename ) ) {
138
  if ( ! empty( $_POST['id'] ) ) {
139
  $id = (int) $_POST['id'];
classes/class-exactdn.php CHANGED
@@ -130,7 +130,11 @@ if ( ! class_exists( 'ExactDN' ) ) {
130
  }
131
 
132
  $uri = add_query_arg( null, null );
133
- $this->debug_message( "request uri is $uri" );
 
 
 
 
134
 
135
  if ( '/robots.txt' === $uri || '/sitemap.xml' === $uri ) {
136
  return;
@@ -2364,15 +2368,17 @@ if ( ! class_exists( 'ExactDN' ) ) {
2364
 
2365
  if (
2366
  /** Short-circuit via exactdn_srcset_multipliers filter. */
2367
- is_array( $multipliers )
 
 
2368
  /** This filter is already documented in class-exactdn.php */
2369
- && ! apply_filters( 'exactdn_skip_image', false, $url, null )
2370
  /** The original url is valid/allowed. */
2371
- && $this->validate_image_url( $url )
2372
  /** Verify basic meta is intact. */
2373
- && isset( $image_meta['width'] ) && isset( $image_meta['height'] ) && isset( $image_meta['file'] )
2374
  /** Verify we have the requested width/height. */
2375
- && isset( $size_array[0] ) && isset( $size_array[1] )
2376
  ) {
2377
 
2378
  $fullwidth = $image_meta['width'];
@@ -2928,10 +2934,6 @@ if ( ! class_exists( 'ExactDN' ) ) {
2928
  function filter_facetwp_json_output( $output ) {
2929
  $this->debug_message( '<b>' . __METHOD__ . '()</b>' );
2930
  if ( empty( $output['template'] ) || ! is_string( $output['template'] ) ) {
2931
- $this->debug_message( 'no template data available' );
2932
- if ( $this->function_exists( 'print_r' ) ) {
2933
- $this->debug_message( print_r( $output, true ) );
2934
- }
2935
  return $output;
2936
  }
2937
  $this->filtering_the_page = true;
130
  }
131
 
132
  $uri = add_query_arg( null, null );
133
+ if ( false === strpos( $uri, 'page=ewww-image-optimizer-options' ) ) {
134
+ $this->debug_message( "request uri is $uri" );
135
+ } else {
136
+ $this->debug_message( 'request uri is EWWW IO settings' );
137
+ }
138
 
139
  if ( '/robots.txt' === $uri || '/sitemap.xml' === $uri ) {
140
  return;
2368
 
2369
  if (
2370
  /** Short-circuit via exactdn_srcset_multipliers filter. */
2371
+ is_array( $multipliers ) &&
2372
+ /** This isn't an SVG image. */
2373
+ '.svg' !== strtolower( substr( $image_meta['file'], -4 ) ) &&
2374
  /** This filter is already documented in class-exactdn.php */
2375
+ ! apply_filters( 'exactdn_skip_image', false, $url, null ) &&
2376
  /** The original url is valid/allowed. */
2377
+ $this->validate_image_url( $url ) &&
2378
  /** Verify basic meta is intact. */
2379
+ isset( $image_meta['width'] ) && isset( $image_meta['height'] ) && isset( $image_meta['file'] ) &&
2380
  /** Verify we have the requested width/height. */
2381
+ isset( $size_array[0] ) && isset( $size_array[1] )
2382
  ) {
2383
 
2384
  $fullwidth = $image_meta['width'];
2934
  function filter_facetwp_json_output( $output ) {
2935
  $this->debug_message( '<b>' . __METHOD__ . '()</b>' );
2936
  if ( empty( $output['template'] ) || ! is_string( $output['template'] ) ) {
 
 
 
 
2937
  return $output;
2938
  }
2939
  $this->filtering_the_page = true;
common.php CHANGED
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '641.0' );
18
 
19
  // Initialize a couple globals.
20
  $eio_debug = '';
@@ -204,10 +204,14 @@ add_action( 'admin_action_ewww_image_optimizer_network_remove_easyio', 'ewww_ima
204
  add_action( 'admin_action_ewww_image_optimizer_enable_force_gif2webp', 'ewww_image_optimizer_enable_force_gif2webp' );
205
  // Non-AJAX handler to retest async/background mode.
206
  add_action( 'admin_action_ewww_image_optimizer_retest_background_optimization', 'ewww_image_optimizer_retest_background_optimization' );
 
 
207
  // Non-AJAX handler to view the debug log, and display it.
208
  add_action( 'admin_action_ewww_image_optimizer_view_debug_log', 'ewww_image_optimizer_view_debug_log' );
209
  // Non-AJAX handler to delete the debug log, and reroute back to the settings page.
210
  add_action( 'admin_action_ewww_image_optimizer_delete_debug_log', 'ewww_image_optimizer_delete_debug_log' );
 
 
211
  // Non-AJAX handler to apply 6.2 current_timestamp db upgrade.
212
  add_action( 'admin_action_ewww_image_optimizer_620_upgrade', 'ewww_image_optimizer_620_upgrade' );
213
  // Check if WebP option was turned off and is now enabled.
@@ -706,8 +710,9 @@ function ewww_image_optimizer_save_network_settings() {
706
  update_site_option( 'ewww_image_optimizer_ll_autoscale', $ewww_image_optimizer_ll_autoscale );
707
  $ewww_image_optimizer_use_lqip = ( empty( $_POST['ewww_image_optimizer_use_lqip'] ) ? false : true );
708
  update_site_option( 'ewww_image_optimizer_use_lqip', $ewww_image_optimizer_use_lqip );
709
- $ewww_image_optimizer_ll_all_things = empty( $_POST['ewww_image_optimizer_ll_all_things'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['ewww_image_optimizer_ll_all_things'] ) );
710
- update_site_option( 'ewww_image_optimizer_ll_all_things', ewww_image_optimizer_exclude_paths_sanitize( $ewww_image_optimizer_ll_all_things ) );
 
711
  $ewww_image_optimizer_ll_exclude = empty( $_POST['ewww_image_optimizer_ll_exclude'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['ewww_image_optimizer_ll_exclude'] ) );
712
  update_site_option( 'ewww_image_optimizer_ll_exclude', ewww_image_optimizer_exclude_paths_sanitize( $ewww_image_optimizer_ll_exclude ) );
713
  $ewww_image_optimizer_maxmediawidth = empty( $_POST['ewww_image_optimizer_maxmediawidth'] ) ? 0 : (int) $_POST['ewww_image_optimizer_maxmediawidth'];
@@ -1083,6 +1088,7 @@ function ewww_image_optimizer_admin_init() {
1083
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_lazy_load', 'boolval' );
1084
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_ll_autoscale', 'boolval' );
1085
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_use_lqip', 'boolval' );
 
1086
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_ll_all_things', 'sanitize_text_field' );
1087
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_ll_exclude', 'ewww_image_optimizer_exclude_paths_sanitize' );
1088
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_resize_detection', 'boolval' );
@@ -1212,6 +1218,11 @@ function ewww_image_optimizer_admin_init() {
1212
  add_action( 'network_admin_notices', 'ewww_image_optimizer_php72_warning' );
1213
  add_action( 'admin_notices', 'ewww_image_optimizer_php72_warning' );
1214
  }
 
 
 
 
 
1215
  ewwwio_memory( __FUNCTION__ );
1216
  }
1217
 
@@ -2017,6 +2028,9 @@ function ewww_image_optimizer_scheduled_optimizaton_changed( $new_value, $old_va
2017
  * Display a notice that the user should run the bulk optimizer after WebP activation.
2018
  */
2019
  function ewww_image_optimizer_notice_webp_bulk() {
 
 
 
2020
  $already_done = ewww_image_optimizer_aux_images_table_count();
2021
  if ( $already_done > 50 ) {
2022
  echo "<div id='ewww-image-optimizer-pngout-success' class='notice notice-info'><p><a href='" .
@@ -2130,6 +2144,9 @@ function ewww_image_optimizer_easyio_site_initialized() {
2130
  * Let the user know the local domain appears to have changed from what Easy IO has recorded in the db.
2131
  */
2132
  function ewww_image_optimizer_notice_exactdn_domain_mismatch() {
 
 
 
2133
  global $exactdn;
2134
  if ( ! isset( $exactdn->upload_domain ) ) {
2135
  return;
@@ -2162,6 +2179,9 @@ function ewww_image_optimizer_notice_exactdn_domain_mismatch() {
2162
  * Let the user know they need to disable the WP Offload Media CNAME.
2163
  */
2164
  function ewww_image_optimizer_notice_exactdn_as3cf_cname_active() {
 
 
 
2165
  ?>
2166
  <div id="ewww-image-optimizer-notice-exactdn-as3cf-cname-active" class="notice notice-error">
2167
  <p>
@@ -2175,6 +2195,9 @@ function ewww_image_optimizer_notice_exactdn_as3cf_cname_active() {
2175
  * Inform the user that we disabled SP AIO to prevent conflicts with ExactDN.
2176
  */
2177
  function ewww_image_optimizer_notice_exactdn_sp_conflict() {
 
 
 
2178
  echo "<div id='ewww-image-optimizer-exactdn-sp' class='notice notice-warning'><p>" . esc_html__( 'ShortPixel image optimization has been disabled to prevent conflicts with Easy IO (EWWW Image Optimizer).', 'ewww-image-optimizer' ) . '</p></div>';
2179
  }
2180
 
@@ -2182,9 +2205,31 @@ function ewww_image_optimizer_notice_exactdn_sp_conflict() {
2182
  * Display a notice that PHP version 7.2 will be required in a future version.
2183
  */
2184
  function ewww_image_optimizer_php72_warning() {
 
 
 
2185
  echo '<div id="ewww-image-optimizer-notice-php72" class="notice notice-info"><p><a href="https://docs.ewww.io/article/55-upgrading-php" target="_blank" data-beacon-article="5ab2baa6042863478ea7c2ae">' . esc_html__( 'The next release of EWWW Image Optimizer will require PHP 7.2 or greater. Newer versions of PHP are significantly faster and much more secure. If you are unsure how to upgrade to a supported version, ask your webhost for instructions.', 'ewww-image-optimizer' ) . '</a></p></div>';
2186
  }
2187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2188
  /**
2189
  * Lets the user know their network settings have been saved.
2190
  */
@@ -2196,6 +2241,9 @@ function ewww_image_optimizer_network_settings_saved() {
2196
  * Warn the user that scheduled optimization will no longer work without background/async mode.
2197
  */
2198
  function ewww_image_optimizer_notice_schedule_noasync() {
 
 
 
2199
  global $ewwwio_upgrading;
2200
  if ( $ewwwio_upgrading ) {
2201
  return;
@@ -2215,6 +2263,9 @@ function ewww_image_optimizer_thumbnail_regen_notice() {
2215
  * Lets the user know WooCommerce has regenerated thumbnails and that they need to take action.
2216
  */
2217
  function ewww_image_optimizer_notice_wc_regen() {
 
 
 
2218
  echo "<div id='ewww-image-optimizer-wc-regen' class='notice notice-info is-dismissible'><p>" . esc_html__( 'EWWW Image Optimizer has detected a WooCommerce thumbnail regeneration. To optimize new thumbnails, you may run the Bulk Optimizer from the Media menu. This notice may be dismissed after the regeneration is complete.', 'ewww-image-optimizer' ) . '</p></div>';
2219
  }
2220
 
@@ -2241,6 +2292,9 @@ function ewww_image_optimizer_wc_regen_script() {
2241
  * Lets the user know LR Sync has regenerated thumbnails and that they need to take action.
2242
  */
2243
  function ewww_image_optimizer_notice_lr_sync() {
 
 
 
2244
  echo "<div id='ewww-image-optimizer-lr-sync' class='notice notice-info is-dismissible'><p>" . esc_html__( 'EWWW Image Optimizer has detected a WP/LR Sync process. To optimize new thumbnails, you may run the Bulk Optimizer from the Media menu. This notice may be dismissed after the Sync process is complete.', 'ewww-image-optimizer' ) . '</p></div>';
2245
  }
2246
 
@@ -2290,6 +2344,9 @@ function ewww_image_optimizer_notice_media_listmode() {
2290
  * Instruct the user to run the db upgrade.
2291
  */
2292
  function ewww_image_optimizer_620_upgrade_needed() {
 
 
 
2293
  echo "<div id='ewww-image-optimizer-upgrade-notice' class='notice notice-info'><p>" .
2294
  esc_html__( 'EWWW Image Optimizer needs to upgrade the image log table.', 'ewww-image-optimizer' ) . '<br>' .
2295
  '<a href="' . esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_620_upgrade' ) ) . '" class="button-secondary">' .
@@ -2301,6 +2358,9 @@ function ewww_image_optimizer_620_upgrade_needed() {
2301
  * Ask the user to leave a review for the plugin on wp.org.
2302
  */
2303
  function ewww_image_optimizer_notice_review() {
 
 
 
2304
  echo "<div id='ewww-image-optimizer-review' class='notice notice-info is-dismissible'><p>" .
2305
  esc_html__( "Hi, you've been using the EWWW Image Optimizer for a while, and we hope it has been a big help for you.", 'ewww-image-optimizer' ) . '<br>' .
2306
  esc_html__( 'If you could take a few moments to rate it on WordPress.org, we would really appreciate your help making the plugin better. Thanks!', 'ewww-image-optimizer' ) .
@@ -2331,6 +2391,9 @@ function ewww_image_optimizer_notice_review_script() {
2331
  * Inform the user of our beacon function so that they can opt-in.
2332
  */
2333
  function ewww_image_optimizer_notice_beacon() {
 
 
 
2334
  $optin_url = admin_url( 'admin.php?action=eio_opt_into_hs_beacon' );
2335
  $optout_url = admin_url( 'admin.php?action=eio_opt_out_of_hs_beacon' );
2336
  echo '<div id="ewww-image-optimizer-hs-beacon" class="notice notice-info"><p>' .
@@ -2346,6 +2409,9 @@ function ewww_image_optimizer_notice_beacon() {
2346
  * @global object $wpdb
2347
  */
2348
  function ewww_image_optimizer_notice_reoptimization() {
 
 
 
2349
  // Allows the user to reset all images back to 1 optimization, which clears the alert.
2350
  if ( ! empty( $_GET['ewww_reset_reopt_nonce'] ) && wp_verify_nonce( sanitize_key( $_GET['ewww_reset_reopt_nonce'] ), 'reset_reoptimization_counters' ) ) {
2351
  global $wpdb;
@@ -2590,7 +2656,7 @@ function ewww_image_optimizer_image_sizes_advanced( $sizes ) {
2590
  $sizes = array_flip( $sizes );
2591
  $flipped = true;
2592
  }
2593
- if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
2594
  ewwwio_debug_message( print_r( $sizes, true ) );
2595
  }
2596
  if ( ewww_image_optimizer_iterable( $disabled_sizes ) ) {
@@ -2619,7 +2685,7 @@ function ewww_image_optimizer_fallback_sizes( $sizes ) {
2619
  $disabled_sizes = ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_resizes', false, true );
2620
  $flipped = false;
2621
  if ( ! empty( $disabled_sizes ) ) {
2622
- if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
2623
  ewwwio_debug_message( print_r( $sizes, true ) );
2624
  }
2625
  if ( ewww_image_optimizer_iterable( $sizes ) && ewww_image_optimizer_iterable( $disabled_sizes ) ) {
@@ -2659,7 +2725,7 @@ function ewww_image_optimizer_handle_mpp_upload( $params ) {
2659
  */
2660
  function ewww_image_optimizer_handle_upload( $params ) {
2661
  ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
2662
- if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
2663
  ewwwio_debug_message( print_r( $params, true ) );
2664
  }
2665
  global $ewww_new_image;
@@ -3855,12 +3921,27 @@ function ewwwio_is_dir( $dir ) {
3855
  if ( empty( $upload_dir ) ) {
3856
  $upload_dir = $content_dir;
3857
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
3858
  $plugin_dir = realpath( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH );
3859
  if (
3860
  false === strpos( $dir, $upload_dir ) &&
3861
  false === strpos( $dir, $content_dir ) &&
3862
  false === strpos( $dir, $wp_dir ) &&
3863
- false === strpos( $dir, $plugin_dir )
 
 
3864
  ) {
3865
  return false;
3866
  }
@@ -3902,12 +3983,19 @@ function ewwwio_is_file( $file ) {
3902
  if ( empty( $tool_dir ) ) {
3903
  $tool_dir = $content_dir;
3904
  }
 
 
 
 
 
 
3905
  if (
3906
  false === strpos( $file, $upload_dir ) &&
3907
  false === strpos( $file, $content_dir ) &&
3908
  false === strpos( $file, $wp_dir ) &&
3909
  false === strpos( $file, $plugin_dir ) &&
3910
- false === strpos( $file, $tool_dir )
 
3911
  ) {
3912
  return false;
3913
  }
@@ -3991,6 +4079,7 @@ function ewwwio_chmod( $file, $mode ) {
3991
  }
3992
  return false;
3993
  }
 
3994
  /**
3995
  * Make sure an array/object can be parsed by a foreach().
3996
  *
@@ -5022,7 +5111,7 @@ function ewww_image_optimizer_cloud_key_verify_ajax() {
5022
  die( wp_json_encode( array( 'success' => esc_html__( 'Successfully validated API key, happy optimizing!', 'ewww-image-optimizer' ) ) ) );
5023
  } else {
5024
  ewwwio_debug_message( "verification failed via: $url" );
5025
- if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
5026
  ewwwio_debug_message( print_r( $result, true ) );
5027
  }
5028
  die( wp_json_encode( array( 'error' => esc_html__( 'Could not validate API key, please copy and paste your key to ensure it is correct.', 'ewww-image-optimizer' ) ) ) );
@@ -5147,7 +5236,7 @@ function ewww_image_optimizer_cloud_verify( $api_key, $cache = true ) {
5147
  ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_key', '' );
5148
  }
5149
  ewwwio_debug_message( "verification failed via: $url" );
5150
- if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
5151
  ewwwio_debug_message( print_r( $result, true ) );
5152
  }
5153
  }
@@ -6344,7 +6433,7 @@ function ewww_image_optimizer_update_table( $attachment, $opt_size, $orig_size,
6344
  if ( is_object( $ewww_image ) && $ewww_image instanceof EWWW_Image && $ewww_image->level ) {
6345
  $updates['level'] = $ewww_image->level;
6346
  }
6347
- if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
6348
  ewwwio_debug_message( print_r( $updates, true ) );
6349
  }
6350
  // Update information for the image.
@@ -6356,7 +6445,7 @@ function ewww_image_optimizer_update_table( $attachment, $opt_size, $orig_size,
6356
  )
6357
  );
6358
  if ( false === $record_updated ) {
6359
- if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
6360
  ewwwio_debug_message( 'db error: ' . print_r( $wpdb->last_error, true ) );
6361
  }
6362
  } else {
@@ -7657,7 +7746,7 @@ function ewww_image_optimizer_get_orientation( $file, $type ) {
7657
  ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
7658
  if ( function_exists( 'exif_read_data' ) && 'image/jpeg' === $type && ewwwio_is_readable( $file ) ) {
7659
  $exif = @exif_read_data( $file );
7660
- if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
7661
  ewwwio_debug_message( print_r( $exif, true ) );
7662
  }
7663
  if ( is_array( $exif ) && array_key_exists( 'Orientation', $exif ) ) {
@@ -8671,7 +8760,7 @@ function ewww_image_optimizer_detect_wpsf_location_lock() {
8671
  if ( function_exists( 'icwp_wpsf_init' ) ) {
8672
  ewwwio_debug_message( 'Shield Security detected' );
8673
  $shield_user_man = ewww_image_optimizer_get_option( 'icwp_wpsf_user_management_options' );
8674
- if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
8675
  ewwwio_debug_message( print_r( $shield_user_man, true ) );
8676
  }
8677
  if ( ! empty( $shield_user_man['session_lock_location'] ) && 'Y' === $shield_user_man['session_lock_location'] ) {
@@ -10189,7 +10278,7 @@ function ewww_image_optimizer_migrate_meta_to_db( $id, $meta, $bail_early = fals
10189
  }
10190
  }
10191
  $meta = ewww_image_optimizer_clean_meta( $meta );
10192
- if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
10193
  ewwwio_debug_message( print_r( $meta, true ) );
10194
  }
10195
  return $meta;
@@ -11044,6 +11133,7 @@ function ewwwio_debug_info() {
11044
  ewwwio_debug_version_info();
11045
  ewwwio_debug_message( 'ABSPATH: ' . ABSPATH );
11046
  ewwwio_debug_message( 'WP_CONTENT_DIR: ' . WP_CONTENT_DIR );
 
11047
  ewwwio_debug_message( 'home url (Site URL): ' . get_home_url() );
11048
  ewwwio_debug_message( 'site url (WordPress URL): ' . get_site_url() );
11049
  $upload_info = wp_get_upload_dir();
@@ -11182,7 +11272,7 @@ function ewwwio_debug_info() {
11182
  ewwwio_debug_message( 'resize existing images: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_existing' ) ? 'on' : 'off' ) );
11183
  ewwwio_debug_message( 'resize existing (non-media) images: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_other_existing' ) ? 'on' : 'off' ) );
11184
  $image_sizes = ewww_image_optimizer_get_image_sizes();
11185
- ewwwio_debug_message( 'disabled resizes:' );
11186
  $disabled_sizes = ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_resizes', false, true );
11187
  $disabled_sizes_opt = ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_resizes_opt', false, true );
11188
  foreach ( $image_sizes as $size => $dimensions ) {
@@ -11708,7 +11798,7 @@ function ewww_image_optimizer_rescue_mode() {
11708
  <?php endif; ?>
11709
  <?php if ( in_array( 'jswebp', $frontend_functions, true ) ) : ?>
11710
  <li>
11711
- <?php esc_html_e( 'Enabling Lazy Load alongside JS WebP enables better compatibility with some themes/plugins. Alternatively, you may try <picture> WebP Rewriting for a JavaScript-free delivery method.', 'ewww-image-optimizer' ); ?>
11712
  </li>
11713
  <?php endif; ?>
11714
  <?php if ( in_array( 'picturewebp', $frontend_functions, true ) ) : ?>
@@ -12329,7 +12419,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
12329
  $frontend_functions[] = __( 'JS WebP Rewriting', 'ewww-image-optimizer' );
12330
  }
12331
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) ) {
12332
- $frontend_functions[] = __( '<picture> WebP Rewriting', 'ewww-image-optimizer' );
12333
  }
12334
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
12335
  $frontend_functions[] = __( 'Easy IO', 'ewww-image-optimizer' );
@@ -12846,7 +12936,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
12846
  <td>
12847
  <label for='ewww_image_optimizer_ll_all_things'><strong><?php esc_html_e( 'External Background Images', 'ewww-image-optimizer' ); ?></strong></label>
12848
  <?php ewwwio_help_link( 'https://docs.ewww.io/article/74-lazy-load', '5c6c36ed042863543ccd2d9b' ); ?><br>
12849
- <input type='text' name='ewww_image_optimizer_ll_all_things' id='ewww_image_optimizer_all_things' class='regular-text' value='<?php echo esc_attr( ewww_image_optimizer_get_option( 'ewww_image_optimizer_ll_all_things' ) ); ?>' />
12850
  <p class='description'>
12851
  <?php esc_html_e( 'Specify class/id values of elements with CSS background images (comma-separated).', 'ewww-image-optimizer' ); ?>
12852
  <br>*<?php esc_html_e( 'Background images directly attached via inline style attributes will be lazy loaded by default.', 'ewww-image-optimizer' ); ?>
@@ -13067,9 +13157,9 @@ AddType image/webp .webp</pre>
13067
  </div>
13068
  <?php endif; ?>
13069
  <?php elseif ( $cf_host && ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) : ?>
13070
- <p><?php esc_html_e( 'Your site is using Cloudflare, please use JS WebP or <picture> WebP rewriting to prevent broken images on older browsers.', 'ewww-image-optimizer' ); ?></p>
13071
  <?php elseif ( $cloudways_host && ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) : ?>
13072
- <p><?php esc_html_e( 'Cloudways sites should use JS WebP or <picture> WebP rewriting to prevent broken images on older browsers.', 'ewww-image-optimizer' ); ?></p>
13073
  <?php endif; ?>
13074
  </td>
13075
  </tr>
@@ -13089,7 +13179,7 @@ AddType image/webp .webp</pre>
13089
  <th>&nbsp;</th>
13090
  <td>
13091
  <input type='checkbox' id='ewww_image_optimizer_picture_webp' name='ewww_image_optimizer_picture_webp' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) ); ?> />
13092
- <label for='ewww_image_optimizer_picture_webp'><strong><?php esc_html_e( '<picture> WebP Rewriting', 'ewww-image-optimizer' ); ?></strong></label>
13093
  <span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89,59443d162c7d3a0747cdf9f0' ); ?></span><br>
13094
  <p class='description'>
13095
  <?php esc_html_e( 'A JavaScript-free rewriting method using picture tags.', 'ewww-image-optimizer' ); ?>
@@ -13101,7 +13191,7 @@ AddType image/webp .webp</pre>
13101
  <tr class='ewww_image_optimizer_webp_rewrite_setting_container' <?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) && $webp_php_rewriting ? '' : ' style="display:none"'; ?>>
13102
  <td>&nbsp;</td>
13103
  <td>
13104
- <label for='ewww_image_optimizer_webp_rewrite_exclude'><strong><?php esc_html_e( 'JS WebP and <picture> Web Exclusions', 'ewww-image-optimizer' ); ?></strong></label><br>
13105
  <textarea id='ewww_image_optimizer_webp_rewrite_exclude' name='ewww_image_optimizer_webp_rewrite_exclude' rows='3' cols='60'><?php echo esc_html( $webp_exclude_paths ); ?></textarea>
13106
  <p class='description'><?php esc_html_e( 'One exclusion per line, no wildcards (*) needed. Use any string that matches the desired element(s) or exclude entire element types like "div", "span", etc.', 'ewww-image-optimizer' ); ?></p>
13107
  </td>
@@ -13150,7 +13240,7 @@ AddType image/webp .webp</pre>
13150
  </th>
13151
  <td>
13152
  <input type='checkbox' id='ewww_image_optimizer_webp_force' name='ewww_image_optimizer_webp_force' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ); ?> />
13153
- <span><?php esc_html_e( 'WebP images will be generated and saved for all images regardless of their size. JS and <picture> WebP rewriters will not check if a file exists, only that the domain matches the home url, or one of the provided WebP URLs.', 'ewww-image-optimizer' ); ?></span>
13154
  <?php if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
13155
  <p>
13156
  <a href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_enable_force_gif2webp' ) ); ?>'>
@@ -13735,21 +13825,37 @@ AddType image/webp .webp</pre>
13735
  <span><?php esc_html_e( 'Use this to provide information for support purposes, or if you feel comfortable digging around in the code to fix a problem you are experiencing.', 'ewww-image-optimizer' ); ?></span>
13736
  </td>
13737
  </tr>
13738
- </table>
13739
-
 
 
 
 
 
 
 
 
 
 
 
 
13740
  <?php if ( ! empty( $debug_info ) ) : ?>
13741
- <p class="debug-actions">
13742
- <strong><?php esc_html_e( 'Debugging Information', 'ewww-image-optimizer' ); ?>:</strong>
13743
- <button id="ewww-copy-debug" class="button button-secondary" type="button"><?php esc_html_e( 'Copy', 'ewww-image-optimizer' ); ?></button>
13744
- <?php if ( ewwwio_is_file( WP_CONTENT_DIR . '/ewww/debug.log' ) ) : ?>
13745
- &emsp;<a href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_view_debug_log' ) ); ?>'><?php esc_html_e( 'View Debug Log', 'ewww-image-optimizer' ); ?></a> -
13746
- <a href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_delete_debug_log' ) ); ?>'><?php esc_html_e( 'Remove Debug Log', 'ewww-image-optimizer' ); ?></a>
13747
- <?php endif; ?>
13748
- </p>
13749
- <div id="ewww-debug-info" contenteditable="true">
13750
- <?php echo wp_kses_post( $debug_info ); ?>
13751
- </div>
 
 
13752
  <?php endif; ?>
 
 
13753
  </div>
13754
 
13755
  <div id='ewww-contribute-settings'>
@@ -14144,6 +14250,22 @@ function ewww_image_optimizer_admin_bar_menu( $wp_admin_bar ) {
14144
  );
14145
  }
14146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14147
  /**
14148
  * Adds information to the in-memory debug log.
14149
  *
@@ -14184,9 +14306,9 @@ function ewwwio_debug_message( $message ) {
14184
  function ewww_image_optimizer_debug_log() {
14185
  global $eio_debug;
14186
  global $ewwwio_temp_debug;
14187
- $debug_log = WP_CONTENT_DIR . '/ewww/debug.log';
14188
- if ( ! is_dir( dirname( $debug_log ) ) && is_writable( WP_CONTENT_DIR ) ) {
14189
- wp_mkdir_p( dirname( $debug_log ) );
14190
  }
14191
  if (
14192
  ! empty( $eio_debug ) &&
@@ -14224,10 +14346,11 @@ function ewww_image_optimizer_view_debug_log() {
14224
  if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
14225
  wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
14226
  }
14227
- if ( ewwwio_is_file( WP_CONTENT_DIR . '/ewww/debug.log' ) ) {
 
14228
  ewwwio_ob_clean();
14229
  header( 'Content-Type: text/plain;charset=UTF-8' );
14230
- readfile( WP_CONTENT_DIR . '/ewww/debug.log' );
14231
  exit;
14232
  }
14233
  wp_die( esc_html__( 'The Debug Log is empty.', 'ewww-image-optimizer' ) );
@@ -14240,14 +14363,38 @@ function ewww_image_optimizer_delete_debug_log() {
14240
  if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
14241
  wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
14242
  }
14243
- if ( ewwwio_is_file( WP_CONTENT_DIR . '/ewww/debug.log' ) ) {
14244
- unlink( WP_CONTENT_DIR . '/ewww/debug.log' );
 
14245
  }
14246
  $sendback = wp_get_referer();
14247
  wp_safe_redirect( $sendback );
14248
  exit;
14249
  }
14250
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14251
  /**
14252
  * Adds version information to the in-memory debug log.
14253
  *
@@ -14460,4 +14607,3 @@ function ewwwio_preserve_strings() {
14460
  $string3 = __( 'Maximum Lossless Compression', 'ewww-image-optimizer' );
14461
  $string4 = __( 'Maximum Lossy Compression', 'ewww-image-optimizer' );
14462
  }
14463
- ?>
14
  exit;
15
  }
16
 
17
+ define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '642.0' );
18
 
19
  // Initialize a couple globals.
20
  $eio_debug = '';
204
  add_action( 'admin_action_ewww_image_optimizer_enable_force_gif2webp', 'ewww_image_optimizer_enable_force_gif2webp' );
205
  // Non-AJAX handler to retest async/background mode.
206
  add_action( 'admin_action_ewww_image_optimizer_retest_background_optimization', 'ewww_image_optimizer_retest_background_optimization' );
207
+ // Non-AJAX handler to disable debugging mode.
208
+ add_action( 'admin_action_ewww_image_optimizer_disable_debugging', 'ewww_image_optimizer_disable_debugging' );
209
  // Non-AJAX handler to view the debug log, and display it.
210
  add_action( 'admin_action_ewww_image_optimizer_view_debug_log', 'ewww_image_optimizer_view_debug_log' );
211
  // Non-AJAX handler to delete the debug log, and reroute back to the settings page.
212
  add_action( 'admin_action_ewww_image_optimizer_delete_debug_log', 'ewww_image_optimizer_delete_debug_log' );
213
+ // Non-AJAX handler to download the debug log.
214
+ add_action( 'admin_action_ewww_image_optimizer_download_debug_log', 'ewww_image_optimizer_download_debug_log' );
215
  // Non-AJAX handler to apply 6.2 current_timestamp db upgrade.
216
  add_action( 'admin_action_ewww_image_optimizer_620_upgrade', 'ewww_image_optimizer_620_upgrade' );
217
  // Check if WebP option was turned off and is now enabled.
710
  update_site_option( 'ewww_image_optimizer_ll_autoscale', $ewww_image_optimizer_ll_autoscale );
711
  $ewww_image_optimizer_use_lqip = ( empty( $_POST['ewww_image_optimizer_use_lqip'] ) ? false : true );
712
  update_site_option( 'ewww_image_optimizer_use_lqip', $ewww_image_optimizer_use_lqip );
713
+ // Using sanitize_text_field instead of textarea on purpose.
714
+ $ewww_image_optimizer_ll_all_things = empty( $_POST['ewww_image_optimizer_ll_all_things'] ) ? '' : sanitize_text_field( wp_unslash( $_POST['ewww_image_optimizer_ll_all_things'] ) );
715
+ update_site_option( 'ewww_image_optimizer_ll_all_things', $ewww_image_optimizer_ll_all_things );
716
  $ewww_image_optimizer_ll_exclude = empty( $_POST['ewww_image_optimizer_ll_exclude'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['ewww_image_optimizer_ll_exclude'] ) );
717
  update_site_option( 'ewww_image_optimizer_ll_exclude', ewww_image_optimizer_exclude_paths_sanitize( $ewww_image_optimizer_ll_exclude ) );
718
  $ewww_image_optimizer_maxmediawidth = empty( $_POST['ewww_image_optimizer_maxmediawidth'] ) ? 0 : (int) $_POST['ewww_image_optimizer_maxmediawidth'];
1088
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_lazy_load', 'boolval' );
1089
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_ll_autoscale', 'boolval' );
1090
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_use_lqip', 'boolval' );
1091
+ // Using sanitize_text_field instead of textarea on purpose.
1092
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_ll_all_things', 'sanitize_text_field' );
1093
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_ll_exclude', 'ewww_image_optimizer_exclude_paths_sanitize' );
1094
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_resize_detection', 'boolval' );
1218
  add_action( 'network_admin_notices', 'ewww_image_optimizer_php72_warning' );
1219
  add_action( 'admin_notices', 'ewww_image_optimizer_php72_warning' );
1220
  }
1221
+ if ( get_option( 'ewww_image_optimizer_debug' ) ) {
1222
+ add_action( 'admin_notices', 'ewww_image_optimizer_debug_enabled_notice' );
1223
+ } elseif ( get_site_option( 'ewww_image_optimizer_debug' ) && is_network_admin() ) {
1224
+ add_action( 'network_admin_notices', 'ewww_image_optimizer_debug_enabled_notice' );
1225
+ }
1226
  ewwwio_memory( __FUNCTION__ );
1227
  }
1228
 
2028
  * Display a notice that the user should run the bulk optimizer after WebP activation.
2029
  */
2030
  function ewww_image_optimizer_notice_webp_bulk() {
2031
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2032
+ return;
2033
+ }
2034
  $already_done = ewww_image_optimizer_aux_images_table_count();
2035
  if ( $already_done > 50 ) {
2036
  echo "<div id='ewww-image-optimizer-pngout-success' class='notice notice-info'><p><a href='" .
2144
  * Let the user know the local domain appears to have changed from what Easy IO has recorded in the db.
2145
  */
2146
  function ewww_image_optimizer_notice_exactdn_domain_mismatch() {
2147
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2148
+ return;
2149
+ }
2150
  global $exactdn;
2151
  if ( ! isset( $exactdn->upload_domain ) ) {
2152
  return;
2179
  * Let the user know they need to disable the WP Offload Media CNAME.
2180
  */
2181
  function ewww_image_optimizer_notice_exactdn_as3cf_cname_active() {
2182
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2183
+ return;
2184
+ }
2185
  ?>
2186
  <div id="ewww-image-optimizer-notice-exactdn-as3cf-cname-active" class="notice notice-error">
2187
  <p>
2195
  * Inform the user that we disabled SP AIO to prevent conflicts with ExactDN.
2196
  */
2197
  function ewww_image_optimizer_notice_exactdn_sp_conflict() {
2198
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2199
+ return;
2200
+ }
2201
  echo "<div id='ewww-image-optimizer-exactdn-sp' class='notice notice-warning'><p>" . esc_html__( 'ShortPixel image optimization has been disabled to prevent conflicts with Easy IO (EWWW Image Optimizer).', 'ewww-image-optimizer' ) . '</p></div>';
2202
  }
2203
 
2205
  * Display a notice that PHP version 7.2 will be required in a future version.
2206
  */
2207
  function ewww_image_optimizer_php72_warning() {
2208
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2209
+ return;
2210
+ }
2211
  echo '<div id="ewww-image-optimizer-notice-php72" class="notice notice-info"><p><a href="https://docs.ewww.io/article/55-upgrading-php" target="_blank" data-beacon-article="5ab2baa6042863478ea7c2ae">' . esc_html__( 'The next release of EWWW Image Optimizer will require PHP 7.2 or greater. Newer versions of PHP are significantly faster and much more secure. If you are unsure how to upgrade to a supported version, ask your webhost for instructions.', 'ewww-image-optimizer' ) . '</a></p></div>';
2212
  }
2213
 
2214
+ /**
2215
+ * Display a notice that debugging mode is enabled.
2216
+ */
2217
+ function ewww_image_optimizer_debug_enabled_notice() {
2218
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2219
+ return;
2220
+ }
2221
+ ?>
2222
+ <div id="ewww-image-optimizer-notice-debug" class="notice notice-info">
2223
+ <p>
2224
+ <?php esc_html_e( 'Debug mode is enabled in the EWWW Image Optimizer settings. Please be sure to turn Debugging off when you are done troubleshooting.', 'ewww-image-optimizer' ); ?>
2225
+ <a class='button button-secondary' href='<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?action=ewww_image_optimizer_disable_debugging' ), 'ewww_image_optimizer_options-options' ) ); ?>'>
2226
+ <?php esc_html_e( 'Disable Debugging', 'ewww-image-optimizer' ); ?>
2227
+ </a>
2228
+ </p>
2229
+ </div>
2230
+ <?php
2231
+ }
2232
+
2233
  /**
2234
  * Lets the user know their network settings have been saved.
2235
  */
2241
  * Warn the user that scheduled optimization will no longer work without background/async mode.
2242
  */
2243
  function ewww_image_optimizer_notice_schedule_noasync() {
2244
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2245
+ return;
2246
+ }
2247
  global $ewwwio_upgrading;
2248
  if ( $ewwwio_upgrading ) {
2249
  return;
2263
  * Lets the user know WooCommerce has regenerated thumbnails and that they need to take action.
2264
  */
2265
  function ewww_image_optimizer_notice_wc_regen() {
2266
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2267
+ return;
2268
+ }
2269
  echo "<div id='ewww-image-optimizer-wc-regen' class='notice notice-info is-dismissible'><p>" . esc_html__( 'EWWW Image Optimizer has detected a WooCommerce thumbnail regeneration. To optimize new thumbnails, you may run the Bulk Optimizer from the Media menu. This notice may be dismissed after the regeneration is complete.', 'ewww-image-optimizer' ) . '</p></div>';
2270
  }
2271
 
2292
  * Lets the user know LR Sync has regenerated thumbnails and that they need to take action.
2293
  */
2294
  function ewww_image_optimizer_notice_lr_sync() {
2295
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2296
+ return;
2297
+ }
2298
  echo "<div id='ewww-image-optimizer-lr-sync' class='notice notice-info is-dismissible'><p>" . esc_html__( 'EWWW Image Optimizer has detected a WP/LR Sync process. To optimize new thumbnails, you may run the Bulk Optimizer from the Media menu. This notice may be dismissed after the Sync process is complete.', 'ewww-image-optimizer' ) . '</p></div>';
2299
  }
2300
 
2344
  * Instruct the user to run the db upgrade.
2345
  */
2346
  function ewww_image_optimizer_620_upgrade_needed() {
2347
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2348
+ return;
2349
+ }
2350
  echo "<div id='ewww-image-optimizer-upgrade-notice' class='notice notice-info'><p>" .
2351
  esc_html__( 'EWWW Image Optimizer needs to upgrade the image log table.', 'ewww-image-optimizer' ) . '<br>' .
2352
  '<a href="' . esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_620_upgrade' ) ) . '" class="button-secondary">' .
2358
  * Ask the user to leave a review for the plugin on wp.org.
2359
  */
2360
  function ewww_image_optimizer_notice_review() {
2361
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2362
+ return;
2363
+ }
2364
  echo "<div id='ewww-image-optimizer-review' class='notice notice-info is-dismissible'><p>" .
2365
  esc_html__( "Hi, you've been using the EWWW Image Optimizer for a while, and we hope it has been a big help for you.", 'ewww-image-optimizer' ) . '<br>' .
2366
  esc_html__( 'If you could take a few moments to rate it on WordPress.org, we would really appreciate your help making the plugin better. Thanks!', 'ewww-image-optimizer' ) .
2391
  * Inform the user of our beacon function so that they can opt-in.
2392
  */
2393
  function ewww_image_optimizer_notice_beacon() {
2394
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2395
+ return;
2396
+ }
2397
  $optin_url = admin_url( 'admin.php?action=eio_opt_into_hs_beacon' );
2398
  $optout_url = admin_url( 'admin.php?action=eio_opt_out_of_hs_beacon' );
2399
  echo '<div id="ewww-image-optimizer-hs-beacon" class="notice notice-info"><p>' .
2409
  * @global object $wpdb
2410
  */
2411
  function ewww_image_optimizer_notice_reoptimization() {
2412
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
2413
+ return;
2414
+ }
2415
  // Allows the user to reset all images back to 1 optimization, which clears the alert.
2416
  if ( ! empty( $_GET['ewww_reset_reopt_nonce'] ) && wp_verify_nonce( sanitize_key( $_GET['ewww_reset_reopt_nonce'] ), 'reset_reoptimization_counters' ) ) {
2417
  global $wpdb;
2656
  $sizes = array_flip( $sizes );
2657
  $flipped = true;
2658
  }
2659
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
2660
  ewwwio_debug_message( print_r( $sizes, true ) );
2661
  }
2662
  if ( ewww_image_optimizer_iterable( $disabled_sizes ) ) {
2685
  $disabled_sizes = ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_resizes', false, true );
2686
  $flipped = false;
2687
  if ( ! empty( $disabled_sizes ) ) {
2688
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
2689
  ewwwio_debug_message( print_r( $sizes, true ) );
2690
  }
2691
  if ( ewww_image_optimizer_iterable( $sizes ) && ewww_image_optimizer_iterable( $disabled_sizes ) ) {
2725
  */
2726
  function ewww_image_optimizer_handle_upload( $params ) {
2727
  ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
2728
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
2729
  ewwwio_debug_message( print_r( $params, true ) );
2730
  }
2731
  global $ewww_new_image;
3921
  if ( empty( $upload_dir ) ) {
3922
  $upload_dir = $content_dir;
3923
  }
3924
+ if ( defined( 'EWWW_IMAGE_OPTIMIZER_TOOL_PATH' ) ) {
3925
+ $tool_dir = realpath( EWWW_IMAGE_OPTIMIZER_TOOL_PATH );
3926
+ $tool_dir = dirname( $tool_dir );
3927
+ }
3928
+ if ( empty( $tool_dir ) ) {
3929
+ $tool_dir = $content_dir;
3930
+ }
3931
+ if ( defined( 'EWWWIO_CONTENT_DIR' ) ) {
3932
+ $eio_content_dir = realpath( EWWWIO_CONTENT_DIR );
3933
+ }
3934
+ if ( empty( $eio_content_dir ) ) {
3935
+ $eio_content_dir = $content_dir;
3936
+ }
3937
  $plugin_dir = realpath( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH );
3938
  if (
3939
  false === strpos( $dir, $upload_dir ) &&
3940
  false === strpos( $dir, $content_dir ) &&
3941
  false === strpos( $dir, $wp_dir ) &&
3942
+ false === strpos( $dir, $plugin_dir ) &&
3943
+ false === strpos( $file, $tool_dir ) &&
3944
+ false === strpos( $file, $eio_content_dir )
3945
  ) {
3946
  return false;
3947
  }
3983
  if ( empty( $tool_dir ) ) {
3984
  $tool_dir = $content_dir;
3985
  }
3986
+ if ( defined( 'EWWWIO_CONTENT_DIR' ) ) {
3987
+ $eio_content_dir = realpath( EWWWIO_CONTENT_DIR );
3988
+ }
3989
+ if ( empty( $eio_content_dir ) ) {
3990
+ $eio_content_dir = $content_dir;
3991
+ }
3992
  if (
3993
  false === strpos( $file, $upload_dir ) &&
3994
  false === strpos( $file, $content_dir ) &&
3995
  false === strpos( $file, $wp_dir ) &&
3996
  false === strpos( $file, $plugin_dir ) &&
3997
+ false === strpos( $file, $tool_dir ) &&
3998
+ false === strpos( $file, $eio_content_dir )
3999
  ) {
4000
  return false;
4001
  }
4079
  }
4080
  return false;
4081
  }
4082
+
4083
  /**
4084
  * Make sure an array/object can be parsed by a foreach().
4085
  *
5111
  die( wp_json_encode( array( 'success' => esc_html__( 'Successfully validated API key, happy optimizing!', 'ewww-image-optimizer' ) ) ) );
5112
  } else {
5113
  ewwwio_debug_message( "verification failed via: $url" );
5114
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
5115
  ewwwio_debug_message( print_r( $result, true ) );
5116
  }
5117
  die( wp_json_encode( array( 'error' => esc_html__( 'Could not validate API key, please copy and paste your key to ensure it is correct.', 'ewww-image-optimizer' ) ) ) );
5236
  ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_key', '' );
5237
  }
5238
  ewwwio_debug_message( "verification failed via: $url" );
5239
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
5240
  ewwwio_debug_message( print_r( $result, true ) );
5241
  }
5242
  }
6433
  if ( is_object( $ewww_image ) && $ewww_image instanceof EWWW_Image && $ewww_image->level ) {
6434
  $updates['level'] = $ewww_image->level;
6435
  }
6436
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
6437
  ewwwio_debug_message( print_r( $updates, true ) );
6438
  }
6439
  // Update information for the image.
6445
  )
6446
  );
6447
  if ( false === $record_updated ) {
6448
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
6449
  ewwwio_debug_message( 'db error: ' . print_r( $wpdb->last_error, true ) );
6450
  }
6451
  } else {
7746
  ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
7747
  if ( function_exists( 'exif_read_data' ) && 'image/jpeg' === $type && ewwwio_is_readable( $file ) ) {
7748
  $exif = @exif_read_data( $file );
7749
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
7750
  ewwwio_debug_message( print_r( $exif, true ) );
7751
  }
7752
  if ( is_array( $exif ) && array_key_exists( 'Orientation', $exif ) ) {
8760
  if ( function_exists( 'icwp_wpsf_init' ) ) {
8761
  ewwwio_debug_message( 'Shield Security detected' );
8762
  $shield_user_man = ewww_image_optimizer_get_option( 'icwp_wpsf_user_management_options' );
8763
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
8764
  ewwwio_debug_message( print_r( $shield_user_man, true ) );
8765
  }
8766
  if ( ! empty( $shield_user_man['session_lock_location'] ) && 'Y' === $shield_user_man['session_lock_location'] ) {
10278
  }
10279
  }
10280
  $meta = ewww_image_optimizer_clean_meta( $meta );
10281
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && ewww_image_optimizer_function_exists( 'print_r' ) ) {
10282
  ewwwio_debug_message( print_r( $meta, true ) );
10283
  }
10284
  return $meta;
11133
  ewwwio_debug_version_info();
11134
  ewwwio_debug_message( 'ABSPATH: ' . ABSPATH );
11135
  ewwwio_debug_message( 'WP_CONTENT_DIR: ' . WP_CONTENT_DIR );
11136
+ ewwwio_debug_message( 'EWWWIO_CONTENT_DIR: ' . EWWWIO_CONTENT_DIR );
11137
  ewwwio_debug_message( 'home url (Site URL): ' . get_home_url() );
11138
  ewwwio_debug_message( 'site url (WordPress URL): ' . get_site_url() );
11139
  $upload_info = wp_get_upload_dir();
11272
  ewwwio_debug_message( 'resize existing images: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_existing' ) ? 'on' : 'off' ) );
11273
  ewwwio_debug_message( 'resize existing (non-media) images: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_other_existing' ) ? 'on' : 'off' ) );
11274
  $image_sizes = ewww_image_optimizer_get_image_sizes();
11275
+ ewwwio_debug_message( 'disabled sizes:' );
11276
  $disabled_sizes = ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_resizes', false, true );
11277
  $disabled_sizes_opt = ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_resizes_opt', false, true );
11278
  foreach ( $image_sizes as $size => $dimensions ) {
11798
  <?php endif; ?>
11799
  <?php if ( in_array( 'jswebp', $frontend_functions, true ) ) : ?>
11800
  <li>
11801
+ <?php esc_html_e( 'Enabling Lazy Load alongside JS WebP enables better compatibility with some themes/plugins. Alternatively, you may try Picture WebP Rewriting for a JavaScript-free delivery method.', 'ewww-image-optimizer' ); ?>
11802
  </li>
11803
  <?php endif; ?>
11804
  <?php if ( in_array( 'picturewebp', $frontend_functions, true ) ) : ?>
12419
  $frontend_functions[] = __( 'JS WebP Rewriting', 'ewww-image-optimizer' );
12420
  }
12421
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) ) {
12422
+ $frontend_functions[] = __( 'Picture WebP Rewriting', 'ewww-image-optimizer' );
12423
  }
12424
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
12425
  $frontend_functions[] = __( 'Easy IO', 'ewww-image-optimizer' );
12936
  <td>
12937
  <label for='ewww_image_optimizer_ll_all_things'><strong><?php esc_html_e( 'External Background Images', 'ewww-image-optimizer' ); ?></strong></label>
12938
  <?php ewwwio_help_link( 'https://docs.ewww.io/article/74-lazy-load', '5c6c36ed042863543ccd2d9b' ); ?><br>
12939
+ <textarea id='ewww_image_optimizer_ll_all_things' name='ewww_image_optimizer_ll_all_things' rows='3' cols='60'><?php echo esc_html( ewww_image_optimizer_get_option( 'ewww_image_optimizer_ll_all_things' ) ); ?></textarea>
12940
  <p class='description'>
12941
  <?php esc_html_e( 'Specify class/id values of elements with CSS background images (comma-separated).', 'ewww-image-optimizer' ); ?>
12942
  <br>*<?php esc_html_e( 'Background images directly attached via inline style attributes will be lazy loaded by default.', 'ewww-image-optimizer' ); ?>
13157
  </div>
13158
  <?php endif; ?>
13159
  <?php elseif ( $cf_host && ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) : ?>
13160
+ <p><?php esc_html_e( 'Your site is using Cloudflare, please use JS WebP or Picture WebP rewriting to prevent broken images on older browsers.', 'ewww-image-optimizer' ); ?></p>
13161
  <?php elseif ( $cloudways_host && ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) : ?>
13162
+ <p><?php esc_html_e( 'Cloudways sites should use JS WebP or Picture WebP rewriting to prevent broken images on older browsers.', 'ewww-image-optimizer' ); ?></p>
13163
  <?php endif; ?>
13164
  </td>
13165
  </tr>
13179
  <th>&nbsp;</th>
13180
  <td>
13181
  <input type='checkbox' id='ewww_image_optimizer_picture_webp' name='ewww_image_optimizer_picture_webp' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) ); ?> />
13182
+ <label for='ewww_image_optimizer_picture_webp'><strong><?php esc_html_e( 'Picture WebP Rewriting', 'ewww-image-optimizer' ); ?></strong></label>
13183
  <span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89,59443d162c7d3a0747cdf9f0' ); ?></span><br>
13184
  <p class='description'>
13185
  <?php esc_html_e( 'A JavaScript-free rewriting method using picture tags.', 'ewww-image-optimizer' ); ?>
13191
  <tr class='ewww_image_optimizer_webp_rewrite_setting_container' <?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) && $webp_php_rewriting ? '' : ' style="display:none"'; ?>>
13192
  <td>&nbsp;</td>
13193
  <td>
13194
+ <label for='ewww_image_optimizer_webp_rewrite_exclude'><strong><?php esc_html_e( 'JS WebP and Picture Web Exclusions', 'ewww-image-optimizer' ); ?></strong></label><br>
13195
  <textarea id='ewww_image_optimizer_webp_rewrite_exclude' name='ewww_image_optimizer_webp_rewrite_exclude' rows='3' cols='60'><?php echo esc_html( $webp_exclude_paths ); ?></textarea>
13196
  <p class='description'><?php esc_html_e( 'One exclusion per line, no wildcards (*) needed. Use any string that matches the desired element(s) or exclude entire element types like "div", "span", etc.', 'ewww-image-optimizer' ); ?></p>
13197
  </td>
13240
  </th>
13241
  <td>
13242
  <input type='checkbox' id='ewww_image_optimizer_webp_force' name='ewww_image_optimizer_webp_force' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ); ?> />
13243
+ <span><?php esc_html_e( 'WebP images will be generated and saved for all images regardless of their size. JS and Picture WebP rewriters will not check if a file exists, only that the domain matches the home url, or one of the provided WebP URLs.', 'ewww-image-optimizer' ); ?></span>
13244
  <?php if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
13245
  <p>
13246
  <a href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_enable_force_gif2webp' ) ); ?>'>
13825
  <span><?php esc_html_e( 'Use this to provide information for support purposes, or if you feel comfortable digging around in the code to fix a problem you are experiencing.', 'ewww-image-optimizer' ); ?></span>
13826
  </td>
13827
  </tr>
13828
+ <?php if ( ewwwio_is_file( EWWWIO_CONTENT_DIR . 'debug.log' ) ) : ?>
13829
+ <tr>
13830
+ <th scope='row'>
13831
+ <?php esc_html_e( 'Debug Log', 'ewww-image-optimizer' ); ?>
13832
+ </th>
13833
+ <td>
13834
+ <p>
13835
+ <a target='_blank' href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_view_debug_log' ) ); ?>'><?php esc_html_e( 'View Log', 'ewww-image-optimizer' ); ?></a> -
13836
+ <a href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_delete_debug_log' ) ); ?>'><?php esc_html_e( 'Clear Log', 'ewww-image-optimizer' ); ?></a>
13837
+ </p>
13838
+ <p><a class='button button-secondary' target='_blank' href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_download_debug_log' ) ); ?>'><?php esc_html_e( 'Download Log', 'ewww-image-optimizer' ); ?></a></p>
13839
+ </td>
13840
+ </tr>
13841
+ <?php endif; ?>
13842
  <?php if ( ! empty( $debug_info ) ) : ?>
13843
+ <tr>
13844
+ <th scope='row'>
13845
+ <?php esc_html_e( 'System Info', 'ewww-image-optimizer' ); ?>
13846
+ </th>
13847
+ <td>
13848
+ <p class="debug-actions">
13849
+ <button id="ewww-copy-debug" class="button button-secondary" type="button"><?php esc_html_e( 'Copy', 'ewww-image-optimizer' ); ?></button>
13850
+ </p>
13851
+ <div id="ewww-debug-info" contenteditable="true">
13852
+ <?php echo wp_kses_post( $debug_info ); ?>
13853
+ </div>
13854
+ </td>
13855
+ </tr>
13856
  <?php endif; ?>
13857
+ </table>
13858
+
13859
  </div>
13860
 
13861
  <div id='ewww-contribute-settings'>
14250
  );
14251
  }
14252
 
14253
+ /**
14254
+ * Disables the debugging option.
14255
+ */
14256
+ function ewww_image_optimizer_disable_debugging() {
14257
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
14258
+ wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
14259
+ }
14260
+ if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_options-options' ) ) {
14261
+ wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
14262
+ }
14263
+ ewww_image_optimizer_set_option( 'ewww_image_optimizer_debug', false );
14264
+ $sendback = wp_get_referer();
14265
+ wp_safe_redirect( $sendback );
14266
+ exit;
14267
+ }
14268
+
14269
  /**
14270
  * Adds information to the in-memory debug log.
14271
  *
14306
  function ewww_image_optimizer_debug_log() {
14307
  global $eio_debug;
14308
  global $ewwwio_temp_debug;
14309
+ $debug_log = EWWWIO_CONTENT_DIR . 'debug.log';
14310
+ if ( ! is_dir( EWWWIO_CONTENT_DIR ) && is_writable( dirname( EWWWIO_CONTENT_DIR ) ) ) {
14311
+ wp_mkdir_p( EWWWIO_CONTENT_DIR );
14312
  }
14313
  if (
14314
  ! empty( $eio_debug ) &&
14346
  if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
14347
  wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
14348
  }
14349
+ $debug_log = EWWWIO_CONTENT_DIR . 'debug.log';
14350
+ if ( ewwwio_is_file( $debug_log ) ) {
14351
  ewwwio_ob_clean();
14352
  header( 'Content-Type: text/plain;charset=UTF-8' );
14353
+ readfile( $debug_log );
14354
  exit;
14355
  }
14356
  wp_die( esc_html__( 'The Debug Log is empty.', 'ewww-image-optimizer' ) );
14363
  if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
14364
  wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
14365
  }
14366
+ $debug_log = EWWWIO_CONTENT_DIR . 'debug.log';
14367
+ if ( ewwwio_is_file( $debug_log ) && is_writable( $debug_log ) ) {
14368
+ unlink( $debug_log );
14369
  }
14370
  $sendback = wp_get_referer();
14371
  wp_safe_redirect( $sendback );
14372
  exit;
14373
  }
14374
 
14375
+ /**
14376
+ * Download the debug.log file from the wp-admin.
14377
+ */
14378
+ function ewww_image_optimizer_download_debug_log() {
14379
+ if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
14380
+ wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
14381
+ }
14382
+ $debug_log = EWWWIO_CONTENT_DIR . 'debug.log';
14383
+ if ( ewwwio_is_file( $debug_log ) ) {
14384
+ ewwwio_ob_clean();
14385
+ header( 'Content-Description: File Transfer' );
14386
+ header( 'Content-Type: text/plain;charset=UTF-8' );
14387
+ header( 'Content-Disposition: attachment; filename=ewwwio-debug-log-' . gmdate( 'Ymd-His' ) . '.txt' );
14388
+ header( 'Expires: 0' );
14389
+ header( 'Cache-Control: must-revalidate' );
14390
+ header( 'Pragma: public' );
14391
+ header( 'Content-Length: ' . filesize( $debug_log ) );
14392
+ readfile( $debug_log );
14393
+ exit;
14394
+ }
14395
+ wp_die( esc_html__( 'The Debug Log is empty.', 'ewww-image-optimizer' ) );
14396
+ }
14397
+
14398
  /**
14399
  * Adds version information to the in-memory debug log.
14400
  *
14607
  $string3 = __( 'Maximum Lossless Compression', 'ewww-image-optimizer' );
14608
  $string4 = __( 'Maximum Lossy Compression', 'ewww-image-optimizer' );
14609
  }
 
ewww-image-optimizer.php CHANGED
@@ -13,7 +13,7 @@ Plugin Name: EWWW Image Optimizer
13
  Plugin URI: https://wordpress.org/plugins/ewww-image-optimizer/
14
  Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
15
  Author: Exactly WWW
16
- Version: 6.4.1
17
  Requires at least: 5.6
18
  Requires PHP: 7.2
19
  Author URI: https://ewww.io/
@@ -28,14 +28,6 @@ if ( ! defined( 'EWWW_IO_CLOUD_PLUGIN' ) ) {
28
  define( 'EWWW_IO_CLOUD_PLUGIN', false );
29
  }
30
 
31
- if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_TOOL_PATH' ) ) {
32
- /**
33
- * The folder where we install optimization tools - MUST have a trailing slash.
34
- *
35
- * @var string EWWW_IMAGE_OPTIMIZER_TOOL_PATH
36
- */
37
- define( 'EWWW_IMAGE_OPTIMIZER_TOOL_PATH', WP_CONTENT_DIR . '/ewww/' );
38
- }
39
 
40
  // Check the PHP version.
41
  if ( ! defined( 'PHP_VERSION_ID' ) || PHP_VERSION_ID < 70200 ) {
@@ -80,6 +72,31 @@ if ( ! defined( 'PHP_VERSION_ID' ) || PHP_VERSION_ID < 70200 ) {
80
  * @var string EWWW_IMAGE_OPTIMIZER_IMAGES_PATH
81
  */
82
  define( 'EWWW_IMAGE_OPTIMIZER_IMAGES_PATH', plugin_dir_path( __FILE__ ) . 'images/' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  /**
85
  * All the 'unique' functions for the core EWWW IO plugin.
13
  Plugin URI: https://wordpress.org/plugins/ewww-image-optimizer/
14
  Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
15
  Author: Exactly WWW
16
+ Version: 6.4.2
17
  Requires at least: 5.6
18
  Requires PHP: 7.2
19
  Author URI: https://ewww.io/
28
  define( 'EWWW_IO_CLOUD_PLUGIN', false );
29
  }
30
 
 
 
 
 
 
 
 
 
31
 
32
  // Check the PHP version.
33
  if ( ! defined( 'PHP_VERSION_ID' ) || PHP_VERSION_ID < 70200 ) {
72
  * @var string EWWW_IMAGE_OPTIMIZER_IMAGES_PATH
73
  */
74
  define( 'EWWW_IMAGE_OPTIMIZER_IMAGES_PATH', plugin_dir_path( __FILE__ ) . 'images/' );
75
+ if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_TOOL_PATH' ) ) {
76
+ if ( ! defined( 'EWWWIO_CONTENT_DIR' ) ) {
77
+ $ewwwio_content_dir = trailingslashit( WP_CONTENT_DIR ) . trailingslashit( 'ewww' );
78
+ if ( ! is_writable( WP_CONTENT_DIR ) || ! empty( $_ENV['PANTHEON_ENVIRONMENT'] ) ) {
79
+ $upload_dir = wp_get_upload_dir();
80
+ if ( false === strpos( $upload_dir['basedir'], '://' ) && is_writable( $upload_dir['basedir'] ) ) {
81
+ $ewwwio_content_dir = trailingslashit( $upload_dir['basedir'] ) . trailingslashit( 'ewww' );
82
+ }
83
+ }
84
+ /**
85
+ * The folder where we store debug logs (among other things) - MUST have a trailing slash.
86
+ *
87
+ * @var string EWWW_IMAGE_OPTIMIZER_TOOL_PATH
88
+ */
89
+ define( 'EWWWIO_CONTENT_DIR', $ewwwio_content_dir );
90
+ }
91
+ /**
92
+ * The folder where we install optimization tools - MUST have a trailing slash.
93
+ *
94
+ * @var string EWWW_IMAGE_OPTIMIZER_TOOL_PATH
95
+ */
96
+ define( 'EWWW_IMAGE_OPTIMIZER_TOOL_PATH', EWWWIO_CONTENT_DIR );
97
+ } elseif ( ! defined( 'EWWWIO_CONTENT_DIR' ) ) {
98
+ define( 'EWWWIO_CONTENT_DIR', EWWW_IMAGE_OPTIMIZER_TOOL_PATH );
99
+ }
100
 
101
  /**
102
  * All the 'unique' functions for the core EWWW IO plugin.
includes/jquery-ui-1.10.1.custom.css CHANGED
@@ -690,6 +690,7 @@ p.debug-actions {
690
  overflow: auto;
691
  height: 300px;
692
  width: 800px;
 
693
  }
694
  #ewww-webp-rewrite #webp-rewrite-rules {
695
  background-color: white;
690
  overflow: auto;
691
  height: 300px;
692
  width: 800px;
693
+ margin-top: 5px;
694
  }
695
  #ewww-webp-rewrite #webp-rewrite-rules {
696
  background-color: white;
includes/load-webp.js CHANGED
@@ -91,7 +91,7 @@ var Arrive = (function(window, $, undefined) {
91
  toElementsArray: function (elements) {
92
  // check if object is an array (or array like object)
93
  // Note: window object has .length property but it's not array of elements so don't consider it an array
94
- if (typeof elements !== "undefined" && (typeof elements.length !== "number" || elements === window)) {
95
  elements = [elements];
96
  }
97
  return elements;
@@ -443,9 +443,6 @@ var Arrive = (function(window, $, undefined) {
443
  exposeUnbindApi(leaveEvents, exposeTo, "unbindLeave");
444
  }
445
 
446
- if ($) {
447
- exposeApi($.fn);
448
- }
449
  exposeApi(HTMLElement.prototype);
450
  exposeApi(NodeList.prototype);
451
  exposeApi(HTMLCollection.prototype);
@@ -459,7 +456,7 @@ var Arrive = (function(window, $, undefined) {
459
 
460
  return Arrive;
461
 
462
- })(window, typeof jQuery === 'undefined' ? null : jQuery, undefined);
463
 
464
  var ewww_webp_supported = false;
465
  // webp detection adapted from https://developers.google.com/speed/webp/faq#how_can_i_detect_browser_support_using_javascript
91
  toElementsArray: function (elements) {
92
  // check if object is an array (or array like object)
93
  // Note: window object has .length property but it's not array of elements so don't consider it an array
94
+ if (typeof elements !== 'undefined' && (typeof elements.length !== 'number' || elements === window)) {
95
  elements = [elements];
96
  }
97
  return elements;
443
  exposeUnbindApi(leaveEvents, exposeTo, "unbindLeave");
444
  }
445
 
 
 
 
446
  exposeApi(HTMLElement.prototype);
447
  exposeApi(NodeList.prototype);
448
  exposeApi(HTMLCollection.prototype);
456
 
457
  return Arrive;
458
 
459
+ })(window, null, undefined);
460
 
461
  var ewww_webp_supported = false;
462
  // webp detection adapted from https://developers.google.com/speed/webp/faq#how_can_i_detect_browser_support_using_javascript
includes/load-webp.min.js CHANGED
@@ -1 +1 @@
1
- var Arrive=function(c,e,w){"use strict";if(c.MutationObserver&&"undefined"!=typeof HTMLElement){var r,a=0,u=(r=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector,{matchesSelector:function(e,t){return e instanceof HTMLElement&&r.call(e,t)},addMethod:function(e,t,r){var a=e[t];e[t]=function(){return r.length==arguments.length?r.apply(this,arguments):"function"==typeof a?a.apply(this,arguments):void 0}},callCallbacks:function(e,t){t&&t.options.onceOnly&&1==t.firedElems.length&&(e=[e[0]]);for(var r,a=0;r=e[a];a++)r&&r.callback&&r.callback.call(r.elem,r.elem);t&&t.options.onceOnly&&1==t.firedElems.length&&t.me.unbindEventWithSelectorAndCallback.call(t.target,t.selector,t.callback)},checkChildNodesRecursively:function(e,t,r,a){for(var i,n=0;i=e[n];n++)r(i,t,a)&&a.push({callback:t.callback,elem:i}),0<i.childNodes.length&&u.checkChildNodesRecursively(i.childNodes,t,r,a)},mergeArrays:function(e,t){var r,a={};for(r in e)e.hasOwnProperty(r)&&(a[r]=e[r]);for(r in t)t.hasOwnProperty(r)&&(a[r]=t[r]);return a},toElementsArray:function(e){return e=void 0!==e&&("number"!=typeof e.length||e===c)?[e]:e}}),t=(n.prototype.addEvent=function(e,t,r,a){a={target:e,selector:t,options:r,callback:a,firedElems:[]};return this._beforeAdding&&this._beforeAdding(a),this._eventsBucket.push(a),a},n.prototype.removeEvent=function(e){for(var t,r=this._eventsBucket.length-1;t=this._eventsBucket[r];r--)e(t)&&(this._beforeRemoving&&this._beforeRemoving(t),(t=this._eventsBucket.splice(r,1))&&t.length&&(t[0].callback=null))},n.prototype.beforeAdding=function(e){this._beforeAdding=e},n.prototype.beforeRemoving=function(e){this._beforeRemoving=e},n),o=function(i,n){var o=new t,l=this,s={fireOnAttributesModification:!1};return o.beforeAdding(function(t){var e=t.target;e!==c.document&&e!==c||(e=document.getElementsByTagName("html")[0]);var r=new MutationObserver(function(e){n.call(this,e,t)}),a=i(t.options);r.observe(e,a),t.observer=r,t.me=l}),o.beforeRemoving(function(e){e.observer.disconnect()}),this.bindEvent=function(e,t,r){t=u.mergeArrays(s,t);for(var a=u.toElementsArray(this),i=0;i<a.length;i++)o.addEvent(a[i],e,t,r)},this.unbindEvent=function(){var r=u.toElementsArray(this);o.removeEvent(function(e){for(var t=0;t<r.length;t++)if(this===w||e.target===r[t])return!0;return!1})},this.unbindEventWithSelectorOrCallback=function(r){var a=u.toElementsArray(this),i=r,e="function"==typeof r?function(e){for(var t=0;t<a.length;t++)if((this===w||e.target===a[t])&&e.callback===i)return!0;return!1}:function(e){for(var t=0;t<a.length;t++)if((this===w||e.target===a[t])&&e.selector===r)return!0;return!1};o.removeEvent(e)},this.unbindEventWithSelectorAndCallback=function(r,a){var i=u.toElementsArray(this);o.removeEvent(function(e){for(var t=0;t<i.length;t++)if((this===w||e.target===i[t])&&e.selector===r&&e.callback===a)return!0;return!1})},this},i=new function(){var s={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};function n(e,t,r){return!(!u.matchesSelector(e,t.selector)||(e._id===w&&(e._id=a++),-1!=t.firedElems.indexOf(e._id)))&&(t.firedElems.push(e._id),!0)}var c=(i=new o(function(e){var t={attributes:!1,childList:!0,subtree:!0};return e.fireOnAttributesModification&&(t.attributes=!0),t},function(e,i){e.forEach(function(e){var t=e.addedNodes,r=e.target,a=[];null!==t&&0<t.length?u.checkChildNodesRecursively(t,i,n,a):"attributes"===e.type&&n(r,i)&&a.push({callback:i.callback,elem:r}),u.callCallbacks(a,i)})})).bindEvent;return i.bindEvent=function(e,t,r){t=void 0===r?(r=t,s):u.mergeArrays(s,t);var a=u.toElementsArray(this);if(t.existing){for(var i=[],n=0;n<a.length;n++)for(var o=a[n].querySelectorAll(e),l=0;l<o.length;l++)i.push({callback:r,elem:o[l]});if(t.onceOnly&&i.length)return r.call(i[0].elem,i[0].elem);setTimeout(u.callCallbacks,1,i)}c.call(this,e,t,r)},i},l=new function(){var a={};function i(e,t){return u.matchesSelector(e,t.selector)}var n=(l=new o(function(){return{childList:!0,subtree:!0}},function(e,r){e.forEach(function(e){var t=e.removedNodes,e=[];null!==t&&0<t.length&&u.checkChildNodesRecursively(t,r,i,e),u.callCallbacks(e,r)})})).bindEvent;return l.bindEvent=function(e,t,r){t=void 0===r?(r=t,a):u.mergeArrays(a,t),n.call(this,e,t,r)},l};e&&d(e.fn),d(HTMLElement.prototype),d(NodeList.prototype),d(HTMLCollection.prototype),d(HTMLDocument.prototype),d(Window.prototype);e={};return s(i,e,"unbindAllArrive"),s(l,e,"unbindAllLeave"),e}function n(){this._eventsBucket=[],this._beforeAdding=null,this._beforeRemoving=null}function s(e,t,r){u.addMethod(t,r,e.unbindEvent),u.addMethod(t,r,e.unbindEventWithSelectorOrCallback),u.addMethod(t,r,e.unbindEventWithSelectorAndCallback)}function d(e){e.arrive=i.bindEvent,s(i,e,"unbindArrive"),e.leave=l.bindEvent,s(l,e,"unbindLeave")}}(window,"undefined"==typeof jQuery?null:jQuery,void 0),ewww_webp_supported=!1;function check_webp_feature(e,t){var r;ewww_webp_supported?t(ewww_webp_supported):((r=new Image).onload=function(){ewww_webp_supported=0<r.width&&0<r.height,t(ewww_webp_supported)},r.onerror=function(){t(!1)},r.src="data:image/webp;base64,"+{alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"}[e])}function ewwwLoadImages(e){if(e){for(var t=document.querySelectorAll(".batch-image img, .image-wrapper a, .ngg-pro-masonry-item a, .ngg-galleria-offscreen-seo-wrapper a"),r=0,a=t.length;r<a;r++)ewwwAttr(t[r],"data-src",t[r].getAttribute("data-webp")),ewwwAttr(t[r],"data-thumbnail",t[r].getAttribute("data-webp-thumbnail"));for(var i=document.querySelectorAll(".rev_slider ul li"),r=0,a=i.length;r<a;r++){ewwwAttr(i[r],"data-thumb",i[r].getAttribute("data-webp-thumb"));for(var n=1;n<11;)ewwwAttr(i[r],"data-param"+n,i[r].getAttribute("data-webp-param"+n)),n++}for(r=0,a=(i=document.querySelectorAll(".rev_slider img")).length;r<a;r++)ewwwAttr(i[r],"data-lazyload",i[r].getAttribute("data-webp-lazyload"));for(var o=document.querySelectorAll("div.woocommerce-product-gallery__image"),r=0,a=o.length;r<a;r++)ewwwAttr(o[r],"data-thumb",o[r].getAttribute("data-webp-thumb"))}for(var l=document.querySelectorAll("video"),r=0,a=l.length;r<a;r++)ewwwAttr(l[r],"poster",e?l[r].getAttribute("data-poster-webp"):l[r].getAttribute("data-poster-image"));for(var s,c=document.querySelectorAll("img.ewww_webp_lazy_load"),r=0,a=c.length;r<a;r++)e&&(ewwwAttr(c[r],"data-lazy-srcset",c[r].getAttribute("data-lazy-srcset-webp")),ewwwAttr(c[r],"data-srcset",c[r].getAttribute("data-srcset-webp")),ewwwAttr(c[r],"data-lazy-src",c[r].getAttribute("data-lazy-src-webp")),ewwwAttr(c[r],"data-src",c[r].getAttribute("data-src-webp")),ewwwAttr(c[r],"data-orig-file",c[r].getAttribute("data-webp-orig-file")),ewwwAttr(c[r],"data-medium-file",c[r].getAttribute("data-webp-medium-file")),ewwwAttr(c[r],"data-large-file",c[r].getAttribute("data-webp-large-file")),null!=(s=c[r].getAttribute("srcset"))&&!1!==s&&s.includes("R0lGOD")&&ewwwAttr(c[r],"src",c[r].getAttribute("data-lazy-src-webp"))),c[r].className=c[r].className.replace(/\bewww_webp_lazy_load\b/,"");for(var w=document.querySelectorAll(".ewww_webp"),r=0,a=w.length;r<a;r++)e?(ewwwAttr(w[r],"srcset",w[r].getAttribute("data-srcset-webp")),ewwwAttr(w[r],"src",w[r].getAttribute("data-src-webp")),ewwwAttr(w[r],"data-orig-file",w[r].getAttribute("data-webp-orig-file")),ewwwAttr(w[r],"data-medium-file",w[r].getAttribute("data-webp-medium-file")),ewwwAttr(w[r],"data-large-file",w[r].getAttribute("data-webp-large-file")),ewwwAttr(w[r],"data-large_image",w[r].getAttribute("data-webp-large_image")),ewwwAttr(w[r],"data-src",w[r].getAttribute("data-webp-src"))):(ewwwAttr(w[r],"srcset",w[r].getAttribute("data-srcset-img")),ewwwAttr(w[r],"src",w[r].getAttribute("data-src-img"))),w[r].className=w[r].className.replace(/\bewww_webp\b/,"ewww_webp_loaded");window.jQuery&&jQuery.fn.isotope&&jQuery.fn.imagesLoaded&&(jQuery(".fusion-posts-container-infinite").imagesLoaded(function(){jQuery(".fusion-posts-container-infinite").hasClass("isotope")&&jQuery(".fusion-posts-container-infinite").isotope()}),jQuery(".fusion-portfolio:not(.fusion-recent-works) .fusion-portfolio-wrapper").imagesLoaded(function(){jQuery(".fusion-portfolio:not(.fusion-recent-works) .fusion-portfolio-wrapper").isotope()}))}function ewwwWebPInit(e){ewwwLoadImages(e),ewwwNggLoadGalleries(e),document.arrive(".ewww_webp",function(){ewwwLoadImages(e)}),document.arrive(".ewww_webp_lazy_load",function(){ewwwLoadImages(e)}),document.arrive("videos",function(){ewwwLoadImages(e)}),"loading"==document.readyState?document.addEventListener("DOMContentLoaded",ewwwJSONParserInit):("undefined"!=typeof galleries&&ewwwNggParseGalleries(e),ewwwWooParseVariations(e))}function ewwwAttr(e,t,r){null!=r&&!1!==r&&e.setAttribute(t,r)}function ewwwJSONParserInit(){"undefined"!=typeof galleries&&check_webp_feature("alpha",ewwwNggParseGalleries),check_webp_feature("alpha",ewwwWooParseVariations)}function ewwwWooParseVariations(e){if(e)for(var t=document.querySelectorAll("form.variations_form"),r=0,a=t.length;r<a;r++){var i=t[r].getAttribute("data-product_variations"),n=!1;try{for(var o in i=JSON.parse(i))void 0!==i[o]&&void 0!==i[o].image&&(void 0!==i[o].image.src_webp&&(i[o].image.src=i[o].image.src_webp,n=!0),void 0!==i[o].image.srcset_webp&&(i[o].image.srcset=i[o].image.srcset_webp,n=!0),void 0!==i[o].image.full_src_webp&&(i[o].image.full_src=i[o].image.full_src_webp,n=!0),void 0!==i[o].image.gallery_thumbnail_src_webp&&(i[o].image.gallery_thumbnail_src=i[o].image.gallery_thumbnail_src_webp,n=!0),void 0!==i[o].image.thumb_src_webp&&(i[o].image.thumb_src=i[o].image.thumb_src_webp,n=!0));n&&ewwwAttr(t[r],"data-product_variations",JSON.stringify(i))}catch(e){}}}function ewwwNggParseGalleries(e){if(e)for(var t in galleries){var r=galleries[t];galleries[t].images_list=ewwwNggParseImageList(r.images_list)}}function ewwwNggLoadGalleries(e){e&&document.addEventListener("ngg.galleria.themeadded",function(e,t){window.ngg_galleria._create_backup=window.ngg_galleria.create,window.ngg_galleria.create=function(e,t){var r=$(e).data("id");return galleries["gallery_"+r].images_list=ewwwNggParseImageList(galleries["gallery_"+r].images_list),window.ngg_galleria._create_backup(e,t)}})}function ewwwNggParseImageList(e){for(var t in e){var r=e[t];if(void 0!==r["image-webp"]&&(e[t].image=r["image-webp"],delete e[t]["image-webp"]),void 0!==r["thumb-webp"]&&(e[t].thumb=r["thumb-webp"],delete e[t]["thumb-webp"]),void 0!==r.full_image_webp&&(e[t].full_image=r.full_image_webp,delete e[t].full_image_webp),void 0!==r.srcsets)for(var a in r.srcsets)nggSrcset=r.srcsets[a],void 0!==r.srcsets[a+"-webp"]&&(e[t].srcsets[a]=r.srcsets[a+"-webp"],delete e[t].srcsets[a+"-webp"]);if(void 0!==r.full_srcsets)for(var i in r.full_srcsets)nggFSrcset=r.full_srcsets[i],void 0!==r.full_srcsets[i+"-webp"]&&(e[t].full_srcsets[i]=r.full_srcsets[i+"-webp"],delete e[t].full_srcsets[i+"-webp"])}return e}check_webp_feature("alpha",ewwwWebPInit);
1
+ var Arrive=function(c,w){"use strict";if(c.MutationObserver&&"undefined"!=typeof HTMLElement){var r,a=0,u=(r=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector,{matchesSelector:function(e,t){return e instanceof HTMLElement&&r.call(e,t)},addMethod:function(e,t,r){var a=e[t];e[t]=function(){return r.length==arguments.length?r.apply(this,arguments):"function"==typeof a?a.apply(this,arguments):void 0}},callCallbacks:function(e,t){t&&t.options.onceOnly&&1==t.firedElems.length&&(e=[e[0]]);for(var r,a=0;r=e[a];a++)r&&r.callback&&r.callback.call(r.elem,r.elem);t&&t.options.onceOnly&&1==t.firedElems.length&&t.me.unbindEventWithSelectorAndCallback.call(t.target,t.selector,t.callback)},checkChildNodesRecursively:function(e,t,r,a){for(var i,n=0;i=e[n];n++)r(i,t,a)&&a.push({callback:t.callback,elem:i}),0<i.childNodes.length&&u.checkChildNodesRecursively(i.childNodes,t,r,a)},mergeArrays:function(e,t){var r,a={};for(r in e)e.hasOwnProperty(r)&&(a[r]=e[r]);for(r in t)t.hasOwnProperty(r)&&(a[r]=t[r]);return a},toElementsArray:function(e){return e=void 0!==e&&("number"!=typeof e.length||e===c)?[e]:e}}),e=(l.prototype.addEvent=function(e,t,r,a){a={target:e,selector:t,options:r,callback:a,firedElems:[]};return this._beforeAdding&&this._beforeAdding(a),this._eventsBucket.push(a),a},l.prototype.removeEvent=function(e){for(var t,r=this._eventsBucket.length-1;t=this._eventsBucket[r];r--)e(t)&&(this._beforeRemoving&&this._beforeRemoving(t),(t=this._eventsBucket.splice(r,1))&&t.length&&(t[0].callback=null))},l.prototype.beforeAdding=function(e){this._beforeAdding=e},l.prototype.beforeRemoving=function(e){this._beforeRemoving=e},l),t=function(i,n){var o=new e,l=this,s={fireOnAttributesModification:!1};return o.beforeAdding(function(t){var e=t.target;e!==c.document&&e!==c||(e=document.getElementsByTagName("html")[0]);var r=new MutationObserver(function(e){n.call(this,e,t)}),a=i(t.options);r.observe(e,a),t.observer=r,t.me=l}),o.beforeRemoving(function(e){e.observer.disconnect()}),this.bindEvent=function(e,t,r){t=u.mergeArrays(s,t);for(var a=u.toElementsArray(this),i=0;i<a.length;i++)o.addEvent(a[i],e,t,r)},this.unbindEvent=function(){var r=u.toElementsArray(this);o.removeEvent(function(e){for(var t=0;t<r.length;t++)if(this===w||e.target===r[t])return!0;return!1})},this.unbindEventWithSelectorOrCallback=function(r){var a=u.toElementsArray(this),i=r,e="function"==typeof r?function(e){for(var t=0;t<a.length;t++)if((this===w||e.target===a[t])&&e.callback===i)return!0;return!1}:function(e){for(var t=0;t<a.length;t++)if((this===w||e.target===a[t])&&e.selector===r)return!0;return!1};o.removeEvent(e)},this.unbindEventWithSelectorAndCallback=function(r,a){var i=u.toElementsArray(this);o.removeEvent(function(e){for(var t=0;t<i.length;t++)if((this===w||e.target===i[t])&&e.selector===r&&e.callback===a)return!0;return!1})},this},i=new function(){var s={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};function n(e,t,r){return!(!u.matchesSelector(e,t.selector)||(e._id===w&&(e._id=a++),-1!=t.firedElems.indexOf(e._id)))&&(t.firedElems.push(e._id),!0)}var c=(i=new t(function(e){var t={attributes:!1,childList:!0,subtree:!0};return e.fireOnAttributesModification&&(t.attributes=!0),t},function(e,i){e.forEach(function(e){var t=e.addedNodes,r=e.target,a=[];null!==t&&0<t.length?u.checkChildNodesRecursively(t,i,n,a):"attributes"===e.type&&n(r,i)&&a.push({callback:i.callback,elem:r}),u.callCallbacks(a,i)})})).bindEvent;return i.bindEvent=function(e,t,r){t=void 0===r?(r=t,s):u.mergeArrays(s,t);var a=u.toElementsArray(this);if(t.existing){for(var i=[],n=0;n<a.length;n++)for(var o=a[n].querySelectorAll(e),l=0;l<o.length;l++)i.push({callback:r,elem:o[l]});if(t.onceOnly&&i.length)return r.call(i[0].elem,i[0].elem);setTimeout(u.callCallbacks,1,i)}c.call(this,e,t,r)},i},o=new function(){var a={};function i(e,t){return u.matchesSelector(e,t.selector)}var n=(o=new t(function(){return{childList:!0,subtree:!0}},function(e,r){e.forEach(function(e){var t=e.removedNodes,e=[];null!==t&&0<t.length&&u.checkChildNodesRecursively(t,r,i,e),u.callCallbacks(e,r)})})).bindEvent;return o.bindEvent=function(e,t,r){t=void 0===r?(r=t,a):u.mergeArrays(a,t),n.call(this,e,t,r)},o};d(HTMLElement.prototype),d(NodeList.prototype),d(HTMLCollection.prototype),d(HTMLDocument.prototype),d(Window.prototype);var n={};return s(i,n,"unbindAllArrive"),s(o,n,"unbindAllLeave"),n}function l(){this._eventsBucket=[],this._beforeAdding=null,this._beforeRemoving=null}function s(e,t,r){u.addMethod(t,r,e.unbindEvent),u.addMethod(t,r,e.unbindEventWithSelectorOrCallback),u.addMethod(t,r,e.unbindEventWithSelectorAndCallback)}function d(e){e.arrive=i.bindEvent,s(i,e,"unbindArrive"),e.leave=o.bindEvent,s(o,e,"unbindLeave")}}(window,void 0),ewww_webp_supported=!1;function check_webp_feature(e,t){var r;ewww_webp_supported?t(ewww_webp_supported):((r=new Image).onload=function(){ewww_webp_supported=0<r.width&&0<r.height,t(ewww_webp_supported)},r.onerror=function(){t(!1)},r.src="data:image/webp;base64,"+{alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"}[e])}function ewwwLoadImages(e){if(e){for(var t=document.querySelectorAll(".batch-image img, .image-wrapper a, .ngg-pro-masonry-item a, .ngg-galleria-offscreen-seo-wrapper a"),r=0,a=t.length;r<a;r++)ewwwAttr(t[r],"data-src",t[r].getAttribute("data-webp")),ewwwAttr(t[r],"data-thumbnail",t[r].getAttribute("data-webp-thumbnail"));for(var i=document.querySelectorAll(".rev_slider ul li"),r=0,a=i.length;r<a;r++){ewwwAttr(i[r],"data-thumb",i[r].getAttribute("data-webp-thumb"));for(var n=1;n<11;)ewwwAttr(i[r],"data-param"+n,i[r].getAttribute("data-webp-param"+n)),n++}for(r=0,a=(i=document.querySelectorAll(".rev_slider img")).length;r<a;r++)ewwwAttr(i[r],"data-lazyload",i[r].getAttribute("data-webp-lazyload"));for(var o=document.querySelectorAll("div.woocommerce-product-gallery__image"),r=0,a=o.length;r<a;r++)ewwwAttr(o[r],"data-thumb",o[r].getAttribute("data-webp-thumb"))}for(var l=document.querySelectorAll("video"),r=0,a=l.length;r<a;r++)ewwwAttr(l[r],"poster",e?l[r].getAttribute("data-poster-webp"):l[r].getAttribute("data-poster-image"));for(var s,c=document.querySelectorAll("img.ewww_webp_lazy_load"),r=0,a=c.length;r<a;r++)e&&(ewwwAttr(c[r],"data-lazy-srcset",c[r].getAttribute("data-lazy-srcset-webp")),ewwwAttr(c[r],"data-srcset",c[r].getAttribute("data-srcset-webp")),ewwwAttr(c[r],"data-lazy-src",c[r].getAttribute("data-lazy-src-webp")),ewwwAttr(c[r],"data-src",c[r].getAttribute("data-src-webp")),ewwwAttr(c[r],"data-orig-file",c[r].getAttribute("data-webp-orig-file")),ewwwAttr(c[r],"data-medium-file",c[r].getAttribute("data-webp-medium-file")),ewwwAttr(c[r],"data-large-file",c[r].getAttribute("data-webp-large-file")),null!=(s=c[r].getAttribute("srcset"))&&!1!==s&&s.includes("R0lGOD")&&ewwwAttr(c[r],"src",c[r].getAttribute("data-lazy-src-webp"))),c[r].className=c[r].className.replace(/\bewww_webp_lazy_load\b/,"");for(var w=document.querySelectorAll(".ewww_webp"),r=0,a=w.length;r<a;r++)e?(ewwwAttr(w[r],"srcset",w[r].getAttribute("data-srcset-webp")),ewwwAttr(w[r],"src",w[r].getAttribute("data-src-webp")),ewwwAttr(w[r],"data-orig-file",w[r].getAttribute("data-webp-orig-file")),ewwwAttr(w[r],"data-medium-file",w[r].getAttribute("data-webp-medium-file")),ewwwAttr(w[r],"data-large-file",w[r].getAttribute("data-webp-large-file")),ewwwAttr(w[r],"data-large_image",w[r].getAttribute("data-webp-large_image")),ewwwAttr(w[r],"data-src",w[r].getAttribute("data-webp-src"))):(ewwwAttr(w[r],"srcset",w[r].getAttribute("data-srcset-img")),ewwwAttr(w[r],"src",w[r].getAttribute("data-src-img"))),w[r].className=w[r].className.replace(/\bewww_webp\b/,"ewww_webp_loaded");window.jQuery&&jQuery.fn.isotope&&jQuery.fn.imagesLoaded&&(jQuery(".fusion-posts-container-infinite").imagesLoaded(function(){jQuery(".fusion-posts-container-infinite").hasClass("isotope")&&jQuery(".fusion-posts-container-infinite").isotope()}),jQuery(".fusion-portfolio:not(.fusion-recent-works) .fusion-portfolio-wrapper").imagesLoaded(function(){jQuery(".fusion-portfolio:not(.fusion-recent-works) .fusion-portfolio-wrapper").isotope()}))}function ewwwWebPInit(e){ewwwLoadImages(e),ewwwNggLoadGalleries(e),document.arrive(".ewww_webp",function(){ewwwLoadImages(e)}),document.arrive(".ewww_webp_lazy_load",function(){ewwwLoadImages(e)}),document.arrive("videos",function(){ewwwLoadImages(e)}),"loading"==document.readyState?document.addEventListener("DOMContentLoaded",ewwwJSONParserInit):("undefined"!=typeof galleries&&ewwwNggParseGalleries(e),ewwwWooParseVariations(e))}function ewwwAttr(e,t,r){null!=r&&!1!==r&&e.setAttribute(t,r)}function ewwwJSONParserInit(){"undefined"!=typeof galleries&&check_webp_feature("alpha",ewwwNggParseGalleries),check_webp_feature("alpha",ewwwWooParseVariations)}function ewwwWooParseVariations(e){if(e)for(var t=document.querySelectorAll("form.variations_form"),r=0,a=t.length;r<a;r++){var i=t[r].getAttribute("data-product_variations"),n=!1;try{for(var o in i=JSON.parse(i))void 0!==i[o]&&void 0!==i[o].image&&(void 0!==i[o].image.src_webp&&(i[o].image.src=i[o].image.src_webp,n=!0),void 0!==i[o].image.srcset_webp&&(i[o].image.srcset=i[o].image.srcset_webp,n=!0),void 0!==i[o].image.full_src_webp&&(i[o].image.full_src=i[o].image.full_src_webp,n=!0),void 0!==i[o].image.gallery_thumbnail_src_webp&&(i[o].image.gallery_thumbnail_src=i[o].image.gallery_thumbnail_src_webp,n=!0),void 0!==i[o].image.thumb_src_webp&&(i[o].image.thumb_src=i[o].image.thumb_src_webp,n=!0));n&&ewwwAttr(t[r],"data-product_variations",JSON.stringify(i))}catch(e){}}}function ewwwNggParseGalleries(e){if(e)for(var t in galleries){var r=galleries[t];galleries[t].images_list=ewwwNggParseImageList(r.images_list)}}function ewwwNggLoadGalleries(e){e&&document.addEventListener("ngg.galleria.themeadded",function(e,t){window.ngg_galleria._create_backup=window.ngg_galleria.create,window.ngg_galleria.create=function(e,t){var r=$(e).data("id");return galleries["gallery_"+r].images_list=ewwwNggParseImageList(galleries["gallery_"+r].images_list),window.ngg_galleria._create_backup(e,t)}})}function ewwwNggParseImageList(e){for(var t in e){var r=e[t];if(void 0!==r["image-webp"]&&(e[t].image=r["image-webp"],delete e[t]["image-webp"]),void 0!==r["thumb-webp"]&&(e[t].thumb=r["thumb-webp"],delete e[t]["thumb-webp"]),void 0!==r.full_image_webp&&(e[t].full_image=r.full_image_webp,delete e[t].full_image_webp),void 0!==r.srcsets)for(var a in r.srcsets)nggSrcset=r.srcsets[a],void 0!==r.srcsets[a+"-webp"]&&(e[t].srcsets[a]=r.srcsets[a+"-webp"],delete e[t].srcsets[a+"-webp"]);if(void 0!==r.full_srcsets)for(var i in r.full_srcsets)nggFSrcset=r.full_srcsets[i],void 0!==r.full_srcsets[i+"-webp"]&&(e[t].full_srcsets[i]=r.full_srcsets[i+"-webp"],delete e[t].full_srcsets[i+"-webp"])}return e}check_webp_feature("alpha",ewwwWebPInit);
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization,
5
  Requires at least: 5.6
6
  Tested up to: 5.9
7
  Requires PHP: 7.2
8
- Stable tag: 6.4.1
9
  License: GPLv3
10
 
11
  Smaller Images, Faster Sites, Happier Visitors. Comprehensive image optimization that doesn't require a degree in rocket science.
@@ -137,6 +137,12 @@ That's not a question, but since I made it up, I'll answer it. See this resource
137
  * Feature requests can be viewed and submitted on our [feedback portal](https://feedback.ewww.io/b/features)
138
  * If you would like to help translate this plugin in your language, [join the team](https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/)
139
 
 
 
 
 
 
 
140
  = 6.4.1 =
141
  * added: use decoding=async to prevent images from blocking text render
142
  * fixed: database upgrade fails on MySQL 8.0.x
5
  Requires at least: 5.6
6
  Tested up to: 5.9
7
  Requires PHP: 7.2
8
+ Stable tag: 6.4.2
9
  License: GPLv3
10
 
11
  Smaller Images, Faster Sites, Happier Visitors. Comprehensive image optimization that doesn't require a degree in rocket science.
137
  * Feature requests can be viewed and submitted on our [feedback portal](https://feedback.ewww.io/b/features)
138
  * If you would like to help translate this plugin in your language, [join the team](https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/)
139
 
140
+ = 6.4.2 =
141
+ * added: JS/Picture WebP rewriters support FacetWP AJAX responses
142
+ * fixed: errors from posix_getpwuid() and posix_getgrgid() not handled correctly
143
+ * fixed: PNGOUT download URLs were moved, causing auto-install to fail
144
+ * fixed: Easy IO was adding srcset markup for SVG images
145
+
146
  = 6.4.1 =
147
  * added: use decoding=async to prevent images from blocking text render
148
  * fixed: database upgrade fails on MySQL 8.0.x
unique.php CHANGED
@@ -1981,11 +1981,19 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
1981
  $file_group = 'unknown';
1982
  if ( function_exists( 'posix_getpwuid' ) ) {
1983
  $file_owner = posix_getpwuid( fileowner( $file ) );
1984
- $file_owner = 'xxxxxxxx' . substr( $file_owner['name'], -4 );
 
 
 
 
1985
  }
1986
  if ( function_exists( 'posix_getgrgid' ) ) {
1987
  $file_group = posix_getgrgid( filegroup( $file ) );
1988
- $file_group = 'xxxxx' . substr( $file_group['name'], -5 );
 
 
 
 
1989
  }
1990
  ewwwio_debug_message( "permissions: $file_perms, owner: $file_owner, group: $file_group" );
1991
  $type = ewww_image_optimizer_mimetype( $file, 'i' );
1981
  $file_group = 'unknown';
1982
  if ( function_exists( 'posix_getpwuid' ) ) {
1983
  $file_owner = posix_getpwuid( fileowner( $file ) );
1984
+ if ( $file_owner ) {
1985
+ $file_owner = 'xxxxxxxx' . substr( $file_owner['name'], -4 );
1986
+ } else {
1987
+ $file_owner = 'unknown';
1988
+ }
1989
  }
1990
  if ( function_exists( 'posix_getgrgid' ) ) {
1991
  $file_group = posix_getgrgid( filegroup( $file ) );
1992
+ if ( $file_group ) {
1993
+ $file_group = 'xxxxx' . substr( $file_group['name'], -5 );
1994
+ } else {
1995
+ $file_group = 'unknown';
1996
+ }
1997
  }
1998
  ewwwio_debug_message( "permissions: $file_perms, owner: $file_owner, group: $file_group" );
1999
  $type = ewww_image_optimizer_mimetype( $file, 'i' );