• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP woocommerce_placeholder_img函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中woocommerce_placeholder_img函数的典型用法代码示例。如果您正苦于以下问题:PHP woocommerce_placeholder_img函数的具体用法?PHP woocommerce_placeholder_img怎么用?PHP woocommerce_placeholder_img使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了woocommerce_placeholder_img函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: dp_get_imagea

 function dp_get_imagea($dpanimatehover)
 {
     global $product;
     if (has_post_thumbnail()) {
         $result = '<div class="he-wrap tpl1">';
         if ($dpanimatehover != 'disable') {
             $attachment_ids = $product->get_gallery_attachment_ids();
             if ($attachment_ids) {
                 $result .= '<div class="he-view">';
                 foreach ($attachment_ids as $attachment_id) {
                     $result .= '<div class="dp-img-wrapper">';
                     //img-hided
                     $result .= wp_get_attachment_image($attachment_id, 'display_product_thumbnail', 0, array('class' => "a0", 'data-animate' => $dpanimatehover));
                     $result .= '</div>';
                     break;
                 }
                 $result .= '</div>';
             }
         }
         $result .= '<div class="dp-img-wrapper">';
         $result .= get_the_post_thumbnail($product->post->ID, 'display_product_thumbnail');
         $result .= '</div>';
         $result .= '</div>';
     } else {
         $result = woocommerce_placeholder_img();
     }
     return $result;
 }
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:28,代码来源:functions.php


示例2: widget

    /**
     * widget function.
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     */
    function widget($args, $instance)
    {
        global $woocommerce;
        // Use default title as fallback
        $title = '' === $instance['title'] ? __('Random Products', 'woocommerce') : $instance['title'];
        $title = apply_filters('widget_title', $title, $instance, $this->id_base);
        // Setup product query
        $query_args = array('post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => $instance['number'], 'orderby' => 'rand', 'no_found_rows' => 1);
        $query_args['meta_query'] = array();
        if (!$instance['show_variations']) {
            $query_args['meta_query'][] = $woocommerce->query->visibility_meta_query();
            $query_args['post_parent'] = 0;
        }
        $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query();
        $query_args['meta_query'] = array_filter($query_args['meta_query']);
        $query = new WP_Query($query_args);
        if ($query->have_posts()) {
            echo $args['before_widget'];
            if ('' !== $title) {
                echo $args['before_title'], $title, $args['after_title'];
            }
            ?>

			<ul class="product_list_widget">
				<?php 
            while ($query->have_posts()) {
                $query->the_post();
                global $product;
                ?>
					<li>
						<a href="<?php 
                the_permalink();
                ?>
">
							<?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail('shop_thumbnail');
                } else {
                    echo woocommerce_placeholder_img('shop_thumbnail');
                }
                ?>
							<?php 
                the_title();
                ?>
						</a>
						<?php 
                echo $product->get_price_html();
                ?>
					</li>
				<?php 
            }
            ?>
			</ul>

			<?php 
            echo $args['after_widget'];
        }
        wp_reset_postdata();
    }
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:68,代码来源:class-wc-widget-random-products.php


