$genres = wordtour_get_all_genre(); $term = strtolower($_GET['term']); $result = array(); $max_result = isset($_GET["maxRows"]) ? (int) $_GET["maxRows"] : 10; $i = 0; foreach ($genres as $genre) { if (stripos(strtolower($genre), $term) !== false && $i < $max_result) { array_push($result, array("term" => $genre, "value" => ucwords($genre))); $i++; } } echo json_encode($result); exit; } if (isset($_GET['term']) && $_GET['type'] == "event_type") { $type = get_all_event_type(); $term = strtolower($_GET['term']); $result = array(); $max_result = isset($_GET["maxRows"]) ? (int) $_GET["maxRows"] : 10; $i = 0; foreach ($type as $t) { if (stripos(strtolower($t), $term) !== false && $i < $max_result) { array_push($result, array("term" => $t, "value" => ucwords($t))); $i++; } } echo json_encode($result); exit; } if (isset($_GET['term']) && $_GET['type'] == "state") { $states = get_states();
function wordtour_add_event_type($type = "") { try { $event_type = get_all_event_type(); if (!empty($type) && !in_array($type, $event_type)) { $event_type[] = $type; update_option("wordtour_event_type", $event_type); } } catch (Exception $e) { } }