コード例 #1
0
/**
 * Defines [show_categories] shortcode
 *
 * @global type $cat_shortcode_query
 * @param type $atts
 * @return string
 */
function product_cat_shortcode($atts)
{
    global $cat_shortcode_query, $product_sort, $archive_template;
    $cat_shortcode_query = array();
    $cat_shortcode_query['current'] = 0;
    $args = shortcode_atts(array('exclude' => array(), 'include' => array(), 'archive_template' => get_option('archive_template', 'default'), 'parent' => '', 'sort' => 0, 'shortcode_query' => 'yes'), $atts);
    $div = '<div class="product-subcategories ' . $args['archive_template'] . ' ' . product_list_class('category-list') . '">';
    $cats = get_terms('al_product-cat', $args);
    $cat_shortcode_query['count'] = count($cats);
    $cat_shortcode_query['enable'] = $args['shortcode_query'];
    $product_sort = intval($args['sort']);
    $inside = '';
    if ($args['parent'] == '' && empty($args['include'])) {
        $old_args = $args;
        $args['parent'] = 0;
        $cats = get_terms('al_product-cat', $args);
        foreach ($cats as $cat) {
            $inside .= get_product_category_template($args['archive_template'], $cat);
            $cat_shortcode_query['current']++;
            $inside .= get_sub_product_subcategories($args, $cat);
        }
    } else {
        foreach ($cats as $cat) {
            $inside .= get_product_category_template($args['archive_template'], $cat);
            $cat_shortcode_query['current']++;
        }
    }
    if (!empty($inside)) {
        do_action('before_category_list', $archive_template);
        $inside = $div . $inside;
        $inside .= '</div>';
    }
    reset_row_class();
    return $inside;
}
コード例 #2
0
ファイル: shortcodes.php プロジェクト: satokora/IT354Project
function product_cat_shortcode($atts)
{
    global $cat_shortcode_query;
    $cat_shortcode_query = array();
    $cat_shortcode_query['current'] = 0;
    $args = shortcode_atts(array('exclude' => array(), 'include' => array(), 'archive_template' => get_option('archive_template', 'default'), 'parent' => ''), $atts);
    $inside = '<div class="product-subcategories ' . $args['archive_template'] . ' ' . product_list_class() . '">';
    $cats = get_terms('al_product-cat', $args);
    $cat_shortcode_query['count'] = count($cats);
    if ($args['parent'] == '') {
        $old_args = $args;
        $args['parent'] = 0;
        $cats = get_terms('al_product-cat', $args);
        foreach ($cats as $cat) {
            $inside .= get_product_category_template($args['archive_template'], $cat);
            $cat_shortcode_query['current']++;
            $inside .= get_sub_product_subcategories($args, $cat);
        }
    } else {
        foreach ($cats as $cat) {
            $inside .= get_product_category_template($args['archive_template'], $cat);
            $cat_shortcode_query['current']++;
        }
    }
    $inside .= '</div>';
    reset_row_class();
    return $inside;
}
コード例 #3
0
ファイル: shortcodes.php プロジェクト: nanookYs/orientreizen
/**
 * Defines [show_categories] shortcode
 *
 * @global type $cat_shortcode_query
 * @param type $atts
 * @return string
 */
