function bl_build_cat_checkbox($cat_parent, $form_input_name, $level, $incoming = array()) { $options = get_terms(array('bepro_listing_types'), array("parent" => $cat_parent, "hide_empty" => 0)); foreach ($options as $opt) { $checked = isset($incoming[$opt->term_id]) ? "checked='checked'" : ""; $search_form .= '<input type="checkbox" class="sub_cat_checkbox_' . $level . '" name="' . $form_input_name . '" value="' . $opt->term_id . '" ' . $checked . '/><span class="searchcheckbox">' . $opt->name . '</span><br />'; $search_form .= bl_build_cat_checkbox($opt->term_id, $form_input_name, $level + 1, $incoming); } return $search_form; }
function search_filter_options($atts = array(), $echo_this = false) { global $wpdb; extract(shortcode_atts(array('bl_form_id' => $wpdb->escape($_POST["bl_form_id"]), 'listing_page' => $wpdb->escape($_POST["listing_page"])), $atts)); if (empty($atts["bl_form_id"])) { $atts["bl_form_id"] = $_POST["bl_form_id"]; } //get settings $data = get_option("bepro_listings"); //Process user requested Bepro listing types $types = ""; if (!empty($_REQUEST["l_type"])) { $l_type = $_REQUEST["l_type"]; if (is_array($l_type)) { foreach ($l_type as $raw_t) { $types[$raw_t] = 1; } } else { if (is_numeric($_REQUEST["l_type"])) { $types[$_REQUEST["l_type"]] = 1; } } } $cat_heading = $data["cat_heading"]; $search_form_head = "<div class='filter_search_form bl_frontend_search_section'>\n\t\t\t<form id='filter_search_form' method='post' action='" . $listing_page . "'>\n\t\t\t\t<input type='hidden' name='name_search' value='" . $_POST["name_search"] . "'>\n\t\t\t\t<input type='hidden' name='listing_page' value='" . $listing_page . "'>\n\t\t\t\t<input type='hidden' name='addr_search' value='" . $_POST["addr_search"] . "'>\n\t\t\t\t<input type='hidden' name='order_dir' value='" . $_POST["order_dir"] . "'>\n\t\t\t\t<input type='hidden' name='filter_search' value='1'>\n\t\t\t\t<input type='hidden' name='bl_form_id' value='" . $atts["bl_form_id"] . "'>\n\t\t\t\t<table>"; $search_form_fields = apply_filters("bepro_listings_search_filter_override", $atts); if (empty($search_form_fields) || $search_form_fields == $atts) { $search_form_fields = "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<span class='label_sep'>" . __($cat_heading, "bepro-listings") . "</span><br />\n\t\t\t\t\t\t\t"; $search_form_fields .= bl_build_cat_checkbox(0, "l_type[]", 0, $types); $search_form_fields .= '</td> </tr>'; /////////////////////////////////////////////////////////////////////// if (is_numeric($data["show_geo"]) && $data["show_geo"] != 0) { $search_form_fields .= ' <tr class="bl_distance_search_option"><td> ' . __("Distance", "bepro-listings") . ': <select name="distance"> <option value="">' . __("None", "bepro-listings") . '</option> <option value="10" ' . ($_POST["distance"] == 10 || empty($_POST["distance"]) && $data["distance"] == 10 ? 'selected="selected"' : "") . '>' . __("10 miles", "bepro-listings") . '</option> <option value="50" ' . ($_POST["distance"] == 50 || empty($_POST["distance"]) && $data["distance"] == 50 ? 'selected="selected"' : "") . '>' . __("50 miles", "bepro-listings") . '</option> <option value="150" ' . ($_POST["distance"] == 150 || empty($_POST["distance"]) && $data["distance"] == 150 ? 'selected="selected"' : "") . '>' . __("150 miles", "bepro-listings") . '</option> <option value="250" ' . ($_POST["distance"] == 250 || empty($_POST["distance"]) && $data["distance"] == 250 ? 'selected="selected"' : "") . '>' . __("250 miles", "bepro-listings") . '</option> <option value="500" ' . ($_POST["distance"] == 500 || empty($_POST["distance"]) && $data["distance"] == 500 ? 'selected="selected"' : "") . '>' . __("500 miles", "bepro-listings") . '</option> <option value="1000" ' . ($_POST["distance"] == 1000 || empty($_POST["distance"]) && $data["distance"] == 1000 ? 'selected="selected"' : "") . '>' . __("1000 miles", "bepro-listings") . '</option> </select> </td></tr>'; } //min/max cost if ($data["show_cost"] == 1 || $data["show_cost"] == "on") { $search_form_fields .= ' <tr><td> <span class="label_sep">' . __("Price Range", "bepro-listings") . '</span><span class="form_label">' . __("From", "bepro-listings") . '</span><input class="input_text" type="text" name="min_cost" value="' . $_POST["min_cost"] . '"><span class="form_label">' . __("To", "bepro-listings") . '</span><input class="input_text" type="text" name="max_cost" value="' . $_POST["max_cost"] . '"> </td></tr>'; } if ($data["show_date"] == 1 || $data["show_date"] == "on") { $search_form_fields .= ' <tr><td> <span class="label_sep">' . __("Date Range", "bepro-listings") . '</span><span class="form_label">' . __("From", "bepro-listings") . '</span><input class="input_text" type="text" name="min_date" id="min_date" value="' . $_POST["min_date"] . '"><span class="form_label">' . __("To", "bepro-listings") . '</span><input class="input_text" type="text" name="max_date" id="max_date" value="' . $_POST["max_date"] . '"> </td></tr>'; } $check_form_fields = apply_filters("bepro_listings_search_filter", $atts, ""); if ($check_form_fields != $atts) { $search_form_fields .= $check_form_fields; } } $search_form_end = ' <tr> <td> <input type="submit" class="form-submit" value="' . __("Search", "bepro-listings") . '" id="edit-submit" name="find"> <a class="clear_search" href="' . get_bloginfo("url") . "/" . $listing_page . '"><button>' . __("Clear", "bepro-listings") . '</button></a> </td> </tr> </table> </form></div> '; if ($echo_this) { echo $search_form_head . $search_form_fields . $search_form_end; } else { return $search_form_head . $search_form_fields . $search_form_end; } }