示例3: widget

    function widget($args, $instance)
    {
        global $woocommerce;
        $cache = wp_cache_get('widget_best_sellers', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Best Sellers', 'mr_tailor') : $instance['title'], $instance, $this->id_base);
        if (!($number = (int) $instance['number'])) {
            $number = 10;
        } else {
            if ($number < 1) {
                $number = 1;
            } else {
                if ($number > 15) {
                    $number = 15;
                }
            }
        }
        $query_args = array('posts_per_page' => $number, 'post_status' => 'publish', 'post_type' => 'product', 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'no_found_rows' => 1);
        $query_args['meta_query'] = $woocommerce->query->get_meta_query();
        if (isset($instance['hide_free']) && 1 == $instance['hide_free']) {
            $query_args['meta_query'][] = array('key' => '_price', 'value' => 0, 'compare' => '>', 'type' => 'DECIMAL');
        }
        $r = new WP_Query($query_args);
        if ($r->have_posts()) {
            echo $before_widget;
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            echo '<ul class="product_list_widget">';
            while ($r->have_posts()) {
                $r->the_post();
                global $product;
                echo '<li>
					<a href="' . get_permalink() . '">
						' . (has_post_thumbnail() ? get_the_post_thumbnail($r->post->ID, 'shop_thumbnail') : woocommerce_placeholder_img('shop_thumbnail')) . ' ' . get_the_title() . '
					</a> ' . $product->get_price_html() . '
				</li>';
            }
            echo '</ul>';
            echo $after_widget;
        }
        wp_reset_postdata();
        $content = ob_get_clean();
        if (isset($args['widget_id'])) {
            $cache[$args['widget_id']] = $content;
        }
        echo $content;
        wp_cache_set('widget_best_sellers', $cache, 'widget');
    }
开发者ID:apeachdev,项目名称:eyeboutique,代码行数:57,代码来源:woocommerce-best-sellers.php


示例4: woocommerce_subcategory_thumbnail

function woocommerce_subcategory_thumbnail($category)
{
    // Figure
    $figure = \Drone\HTML::figure()->class('featured full-width');
    // Hyperlink
    $a = $figure->addNew('a')->attr(Everything::getImageAttrs('a', array('fancybox' => false)))->href(get_term_link($category->slug, 'product_cat'));
    // Thumbnail
    $thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true);
    $thumbnail_size = apply_filters('single_product_small_thumbnail_size', 'shop_catalog');
    if ($thumbnail_id) {
        $a->add(wp_get_attachment_image($thumbnail_id, $thumbnail_size));
    } elseif (woocommerce_placeholder_img_src()) {
        $a->add(woocommerce_placeholder_img($thumbnail_size));
    }
    echo $figure->html();
}
开发者ID:xpander54,项目名称:wp-drz,代码行数:16,代码来源:woocommerce.php


示例5: kt_woocommerce_template_loop_product_thumbnail

function kt_woocommerce_template_loop_product_thumbnail()
{
    global $virtue, $woocommerce_loop, $post;
    // Store column count for displaying the grid
    if (empty($woocommerce_loop['columns'])) {
        $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 4);
    }
    if ($woocommerce_loop['columns'] == '3') {
        $productimgwidth = 365;
    } else {
        $productimgwidth = 268;
    }
    if (isset($virtue['product_img_resize']) && $virtue['product_img_resize'] == 0) {
        $resizeimage = 0;
    } else {
        $resizeimage = 1;
    }
    if ($resizeimage == 1) {
        if (has_post_thumbnail()) {
            $product_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
            $product_image_url = $product_image[0];
            $image_product = aq_resize($product_image_url, $productimgwidth, $productimgwidth, true);
            if (empty($image_product)) {
                $image_product = $product_image_url;
            }
            ?>
 
                 <img width="<?php 
            echo $productimgwidth;
            ?>
" height="<?php 
            echo esc_attr($productimgwidth);
            ?>
" src="<?php 
            echo esc_attr($image_product);
            ?>
" class="attachment-shop_catalog wp-post-image" alt="<?php 
            the_title();
            ?>
">
                 <?php 
        } elseif (woocommerce_placeholder_img_src()) {
            echo woocommerce_placeholder_img('shop_catalog');
        }
    } else {
        echo '<div class="kad-woo-image-size">';
        echo woocommerce_template_loop_product_thumbnail();
        echo '</div>';
    }
}
开发者ID:neruub,项目名称:shop_sda,代码行数:50,代码来源:custom-woocommerce.php


示例6: woocommerce_get_product_thumbnail

			/**
			* Get the product thumbnail, or the placeholder if not set.
			*
			* @access public
			* @subpackage	Loop
			* @param string $size (default: 'shop_catalog')
			* @param int $placeholder_width (default: 0)
			* @param int $placeholder_height (default: 0)
			* @return string
			*
			* WM: OVERRIDE
			* Added permalink
			*/
			function woocommerce_get_product_thumbnail( $size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0  ) {
				global $post;

				if ( has_post_thumbnail() )
					return '<a href="' . get_permalink() . '">' . get_the_post_thumbnail( $post->ID, $size ) . '</a>';
				elseif ( woocommerce_placeholder_img_src() )
					return '<a href="' . get_permalink() . '">' . woocommerce_placeholder_img( $size ) . '</a>';
			} // woocommerce_get_product_thumbnail
开发者ID:unisexx,项目名称:drtooth,代码行数:21,代码来源:setup.php


