Skip to content

Commit

Permalink
one more js webp notice fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nosilver4u committed Aug 14, 2019
1 parent 68bb655 commit 3d7cf8d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions classes/class-eio-alt-webp.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function filter_page_output( $buffer ) {
/* TODO: detect non-utf8 encoding and convert the buffer (if necessary). */

$images = $this->get_images_from_html( preg_replace( '/<noscript.*?\/noscript>/s', '', $buffer ), false );
if ( ewww_image_optimizer_iterable( $images[0] ) ) {
if ( ! empty( $images[0] ) && $this->is_iterable( $images[0] ) ) {
foreach ( $images[0] as $index => $image ) {
$file = $images['img_url'][ $index ];
ewwwio_debug_message( "parsing an image: $file" );
Expand Down Expand Up @@ -457,7 +457,7 @@ function filter_page_output( $buffer ) {
} // End if().
// Now we will look for any lazy images that don't have a src attribute (this search returns ALL img elements though).
$images = $this->get_images_from_html( preg_replace( '/<noscript.*?\/noscript>/s', '', $buffer ), false, false );
if ( ewww_image_optimizer_iterable( $images[0] ) ) {
if ( ! empty( $images[0] ) && $this->is_iterable( $images[0] ) ) {
ewwwio_debug_message( 'parsing images without requiring src' );
foreach ( $images[0] as $index => $image ) {
if ( $this->get_attribute( $image, 'src' ) ) {
Expand Down
22 changes: 17 additions & 5 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -8719,7 +8719,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
$output[] = "<div id='ewww-webp-settings'>\n";
$output[] = '<noscript><h2>' . esc_html__( 'WebP', 'ewww-image-optimizer' ) . '</h2></noscript>';
$output[] = "<table class='form-table'>\n";
if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) {
if ( ! ewww_image_optimizer_easy_active() || ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) {
$output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_webp'>" . esc_html__( 'JPG/PNG to WebP', 'ewww-image-optimizer' ) . '</label>' .
ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ) .
"</th><td><span><input type='checkbox' id='ewww_image_optimizer_webp' name='ewww_image_optimizer_webp' value='true' " .
Expand All @@ -8735,7 +8735,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
esc_html__( 'WebP images will be generated and saved for all JPG/PNG images regardless of their size. The JS WebP Rewriting will not check if a file exists, only that the domain matches the home url.', 'ewww-image-optimizer' ) . "</span></td></tr>\n";
ewwwio_debug_message( 'forced webp: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ? 'on' : 'off' ) );
}
if ( ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
if ( ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_easy_active() ) {
$webp_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ? esc_html( implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ) ) : '';
$output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_webp_paths'>" . esc_html__( 'WebP URLs', 'ewww-image-optimizer' ) . '</label>' .
ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ) . '</th><td>' .
Expand All @@ -8753,6 +8753,8 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
ewwwio_debug_message( 'alt webp rewriting: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) ? 'on' : 'off' ) );
} elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
$output[] = "<tr class='$network_class'><th>&nbsp;</th><td><p class='description'>" . esc_html__( 'WebP images are served automatically by ExactDN.', 'ewww-image-optimizer' ) . '</p></td></tr>';
} elseif ( get_option( 'easyio_exactdn' ) ) {
$output[] = "<tr class='$network_class'><th>&nbsp;</th><td><p class='description'>" . esc_html__( 'WebP images are served automatically by Easy Image Optimizer.', 'ewww-image-optimizer' ) . '</p></td></tr>';
}
$output[] = "</table>\n</div>\n";

Expand Down Expand Up @@ -8800,10 +8802,10 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
$output[] = "<p class='submit'><input type='submit' class='button-primary' value='" . esc_attr__( 'Save Changes', 'ewww-image-optimizer' ) . "' /></p>\n";
$output[] = "</form>\n";
// Make sure .htaccess rules are terminated when ExactDN is enabled.
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
if ( ewww_image_optimizer_easy_active() ) {
ewww_image_optimizer_webp_rewrite_verify();
}
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) && ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) && ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_easy_active() ) {
if ( ! apache_mod_loaded( 'mod_rewrite' ) ) {
ewwwio_debug_message( 'webp missing mod_rewrite' );
/* translators: %s: mod_rewrite or mod_headers */
Expand Down Expand Up @@ -8866,7 +8868,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
return;
}
$output = apply_filters( 'ewww_image_optimizer_settings', $output );
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) && ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) && ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_easy_active() ) {
global $eio_alt_webp;
$eio_alt_webp->inline_script();
}
Expand Down Expand Up @@ -9012,6 +9014,16 @@ function ewwwio_help_link( $link, $hsid = '' ) {
return "<a class='$link_class' href='$link' target='_blank' style='margin: 3px'$beacon_attr><img title='" . esc_attr__( 'Help', 'ewww-image-optimizer' ) . "' src='$help_icon'></a>";
}

/**
* Checks to see if ExactDN or Easy I.O. is active.
*/
function ewww_image_optimizer_easy_active() {
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) || get_option( 'easyio_exactdn' ) ) {
return true;
}
return false;
}

/**
* Removes the API key currently installed.
*
Expand Down

0 comments on commit 3d7cf8d

Please sign in to comment.