Skip to content

Commit

Permalink
fix: compatibility with Woocommerce, solving issue with zoom image on…
Browse files Browse the repository at this point in the history
… single product pages
  • Loading branch information
selul committed Mar 8, 2019
1 parent 0bbd254 commit 1692e2b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
41 changes: 41 additions & 0 deletions inc/compatibilities/woocommerce.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* Class Optml_woocommerce.
*
* @reason Zoom image on product pages uses a the lqip placeholder instead of the full size image.
*/
class Optml_woocommerce extends Optml_compatibility {

/**
* Should we load the integration logic.
*
* @return bool Should we load.
*/
function should_load() {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );

return is_plugin_active( 'woocommerce/woocommerce.php' );
}

/**
* Register integration details.
*/
public function register() {
add_filter( 'optml_watcher_lz_classes', [ $this, 'add_watcher_class' ], 10, 1 );
}

/**
* Add classes for watching for late lazyload.
*
* @param string $classes Old classes.
*
* @return array New classes.
*/
public function add_watcher_class( $classes = array() ) {
$classes[] = 'zoomImg';

return $classes;
}

}
8 changes: 7 additions & 1 deletion inc/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ final class Optml_Manager {
*
* @var array Integrations classes.
*/
private $compatibilities = array( 'shortcode_ultimate', 'foogallery', 'envira', 'revslider' );
private $compatibilities = array(
'shortcode_ultimate',
'foogallery',
'envira',
'revslider',
'woocommerce',
);

/**
* Class instance method.
Expand Down

0 comments on commit 1692e2b

Please sign in to comment.