Ejemplo n.º 1
0
function tpvc_divider_shortcode($atts)
{
    extract(shortcode_atts(array('tpvc_divider_title_option' => 'no', 'tpvc_divider_icon_option' => 'no', 'tpvc_divider_heading' => 'span', 'tpvc_divider_text' => '', 'tpvc_divider_icon' => 'fa-check-square-o', 'tpvc_divider_icon_color' => '', 'extra_class' => ''), $atts));
    if (!$tpvc_divider_text) {
        $tpvc_divider_heading = 'span';
    }
    /* backward, we no longer allow h1 here for SEO */
    if ($tpvc_divider_heading == 'h1') {
        $tpvc_divider_heading = 'h2';
    }
    $output = '<div class="tpvc-divider ' . $extra_class . '">';
    $output .= '<div class="divider-box">';
    $output .= '<div class="break-line"></div>';
    if ("no" == $tpvc_divider_title_option) {
        $output .= '<div class="divider-text">';
        $output .= '<' . $tpvc_divider_heading . ' class="divider-heading">';
        if ($tpvc_divider_icon_option == "no") {
            $output .= '<i class="' . tpvc_icon($tpvc_divider_icon) . '" ' . ($tpvc_divider_icon_color ? 'style="color:' . $tpvc_divider_icon_color . '"' : '') . '></i>';
        }
        $output .= $tpvc_divider_text;
        $output .= '</' . $tpvc_divider_heading . '>';
        $output .= '</div>';
    }
    $output .= '</div>';
    $output .= '</div>';
    return $output;
}
Ejemplo n.º 2
0
function tpvc_shortcode_heading($atts)
{
    extract(shortcode_atts(array('heading' => 'h1', 'text' => 'Heading Text', 'text_align' => 'text-left', 'heading_icon' => '', 'bg_color' => '', 'text_color' => '', 'icon_color' => '', 'extra_class' => ''), $atts));
    $output = "\t" . '<div class="tpvc-heading ' . $text_align . ' ' . $extra_class . '" ' . ($bg_color ? 'style="background:' . $bg_color . '"' : '') . '>' . "\n";
    $output .= "\t\t" . '<' . $heading . ' class="heading-title" ' . ($text_color ? 'style="color:' . $text_color . '"' : '') . '><i class="' . tpvc_icon($heading_icon) . '" ' . ($icon_color ? 'style="color:' . $icon_color . '"' : '') . '></i>' . $text . '</' . $heading . '>' . "\n";
    $output .= "\t" . '</div>' . "\n";
    return $output;
}
Ejemplo n.º 3
0
function tpvc_features_shortcode($atts)
{
    extract(shortcode_atts(array('tpvc_features_title' => '', 'tpvc_features_icon_position' => 'top-icon', 'tpvc_features_title_heading' => 'h3', 'tpvc_features_icon' => '', 'tpvc_features_icon_color' => '#EB8E7C', 'tpvc_features_description' => '', 'tpvc_features_url' => '', 'tpvc_features_extra_class' => ''), $atts));
    /* backward, we no longer allow h1 here for SEO */
    if ($tpvc_features_title_heading == 'h1') {
        $tpvc_features_title_heading = 'h3';
    }
    $output = "\t" . '<div class="tpvc-feature ' . $tpvc_features_extra_class . '">' . "\n";
    $output .= "\t\t" . '<div class="feature-inner ' . $tpvc_features_icon_position . '">' . "\n";
    $output .= "\t\t\t" . '<div class="feature-content">' . "\n";
    $output .= "\t\t\t\t" . '<span class="feature-icon"><i class="' . tpvc_icon($tpvc_features_icon) . '" style="color:' . $tpvc_features_icon_color . '"></i></span>' . "\n";
    $output .= "\t\t\t\t" . '<' . $tpvc_features_title_heading . ' class="feature-title"><a href="' . $tpvc_features_url . '">' . $tpvc_features_title . '</a></' . $tpvc_features_title_heading . '>' . "\n";
    $output .= "\t\t\t\t" . '<p>' . $tpvc_features_description . '</p>' . "\n";
    $output .= "\t\t\t" . '</div>' . "\n";
    $output .= "\t\t" . '</div>' . "\n";
    $output .= "\t" . '</div>' . "\n";
    return $output;
}
Ejemplo n.º 4
0
function tpvc_wc_mini_product_shortcode($atts)
{
    if (!class_exists('woocommerce')) {
        return;
    }
    extract(shortcode_atts(array('tpvc_wc_product_title' => 'Product', 'tpvc_wc_product_title_color' => '', 'tpvc_wc_product_title_bg' => '', 'tpvc_wc_product_title_icon' => '', 'tpvc_wc_product_title_icon_color' => '', 'tpvc_wc_product_numbers' => 36, 'tpvc_wc_product_columns' => 12, 'tpvc_wc_product_columns_tablet' => 9, 'tpvc_wc_product_columns_mobile' => 4, 'tpvc_wc_product_orderby' => 'date', 'tpvc_wc_product_order' => 'desc', 'tpvc_wc_product_hide_title' => '', 'tpvc_wc_product_class' => ''), $atts));
    $meta_query = WC()->query->get_meta_query();
    if (intval($tpvc_wc_product_numbers) < 1) {
        $tpvc_wc_product_numbers = 36;
    }
    if (intval($tpvc_wc_product_columns) < 1) {
        $tpvc_wc_product_columns = 12;
    }
    if (intval($tpvc_wc_product_columns_tablet) < 1) {
        $tpvc_wc_product_columns_tablet = 9;
    }
    if (intval($tpvc_wc_product_columns_mobile) < 1) {
        $tpvc_wc_product_columns_mobile = 4;
    }
    $tpvc_wc_product_class .= ' tpvc-mini-product-col-md-' . $tpvc_wc_product_columns;
    $tpvc_wc_product_class .= ' tpvc-mini-product-col-sm-' . $tpvc_wc_product_columns_tablet;
    $tpvc_wc_product_class .= ' tpvc-mini-product-col-xs-' . $tpvc_wc_product_columns_mobile;
    $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $tpvc_wc_product_numbers, 'orderby' => $tpvc_wc_product_orderby, 'order' => $tpvc_wc_product_order, 'meta_query' => $meta_query);
    ob_start();
    $products = new WP_Query($args);
    if ($products->have_posts()) {
        ?>

	<div class="tpvc-mini-product woocommerce <?php 
        echo $tpvc_wc_product_class;
        ?>
">

		<?php 
        if ("hide" != $tpvc_wc_product_hide_title) {
            ?>
			<div class="tpvc-title" <?php 
            if ("" !== $tpvc_wc_product_title_bg) {
                echo 'style="background-color:' . $tpvc_wc_product_title_bg . '"';
            }
            ?>
>
				<h2 <?php 
            if ("" !== $tpvc_wc_product_title_color) {
                echo 'style="color:' . $tpvc_wc_product_title_color . '"';
            }
            ?>
>
					<?php 
            if ("" != $tpvc_wc_product_title_icon) {
                echo '<i class="' . tpvc_icon($tpvc_wc_product_title_icon) . '" ' . ($tpvc_wc_product_title_icon_color ? 'style="color:' . $tpvc_wc_product_title_icon_color . '"' : '') . '></i>';
            }
            ?>
					<?php 
            echo $tpvc_wc_product_title;
            ?>
				</h2>
			</div>
		<?php 
        }
        ?>

		<ul class="products">

			<?php 
        while ($products->have_posts()) {
            $products->the_post();
            ?>

				<li <?php 
            post_class();
            ?>
>

					<?php 
            the_post_thumbnail('shop_thumbnail');
            ?>

					<div class="mini-icon-view">
						<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
">
							<i class="fa fa-search"></i>
						</a>
					</div>

				</li>

			<?php 
        }
        // end of the loop.
        ?>

		</ul>

	</div>

	<?php 
    }
    wp_reset_postdata();
    return ob_get_clean();
}
function tpvc_wc_mini_wcvendors_shortcode($atts)
{
    if (!class_exists('woocommerce')) {
        return;
    }
    if (!class_exists('WC_Vendors')) {
        return;
    }
    extract(shortcode_atts(array('tpvc_wc_vendor_title' => 'Vendors', 'tpvc_wc_vendor_title_color' => '', 'tpvc_wc_vendor_title_bg' => '', 'tpvc_wc_vendor_title_icon' => '', 'tpvc_wc_vendor_title_icon_color' => '', 'tpvc_wc_vendor_numbers' => 36, 'tpvc_wc_vendor_columns' => 12, 'tpvc_wc_vendor_columns_tablet' => 9, 'tpvc_wc_vendor_columns_mobile' => 4, 'tpvc_wc_vendor_orderby' => 'registered', 'tpvc_wc_vendor_order' => 'asc', 'tpvc_wc_vendor_hide_title' => '', 'tpvc_wc_vendor_show_products' => 'no', 'tpvc_wc_vendor_class' => ''), $atts));
    $meta_query = WC()->query->get_meta_query();
    if (intval($tpvc_wc_vendor_numbers) < 1) {
        $tpvc_wc_vendor_numbers = 36;
    }
    if (intval($tpvc_wc_vendor_columns) < 1) {
        $tpvc_wc_vendor_columns = 12;
    }
    if (intval($tpvc_wc_vendor_columns_tablet) < 1) {
        $tpvc_wc_vendor_columns_tablet = 9;
    }
    if (intval($tpvc_wc_vendor_columns_mobile) < 1) {
        $tpvc_wc_vendor_columns_mobile = 4;
    }
    $tpvc_wc_vendor_class .= ' tpvc-mini-product-col-md-' . $tpvc_wc_vendor_columns;
    $tpvc_wc_vendor_class .= ' tpvc-mini-product-col-sm-' . $tpvc_wc_vendor_columns_tablet;
    $tpvc_wc_vendor_class .= ' tpvc-mini-product-col-xs-' . $tpvc_wc_vendor_columns_mobile;
    $paged = 1;
    $offset = 0;
    // $paged      = (get_query_var('paged')) ? get_query_var('paged') : 1;
    // $offset     = ($paged - 1) * $per_page;
    // Hook into the user query to modify the query to return users that have at least one product
    if ($tpvc_wc_vendor_show_products == 'yes') {
        add_action('pre_user_query', array($this, 'vendors_with_products'));
    }
    // Get all vendors
    // 	$vendor_total_args = array (
    // 		'role' 				=> 'vendor',
    // 		'meta_key' 			=> 'pv_shop_slug',
    // 	'meta_value'   		=> '',
    // 'meta_compare' 		=> '>',
    // 'orderby' 			=> $tpvc_wc_vendor_orderby,
    // 	'order'				=> $tpvc_wc_vendor_order,
    // 	);
    // 	if ($tpvc_wc_vendor_show_products == 'yes') $vendor_total_args['query_id'] = 'vendors_with_products';
    // 	$vendor_query = New WP_User_Query( $vendor_total_args );
    // 	$all_vendors =$vendor_query->get_results();
    // Get the paged vendors
    $vendor_paged_args = array('role' => 'vendor', 'meta_key' => 'pv_shop_slug', 'meta_value' => '', 'meta_compare' => '>', 'orderby' => $tpvc_wc_vendor_orderby, 'order' => $tpvc_wc_vendor_order, 'offset' => $offset, 'number' => $tpvc_wc_vendor_numbers);
    if ($tpvc_wc_vendor_show_products == 'yes') {
        $vendor_total_args['query_id'] = 'vendors_with_products';
    }
    $vendor_paged_query = new WP_User_Query($vendor_paged_args);
    $paged_vendors = $vendor_paged_query->get_results();
    // Pagination calcs
    // $total_vendors = count($all_vendors);
    // $total_vendors_paged = count($paged_vendors);
    // $total_pages = intval($total_vendors / $per_page) + 1;
    ob_start();
    if (!empty($paged_vendors)) {
        ?>

	<div class="tpvc-mini-product woocommerce <?php 
        echo $tpvc_wc_vendor_class;
        ?>
">

		<?php 
        if ("hide" != $tpvc_wc_vendor_hide_title) {
            ?>
			<div class="tpvc-title" <?php 
            if ("" !== $tpvc_wc_vendor_title_bg) {
                echo 'style="background-color:' . $tpvc_wc_vendor_title_bg . '"';
            }
            ?>
>
				<h2 <?php 
            if ("" !== $tpvc_wc_vendor_title_color) {
                echo 'style="color:' . $tpvc_wc_vendor_title_color . '"';
            }
            ?>
>
					<?php 
            if ("" != $tpvc_wc_vendor_title_icon) {
                echo '<i class="' . tpvc_icon($tpvc_wc_vendor_title_icon) . '" ' . ($tpvc_wc_vendor_title_icon_color ? 'style="color:' . $tpvc_wc_vendor_title_icon_color . '"' : '') . '></i>';
            }
            ?>
					<?php 
            echo $tpvc_wc_vendor_title;
            ?>
				</h2>
			</div>
		<?php 
        }
        ?>

		<ul class="products">

			<?php 
        foreach ($paged_vendors as $vendor) {
            ?>

				<?php 
            $vendor_link = WCV_Vendors::get_vendor_shop_page($vendor->ID);
            ?>
				<?php 
            $vendor_name = $vendor->pv_shop_name;
            ?>

				<li class="product">

					<?php 
            echo get_avatar($vendor->ID, 200);
            ?>

					<div class="mini-icon-view">
						<a href="<?php 
            echo esc_url($vendor_link);
            ?>
" title="<?php 
            echo esc_attr($vendor_name);
            ?>
">
							<i class="fa fa-search"></i>
						</a>
					</div>

				</li>

			<?php 
        }
        // end of the loop.
        ?>

		</ul>

	</div>

	<?php 
    }
    return ob_get_clean();
}
Ejemplo n.º 6
0
function tpvc_wc_product_featured_shortcode($atts)
{
    if (!class_exists('woocommerce')) {
        return;
    }
    global $woocommerce_loop;
    extract(shortcode_atts(array('tpvc_wc_featured_title' => __('Featured Product', 'tokopress'), 'tpvc_wc_featured_title_color' => '', 'tpvc_wc_featured_title_bg' => '', 'tpvc_wc_featured_title_icon' => '', 'tpvc_wc_featured_title_icon_color' => '', 'tpvc_wc_featured_link' => __('see all', 'tokopress'), 'tpvc_wc_featured_link_color' => '', 'tpvc_wc_featured_number' => '6', 'tpvc_wc_featured_orderby' => 'date', 'tpvc_wc_featured_order' => 'desc', 'tpvc_wc_featured_hide_title' => '', 'tpvc_wc_featured_hide_prodprice' => '', 'tpvc_wc_featured_hide_prodtitle' => '', 'tpvc_wc_featured_hide_prodlink' => '', 'tpvc_wc_featured_hide_prodcart' => '', 'tpvc_wc_featured_hide_prodlink_text' => __('detail', 'tokopress'), 'tpvc_wc_featured_class' => ''), $atts));
    $tpvc_wc_featured_columns = 1;
    $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $tpvc_wc_featured_number, 'orderby' => $tpvc_wc_featured_orderby, 'order' => $tpvc_wc_featured_order, 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')));
    ob_start();
    $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
    $woocommerce_loop['columns'] = $tpvc_wc_featured_columns;
    if ($products->have_posts()) {
        ?>
	<div class="tpvc-featured-product woocommerce woocommerce-product-col-<?php 
        echo $tpvc_wc_featured_columns;
        ?>
 <?php 
        echo $tpvc_wc_featured_class;
        ?>
">

		<?php 
        if ("hide" != $tpvc_wc_featured_hide_title) {
            ?>
			<?php 
            if ($tpvc_wc_featured_link_color) {
                echo '<style>';
                echo '.tpvc-featured-product.woocommerce .tpvc-title a.button.alt { color:' . $tpvc_wc_featured_link_color . '; box-shadow: ' . $tpvc_wc_featured_link_color . ' 0 0px 0px 2px inset; }';
                echo '.tpvc-featured-product.woocommerce .tpvc-title a.button.alt:hover { color: #fff; box-shadow: ' . $tpvc_wc_featured_link_color . ' 0 0px 0px 40px inset; }';
                echo '</style>';
            }
            ?>

			<div class="tpvc-title" <?php 
            if ("" != $tpvc_wc_featured_title_bg) {
                echo 'style="background-color:' . $tpvc_wc_featured_title_bg . '"';
            }
            ?>
>
				<h2 <?php 
            if ("" != $tpvc_wc_featured_title_color) {
                echo 'style="color:' . $tpvc_wc_featured_title_color . '"';
            }
            ?>
>
					<?php 
            if ("" != $tpvc_wc_featured_title_icon) {
                echo '<i class="' . tpvc_icon($tpvc_wc_featured_title_icon) . '" ' . ($tpvc_wc_featured_title_icon_color ? 'style="color:' . $tpvc_wc_featured_title_icon_color . '"' : '') . '></i>';
            }
            ?>
					<?php 
            echo $tpvc_wc_featured_title;
            ?>
				</h2>
				<a href="<?php 
            echo get_permalink(wc_get_page_id('shop'));
            ?>
" class="button alt">
					<?php 
            if (!$tpvc_wc_featured_link) {
                $tpvc_wc_featured_link = __('see all', 'tokopress');
            }
            echo $tpvc_wc_featured_link;
            ?>
				</a>
			</div>
		<?php 
        }
        ?>

		<ul class="products owl-carousel">

			<?php 
        while ($products->have_posts()) {
            $products->the_post();
            ?>

				<li <?php 
            post_class();
            ?>
>
					<div class="featured-top">
						<?php 
            the_post_thumbnail('custom-woo-thumbnail');
            ?>
					</div>
					<?php 
            if ("yes" != $tpvc_wc_featured_hide_prodprice || "yes" != $tpvc_wc_featured_hide_prodtitle || "yes" != $tpvc_wc_featured_hide_prodlink || "yes" != $tpvc_wc_featured_hide_prodcart) {
                ?>
						<div class="featured-bottom">
							<?php 
                if ("yes" != $tpvc_wc_featured_hide_prodprice) {
                    ?>
								<div class="featured-price">
									<?php 
                    woocommerce_template_loop_price();
                    ?>
								</div>
							<?php 
                }
                ?>
							<?php 
                if ("yes" != $tpvc_wc_featured_hide_prodlink || "yes" != $tpvc_wc_featured_hide_prodcart) {
                    ?>
								<div class="featured-action">
									<?php 
                    if ("yes" != $tpvc_wc_featured_hide_prodlink) {
                        ?>
										<a href="<?php 
                        echo get_permalink();
                        ?>
" class="button detail_button_loop">
											<?php 
                        if (!$tpvc_wc_featured_hide_prodlink_text) {
                            $tpvc_wc_featured_hide_prodlink_text = __('detail', 'tokopress');
                        }
                        echo $tpvc_wc_featured_hide_prodlink_text;
                        ?>
										</a>
									<?php 
                    }
                    ?>
									<?php 
                    if ("yes" != $tpvc_wc_featured_hide_prodcart) {
                        ?>
										<?php 
                        woocommerce_template_loop_add_to_cart();
                        ?>
									<?php 
                    }
                    ?>
								</div>
							<?php 
                }
                ?>
							<?php 
                if ("yes" != $tpvc_wc_featured_hide_prodtitle) {
                    ?>
								<div class="featured-title">
									<h3><a href="<?php 
                    echo get_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h3>
								</div>
							<?php 
                }
                ?>
						</div>
					<?php 
            }
            ?>
				</li>

			<?php 
        }
        ?>

		</ul>

	</div>
	<?php 
    }
    wp_reset_postdata();
    $js_code = '$(\'.tpvc-featured-product ul.owl-carousel\').owlCarousel({
            items : 1,
            loop: true,
            nav : true,
            stopOnHover : true,     
            navText : [\'<i class="fa fa-chevron-left"></i>\', \'<i class="fa fa-chevron-right"></i>\'],
            lazyLoad: true,
            autoplay: true,
            dots: false
        });';
    wc_enqueue_js($js_code);
    return ob_get_clean();
}
Ejemplo n.º 7
0
function tpvc_wc_cat_categories_shortcode($atts)
{
    if (!class_exists('woocommerce')) {
        return;
    }
    global $woocommerce_loop;
    extract(shortcode_atts(array('tpvc_wc_cat_style' => 'alt', 'tpvc_wc_cat_title' => __('Product Category', 'tokopress'), 'tpvc_wc_cat_title_color' => '', 'tpvc_wc_cat_title_bg' => '', 'tpvc_wc_cat_title_icon' => '', 'tpvc_wc_cat_title_icon_color' => '', 'tpvc_wc_cat_parent' => '', 'tpvc_wc_cat_hide_empty' => 1, 'tpvc_wc_cat_numbers' => '6', 'tpvc_wc_cat_columns' => '3', 'tpvc_wc_cat_orderby' => 'none', 'tpvc_wc_cat_order' => 'asc', 'tpvc_wc_cat_hide_title' => '', 'tpvc_wc_cat_class' => ''), $atts));
    if (isset($atts['tpvc_wc_cat_ids'])) {
        $tpvc_wc_cat_ids = explode(',', $atts['tpvc_wc_cat_ids']);
        $tpvc_wc_cat_ids = array_map('trim', $ids);
    } else {
        $tpvc_wc_cat_ids = array();
    }
    $tpvc_wc_cat_hide_empty = $tpvc_wc_cat_hide_empty == true || $tpvc_wc_cat_hide_empty == 1 ? 1 : 0;
    if ($tpvc_wc_cat_parent == 'top') {
        $tpvc_wc_cat_parent = '0';
    }
    // get terms and workaround WP bug with parents/pad counts
    $args = array('orderby' => $tpvc_wc_cat_orderby, 'order' => $tpvc_wc_cat_order, 'hide_empty' => $tpvc_wc_cat_hide_empty, 'include' => $tpvc_wc_cat_ids, 'pad_counts' => true, 'child_of' => $tpvc_wc_cat_parent);
    $product_categories = get_terms('product_cat', $args);
    if ($tpvc_wc_cat_parent !== "") {
        $product_categories = wp_list_filter($product_categories, array('parent' => $tpvc_wc_cat_parent));
    }
    if ($tpvc_wc_cat_hide_empty) {
        foreach ($product_categories as $key => $category) {
            if ($category->count == 0) {
                unset($product_categories[$key]);
            }
        }
    }
    if ($tpvc_wc_cat_numbers) {
        $product_categories = array_slice($product_categories, 0, $tpvc_wc_cat_numbers);
    }
    ob_start();
    $woocommerce_loop['columns'] = $tpvc_wc_cat_columns;
    if ($product_categories) {
        ?>

	<div class="tpvc-product woocommerce woocommerce-product-col-<?php 
        echo $tpvc_wc_cat_columns;
        ?>
 <?php 
        echo $tpvc_wc_cat_class;
        ?>
">

		<?php 
        if ("hide" != $tpvc_wc_cat_hide_title) {
            ?>
			<div class="tpvc-title" <?php 
            if ("" !== $tpvc_wc_cat_title_bg) {
                echo 'style="background-color:' . $tpvc_wc_cat_title_bg . '"';
            }
            ?>
>
				<h2 <?php 
            if ("" !== $tpvc_wc_cat_title_color) {
                echo 'style="color:' . $tpvc_wc_cat_title_color . '"';
            }
            ?>
>
					<?php 
            if ("" != $tpvc_wc_cat_title_icon) {
                echo '<i class="' . tpvc_icon($tpvc_wc_cat_title_icon) . '" ' . ($tpvc_wc_cat_title_icon_color ? 'style="color:' . $tpvc_wc_cat_title_icon_color . '"' : '') . '></i>';
            }
            ?>
					<?php 
            echo $tpvc_wc_cat_title;
            ?>
				</h2>
			</div>
		<?php 
        }
        ?>

		<ul class="products product-category">

			<?php 
        foreach ($product_categories as $category) {
            wc_get_template('content-product_cat.php', array('category' => $category));
        }
        ?>

		</ul>

	</div>

	<?php 
    }
    return ob_get_clean();
}
Ejemplo n.º 8
0
function tpvc_wc_mini_vendors_dokan_shortcode($atts)
{
    if (!class_exists('woocommerce')) {
        return;
    }
    if (!class_exists('WeDevs_Dokan')) {
        return;
    }
    extract(shortcode_atts(array('tpvc_wc_vendor_title' => 'Vendors', 'tpvc_wc_vendor_title_color' => '', 'tpvc_wc_vendor_title_bg' => '', 'tpvc_wc_vendor_title_icon' => '', 'tpvc_wc_vendor_title_icon_color' => '', 'tpvc_wc_vendor_numbers' => 36, 'tpvc_wc_vendor_columns' => 12, 'tpvc_wc_vendor_columns_tablet' => 9, 'tpvc_wc_vendor_columns_mobile' => 4, 'tpvc_wc_vendor_orderby' => 'registered', 'tpvc_wc_vendor_order' => 'asc', 'tpvc_wc_vendor_hide_title' => '', 'tpvc_wc_vendor_show_products' => 'no', 'tpvc_wc_vendor_class' => ''), $atts));
    $meta_query = WC()->query->get_meta_query();
    if (intval($tpvc_wc_vendor_numbers) < 1) {
        $tpvc_wc_vendor_numbers = 36;
    }
    if (intval($tpvc_wc_vendor_columns) < 1) {
        $tpvc_wc_vendor_columns = 12;
    }
    if (intval($tpvc_wc_vendor_columns_tablet) < 1) {
        $tpvc_wc_vendor_columns_tablet = 9;
    }
    if (intval($tpvc_wc_vendor_columns_mobile) < 1) {
        $tpvc_wc_vendor_columns_mobile = 4;
    }
    $tpvc_wc_vendor_class .= ' tpvc-mini-product-col-md-' . $tpvc_wc_vendor_columns;
    $tpvc_wc_vendor_class .= ' tpvc-mini-product-col-sm-' . $tpvc_wc_vendor_columns_tablet;
    $tpvc_wc_vendor_class .= ' tpvc-mini-product-col-xs-' . $tpvc_wc_vendor_columns_mobile;
    $paged = 1;
    $offset = 0;
    // Get the paged vendors
    $vendor_paged_args = array('meta_query' => array(array('key' => 'dokan_enable_selling', 'value' => 'yes', 'compare' => '=')), 'orderby' => $tpvc_wc_vendor_orderby, 'order' => $tpvc_wc_vendor_order, 'offset' => $offset, 'number' => $tpvc_wc_vendor_numbers);
    $vendor_paged_query = new WP_User_Query($vendor_paged_args);
    $paged_vendors = $vendor_paged_query->get_results();
    // Pagination calcs
    // $total_vendors = count($all_vendors);
    // $total_vendors_paged = count($paged_vendors);
    // $total_pages = intval($total_vendors / $per_page) + 1;
    ob_start();
    if (!empty($paged_vendors)) {
        ?>

	<div class="tpvc-mini-product woocommerce <?php 
        echo $tpvc_wc_vendor_class;
        ?>
">

		<?php 
        if ("hide" != $tpvc_wc_vendor_hide_title) {
            ?>
			<div class="tpvc-title" <?php 
            if ("" !== $tpvc_wc_vendor_title_bg) {
                echo 'style="background-color:' . $tpvc_wc_vendor_title_bg . '"';
            }
            ?>
>
				<h2 <?php 
            if ("" !== $tpvc_wc_vendor_title_color) {
                echo 'style="color:' . $tpvc_wc_vendor_title_color . '"';
            }
            ?>
>
					<?php 
            if ("" != $tpvc_wc_vendor_title_icon) {
                echo '<i class="' . tpvc_icon($tpvc_wc_vendor_title_icon) . '" ' . ($tpvc_wc_vendor_title_icon_color ? 'style="color:' . $tpvc_wc_vendor_title_icon_color . '"' : '') . '></i>';
            }
            ?>
					<?php 
            echo $tpvc_wc_vendor_title;
            ?>
				</h2>
			</div>
		<?php 
        }
        ?>

		<ul class="products">

			<?php 
        foreach ($paged_vendors as $vendor) {
            ?>

                <?php 
            $store_info = dokan_get_store_info($vendor->ID);
            $vendor_name = isset($store_info['store_name']) ? esc_html($store_info['store_name']) : __('N/A', 'tokopress');
            $vendor_link = dokan_get_store_url($vendor->ID);
            ?>

				<li class="product">

					<?php 
            echo get_avatar($vendor->ID, 200);
            ?>

					<div class="mini-icon-view">
						<a href="<?php 
            echo esc_url($vendor_link);
            ?>
" title="<?php 
            echo esc_attr($vendor_name);
            ?>
">
							<i class="fa fa-search"></i>
						</a>
					</div>

				</li>

			<?php 
        }
        // end of the loop.
        ?>

		</ul>

	</div>

	<?php 
    }
    return ob_get_clean();
}
Ejemplo n.º 9
0
function tpvc_wc_product_shortcode($atts)
{
    if (!class_exists('woocommerce')) {
        return;
    }
    global $woocommerce_loop;
    extract(shortcode_atts(array('tpvc_wc_product_style' => 'alternate', 'tpvc_wc_product_title' => __('Product', 'tokopress'), 'tpvc_wc_product_title_color' => '', 'tpvc_wc_product_title_bg' => '', 'tpvc_wc_product_title_icon' => '', 'tpvc_wc_product_title_icon_color' => '', 'tpvc_wc_product_link' => __('see all', 'tokopress'), 'tpvc_wc_product_link_color' => '', 'tpvc_wc_product_per_page' => '6', 'tpvc_wc_product_columns' => '2', 'tpvc_wc_product_orderby' => 'date', 'tpvc_wc_product_order' => 'desc', 'tpvc_wc_product_hide_title' => '', 'tpvc_wc_product_play' => 'false', 'tpvc_wc_product_class' => ''), $atts));
    if ($tpvc_wc_product_style == '') {
        $tpvc_wc_product_style = 'alternate';
    } elseif ($tpvc_wc_product_style == 'style-2') {
        $tpvc_wc_product_style = 'alternate';
    } elseif ($tpvc_wc_product_style == 'style-1') {
        $tpvc_wc_product_style = 'default';
    }
    $meta_query = WC()->query->get_meta_query();
    $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $tpvc_wc_product_per_page, 'orderby' => $tpvc_wc_product_orderby, 'order' => $tpvc_wc_product_order, 'meta_query' => $meta_query);
    ob_start();
    $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
    $woocommerce_loop['columns'] = $tpvc_wc_product_columns;
    if ($products->have_posts()) {
        ?>

	<div class="tpvc-product woocommerce woocommerce-product-col-<?php 
        echo $tpvc_wc_product_columns;
        ?>
 <?php 
        echo $tpvc_wc_product_class;
        ?>
">

		<?php 
        if ("hide" != $tpvc_wc_product_hide_title) {
            ?>
			<?php 
            if ($tpvc_wc_product_link_color) {
                echo '<style>';
                echo '.tpvc-product.woocommerce .tpvc-title a.button { color:' . $tpvc_wc_product_link_color . '; box-shadow: ' . $tpvc_wc_product_link_color . ' 0 0px 0px 2px inset; }';
                echo '.tpvc-product.woocommerce .tpvc-title a.button:hover { color: #fff; box-shadow: ' . $tpvc_wc_product_link_color . ' 0 0px 0px 40px inset; }';
                echo '</style>';
            }
            ?>

			<?php 
            if (!$tpvc_wc_product_link) {
                $tpvc_wc_product_link = __('see all', 'tokopress');
            }
            $shop = get_permalink(wc_get_page_id('shop'));
            if ("date" == $tpvc_wc_product_orderby) {
                $see_all = '<a href="' . add_query_arg('orderby', 'date', $shop) . '" class="button">' . $tpvc_wc_product_link . '</a>';
            } elseif ("price" == $tpvc_wc_product_orderby) {
                $see_all = '<a href="' . add_query_arg('orderby', 'price', $shop) . '" class="button">' . $tpvc_wc_product_link . '</a>';
            } elseif ("sales" == $tpvc_wc_product_orderby) {
                $see_all = '<a href="' . add_query_arg('orderby', 'popularity', $shop) . '" class="button">' . $tpvc_wc_product_link . '</a>';
            } else {
                $see_all = '<a href="' . $shop . '" class="button">' . $tpvc_wc_product_link . '</a>';
            }
            ?>
			<div class="tpvc-title" <?php 
            if ("" !== $tpvc_wc_product_title_bg) {
                echo 'style="background-color:' . $tpvc_wc_product_title_bg . '"';
            }
            ?>
>
				<h2 <?php 
            if ("" !== $tpvc_wc_product_title_color) {
                echo 'style="color:' . $tpvc_wc_product_title_color . '"';
            }
            ?>
>
					<?php 
            if ("" != $tpvc_wc_product_title_icon) {
                echo '<i class="' . tpvc_icon($tpvc_wc_product_title_icon) . '" ' . ($tpvc_wc_product_title_icon_color ? 'style="color:' . $tpvc_wc_product_title_icon_color . '"' : '') . '></i>';
            }
            ?>
					<?php 
            echo $tpvc_wc_product_title;
            ?>
				</h2>
				<?php 
            echo $see_all;
            ?>
			</div>
		<?php 
        }
        ?>

		<ul class="products">

			<?php 
        while ($products->have_posts()) {
            $products->the_post();
            ?>

				<?php 
            if ("default" == $tpvc_wc_product_style) {
                ?>
					<?php 
                wc_get_template_part('content-product');
                ?>
				<?php 
            } else {
                ?>
					<?php 
                wc_get_template_part('content-product', 'alt');
                ?>
				<?php 
            }
            ?>

			<?php 
        }
        // end of the loop.
        ?>

		</ul>

	</div>

	<?php 
    }
    wp_reset_postdata();
    return ob_get_clean();
}