function product_cat_shortcode($atts)
{
    global $cat_shortcode_query, $product_sort, $archive_template;
    $cat_shortcode_query = array();
    $cat_shortcode_query['current'] = 0;
    $args = shortcode_atts(array('exclude' => array(), 'include' => array(), 'archive_template' => get_option('archive_template', 'default'), 'parent' => '', 'sort' => 0, 'shortcode_query' => 'yes', 'orderby' => 'name', 'order' => 'ASC'), $atts);
    if ($args['orderby'] == 'none') {
        $args['orderby'] = 'include';
    }
    $args = apply_filters('show_categories_args', $args);
    if (!is_array($args['include'])) {
        $args['include'] = explode(',', $args['include']);
    }
    $div = '<div class="product-subcategories responsive ' . $args['archive_template'] . ' ' . product_list_class($args['archive_template'], 'category-list') . '">';
    $cats = get_terms('al_product-cat', $args);
    $cat_shortcode_query['count'] = count($cats);
    $cat_shortcode_query['enable'] = $args['shortcode_query'];
    $product_sort = intval($args['sort']);
    $inside = '';
    if ($args['parent'] == '' && empty($args['include'])) {
        $old_args = $args;
        $args['parent'] = 0;
        $cats = get_terms('al_product-cat', $args);
        foreach ($cats as $cat) {
            $inside .= get_product_category_template($args['archive_template'], $cat);
            $cat_shortcode_query['current']++;
            $inside .= get_sub_product_subcategories($args, $cat);
        }
    } else {
        foreach ($cats as $cat) {
            $inside .= get_product_category_template($args['archive_template'], $cat);
            $cat_shortcode_query['current']++;
        }
    }
    if (!empty($inside)) {
        $ready = apply_filters('category_list_ready', $inside, $args['archive_template']);
        ob_start();
        do_action('before_category_list', $args['archive_template']);
        $inside = ob_get_contents();
        ob_end_clean();
        $inside .= $div . $ready;
        $inside .= '</div>';
    }
    reset_row_class();
    return $inside;
}
コード例 #4
0
ファイル: templates-functions.php プロジェクト: RA2WP/RA2WP
function show_products_outside_loop($atts)
{
    global $shortcode_query, $product_sort, $archive_template, $shortcode_args;
    $available_args = apply_filters('show_products_shortcode_args', array('post_type' => 'al_product', 'category' => '', 'product' => '', 'exclude' => '', 'products_limit' => -1, 'archive_template' => get_product_listing_template(), 'design_scheme' => '', 'sort' => 0, 'orderby' => '', 'order' => ''));
    $args = shortcode_atts($available_args, $atts);
    $shortcode_args = $args;
    $category = esc_html($args['category']);
    $product = esc_html($args['product']);
    $exclude = esc_html($args['exclude']);
    $products_limit = intval($args['products_limit']);
    $archive_template = esc_attr($args['archive_template']);
    $design_scheme = esc_attr($args['design_scheme']);
    $product_sort = intval($args['sort']);
    if ($product != 0) {
        $product_array = explode(',', $product);
        $query_param = array('post_type' => 'al_product', 'post__in' => $product_array, 'posts_per_page' => $products_limit);
    } else {
        if (!empty($category)) {
            $category_array = explode(',', $category);
            $field = 'name';
            if (is_numeric($category_array[0])) {
                $field = 'term_id';
            }
            $query_param = array('post_type' => 'al_product', 'tax_query' => array(array('taxonomy' => 'al_product-cat', 'field' => $field, 'terms' => $category_array)), 'posts_per_page' => $products_limit);
        } else {
            $query_param = array('post_type' => 'al_product', 'posts_per_page' => $products_limit);
            if (!empty($exclude)) {
                $query_param['post__not_in'] = explode(',', $exclude);
            }
        }
    }
    if (!empty($args['orderby'])) {
        $query_param['orderby'] = esc_attr($args['orderby']);
    }
    if (!empty($args['order'])) {
        $query_param['order'] = esc_attr($args['order']);
    }
    $query_param = apply_filters('shortcode_query', $query_param, $args);
    $shortcode_query = new WP_Query($query_param);
    $inside = '';
    $i = 0;
    ob_start();
    do_action('before_product_list', $archive_template);
    $before = ob_get_contents();
    ob_end_clean();
    while ($shortcode_query->have_posts()) {
        $shortcode_query->the_post();
        global $post;
        $i++;
        $inside .= get_catalog_template($archive_template, $post, $i, $design_scheme);
    }
    $inside = apply_filters('product_list_ready', $inside, $archive_template, $args);
    wp_reset_postdata();
    reset_row_class();
    unset($shortcode_args);
    return $before . '<div class="product-list responsive ' . $archive_template . ' ' . product_list_class($archive_template) . '">' . $inside . '<div style="clear:both"></div></div>';
}
コード例 #5
0
ファイル: shortcodes.php プロジェクト: RA2WP/RA2WP
/**
 * Shows products on product listing for custom templates usage
 *
 * @return type
 */
