WP Image Zoom - Version 1.39.2

Version Description

  • 02/12/2019
  • Fix: the WC product images were distorted on the Flatsome theme
Download this release

Release Info

Developer diana_burduja
Plugin Icon 128x128 WP Image Zoom
Version 1.39.2
Comparing to
See all releases

Code changes from version 1.39.1 to 1.39.2

Files changed (3) hide show
  1. image-zoooom.php +555 -534
  2. includes/admin-side.php +7 -0
  3. readme.txt +7 -3
image-zoooom.php CHANGED
@@ -2,9 +2,9 @@
2
  /**
3
  * Plugin Name: WP Image Zoom
4
  * Plugin URI: https://wordpress.org/plugins/wp-image-zoooom/
5
- * Description: Add zoom effect over the an image, whether it is an image in a post/page or the featured image of a product in a WooCommerce shop
6
- * Version: 1.39.1
7
- * Author: SilkyPress
8
  * Author URI: https://www.silkypress.com
9
  * License: GPL2
10
  *
@@ -16,539 +16,560 @@
16
  */
17
 
18
  if ( ! defined( 'ABSPATH' ) ) {
19
- exit; // Exit if accessed directly
20
  }
21
 
22
  if ( ! class_exists( 'ImageZoooom' ) ) :
23
- /**
24
- * Main ImageZoooom Class
25
- *
26
- * @class ImageZoooom
27
- */
28
- final class ImageZoooom {
29
- public $version = '1.39.1';
30
- public $theme = '';
31
- protected static $_instance = null;
32
-
33
-
34
- /**
35
- * Main ImageZoooom Instance
36
- *
37
- * Ensures only one instance of ImageZoooom is loaded or can be loaded
38
- *
39
- * @static
40
- * @return ImageZoooom - Main instance
41
- */
42
- public static function instance() {
43
- if ( is_null( self::$_instance ) ) {
44
- self::$_instance = new self();
45
- }
46
- return self::$_instance;
47
- }
48
-
49
- /**
50
- * Cloning is forbidden.
51
- */
52
- public function __clone() {
53
- _doing_it_wrong( __FUNCTION__, __( 'An error has occurred. Please reload the page and try again.' ), '1.0' );
54
- }
55
-
56
- /**
57
- * Unserializing instances of this class is forbidden.
58
- */
59
- public function __wakeup() {
60
- _doing_it_wrong( __FUNCTION__, __( 'An error has occurred. Please reload the page and try again.' ), '1.0' );
61
- }
62
-
63
- /**
64
- * Image Zoooom Constructor
65
- * @access public
66
- * @return ImageZoooom
67
- */
68
- public function __construct() {
69
- global $_wp_theme_features;
70
-
71
-
72
- define('IMAGE_ZOOM_FILE', __FILE__);
73
- define('IMAGE_ZOOM_URL', plugins_url('/', __FILE__));
74
- define('IMAGE_ZOOM_PATH', plugin_dir_path(__FILE__));
75
- define('IMAGE_ZOOM_VERSION', $this->version);
76
-
77
- $this->theme = strtolower(get_template());
78
- include_once( 'includes/settings.php' );
79
-
80
- if ( is_admin() ) {
81
- $this->load_plugin_textdomain();
82
- include_once( 'includes/admin-side.php' );
83
- new ImageZoooom_Admin();
84
- }
85
- add_action( 'template_redirect', array( $this, 'template_redirect' ) );
86
- add_action( 'vc_after_init', array( $this, 'js_composer' ) );
87
- }
88
-
89
- /**
90
- * Show the javascripts in the front-end
91
- * Hooked to template_redirect in $this->__construct()
92
- * @access public
93
- */
94
- public function template_redirect() {
95
-
96
- $general = $this->get_option_general();
97
-
98
- if ( isset($general['enable_mobile']) && empty($general['enable_mobile']) && wp_is_mobile() )
99
- return false;
100
-
101
- // Adjust the zoom to WooCommerce 3.0.+
102
- if ( $general['enable_woocommerce'] && class_exists('woocommerce') && version_compare( WC_VERSION, '3.0', '>') ) {
103
- remove_theme_support( 'wc-product-gallery-zoom' );
104
- //remove_theme_support( 'wc-product-gallery-lightbox' );
105
- add_theme_support( 'wc-product-gallery-slider' );
106
-
107
- if ($this->theme('kiddy') || ($this->theme('flatsome') && get_theme_mod('product_gallery_woocommerce'))) {
108
- remove_theme_support( 'wc-product-gallery-slider' );
109
- }
110
-
111
- if ($this->theme('thegem')) {
112
- remove_action('thegem_woocommerce_single_product_left', 'thegem_woocommerce_single_product_gallery', 5);
113
- add_action( 'thegem_woocommerce_single_product_left', 'woocommerce_show_product_images', 20 );
114
- }
115
- }
116
-
117
- add_filter( 'woocommerce_single_product_image_html', array( $this, 'woocommerce_single_product_image_html' ) );
118
- add_filter( 'woocommerce_single_product_image_thumbnail_html', array( $this, 'woocommerce_single_product_image_thumbnail_html' ) );
119
-
120
- add_filter( 'woocommerce_single_product_image_html', array( $this, 'remove_prettyPhoto' ) );
121
- add_filter( 'woocommerce_single_product_image_thumbnail_html', array( $this, 'remove_prettyPhoto' ) );
122
-
123
- add_filter( 'the_content', array( $this, 'find_bigger_image' ), 40 );
124
-
125
- add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
126
- add_action( 'wp_head', array( $this, 'wp_head_compatibilities' ) );
127
-
128
- add_filter( 'wp_calculate_image_srcset', array( $this, 'wp_calculate_image_srcset' ), 40, 5 );
129
- }
130
-
131
- /**
132
- * If the full image isn't in the srcset, then add it
133
- */
134
- function wp_calculate_image_srcset($sources, $size_array, $image_src, $image_meta, $attachment_id ) {
135
- if ( ! isset( $image_meta['width'] ) ) {
136
- return $sources;
137
- }
138
- if ( ! is_array( $sources ) ) {
139
- $sources = array();
140
- }
141
- if ( isset( $sources[ $image_meta['width'] ] ) ) {
142
- return $sources;
143
- }
144
-
145
- if ( is_array($size_array) && count($size_array) == 2
146
- && isset( $size_array[1] ) && isset($image_meta['height'])
147
- && $size_array[1] > 0
148
- && isset($image_meta['width']) && $image_meta['width'] > 0 ) {
149
-
150
- $ratio = $size_array[0] * $image_meta['height'] / $size_array[1] / $image_meta['width'];
151
- if ( $ratio > 1.03 || $ratio < 0.97 ) return $sources;
152
- }
153
-
154
- $url = str_replace( wp_basename( $image_src ), wp_basename( $image_meta['file'] ), $image_src );
155
- $sources[$image_meta['width']] = array(
156
- 'url' => $url,
157
- 'descriptor' => 'w',
158
- 'value' => $image_meta['width'],
159
- );
160
- return $sources;
161
- }
162
-
163
- /**
164
- * Add zoom option in the vc_single_image shortcode in WPBakery
165
- */
166
- function js_composer() {
167
- if ( ! defined( 'WPB_VC_VERSION' ) ) return false;
168
- $param = WPBMap::getParam( 'vc_single_image', 'style' );
169
- if ( is_array( $param ) ) {
170
- $param['value'][__( 'WP Image Zoooom', 'wp-image-zoooom' )] = 'zoooom';
171
- vc_update_shortcode_param( 'vc_single_image', $param );
172
- }
173
- }
174
-
175
- /**
176
- * Add data-thumbnail-src to the main product image
177
- */
178
- function woocommerce_single_product_image_html( $content ) {
179
- if ( !strstr( $content, 'attachment-shop_single' ) ) {
180
- $content = preg_replace('/ class="([^"]+)" alt="/i', ' class="attachment-shop_single $1" alt="', $content);
181
- }
182
- $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'shop_thumbnail' );
183
-
184
- if ( ! isset( $thumbnail[0] ) ) return $content;
185
-
186
- $thumbnail_data = ' data-thumbnail-src="'.$thumbnail[0].'"';
187
-
188
- $content = str_replace( ' title="', $thumbnail_data . ' title="', $content );
189
-
190
- return $content;
191
- }
192
-
193
- /**
194
- * Force the WooCommerce to use the "src" attribute
195
- */
196
- function woocommerce_single_product_image_thumbnail_html( $content ) {
197
- $content = str_replace('class="attachment-shop_single size-shop_single"', 'class="attachment-shop_thumbnail size-shop_thumbnail"', $content);
198
-
199
- if ( !strstr( $content, 'attachment-shop_thumbnail' ) ) {
200
- $content = str_replace(' class="', ' class="attachment-shop_thumbnail ', $content);
201
- }
202
-
203
- if ( strstr( $content, 'attachment-shop_single' ) ) {
204
- $content = str_replace('attachment-shop_single', '', $content);
205
- }
206
-
207
- // Fix for the 2.8.6+ Virtue theme, see https://wordpress.org/support/topic/woocommerce_single_product_image_html-filter/
208
- if ($this->theme('virtue')) {
209
- $content = str_replace('attachment-shop_thumbnail wp-post-image', 'attachment-shop_single wp-post-image', $content);
210
- }
211
- return $content;
212
- }
213
-
214
- /**
215
- * Remove the lightbox
216
- */
217
- function remove_prettyPhoto( $content ) {
218
- $replace = array( 'data-rel="prettyPhoto"', 'data-rel="lightbox"', 'data-rel="prettyPhoto[product-gallery]"', 'data-rel="lightbox[product-gallery]"', 'data-rel="prettyPhoto[]"');
219
-
220
- return str_replace( $replace, 'data-rel="zoomImage"', $content );
221
- }
222
-
223
-
224
- /**
225
- * Find bigger image if class="zoooom" and there is no srcset
226
- *
227
- * Note: the srcset is not be set if for some reason
228
- * the _wp_attachment_metadata for the image is not present
229
- */
230
- function find_bigger_image( $content ) {
231
- if ( ! preg_match_all( '/<img [^>]+>/', $content, $matches ) ) {
232
- return $content;
233
- }
234
-
235
- foreach( $matches[0] as $image ) {
236
- // the image has to have the class "zoooom"
237
- if ( false === strpos( $image, 'zoooom' ) ) {
238
- continue;
239
- }
240
- // the image was tagged to skip this step
241
- if ( false !== strpos( $image, 'skip-data-zoom-image' ) ) {
242
- continue;
243
- }
244
- // the image does not have the srcset
245
- if ( false !== strpos( $image, ' srcset=' ) ) {
246
- continue;
247
- }
248
- // the image has an "-300x400.jpg" type ending
249
- if ( 0 == preg_match( '@ src="([^"]+)(-[0-9]+x[0-9]+).(jpg|png|gif)"@', $image) ) {
250
- continue;
251
- }
252
-
253
- // link the full-sized image to the data-zoom-image attribute
254
- $full_image = preg_replace( '@^(.*) src="(.*)(-[0-9]+x[0-9]+).(jpg|png|gif)"(.*)$@', '$2.$4', $image );
255
- $full_image_attr = ' data-zoom-image="' . $full_image . '"';
256
- $full_image_img = str_replace(' src=', $full_image_attr. ' src=', $image);
257
- $content = str_replace( $image, $full_image_img, $content);
258
- }
259
-
260
- return $content;
261
- }
262
-
263
-
264
- /**
265
- * wp_head compatibilities
266
- */
267
- function wp_head_compatibilities() {
268
- $theme = get_template();
269
-
270
- $opt = $this->get_option_general();
271
-
272
- // These themes add a wrapper on the whole page with index higher than the zoom
273
- $wrapper_themes = array(
274
- array(
275
- 'rule' => '.wrapper { z-index: 40 !important; }',
276
- 'themes' => array('bridge', 'nouveau', 'stockholm', 'tactile', 'vigor', 'homa', 'hudsonwp', 'borderland', 'moose'),
277
- ),
278
- array(
279
- 'rule' => '.qodef-wrapper { z-index: 200 !important; }',
280
- 'themes' => array('kloe', 'startit', 'kudos', 'moments', 'ayro', 'suprema', 'ultima', 'geko', 'target', 'coney', 'aton', 'ukiyo', 'zenit', 'mixtape', 'scribbler', 'alecta', 'cityrama', 'bazaar'),
281
- ),
282
- array(
283
- 'rule' => '.edgtf-wrapper { z-index: 40 !important; }',
284
- 'themes' => array('quadric', 'oxides', 'kvadrat', 'magazinevibe', 'kolumn', 'skyetheme', 'conall', 'dorianwp', 'node', 'ratio', 'escher', 'fair', 'assemble', 'any', 'walker', 'freestyle', 'shuffle', 'vangard', 'fuzion', 'crimson', 'cozy', 'xpo', 'onschedule', 'illustrator', 'oberon', 'fluid', 'barista', 'kamera', 'revolver', 'baker', 'rebellion', 'goodwish', 'maison', 'silverscreen', 'sovereign', 'atmosphere', 'dekko', 'objektiv', 'okami', 'coyote', 'bumblebee', 'blaze', 'mediadesk', 'penumbra', 'pxlz', 'gastrobar', 'aalto', 'dishup', 'voevod', 'orkan', 'fierce', 'grayson', 'hyperon', 'pintsandcrafts', 'haar', 'polyphonic', 'offbeat', 'hereford', 'kvell', 'sarto', 'journo', 'cinerama', 'ottar', 'playerx', 'kenozoik', 'elaine', 'entropia', 'tetsuo', 'bitpal', 'tahoe', 'urbango', 'smilte', 'neralbo', 'galatia', 'mintus', 'manon'),
285
- ),
286
- array(
287
- 'rule' => '.edge-wrapper { z-index: 40 !important; }',
288
- 'themes' => array('dieter', 'anders', 'adorn', 'creedence', 'noizzy'),
289
- ),
290
- array(
291
- 'rule' => '.edgt-wrapper { z-index: 40 !important; }',
292
- 'themes' => array('shade', 'eldritch', 'morsel', 'educator', 'milieu'),
293
- ),
294
- array(
295
- 'rule' => '.sidebar-menu-push { z-index: 40 !important; }',
296
- 'themes' => array('artcore'),
297
- ),
298
- array(
299
- 'rule' => '.eltdf-wrapper { z-index: 40 !important; }',
300
- 'themes' => array('readanddigest', 'tomasdaisy', 'virtuoso', 'blu', 'superfood', 'ambient', 'koto', 'azaleawp', 'all4home', 'mrseo', 'vibez', 'sweettooth', 'halogen', 'vino', 'ion', 'satine', 'nightshade', 'esmarts', 'makoto', 'mane', 'imogen', 'yvette', 'gourmand', 'sceon', 'calla', 'corretto', 'allston'),
301
- ),
302
- array(
303
- 'rule' => '.eltd-wrapper { z-index: 40 !important; }',
304
- 'themes' => array('woly', 'averly', 'search-and-go', 'flow', 'kreate', 'allure', 'chandelier', 'malmo', 'minnesota', 'newsroom', 'kendall', 'savory', 'creator', 'awake', 'diorama', 'medipoint', 'audrey', 'findme', 'april', 'bizfinder', 'bjorn', 'trackstore', 'albergo', 'vakker', 'tamashi', 'bonvoyage')
305
- ),
306
- // Next three rules are to the Mikado-Themes
307
- array(
308
- 'rule' => '.wrapper {z-index: 20 !important; }',
309
- 'themes' => array('mikado1', 'onyx', 'hornet', 'burst')
310
- ),
311
- array(
312
- 'rule' => '.mkdf-wrapper {z-index: 20 !important; }',
313
- 'themes' => array('chillnews', 'deploy', 'piquant', 'optimizewp', 'wellspring', 'siennawp', 'hashmag', 'voyagewp', 'gotravel', 'verdict', 'mediclinic', 'iacademy', 'newsflash', 'evently', 'cortex', 'roam', 'lumiere', 'aviana', 'zuhaus', 'staffscout', 'kastell', 'fivestar', 'janeandmark', 'neva', 'klippe', 'rosebud', 'endurer', 'wanderers', 'anwalt', 'equine', 'verdure', 'brewski', 'curly', 'fiorello', 'bardwp', 'lilo', 'gluck', 'dotwork', 'eola', 'cocco', 'housemed', 'ande', 'foton', 'overton', 'kanna', 'attika', 'backpacktraveller'),
314
- ),
315
- array(
316
- 'rule' => '.mkd-wrapper {z-index: 20 !important; }',
317
- 'themes' => array('libero', 'discussionwp', 'hue', 'medigroup', 'newshub', 'affinity', 'hotspot', 'industrialist', 'pinata', 'cornerstone', 'connectwp', 'opportunity', 'highrise', 'anahata', 'hoshi', 'fleur', 'sparks', 'topfit', 'depot', 'trophy', 'motorepair', 'citycruise', 'indigo', 'servicemaster', 'lister', 'renovator', 'ecologist', 'buro', 'cyberstore', 'appetito', 'grillandchow', 'baumeister', 'kalos', 'fuego', 'entre'),
318
- ),
319
-
320
- array(
321
- 'rule' => '#boxed { z-index: 840 !important; }',
322
- 'themes' => array('salient'),
323
- ),
324
- );
325
-
326
- foreach( $wrapper_themes as $_v ) {
327
- if ( in_array($theme, $_v['themes'] ) ) {
328
- echo '<style type="text/css">' . $_v['rule'] . '</style>'. PHP_EOL;
329
- }
330
- }
331
-
332
- if ($this->theme('thegem') && $opt['enable_woocommerce'] && class_exists('woocommerce') && version_compare( WC_VERSION, '3.0', '>') ) { ?>
333
- <style type="text/css">
334
- .single-product div.product .woocommerce-product-gallery .attachment-shop_thumbnail {width: 100%;height: 100%;}
335
- .single-product div.product .woocommerce-product-gallery .flex-control-thumbs {margin: 0;padding: 0;margin-top: 10px;}
336
- .single-product div.product .woocommerce-product-gallery .flex-control-thumbs::before {content: "";display: table;}
337
- .single-product div.product .woocommerce-product-gallery.woocommerce-product-gallery--columns-4 .flex-control-thumbs li {width: 24.2857142857%;float: left;}
338
- .single-product div.product .woocommerce-product-gallery .flex-control-thumbs li {list-style: none;margin-bottom: 1.618em;cursor: pointer;}
339
- </style>
340
- <?php }
341
-
342
- if ( $this->theme( 'brooklyn' ) && $opt['enable_woocommerce'] && class_exists('woocommerce') && version_compare( WC_VERSION, '3.0', '>') ) { ?>
 
 
 
 
 
 
 
 
 
 
343
  <style type="text/css">
344
  .woocommerce div.product div.images .woocommerce-product-gallery__wrapper { -webkit-box-pack: start; -ms-flex-pack: start; justify-content: start; }
345
  </style>
346
- <?php }
347
-
348
-
349
- if ( defined('LP_PLUGIN_FILE')) {
350
- echo '<style type="text/css">body.content-item-only .learn-press-content-item-only { z-index: 990; } .single-lp_course #wpadminbar{z-index:900;}</style>' . PHP_EOL;
351
- }
352
- if (class_exists('WP_Image_Hotspot') ) {
353
- echo '<style type="text/css">.point_style.ihotspot_tooltop_html {z-index: 1003}</style>';
354
- }
355
- if ( defined('ELEMENTOR_VERSION')) {
356
- echo '<style type="text/css">.dialog-lightbox-widget-content[style] { top: 0 !important; left: 0 !important;}</style>' . PHP_EOL;
357
- }
358
-
359
- }
360
-
361
-
362
- /**
363
- * Enqueue the jquery.image_zoom.js
364
- * Hooked to wp_enqueue_scripts in $this->template_redirect
365
- * @access public
366
- */
367
- public function wp_enqueue_scripts() {
368
- $v = IMAGE_ZOOM_VERSION;
369
- $url = IMAGE_ZOOM_URL;
370
- $prefix = '.min';
371
-
372
- // Load the jquery.image_zoom.js
373
- wp_register_script( 'image_zoooom', $url.'assets/js/jquery.image_zoom'.$prefix.'.js', array( 'jquery' ), $v, false);
374
- wp_enqueue_script( 'image_zoooom' );
375
-
376
- // Load the image_zoom-init.js
377
- wp_register_script( 'image_zoooom-init', $url. 'assets/js/image_zoom-init.js', array( 'jquery' ), $v, false);
378
- wp_localize_script( 'image_zoooom-init', 'IZ', $this->get_localize_vars());
379
- wp_enqueue_script( 'image_zoooom-init' );
380
-
381
- // Remove the prettyPhoto
382
- if ( $this->woocommerce_is_active() && function_exists('is_product') && is_product() ) {
383
- wp_dequeue_script( 'prettyPhoto' );
384
- wp_dequeue_script( 'prettyPhoto-init' );
385
- }
386
-
387
- if ( $this->theme('sovereign') ) {
388
- wp_enqueue_script( 'prettyPhoto' );
389
- wp_enqueue_script( 'prettyPhoto-init' );
390
- }
391
- }
392
-
393
- function get_localize_vars() {
394
- $general = $this->get_option_general();
395
- $options = $this->get_options_for_zoom();
396
-
397
- $default = array(
398
- 'with_woocommerce' => '1',
399
- 'exchange_thumbnails' => '1',
400
- 'woo_categories' => (isset($general['woo_cat']) && $general['woo_cat'] == 1 ) ? '1' : '0',
401
- 'enable_mobile' => $general['enable_mobile'],
402
- 'options' => $options,
403
- 'woo_slider' => '0',
404
- );
405
-
406
- if (class_exists('woocommerce') && version_compare( WC_VERSION, '3.0', '>') && current_theme_supports( 'wc-product-gallery-slider' )) {
407
- $default['woo_slider'] = 1;
408
- }
409
-
410
- $with_woocommerce = true;
411
- if ( ! $this->woocommerce_is_active() )
412
- $default['with_woocommerce'] = '0';
413
-
414
- if ( !function_exists( 'is_product' ) || !is_product() )
415
- $default['with_woocommerce'] = '0';
416
-
417
- if ( isset($general['enable_woocommerce']) && empty($general['enable_woocommerce']))
418
- $default['with_woocommerce'] = '0';
419
-
420
- if ( isset($general['exchange_thumbnails']) && empty($general['exchange_thumbnails']))
421
- $default['exchange_thumbnails'] = '0';
422
-
423
- return $default;
424
- }
425
-
426
- function get_options_for_zoom() {
427
- $i = get_option( 'zoooom_settings' );
428
- $o = array();
429
-
430
- switch ( $i['lensShape'] ) {
431
- case 'none' :
432
- $o = array(
433
- 'zoomType' => 'inner',
434
- 'cursor' => $i['cursorType'],
435
- 'easingAmount' => $i['zwEasing'],
436
- );
437
- break;
438
- case 'square' :
439
- case 'round' :
440
- $o = array(
441
- 'lensShape' => $i['lensShape'],
442
- 'zoomType' => 'lens',
443
- 'lensSize' => $i['lensSize'],
444
- 'borderSize' => $i['borderThickness'],
445
- 'borderColour' => $i['borderColor'],
446
- 'cursor' => $i['cursorType'],
447
- 'lensFadeIn' => $i['lensFade'],
448
- 'lensFadeOut' => $i['lensFade'],
449
- );
450
- if ( $i['tint'] == true ) {
451
- $o['tint'] = 'true';
452
- $o['tintColour'] = $i['tintColor'];
453
- $o['tintOpacity'] = $i['tintOpacity'];
454
- }
455
-
456
- break;
457
- case 'square' :
458
- break;
459
- case 'zoom_window' :
460
- $o = array(
461
- 'lensShape' => 'square',
462
- 'lensSize' => $i['lensSize'],
463
- 'lensBorderSize' => $i['borderThickness'],
464
- 'lensBorderColour' => $i['borderColor'],
465
- 'borderRadius' => $i['zwBorderRadius'],
466
- 'cursor' => $i['cursorType'],
467
- 'zoomWindowWidth' => $i['zwWidth'],
468
- 'zoomWindowHeight' => $i['zwHeight'],
469
- 'zoomWindowOffsetx' => $i['zwPadding'],
470
- 'borderSize' => $i['zwBorderThickness'],
471
- 'borderColour' => $i['zwBorderColor'],
472
- 'zoomWindowShadow' => $i['zwShadow'],
473
- 'lensFadeIn' => $i['lensFade'],
474
- 'lensFadeOut' => $i['lensFade'],
475
- 'zoomWindowFadeIn' => $i['zwFade'],
476
- 'zoomWindowFadeOut' => $i['zwFade'],
477
- 'easingAmount' => $i['zwEasing'],
478
- );
479
-
480
- if ( $i['tint'] == true ) {
481
- $o['tint'] = 'true';
482
- $o['tintColour'] = $i['tintColor'];
483
- $o['tintOpacity'] = $i['tintOpacity'];
484
- }
485
-
486
- break;
487
- }
488
- return $o;
489
- }
490
-
491
-
492
-
493
- /** Helper function ****************************************/
494
-
495
- public function theme($string) {
496
- $string = strtolower($string);
497
- if (empty($this->theme)) {
498
- $this->theme = strtolower(get_template());
499
- }
500
- if (strpos($this->theme, $string ) !== false)
501
- return true;
502
-
503
- return false;
504
- }
505
-
506
-
507
- /**
508
- * Check if WooCommerce is activated
509
- * @access public
510
- * @return bool
511
- */
512
- public function woocommerce_is_active() {
513
- if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
514
- return true;
515
- }
516
- return false;
517
- }
518
-
519
- public function get_option_general() {
520
- $general = get_option('zoooom_general');
521
-
522
- if (!isset($general['enable_woocommerce']))
523
- $general['enable_woocommerce'] = true;
524
-
525
- if (!isset($general['exchange_thumbnails']))
526
- $general['exchange_thumbnails'] = true;
527
-
528
- if ( !isset( $general['enable_mobile'] ) )
529
- $general['enable_mobile'] = false;
530
-
531
- $general['force_woocommerce'] = false;
532
-
533
- if ( !isset( $general['woo_cat'] ) )
534
- $general['woo_cat'] = false;
535
-
536
- if ( ! $this->woocommerce_is_active() ) {
537
- $general['woo_cat'] = false;
538
- }
539
-
540
- return $general;
541
- }
542
-
543
- public function load_plugin_textdomain() {
544
- load_plugin_textdomain( 'wp-image-zoooom', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
545
- }
 
 
 
 
 
 
 
 
 
 
 
546
 
547
 
548
 
549
- }
550
 
551
- endif;
552
 
553
  /**
554
  * Returns the main instance of ImageZoooom
@@ -556,7 +577,7 @@ endif;
556
  * @return ImageZoooom
557
  */
558
  function ImageZoooom() {
559
- return ImageZoooom::instance();
560
  }
561
 
562
  ImageZoooom();
@@ -566,16 +587,16 @@ ImageZoooom();
566
  * */
567
  function wp_image_zoooom_plugin_action_links( $links ) {
568
 
569
- $settings_link = '<a href="admin.php?page=zoooom_settings">' .
570
- esc_html( __('Settings', 'wp-image-zoooom' ) ) . '</a>';
571
 
572
- return array_merge( array( $settings_link), $links );
573
 
574
  }
575
- add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'wp_image_zoooom_plugin_action_links' );
576
 
577
  if ( ! function_exists( 'x_disable_wp_image_srcset' ) ) :
578
- function x_disable_wp_image_srcset() {
579
- return true;
580
- }
581
  endif;
2
  /**
3
  * Plugin Name: WP Image Zoom
4
  * Plugin URI: https://wordpress.org/plugins/wp-image-zoooom/
5
+ * Description: Add zoom effect over the an image, whether it is an image in a post/page or the featured image of a product in a WooCommerce shop
6
+ * Version: 1.39.2
7
+ * Author: SilkyPress
8
  * Author URI: https://www.silkypress.com
9
  * License: GPL2
10
  *
16
  */
