Created
September 17, 2012 10:41
-
-
Save aristath/3736642 to your computer and use it in GitHub Desktop.
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
<?php | |
function single_product_images_slider($echo, $id){ | |
$attachments = get_posts( array( | |
'post_type' => 'attachment', | |
'posts_per_page' => -1, | |
'post_parent' => $id, | |
)); | |
if ( $attachments ) { | |
$content = '<div class="single-product-image-slider">'; | |
$content .= '<div class="flexslider">'; | |
$content .= '<ul class="slides">'; | |
foreach ( $attachments as $attachment ) { | |
$class = "post-attachment mime-" . sanitize_title( $attachment->post_mime_type ); | |
$img_attributes = wp_get_attachment_image_src($attachment->ID, 'full' ); | |
$img = '<img itemprop="image" src="' . $img_attributes[0] . '" />'; | |
$content .= '<li class="' . $class . ' data-design-thumbnail">' . $img . '</li>'; | |
} | |
$content .= '</ul></div></div>'; | |
$content .= '<script type="text/javascript" charset="utf-8"> | |
jQuery(window).load(function() { | |
jQuery(".single-product-image-slider .flexslider").flexslider({ | |
slideshowSpeed: 7000, | |
animation: "slide" | |
}); | |
}); | |
</script>'; | |
$content .= '<div class="region-divider"></div>'; | |
} | |
if ($echo) | |
echo $content; | |
else | |
return $content; | |
} | |
function product_with_slider($id){ | |
$post = get_post($product_id); | |
$content .= single_product_images_slider(false, $id); | |
$content .= '<div itemprop="description" class="mp_product_content">'; | |
$content .= apply_filters('the_content', $post->post_content); | |
$content .= '</div>'; | |
$content .= '<div itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="mp_product_meta">'; | |
$content .= mp_product_price(false, $id); | |
$content .= mp_buy_button(false, 'single', $id); | |
$content .= '</div>'; | |
echo $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment