-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from JetixWP/release-v0.15.0
Release v0.15.0
- Loading branch information
Showing
17 changed files
with
673 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
includes/Compatibility/Plugins/CIXWooGallerySlider/class-compatibility.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* Codeixer Product Gallery Slider compatibility handler. | ||
* | ||
* @package RSFV | ||
*/ | ||
|
||
namespace RSFV\Compatibility\Plugins\CIXWooGallerySlider; | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
use RSFV\Compatibility\Plugins\Base_Compatibility; | ||
|
||
/** | ||
* Class Compatibility | ||
* | ||
* @package RSFV | ||
*/ | ||
class Compatibility extends Base_Compatibility { | ||
|
||
|
||
/** | ||
* Class instance. | ||
* | ||
* @var $instance | ||
*/ | ||
protected static $instance; | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(); | ||
|
||
$this->id = 'cix-woo-gallery-slider'; | ||
|
||
$this->setup(); | ||
} | ||
|
||
/** | ||
* Sets up hooks and filters. | ||
* | ||
* @return void | ||
*/ | ||
public function setup() { | ||
if ( function_exists( 'wpgs_get_template' ) && has_filter( 'wc_get_template', 'wpgs_get_template' ) ) { | ||
remove_filter( 'wc_get_template', 'wpgs_get_template' ); | ||
add_filter( 'wc_get_template', array( $this, 'filter_product_image_template' ), 10, 5 ); | ||
} | ||
} | ||
|
||
/** | ||
* Updates plugin's template for Featured video. | ||
* | ||
* @param string $located Located at absolute file path. | ||
* @param string $template_name Widget name/id. | ||
* @param array $args Arguments from widget. | ||
* @param string $template_path Widget path. | ||
* @param string $default_path Default location. | ||
*/ | ||
public function filter_product_image_template( $located, $template_name, $args, $template_path, $default_path ) { | ||
if ( 'single-product/product-image.php' === $template_name ) { | ||
$template_directory = untrailingslashit( plugin_dir_path( __FILE__ ) ); | ||
$located = $template_directory . '/templates/product-image.php'; | ||
$located = apply_filters( 'rsfv_cix_woo_gallery_slider_template', $located ); | ||
} | ||
|
||
return $located; | ||
} | ||
} |
231 changes: 231 additions & 0 deletions
231
includes/Compatibility/Plugins/CIXWooGallerySlider/templates/product-image.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
<?php | ||
/** | ||
* Single Product Image | ||
* | ||
* @package WooCommerce\Templates | ||
* @version 10.0.0 | ||
* @CIX-version 2.3.10 | ||
*/ | ||
|
||
use RSFV\Options; | ||
use RSFV\FrontEnd as RSFV_FrontEnd; | ||
use RSFV\Compatibility\Plugins\WooCommerce\Compatibility as WooCommerceCompatibility; | ||
use function RSFV\Settings\get_post_types; | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
// Note: `wc_get_gallery_image_html` was added in WC 3.3.2 and did not exist prior. This check protects against theme overrides being used on older versions of WC. | ||
if ( ! function_exists( 'wc_get_gallery_image_html' ) || ! apply_filters( 'wpgs_default_gallery_hook', true ) ) { | ||
return; | ||
} | ||
|
||
global $product; | ||
$post_thumbnail_id = $product->get_image_id(); | ||
$gallery_options = get_option( 'wpgs_form' ); | ||
$html = ''; | ||
$wrapper_classes = apply_filters( | ||
'woocommerce_single_product_image_gallery_classes', | ||
array( | ||
'woo-product-gallery-slider', | ||
'woocommerce-product-gallery', | ||
'wpgs--' . ( has_post_thumbnail() ? 'with-images' : 'without-images' ), | ||
'images', | ||
|
||
) | ||
); | ||
|
||
$slider_rtl = ( is_rtl() ) ? 'true' : 'false'; | ||
$lightbox_img_count = ( '1' == $gallery_options['lightbox_img_count'] ) ? 'true' : 'false'; | ||
|
||
do_action( 'wpgs_before_image_gallery' ); | ||
|
||
?> | ||
|
||
<div class="<?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $wrapper_classes ) ) ); ?>" <?php echo esc_attr( 'true' == $slider_rtl ? 'dir=rtl' : '' ); ?> > | ||
|
||
<?php | ||
|
||
echo '<div class="wpgs-for">'; | ||
if ( has_post_thumbnail() ) { | ||
|
||
$image = wp_get_attachment_image( | ||
$post_thumbnail_id, | ||
$gallery_options['slider_image_size'], | ||
true, | ||
array( | ||
'class' => 'attachment-shop_single size-shop_single wp-post-image', | ||
'data-zoom_src' => wp_get_attachment_image_src( $post_thumbnail_id, apply_filters( 'gallery_slider_zoom_image_size', 'full' ) )[0], | ||
'data-large_image' => wp_get_attachment_image_src( $post_thumbnail_id, apply_filters( 'gallery_slider_zoom_image_size', 'full' ) )[0], | ||
'alt' => trim( wp_strip_all_tags( get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ) ) ), | ||
'data-o_img' => wp_get_attachment_image_url( $post_thumbnail_id, apply_filters( 'wpgs_new_main_img_size', wpgs_get_option( 'slider_image_size' ) ) ), | ||
'data-zoom-image' => wp_get_attachment_image_url( $post_thumbnail_id, apply_filters( 'gallery_slider_zoom_image_size', 'large' ) ), | ||
) | ||
); | ||
} else { | ||
$placeholder_id = get_option( 'woocommerce_placeholder_image', 0 ); | ||
$image = wp_get_attachment_image( | ||
$placeholder_id, | ||
$gallery_options['slider_image_size'], | ||
true, | ||
array( | ||
'class' => 'attachment-shop_single size-shop_single wp-post-image', | ||
'data-zoom_src' => wp_get_attachment_image_src( $placeholder_id, apply_filters( 'gallery_slider_zoom_image_size', 'full' ) )[0], | ||
'data-large_image' => wp_get_attachment_image_src( $placeholder_id, apply_filters( 'gallery_slider_zoom_image_size', 'full' ) )[0], | ||
'alt' => trim( wp_strip_all_tags( get_post_meta( $placeholder_id, '_wp_attachment_image_alt', true ) ) ), | ||
'data-o_img' => wp_get_attachment_image_url( $placeholder_id, apply_filters( 'wpgs_new_main_img_size', wpgs_get_option( 'slider_image_size' ) ) ), | ||
'data-zoom-image' => wp_get_attachment_image_url( $placeholder_id, apply_filters( 'gallery_slider_zoom_image_size', 'large' ) ), | ||
) | ||
); | ||
} | ||
$attachment_ids = $product->get_gallery_image_ids(); | ||
|
||
$lightbox_src = wc_get_product_attachment_props( $post_thumbnail_id ); | ||
|
||
$img_caption = get_the_title( $post_thumbnail_id ); | ||
if ( apply_filters( 'wpgs_show_featured_image_in_gallery', true ) ) { | ||
|
||
if ( '1' === $gallery_options['lightbox_picker'] ) { | ||
$html .= '<div class="woocommerce-product-gallery__image single-product-main-image">'; | ||
$html .= '<a class="wpgs-lightbox-icon" data-caption="' . $img_caption . '" data-fancybox="wpgs-lightbox" href="' . $lightbox_src['url'] . '" data-mobile=["clickContent:close","clickSlide:close"] data-click-slide="close" data-animation-effect="fade" data-loop="true" data-infobar="' . $lightbox_img_count . '" data-hash="false" >' . $image . '</a></div>'; | ||
|
||
} else { | ||
$html .= '<div class="woocommerce-product-gallery__image single-product-main-image">' . $image . '</div>'; | ||
|
||
} | ||
} | ||
|
||
echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, $post_thumbnail_id ); // phpcs:ignore. | ||
|
||
|
||
if ( $attachment_ids ) { | ||
foreach ( $attachment_ids as $attachment_id ) { | ||
$thumbnail_image = wp_get_attachment_image( | ||
$attachment_id, | ||
$gallery_options['slider_image_size'], | ||
true, | ||
array( | ||
'class' => 'attachment-shop_single', | ||
'data-zoom_src' => wp_get_attachment_image_src( $attachment_id, apply_filters( 'gallery_slider_zoom_image_size', 'full' ) )[0], | ||
'data-large_image' => wp_get_attachment_image_src( $attachment_id, apply_filters( 'gallery_slider_zoom_image_size', 'full' ) )[0], | ||
'alt' => trim( wp_strip_all_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) ), | ||
) | ||
); | ||
$lightbox_src = wc_get_product_attachment_props( $attachment_id ); | ||
|
||
$img_caption = get_the_title( $attachment_id ); | ||
$attachment_html = ''; | ||
if ( '1' === $gallery_options['lightbox_picker'] ) { | ||
$attachment_html .= '<div><a class="wpgs-lightbox-icon" data-fancybox="wpgs-lightbox" data-caption="' . $img_caption . '" href="' . $lightbox_src['url'] . '" data-mobile=["clickContent:close","clickSlide:close"] data-click-slide="close" data-animation-effect="fade" data-loop="true" data-hash="false" data-infobar="' . $lightbox_img_count . '" >' . $thumbnail_image . '</a></div>'; | ||
|
||
} else { | ||
$attachment_html .= '<div>' . $thumbnail_image . '</div>'; | ||
} | ||
|
||
echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $attachment_html, $post_thumbnail_id ); // phpcs:ignore. | ||
|
||
} | ||
} | ||
echo '</div>'; | ||
|
||
|
||
do_action( 'woocommerce_product_thumbnails' ); | ||
|
||
$attachment_ids = $product->get_gallery_image_ids(); | ||
$gallery_thumbnail_size = $gallery_options['thumbnail_image_size']; | ||
|
||
$product_id = $product->get_id(); | ||
$post_type = get_post_type( $product_id ) ?? ''; // phpcs:ignore. | ||
|
||
// Get enabled post types. | ||
$post_types = get_post_types(); | ||
|
||
$options = Options::get_instance(); | ||
$has_video_thumbnail = RSFV_FrontEnd::has_featured_video( $product_id ); | ||
$video_html = ''; | ||
|
||
if ( ! empty( $post_types ) ) { | ||
if ( in_array( $post_type, $post_types, true ) ) { | ||
$video_html = WooCommerceCompatibility::woo_video_markup( $product->get_id(), 'woocommerce-product-gallery__image', '', true ); | ||
$video_html = '<div>' . $video_html . '</div>'; | ||
} | ||
} | ||
|
||
$display_html = ''; | ||
|
||
if ( $attachment_ids ) { | ||
echo '<div class="wpgs-nav">'; | ||
if ( has_post_thumbnail() ) { | ||
|
||
$image = wp_get_attachment_image( | ||
$post_thumbnail_id, | ||
$gallery_thumbnail_size, | ||
true, | ||
array( | ||
'class' => 'wpgs-thumb-main-image', | ||
'alt' => trim( wp_strip_all_tags( get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ) ) ), | ||
) | ||
); | ||
} else { | ||
$placeholder_id = get_option( 'woocommerce_placeholder_image', 0 ); | ||
$image = wp_get_attachment_image( | ||
$placeholder_id, | ||
$gallery_thumbnail_size, | ||
true, | ||
array( | ||
'class' => 'wpgs-thumb-main-image', | ||
'alt' => trim( wp_strip_all_tags( get_post_meta( $placeholder_id, '_wp_attachment_image_alt', true ) ) ), | ||
) | ||
); | ||
|
||
} | ||
|
||
if ( $has_video_thumbnail ) { | ||
echo $video_html; // phpcs:ignore; | ||
} | ||
|
||
if ( apply_filters( 'wpgs_show_featured_image_in_gallery', true ) ) { | ||
echo '<div>' . $image . '</div>'; // phpcs:ignore. | ||
} | ||
|
||
foreach ( $attachment_ids as $attachment_id ) { | ||
$thumbnail_image = wp_get_attachment_image( | ||
$attachment_id, | ||
$gallery_thumbnail_size, | ||
true, | ||
array( | ||
'alt' => trim( wp_strip_all_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) ), | ||
) | ||
); | ||
echo '<div>' . $thumbnail_image . '</div>'; // phpcs:ignore. | ||
} | ||
|
||
echo '</div>'; | ||
} elseif ( $has_video_thumbnail ) { | ||
$image = ''; | ||
if ( has_post_thumbnail() ) { | ||
|
||
$image = '<div>' . wp_get_attachment_image( | ||
$post_thumbnail_id, | ||
$gallery_thumbnail_size, | ||
true, | ||
array( | ||
'class' => 'wpgs-thumb-main-image', | ||
'alt' => trim( wp_strip_all_tags( get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ) ) ), | ||
) | ||
) . '</div>'; | ||
} | ||
|
||
?> | ||
<div class="wpgs-nav"> | ||
<div class="wpgs-thumb-main-image"> | ||
<?php echo $video_html; // phpcs:ignore; ?> | ||
</div> | ||
<?php echo $image; // phpcs:ignore; ?> | ||
</div> | ||
<?php | ||
} | ||
do_action( 'wpgs_after_image_gallery' ); | ||
|
||
?> | ||
|
||
</div> |
Oops, something went wrong.