Ejemplo n.º 1
0
/**
* Output breadcrumbs if configured
* @return None - outputs breadcrumb HTML
*/
function wpsc_output_breadcrumbs($options = null)
{
    // Defaults
    $options = apply_filters('wpsc_output_breadcrumbs_options', $options);
    $options = wp_parse_args((array) $options, array('before-breadcrumbs' => '<div class="wpsc-breadcrumbs">', 'after-breadcrumbs' => '</div>', 'before-crumb' => '', 'after-crumb' => '', 'crumb-separator' => ' &raquo; ', 'show_home_page' => true, 'show_products_page' => true, 'echo' => true));
    $output = '';
    $products_page_id = wpec_get_the_post_id_by_shortcode('[productspage]');
    $products_page = get_post($products_page_id);
    if (!wpsc_has_breadcrumbs()) {
        return;
    }
    $filtered_products_page = array('url' => get_option('product_list_url'), 'name' => apply_filters('the_title', $products_page->post_title));
    $filtered_products_page = apply_filters('wpsc_change_pp_breadcrumb', $filtered_products_page);
    // Home Page Crumb
    // If home if the same as products page only show the products-page link and not the home link
    if (get_option('page_on_front') != $products_page_id && $options['show_home_page']) {
        $output .= $options['before-crumb'];
        $output .= '<a class="wpsc-crumb" id="wpsc-crumb-home" href="' . get_option('home') . '">' . get_option('blogname') . '</a>';
        $output .= $options['after-crumb'];
    }
    // Products Page Crumb
    if ($options['show_products_page']) {
        if (!empty($output)) {
            $output .= $options['crumb-separator'];
        }
        $output .= $options['before-crumb'];
        $output .= '<a class="wpsc-crumb" id="wpsc-crumb-' . $products_page_id . '" href="' . $filtered_products_page['url'] . '">' . $filtered_products_page['name'] . '</a>';
        $output .= $options['after-crumb'];
    }
    // Remaining Crumbs
    while (wpsc_have_breadcrumbs()) {
        wpsc_the_breadcrumb();
        if (!empty($output)) {
            $output .= $options['crumb-separator'];
        }
        $output .= $options['before-crumb'];
        if (wpsc_breadcrumb_url()) {
            $output .= '<a class="wpsc-crumb" id="wpsc-crumb-' . wpsc_breadcrumb_slug() . '" href="' . wpsc_breadcrumb_url() . '">' . wpsc_breadcrumb_name() . '</a>';
        } else {
            $output .= '<span class="wpsc-crumb" id="wpsc-crumb-' . wpsc_breadcrumb_slug() . '">' . wpsc_breadcrumb_name() . '</span>';
        }
        $output .= $options['after-crumb'];
    }
    $output = $options['before-breadcrumbs'] . apply_filters('wpsc_output_breadcrumbs', $output, $options) . $options['after-breadcrumbs'];
    if ($options['echo']) {
        echo $output;
    } else {
        return $output;
    }
}
Ejemplo n.º 2
0
/**
* Output breadcrumbs if configured
* @return None - outputs breadcrumb HTML
*/
function wpsc_output_breadcrumbs($options = array())
{
    $products_page_id = wpec_get_the_post_id_by_shortcode('[productspage]');
    $products_page = get_post($products_page_id);
    if (!wpsc_has_breadcrumbs()) {
        return;
    }
    $filtered_products_page = array('url' => get_option('product_list_url'), 'name' => $products_page->post_title);
    $filtered_products_page = apply_filters('wpsc_change_pp_breadcrumb', $filtered_products_page);
    // If home if the same as products apge only show the products-page link and not the home link
    if (get_option('page_on_front') != $products_page_id) {
        echo isset($options['before-breadcrumbs']) ? $options['before-breadcrumbs'] : '<div class="wpsc-breadcrumbs">';
        echo isset($options['before-crumb']) ? $options['before-crumb'] : '';
        echo '<a class="wpsc-crumb" id="wpsc-crumb-home" href="' . get_option('home') . '">' . get_option('blogname') . '</a>';
        echo isset($options['after-crumb']) ? $options['after-crumb'] : '';
        echo isset($options['crumb-separator']) ? $options['crumb-separator'] : ' &raquo; ';
    }
    echo isset($options['before-crumb']) ? $options['before-crumb'] : '';
    echo '<a class="wpsc-crumb" id="wpsc-crumb-' . $products_page_id . '" href="' . $filtered_products_page['url'] . '">' . $filtered_products_page['name'] . '</a>';
    echo isset($options['after-crumb']) ? $options['after-crumb'] : '';
    while (wpsc_have_breadcrumbs()) {
        wpsc_the_breadcrumb();
        echo isset($options['crumb-separator']) ? $options['crumb-separator'] : ' &raquo; ';
        echo isset($options['before-crumb']) ? $options['before-crumb'] : '';
        if (wpsc_breadcrumb_url()) {
            echo '<a class="wpsc-crumb" id="wpsc-crumb-' . wpsc_breadcrumb_slug() . '" href="' . wpsc_breadcrumb_url() . '">' . wpsc_breadcrumb_name() . '</a>';
        } else {
            echo wpsc_breadcrumb_name();
        }
        echo isset($options['after-crumb']) ? $options['after-crumb'] : '';
    }
    if (isset($options['after-breadcrumbs'])) {
        echo $options['after-breadcrumbs'];
    } else {
        echo '</div>';
    }
}
Ejemplo n.º 3
0
/**
 * wpsc display products function
 * Used to determine whether to display products on the page
 * @return boolean - true for yes, false for no
 */
