PluginProbe
Slider Ultimate / 2.0.3
Slider Ultimate v2.0.3
2.2.10 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 All 54 releases
ultimate-slider / includes / WooCommerceIntegration.class.php
WooCommerceIntegration.class.php
51 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class to replace the main WooCommerce product image with a slider
5 * that contains all of the product images
6 */
7
8 if ( !defined( 'ABSPATH' ) )
9 exit;
10
11 class ewdusWooCommerceIntegration {
12
13
14 public function __construct() {
15
16 add_filter( 'woocommerce_single_product_image_thumbnail_html', array( $this, 'remove_wc_thumbnails' ) );
17 add_filter( 'woocommerce_single_product_image_html', array( $this, 'replace_woocommerce_image' ), 10, 2 );
18 }
19
20 /**
21 * Replace main WooCommerce image with a slider containing all product images
22 * @since 2.0.0
23 */
24 public function replace_woocommerce_image( $html, $product_id ) {
25
26 $product = wc_get_product( $product_id );
27
28 $post_ids = get_post_thumbnail_id( $product_id );
29 $attachment_ids = $product->get_gallery_attachment_ids();
30
31 if ( $attachment_ids ) {
32
33 foreach ( $attachment_ids as $attachment_id ) {
34 $post_ids .= "," . $attachment_id;
35 }
36
37 return do_shortcode( '[ultimate-slider post__in_string="' . $post_ids . '"]' );
38 }
39
40 return $html;
41 }
42
43 /**
44 * Remove the product image thumbnails if displaying the slider
45 * @since 2.0.0
46 */
47 public function remove_wc_thumbnails() {
48
49 return null;
50 }
51 }