本文整理汇总了PHP中woocommerce_placeholder_img函数的典型用法代码示例。如果您正苦于以下问题:PHP woocommerce_placeholder_img函数的具体用法?PHP woocommerce_placeholder_img怎么用?PHP woocommerce_placeholder_img使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了woocommerce_placeholder_img函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
示例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');
}
示例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();
}
示例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>';
}
}
示例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
示例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');
}
示例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');
}
示例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');
}
示例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>
示例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);
示例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>
示例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();
}
示例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;
}