function wpsc_display_products()
{
    global $post;
    $product_page_id = wpec_get_the_post_id_by_shortcode('[productspage]');
    //we have to display something, if we are not displaying categories, then we must display products
    $output = true;
    if (wpsc_display_categories()) {
        if (get_option('wpsc_default_category') == 'list' && $post->ID == $product_page_id) {
            $output = false;
        }
        if (isset($_GET['range']) || isset($_GET['category'])) {
            $output = true;
        }
    }
    return $output;
}
Ejemplo n.º 4
0
/**
 * wpsc_generate_product_query function.
 *
 * @access public
 * @param mixed $query
 * @return void
 */
function wpsc_generate_product_query($query)
{
    global $wp_query;
    $prod_page = wpec_get_the_post_id_by_shortcode('[productspage]');
    $prod_page = get_post($prod_page);
    remove_filter('pre_get_posts', 'wpsc_generate_product_query', 11);
    $query->query_vars['taxonomy'] = null;
    $query->query_vars['term'] = null;
    // default product selection
    if ($query->query_vars['pagename'] != '') {
        $query->query_vars['post_type'] = 'wpsc-product';
        $query->query_vars['pagename'] = '';
        $query->is_page = false;
        $query->is_tax = false;
        $query->is_archive = true;
        $query->is_singular = false;
        $query->is_single = false;
    }
    // If wpsc_item is not null, we are looking for a product or a product category, check for category
    if (isset($query->query_vars['wpsc_item']) && $query->query_vars['wpsc_item'] != '') {
        $test_term = get_term_by('slug', $query->query_vars['wpsc_item'], 'wpsc_product_category');
        if ($test_term->slug == $query->query_vars['wpsc_item']) {
            // if category exists (slug matches slug), set products to value of wpsc_item
            $query->query_vars['products'] = $query->query_vars['wpsc_item'];
        } else {
            // otherwise set name to value of wpsc_item
            $query->query_vars['name'] = $query->query_vars['wpsc_item'];
        }
    }
    if (isset($query->query_vars['products']) && $query->query_vars['products'] != null && $query->query_vars['name'] != null) {
        unset($query->query_vars['taxonomy']);
        unset($query->query_vars['term']);
        $query->query_vars['post_type'] = 'wpsc-product';
        $query->is_tax = false;
        $query->is_archive = true;
        $query->is_singular = false;
        $query->is_single = false;
    }
    if (isset($wp_query->query_vars['wpsc_product_category']) && !isset($wp_query->query_vars['wpsc-product'])) {
        $query->query_vars['wpsc_product_category'] = $wp_query->query_vars['wpsc_product_category'];
        $query->query_vars['taxonomy'] = $wp_query->query_vars['taxonomy'];
        $query->query_vars['term'] = $wp_query->query_vars['term'];
    } elseif ('' != ($default_category = get_option('wpsc_default_category')) && !isset($wp_query->query_vars['wpsc-product'])) {
        $default_term = get_term($default_category, 'wpsc_product_category');
        if (!empty($default_term) && empty($wp_query->query_vars['category_name'])) {
            $query->query_vars['taxonomy'] = 'wpsc_product_category';
            $query->query_vars['term'] = $default_term->slug;
            $query->is_tax = true;
        } elseif (isset($wp_query->query_vars['name']) && $wp_query->is_404 && $wp_query->query_vars['category_name'] != $prod_page->post_name) {
            unset($query->query_vars['taxonomy']);
            unset($query->query_vars['term']);
            $query->query_vars['wpsc-product'] = $wp_query->query_vars['name'];
            $query->query_vars['name'] = $wp_query->query_vars['name'];
        } else {
            $query->is_tax = true;
            $term = get_term_by('slug', $wp_query->query_vars['name'], 'wpsc_product_category');
            if (!empty($term)) {
                $query->query_vars['taxonomy'] = 'wpsc_product_category';
                $query->query_vars['wpsc_product_category__in'] = array($term->term_taxonomy_id);
                $query->query_vars['wpsc_product_category'] = $wp_query->query_vars['name'];
                $query->query_vars['term'] = $wp_query->query_vars['name'];
            } elseif (is_numeric($default_category)) {
                $query->query_vars['taxonomy'] = 'wpsc_product_category';
            } else {
                $query->is_tax = false;
            }
        }
    }
    //If Product Tag Taxonomy
    if (isset($wp_query->query_vars['product_tag']) && $wp_query->query_vars['product_tag']) {
        $query->query_vars['product_tag'] = $wp_query->query_vars['product_tag'];
        $query->query_vars['term'] = $wp_query->query_vars['term'];
        $query->query_vars['taxonomy'] = 'product_tag';
        $query->is_tax = true;
    }
    if (1 == get_option('use_pagination')) {
        $query->query_vars['posts_per_page'] = get_option('wpsc_products_per_page');
        if (isset($_GET['items_per_page'])) {
            if (is_numeric($_GET['items_per_page'])) {
                $query->query_vars['posts_per_page'] = (int) $_GET['items_per_page'];
            } elseif ($_GET['items_per_page'] == 'all') {
                $query->query_vars['posts_per_page'] = -1;
                $query->query_vars['nopaging'] = 1;
            }
        }
    } else {
        $query->query_vars['posts_per_page'] = -1;
        $query->query_vars['nopaging'] = 1;
    }
    if ($query->is_tax == true) {
        new wpsc_products_by_category($query);
    }
    return $query;
}
Ejemplo n.º 5
0
 function wpsc_gc_start_search_query()
 {
     global $wp_query, $wpsc_query;
     $product_page_id = wpec_get_the_post_id_by_shortcode('[productspage]');
     $post = get_post($product_page_id);
     $wp_query = new WP_Query('pagename=' . $post->post_name);
     add_action('pre_get_posts', 'wpsc_gc_live_search_pre_get_posts');
     wpsc_start_the_query();
     remove_action('pre_get_posts', 'wpsc_gc_live_search_pre_get_posts');
     list($wp_query, $wpsc_query) = array($wpsc_query, $wp_query);
     // swap the wpsc_query object
     $GLOBALS['nzshpcrt_activateshpcrt'] = true;
 }
Ejemplo n.º 6
0
function is_products_page()
{
    global $post;
    $product_page_id = wpec_get_the_post_id_by_shortcode('[productspage]');
    if ($post->ID == $product_page_id) {
        return true;
    } else {
        return false;
    }
}