示例7: widget

    /**
     * widget function.
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     */
    function widget($args, $instance)
    {
        global $woocommerce;
        $cache = wp_cache_get('widget_recent_products', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('New Products', 'woocommerce') : $instance['title'], $instance, $this->id_base);
        if (!($number = (int) $instance['number'])) {
            $number = 10;
        } else {
            if ($number < 1) {
                $number = 1;
            } else {
                if ($number > 15) {
                    $number = 15;
                }
            }
        }
        $show_variations = $instance['show_variations'] ? '1' : '0';
        $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product');
        $query_args['meta_query'] = array();
        if ($show_variations == '0') {
            $query_args['meta_query'][] = $woocommerce->query->visibility_meta_query();
            $query_args['parent'] = '0';
        }
        $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query();
        $query_args['meta_query'] = array_filter($query_args['meta_query']);
        $r = new WP_Query($query_args);
        if ($r->have_posts()) {
            echo $before_widget;
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            echo '<ul class="product_list_widget">';
            while ($r->have_posts()) {
                $r->the_post();
                global $product;
                echo '<li>
					<a href="' . get_permalink() . '">
						' . (has_post_thumbnail() ? get_the_post_thumbnail($r->post->ID, 'shop_thumbnail') : woocommerce_placeholder_img('shop_thumbnail')) . ' ' . get_the_title() . '
					</a> ' . $product->get_price_html() . '
				</li>';
            }
            echo '</ul>';
            echo $after_widget;
        }
        $content = ob_get_clean();
        if (isset($args['widget_id'])) {
            $cache[$args['widget_id']] = $content;
        }
        echo $content;
        wp_cache_set('widget_recent_products', $cache, 'widget');
    }
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:69,代码来源:class-wc-widget-recent-products.php


示例8: widget

    /**
     * widget function.
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     */
    function widget($args, $instance)
    {
        global $woocommerce;
        $cache = wp_cache_get('recently_viewed_products', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        $viewed_products = !empty($_COOKIE['woocommerce_recently_viewed']) ? (array) explode('|', $_COOKIE['woocommerce_recently_viewed']) : array();
        $viewed_products = array_filter(array_map('absint', $viewed_products));
        if (empty($viewed_products)) {
            return;
        }
        ob_start();
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recently viewed', 'woocommerce') : $instance['title'], $instance, $this->id_base);
        if (!($number = (int) $instance['number'])) {
            $number = 10;
        } else {
            if ($number < 1) {
                $number = 1;
            } else {
                if ($number > 15) {
                    $number = 15;
                }
            }
        }
        $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'rand');
        $query_args['meta_query'] = array();
        $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query();
        $r = new WP_Query($query_args);
        if ($r->have_posts()) {
            echo $before_widget;
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            echo '<ul class="product_list_widget">';
            while ($r->have_posts()) {
                $r->the_post();
                global $product;
                echo '<li>
					<a href="' . get_permalink() . '">
						' . (has_post_thumbnail() ? get_the_post_thumbnail($r->post->ID, 'shop_thumbnail') : woocommerce_placeholder_img('shop_thumbnail')) . ' ' . get_the_title() . '
					</a> ' . $product->get_price_html() . '
				</li>';
            }
            echo '</ul>';
            echo $after_widget;
        }
        $content = ob_get_clean();
        if (isset($args['widget_id'])) {
            $cache[$args['widget_id']] = $content;
        }
        echo $content;
        wp_cache_set('recently_viewed_products', $cache, 'widget');
    }
开发者ID:googlecode-mirror,项目名称:wpmu-demo,代码行数:68,代码来源:class-wc-widget-recently-viewed.php


示例9: widget

    /**
     * widget function.
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     */
    function widget($args, $instance)
    {
        global $wp_query, $woocommerce;
        $cache = wp_cache_get('widget_onsale', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('On Sale', 'woocommerce') : $instance['title'], $instance, $this->id_base);
        if (!($number = (int) $instance['number'])) {
            $number = 10;
        } else {
            if ($number < 1) {
                $number = 1;
            } else {
                if ($number > 15) {
                    $number = 15;
                }
            }
        }
        // Get products on sale
        $product_ids_on_sale = woocommerce_get_product_ids_on_sale();
        $product_ids_on_sale[] = 0;
        $meta_query = $woocommerce->query->get_meta_query();
        $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'orderby' => 'date', 'order' => 'ASC', 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale);
        $r = new WP_Query($query_args);
        if ($r->have_posts()) {
            echo $before_widget;
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            echo '<ul class="product_list_widget">';
            while ($r->have_posts()) {
                $r->the_post();
                global $product;
                echo '<li>
					<a href="' . get_permalink() . '">
						' . (has_post_thumbnail() ? get_the_post_thumbnail($r->post->ID, 'shop_thumbnail') : woocommerce_placeholder_img('shop_thumbnail')) . ' ' . get_the_title() . '
					</a> ' . $product->get_price_html() . '
				</li>';
            }
            echo '</ul>';
            echo $after_widget;
        }
        wp_reset_postdata();
        $content = ob_get_clean();
        if (isset($args['widget_id'])) {
            $cache[$args['widget_id']] = $content;
        }
        echo $content;
        wp_cache_set('widget_onsale', $cache, 'widget');
    }
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:66,代码来源:class-wc-widget-onsale.php


