first commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Product Loop Start
|
||||
*
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 9999
|
||||
*/
|
||||
|
||||
// Classes.
|
||||
$wrap_classes = array( 'products', 'oceanwp-row', 'clr' );
|
||||
|
||||
// List/grid style.
|
||||
if ( ( oceanwp_is_woo_shop() || oceanwp_is_woo_tax() )
|
||||
&& get_theme_mod( 'ocean_woo_grid_list', true )
|
||||
&& 'list' === get_theme_mod( 'ocean_woo_catalog_view', 'grid' ) ) {
|
||||
$wrap_classes[] = 'list';
|
||||
} else {
|
||||
$wrap_classes[] = 'grid';
|
||||
}
|
||||
|
||||
// Responsive columns.
|
||||
$tablet_columns = get_theme_mod( 'ocean_woocommerce_tablet_shop_columns' );
|
||||
$mobile_columns = get_theme_mod( 'ocean_woocommerce_mobile_shop_columns' );
|
||||
|
||||
if ( ! empty( $tablet_columns ) ) {
|
||||
$wrap_classes[] = 'tablet-col';
|
||||
$wrap_classes[] = 'tablet-' . $tablet_columns . '-col';
|
||||
}
|
||||
if ( ! empty( $mobile_columns ) ) {
|
||||
$wrap_classes[] = 'mobile-col';
|
||||
$wrap_classes[] = 'mobile-' . $mobile_columns . '-col';
|
||||
}
|
||||
|
||||
// If infinite scroll.
|
||||
if ( 'infinite_scroll' === get_theme_mod( 'ocean_woo_pagination_style', 'standard' ) ) {
|
||||
$wrap_classes[] = 'infinite-scroll-wrap';
|
||||
}
|
||||
|
||||
$wrap_classes = implode( ' ', $wrap_classes ); ?>
|
||||
|
||||
<ul class="<?php echo esc_attr( $wrap_classes ); ?>">
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Image Swap style thumbnail
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return placeholder if there isn't a thumbnail defined.
|
||||
if ( ! has_post_thumbnail() ) {
|
||||
oceanwp_woo_placeholder_img();
|
||||
return;
|
||||
}
|
||||
|
||||
// Get global product data.
|
||||
global $product;
|
||||
|
||||
// Get featured image.
|
||||
$attachment = $product->get_image_id();
|
||||
|
||||
// Image args.
|
||||
$img_args = array(
|
||||
'class' => 'woo-entry-image-main',
|
||||
'alt' => get_the_title(),
|
||||
);
|
||||
if ( oceanwp_get_schema_markup( 'image' ) ) {
|
||||
$img_args['itemprop'] = 'image';
|
||||
}
|
||||
|
||||
// Display featured image if defined.
|
||||
if ( $attachment ) {
|
||||
?>
|
||||
|
||||
<div class="woo-entry-image clr">
|
||||
<?php do_action( 'ocean_before_product_entry_image' ); ?>
|
||||
<a href="<?php the_permalink(); ?>" class="woocommerce-LoopProduct-link">
|
||||
<?php
|
||||
// Single Image.
|
||||
echo wp_get_attachment_image( $attachment, 'shop_catalog', '', $img_args );
|
||||
?>
|
||||
</a>
|
||||
<?php do_action( 'ocean_after_product_entry_image' ); ?>
|
||||
</div><!-- .woo-entry-image -->
|
||||
|
||||
<?php
|
||||
} else {
|
||||
// Display placeholder.
|
||||
?>
|
||||
|
||||
<div class="woo-entry-image clr">
|
||||
<?php do_action( 'ocean_before_product_entry_image' ); ?>
|
||||
<a href="<?php the_permalink(); ?>" class="woocommerce-LoopProduct-link">
|
||||
<?php echo '<img src="' . esc_url( wc_placeholder_img_src() ) . '" alt="' . esc_html__( 'Placeholder Image', 'oceanwp' ) . '" class="woo-entry-image-main" />'; ?>
|
||||
</a>
|
||||
<?php do_action( 'ocean_after_product_entry_image' ); ?>
|
||||
</div><!-- .woo-entry-image -->
|
||||
<?php } ?>
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Gallery Style WooCommerce
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return dummy image if no featured image is defined.
|
||||
if ( ! has_post_thumbnail() ) {
|
||||
oceanwp_woo_placeholder_img();
|
||||
return;
|
||||
}
|
||||
|
||||
// Get global product data.
|
||||
global $product;
|
||||
|
||||
// Get featured image.
|
||||
$thumbnail_id = $product->get_image_id();
|
||||
|
||||
// Get gallery images.
|
||||
if ( version_compare( OceanWP_WooCommerce_Config::get_wc_version(), '2.7', '>=' ) ) {
|
||||
$attachment_ids = $product->get_gallery_image_ids();
|
||||
} else {
|
||||
$attachment_ids = $product->get_gallery_attachment_ids();
|
||||
}
|
||||
|
||||
// Get attachments count.
|
||||
$attachments_count = count( $attachment_ids );
|
||||
|
||||
// Image args.
|
||||
$img_args = array(
|
||||
'alt' => get_the_title(),
|
||||
);
|
||||
if ( oceanwp_get_schema_markup( 'image' ) ) {
|
||||
$img_args['itemprop'] = 'image';
|
||||
}
|
||||
|
||||
// If there are attachments display slider.
|
||||
if ( $attachment_ids ) : ?>
|
||||
|
||||
<div class="product-entry-slider-wrap">
|
||||
|
||||
<?php do_action( 'ocean_before_product_entry_slider' ); ?>
|
||||
|
||||
<div class="product-entry-slider woo-entry-image clr">
|
||||
|
||||
<?php do_action( 'ocean_before_product_entry_image' ); ?>
|
||||
|
||||
<?php
|
||||
// Define counter variable.
|
||||
$count = 0;
|
||||
|
||||
if ( has_post_thumbnail() ) :
|
||||
?>
|
||||
|
||||
<div class="oceanwp-slider-slide">
|
||||
<a href="<?php the_permalink(); ?>" class="woocommerce-LoopProduct-link">
|
||||
<?php
|
||||
echo wp_get_attachment_image( $thumbnail_id, 'shop_catalog', '', $img_args );
|
||||
?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
|
||||
if ( $attachments_count > 0 ) :
|
||||
|
||||
// Loop through images.
|
||||
foreach ( $attachment_ids as $attachment_id ) :
|
||||
|
||||
// Add to counter.
|
||||
$count++;
|
||||
|
||||
// Only display the first 5 images.
|
||||
if ( $count < 5 ) :
|
||||
?>
|
||||
|
||||
<div class="oceanwp-slider-slide">
|
||||
<a href="<?php the_permalink(); ?>" class="woocommerce-LoopProduct-link">
|
||||
<?php
|
||||
echo wp_get_attachment_image( $attachment_id, 'shop_catalog', '', $img_args );
|
||||
?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
endif;
|
||||
?>
|
||||
|
||||
<?php do_action( 'ocean_after_product_entry_image' ); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php do_action( 'ocean_after_product_entry_slider' ); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// There aren't any images so lets display the featured image.
|
||||
else :
|
||||
|
||||
wc_get_template( 'loop/thumbnail/featured-image.php' );
|
||||
|
||||
endif;
|
||||
?>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* Image Swap style thumbnail
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return dummy image if no featured image is defined.
|
||||
if ( ! has_post_thumbnail() ) {
|
||||
oceanwp_woo_placeholder_img();
|
||||
return;
|
||||
}
|
||||
|
||||
// Globals.
|
||||
global $product;
|
||||
|
||||
// Get first image.
|
||||
$attachment = $product->get_image_id();
|
||||
|
||||
// Get Second Image in Gallery.
|
||||
if ( version_compare( OceanWP_WooCommerce_Config::get_wc_version(), '2.7', '>=' ) ) {
|
||||
$attachment_ids = $product->get_gallery_image_ids();
|
||||
} else {
|
||||
$attachment_ids = $product->get_gallery_attachment_ids();
|
||||
}
|
||||
$attachment_ids[] = $attachment; // Add featured image to the array.
|
||||
$secondary_img_id = '';
|
||||
|
||||
if ( ! empty( $attachment_ids ) ) {
|
||||
$attachment_ids = array_unique( $attachment_ids ); // remove duplicate images.
|
||||
if ( count( $attachment_ids ) > '1' ) {
|
||||
if ( $attachment_ids['0'] !== $attachment ) {
|
||||
$secondary_img_id = $attachment_ids['0'];
|
||||
} elseif ( $attachment_ids['1'] !== $attachment ) {
|
||||
$secondary_img_id = $attachment_ids['1'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Image args.
|
||||
$first_img = array(
|
||||
'class' => 'woo-entry-image-main',
|
||||
'alt' => get_the_title(),
|
||||
);
|
||||
if ( oceanwp_get_schema_markup( 'image' ) ) {
|
||||
$first_img['itemprop'] = 'image';
|
||||
}
|
||||
|
||||
$second_img = array(
|
||||
'class' => 'woo-entry-image-secondary',
|
||||
'alt' => get_the_title(),
|
||||
);
|
||||
if ( oceanwp_get_schema_markup( 'image' ) ) {
|
||||
$second_img['itemprop'] = 'image';
|
||||
}
|
||||
|
||||
|
||||
// Return thumbnail.
|
||||
if ( $secondary_img_id ) : ?>
|
||||
|
||||
<div class="woo-entry-image-swap woo-entry-image clr">
|
||||
<?php do_action( 'ocean_before_product_entry_image' ); ?>
|
||||
<a href="<?php the_permalink(); ?>" class="woocommerce-LoopProduct-link">
|
||||
<?php
|
||||
// Main Image.
|
||||
echo wp_get_attachment_image( $attachment, 'shop_catalog', '', $first_img );
|
||||
|
||||
// Secondary Image.
|
||||
echo wp_get_attachment_image( $secondary_img_id, 'shop_catalog', '', $second_img );
|
||||
?>
|
||||
</a>
|
||||
<?php do_action( 'ocean_after_product_entry_image' ); ?>
|
||||
</div><!-- .woo-entry-image-swap -->
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<div class="woo-entry-image clr">
|
||||
<?php do_action( 'ocean_before_product_entry_image' ); ?>
|
||||
<a href="<?php the_permalink(); ?>" class="woocommerce-LoopProduct-link">
|
||||
<?php
|
||||
// Single Image.
|
||||
echo wp_get_attachment_image( $attachment, 'shop_catalog', '', $first_img );
|
||||
?>
|
||||
</a>
|
||||
<?php do_action( 'ocean_after_product_entry_image' ); ?>
|
||||
</div><!-- .woo-entry-image -->
|
||||
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user