本文整理汇总了PHP中WC_Product::get_gallery_attachment_ids方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product::get_gallery_attachment_ids方法的具体用法?PHP WC_Product::get_gallery_attachment_ids怎么用?PHP WC_Product::get_gallery_attachment_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Product
的用法示例。
在下文中一共展示了WC_Product::get_gallery_attachment_ids方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: webdados_fb_open_graph
//.........这里部分代码省略.........
}
//If no description let's just add the title
if (trim($fb_desc) == '') {
$fb_desc = $fb_title;
}
//YOAST?
if ($fb_show_wpseoyoast == 1) {
if (defined('WPSEO_VERSION')) {
$wpseo = WPSEO_Frontend::get_instance();
//App ID - From our plugin
//Admin ID - From our plugin
//Locale - From our plugin
//Sitename - From our plugin
//Title - From WPSEO
$fb_title = strip_tags($wpseo->title(false));
//Title - SubHeading plugin
if ($fb_show_subheading == 1) {
if (webdados_fb_open_graph_subheadingactive()) {
$fb_title .= ' - ' . get_the_subheading();
}
}
//URL - From WPSEO
$fb_url = $wpseo->canonical(false);
//Description - From WPSEO or our plugin
$fb_desc_temp = $wpseo->metadesc(false);
$fb_desc = strip_tags(trim($fb_desc_temp) != '' ? trim($fb_desc_temp) : $fb_desc);
//Image - From our plugin
}
}
//WooCommerce - Additional product images?
if (intval($fb_image_show) == 1 && class_exists('woocommerce') && $fb_wc_useproductgallery == 1 && is_product()) {
global $post;
$product = new WC_Product($post->ID);
if ($attachment_ids = $product->get_gallery_attachment_ids()) {
foreach ($attachment_ids as $attachment_id) {
if ($image_link = wp_get_attachment_url($attachment_id)) {
if (trim($image_link) != '') {
$fb_image_additional[] = trim($image_link);
}
}
}
}
}
//Apply Filters
$fb_title = apply_filters('fb_og_title', $fb_title);
$fb_desc = apply_filters('fb_og_desc', $fb_desc);
$fb_image = apply_filters('fb_og_image', $fb_image);
$fb_image_additional = apply_filters('fb_og_image_additional', $fb_image_additional);
$fb_locale = apply_filters('fb_og_locale', $fb_locale);
$fb_image_size = false;
if (intval($fb_image_show) == 1 && trim($fb_image) != '') {
if (intval($fb_image_size_show) == 1) {
if (isset($GLOBALS['webdados_fb_img_size'])) {
//Already fetched
$fb_image_size = $GLOBALS['webdados_fb_img_size'];
} else {
$fb_image_size = webdados_fb_open_graph_getimagesize($fb_image);
}
}
} else {
$fb_image_size_show = 0;
}
//No spaces on URLs
if (isset($fb_url) && trim($fb_url) != '') {
$fb_url = str_replace(' ', '%20', trim($fb_url));
}
示例2: mg_lightbox
function mg_lightbox($post_id, $prev_item = false, $next_item = false)
{
include_once MG_DIR . '/functions.php';
$post_data = get_post($post_id);
$GLOBALS['post'] = $post_data;
// post type and layout
if ($post_data->post_type == 'product') {
// simulate standard type and add flag
$wc_prod = new WC_Product($post_id);
$wc_gallery = $wc_prod->get_gallery_attachment_ids();
$type = is_array($wc_gallery) && count($wc_gallery) > 0 ? 'img_gallery' : 'single_img';
} else {
$type = get_post_meta($post_id, 'mg_main_type', true);
$wc_prod = false;
}
// layout
$layout = get_post_meta($post_id, 'mg_layout', true);
$touchswipe = get_option('mg_lb_touchswipe') ? 'mg_touchswipe' : '';
$img_max_h = (int) get_post_meta($post_id, 'mg_img_maxheight', true);
$item_title = $post_data->post_title;
// canvas color for TT
$tt_canvas = substr(get_option('mg_item_bg_color', '#ffffff'), 1);
// maxwidth control
$lb_max_w = (int) get_option('mg_item_maxwidth', 960);
if ($lb_max_w == 0) {
$lb_max_w = 960;
}
// Thumb center
$tt_center = get_post_meta($post_id, 'mg_thumb_center', true) ? get_post_meta($post_id, 'mg_thumb_center', true) : 'c';
// lightbox max width for the item
$fc_max_w = (int) get_post_meta($post_id, 'mg_lb_max_w', true);
if (!$fc_max_w || $fc_max_w < 280) {
$fc_max_w = false;
}
// item featured image for socials
$fi_img_id = get_post_thumbnail_id($post_id);
$fi_src = wp_get_attachment_image_src($fi_img_id, 'medium');
$fi_src_pt = wp_get_attachment_image_src($fi_img_id, 'full');
// pinterest - use full one
///////////////////////////
// TYPES
if ($type == 'single_img') {
$img_id = get_post_thumbnail_id($post_id);
$featured = mg_preloader() . '<img src="' . mg_lb_image_optimizer($img_id, $layout, $img_max_h, $tt_center, $resize = 3) . '" alt="' . mg_sanitize_input(strip_tags($item_title)) . '" />';
} elseif ($type == 'img_gallery') {
$slider_img = isset($wc_gallery) ? $wc_gallery : get_post_meta($post_id, 'mg_slider_img', true);
$style = get_option('mg_slider_style', 'light');
$unique_id = uniqid();
$autoplay = get_post_meta($post_id, 'mg_slider_autoplay', true) ? 'true' : 'false';
// slider height
$def_h_val = get_option('mg_slider_main_w_val', 55);
$def_h_type = get_option('mg_slider_main_w_type', '%');
$h_val = get_post_meta($post_id, 'mg_slider_w_val', true);
$h_type = get_post_meta($post_id, 'mg_slider_w_type', true);
if (!$h_val) {
$h_val = $def_h_val;
}
if (!$h_type) {
$h_type = $def_h_type;
}
$height = $h_val . $h_type;
// slider proportions parameter
if (strpos($height, '%') !== false) {
$val = (int) str_replace("%", "", $height) / 100;
$proportions_param = 'asp-ratio="' . $val . '"';
$proportions_class = "mg_galleria_responsive";
$slider_h = '';
$stage_max_h = $val;
} else {
$proportions_param = '';
$proportions_class = "";
$slider_h = 'height: ' . $height . ';';
$stage_max_h = $h_val;
}
// images management
$crop = get_post_meta($post_id, 'mg_slider_crop', true);
if (!$crop) {
$crop = 'true';
}
// slider thumbs visibility
$thumbs_visibility = get_post_meta($post_id, 'mg_slider_thumbs', true);
$thumbs_class = $thumbs_visibility == 'yes' || $thumbs_visibility == 'always' ? 'mg_galleria_slider_show_thumbs' : '';
// thumbs CSS code
if ($thumbs_visibility == 'always' || $thumbs_visibility == 'never') {
$css_code = '.mg_galleria_slider_wrap .galleria-mg-toggle-thumb {display: none !important;}';
} else {
$css_code = '';
}
if (!$thumbs_visibility || $thumbs_visibility == 'no' || $thumbs_visibility == 'never') {
$css_code .= '.mg_galleria_slider_wrap .galleria-thumbnails-container {opacity: 0; filter: alpha(opacity=0);}';
}
$featured = '
<style type="text/css">
' . $css_code . '
.mg_item_featured {max-height: 0px; overflow: hidden;}
</style>
<script type="text/javascript">
mg_galleria_img_crop = "' . $crop . '";
mg_slider_autoplay["#' . $unique_id . '"] = ' . $autoplay . ';
//.........这里部分代码省略.........
示例3: get_images
/**
* Get the images for a product or product variation.
*
* @param WC_Product|WC_Product_Variation $product
* @return array
*/
protected function get_images($product)
{
$images = array();
$attachment_ids = array();
if ($product->is_type('variation')) {
if (has_post_thumbnail($product->get_variation_id())) {
// Add variation image if set.
$attachment_ids[] = get_post_thumbnail_id($product->get_variation_id());
} elseif (has_post_thumbnail($product->id)) {
// Otherwise use the parent product featured image if set.
$attachment_ids[] = get_post_thumbnail_id($product->id);
}
} else {
// Add featured image.
if (has_post_thumbnail($product->id)) {
$attachment_ids[] = get_post_thumbnail_id($product->id);
}
// Add gallery images.
$attachment_ids = array_merge($attachment_ids, $product->get_gallery_attachment_ids());
}
// Build image data.
foreach ($attachment_ids as $position => $attachment_id) {
$attachment_post = get_post($attachment_id);
if (is_null($attachment_post)) {
continue;
}
$attachment = wp_get_attachment_image_src($attachment_id, 'full');
if (!is_array($attachment)) {
continue;
}
$imageData = array('id' => (int) $attachment_id, 'date_created' => wc_rest_prepare_date_response($attachment_post->post_date_gmt), 'date_modified' => wc_rest_prepare_date_response($attachment_post->post_modified_gmt), 'src' => current($attachment), 'name' => get_the_title($attachment_id), 'alt' => get_post_meta($attachment_id, '_wp_attachment_image_alt', true), 'position' => (int) $position);
if ($_GET['include'] == 'image-sizes') {
$imageData['sizes'] = $this->get_image_sizes($attachment_id);
}
$images[] = $imageData;
}
// Set a placeholder image if the product has no images set.
if (empty($images)) {
$images[] = array('id' => 0, 'date_created' => wc_rest_prepare_date_response(current_time('mysql')), 'date_modified' => wc_rest_prepare_date_response(current_time('mysql')), 'src' => wc_placeholder_img_src(), 'name' => __('Placeholder', 'woocommerce'), 'alt' => __('Placeholder', 'woocommerce'), 'position' => 0);
}
return $images;
}
示例4: array
function anaglyph_woo_template_loop_second_product_thumbnail()
{
global $post, $woocommerce, $product, $anaglyph_config;
$columns_in = (int) $anaglyph_config['shop-product-perrow'];
$attachment_ids = '';
$size = 'full';
$productObj = new WC_Product($product);
$attachment_ids = $productObj->get_gallery_attachment_ids();
if (!empty($attachment_ids)) {
$secondary_image_id = $attachment_ids['0'];
if ($columns_in == 2) {
$size = array(560, 560);
} else {
if ($columns_in == 3) {
$size = array(420, 420);
} else {
if ($columns_in == 1) {
$size = 'full';
} else {
$size = array(258, 258);
}
}
}
echo wp_get_attachment_image($secondary_image_id, $size, '', $attr = array('class' => 'anaglyph-second-image attachment-shop-catalog'));
}
}
示例5: get_images
/**
* Get the images for a product or product variation
*
* @since 2.1
* @param WC_Product|WC_Product_Variation $product
* @return array
*/
private function get_images($product)
{
$images = $attachment_ids = array();
if ($product->is_type('variation')) {
if (has_post_thumbnail($product->get_variation_id())) {
// Add variation image if set
$attachment_ids[] = get_post_thumbnail_id($product->get_variation_id());
} elseif (has_post_thumbnail($product->id)) {
// Otherwise use the parent product featured image if set
$attachment_ids[] = get_post_thumbnail_id($product->id);
}
} else {
// Add featured image
if (has_post_thumbnail($product->id)) {
$attachment_ids[] = get_post_thumbnail_id($product->id);
}
// Add gallery images
$attachment_ids = array_merge($attachment_ids, $product->get_gallery_attachment_ids());
}
// Build image data
foreach ($attachment_ids as $position => $attachment_id) {
$attachment_post = get_post($attachment_id);
if (is_null($attachment_post)) {
continue;
}
$attachment = wp_get_attachment_image_src($attachment_id, 'full');
if (!is_array($attachment)) {
continue;
}
$images[] = array('id' => (int) $attachment_id, 'created_at' => $this->server->format_datetime($attachment_post->post_date_gmt), 'updated_at' => $this->server->format_datetime($attachment_post->post_modified_gmt), 'src' => current($attachment), 'title' => get_the_title($attachment_id), 'alt' => get_post_meta($attachment_id, '_wp_attachment_image_alt', true), 'position' => (int) $position);
}
// Set a placeholder image if the product has no images set
if (empty($images)) {
$images[] = array('id' => 0, 'created_at' => $this->server->format_datetime(time()), 'updated_at' => $this->server->format_datetime(time()), 'src' => wc_placeholder_img_src(), 'title' => __('Placeholder', 'woocommerce'), 'alt' => __('Placeholder', 'woocommerce'), 'position' => 0);
}
return $images;
}
示例6: extract
//.........这里部分代码省略.........
$display_type = '';
}
if (!isset($columns)) {
$columns = '4';
}
if (isset($per_page)) {
$post_count = $per_page;
}
if (isset($number)) {
$post_count = $number;
}
if (!isset($order)) {
$order = 'ASC';
}
if (!isset($orderby)) {
$orderby = 'date';
}
if (!isset($category)) {
$category = '';
}
if (!isset($ids)) {
$ids = '';
}
if ($ids) {
$ids = explode(',', $ids);
$ids = array_map('trim', $ids);
}
if ($columns == "2") {
$columns = 6;
} elseif ($columns == "3") {
$columns = 4;
} elseif ($columns == "4") {
$columns = 3;
}
$meta_query = '';
if ($display_type == "recent_products") {
$meta_query = WC()->query->get_meta_query();
}
if ($display_type == "featured_products") {
$meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes'));
}
if ($display_type == "top_rated_products") {
add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
$meta_query = WC()->query->get_meta_query();
}
$args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $post_count, 'orderby' => $orderby, 'order' => $order, 'meta_query' => $meta_query);
if ($display_type == "sale_products") {
$product_ids_on_sale = woocommerce_get_product_ids_on_sale();
$meta_query = array();
$meta_query[] = $woocommerce->query->visibility_meta_query();
$meta_query[] = $woocommerce->query->stock_status_meta_query();
$args['meta_query'] = $meta_query;
$args['post__in'] = $product_ids_on_sale;
}
if ($display_type == "best_selling_products") {
$args['meta_key'] = 'total_sales';
$args['orderby'] = 'meta_value_num';
$args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'));
}
if ($display_type == "product_category") {
$args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN'));
}
if ($display_type == "product_categories") {
$args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $ids, 'field' => 'term_id', 'operator' => 'IN'));
}
$query = new WP_Query($args);
$output .= '<ul class="wcmp-product-list wcmp-img-' . $img_position . ' ' . $order . '">';
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$product_id = get_the_ID();
$post = get_post($product_id);
$product_title = get_the_title();
$product = new WC_Product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
$price = $product->get_price_html();
$rating = $product->get_rating_html();
$product_var = new WC_Product_Variable($product_id);
$available_variations = $product_var->get_available_variations();
$output .= '<li>';
$output .= '<a href="' . get_permalink($product_id) . '">';
$product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), 'full');
$output .= '<img style="' . $style . '" src="' . $product_img[0] . '"/>';
$output .= '<span style="' . $title_style . '">' . $product_title . '</span>';
$output .= '</a>';
if ($display_type == "top_rated_products") {
$output .= '<div style="' . $rating_style . '">' . $rating . '</div>';
}
$output .= '<span class="amount" style="' . $pricing_style . '">' . $price . '</span>';
$output .= '</li>';
}
}
$output .= "\n" . '</ul>';
$output .= "\n" . '</div>';
if ($display_type == "top_rated_products") {
remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
}
wp_reset_postdata();
return $output;
}
示例7: array
//.........这里部分代码省略.........
$front_edit_reverse = array("postName" => __('Product Name', "ts_visual_composer_extend"), "postPrice" => __('Product Price', "ts_visual_composer_extend"), "postRating" => __('Product Rating', "ts_visual_composer_extend"), "postDate" => __('Product Date', "ts_visual_composer_extend"), "postModified" => __('Product Modified', "ts_visual_composer_extend"));
foreach ($front_edit_reverse as $key => $value) {
if ($key == $sort_by) {
echo '<div>' . __("Sort Criterion", "ts_visual_composer_extend") . ': ' . $value . '</div>';
}
}
$front_edit_reverse = array("asc" => __('Bottom to Top', "ts_visual_composer_extend"), "desc" => __('Top to Bottom', "ts_visual_composer_extend"));
foreach ($front_edit_reverse as $key => $value) {
if ($key == $sort_order) {
echo '<div>' . __("Initial Order", "ts_visual_composer_extend") . ': ' . $value . '</div>';
}
}
echo '<div>' . __("Show Filter Button", "ts_visual_composer_extend") . ': ' . $filter_menu . '</div>';
echo '<div>' . __("Show Layout Button", "ts_visual_composer_extend") . ': ' . $layout_menu . '</div>';
echo '<div>' . __("Show Sort Criterion Button", "ts_visual_composer_extend") . ': ' . $sort_menu . '</div>';
echo '<div>' . __("Show Directions Buttons", "ts_visual_composer_extend") . ': ' . $directions_menu . '</div>';
echo '</div>';
} else {
$opening .= '<div id="' . $posts_container_id . '" class="ts-isotope-posts-grid-parent ' . ($layout == 'spineTimeline' ? 'ts-timeline ' : 'ts-postsgrid ') . 'ts-timeline-' . $sort_order . ' ts-posts-timeline ' . $isotope_posts_list_class . ' ' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . ';" data-lazy="' . $posts_lazy . '" data-count="' . $posts_limit . '" data-ajax="' . $posts_ajax . '" data-trigger="' . $posts_trigger . '" data-column="' . $column_width . '" data-layout="' . $layout . '" data-sort="' . $sort_by . '" data-order="' . $sort_order . '" data-break="' . $layout_break . '" data-type="' . $post_type . '">';
// Create Individual Post Output
$postCounter = 0;
$postCategories = array();
$categoriesCount = 0;
if (post_type_exists($post_type) && $loop->have_posts()) {
$products .= '<div class="ts-timeline-content">';
$products .= '<ul id="ts-isotope-posts-grid-' . $postsgrid_random . '" class="ts-isotope-posts-grid ts-timeline-list" data-layout="' . $layout . '" data-key="' . $postsgrid_random . '">';
while ($loop->have_posts()) {
$loop->the_post();
$postCounter++;
$product_id = get_the_ID();
$product_title = get_the_title($product_id);
$post = get_post($product_id);
$product = new WC_Product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
$price = $product->get_price_html();
$product_sku = $product->get_sku();
$attributes = $product->get_attributes();
$stock = $product->is_in_stock() ? 'true' : 'false';
$onsale = $product->is_on_sale() ? 'true' : 'false';
// Rating Settings
$rating_html = $product->get_rating_html();
$rating = $product->get_average_rating();
if ($rating == '') {
$rating = 0;
}
if ($rating_quarter == "true") {
$rating_value = floor($rating * 4) / 4;
} else {
$rating_value = $rating;
}
$rating_value = number_format($rating_value, 2, $caption_digits, '');
if ($rating_rtl == "false") {
$rating_width = $rating_value / $rating_maximum * 100;
} else {
$rating_width = 100 - $rating_value / $rating_maximum * 100;
}
if ($rating_symbol == "other") {
if ($rating_icon == "ts-ecommerce-starfull1") {
$rating_class = 'ts-rating-stars-star1';
} else {
if ($rating_icon == "ts-ecommerce-starfull2") {
$rating_class = 'ts-rating-stars-star2';
} else {
if ($rating_icon == "ts-ecommerce-starfull3") {
$rating_class = 'ts-rating-stars-star3';
} else {
示例8: WooComposer_Loop_style04
//.........这里部分代码省略.........
$args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN'));
}
if ($display_type == "product_categories") {
$args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $ids, 'field' => 'term_id', 'operator' => 'IN'));
}
$test = '';
if (vc_is_inline()) {
$test = "wcmp_vc_inline";
}
if ($product_animation == '') {
$product_animation = 'no-animation';
} else {
$style .= 'opacity:1;';
}
if ($element == "grid") {
$class = 'vc_span' . $columns . ' ';
}
$output .= '<div class="woocomposer ' . $test . '" data-columns="' . $col . '">';
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$product_id = get_the_ID();
$uid = uniqid();
$output .= '<div id="product-' . $uid . '" style="' . $style . '" class="' . $class . ' wpb_column column_container wooproduct" data-animation="animated ' . $product_animation . '">';
if ($element == 'carousel') {
$output .= '<div class="wcmp-carousel-item">';
}
$product_title = get_the_title($product_id);
$post = get_post($product_id);
$product_desc = get_post($product_id)->post_excerpt;
$product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
$product = new WC_Product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
$price = $product->get_price_html();
$rating = $product->get_rating_html();
$attributes = $product->get_attributes();
$stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock';
if ($product->is_on_sale()) {
$on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product);
} else {
$on_sale = '';
}
if ($quick_view_style == "expandable") {
$quick_view_class = 'quick-view-loop';
} else {
$quick_view_class = 'quick-view-loop-popup';
}
$cat_count = sizeof(get_the_terms($product_id, 'product_cat'));
$tag_count = sizeof(get_the_terms($product_id, 'product_tag'));
$categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>');
$tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>');
$output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">';
$output .= "\n\t" . '<div class="wcmp-product-image">';
if (empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") {
$uniqid = uniqid();
$output .= '<div class="wcmp-single-image-carousel carousel-in-loop">';
$product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
if ($lazy_images == "enable") {
$src = plugins_url('../assets/img/loader.gif', __FILE__);
} else {
$src = $product_img[0];
}
$output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>';
foreach ($attachment_ids as $attachment_id) {
$product_img = wp_get_attachment_image_src($attachment_id, $image_size);
示例9: WooComposer_Single_style03
function WooComposer_Single_style03($atts)
{
$product_id = $product_style = $display_elements = $img_animate = $text_align = $color_heading = $color_categories = $color_price = '';
$color_rating = $color_rating_bg = $color_quick_bg = $color_quick = $color_cart_bg = $color_cart = $color_product_desc = '';
$color_product_desc_bg = $size_title = $size_cat = $size_price = $color_on_sale = $color_on_sale_bg = $label_on_sale = $border_style = '';
$border_color = $border_size = $border_radius = $sale_price = $on_sale_alignment = $on_sale_style = $product_img_disp = '';
extract(shortcode_atts(array("product_id" => "", "product_style" => "style01", "display_elements" => "", "label_on_sale" => "Sale!", "text_align" => "left", "img_animate" => "rotate-clock", "color_heading" => "", "color_categories" => "", "color_price" => "", "color_rating" => "", "color_rating_bg" => "", "color_quick_bg" => "", "color_quick" => "", "color_cart_bg" => "", "color_on_sale_bg" => "", "color_on_sale" => "", "color_cart" => "", "color_product_desc" => "", "color_product_desc_bg" => "", "size_title" => "", "size_cat" => "", "size_price" => "", "border_style" => "", "border_color" => "", "border_size" => "", "border_radius" => "", "sale_price" => "", "on_sale_style" => "wcmp-sale-circle", "on_sale_alignment" => "wcmp-sale-right", "product_img_disp" => "single"), $atts));
$output = $heading_style = $cat_style = $price_style = $cart_style = $cart_bg_style = $view_style = $view_bg_style = $rating_style = '';
$desc_style = $label_style = $border = $desc_style = $sale_price_size = '';
$image_size = apply_filters('single_product_large_thumbnail_size', 'shop_single');
if ($sale_price !== '') {
$sale_price_size = 'font-size:' . $sale_price . 'px;';
}
$img_animate = 'wcmp-img-' . $img_animate;
if ($border_style !== '') {
$border .= 'border:' . $border_size . 'px ' . $border_style . ' ' . $border_color . ';';
$border .= 'border-radius:' . $border_radius . 'px;';
}
if ($color_product_desc_bg !== '') {
$desc_style .= 'background:' . $color_product_desc_bg . ';';
}
if ($color_product_desc !== '') {
$desc_style .= 'color:' . $color_product_desc . ';';
}
if ($color_heading !== "") {
$heading_style = 'color:' . $color_heading . ';';
}
if ($size_title !== "") {
$heading_style .= 'font-size:' . $size_title . 'px;';
}
if ($color_categories !== "") {
$cat_style = 'color:' . $color_categories . ';';
}
if ($size_cat !== "") {
$cat_style .= 'font-size:' . $size_cat . 'px;';
}
if ($color_price !== "") {
$price_style = 'color:' . $color_price . ';';
}
if ($size_price !== "") {
$price_style .= 'font-size:' . $size_price . 'px;';
}
if ($color_rating !== "") {
$rating_style .= 'color:' . $color_rating . ';';
}
if ($color_rating_bg !== "") {
$rating_style .= 'background:' . $color_rating_bg . ';';
}
if ($color_quick_bg !== "") {
$view_bg_style = 'background:' . $color_quick_bg . ';';
}
if ($color_quick !== "") {
$view_style = 'color:' . $color_quick . ';';
}
if ($color_cart_bg !== "") {
$cart_bg_style = 'background:' . $color_cart_bg . ';';
}
if ($color_cart !== "") {
$cart_style = 'color:' . $color_cart . ';';
}
if ($color_on_sale_bg !== "") {
$label_style = 'background:' . $color_on_sale_bg . ';';
}
if ($color_on_sale !== "") {
$label_style .= 'color:' . $color_on_sale . ';';
}
$elemets = explode(",", $display_elements);
$product_title = get_the_title($product_id);
$post = get_post($product_id);
$product_desc = get_post($product_id)->post_excerpt;
$product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
$product = new WC_Product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
$price = $product->get_price_html();
$rating = $product->get_rating_html();
$attributes = $product->get_attributes();
$stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock';
if ($product->is_on_sale()) {
$on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product);
} else {
$on_sale = '';
}
$cat_count = sizeof(get_the_terms($product_id, 'product_cat'));
$tag_count = sizeof(get_the_terms($product_id, 'product_tag'));
$categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>');
$tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>');
$output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">';
$output .= "\n\t" . '<div class="wcmp-product-image">';
if (!empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") {
$uniqid = uniqid();
$output .= '<div class="wcmp-single-image-carousel">';
$product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
$src = $product_img[0];
$output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>';
foreach ($attachment_ids as $attachment_id) {
$product_img = wp_get_attachment_image_src($attachment_id, $image_size);
$output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>';
}
$output .= '</div>';
} else {
//.........这里部分代码省略.........
示例10: extract
//.........这里部分代码省略.........
// Start WordPress Query
$loop = new WP_Query($args);
if ($data_grid_machine == 'internal') {
$class_name = 'ts-image-link-grid-frame';
} else {
if ($data_grid_machine == 'freewall') {
wp_enqueue_script('ts-extend-freewall');
$class_name = 'ts-image-freewall-grid-frame';
}
}
if (function_exists('vc_shortcode_custom_css_class')) {
$css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $el_class . ' ' . $class_name . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_ImageGrid_Basic', $atts);
} else {
$css_class = $class_name . ' ' . $el_class;
}
$fullwidth_allow = "true";
$postCounter = 0;
$modal_gallery = '';
// Front-Edit Message
if ($frontend_edit == "true") {
$modal_gallery .= $grid_message;
if ($loop->have_posts()) {
while ($loop->have_posts()) {
$loop->the_post();
$matched_terms = 0;
$post_thumbnail = get_the_post_thumbnail();
if ($matched_terms == 0 && ($post_thumbnail != '' || $data_grid_invalid == "false")) {
$postCounter++;
if ($postCounter < $posts_limit + 1) {
$product_id = get_the_ID();
$product_title = get_the_title($product_id);
$post = get_post($product_id);
$product = new WC_Product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
$product_sku = $product->get_sku();
$attributes = $product->get_attributes();
$stock = $product->is_in_stock() ? 'true' : 'false';
if ('' != $post_thumbnail) {
$grid_image = wp_get_attachment_image_src(get_post_thumbnail_id(), $content_images_size);
$modal_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
$grid_image = $grid_image[0];
$modal_image = $modal_image[0];
} else {
$grid_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png');
$modal_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png');
}
$categories = array();
if (taxonomy_exists($menu_tax)) {
foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) {
array_push($categories, $term->name);
}
$categories = implode($categories, ',');
}
$valid_images++;
$modal_gallery .= '<a style="' . $image_style . '" href="' . get_permalink() . '" target="_blank" title="' . get_the_title() . '">';
$modal_gallery .= '<img id="ts-image-link-picture-' . $randomizer . '-' . $i . '" class="ts-image-link-picture" src="' . $grid_image . '" rel="link-group-' . $randomizer . '" data-include="true" data-image="' . $modal_image . '" width="100%" height="auto" title="' . get_the_title() . '" data-groups="' . $categories . '" data-target="' . $data_grid_target . '" data-link="' . get_permalink() . '">';
$modal_gallery .= '</a>';
$categories = array();
}
}
}
} else {
echo __("No products could be found.", "ts_visual_composer_extend");
}
wp_reset_postdata();
wp_reset_query();
示例11: extract
//.........这里部分代码省略.........
if (function_exists('vc_shortcode_custom_css_class')) {
$css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $slider_class . ' ' . $el_class . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Slider_Basic', $atts);
} else {
$css_class = $slider_class . ' ' . $el_class;
}
$output .= '<div id="' . $woo_slider_id . '-container" class="ts-woocommerce-slider-container">';
// Add Progressbar
if ($auto_play == "true" && $show_bar == "true" && $frontend_edit == "false") {
$output .= '<div id="ts-owlslider-progressbar-' . $woo_random . '" class="ts-owlslider-progressbar-holder" style=""><div class="ts-owlslider-progressbar" style="background: ' . $bar_color . '; height: 100%; width: 0%;"></div></div>';
}
// Add Navigation Controls
if ($frontend_edit == "false") {
$output .= '<div id="ts-owlslider-controls-' . $woo_random . '" class="ts-owlslider-controls" style="' . ($auto_play == "true" || $show_navigation == "true" ? "display: block;" : "display: none;") . '">';
$output .= '<div id="ts-owlslider-controls-next-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>';
$output .= '<div id="ts-owlslider-controls-prev-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>';
if ($auto_play == "true") {
$output .= '<div id="ts-owlslider-controls-play-' . $woo_random . '" class="ts-owlslider-controls-play active"><span class="ts-ecommerce-pause"></span></div>';
}
$output .= '</div>';
}
// Front-Edit Message
if ($frontend_edit == "true") {
$output .= $slider_message;
}
// Add Slider
$output .= '<div id="' . $woo_slider_id . '" class="' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px;" data-id="' . $woo_random . '" data-items="' . $products_slide . '" data-breakpointscustom="' . $breakpoints_custom . '" data-breakpointitems="' . $breakpoints_items . '" data-rtl="' . $page_rtl . '" data-loop="' . $items_loop . '" data-navigation="' . $show_navigation . '" data-dots="' . $show_dots . '" data-mobile="' . $animation_mobile . '" data-animationin="' . $animation_in . '" data-animationout="' . $animation_out . '" data-height="' . $auto_height . '" data-play="' . $auto_play . '" data-bar="' . $show_bar . '" data-color="' . $bar_color . '" data-speed="' . $show_speed . '" data-hover="' . $stop_hover . '">';
if ($loop->have_posts()) {
while ($loop->have_posts()) {
$loop->the_post();
$product_id = get_the_ID();
$product_title = get_the_title($product_id);
$post = get_post($product_id);
$product = new WC_Product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
$price = $product->get_price_html();
$product_sku = $product->get_sku();
$attributes = $product->get_attributes();
$stock = $product->is_in_stock() ? 'true' : 'false';
$onsale = $product->is_on_sale() ? 'true' : 'false';
// Rating Settings
$rating_html = $product->get_rating_html();
$rating = $product->get_average_rating();
if ($rating == '') {
$rating = 0;
}
if ($rating_quarter == "true") {
$rating_value = floor($rating * 4) / 4;
} else {
$rating_value = $rating;
}
$rating_value = number_format($rating_value, 2, $caption_digits, '');
if ($rating_rtl == "false") {
$rating_width = $rating_value / $rating_maximum * 100;
} else {
$rating_width = 100 - $rating_value / $rating_maximum * 100;
}
if ($rating_symbol == "other") {
if ($rating_icon == "ts-ecommerce-starfull1") {
$rating_class = 'ts-rating-stars-star1';
} else {
if ($rating_icon == "ts-ecommerce-starfull2") {
$rating_class = 'ts-rating-stars-star2';
} else {
if ($rating_icon == "ts-ecommerce-starfull3") {
$rating_class = 'ts-rating-stars-star3';
} else {
示例12: extract
//.........这里部分代码省略.........
data-parent="' . $woo_ticker_id . '"
data-side="' . $ticker_side . '"
data-header="ts-newsticker-header-' . $woo_random . '"
data-next="ts-newsticker-controls-next-' . $woo_random . '"
data-prev="ts-newsticker-controls-prev-' . $woo_random . '"
data-play="ts-newsticker-controls-play-' . $woo_random . '"
data-stop="ts-newsticker-controls-stop-' . $woo_random . '">';
$output .= '<div class="ts-newsticker-elements-frame ' . $newsticker_elements . ' ' . $ticker_border_radius . '" style="">';
// Add Navigation Controls
$output .= '<div id="ts-newsticker-controls-' . $woo_random . '" class="ts-newsticker-controls" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . ' ' . $newsticker_controls . '">';
$output .= '<div id="ts-newsticker-controls-next-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>';
$output .= '<div id="ts-newsticker-controls-prev-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>';
$output .= '<div id="ts-newsticker-controls-stop-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: block;" : "display: none;") . '"><span class="ts-ecommerce-pause"></span></div>';
$output .= '<div id="ts-newsticker-controls-play-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: none;" : "display: block;") . '"><span class="ts-ecommerce-play"></span></div>';
$output .= '</div>';
if ($ticker_side == "left" && $ticker_title == "true") {
$output .= '<div id="ts-newsticker-header-' . $woo_random . '" class="header ' . $ticker_border_radius . '" style="background: ' . $ticker_background . '; color: ' . $ticker_color . '; left: 0;">';
if ($ticker_icon != '' && $ticker_icon != 'transparent' && $ticker_symbol == "true") {
$output .= '<i class="ts-font-icon ' . $ticker_icon . '" style="color: ' . $ticker_paint . '"></i>';
}
$output .= '<span>' . $ticker_header . '</span>';
$output .= '</div>';
}
$output .= '<ul id="ts-newsticker-ticker-' . $woo_random . '" class="newsticker ' . $ticker_border_radius . '" style="' . $newsticker_header . '">';
while ($loop->have_posts()) {
$loop->the_post();
$postCounter++;
if ($postCounter < $posts_limit + 1) {
$postAttributes = 'data-full="' . get_post_time($date_format) . '" data-time="' . get_post_time($time_format) . '" data-author="' . get_the_author() . '" data-date="' . get_post_time('U') . '" data-modified="' . get_the_modified_time('U') . '" data-title="' . get_the_title() . '" data-comments="' . get_comments_number() . '" data-id="' . get_the_ID() . '"';
$product_id = get_the_ID();
$product_title = get_the_title($product_id);
$post = get_post($product_id);
$product = new WC_Product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
$price = $product->get_price_html();
$product_sku = $product->get_sku();
$attributes = $product->get_attributes();
$stock = $product->is_in_stock() ? 'true' : 'false';
$onsale = $product->is_on_sale() ? 'true' : 'false';
// Rating Settings
$rating_html = $product->get_rating_html();
$rating = $product->get_average_rating();
if ($rating == '') {
$rating = 0;
}
if ($rating_quarter == "true") {
$rating_value = floor($rating * 4) / 4;
} else {
$rating_value = $rating;
}
$rating_value = number_format($rating_value, 2, $caption_digits, '');
if ($rating_rtl == "false") {
$rating_width = $rating_value / $rating_maximum * 100;
} else {
$rating_width = 100 - $rating_value / $rating_maximum * 100;
}
if ($rating_symbol == "other") {
if ($rating_icon == "ts-ecommerce-starfull1") {
$rating_class = 'ts-rating-stars-star1';
} else {
if ($rating_icon == "ts-ecommerce-starfull2") {
$rating_class = 'ts-rating-stars-star2';
} else {
if ($rating_icon == "ts-ecommerce-starfull3") {
$rating_class = 'ts-rating-stars-star3';
} else {
示例13: extract
function TS_VCSC_WooCommerce_Rating_Basic_Function($atts, $content = null)
{
global $VISUAL_COMPOSER_EXTENSIONS;
global $product;
global $woocommerce;
ob_start();
if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") {
wp_enqueue_style('ts-extend-simptip');
wp_enqueue_style('ts-font-ecommerce');
wp_enqueue_style('ts-visual-composer-extend-front');
wp_enqueue_script('ts-visual-composer-extend-front');
}
extract(shortcode_atts(array('best_rated' => 'false', 'id' => '', 'rating_maximum' => 5, 'rating_size' => 24, 'rating_quarter' => 'true', 'rating_title' => 'true', 'rating_auto' => 'true', 'rating_position' => 'top', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => '', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'true', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'title_size' => 24, 'title_truncate' => 'true', 'use_name' => 'true', 'custom_title' => '', 'show_cart' => 'true', 'cart_color' => '#cccccc', 'show_link' => 'true', 'link_color' => '#cccccc', 'tooltip_css' => 'false', 'tooltip_content' => '', 'tooltip_position' => 'ts-simptip-position-top', 'tooltip_style' => '', 'margin_top' => 20, 'margin_bottom' => 20, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts));
// Final Query Arguments
add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
$meta_query = WC()->query->get_meta_query();
$args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => -1, 'orderby' => 'date', 'order' => 'desc', 'paged' => 1, 'meta_query' => $meta_query);
$loop = new WP_Query($args);
if ($loop->have_posts()) {
$best_rating = 0;
while ($loop->have_posts()) {
$loop->the_post();
$product_id = get_the_ID();
$product = new WC_Product($product_id);
if ($product_id == $id) {
$product_title = get_the_title($product_id);
$post = get_post($product_id);
$product = new WC_Product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
$price = $product->get_price_html();
$product_sku = $product->get_sku();
$attributes = $product->get_attributes();
$stock = $product->is_in_stock() ? 'true' : 'false';
$onsale = $product->is_on_sale() ? 'true' : 'false';
$link = get_permalink();
// Rating Settings
$rating_html = $product->get_rating_html();
$rating = $product->get_average_rating();
if ($rating == '') {
$rating = 0;
}
if ($rating_quarter == "true") {
$rating_value = floor($rating * 4) / 4;
} else {
$rating_value = $rating;
}
$rating_value = number_format($rating_value, 2, $caption_digits, '');
break;
}
}
}
wp_reset_postdata();
wp_reset_query();
if ($rating_title == "true") {
if ($use_name == "true") {
$rating_title = $product_title;
} else {
$rating_title = $custom_title;
}
} else {
$rating_title = '';
}
if ($rating_rtl == "false") {
$rating_width = $rating_value / $rating_maximum * 100;
} else {
$rating_width = 100 - $rating_value / $rating_maximum * 100;
}
if ($rating_symbol == "other") {
if ($rating_icon == "ts-ecommerce-starfull1") {
$rating_class = 'ts-rating-stars-star1';
} else {
if ($rating_icon == "ts-ecommerce-starfull2") {
$rating_class = 'ts-rating-stars-star2';
} else {
if ($rating_icon == "ts-ecommerce-starfull3") {
$rating_class = 'ts-rating-stars-star3';
} else {
if ($rating_icon == "ts-ecommerce-starfull4") {
$rating_class = 'ts-rating-stars-star4';
} else {
if ($rating_icon == "ts-ecommerce-heartfull") {
$rating_class = 'ts-rating-stars-heart1';
} else {
if ($rating_icon == "ts-ecommerce-heart") {
$rating_class = 'ts-rating-stars-heart2';
} else {
if ($rating_icon == "ts-ecommerce-thumbsup") {
$rating_class = 'ts-rating-stars-thumb';
} else {
if ($rating_icon == "ts-ecommerce-ribbon4") {
$rating_class = 'ts-rating-stars-ribbon';
}
}
}
}
}
}
}
}
} else {
//.........这里部分代码省略.........
示例14: insert_meta_tags
//.........这里部分代码省略.........
//Featured
if ($id_attachment = get_post_thumbnail_id($this->post->ID)) {
//There's a featured/thumbnail image for this listing
$fb_image = wp_get_attachment_url($id_attachment, false);
$thumbdone = true;
} else {
}
}
if (!$thumbdone) {
//Main image loaded
if ($thumbnail_id = wpbdp_listings_api()->get_thumbnail_id($this->post->ID)) {
$fb_image = wp_get_attachment_url($thumbnail_id, false);
$thumbdone = true;
}
}
}
}
}
// WooCommerce
if ($webdados_fb->is_woocommerce_active() && is_product()) {
$fb_type = 'product';
$product = new WC_Product($post->ID);
//Price
$fb_additional_tags['property']['og_price_amount'] = array($product->get_price_including_tax());
if (function_exists('get_woocommerce_currency')) {
$fb_additional_tags['property']['og_price_currency'] = array(get_woocommerce_currency());
}
$fb_additional_tags['name']['twitter_label1'] = array(__('Price', 'wd-fb-og'));
if (function_exists('get_woocommerce_currency')) {
$fb_additional_tags['name']['twitter_data1'] = array($product->get_price_including_tax() . ' ' . get_woocommerce_currency());
}
//Additional product images?
if (intval($this->options['fb_image_show']) == 1 && $this->options['fb_wc_useproductgallery'] == 1) {
if ($attachment_ids = $product->get_gallery_attachment_ids()) {
foreach ($attachment_ids as $attachment_id) {
if ($image_link = wp_get_attachment_url($attachment_id)) {
if (trim($image_link) != '') {
$fb_image_additional[] = array('fb_image' => trim($image_link), 'png_overlay' => intval($this->options['fb_wc_usepg_png_overlay']) ? true : false);
}
}
}
}
}
}
} else {
//Other pages - Defaults
$fb_title = esc_attr(wp_strip_all_tags(stripslashes(get_bloginfo('name')), true));
$fb_url = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//Not really canonical but will work for now
$fb_image = trim($this->options['fb_image']);
$this->options['fb_article_sections_show'] = 0;
$this->options['fb_article_dates_show'] = 0;
$this->options['fb_author_show'] = 0;
$this->options['fb_author_show_meta'] = 0;
$this->options['fb_author_show_linkrelgp'] = 0;
$this->options['fb_author_show_twitter'] = 0;
$this->options['fb_author_show_twitter'] = 0;
//Category
if (is_category()) {
$fb_title = esc_attr(wp_strip_all_tags(stripslashes(single_cat_title('', false)), true));
$term = $wp_query->get_queried_object();
$fb_url = get_term_link($term, $term->taxonomy);
$cat_desc = trim(esc_attr(wp_strip_all_tags(stripslashes(category_description()), true)));
if (trim($cat_desc) != '') {
$fb_desc = $cat_desc;
}
示例15: content
//.........这里部分代码省略.........
} else {
$data_carousel['items'] = 3;
if ($products->post_count < 3) {
$data_carousel['loop'] = 'false';
} else {
$data_carousel['loop'] = $loop;
}
}
?>
<div class="section8 block-trending <?php
echo esc_attr($elementClass);
?>
">
<h3 class="section-title"><?php
echo esc_html($title);
?>
</h3>
<?php
if ($products->have_posts()) {
?>
<ul class="products-style8 owl-carousel" <?php
echo _data_carousel($data_carousel);
?>
>
<?php
while ($products->have_posts()) {
$products->the_post();
?>
<li class="product autoHeight-item">
<div class="product-container">
<div class="product-thumb">
<?php
$product = new WC_Product(get_the_ID());
$attachment_ids = $product->get_gallery_attachment_ids();
$secondary_image = '';
if ($attachment_ids) {
$secondary_image = wp_get_attachment_image($attachment_ids[0], $size);
}
if (has_post_thumbnail()) {
?>
<a class="primary_image" href="<?php
the_permalink();
?>
"><?php
the_post_thumbnail($size);
?>
</a>
<?php
} else {
?>
<a class="primary_image" href="<?php
the_permalink();
?>
"><?php
echo wc_placeholder_img($size);
?>
</a>
<?php
}
if ($secondary_image != "") {
?>
<a class="secondary_image" href="<?php
the_permalink();
?>
"><?php
echo $secondary_image;