コード例 #1
0
 /**
  * Displays the widget in the sidebar.
  *
  * @param array $args     Sidebar arguments.
  * @param array $instance The instance.
  *
  * @return bool|void
  */
 public function widget($args, $instance)
 {
     // Get the best selling products from the transient
     $cache = get_transient(Core::WIDGET_CACHE);
     // If cached get from the cache
     if (isset($cache[$args['widget_id']])) {
         echo $cache[$args['widget_id']];
         return;
     }
     // Otherwise Start buffering and output the Widget
     ob_start();
     // Set the widget title
     $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : __('Product Categories', 'jigoshop'), $instance, $this->id_base);
     // Get options
     $count = isset($instance['count']) ? $instance['count'] : false;
     $is_hierarchical = isset($instance['hierarchical']) ? $instance['hierarchical'] : false;
     $is_dropdown = isset($instance['dropdown']) ? $instance['dropdown'] : false;
     $query = array('orderby' => 'name', 'show_count' => $count, 'hierarchical' => $is_hierarchical, 'taxonomy' => Core\Types::PRODUCT_CATEGORY, 'title_li' => null);
     if (Pages::isProduct()) {
         global $post;
         $categories = get_the_terms($post->ID, Core\Types::PRODUCT_CATEGORY);
         if (!empty($categories)) {
             $category = reset($categories);
             $query['current_category'] = apply_filters('jigoshop_product_cat_widget_terms', $category->term_id, $categories);
         }
     }
     if ($is_dropdown) {
         global $wp_query;
         $query = array('pad_counts' => 1, 'hierarchical' => $is_hierarchical, 'hide_empty' => true, 'show_count' => $count, 'selected' => isset($wp_query->query[Core\Types::PRODUCT_CATEGORY]) ? $wp_query->query[Core\Types::PRODUCT_CATEGORY] : '');
         $terms = get_terms(Core\Types::PRODUCT_CATEGORY, $query);
         if (!$terms) {
             return;
         }
         $walker = new CategoryWalker(self::$wp, 'widget/product_categories/item');
         Render::output('widget/product_categories/dropdown', array_merge($args, array('title' => $title, 'query' => $query, 'walker' => $walker, 'terms' => $terms, 'value' => $query['selected'], 'shopUrl' => get_permalink(self::$options->getPageId(Pages::SHOP)))));
     } else {
         Render::output('widget/product_categories/list', array_merge($args, array('title' => $title, 'args' => $query)));
     }
     // Flush output buffer and save to transient cache
     $cache[$args['widget_id']] = ob_get_flush();
     set_transient(Core::WIDGET_CACHE, $cache, 3600 * 3);
     // 3 hours ahead
 }
コード例 #2
0
ファイル: PageResolver.php プロジェクト: jigoshop/Jigoshop2
 public function getPage(Container $container)
 {
     if (!Pages::isJigoshop() && !Pages::isAjax()) {
         return $container->get('jigoshop.page.dummy');
     }
     $this->wp->doAction('jigoshop\\page_resolver\\before');
     if (Pages::isCheckoutThankYou()) {
         return $container->get('jigoshop.page.checkout.thank_you');
     }
     if (Pages::isCheckoutPay()) {
         return $container->get('jigoshop.page.checkout.pay');
     }
     if (Pages::isCheckout()) {
         return $container->get('jigoshop.page.checkout');
     }
     if (Pages::isCart()) {
         return $container->get('jigoshop.page.cart');
     }
     if (Pages::isProductCategory()) {
         return $container->get('jigoshop.page.product_category_list');
     }
     if (Pages::isProductTag()) {
         return $container->get('jigoshop.page.product_tag_list');
     }
     if (Pages::isProductList()) {
         return $container->get('jigoshop.page.product_list');
     }
     if (Pages::isProduct()) {
         return $container->get('jigoshop.page.product');
     }
     if (Pages::isAccountOrders()) {
         return $container->get('jigoshop.page.account.orders');
     }
     if (Pages::isAccountEditAddress()) {
         return $container->get('jigoshop.page.account.edit_address');
     }
     if (Pages::isAccountChangePassword()) {
         return $container->get('jigoshop.page.account.change_password');
     }
     if (Pages::isAccount()) {
         return $container->get('jigoshop.page.account');
     }
 }
コード例 #3
0
ファイル: JigoshopInit.php プロジェクト: jigoshop/Jigoshop2
 /**
  *
  */
 private function disableRelationLinks()
 {
     $disable = function ($value) {
         if (\Jigoshop\Frontend\Pages::isProduct()) {
             return false;
         }
         return $value;
     };
     add_filter('index_rel_link', $disable);
     add_filter('parent_post_rel_link', $disable);
     add_filter('start_post_rel_link', $disable);
     add_filter('previous_post_rel_link', $disable);
     add_filter('next_post_rel_link', $disable);
 }