Plugin Directory

Changeset 3337851


Ignore:
Timestamp:
08/01/2025 01:27:44 PM (5 months ago)
Author:
wijnbergdevelopments
Message:

Improved compatibility for XStore theme

Location:
product-gallery-swiper-for-woocommerce
Files:
39 added
4 edited

Legend:

Unmodified
Added
Removed
  • product-gallery-swiper-for-woocommerce/trunk/README.txt

    r3334031 r3337851  
    44Requires at least: 6.0
    55Tested up to: 6.8
    6 Stable tag: 1.5.9
     6Stable tag: 1.5.10
    77Requires PHP: 7.2
    88License: GPL-2.0+
     
    6565
    6666== Changelog ==
     67= 1.5.10 =
     68* Improved compatibility for XStore theme
     69
    6770= 1.5.9 =
    6871* Added WooCommerce ProductImage block integration
  • product-gallery-swiper-for-woocommerce/trunk/public/class-wdevs-gallery-swiper-public.php

    r3334031 r3337851  
    235235            ], $this->version, true );
    236236            wp_enqueue_script( 'wdevs-gallery-swiper-xstore-theme' );
     237
     238            // Hook into XStore product grid element rendering
     239            add_filter( 'etheme_product_grid_list_product_element_image', [ $this, 'xstore_product_grid_gallery_integration' ], PHP_INT_MIN, 3 );
    237240        }
    238241    }
     
    398401     * @since    1.4.0
    399402     */
    400     public function finish_gallery_rendering() {
     403    public function finish_gallery_rendering( $product = null ) {
    401404        if ( $this->should_display_gallery() && ! $this->executed_block_integration() ) {
    402405            echo '</div>';
    403406
    404             $product = wc_get_product();
    405             if ( $product ) {
    406                 foreach ( $product->get_gallery_image_ids() as $attachment_id ) {
    407                     echo $this->wrap_in_slide( $this->get_product_image( $product, $attachment_id ) );
    408                 }
    409 
    410                 if ( $product->is_type( 'variable' ) ) {
    411                     if ( $this->should_include_variation_images() ) {
    412                         $variation_images = [];
    413                         $variations       = $product->get_available_variations();
    414 
    415                         foreach ( $variations as $variation ) {
    416                             if ( ! empty( $variation['image_id'] ) && ! in_array( $variation['image_id'], $variation_images, true ) ) {
    417                                 echo $this->wrap_in_slide( $this->get_product_image( $product, $variation['image_id'] ) );
    418                                 $variation_images[] = $variation['image_id'];
    419                             }
    420                         }
    421                     }
    422                 }
    423             }
     407            $this->render_gallery_images( $product );
    424408
    425409            echo $this->build_swiper_closing_tag();
     
    763747        return ( get_option( 'wdevs_gallery_swiper_variation_images', 'no' ) === 'yes' );
    764748    }
     749
     750    /**
     751     * Render gallery images and variations for a specific product.
     752     *
     753     * @param WC_Product|null $product Product object, uses current product if null.
     754     * @return void
     755     * @since 1.5.10
     756     */
     757    private function render_gallery_images( $product = null ) {
     758        if ( ! $product ) {
     759            $product = wc_get_product();
     760        }
     761       
     762        if ( ! $product ) {
     763            return;
     764        }
     765
     766        foreach ( $product->get_gallery_image_ids() as $attachment_id ) {
     767            echo $this->wrap_in_slide( $this->get_product_image( $product, $attachment_id ) );
     768        }
     769
     770        if ( $product->is_type( 'variable' ) && $this->should_include_variation_images() ) {
     771            $variation_images = [];
     772            $variations       = $product->get_available_variations();
     773
     774            foreach ( $variations as $variation ) {
     775                if ( ! empty( $variation['image_id'] ) && ! in_array( $variation['image_id'], $variation_images, true ) ) {
     776                    echo $this->wrap_in_slide( $this->get_product_image( $product, $variation['image_id'] ) );
     777                    $variation_images[] = $variation['image_id'];
     778                }
     779            }
     780        }
     781    }
     782
     783    /**
     784     * XStore product grid gallery integration.
     785     *
     786     * @param string $original_image_html The original image HTML from XStore.
     787     * @param WC_Product $product The product object.
     788     * @param array $local_settings The XStore element settings.
     789     *
     790     * @return string The gallery HTML or original image HTML.
     791     * @since 1.5.10
     792     */
     793    public function xstore_product_grid_gallery_integration( $original_image_html, $product, $local_settings ) {
     794        if ( ! $product || ! is_a( $product, 'WC_Product' ) ) {
     795            return $original_image_html;
     796        }
     797
     798        if ( ! $this->should_display_gallery( $product->get_id() ) ) {
     799            return $original_image_html;
     800        }
     801
     802        ob_start();
     803       
     804        $this->start_gallery_rendering();
     805        echo $original_image_html;
     806        $this->finish_gallery_rendering( $product );
     807       
     808        return ob_get_clean();
     809    }
    765810}
  • product-gallery-swiper-for-woocommerce/trunk/public/css/wdevs-gallery-swiper-public.css

    r3217195 r3337851  
    1111    max-width: 100%;
    1212}
     13
     14/* XStore product grid */
     15.etheme-product-grid-image footer{
     16    z-index: 1;
     17}
  • product-gallery-swiper-for-woocommerce/trunk/wdevs-gallery-swiper.php

    r3334031 r3337851  
    1717 * Plugin URI:           https://products.wijnberg.dev
    1818 * Description:          Enhances WooCommerce product images display on product listing sections, providing a responsive and touch-friendly swiper.
    19  * Version:              1.5.9
     19 * Version:              1.5.10
    2020 * Author:               Wijnberg Developments
    2121 * License:              GPL-2.0+
     
    4141 * Rename this for your plugin and update it as you release new versions.
    4242 */
    43 define( 'WDEVS_GALLERY_SWIPER_VERSION', '1.5.9' );
     43define( 'WDEVS_GALLERY_SWIPER_VERSION', '1.5.10' );
    4444
    4545/**
Note: See TracChangeset for help on using the changeset viewer.