/**
  * Display product sub categories as thumbnails.
  *
  * @access public
  * @subpackage	Loop
  * @param array $args
  * @return null|boolean
  */
 function woocommerce_product_subcategories($args = array())
 {
     global $wp_query;
     $defaults = array('before' => '', 'after' => '', 'force_display' => false);
     $args = wp_parse_args($args, $defaults);
     extract($args);
     // Main query only
     if (!is_main_query() && !$force_display) {
         return;
     }
     // Don't show when filtering, searching or when on page > 1 and ensure we're on a product archive
     if (is_search() || is_filtered() || is_paged() || !is_product_category() && !is_shop()) {
         return;
     }
     // Check categories are enabled
     if (is_shop() && get_option('woocommerce_shop_page_display') == '') {
         return;
     }
     // Find the category + category parent, if applicable
     $term = get_queried_object();
     $parent_id = empty($term->term_id) ? 0 : $term->term_id;
     if (is_product_category()) {
         $display_type = get_woocommerce_term_meta($term->term_id, 'display_type', true);
         switch ($display_type) {
             case 'products':
                 return;
                 break;
             case '':
                 if (get_option('woocommerce_category_archive_display') == '') {
                     return;
                 }
                 break;
         }
     }
     // NOTE: using child_of instead of parent - this is not ideal but due to a WP bug ( http://core.trac.wordpress.org/ticket/15626 ) pad_counts won't work
     $product_categories = get_categories(apply_filters('woocommerce_product_subcategories_args', array('parent' => $parent_id, 'menu_order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'taxonomy' => 'product_cat', 'pad_counts' => 1)));
     if (!apply_filters('woocommerce_product_subcategories_hide_empty', false)) {
         $product_categories = wp_list_filter($product_categories, array('count' => 0), 'NOT');
     }
     $product_category_found = false;
     if ($product_categories) {
         echo $before;
         foreach ($product_categories as $category) {
             wc_get_template('content-product_cat.php', array('category' => $category));
         }
         // If we are hiding products disable the loop and pagination
         if (is_product_category()) {
             $display_type = get_woocommerce_term_meta($term->term_id, 'display_type', true);
             switch ($display_type) {
                 case 'subcategories':
                     $wp_query->post_count = 0;
                     $wp_query->max_num_pages = 0;
                     break;
                 case '':
                     if (get_option('woocommerce_category_archive_display') == 'subcategories') {
                         $wp_query->post_count = 0;
                         $wp_query->max_num_pages = 0;
                     }
                     break;
             }
         }
         if (is_shop() && get_option('woocommerce_shop_page_display') == 'subcategories') {
             $wp_query->post_count = 0;
             $wp_query->max_num_pages = 0;
         }
         echo $after;
     }
     return true;
 }
示例#2
0
    if ($port_details) {
        $ext_tables = array_merge($ext_tables, array('ipv4_addresses', 'ipv6_addresses', 'pseudowires'));
        // Here stored ifIndex!
        $ports_has_ext['ports_pagp'] = dbFetchColumn("SELECT `pagpGroupIfIndex` FROM `ports`   WHERE `device_id` = ? GROUP BY `pagpGroupIfIndex`", array($device['device_id']));
        $ports_has_ext['ports_stack_low'] = dbFetchColumn("SELECT `port_id_low`  FROM `ports_stack` WHERE `device_id` = ? AND `port_id_high` != 0 GROUP BY `port_id_low`", array($device['device_id']));
        $ports_has_ext['ports_stack_high'] = dbFetchColumn("SELECT `port_id_high` FROM `ports_stack` WHERE `device_id` = ? AND `port_id_low`  != 0 GROUP BY `port_id_high`", array($device['device_id']));
    }
    $where = ' IN (' . implode(',', array_keys($port_cache)) . ')';
    foreach ($ext_tables as $table) {
        // Here stored port_id!
        $ports_has_ext[$table] = dbFetchColumn("SELECT `port_id` FROM `{$table}` WHERE `port_id` {$where} GROUP BY `port_id`");
    }
    $ports_has_ext['links'] = dbFetchColumn("SELECT `local_port_id` FROM `links` WHERE `local_port_id` {$where} AND `remote_port_id` != 0 GROUP BY `local_port_id`");
    $ports_vlan_cache = array();
    // Cache port vlans
    foreach (dbFetchRows('SELECT * FROM `ports_vlans` AS PV LEFT JOIN vlans AS V ON PV.`vlan` = V.`vlan_vlan` AND PV.`device_id` = V.`device_id`
                       WHERE PV.`device_id` = ? ORDER BY PV.`vlan`', array($device['device_id'])) as $entry) {
        $ports_vlan_cache[$entry['port_id']][$entry['vlan']] = $entry;
    }
    foreach ($ports as $port) {
        if (is_filtered()) {
            continue;
        }
        include "includes/print-interface.inc.php";
        $i++;
    }
    echo "</table>";
}
$pagetitle[] = "Ports";
unset($ports_has_ext, $where, $ext_tables, $ports_vlan_cache);
// EOF
/**
 * Display product sub categories as title and List
 *
 * @subpackage  Loop
 * @param array $args
 * @return null|boolean
 */
function woocommerce_product_subcategories($args = array())
{
    global $wp_query;
    $defaults = array('before' => '', 'after' => '', 'force_display' => false);
    $args = wp_parse_args($args, $defaults);
    extract($args);
    // Main query only
    if (!is_main_query() && !$force_display) {
        return;
    }
    // Don't show when filtering, searching or when on page > 1 and ensure we're on a product archive
    if (is_search() || is_filtered() || is_paged() || !is_product_category() && !is_shop()) {
        return;
    }
    // Check categories are enabled
    if (is_shop() && get_option('woocommerce_shop_page_display') == '') {
        return;
    }
    // Find the category + category parent, if applicable
    $term = get_queried_object();
    $parent_id = empty($term->term_id) ? 0 : $term->term_id;
    if (is_product_category()) {
        $display_type = get_woocommerce_term_meta($term->term_id, 'display_type', true);
        switch ($display_type) {
            case 'products':
                return;
                break;
            case '':
                if (get_option('woocommerce_category_archive_display') == '') {
                    return;
                }
                break;
        }
    }
    // NOTE: using child_of instead of parent - this is not ideal but due to a WP bug ( http://core.trac.wordpress.org/ticket/15626 ) pad_counts won't work
    $product_categories = get_categories(apply_filters('woocommerce_product_subcategories_args', array('parent' => $parent_id, 'menu_order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'taxonomy' => 'product_cat', 'pad_counts' => 1)));
    if (!apply_filters('woocommerce_product_subcategories_hide_empty', false)) {
        $product_categories = wp_list_filter($product_categories, array('count' => 0), 'NOT');
    }
    if ($product_categories) {
        echo $before;
        foreach ($product_categories as $category) {
            echo '<h2 class="col-xs-12">' . $category->name . '</h2>';
            $args = array('posts_per_page' => 5, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'tax_query' => array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $category->term_taxonomy_id)));
            $the_query = new WP_Query($args);
            if ($the_query->have_posts()) {
                while ($the_query->have_posts()) {
                    $the_query->the_post();
                    wc_get_template_part('taxonomy', 'product_list-diving');
                }
            }
        }
        // // If we are hiding products disable the loop and pagination
        // if ( is_product_category() ) {
        //     $display_type = get_woocommerce_term_meta( $term->term_id, 'display_type', true );
        //     switch ( $display_type ) {
        //         case 'subcategories' :
        //             $wp_query->post_count    = 0;
        //             $wp_query->max_num_pages = 0;
        //         break;
        //         case '' :
        //             if ( get_option( 'woocommerce_category_archive_display' ) == 'subcategories' ) {
        //                 $wp_query->post_count    = 0;
        //                 $wp_query->max_num_pages = 0;
        //             }
        //         break;
        //     }
        // }
        // if ( is_shop() && get_option( 'woocommerce_shop_page_display' ) == 'subcategories' ) {
        //     $wp_query->post_count    = 0;
        //     $wp_query->max_num_pages = 0;
        // }
        echo $after;
        return true;
    }
}
示例#4
0
 public static function is_filtered()
 {
     return self::exists() && is_filtered();
 }