17
 
18
  if ( ! defined( 'ABSPATH' ) ) {
19
+ exit; // Exit if accessed directly
20
  }
21
 
22
  if ( ! class_exists( 'ImageZoooom' ) ) :
23
+ /**
24
+ * Main ImageZoooom Class
25
+ *
26
+ * @class ImageZoooom
27
+ */
28
+ final class ImageZoooom {
29
+ public $version = '1.39.2';
30
+ public $theme = '';
31
+ protected static $_instance = null;
32
+
33
+
34
+ /**
35
+ * Main ImageZoooom Instance
36
+ *
37
+ * Ensures only one instance of ImageZoooom is loaded or can be loaded
38
+ *
39
+ * @static
40
+ * @return ImageZoooom - Main instance
41
+ */
42
+ public static function instance() {
43
+ if ( is_null( self::$_instance ) ) {
44
+ self::$_instance = new self();
45
+ }
46
+ return self::$_instance;
47
+ }
48
+
49
+ /**
50
+ * Cloning is forbidden.
51
+ */
52
+ public function __clone() {
53
+ _doing_it_wrong( __FUNCTION__, __( 'An error has occurred. Please reload the page and try again.' ), '1.0' );
54
+ }
55
+
56
+ /**
57
+ * Unserializing instances of this class is forbidden.
58
+ */
59
+ public function __wakeup() {
60
+ _doing_it_wrong( __FUNCTION__, __( 'An error has occurred. Please reload the page and try again.' ), '1.0' );
61
+ }
62
+
63
+ /**
64
+ * Image Zoooom Constructor
65
+ *
66
+ * @access public
67
+ * @return ImageZoooom
68
+ */
69
+ public function __construct() {
70
+ global $_wp_theme_features;
71
+
72
+ define( 'IMAGE_ZOOM_FILE', __FILE__ );
73
+ define( 'IMAGE_ZOOM_URL', plugins_url( '/', __FILE__ ) );
74
+ define( 'IMAGE_ZOOM_PATH', plugin_dir_path( __FILE__ ) );
75
+ define( 'IMAGE_ZOOM_VERSION', $this->version );
76
+
77
+ $this->theme = strtolower( get_template() );
78
+ include_once 'includes/settings.php';
79
+
80
+ if ( is_admin() ) {
81
+ $this->load_plugin_textdomain();
82
+ include_once 'includes/admin-side.php';
83
+ new ImageZoooom_Admin();
84
+ }
85
+ add_action( 'template_redirect', array( $this, 'template_redirect' ) );
86
+ add_action( 'vc_after_init', array( $this, 'js_composer' ) );
87
+ }
88
+
89
+ /**
90
+ * Show the javascripts in the front-end
91
+ * Hooked to template_redirect in $this->__construct()
92
+ *
93
+ * @access public
94
+ */
95
+ public function template_redirect() {
96
+
97
+ $general = $this->get_option_general();
98
+
99
+ if ( isset( $general['enable_mobile'] ) && empty( $general['enable_mobile'] ) && wp_is_mobile() ) {
100
+ return false;
101
+ }
102
+
103
+ // Adjust the zoom to WooCommerce 3.0.+
104
+ if ( $general['enable_woocommerce'] && class_exists( 'woocommerce' ) && version_compare( WC_VERSION, '3.0', '>' ) ) {
105
+ remove_theme_support( 'wc-product-gallery-zoom' );
106
+ // remove_theme_support( 'wc-product-gallery-lightbox' );
107
+ add_theme_support( 'wc-product-gallery-slider' );
108
+
109
+ if ( $this->theme( 'kiddy' ) || ( $this->theme( 'flatsome' ) && ! get_theme_mod( 'product_gallery_woocommerce' ) ) ) {
110
+ remove_theme_support( 'wc-product-gallery-slider' );
111
+ }
112
+
113
+ if ( $this->theme( 'thegem' ) ) {
114
+ remove_action( 'thegem_woocommerce_single_product_left', 'thegem_woocommerce_single_product_gallery', 5 );
115
+ add_action( 'thegem_woocommerce_single_product_left', 'woocommerce_show_product_images', 20 );
116
+ }
117
+ }
118
+
119
+ add_filter( 'woocommerce_single_product_image_html', array( $this, 'woocommerce_single_product_image_html' ) );
120
+ add_filter( 'woocommerce_single_product_image_thumbnail_html', array( $this, 'woocommerce_single_product_image_thumbnail_html' ) );
121
+
122
+ add_filter( 'woocommerce_single_product_image_html', array( $this, 'remove_prettyPhoto' ) );
123
+ add_filter( 'woocommerce_single_product_image_thumbnail_html', array( $this, 'remove_prettyPhoto' ) );
124
+
125
+ add_filter( 'the_content', array( $this, 'find_bigger_image' ), 40 );
126
+
127
+ add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
128
+ add_action( 'wp_head', array( $this, 'wp_head_compatibilities' ) );
129
+
130
+ add_filter( 'wp_calculate_image_srcset', array( $this, 'wp_calculate_image_srcset' ), 40, 5 );
131
+ }
132
+
133
+ /**
134
+ * If the full image isn't in the srcset, then add it
135
+ */
136
+ function wp_calculate_image_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ) {
137
+ if ( ! isset( $image_meta['width'] ) ) {
138
+ return $sources;
139
+ }
140
+ if ( ! is_array( $sources ) ) {
141
+ $sources = array();
142
+ }
143
+ if ( isset( $sources[ $image_meta['width'] ] ) ) {
144
+ return $sources;
145
+ }
146
+
147
+ if ( is_array( $size_array ) && count( $size_array ) == 2
148
+ && isset( $size_array[1] ) && isset( $image_meta['height'] )
149
+ && $size_array[1] > 0
150
+ && isset( $image_meta['width'] ) && $image_meta['width'] > 0 ) {
151
+
152
+ $ratio = $size_array[0] * $image_meta['height'] / $size_array[1] / $image_meta['width'];
153
+ if ( $ratio > 1.03 || $ratio < 0.97 ) {
154
+ return $sources;
155
+ }
156
+ }
157
+
158
+ $url = str_replace( wp_basename( $image_src ), wp_basename( $image_meta['file'] ), $image_src );
159
+ $sources[ $image_meta['width'] ] = array(
160
+ 'url' => $url,
161
+ 'descriptor' => 'w',
162
+ 'value' => $image_meta['width'],
163
+ );
164
+ return $sources;
165
+ }
166
+
167
+ /**
168
+ * Add zoom option in the vc_single_image shortcode in WPBakery
169
+ */
170
+ function js_composer() {
171
+ if ( ! defined( 'WPB_VC_VERSION' ) ) {
172
+ return false;
173
+ }
174
+ $param = WPBMap::getParam( 'vc_single_image', 'style' );
175
+ if ( is_array( $param ) ) {
176
+ $param['value'][ __( 'WP Image Zoooom', 'wp-image-zoooom' ) ] = 'zoooom';
177
+ vc_update_shortcode_param( 'vc_single_image', $param );
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Add data-thumbnail-src to the main product image
183
+ */
184
+ function woocommerce_single_product_image_html( $content ) {
185
+ if ( ! strstr( $content, 'attachment-shop_single' ) ) {
186
+ $content = preg_replace( '/ class="([^"]+)" alt="/i', ' class="attachment-shop_single $1" alt="', $content );
187
+ }
188
+ $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'shop_thumbnail' );
189
+
190
+ if ( ! isset( $thumbnail[0] ) ) {
191
+ return $content;
192
+ }
193
+
194
+ $thumbnail_data = ' data-thumbnail-src="' . $thumbnail[0] . '"';
195
+
196
+ $content = str_replace( ' title="', $thumbnail_data . ' title="', $content );
197
+
198
+ return $content;
199
+ }
200
+
201
+ /**
202
+ * Force the WooCommerce to use the "src" attribute
203
+ */
204
+ function woocommerce_single_product_image_thumbnail_html( $content ) {
205
+ $content = str_replace( 'class="attachment-shop_single size-shop_single"', 'class="attachment-shop_thumbnail size-shop_thumbnail"', $content );
206
+
207
+ if ( ! strstr( $content, 'attachment-shop_thumbnail' ) ) {
208
+ $content = str_replace( ' class="', ' class="attachment-shop_thumbnail ', $content );
209
+ }
210
+
211
+ if ( strstr( $content, 'attachment-shop_single' ) ) {
212
+ $content = str_replace( 'attachment-shop_single', '', $content );
213
+ }
214
+
215
+ // Fix for the 2.8.6+ Virtue theme, see https://wordpress.org/support/topic/woocommerce_single_product_image_html-filter/
216
+ if ( $this->theme( 'virtue' ) ) {
217
+ $content = str_replace( 'attachment-shop_thumbnail wp-post-image', 'attachment-shop_single wp-post-image', $content );
218
+ }
219
+ return $content;
220
+ }
221
+
222
+ /**
223
+ * Remove the lightbox
224
+ */
225
+ function remove_prettyPhoto( $content ) {
226
+ $replace = array( 'data-rel="prettyPhoto"', 'data-rel="lightbox"', 'data-rel="prettyPhoto[product-gallery]"', 'data-rel="lightbox[product-gallery]"', 'data-rel="prettyPhoto[]"' );
227
+
228
+ return str_replace( $replace, 'data-rel="zoomImage"', $content );
229
+ }
230
+
231
+
232
+ /**
233
+ * Find bigger image if class="zoooom" and there is no srcset
234
+ *
235
+ * Note: the srcset is not be set if for some reason
236
+ * the _wp_attachment_metadata for the image is not present
237
+ */
238
+ function find_bigger_image( $content ) {
239
+ if ( ! preg_match_all( '/<img [^>]+>/', $content, $matches ) ) {
240
+ return $content;
241
+ }
242
+
243
+ foreach ( $matches[0] as $image ) {
244
+ // the image has to have the class "zoooom"
245
+ if ( false === strpos( $image, 'zoooom' ) ) {
246
+ continue;
247
+ }
248
+ // the image was tagged to skip this step
249
+ if ( false !== strpos( $image, 'skip-data-zoom-image' ) ) {
250
+ continue;
251
+ }
252
+ // the image does not have the srcset
253
+ if ( false !== strpos( $image, ' srcset=' ) ) {
254
+ continue;
255
+ }
256
+ // the image has an "-300x400.jpg" type ending
257
+ if ( 0 == preg_match( '@ src="([^"]+)(-[0-9]+x[0-9]+).(jpg|png|gif)"@', $image ) ) {
258
+ continue;
259
+ }
260
+
261
+ // link the full-sized image to the data-zoom-image attribute
262
+ $full_image = preg_replace( '@^(.*) src="(.*)(-[0-9]+x[0-9]+).(jpg|png|gif)"(.*)$@', '$2.$4', $image );
263
+ $full_image_attr = ' data-zoom-image="' . $full_image . '"';
264
+ $full_image_img = str_replace( ' src=', $full_image_attr . ' src=', $image );
265
+ $content = str_replace( $image, $full_image_img, $content );
266
+ }
267
+
268
+ return $content;
269
+ }
270
+
271
+
272
+ /**
273
+ * wp_head compatibilities
274
+ */
275
+ function wp_head_compatibilities() {
276
+ $theme = get_template();
277
+
278
+ $opt = $this->get_option_general();
279
+
280
+ // These themes add a wrapper on the whole page with index higher than the zoom
281
+ $wrapper_themes = array(
282
+ array(
283
+ 'rule' => '.wrapper { z-index: 40 !important; }',
284
+ 'themes' => array( 'bridge', 'nouveau', 'stockholm', 'tactile', 'vigor', 'homa', 'hudsonwp', 'borderland', 'moose' ),
285
+ ),
286
+ array(
287
+ 'rule' => '.qodef-wrapper { z-index: 200 !important; }',
288
+ 'themes' => array( 'kloe', 'startit', 'kudos', 'moments', 'ayro', 'suprema', 'ultima', 'geko', 'target', 'coney', 'aton', 'ukiyo', 'zenit', 'mixtape', 'scribbler', 'alecta', 'cityrama', 'bazaar' ),
289
+ ),
290
+ array(
291
+ 'rule' => '.edgtf-wrapper { z-index: 40 !important; }',
292
+ 'themes' => array( 'quadric', 'oxides', 'kvadrat', 'magazinevibe', 'kolumn', 'skyetheme', 'conall', 'dorianwp', 'node', 'ratio', 'escher', 'fair', 'assemble', 'any', 'walker', 'freestyle', 'shuffle', 'vangard', 'fuzion', 'crimson', 'cozy', 'xpo', 'onschedule', 'illustrator', 'oberon', 'fluid', 'barista', 'kamera', 'revolver', 'baker', 'rebellion', 'goodwish', 'maison', 'silverscreen', 'sovereign', 'atmosphere', 'dekko', 'objektiv', 'okami', 'coyote', 'bumblebee', 'blaze', 'mediadesk', 'penumbra', 'pxlz', 'gastrobar', 'aalto', 'dishup', 'voevod', 'orkan', 'fierce', 'grayson', 'hyperon', 'pintsandcrafts', 'haar', 'polyphonic', 'offbeat', 'hereford', 'kvell', 'sarto', 'journo', 'cinerama', 'ottar', 'playerx', 'kenozoik', 'elaine', 'entropia', 'tetsuo', 'bitpal', 'tahoe', 'urbango', 'smilte', 'neralbo', 'galatia', 'mintus', 'manon' ),
293
+ ),
294
+ array(
295
+ 'rule' => '.edge-wrapper { z-index: 40 !important; }',
296
+ 'themes' => array( 'dieter', 'anders', 'adorn', 'creedence', 'noizzy' ),
297
+ ),
298
+ array(
299
+ 'rule' => '.edgt-wrapper { z-index: 40 !important; }',
300
+ 'themes' => array( 'shade', 'eldritch', 'morsel', 'educator', 'milieu' ),
301
+ ),
302
+ array(
303
+ 'rule' => '.sidebar-menu-push { z-index: 40 !important; }',
304
+ 'themes' => array( 'artcore' ),
305
+ ),
306
+ array(
307
+ 'rule' => '.eltdf-wrapper { z-index: 40 !important; }',
308
+ 'themes' => array( 'readanddigest', 'tomasdaisy', 'virtuoso', 'blu', 'superfood', 'ambient', 'koto', 'azaleawp', 'all4home', 'mrseo', 'vibez', 'sweettooth', 'halogen', 'vino', 'ion', 'satine', 'nightshade', 'esmarts', 'makoto', 'mane', 'imogen', 'yvette', 'gourmand', 'sceon', 'calla', 'corretto', 'allston' ),
309
+ ),
310
+ array(
311
+ 'rule' => '.eltd-wrapper { z-index: 40 !important; }',
312
+ 'themes' => array( 'woly', 'averly', 'search-and-go', 'flow', 'kreate', 'allure', 'chandelier', 'malmo', 'minnesota', 'newsroom', 'kendall', 'savory', 'creator', 'awake', 'diorama', 'medipoint', 'audrey', 'findme', 'april', 'bizfinder', 'bjorn', 'trackstore', 'albergo', 'vakker', 'tamashi', 'bonvoyage' ),
313
+ ),
314
+ // Next three rules are to the Mikado-Themes
315
+ array(
316
+ 'rule' => '.wrapper {z-index: 20 !important; }',
317
+ 'themes' => array( 'mikado1', 'onyx', 'hornet', 'burst' ),
318
+ ),
319
+ array(
320
+ 'rule' => '.mkdf-wrapper {z-index: 20 !important; }',
321
+ 'themes' => array( 'chillnews', 'deploy', 'piquant', 'optimizewp', 'wellspring', 'siennawp', 'hashmag', 'voyagewp', 'gotravel', 'verdict', 'mediclinic', 'iacademy', 'newsflash', 'evently', 'cortex', 'roam', 'lumiere', 'aviana', 'zuhaus', 'staffscout', 'kastell', 'fivestar', 'janeandmark', 'neva', 'klippe', 'rosebud', 'endurer', 'wanderers', 'anwalt', 'equine', 'verdure', 'brewski', 'curly', 'fiorello', 'bardwp', 'lilo', 'gluck', 'dotwork', 'eola', 'cocco', 'housemed', 'ande', 'foton', 'overton', 'kanna', 'attika', 'backpacktraveller' ),
322
+ ),
323
+ array(
324
+ 'rule' => '.mkd-wrapper {z-index: 20 !important; }',
325
+ 'themes' => array( 'libero', 'discussionwp', 'hue', 'medigroup', 'newshub', 'affinity', 'hotspot', 'industrialist', 'pinata', 'cornerstone', 'connectwp', 'opportunity', 'highrise', 'anahata', 'hoshi', 'fleur', 'sparks', 'topfit', 'depot', 'trophy', 'motorepair', 'citycruise', 'indigo', 'servicemaster', 'lister', 'renovator', 'ecologist', 'buro', 'cyberstore', 'appetito', 'grillandchow', 'baumeister', 'kalos', 'fuego', 'entre' ),
326
+ ),
327
+
328
+ array(
329
+ 'rule' => '#boxed { z-index: 840 !important; }',
330
+ 'themes' => array( 'salient' ),
331
+ ),
332
+ );
333
+
334
+ foreach ( $wrapper_themes as $_v ) {
335
+ if ( in_array( $theme, $_v['themes'] ) ) {
336
+ echo '<style type="text/css">' . $_v['rule'] . '</style>' . PHP_EOL;
337
+ }
338
+ }
339
+
340
+ if ( $this->theme( 'thegem' ) && $opt['enable_woocommerce'] && class_exists( 'woocommerce' ) && version_compare( WC_VERSION, '3.0', '>' ) ) { ?>
341
+ <style type="text/css">
342
+ .single-product div.product .woocommerce-product-gallery .attachment-shop_thumbnail {width: 100%;height: 100%;}
343
+ .single-product div.product .woocommerce-product-gallery .flex-control-thumbs {margin: 0;padding: 0;margin-top: 10px;}
344
+ .single-product div.product .woocommerce-product-gallery .flex-control-thumbs::before {content: "";display: table;}
345
+ .single-product div.product .woocommerce-product-gallery.woocommerce-product-gallery--columns-4 .flex-control-thumbs li {width: 24.2857142857%;float: left;}
346
+ .single-product div.product .woocommerce-product-gallery .flex-control-thumbs li {list-style: none;margin-bottom: 1.618em;cursor: pointer;}
347
+ </style>
348
+ <?php
349
+ }
350
+
351
+ if ( $this->theme( 'brooklyn' ) && $opt['enable_woocommerce'] && class_exists( 'woocommerce' ) && version_compare( WC_VERSION, '3.0', '>' ) ) {
352
+ ?>
353
  <style type="text/css">
354
  .woocommerce div.product div.images .woocommerce-product-gallery__wrapper { -webkit-box-pack: start; -ms-flex-pack: start; justify-content: start; }
355
  </style>
356
+ <?php
357
+ }
358
+
359
+ if ( defined( 'LP_PLUGIN_FILE' ) ) {
360
+ echo '<style type="text/css">body.content-item-only .learn-press-content-item-only { z-index: 990; } .single-lp_course #wpadminbar{z-index:900;}</style>' . PHP_EOL;
361
+ }
362
+ if ( class_exists( 'WP_Image_Hotspot' ) ) {
363
+ echo '<style type="text/css">.point_style.ihotspot_tooltop_html {z-index: 1003}</style>';
364
+ }
365
+ if ( defined( 'ELEMENTOR_VERSION' ) ) {
366
+ echo '<style type="text/css">.dialog-lightbox-widget-content[style] { top: 0 !important; left: 0 !important;}</style>' . PHP_EOL;
367
+ }
368
+
369
+ }
370
+
371
+
372
+ /**
373
+ * Enqueue the jquery.image_zoom.js
374
+ * Hooked to wp_enqueue_scripts in $this->template_redirect
375
+ *
376
+ * @access public
377
+ */
378
+ public function wp_enqueue_scripts() {
379
+ $v = IMAGE_ZOOM_VERSION;
380
+ $url = IMAGE_ZOOM_URL;
381
+ $prefix = '.min';
382
+
383
+ // Load the jquery.image_zoom.js
384
+ wp_register_script( 'image_zoooom', $url . 'assets/js/jquery.image_zoom' . $prefix . '.js', array( 'jquery' ), $v, false );
385
+ wp_enqueue_script( 'image_zoooom' );
386
+
387
+ // Load the image_zoom-init.js
388
+ wp_register_script( 'image_zoooom-init', $url . 'assets/js/image_zoom-init.js', array( 'jquery' ), $v, false );
389
+ wp_localize_script( 'image_zoooom-init', 'IZ', $this->get_localize_vars() );
390
+ wp_enqueue_script( 'image_zoooom-init' );
391
+
392
+ // Remove the prettyPhoto
393
+ if ( $this->woocommerce_is_active() && function_exists( 'is_product' ) && is_product() ) {
394
+ wp_dequeue_script( 'prettyPhoto' );
395
+ wp_dequeue_script( 'prettyPhoto-init' );
396
+ }
397
+
398
+ if ( $this->theme( 'sovereign' ) ) {
399
+ wp_enqueue_script( 'prettyPhoto' );
400
+ wp_enqueue_script( 'prettyPhoto-init' );
401
+ }
402
+ }
403
+
404
+ function get_localize_vars() {
405
+ $general = $this->get_option_general();
406
+ $options = $this->get_options_for_zoom();
407
+
408
+ $default = array(
409
+ 'with_woocommerce' => '1',
410
+ 'exchange_thumbnails' => '1',
411
+ 'woo_categories' => ( isset( $general['woo_cat'] ) && $general['woo_cat'] == 1 ) ? '1' : '0',
412
+ 'enable_mobile' => $general['enable_mobile'],
413
+ 'options' => $options,
414
+ 'woo_slider' => '0',
415
+ );
416
+
417
+ if ( class_exists( 'woocommerce' ) && version_compare( WC_VERSION, '3.0', '>' ) && current_theme_supports( 'wc-product-gallery-slider' ) ) {
418
+ $default['woo_slider'] = 1;
419
+ }
420
+
421
+ $with_woocommerce = true;
422
+ if ( ! $this->woocommerce_is_active() ) {
423
+ $default['with_woocommerce'] = '0';
424
+ }
425
+
426
+ if ( ! function_exists( 'is_product' ) || ! is_product() ) {
427
+ $default['with_woocommerce'] = '0';
428
+ }
429
+
430
+ if ( isset( $general['enable_woocommerce'] ) && empty( $general['enable_woocommerce'] ) ) {
431
+ $default['with_woocommerce'] = '0';
432
+ }
433
+
434
+ if ( isset( $general['exchange_thumbnails'] ) && empty( $general['exchange_thumbnails'] ) ) {
435
+ $default['exchange_thumbnails'] = '0';
436
+ }
437
+
438
+ return $default;
439
+ }
440
+
441
+ function get_options_for_zoom() {
442
+ $i = get_option( 'zoooom_settings' );
443
+ $o = array();
444
+
445
+ switch ( $i['lensShape'] ) {
446
+ case 'none':
447
+ $o = array(
448
+ 'zoomType' => 'inner',
449
+ 'cursor' => $i['cursorType'],
450
+ 'easingAmount' => $i['zwEasing'],
451
+ );
452
+ break;
453
+ case 'square':
454
+ case 'round':
455
+ $o = array(
456
+ 'lensShape' => $i['lensShape'],
457
+ 'zoomType' => 'lens',
458
+ 'lensSize' => $i['lensSize'],
459
+ 'borderSize' => $i['borderThickness'],
460
+ 'borderColour' => $i['borderColor'],
461
+ 'cursor' => $i['cursorType'],
462
+ 'lensFadeIn' => $i['lensFade'],
463
+ 'lensFadeOut' => $i['lensFade'],
464
+ );
465
+ if ( $i['tint'] == true ) {
466
+ $o['tint'] = 'true';
467
+ $o['tintColour'] = $i['tintColor'];
468
+ $o['tintOpacity'] = $i['tintOpacity'];
469
+ }
470
+
471
+ break;
472
+ case 'square':
473
+ break;
474
+ case 'zoom_window':
475
+ $o = array(
476
+ 'lensShape' => 'square',
477
+ 'lensSize' => $i['lensSize'],
478
+ 'lensBorderSize' => $i['borderThickness'],
479
+ 'lensBorderColour' => $i['borderColor'],
480
+ 'borderRadius' => $i['zwBorderRadius'],
481
+ 'cursor' => $i['cursorType'],
482
+ 'zoomWindowWidth' => $i['zwWidth'],
483
+ 'zoomWindowHeight' => $i['zwHeight'],
484
+ 'zoomWindowOffsetx' => $i['zwPadding'],
485
+ 'borderSize' => $i['zwBorderThickness'],
486
+ 'borderColour' => $i['zwBorderColor'],
487
+ 'zoomWindowShadow' => $i['zwShadow'],
488
+ 'lensFadeIn' => $i['lensFade'],
489
+ 'lensFadeOut' => $i['lensFade'],
490
+ 'zoomWindowFadeIn' => $i['zwFade'],
491
+ 'zoomWindowFadeOut' => $i['zwFade'],
492
+ 'easingAmount' => $i['zwEasing'],
493
+ );
494
+
495
+ if ( $i['tint'] == true ) {
496
+ $o['tint'] = 'true';
497
+ $o['tintColour'] = $i['tintColor'];
498
+ $o['tintOpacity'] = $i['tintOpacity'];
499
+ }
500
+
501
+ break;
502
+ }
503
+ return $o;
504
+ }
505
+
506
+
507
+
508
+ /** Helper function ****************************************/
509
+
510
+ public function theme( $string ) {
511
+ $string = strtolower( $string );
512
+ if ( empty( $this->theme ) ) {
513
+ $this->theme = strtolower( get_template() );
514
+ }
515
+ if ( strpos( $this->theme, $string ) !== false ) {
516
+ return true;
517
+ }
518
+
519
+ return false;
520
+ }
521
+
522
+
523
+ /**
524
+ * Check if WooCommerce is activated
525
+ *
526
+ * @access public
527
+ * @return bool
528
+ */
529
+ public function woocommerce_is_active() {
530
+ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
531
+ return true;
532
+ }
533
+ return false;
534
+ }
535
+
536
+ public function get_option_general() {
537
+ $general = get_option( 'zoooom_general' );
538
+
539
+ if ( ! isset( $general['enable_woocommerce'] ) ) {
540
+ $general['enable_woocommerce'] = true;
541
+ }
542
+
543
+ if ( ! isset( $general['exchange_thumbnails'] ) ) {
544
+ $general['exchange_thumbnails'] = true;
545
+ }
546
+
547
+ if ( ! isset( $general['enable_mobile'] ) ) {
548
+ $general['enable_mobile'] = false;
549
+ }
550
+
551
+ $general['force_woocommerce'] = false;
552
+
553
+ if ( ! isset( $general['woo_cat'] ) ) {
554
+ $general['woo_cat'] = false;
555
+ }
556
+
557
+ if ( ! $this->woocommerce_is_active() ) {
558
+ $general['woo_cat'] = false;
559
+ }
560
+
561
+ return $general;
562
+ }
563
+
564
+ public function load_plugin_textdomain() {
565
+ load_plugin_textdomain( 'wp-image-zoooom', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
566
+ }
567
 
568
 
569
 
570
+ }
571
 
