function cgmp_extract_markers_from_published_content() { $posts = cgmp_get_content_from_db_by_type("post", CGMP_DB_PUBLISHED_POST_IDS); $pages = cgmp_get_content_from_db_by_type("page", CGMP_DB_PUBLISHED_PAGE_IDS); return array_merge(process_collection_of_contents($posts), process_collection_of_contents($pages)); }
function make_marker_geo_mashup_2() { $cached_geomashup_json = get_option(CGMP_DB_GEOMASHUP_DATA_CACHE); if (isset($cached_geomashup_json) && trim($cached_geomashup_json) != "") { $cached_geomashup_json = str_replace("\\\"", "\"", $cached_geomashup_json); $cache_time = get_option(CGMP_DB_GEOMASHUP_DATA_CACHE_TIME); return array("data" => $cached_geomashup_json, "debug" => array("state" => "cached", "since" => $cache_time)); } $query_debug_data = array(); $post_data = extract_published_content_containing_shortcode("post"); $query_debug_data["post"] = $post_data["query"]; $page_data = extract_published_content_containing_shortcode("page"); $query_debug_data["page"] = $page_data["query"]; $custom_data = array(); $custom_data["extracted"] = array(); $custom_data["query"] = array(); $custom_post_types = get_option(CGMP_DB_SETTINGS_CUSTOM_POST_TYPES); if (isset($custom_post_types) && trim($custom_post_types) != "") { $custom_post_types_arr = explode(",", $custom_post_types); array_walk($custom_post_types_arr, 'trim_to_lower_value'); $custom_post_types = implode("','", $custom_post_types_arr); $custom_data = extract_published_content_containing_shortcode($custom_post_types); $query_debug_data["custom"] = $custom_data["query"]; } $extracted_published_markers = array_merge(process_collection_of_contents($post_data["extracted"]), process_collection_of_contents($page_data["extracted"]), process_collection_of_contents($custom_data["extracted"])); if (is_array($extracted_published_markers) && count($extracted_published_markers) > 0) { $filtered = array(); $duplicates = array(); foreach ($extracted_published_markers as $post_data) { $title = $post_data['title']; $permalink = $post_data['permalink']; $markers = $post_data['markers']; $excerpt = $post_data['excerpt']; $bad_entities = array(""", "'", "'", "\""); $bad_characters = array("\r\n", "\r", "\n", "<br>", "<BR>", "<br />", "<BR />"); foreach ($markers as $full_loc) { $tobe_filtered_loc = $full_loc; if (strpos($full_loc, CGMP_SEP) !== false) { $loc_arr = explode(CGMP_SEP, $full_loc); $tobe_filtered_loc = $loc_arr[0]; } $tobe_filtered_loc = str_replace($bad_entities, "", str_replace($bad_characters, " ", $tobe_filtered_loc)); if (!isset($filtered[$tobe_filtered_loc])) { $validated_addresses = cgmp_do_serverside_address_validation_2($full_loc); $filtered[$tobe_filtered_loc]['validated_address_csv_data'] = $validated_addresses; $filtered[$tobe_filtered_loc]['permalink'] = $permalink; if (isset($title) && trim($title) != "") { $title = str_replace($bad_entities, "", $title); $title = trim($title); } $filtered[$tobe_filtered_loc]['title'] = $title; if (isset($excerpt) && trim($excerpt) != "") { $excerpt = str_replace($bad_entities, "", str_replace($bad_characters, " ", $excerpt)); $excerpt = trim($excerpt); } $filtered[$tobe_filtered_loc]['excerpt'] = $excerpt; } else { if (isset($duplicates[$tobe_filtered_loc]) && is_numeric($duplicates[$tobe_filtered_loc])) { $duplicates[$tobe_filtered_loc]++; } else { $duplicates[$tobe_filtered_loc] = 1; } } } } $debug_data = array("since" => time(), "query" => $query_debug_data, "duplicate_addresses_extracted" => $duplicates); $filtered["live_debug"] = $debug_data; $geomashup_json = json_encode($filtered); update_option(CGMP_DB_GEOMASHUP_DATA_CACHE, $geomashup_json); update_option(CGMP_DB_GEOMASHUP_DATA_CACHE_TIME, time()); $debug_data["state"] = "fresh"; return array("data" => $geomashup_json, "debug" => $debug_data); } }