Product functions
This commit is contained in:
parent
4ce301a080
commit
3408965b8a
|
@ -1352,7 +1352,7 @@ class WC_Product {
|
|||
} 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 );
|
||||
$image = wc_placeholder_img( $size );
|
||||
}
|
||||
|
||||
return $image;
|
||||
|
|
|
@ -189,7 +189,7 @@ class WC_Admin_Assets {
|
|||
'post_id' => isset( $post->ID ) ? $post->ID : '',
|
||||
'plugin_url' => $woocommerce->plugin_url(),
|
||||
'ajax_url' => admin_url('admin-ajax.php'),
|
||||
'woocommerce_placeholder_img_src' => woocommerce_placeholder_img_src(),
|
||||
'woocommerce_placeholder_img_src' => wc_placeholder_img_src(),
|
||||
'add_variation_nonce' => wp_create_nonce("add-variation"),
|
||||
'link_variation_nonce' => wp_create_nonce("link-variations"),
|
||||
'delete_variation_nonce' => wp_create_nonce("delete-variation"),
|
||||
|
|
|
@ -97,7 +97,7 @@ class WC_Admin_Taxonomies {
|
|||
</div>
|
||||
<div class="form-field">
|
||||
<label><?php _e( 'Thumbnail', 'woocommerce' ); ?></label>
|
||||
<div id="product_cat_thumbnail" style="float:left;margin-right:10px;"><img src="<?php echo woocommerce_placeholder_img_src(); ?>" width="60px" height="60px" /></div>
|
||||
<div id="product_cat_thumbnail" style="float:left;margin-right:10px;"><img src="<?php echo wc_placeholder_img_src(); ?>" width="60px" height="60px" /></div>
|
||||
<div style="line-height:60px;">
|
||||
<input type="hidden" id="product_cat_thumbnail_id" name="product_cat_thumbnail_id" />
|
||||
<button type="submit" class="upload_image_button button"><?php _e( 'Upload/Add image', 'woocommerce' ); ?></button>
|
||||
|
@ -145,7 +145,7 @@ class WC_Admin_Taxonomies {
|
|||
});
|
||||
|
||||
jQuery(document).on( 'click', '.remove_image_button', function( event ){
|
||||
jQuery('#product_cat_thumbnail img').attr('src', '<?php echo woocommerce_placeholder_img_src(); ?>');
|
||||
jQuery('#product_cat_thumbnail img').attr('src', '<?php echo wc_placeholder_img_src(); ?>');
|
||||
jQuery('#product_cat_thumbnail_id').val('');
|
||||
jQuery('.remove_image_button').hide();
|
||||
return false;
|
||||
|
@ -173,7 +173,7 @@ class WC_Admin_Taxonomies {
|
|||
if ( $thumbnail_id )
|
||||
$image = wp_get_attachment_thumb_url( $thumbnail_id );
|
||||
else
|
||||
$image = woocommerce_placeholder_img_src();
|
||||
$image = wc_placeholder_img_src();
|
||||
?>
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label><?php _e( 'Display type', 'woocommerce' ); ?></label></th>
|
||||
|
@ -233,7 +233,7 @@ class WC_Admin_Taxonomies {
|
|||
});
|
||||
|
||||
jQuery(document).on( 'click', '.remove_image_button', function( event ){
|
||||
jQuery('#product_cat_thumbnail img').attr('src', '<?php echo woocommerce_placeholder_img_src(); ?>');
|
||||
jQuery('#product_cat_thumbnail img').attr('src', '<?php echo wc_placeholder_img_src(); ?>');
|
||||
jQuery('#product_cat_thumbnail_id').val('');
|
||||
jQuery('.remove_image_button').hide();
|
||||
return false;
|
||||
|
@ -322,7 +322,7 @@ class WC_Admin_Taxonomies {
|
|||
if ($thumbnail_id)
|
||||
$image = wp_get_attachment_thumb_url( $thumbnail_id );
|
||||
else
|
||||
$image = woocommerce_placeholder_img_src();
|
||||
$image = wc_placeholder_img_src();
|
||||
|
||||
$columns .= '<img src="' . esc_url( $image ) . '" alt="Thumbnail" class="wp-post-image" height="48" width="48" />';
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
|
||||
?>"><?php echo $_product->get_image( 'shop_thumbnail', array( 'title' => '' ) ); ?></a>
|
||||
<?php else : ?>
|
||||
<?php echo woocommerce_placeholder_img( 'shop_thumbnail' ); ?>
|
||||
<?php echo wc_placeholder_img( 'shop_thumbnail' ); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="name">
|
||||
|
@ -36,7 +36,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
|
||||
<?php
|
||||
if ( $_product && isset( $_product->variation_data ) )
|
||||
echo '<br/>' . woocommerce_get_formatted_variation( $_product->variation_data, true );
|
||||
echo '<br/>' . wc_get_formatted_variation( $_product->variation_data, true );
|
||||
?>
|
||||
|
||||
<div class="view">
|
||||
|
|
|
@ -203,7 +203,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="upload_image">
|
||||
<a href="#" class="upload_image_button <?php if ( $image_id > 0 ) echo 'remove'; ?>" rel="<?php echo esc_attr( $variation_id ); ?>"><img src="<?php if ( ! empty( $image ) ) echo esc_attr( $image ); else echo esc_attr( woocommerce_placeholder_img_src() ); ?>" /><input type="hidden" name="upload_image_id[<?php echo $loop; ?>]" class="upload_image_id" value="<?php echo esc_attr( $image_id ); ?>" /><span class="overlay"></span></a>
|
||||
<a href="#" class="upload_image_button <?php if ( $image_id > 0 ) echo 'remove'; ?>" rel="<?php echo esc_attr( $variation_id ); ?>"><img src="<?php if ( ! empty( $image ) ) echo esc_attr( $image ); else echo esc_attr( wc_placeholder_img_src() ); ?>" /><input type="hidden" name="upload_image_id[<?php echo $loop; ?>]" class="upload_image_id" value="<?php echo esc_attr( $image_id ); ?>" /><span class="overlay"></span></a>
|
||||
</td>
|
||||
<td class="options">
|
||||
<label><input type="checkbox" class="checkbox" name="variable_enabled[<?php echo $loop; ?>]" <?php checked( $variation_post_status, 'publish' ); ?> /> <?php _e( 'Enabled', 'woocommerce' ); ?></label>
|
||||
|
|
|
@ -454,7 +454,7 @@ class WC_API_Products extends WC_API_Resource {
|
|||
'id' => 0,
|
||||
'created_at' => $this->server->format_datetime( time() ), // default to now
|
||||
'updated_at' => $this->server->format_datetime( time() ),
|
||||
'src' => woocommerce_placeholder_img_src(),
|
||||
'src' => wc_placeholder_img_src(),
|
||||
'title' => __( 'Placeholder', 'woocommerce' ),
|
||||
'alt' => __( 'Placeholder', 'woocommerce' ),
|
||||
'position' => 0,
|
||||
|
|
|
@ -373,7 +373,7 @@ class WC_Coupon {
|
|||
// Exclude Sale Items
|
||||
if ( $this->exclude_sale_items == 'yes' ) {
|
||||
$valid_for_cart = true;
|
||||
$product_ids_on_sale = woocommerce_get_product_ids_on_sale();
|
||||
$product_ids_on_sale = wc_get_product_ids_on_sale();
|
||||
if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
|
||||
foreach( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||
if ( in_array( $cart_item['product_id'], $product_ids_on_sale, true ) || in_array( $cart_item['variation_id'], $product_ids_on_sale, true ) || in_array( $cart_item['data']->get_parent(), $product_ids_on_sale, true ) ) {
|
||||
|
@ -474,7 +474,7 @@ class WC_Coupon {
|
|||
|
||||
// Sale Items excluded from discount
|
||||
if ( $this->exclude_sale_items == 'yes' ) {
|
||||
$product_ids_on_sale = woocommerce_get_product_ids_on_sale();
|
||||
$product_ids_on_sale = wc_get_product_ids_on_sale();
|
||||
|
||||
if ( in_array( $product->id, $product_ids_on_sale, true ) || ( isset( $product->variation_id ) && in_array( $product->variation_id, $product_ids_on_sale, true ) ) || in_array( $product->get_parent(), $product_ids_on_sale, true ) )
|
||||
$valid = false;
|
||||
|
|
|
@ -340,7 +340,7 @@ class WC_Product_Variation extends WC_Product {
|
|||
} 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 );
|
||||
$image = wc_placeholder_img( $size );
|
||||
}
|
||||
|
||||
return $image;
|
||||
|
|
|
@ -556,7 +556,7 @@ class WC_Shortcodes {
|
|||
), $atts ) );
|
||||
|
||||
// Get products on sale
|
||||
$product_ids_on_sale = woocommerce_get_product_ids_on_sale();
|
||||
$product_ids_on_sale = wc_get_product_ids_on_sale();
|
||||
|
||||
$meta_query = array();
|
||||
$meta_query[] = WC()->query->visibility_meta_query();
|
||||
|
|
|
@ -291,7 +291,7 @@ function wc_placeholder_img_src() {
|
|||
function wc_placeholder_img( $size = 'shop_thumbnail' ) {
|
||||
$dimensions = wc_get_image_size( $size );
|
||||
|
||||
return apply_filters('woocommerce_placeholder_img', '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="' . esc_attr( $dimensions['width'] ) . '" height="' . esc_attr( $dimensions['height'] ) . '" />' );
|
||||
return apply_filters('woocommerce_placeholder_img', '<img src="' . wc_placeholder_img_src() . '" alt="Placeholder" width="' . esc_attr( $dimensions['width'] ) . '" height="' . esc_attr( $dimensions['height'] ) . '" />' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -443,7 +443,7 @@ function wc_scheduled_sales() {
|
|||
add_action( 'woocommerce_scheduled_sales', 'wc_scheduled_sales' );
|
||||
|
||||
/**
|
||||
* woocommerce_get_attachment_image_attributes function.
|
||||
* wc_get_attachment_image_attributes function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $attr
|
||||
|
@ -451,7 +451,7 @@ add_action( 'woocommerce_scheduled_sales', 'wc_scheduled_sales' );
|
|||
*/
|
||||
function wc_get_attachment_image_attributes( $attr ) {
|
||||
if ( strstr( $attr['src'], 'woocommerce_uploads/' ) )
|
||||
$attr['src'] = woocommerce_placeholder_img_src();
|
||||
$attr['src'] = wc_placeholder_img_src();
|
||||
|
||||
return $attr;
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ add_filter( 'wp_get_attachment_image_attributes', 'wc_get_attachment_image_attri
|
|||
|
||||
|
||||
/**
|
||||
* woocommerce_prepare_attachment_for_js function.
|
||||
* wc_prepare_attachment_for_js function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $response
|
||||
|
@ -468,10 +468,10 @@ add_filter( 'wp_get_attachment_image_attributes', 'wc_get_attachment_image_attri
|
|||
function wc_prepare_attachment_for_js( $response ) {
|
||||
|
||||
if ( isset( $response['url'] ) && strstr( $response['url'], 'woocommerce_uploads/' ) ) {
|
||||
$response['full']['url'] = woocommerce_placeholder_img_src();
|
||||
$response['full']['url'] = wc_placeholder_img_src();
|
||||
if ( isset( $response['sizes'] ) ) {
|
||||
foreach( $response['sizes'] as $size => $value ) {
|
||||
$response['sizes'][ $size ]['url'] = woocommerce_placeholder_img_src();
|
||||
$response['sizes'][ $size ]['url'] = wc_placeholder_img_src();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -566,8 +566,8 @@ if ( ! function_exists( 'wc_get_product_thumbnail' ) ) {
|
|||
|
||||
if ( has_post_thumbnail() )
|
||||
return get_the_post_thumbnail( $post->ID, $size );
|
||||
elseif ( woocommerce_placeholder_img_src() )
|
||||
return woocommerce_placeholder_img( $size );
|
||||
elseif ( wc_placeholder_img_src() )
|
||||
return wc_placeholder_img( $size );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1518,7 +1518,7 @@ if ( ! function_exists( 'wc_subcategory_thumbnail' ) ) {
|
|||
$image = wp_get_attachment_image_src( $thumbnail_id, $small_thumbnail_size );
|
||||
$image = $image[0];
|
||||
} else {
|
||||
$image = woocommerce_placeholder_img_src();
|
||||
$image = wc_placeholder_img_src();
|
||||
}
|
||||
|
||||
if ( $image )
|
||||
|
|
|
@ -139,7 +139,7 @@ class WC_Widget_Products extends WC_Widget {
|
|||
);
|
||||
break;
|
||||
case 'onsale' :
|
||||
$product_ids_on_sale = woocommerce_get_product_ids_on_sale();
|
||||
$product_ids_on_sale = wc_get_product_ids_on_sale();
|
||||
$product_ids_on_sale[] = 0;
|
||||
$query_args['post__in'] = $product_ids_on_sale;
|
||||
break;
|
||||
|
|
|
@ -34,7 +34,7 @@ global $post, $woocommerce, $product;
|
|||
|
||||
} else {
|
||||
|
||||
echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<img src="%s" alt="Placeholder" />', woocommerce_placeholder_img_src() ), $post->ID );
|
||||
echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<img src="%s" alt="Placeholder" />', wc_placeholder_img_src() ), $post->ID );
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue