function getType() { parent::getType(); $this->processData(); $this->types = get_post_types(array('_builtin' => false)); echo "\n <div class='wpdreamsCustomPostTypesEditable' id='wpdreamsCustomPostTypesEditable-" . self::$_instancenumber . "'>\n <fieldset>\n <legend>" . $this->label . "</legend>"; echo '<div class="sortablecontainer" id="sortablecontainer' . self::$_instancenumber . '"> <p>Available post types</p><ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">'; if ($this->types != null && is_array($this->types)) { foreach ($this->types as $k => $v) { if ($this->selected == null || !wd_in_array_r($v, $this->selected)) { echo '<li class="ui-state-default ui-left" style="background: #ddd;"> <label>' . $k . '</label> <input type="text" value="' . $k . '"/> </li>'; } } } echo "</ul></div>"; echo '<div class="sortablecontainer"><p>Drag here the post types you want to use!</p><ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">'; if ($this->selected != null && is_array($this->selected)) { foreach ($this->selected as $k => $v) { echo '<li class="ui-state-default ui-left" style="background: #ddd;"> <label>' . $v[0] . '</label> <input type="text" value="' . $v[1] . '"/> </li>'; } } echo "</ul></div>"; echo "\n <input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>"; echo "\n <input type='hidden' value='wpdreamsCustomPostTypesEditable' name='classname-" . $this->name . "'>"; echo "\n </fieldset>\n </div>"; }
$_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; ?> </legend> <div class='categoryfilter asp_sett_scroll'> <?php } foreach ($needed_terms_flat as $k => $term) { $checked = wd_in_array_r($term->term_id, $style['selected-excludeterms']) ? '' : 'checked="checked"'; ?> <div class="asp_option_cat asp_option_cat_level-<?php echo $term->level; ?> " asp_cat_parent="<?php echo $term->parent; ?> "> <div class="option"> <input type="checkbox" value="<?php echo $term->term_id; ?> " id="<?php echo $id; ?>
function getType() { parent::getType(); $this->processData(); $this->types = $this->getAllTerms(); echo "\r\n <div class='wpdreamsCustomTaxonomyTerm'>\r\n <fieldset> \r\n <div style='margin:15px 30px;text-align: left;'>\r\n <label>Select the taxonomy: </label>\r\n <select name='" . $this->name . "_taxonomies' id='" . $this->name . "_taxonomies'> "; 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>\r\n </div>\r\n <legend>" . $this->label . "</legend>"; echo '<div class="sortablecontainer"><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) { foreach ($vv as $k => $term) { if ($this->selected == null || !wd_in_array_r($term->term_id, $this->selected)) { echo '<li class="ui-state-default" term_id="' . $term->term_id . '" taxonomy="' . $term->taxonomy . '">' . $term->name . '</li>'; } } } } 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 "\r\n <input isparam=1 type='hidden' value='" . $this->data["value"] . "' name='" . $this->name . "'>\r\n <input type='hidden' value='wpdreamsCustomTaxonomyTerm' name='classname-" . $this->name . "'>"; ?> <script type='text/javascript'> (function ($) { $(document).ready(function () { $("#sortable<?php echo self::$_instancenumber; ?> , #sortable_conn<?php echo self::$_instancenumber; ?> ").sortable({ connectWith: ".connectedSortable" }, { update: function (event, ui) { parent = $(ui.item).parent(); while (!parent.hasClass('wpdreamsCustomTaxonomyTerm')) { parent = $(parent).parent(); } var items = $('ul[id*=sortable_conn] li', parent); var hidden = $('input[name=<?php echo $this->name; ?> ]', parent); var val = ""; items.each(function () { val += "|" + $(this).attr('term_id') + "-" + $(this).attr('taxonomy'); }); val = val.substring(1); hidden.val(val); } }).disableSelection(); $("#<?php echo $this->name; ?> _taxonomies").change(function () { var taxonomy = $(this).val(); $("li", "#sortable<?php echo self::$_instancenumber; ?> ").css('display', 'none'); $("li[taxonomy=" + taxonomy + "]", "#sortable<?php echo self::$_instancenumber; ?> ").css('display', 'block'); }); $("#<?php echo $this->name; ?> _taxonomies").change(); }); }(jQuery)); </script> <?php echo "\r\n </fieldset>\r\n </div>"; }
function wd_in_array_r($needle, $haystack, $strict = true) { foreach ($haystack as $item) { if (($strict ? $item === $needle : $item == $needle) || is_array($item) && wd_in_array_r($needle, $item, $strict)) { return true; } } return false; }
function getType() { parent::getType(); $this->processData(); $this->types = get_post_types(array('_builtin' => false)); echo "\r\n <div class='wpdreamsCustomPostTypesEditable'>\r\n <fieldset>\r\n <legend>" . $this->label . "</legend>"; echo '<div class="sortablecontainer"><p>Available post types</p><ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">'; if ($this->types != null && is_array($this->types)) { foreach ($this->types as $k => $v) { if ($this->selected == null || !wd_in_array_r($v, $this->selected)) { echo '<li class="ui-state-default ui-left" style="background: #ddd;"> <label>' . $k . '</label> <input type="text" value="' . $k . '"/> </li>'; } } } echo "</ul></div>"; echo '<div class="sortablecontainer"><p>Drag here the post types you want to use!</p><ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">'; if ($this->selected != null && is_array($this->selected)) { foreach ($this->selected as $k => $v) { echo '<li class="ui-state-default ui-left" style="background: #ddd;"> <label>' . $v[0] . '</label> <input type="text" value="' . $v[1] . '"/> </li>'; } } echo "</ul></div>"; echo "\r\n <input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>"; echo "\r\n <input type='hidden' value='wpdreamsCustomPostTypesEditable' name='classname-" . $this->name . "'>"; ?> <script> (function ($) { $(document).ready(function () { $("#sortable_conn<?php echo self::$_instancenumber; ?> li input").keyup(function () { parent = $(this).parent(); while (!parent.hasClass('wpdreamsCustomPostTypesEditable')) { parent = $(parent).parent(); } var items = $('ul[id*=sortable_conn] li', parent); var hidden = $('input[name=<?php echo $this->name; ?> ]', parent); var val = ""; items.each(function () { val += "|" + $('label', this).html() + ";" + $('input', this).val(); }); val = val.substring(1); hidden.val(val); }); $("#sortable<?php echo self::$_instancenumber; ?> , #sortable_conn<?php echo self::$_instancenumber; ?> ").sortable({ connectWith: ".connectedSortable" }, { update: function (event, ui) { $("#sortable_conn<?php echo self::$_instancenumber; ?> li input").keyup(function () { parent = $(this).parent(); while (!parent.hasClass('wpdreamsCustomPostTypesEditable')) { parent = $(parent).parent(); } var items = $('ul[id*=sortable_conn] li', parent); var hidden = $('input[name=<?php echo $this->name; ?> ]', parent); var val = ""; console.log(val); items.each(function () { val += "|" + $('label', this).html() + ";" + $('input', this).val(); }); val = val.substring(1); hidden.val(val); }); if ($("#sortable_conn<?php echo self::$_instancenumber; ?> li input").length != 0) { $("#sortable_conn<?php echo self::$_instancenumber; ?> li input").keyup(); } else { $("#sortable_conn<?php echo self::$_instancenumber; ?> ").each(function () { parent = $(this).parent(); while (!parent.hasClass('wpdreamsCustomPostTypesEditable')) { parent = $(parent).parent(); } var hidden = $('input[name=<?php echo $this->name; ?> ]', parent); hidden.val(""); }); } } }); }); }(jQuery)); </script> <?php echo "\r\n </fieldset>\r\n </div>"; }