572
+ endif;
573
 
574
  /**
575
  * Returns the main instance of ImageZoooom
577
  * @return ImageZoooom
578
  */
579
  function ImageZoooom() {
580
+ return ImageZoooom::instance();
581
  }
582
 
583
  ImageZoooom();
587
  * */
588
  function wp_image_zoooom_plugin_action_links( $links ) {
589
 
590
+ $settings_link = '<a href="admin.php?page=zoooom_settings">' .
591
+ esc_html( __( 'Settings', 'wp-image-zoooom' ) ) . '</a>';
592
 
593
+ return array_merge( array( $settings_link ), $links );
594
 
595
  }
596
+ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'wp_image_zoooom_plugin_action_links' );
597
 
598
  if ( ! function_exists( 'x_disable_wp_image_srcset' ) ) :
599
+ function x_disable_wp_image_srcset() {
600
+ return true;
601
+ }
602
  endif;
includes/admin-side.php CHANGED
@@ -283,6 +283,7 @@ class ImageZoooom_Admin {
283
  'iz_dismiss_bridge',
284
  'iz_dismiss_wooswipe',
285
  'iz_dismiss_avada_woo_gallery',
 
286
  );
287
 
288
  $w = new SilkyPress_Warnings( $allowed_actions );
@@ -345,6 +346,12 @@ class ImageZoooom_Admin {
345
  }
