spacing !== false) $f .= $this->spacing;
$f .= '>';
$filtertext = esc_attr__('Filter Categories', ESG_TEXTDOMAIN);
if (array_key_exists('filter' . $type, $this->filter_dropdown_text)) {
$filtertext = $this->filter_dropdown_text['filter' . $type];
}
if ($listing == 'dropdown') {
// 2.2.5
$f .= '
';
} else {
// 2.2.5
$f .= '
' . $filtertext . '
';
}
$filters_html = array();
if ($is_post && !empty($do_show) && is_array($do_show)) {
//we are a post based grid
foreach ($do_show as $string_id) {
$fraw = explode('_', $string_id);
if (count($fraw) > 1) {
$f_id = array_pop($fraw);
} else {
$f_id = $fraw[0];
}
if (Essential_Grid_Wpml::is_wpml_exists() && isset($sitepress)) {
$t_id = @icl_object_id($f_id, implode('_', $fraw), true, ICL_LANGUAGE_CODE);
if (!empty($t_id)) $f_id = $t_id;
}
if (isset($this->filter[$f_id])) {
$filter_text = ($demo) ? self::translate_demo_filter($this->filter[$f_id]['slug']) : Essential_Grid_Wpml::strip_category_additions($this->filter[$f_id]['name']);
// 2.2.5
// sanitize multi-select custom meta
if (strpos($filter_text, "['") !== false && strpos($filter_text, "']") !== false) {
$filter_text = preg_replace("/\[\'|\'\]/", '', $filter_text);
$filter_text = preg_replace("/\'\,\'/", ' & ', $filter_text);
}
$_v = Essential_Grid_Base::sanitize_utf8_to_unicode($this->filter[$f_id]['slug']);
$filter = get_category_by_slug($this->filter[$f_id]['slug']);
$sel = (in_array($_v, $this->filter_start_select)) ? ' selected' : '';
$parent_id = (isset($this->filter[$f_id]['parent']) && intval($this->filter[$f_id]['parent']) > 0) ? $this->filter[$f_id]['parent'] : 0;
$parent = ($parent_id > 0) ? ' data-pid="' . $parent_id . '"' : '';
$filters_html[$filter_text] = '
' . $filter_text . '
';
}
}
} else {
if (!empty($do_show) && is_array($do_show)) {
foreach ($do_show as $slug) {
if (!empty($this->filter) && isset($this->filter[$slug])) {
$filter = $this->filter[$slug];
$filter_text = ($demo) ? self::translate_demo_filter($filter['slug']) : Essential_Grid_Wpml::strip_category_additions($filter['name']);
// 2.2.5
// sanitize multi-select custom meta
if (strpos($filter_text, "['") !== false && strpos($filter_text, "']") !== false) {
$filter_text = preg_replace("/\[\'|\'\]/", '', $filter_text);
$filter_text = preg_replace("/\'\,\'/", ' & ', $filter_text);
}
$_v = Essential_Grid_Base::sanitize_utf8_to_unicode($filter['slug']);
$sel = (in_array($_v, $this->filter_start_select)) ? ' selected' : '';
$parent_id = (isset($filter['parent']) && intval($filter['parent']) > 0) ? $filter['parent'] : 0;
$parent = ($parent_id > 0) ? ' data-pid="' . $parent_id . '"' : '';
$filters_html[$filter_text] = '
' . $filter_text . '
';
}
}
} else { //fallback to old version
if (!empty($this->filter)) {
foreach ($this->filter as $filter_id => $filter) {
$filter_text = ($demo) ? self::translate_demo_filter($filter['slug']) : Essential_Grid_Wpml::strip_category_additions($filter['name']);
// 2.2.5
// sanitize multi-select custom meta
if (strpos($filter_text, "['") !== false && strpos($filter_text, "']") !== false) {
$filter_text = preg_replace("/\[\'|\'\]/", '', $filter_text);
$filter_text = preg_replace("/\'\,\'/", ' & ', $filter_text);
}
$_v = Essential_Grid_Base::sanitize_utf8_to_unicode($filter['slug']);
$sel = (in_array($_v, $this->filter_start_select)) ? ' selected' : '';
$parent_id = (isset($filter['parent']) && intval($filter['parent']) > 0) ? $filter['parent'] : 0;
$parent = ($parent_id > 0) ? ' data-pid="' . $parent_id . '"' : '';
$filters_html[$filter_text] = '
' . $filter_text . '
';
}
}
}
}
if ('on' === $sort_alpha && !empty($filters_html)) {
ksort($filters_html);
if ('desc' === $sort_alpha_dir) $filters_html = array_reverse($filters_html);
}
if ($demo) {
array_unshift($filters_html, '
' . esc_html__('Favorites', ESG_TEXTDOMAIN) . '
');
}
/* 2.2.6 hide Filter-All button if text is empty */
$all_filter_text = @$this->filter_all_text['filter' . $type];
if (empty($all_filter_text)) $all_filter_text = esc_attr__('Filter - All', ESG_TEXTDOMAIN);
$sel = (!empty($this->filter_start_select)) ? '' : ' selected';
$sel .= @$this->filterall_visible['filter' . $type] === 'on' ? '' : ' esg-display-none-i ';
array_unshift($filters_html, '
' . $all_filter_text . '
');
//add a class to last element
$last = $this->array_key_last($filters_html);
$filters_html[$last] = str_replace('esg-filterbutton', 'esg-filterbutton-last esg-filterbutton', $filters_html[$last]);
$f .= implode('', $filters_html);
if ($listing == 'dropdown') {
$f .= '