function ic_product_listing_products()
{
    ob_start();
    global $post;
    $multiple_settings = get_multiple_settings();
    $archive_template = get_product_listing_template();
    if (is_home_archive()) {
        $args = array('post_type' => 'al_product', 'posts_per_page' => $multiple_settings['archive_products_limit']);
        query_posts($args);
        $is_home = 1;
    }
    if ((is_tax() || is_search() || !is_ic_only_main_cats()) && more_products()) {
        do_action('before_product_list', $archive_template, $multiple_settings);
        $product_list = '';
        while (have_posts()) {
            the_post();
            $product_list .= get_catalog_template($archive_template, $post);
        }
        if (isset($is_home)) {
            wp_reset_query();
        }
        $product_list = apply_filters('product_list_ready', $product_list, $archive_template, 'auto_listing');
        echo '<div class="product-list responsive ' . $archive_template . ' ' . product_list_class($archive_template) . '">' . $product_list . '</div><span class="clear"></span>';
    } else {
        if (is_search() && !more_products()) {
            echo '<p>' . __('Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'ecommerce-product-catalog') . '</p>';
            product_search_form();
        }
    }
    return ob_get_clean();
}
コード例 #6
0
						</div>
					<?php 
            }
        } else {
            $show_categories = do_shortcode('[show_categories parent=' . get_queried_object_id() . ']');
            if (!empty($show_categories)) {
                echo $show_categories;
                if ($archive_template != 'list') {
                    echo '<hr>';
                }
            }
        }
    }
}
do_action('before_product_list', $archive_template, $multiple_settings);
$product_list = '<div class="product-list responsive ' . product_list_class() . '">';
if (is_home_archive()) {
    $args = array('post_type' => 'al_product');
    query_posts($args);
    $is_home = 1;
}
while (have_posts()) {
    the_post();
    $product_list .= get_catalog_template($archive_template, $post);
}
if (isset($is_home)) {
    wp_reset_query();
}
$product_list .= '</div>';
$product_list = apply_filters('product_list_ready', $product_list, $archive_template);
echo $product_list;
コード例 #7
0
    } else {
        $paged = 1;
    }
    $args = apply_filters('home_product_listing_query', array('post_type' => 'al_product', 'posts_per_page' => $multiple_settings['archive_products_limit'], 'paged' => $paged));
    query_posts($args);
    $is_home = 1;
}
if ((is_tax() || is_search() || !is_ic_only_main_cats()) && more_products()) {
    do_action('before_product_list', $archive_template, $multiple_settings);
    $product_list = '';
    while (have_posts()) {
        the_post();
        $product_list .= get_catalog_template($archive_template, $post);
    }
    $product_list = apply_filters('product_list_ready', $product_list, $archive_template, 'auto_listing');
    echo '<div class="product-list responsive ' . $archive_template . ' ' . product_list_class($archive_template) . '">' . $product_list . '</div><span class="clear"></span>';
} else {
    if (!is_product_filters_active() && is_search() && !more_products()) {
        echo '<p>' . __('Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'ecommerce-product-catalog') . '</p>';
        product_search_form();
    } else {
        if (is_product_filters_active() && !more_products()) {
            show_product_sort_bar();
            $filters = get_active_product_filters();
            if (isset($_GET['s'])) {
                $filters[] = 's';
            }
            echo '<p>' . sprintf(__('Sorry, but nothing matched your search terms. Please try again with some different options or %sreset filters%s.', 'ecommerce-product-catalog'), '<a href="' . esc_url(remove_query_arg($filters)) . '">', '</a>') . '</p>';
        }
    }
}
コード例 #8
0
                    if ($archive_template != 'list' && !is_ic_only_main_cats()) {
                        echo '<hr>';
                    }
                }
            }
        }
    }
}
if (is_home_archive()) {
    $args = array('post_type' => 'al_product', 'posts_per_page' => $multiple_settings['archive_products_limit']);
    query_posts($args);
    $is_home = 1;
}
if ((is_tax() || is_search() || !is_ic_only_main_cats()) && more_products()) {
    do_action('before_product_list', $archive_template, $multiple_settings);
    $product_list = '<div class="product-list responsive ' . $archive_template . ' ' . product_list_class() . '">';
    while (have_posts()) {
        the_post();
        $product_list .= get_catalog_template($archive_template, $post);
    }
    if (isset($is_home)) {
        wp_reset_query();
    }
    $product_list .= '</div>';
    $product_list = apply_filters('product_list_ready', $product_list, $archive_template);
    echo $product_list . '<span class="clear"></span></div>';
} else {
    if (is_search() && !more_products()) {
        echo '<p>' . __('Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'al-ecommerce-product-catalog') . '</p>';
        product_search_form();
    }
コード例 #9
0
function show_products_outside_loop($atts)
{
    global $shortcode_query, $product_sort;
    $args = shortcode_atts(array('post_type' => 'al_product', 'category' => '', 'product' => '', 'products_limit' => -1, 'archive_template' => get_option('archive_template', 'default'), 'design_scheme' => '', 'sort' => 0), $atts);
    $sort = (int) $args['sort'];
    $category = esc_attr($args['category']);
    $product = esc_attr($args['product']);
    $products_limit = (int) $args['products_limit'];
    $archive_template = esc_attr($args['archive_template']);
    $design_scheme = esc_attr($args['design_scheme']);
    //	$post_type = esc_attr($args['post_type']);
    $product_sort = $sort;
    if ($product != 0) {
        $product_array = explode(',', $product);
        $query_param = array('post_type' => 'al_product', 'post__in' => $product_array, 'posts_per_page' => $products_limit);
    } else {
        if ($category != 0) {
            $category_array = explode(',', $category);
            $query_param = array('post_type' => 'al_product', 'tax_query' => array(array('taxonomy' => 'al_product-cat', 'field' => 'term_id', 'terms' => $category_array)), 'posts_per_page' => $products_limit);
        } else {
            $query_param = array('post_type' => 'al_product', 'posts_per_page' => $products_limit);
        }
    }
    $query_param = apply_filters('shortcode_query', $query_param);
    $shortcode_query = new WP_Query($query_param);
    $inside = '';
    $i = 0;
    do_action('before_product_list', $archive_template);
    while ($shortcode_query->have_posts()) {
        $shortcode_query->the_post();
        global $post;
        $i++;
        $inside .= get_catalog_template($archive_template, $post, $i, $design_scheme);
    }
    $inside = apply_filters('product_list_ready', $inside, $archive_template);
    wp_reset_postdata();
    return '<div class="product-list responsive ' . $archive_template . '-list ' . product_list_class() . '">' . $inside . '<div style="clear:both"></div></div>';
}
コード例 #10
0
/**
 * Generates product listing products
 *
 * @param type $archive_template
 * @param type $multiple_settings
 */
function ic_product_listing_products($archive_template, $multiple_settings)
{
    global $post, $ic_is_home;
    if (is_home_archive() || !more_products() && is_custom_product_listing_page()) {
        if (get_query_var('paged')) {
            $paged = get_query_var('paged');
        } elseif (get_query_var('page')) {
            $paged = get_query_var('page');
        } else {
            $paged = 1;
        }
        $args = apply_filters('home_product_listing_query', array('post_type' => 'al_product', 'posts_per_page' => $multiple_settings['archive_products_limit'], 'paged' => $paged));
        query_posts($args);
        $ic_is_home = 1;
    }
    if ((is_tax() || is_search() || !is_ic_only_main_cats() || is_product_filters_active()) && more_products()) {
        do_action('before_product_list', $archive_template, $multiple_settings);
        $product_list = '';
        while (have_posts()) {
            the_post();
            $product_list .= get_catalog_template($archive_template, $post);
        }
        $product_list = apply_filters('product_list_ready', $product_list, $archive_template, 'auto_listing');
        echo '<div class="product-list responsive ' . $archive_template . ' ' . product_list_class($archive_template) . '">' . $product_list . '</div><span class="clear"></span>';
    } else {
        if (!is_product_filters_active() && is_search() && !more_products()) {
            echo '<p>' . __('Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'ecommerce-product-catalog') . '</p>';
            product_search_form();
        } else {
            if (is_product_filters_active() && !more_products()) {
                show_product_sort_bar();
                $filters = get_active_product_filters();
                if (isset($_GET['s'])) {
                    $filters[] = 's';
                }
                echo '<p>' . sprintf(__('Sorry, but nothing matched your search terms. Please try again with some different options or %sreset filters%s.', 'ecommerce-product-catalog'), '<a href="' . esc_url(remove_query_arg($filters)) . '">', '</a>') . '</p>';
            }
        }
    }
}