346
  }
347
 
 
 
 
 
 
 
348
  $w->show_warnings();
349
  }
350
 
283
  'iz_dismiss_bridge',
284
  'iz_dismiss_wooswipe',
285
  'iz_dismiss_avada_woo_gallery',
286
+ 'iz_dismiss_flatsome_theme',
287
  );
288
 
289
  $w = new SilkyPress_Warnings( $allowed_actions );
346
  }
347
  }
348
 
349
+ // Warning about Flatsome theme
350
+ if ( strpos( strtolower(get_template()), 'flatsome') !== false && $w->is_url('zoooom_settings')) {
351
+ $message = __( 'The Flatsome theme replaces the default WooCommerce gallery with a Flickity carousel, which leads to the effects that it zooms only on the first image. Please check <a href="https://www.silkypress.com/wp-image-zoom/zoom-woocommerce-gallery-flatsome-theme/" target="_blank">this article</a> for a solution to the issue.', 'wp-image-zoooom-pro' );
352
+ $w->add_notice( 'iz_dismiss_flatsome_theme', $message );
353
+ }
354
+
355
  $w->show_warnings();
356
  }
357
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Email: diana@burduja.eu
5
  Tags: e-commerce, featured image, hover over image zoom, image, image zoom, image zoom plugin, image magnification, image magnifier, jquery picture zoom, magnifier, magnify image, magnifying glass, mouse over image zoom, panorama, picture zoom, product image, product zoom, product magnification, product magnifier, responsive, woocommerce product zoom, woocommerce zoom, woocommerce magnifying glass, zoom, zoom image, zoom plugin, woocommerce image zoom, woocommerce product image zoom, woocommerce zoom magnifier