示例10: get_the_ID

                            /* Image */
                            $id = get_the_ID();
                            $src = wp_get_attachment_image_src(get_post_thumbnail_id($id));
                            $sale = dp_get_sale_flasha();
                            $pr = "";
                            $pr = $product->get_price_html();
                            /* featuerd */
                            $featured = '';
                            if ($product->is_featured()) {
                                $featured = '<div class="wt-notify">' . __('Featured', EXTRA_WOO_TABS_TEXTDOMAN) . '</div>';
                            }
                            echo '
								<div class="wt_col wt_col_1_of_5">
								<div class="wt-itemcnt">
									<div class="wt-thumbcnt ' . $img_eff . '">
										' . ($src[0] == '' ? woocommerce_placeholder_img() : '<img src="' . $src[0] . '" />') . '
										<div class="wt-overally fadein-eff">
											<a href="' . get_permalink() . '" class="wt-link-icon ' . $icon_eff . '" title="' . get_the_title() . '"></a>
											' . $featured . $sale . '
										</div><!-- wt-overally -->
									</div><!-- wt-thumbcnt -->
								
									
								</div><!--wt-itemcnt -->		
							</div>
							<div class="wt_col wt_col_3_of_5">
									<div class="wt-detailcnt">
										<h4 class="wt-title left-txt"><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h4>
										<p class="wt-text left-txt">' . excerpt(get_the_content(), 20) . '</p>
									</div>
							</div>
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:31,代码来源:template-brands-category.php


示例11: get_post_meta

 $thumbnail_id = get_post_meta(get_the_ID(), '_thumbnail_id', true);
 $src_featured = wp_get_attachment_image($thumbnail_id, $thumbnail_size, 0, $media_attr);
 $img1 = $img2 = $src_featured;
 if ($src_featured == '') {
     if (count($arr_img) > 0) {
         $img1 = wp_get_attachment_image($arr_img[0], $thumbnail_size, 0, $media_attr);
     } else {
         $img1 = "";
     }
     if (count($arr_img) > 1) {
         $img2 = wp_get_attachment_image($arr_img[1], $thumbnail_size, 0, $media_attr);
     } else {
         $img2 = $img1;
     }
     if ($img1 == '' && $img2 == '') {
         $img2 = $img1 = woocommerce_placeholder_img();
     }
 } else {
     if (count($arr_img) > 0) {
         $img2 = wp_get_attachment_image($arr_img[0], $thumbnail_size, 0, $media_attr);
     } else {
         $img2 = $img1;
     }
 }
 //woocommerce_placeholder_img();
 //	$attachments = get_posts( $args );
 //	 if ( $attachments ) {
 //attachment-$size
 //			$media_attr  = array('class'	=> " woo-zoomin");
 //			foreach ( $attachments as $attachment ) {
 //			   $image_gallery[]=wp_get_attachment_image( $attachment->ID, 'medium',0,$media_attr);
开发者ID:hikaram,项目名称:wee,代码行数:31,代码来源:content-product.php


