/**
  *	Add additionnal fields to the category edition form
  */
 public static function category_edit_fields()
 {
     $category_id = wpshop_tools::varSanitizer($_REQUEST["tag_ID"]);
     $category_meta_information = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id);
     $tpl_component = array();
     $category_thumbnail_preview = '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview" />';
     /*	Check if there is already a picture for the selected category	*/
     if (!empty($category_meta_information['wpshop_category_picture'])) {
         $image_post = wp_get_attachment_image($category_meta_information['wpshop_category_picture'], 'thumbnail', false, array('class' => 'category_thumbnail_preview'));
         $category_thumbnail_preview = !empty($image_post) ? $image_post : '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview" />';
     }
     $tpl_component['CATEGORY_DELETE_PICTURE_BUTTON'] = '';
     if (!empty($category_meta_information) && !empty($category_meta_information['wpshop_category_picture'])) {
         $tpl_component['CATEGORY_DELETE_PICTURE_BUTTON'] = '<a href="#" role="button" id="wps-delete-category-picture" class="wps-bton-second-mini-rounded">' . __('Delete the category picture', 'wpshop') . '</a> ';
     }
     $tpl_component['CATEGORY_PICTURE_ID'] = !empty($category_meta_information['wpshop_category_picture']) ? $category_meta_information['wpshop_category_picture'] : '';
     $tpl_component['CATEGORY_THUMBNAIL_PREVIEW'] = $category_thumbnail_preview;
     if (isset($_GET['tag_ID'])) {
         $tpl_component['CATEGORY_TAG_ID'] = $_GET['tag_ID'];
         $tpl_component['CATEGORY_FILTERABLE_ATTRIBUTES'] = '';
         $wpshop_category_products = wpshop_categories::get_product_of_category($_GET['tag_ID']);
         $filterable_attributes_list = array();
         foreach ($wpshop_category_products as $wpshop_category_product) {
             $elementId = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
             if (!empty($elementId)) {
                 $product_attributes = wpshop_attributes::get_attribute_list_for_item($elementId, $wpshop_category_product);
                 if (!empty($product_attributes)) {
                     foreach ($product_attributes as $key => $product_attribute) {
                         if (!empty($product_attribute) && !empty($product_attribute->is_filterable) && strtolower(__($product_attribute->is_filterable, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
                             if (!array_key_exists($product_attribute->attribute_id, $filterable_attributes_list)) {
                                 $filterable_attributes_list[$product_attribute->attribute_id] = $product_attribute;
                                 $sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_ID'] = $product_attribute->attribute_id;
                                 $sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_NAME'] = __($product_attribute->frontend_label, 'wpshop');
                                 if (!empty($category_meta_information) && !empty($category_meta_information['wpshop_category_filterable_attributes']) && array_key_exists($product_attribute->attribute_id, $category_meta_information['wpshop_category_filterable_attributes'])) {
                                     $sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_CHECKED'] = 'checked="checked"';
                                 } else {
                                     $sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_CHECKED'] = '';
                                 }
                                 $tpl_component['CATEGORY_FILTERABLE_ATTRIBUTES'] .= wpshop_display::display_template_element('wpshop_category_filterable_attribute_element', $sub_tpl_component, array(), 'admin');
                                 unset($sub_tpl_component);
                             }
                         }
                     }
                 }
             }
         }
     } else {
         $tpl_component['CATEGORY_TAG_ID'] = 1;
     }
     $output = wpshop_display::display_template_element('wpshop_category_edit_interface_admin', $tpl_component, array(), 'admin');
     echo $output;
 }
<?php 
        foreach ($category_tree as $sub_category_id => $sub_category_content) {
            $sub_category_definition = get_term($sub_category_id, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES);
            echo wpshop_categories::category_mini_output($sub_category_definition, $output_type);
        }
        ?>
					</div>
<?php 
    }
}
?>

<?php 
/*	Check what must be outputed on the page (Defined in plugin option)	*/
if (!is_array($wpshop_display_option['wpshop_display_cat_sheet_output']) || in_array('category_subproduct', $wpshop_display_option['wpshop_display_cat_sheet_output'])) {
    if (count(wpshop_categories::get_product_of_category($wp_query->queried_object->term_taxonomy_id)) > 0) {
        $category_has_content = true;
        $category_has_sub_content = true;
        echo do_shortcode('[wpshop_products cid="' . $wp_query->queried_object->term_id . '" type="' . $output_type . '"]');
    }
} elseif (is_array($wpshop_display_option['wpshop_display_cat_sheet_output']) && !in_array('category_subproduct', $wpshop_display_option['wpshop_display_cat_sheet_output'])) {
    $category_has_sub_content = true;
}
?>

<?php 
if (!$category_has_content || !$category_has_sub_content) {
    ?>
<!--	If there is nothing to output into this page -->
	<h2 class="category_content_part_title" ><?php 
    _e('There is nothing to output here', 'wpshop');
 /**
  * Save Products attribute values for Text attribute data for a products category
  * @param integer $category_id
  * @param std_object $attribute_def
  * @param array $current_category_child
  */
 function save_values_for_text_filterable_attribute($category_id, $attribute_def, $current_category_child)
 {
     $category_option = get_option('wpshop_product_category_' . $category_id);
     $category_product_ids = wpshop_categories::get_product_of_category($category_id);
     /** If there are sub-categories take all products of sub-categories **/
     $list_values = array();
     if (!empty($current_category_children)) {
         foreach ($current_category_children as $current_category_child) {
             $sub_categories_product_ids = wpshop_categories::get_product_of_category($current_category_child->term_taxonomy_id);
             if (!empty($sub_categories_product_ids)) {
                 foreach ($sub_categories_product_ids as $sub_categories_product_id) {
                     if (!in_array($sub_categories_product_id, $category_product_ids)) {
                         $category_product_ids[] = $sub_categories_product_id;
                     }
                 }
             }
         }
     }
     if (!empty($category_option) && !empty($category_option['wpshop_category_filterable_attributes']) && !empty($category_option['wpshop_category_filterable_attributes'][$attribute_def->id])) {
         if (!empty($category_product_ids)) {
             $product_data = '';
             foreach ($category_product_ids as $category_product_id) {
                 $product_postmeta = get_post_meta($category_product_id, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true);
                 $product_data = !empty($product_postmeta[$attribute_def->code]) ? $product_postmeta[$attribute_def->code] : '';
                 if (!in_array($product_data, $list_values)) {
                     $list_values[] = $product_data;
                     if (!empty($product_data)) {
                         $category_option['wpshop_category_filterable_attributes'][$attribute_def->id][] = $product_data;
                     }
                 }
             }
         }
     }
     update_option('wpshop_product_category_' . $category_id, $category_option);
 }