6
  Requires at least: 3.0.1
7
  Tested up to: 5.3
8
- Stable tag: 1.39.1
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
  Requires PHP: 5.2.4
@@ -152,11 +152,15 @@ Alternatively you can upgrade to the Pro version, as there the zoom lens is buil
152
 
153
  == Changelog ==
154
 
155
- = 1.39.1
 
 
 
 
156
  * 02/11/2019
157
  * Fix: allow saving options only if the current user has the "manage_options" capability
158
 
159
- = 1.39
160
  * 02/09/2019
161
  * Fix: zoom was showing only in customizer if the Lazy Load option from Jetpack is enabled
162
  * Declare compatibility with WooCommerce 3.9
5
  Tags: e-commerce, featured image, hover over image zoom, image, image zoom, image zoom plugin, image magnification, image magnifier, jquery picture zoom, magnifier, magnify image, magnifying glass, mouse over image zoom, panorama, picture zoom, product image, product zoom, product magnification, product magnifier, responsive, woocommerce product zoom, woocommerce zoom, woocommerce magnifying glass, zoom, zoom image, zoom plugin, woocommerce image zoom, woocommerce product image zoom, woocommerce zoom magnifier
6
  Requires at least: 3.0.1
7
  Tested up to: 5.3
8
+ Stable tag: 1.39.2
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
  Requires PHP: 5.2.4
152
 
153
  == Changelog ==
154
 
155
+ = 1.39.2 =
156
+ * 02/12/2019
157
+ * Fix: the WC product images were distorted on the Flatsome theme
158
+
159
+ = 1.39.1 =
160
  * 02/11/2019
161
  * Fix: allow saving options only if the current user has the "manage_options" capability
162
 
163
+ = 1.39 =
164
  * 02/09/2019
165
  * Fix: zoom was showing only in customizer if the Lazy Load option from Jetpack is enabled
166
  * Declare compatibility with WooCommerce 3.9