* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio * @copyright Copyright (c) 2014, Ernest Marcinko */ class wpdreamsTaxonomySelect extends wpdreamsType { private $types, $selected, $otype, $v; private $exclude = array( 'product_visibility', 'product_type' ); function getType() { parent::getType(); $this->processData(); $this->types = $this->getAllTaxonomies(); echo "
" . $this->label . ""; echo '

Available taxonomies

    '; if ($this->types != null && is_array($this->types)) { foreach ($this->types as $tax) { $custom_post_type = ""; if ( isset($tax->object_type, $tax->object_type[0]) ) $custom_post_type = $tax->object_type[0] . " - "; if ( in_array($tax->name, $this->exclude) ) continue; if ($this->selected == null || !wd_in_array_r($tax->name, $this->selected)) { echo '
  • ' . $custom_post_type . $tax->labels->name . '[' . $tax->name . ']
  • '; } } } echo "
"; echo '
' . __('Drag here the taxonomies you want to ', 'ajax-search-pro') . '' . $this->otype . '!

    '; if ($this->selected != null && is_array($this->selected)) { foreach ($this->selected as $_tax) { $tax = get_taxonomy( $_tax ); $custom_post_type = ""; if (isset($tax->object_type) && $tax->object_type[0] != null) $custom_post_type = $tax->object_type[0] . " - "; if (isset($tax->name)) echo '
  • ' . $custom_post_type . $tax->labels->name . '[' . $tax->name . ']
  • '; } } echo "
"; echo " "; echo "
"; } function getAllTaxonomies() { $args = array( '_builtin' => false ); $output = 'objects'; // or objects $operator = 'and'; // 'and' or 'or' $taxonomies = get_taxonomies($args, $output, $operator); return $taxonomies; } function processData() { if (is_array($this->data) && isset($this->data['type']) && isset($this->data['value'])) { $this->otype = $this->data['type']; $this->v = str_replace("\n", "", $this->data["value"]); $this->data = $this->data["value"]; } else { $this->otype = "include"; $this->v = str_replace("\n", "", $this->data); } $this->selected = array(); if ($this->v != "") { $this->selected = explode("|", $this->v); } else { $this->selected = null; } } final function getData() { return $this->data; } final function getSelected() { return $this->selected; } } }