示例12: widget

    /**
     * Widget function
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     * 
     */
    function widget($args, $instance)
    {
        global $woocommerce;
        $cache = wp_cache_get('recently_viewed_auctions', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        $viewed_products = !empty($_COOKIE['woocommerce_recently_viewed']) ? (array) explode('|', $_COOKIE['woocommerce_recently_viewed']) : array();
        $viewed_products = array_filter(array_map('absint', $viewed_products));
        if (empty($viewed_products)) {
            return;
        }
        ob_start();
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recently viewed auctions', 'wc_simple_auctions') : $instance['title'], $instance, $this->id_base);
        if (!($number = (int) $instance['number'])) {
            $number = 10;
        } else {
            if ($number < 1) {
                $number = 1;
            } else {
                if ($number > 15) {
                    $number = 15;
                }
            }
        }
        $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'rand');
        $query_args['meta_query'] = array();
        $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query();
        $query_args['meta_query'] = array_filter($query_args['meta_query']);
        $query_args['tax_query'] = array(array('taxonomy' => 'product_type', 'field' => 'slug', 'terms' => 'auction'));
        $query_args['auction_arhive'] = TRUE;
        $r = new WP_Query($query_args);
        if ($r->have_posts()) {
            $hide_time = empty($instance['hide_time']) ? 0 : 1;
            echo $before_widget;
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            echo '<ul class="product_list_widget">';
            while ($r->have_posts()) {
                $r->the_post();
                global $product;
                $timetext = __('Time left', 'wc_simple_auctions');
                $datatime = $product->get_seconds_remaining();
                if (!$product->is_started()) {
                    $timetext = __('Starting in', 'wc_simple_auctions');
                    $datatime = $product->get_seconds_to_auction();
                }
                if ($hide_time != 1 && !$product->is_closed()) {
                    $time = '<span class="time-left">' . apply_filters('time_text', $timetext, $product->id) . '</span>
					<div class="auction-time-countdown" data-time="' . $datatime . '" data-auctionid="' . $product->id . '" data-format="' . get_option('simple_auctions_countdown_format') . '"></div>';
                }
                if ($product->is_closed()) {
                    $time = '<span class="has-finished">' . apply_filters('time_text', __('Auction finished', 'wc_simple_auctions'), $product->id) . '</span>';
                }
                echo '<li>
					<a href="' . get_permalink() . '">
						' . (has_post_thumbnail() ? get_the_post_thumbnail($r->post->ID, 'shop_thumbnail') : woocommerce_placeholder_img('shop_thumbnail')) . ' ' . get_the_title() . '
					</a> ' . $product->get_price_html() . $time . '
				</li>';
            }
            echo '</ul>';
            echo $after_widget;
        }
        wp_reset_postdata();
        $content = ob_get_clean();
        if (isset($args['widget_id'])) {
            $cache[$args['widget_id']] = $content;
        }
        echo $content;
        wp_cache_set('recently_viewed_auctions', $cache, 'widget');
    }
开发者ID:Omuze,项目名称:barakat,代码行数:87,代码来源:class-woocommerce-simple-auctions-widget-recently-auctions.php


示例13: the_title

	            	 <img width="<?php 
        echo $productimgwidth;
        ?>
" height="<?php 
        echo $productimgwidth;
        ?>
" src="<?php 
        echo $image_product;
        ?>
" class="attachment-shop_catalog wp-post-image" alt="<?php 
        the_title();
        ?>
">
	            	 <?php 
    } elseif (woocommerce_placeholder_img_src()) {
        echo woocommerce_placeholder_img('shop_catalog');
    }
} else {
    echo woocommerce_template_loop_product_thumbnail();
}
?>
             </a>
		<div class="product_details">
			<a href="<?php 
the_permalink();
?>
" class="product_item_link">
			<h5><?php 
the_title();
?>
</h5>
开发者ID:pradeep-web,项目名称:brandt,代码行数:31,代码来源:content-product.php


