function getType() { parent::getType(); $this->processData(); $this->types = $this->getAllTerms(); echo "\n <div class='wpdreamsCustomTaxonomyTerm' id='wpdreamsCustomTaxonomyTerm-" . self::$_instancenumber . "'>\n <fieldset> \n <div style='margin:15px 30px;text-align: left;'>\n <label>Select the taxonomy: </label>\n <select name='" . $this->name . "_taxonomies' id='taxonomy_selector_" . self::$_instancenumber . "'> "; foreach ($this->types as $taxonomy => $v) { $tax = get_taxonomy($taxonomy); $custom_post_type = ""; if ($tax->object_type != null && $tax->object_type[0] != null) { $custom_post_type = $tax->object_type[0] . " - "; } echo "<option value='" . $taxonomy . "' taxonomy='" . $taxonomy . "'>" . $custom_post_type . $tax->labels->name . "</option>"; } echo "</select>\n <label>Show parent categories only <input class='hide-children' type='checkbox'></label>\n </div>\n <legend>" . $this->label . "</legend>"; echo '<div class="sortablecontainer" id="sortablecontainer' . self::$_instancenumber . '"> <div class="arrow-all-left"></div> <div class="arrow-all-right"></div> <p>Available terms for the selected taxonomy</p> <ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">'; if ($this->types != null && is_array($this->types)) { foreach ($this->types as $kk => $vv) { $vvHierarchical = array(); wd_sort_terms_hierarchicaly($vv, $vvHierarchical); $this->printTermsRecursive($vvHierarchical); } } echo "</ul></div>"; echo '<div class="sortablecontainer"><p>Drag here the terms you want to <b>' . $this->otype . '</b>!</p><ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">'; if ($this->selected != null && is_array($this->selected)) { foreach ($this->selected as $k => $v) { $term = get_term($v[0], $v[1]); echo '<li class="ui-state-default" term_id="' . $term->term_id . '" taxonomy="' . $term->taxonomy . '">' . $term->name . '</li>'; } } echo "</ul></div>"; echo "\n <input isparam=1 type='hidden' value='" . $this->data["value"] . "' name='" . $this->name . "'>\n <input type='hidden' value='wpdreamsCustomTaxonomyTerm' name='classname-" . $this->name . "'>"; echo "\n </fieldset>\n </div>"; }
//$_all_term_ids = wpdreams_get_all_term_ids(); //$_needed_terms = array_diff($_all_term_ids, $style['selected-excludeterms']); //$_invisible_terms = array_diff($_needed_terms, $style['selected-showterms']); $_close_fieldset = false; $_terms = array(); $visible_terms = array(); ob_start(); foreach ($style['selected-showterms'] as $taxonomy => $terms) { if (is_array($terms)) { $_needed_terms_full = get_terms($taxonomy, array('orderby' => $term_ordering[0], 'order' => $term_ordering[1], 'include' => $terms)); $_needed_terms_full = apply_filters('asp_fontend_get_taxonomy_terms', $_needed_terms_full, $taxonomy, array('orderby' => $term_ordering[0], 'order' => $term_ordering[1], 'include' => $terms)); //var_dump($taxonomy); $_needed_terms_sorted = array(); $needed_terms_flat = array(); if (w_isset_def($style['frontend_term_hierarchy'], 1) == 1) { wd_sort_terms_hierarchicaly($_needed_terms_full, $_needed_terms_sorted); wd_flatten_hierarchical_terms($_needed_terms_sorted, $needed_terms_flat); } else { $needed_terms_flat = $_needed_terms_full; } if ($style['showseparatefilterboxes'] != 0) { $_x_term = get_taxonomies(array("name" => $taxonomy), "objects"); //var_dump($_x_term); if (isset($_x_term[$taxonomy])) { $_tax_name = $_x_term[$taxonomy]->label; } ?> <fieldset> <legend><?php echo asp_icl_t("Taxonomy filter box text", $style['exsearchintaxonomiestext']) . " " . $_tax_name; ?>
/** * Recursively sort an array of taxonomy terms hierarchically. Child categories will be * placed under a 'children' member of their parent term. Handles missing parent categories as well. * * @param Array $cats taxonomy term objects to sort, use get_terms(..) * @param Array $into result array to put them in * @param integer $parentId the current parent ID to put them in * @param integer $depth the current recursion depth */ function wd_sort_terms_hierarchicaly(array &$cats, array &$into, $parentId = 0, $depth = 0) { foreach ($cats as $i => $cat) { if ($cat->parent == $parentId) { $into[$cat->term_id] = $cat; unset($cats[$i]); } } foreach ($into as $topCat) { $topCat->children = array(); wd_sort_terms_hierarchicaly($cats, $topCat->children, $topCat->term_id, $depth + 1); } // Try the remaining - the first parent might be excluded if (is_array($cats) && $depth == 0) { foreach ($cats as $topCat) { $topCat->children = array(); wd_sort_terms_hierarchicaly($cats, $topCat->children, $topCat->term_id, $depth + 1); } } // Still any remaining for some satanic reason? Put the rest to the end... if (is_array($cats) && $depth == 0) { foreach ($cats as $i => $cat) { $into[$cat->term_id] = $cat; unset($cats[$i]); } } }