' . wp_kses_post($description) . '';
}
}
}
}
if ( ! function_exists( 'woocommerce_product_archive_description' ) ) {
/**
* Show a shop page description on product archives.
*
* @subpackage Archives
*/
function woocommerce_product_archive_description() {
if ( is_post_type_archive( 'product' ) && 0 === absint( get_query_var( 'paged' ) ) ) {
$shop_page = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {
$description = wc_format_content( $shop_page->post_content );
if ( $description ) {
echo '
' . wp_kses_post($description) . '
';
}
}
}
}
}
/*
* Show Product Additional Information
* Gallery Mode
*/
if (!function_exists('allstore_section_gallery_props')) {
function allstore_section_gallery_props($attributes) {
global $product;
if (!empty($attributes)) :
?>
-
-
get_id(), $attribute['name'], array( 'fields' => 'names' ) );
echo wp_kses_post(apply_filters( 'woocommerce_attribute', wptexturize( implode( ', ', $values ) ), $attribute, $values ));
} else {
// Convert pipes to commas and display values
$values = array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
echo wp_kses_post(apply_filters( 'woocommerce_attribute', wptexturize( implode( ', ', $values ) ), $attribute, $values ));
}
?>
-
get_id(), $attribute['name'], array( 'fields' => 'names' ) );
echo wp_kses_post( apply_filters( 'woocommerce_attribute', wptexturize( implode( ', ', $values ) ), $attribute, $values ) );
} else {
// Convert pipes to commas and display values
$values = array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
echo wp_kses_post( apply_filters( 'woocommerce_attribute', wptexturize( implode( ', ', $values ) ), $attribute, $values ) );
}
?>
user_email;
} elseif ( is_object($id_or_email) ) {
// No avatar for pingbacks or trackbacks
$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) )
return false;
if ( !empty($id_or_email->user_id) ) {
$id = (int) $id_or_email->user_id;
$user = get_userdata($id);
if ( $user)
$email = $user->user_email;
} elseif ( !empty($id_or_email->comment_author_email) ) {
$email = $id_or_email->comment_author_email;
}
} else {
$email = $id_or_email;
}
$hashkey = md5(strtolower(trim($email)));
$uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404';
$data = wp_cache_get($hashkey);
if (false === $data) {
$response = wp_remote_head($uri);
if( is_wp_error($response) ) {
$data = 'not200';
} else {
$data = $response['response']['code'];
}
wp_cache_set($hashkey, $data, $group = '', $expire = 60*5);
}
if ($data == '200'){
return true;
} else {
return false;
}
}
}
/*
* Walker for Header categories list
*/
class Walker_Allstore_Allcatalog extends Walker_Category {
/**
* Starts the list before the elements are added.
*
* @since 2.1.0
* @access public
*
* @see Walker::start_lvl()
*
* @param string $output Used to append additional content. Passed by reference.
* @param int $depth Optional. Depth of category. Used for tab indentation. Default 0.
* @param array $args Optional. An array of arguments. Will only append content if style argument
* value is 'list'. See wp_list_categories(). Default empty array.
*/
public function start_lvl( &$output, $depth = 0, $args = array() ) {
if ( 'list' != $args['style'] )
return;
$indent = str_repeat("\t", $depth);
$output .= "$indent\n";
}
/**
* Starts the element output.
*
* @since 2.1.0
* @access public
*
* @see Walker::start_el()
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $category Category data object.
* @param int $depth Optional. Depth of category in reference to parents. Default 0.
* @param array $args Optional. An array of arguments. See wp_list_categories(). Default empty array.
* @param int $id Optional. ID of the current category. Default 0.
*/
public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
/** This filter is documented in wp-includes/category-template.php */
$cat_name = apply_filters(
'list_cats',
esc_attr( $category->name ),
$category
);
// Don't generate an element if the category name is empty.
if ( ! $cat_name ) {
return;
}
$link = 'description ) ) {
/**
* Filters the category description for display.
*
* @since 1.2.0
*
* @param string $description Category description.
* @param object $category Category object.
*/
$link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
}
$link .= '>';
$link .= $cat_name;
if ( ! empty( $args['show_count'] ) ) {
$link .= ' (' . number_format_i18n( $category->count ) . ')';
}
$link .= '';
if ( ! empty( $args['feed_image'] ) || ! empty( $args['feed'] ) ) {
$link .= ' ';
if ( empty( $args['feed_image'] ) ) {
$link .= '(';
}
$link .= '';
}
$link .= '';
if ( empty( $args['feed_image'] ) ) {
$link .= ')';
}
}
if ( 'list' == $args['style'] ) {
$output .= "\t- term_id,
);
/*if ( ! empty( $args['current_category'] ) ) {
// 'current_category' can be an array, so we use `get_terms()`.
$_current_terms = get_terms( $category->taxonomy, array(
'include' => $args['current_category'],
'hide_empty' => false,
) );
foreach ( $_current_terms as $_current_term ) {
if ( $category->term_id == $_current_term->term_id ) {
$css_classes[] = 'current-cat';
} elseif ( $category->term_id == $_current_term->parent ) {
$css_classes[] = 'current-cat-parent';
}
while ( $_current_term->parent ) {
if ( $category->term_id == $_current_term->parent ) {
$css_classes[] = 'current-cat-ancestor';
break;
}
$_current_term = get_term( $_current_term->parent, $category->taxonomy );
}
}
}*/
/**
* Filters the list of CSS classes to include with each category in the list.
*
* @since 4.2.0
*
* @see wp_list_categories()
*
* @param array $css_classes An array of CSS classes to be applied to each list item.
* @param object $category Category data object.
* @param int $depth Depth of page, used for padding.
* @param array $args An array of wp_list_categories() arguments.
*/
$css_classes = implode( ' ', apply_filters( 'category_css_class', $css_classes, $category, $depth, $args ) );
$output .= ' class="' . $css_classes . '"';
$output .= ">$link\n";
} elseif ( isset( $args['separator'] ) ) {
$output .= "\t$link" . $args['separator'] . "\n";
} else {
$output .= "\t$link
\n";
}
}
}
/*
* Walker for Header categories list
*/
class Walker_Allstore_Categories_Widget extends Walker_Category {
/**
* Starts the element output.
*
* @since 2.1.0
* @access public
*
* @see Walker::start_el()
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $category Category data object.
* @param int $depth Optional. Depth of category in reference to parents. Default 0.
* @param array $args Optional. An array of arguments. See wp_list_categories(). Default empty array.
* @param int $id Optional. ID of the current category. Default 0.
*/
public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
/** This filter is documented in wp-includes/category-template.php */
$cat_name = apply_filters(
'list_cats',
esc_attr( $category->name ),
$category
);
// Don't generate an element if the category name is empty.
if ( ! $cat_name ) {
return;
}
$link = 'description ) ) {
/**
* Filters the category description for display.
*
* @since 1.2.0
*
* @param string $description Category description.
* @param object $category Category object.
*/
$link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
}
$link .= '>';
$link .= ''.$cat_name;
if ( ! empty( $args['show_count'] ) ) {
$link .= ' (' . number_format_i18n( $category->count ) . ')';
}
$link .= '';
if ($this->has_children) {
$link .= '';
}
$link .= '';
if ( ! empty( $args['feed_image'] ) || ! empty( $args['feed'] ) ) {
$link .= ' ';
if ( empty( $args['feed_image'] ) ) {
$link .= '(';
}
$link .= '';
}
$link .= '';
if ( empty( $args['feed_image'] ) ) {
$link .= ')';
}
}
if ( 'list' == $args['style'] ) {
$output .= "\t - term_id,
);
if ($this->has_children) {
$css_classes[] = 'has_child';
}
/*if ( ! empty( $args['current_category'] ) ) {
// 'current_category' can be an array, so we use `get_terms()`.
$_current_terms = get_terms( $category->taxonomy, array(
'include' => $args['current_category'],
'hide_empty' => false,
) );
foreach ( $_current_terms as $_current_term ) {
if ( $category->term_id == $_current_term->term_id ) {
$css_classes[] = 'current-cat';
} elseif ( $category->term_id == $_current_term->parent ) {
$css_classes[] = 'current-cat-parent';
}
while ( $_current_term->parent ) {
if ( $category->term_id == $_current_term->parent ) {
$css_classes[] = 'current-cat-ancestor';
break;
}
$_current_term = get_term( $_current_term->parent, $category->taxonomy );
}
}
}*/
/**
* Filters the list of CSS classes to include with each category in the list.
*
* @since 4.2.0
*
* @see wp_list_categories()
*
* @param array $css_classes An array of CSS classes to be applied to each list item.
* @param object $category Category data object.
* @param int $depth Depth of page, used for padding.
* @param array $args An array of wp_list_categories() arguments.
*/
$css_classes = implode( ' ', apply_filters( 'category_css_class', $css_classes, $category, $depth, $args ) );
$output .= ' class="' . $css_classes . '"';
$output .= ">$link\n";
} elseif ( isset( $args['separator'] ) ) {
$output .= "\t$link" . $args['separator'] . "\n";
} else {
$output .= "\t$link
\n";
}
}
}
/*
Woocommerce Add to cart Ajax for variable products
http://www.rcreators.com/woocommerce-ajax-add-to-cart-variable-products
Ajax based add to cart for varialbe products in woocommerce.
Rishi Mehta - Rcreators Websolutions
http://rcreators.com
*/
add_action( 'wp_ajax_woocommerce_add_to_cart_variable_rc', 'allstore_add_to_cart_variable_rc_callback' );
add_action( 'wp_ajax_nopriv_woocommerce_add_to_cart_variable_rc', 'allstore_add_to_cart_variable_rc_callback' );
function allstore_add_to_cart_variable_rc_callback() {
ob_start();
if (isset($_POST['product_id'])) {
$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( wp_strip_all_tags( wp_unslash( $_POST['product_id'] ) ) ) );
} else {
$product_id = '';
}
$quantity = empty( $_POST['quantity'] ) ? 1 : apply_filters( 'woocommerce_stock_amount', wp_strip_all_tags( wp_unslash( $_POST['quantity'] ) ) );
if (isset($_POST['variation_id'])) {
$variation_id = wp_strip_all_tags( wp_unslash( $_POST['variation_id'] ) );
} else {
$variation_id = '';
}
if (isset($_POST['variation'])) {
$variation = wp_strip_all_tags(sanitize_text_field(wp_unslash($_POST['variation'])));
} else {
$variation = '';
}
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity );
if ( $passed_validation && WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation ) ) {
do_action( 'woocommerce_ajax_added_to_cart', $product_id );
if ( get_option( 'woocommerce_cart_redirect_after_add' ) == 'yes' ) {
wc_add_to_cart_message( $product_id );
}
// Return fragments
WC_AJAX::get_refreshed_fragments();
} else {
$this->json_headers();
// If there was an error adding to the cart, redirect to the product page to show any errors
$data = array(
'error' => true,
'product_url' => apply_filters( 'woocommerce_cart_redirect_after_error', get_permalink( $product_id ), $product_id )
);
echo json_encode( $data );
}
die();
}
/*
* Product Badge HTML
*/
function allstore_product_badge($product_id, $class='') {
if (!taxonomy_exists('product_badges')) {
return true;
}
$product_badges = get_the_terms( $product_id, 'product_badges' );
if (!empty($product_badges)) {
foreach ($product_badges as $badge) {
$badge_color = get_option("taxonomy_badges_".$badge->term_id);
$badge->color = $badge_color['color'];
}
}
if (!empty($product_badges)) : ?>
color)) echo ' style="background-color: '.esc_html($badge->color).';"'; ?>>name); ?>
(cart->get_cart_contents_count()); ?>)
cart->get_cart();
$cart_item_key = wp_strip_all_tags( wp_unslash( $_POST['cart_item_key'] ) );
if ( array_key_exists($cart_item_key, $items)) {
$cart_item = $items[$cart_item_key];
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$price = apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key );
$resp['price'] = $price;
}
}
echo json_encode($resp);
exit;
}
}
add_action('init', 'allstore_ajaxcart_init');
function allstore_ajaxcart_init() {
if ( !empty($_POST['is_allstore_ajaxcart_ajax']) && !defined( 'WOOCOMMERCE_CART' ) ) {
define( 'WOOCOMMERCE_CART', true );
}
allstore_ajaxcart_enqueue_cart_js();
}
function allstore_ajaxcart_enqueue_cart_js() {
$path = 'assets/js/frontend/cart.js';
$src = str_replace( array( 'http:', 'https:' ), '', plugins_url( $path, WC_PLUGIN_FILE ) );
$deps = array( 'jquery', 'wc-country-select', 'wc-address-i18n');
wp_enqueue_script( 'wc-cart', $src, $deps, WC_VERSION, true );
}