示例14: widget

    /**
     * Widget function
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     * 
     */
    function widget($args, $instance)
    {
        global $woocommerce;
        // Use default title as fallback
        $title = '' === $instance['title'] ? __('Random auctions', 'wc_simple_auctions') : $instance['title'];
        $title = apply_filters('widget_title', $title, $instance, $this->id_base);
        // Setup product query
        $query_args = array('post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => $instance['number'], 'orderby' => 'rand', 'no_found_rows' => 1);
        $query_args['meta_query'] = array();
        $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query();
        $query_args['meta_query'] = array_filter($query_args['meta_query']);
        $query_args['tax_query'] = array(array('taxonomy' => 'product_type', 'field' => 'slug', 'terms' => 'auction'));
        $query_args['auction_arhive'] = TRUE;
        $query = new WP_Query($query_args);
        if ($query->have_posts()) {
            $hide_time = empty($instance['hide_time']) ? 0 : 1;
            echo $args['before_widget'];
            if ('' !== $title) {
                echo $args['before_title'], $title, $args['after_title'];
            }
            ?>

			<ul class="product_list_widget">
				<?php 
            while ($query->have_posts()) {
                $query->the_post();
                global $product;
                $time = '';
                $timetext = __('Time left', 'wc_simple_auctions');
                $datatime = $product->get_seconds_remaining();
                if (!$product->is_started()) {
                    $timetext = __('Starting in', 'wc_simple_auctions');
                    $datatime = $product->get_seconds_to_auction();
                }
                if ($hide_time != 1 && !$product->is_closed()) {
                    $time = '<span class="time-left">' . apply_filters('time_text', $timetext, $product->id) . '</span>
					<div class="auction-time-countdown" data-time="' . $datatime . '" data-auctionid="' . $product->id . '" data-format="' . get_option('simple_auctions_countdown_format') . '"></div>';
                }
                if ($product->is_closed()) {
                    $time = '<span class="has-finished">' . apply_filters('time_text', __('Auction finished', 'wc_simple_auctions'), $product->id) . '</span>';
                }
                ?>
					<li>
						<a href="<?php 
                the_permalink();
                ?>
">
							<?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail('shop_thumbnail');
                } else {
                    echo woocommerce_placeholder_img('shop_thumbnail');
                }
                ?>
							<?php 
                the_title();
                ?>
						</a>
						<?php 
                echo $product->get_price_html();
                ?>
						<?php 
                echo $time;
                ?>
					</li>
				<?php 
            }
            ?>
			</ul>

			<?php 
            echo $args['after_widget'];
        }
        wp_reset_postdata();
    }
开发者ID:Omuze,项目名称:barakat,代码行数:85,代码来源:class-woocommerce-simple-auctions-widget-random-auctions.php


示例15: get_image

 /**
  * Returns the main product image
  *
  * @access public
  * @param string $size (default: 'shop_thumbnail')
  * @return string
  */
 function get_image($size = 'shop_thumbnail', $attr = array())
 {
     global $woocommerce;
     $image = '';
     if (has_post_thumbnail($this->id)) {
         $image = get_the_post_thumbnail($this->id, $size, $attr);
     } elseif (($parent_id = wp_get_post_parent_id($this->id)) && has_post_thumbnail($parent_id)) {
         $image = get_the_post_thumbnail($parent_id, $size, $attr);
     } else {
         $image = woocommerce_placeholder_img($size);
     }
     return $image;
 }
开发者ID:googlecode-mirror,项目名称:wpmu-demo,代码行数:20,代码来源:abstract-wc-product.php


示例16: kt_woocommerce_template_loop_product_thumbnail

function kt_woocommerce_template_loop_product_thumbnail()
{
    global $virtue, $woocommerce_loop, $post;
    // Store column count for displaying the grid
    if (empty($woocommerce_loop['columns'])) {
        $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 4);
    }
    if ($woocommerce_loop['columns'] == '3') {
        $productimgwidth = 365;
    } else {
        $productimgwidth = 268;
    }
    if (isset($virtue['product_img_resize']) && $virtue['product_img_resize'] == 0) {
        $resizeimage = 0;
    } else {
        $resizeimage = 1;
    }
    if ($resizeimage == 1) {
        if (has_post_thumbnail()) {
            $image_id = get_post_thumbnail_id($post->ID);
            $product_image_array = wp_get_attachment_image_src($image_id, 'full');
            $product_image_url = $product_image_array[0];
            // Make sure there is a copped image to output
            $image_product = aq_resize($product_image_url, $productimgwidth, $productimgwidth, true);
            if (empty($image_product)) {
                $image_product = $product_image_url;
            }
            // Get srcset
            $image_meta = get_post_meta($image_id, '_wp_attachment_metadata', true);
            $img_srcset = wp_calculate_image_srcset(array($productimgwidth, $productimgheight), $product_image_url, $image_meta, $image_id);
            // Get alt and fall back to title if no alt
            $alt_text = get_post_meta($image_id, '_wp_attachment_image_alt', true);
            if (empty($alt_text)) {
                $alt_text = get_the_title();
            }
            ?>
 
                <img width="<?php 
            echo esc_attr($productimgwidth);
            ?>
" height="<?php 
            echo esc_attr($productimgheight);
            ?>
" 
                src="<?php 
            echo esc_url($image_product);
            ?>
"
                <?php 
            if (!empty($img_srcset)) {
                ?>
                srcset="<?php 
                echo esc_attr($img_srcset);
                ?>
"
                sizes="(max-width: <?php 
                echo esc_attr($productimgwidth);
                ?>
px) 100vw, <?php 
                echo esc_attr($productimgwidth);
                ?>
px" 
                <?php 
            }
            ?>
                class="attachment-shop_catalog size-<?php 
            echo esc_attr($productimgwidth . 'x' . $productimgheight);
            ?>
 wp-post-image" 
                alt="<?php 
            echo esc_attr($alt_text);
            ?>
">
        <?php 
        } elseif (woocommerce_placeholder_img_src()) {
            echo woocommerce_placeholder_img('shop_catalog');
        }
    } else {
        echo '<div class="kad-woo-image-size">';
        echo woocommerce_template_loop_product_thumbnail();
        echo '</div>';
    }
}
开发者ID:louiseolofsson,项目名称:wordpress_examensarbete,代码行数:83,代码来源:custom-woocommerce.php


示例17: get_term_link

        ?>
				<li class="col-1-<?php 
        echo $columns;
        ?>
">
					<figure class="full-width">
						<a href="<?php 
        echo get_term_link($brand->slug, 'product_brand');
        ?>
" <?php 
        Everything::imageAttrs('a', array('border' => false, 'hover' => ''));
        ?>
>
							<?php 
        if ($thumbnail_id = get_woocommerce_term_meta($brand->term_id, 'thumbnail_id', true)) {
            echo wp_get_attachment_image($thumbnail_id, $size);
        } else {
            echo woocommerce_placeholder_img();
        }
        ?>
						</a>
					</figure>
				</li>
			<?php 
    }
    ?>
		</ul>
	</div>

<?php 
}
开发者ID:xpander54,项目名称:wp-drz,代码行数:31,代码来源:brand-thumbnails.php


示例18: woocommerce_get_product_thumbnail

 /**
  * Get the product thumbnail, or the placeholder if not set.
  *
  * @access public
  * @subpackage	Loop
  * @param string $size (default: 'shop_catalog')
  * @param int $placeholder_width (default: 0)
  * @param int $placeholder_height (default: 0)
  * @return string
  */
 function woocommerce_get_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0)
 {
     global $post;
     if (has_post_thumbnail()) {
         return get_the_post_thumbnail($post->ID, $size);
     } elseif (woocommerce_placeholder_img_src()) {
         return woocommerce_placeholder_img($size);
     }
 }
开发者ID:GarryVeles,项目名称:Artibaltika,代码行数:19,代码来源:woocommerce-template.php


示例19: esc_url

		<?php 
if ($_product) {
    ?>
			<a href="<?php 
    echo esc_url(get_permalink($_product->id));
    ?>
">
				<?php 
    echo $_product->get_image('shop_thumbnail', array('title' => ''));
    ?>
			</a>
		<?php 
} else {
    ?>
			<?php 
    echo woocommerce_placeholder_img('shop_thumbnail');
    ?>
		<?php 
}
?>
	</td>

	<td class="name" width="65%">

		<?php 
if ($_product) {
    ?>
			<a target="_blank" href="<?php 
    echo esc_url(get_permalink($_product->id));
    ?>
">
开发者ID:uwitec,项目名称:findgreatmaster,代码行数:31,代码来源:order-item-html.php


示例20: the_permalink

?>

<li>
	<a href="<?php 
the_permalink();
?>
">
		<div style="background-image: url(<?php 
echo $src[0];
?>
);" class="image">
			<?php 
if (has_post_thumbnail()) {
    the_post_thumbnail('blog-two-column');
} else {
    echo woocommerce_placeholder_img('blog-two-column');
}
?>
		</div>
	</a>
	<h4><a href="<?php 
echo get_permalink();
?>
"><?php 
the_title();
?>
</a></h4>
	<div class="widget-rating"><?php 
echo woocommerce_template_loop_rating();
?>
</div>
开发者ID:realbig,项目名称:TH_MONEYBALL,代码行数:31,代码来源:content-widget-product.php



注:本文中的woocommerce_placeholder_img函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP woocommerce_placeholder_img_src函数代码示例发布时间:2022-05-23
下一篇:
PHP woocommerce_page_title函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap