<?php list($latlng) = get_post_meta($post->ID, 'latlng'); if ($latlng) { $data = array('title' => my_html_entity_decode(get_the_title()), 'clickable' => false); list($data['lat'], $data['lng']) = explode(',', $latlng, 2); switch (true) { case has_term('Restaurant', 'business-type'): $data['icon'] = get_stylesheet_directory_uri() . '/maki/marker-36-1f77b4.png'; break; case has_term('Retailer', 'business-type'): $data['icon'] = get_stylesheet_directory_uri() . '/maki/marker-36-2ca02c.png'; break; default: $data['icon'] = get_stylesheet_directory_uri() . '/maki/marker-36-d62728.png'; } $all_data[] = $data; } ?> <div id=map-canvas></div> <script src=//maps.googleapis.com/maps/api/js></script> <?php wp_enqueue_script('script'); ?> <script> <?php require get_stylesheet_directory() . '/map.js.php'; ?> </script>
<?php $query = "\n SELECT ID\n FROM {$wpdb->posts}\n INNER JOIN {$wpdb->terms} as t\n ON t.name = post_title\n INNER JOIN {$wpdb->term_taxonomy} AS tt\n ON tt.term_id = t.term_id\n INNER JOIN {$wpdb->term_relationships} AS tr\n ON tr.term_taxonomy_id = tt.term_taxonomy_id\n WHERE tt.taxonomy = 'available-at'\n AND tr.object_id = %d\n"; $query = $wpdb->prepare($query, $post->ID); $available_at_data = array(); foreach ($wpdb->get_col($query) as $post_id) { $custom_fields = get_post_custom($post_id); list($address) = $custom_fields['address']; list($latlng) = $custom_fields['latlng']; list($phone) = $custom_fields['phone']; if ($latlng) { $post = get_post($post_id); $data = array('title' => my_html_entity_decode(get_the_title()), 'permalink' => get_permalink()); list($data['lat'], $data['lng']) = explode(',', $latlng, 2); $data += array_filter(compact('address', 'phone')); $value = wp_get_object_terms($post->ID, 'business-type', array('fields' => 'names')); if ($value) { $value = array_map('my_html_entity_decode', array_map('wptexturize', $value)); $data['business-type'] = count($value) == 1 ? $value[0] : $value; } $value = wp_get_object_terms($post->ID, 'farm-practices', array('fields' => 'names')); if ($value) { $value = array_map('my_html_entity_decode', array_map('wptexturize', $value)); $data['farm-practices'] = count($value) == 1 ? $value[0] : $value; } $thumbnail_id = get_post_thumbnail_id($post->ID); if ($thumbnail_id) { list($data['thumbnail-src'], $data['thumbnail-width'], $data['thumbnail-height']) = wp_get_attachment_image_src($thumbnail_id); } switch (true) { case has_term('Restaurant', 'business-type'):
# Copyright (c) 2003-2004 Igoan. # Please see the file CREDITS supplied with Igoan to see the full list # of copyright holders. # # $Id: logout.php,v 1.1 2004/04/08 21:14:45 cam Exp $ # # This file is part of the Igoan project. # # Igoan is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in the version 2 of the License. # # Igoan is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Igoan; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # taken from http://fr2.php.net/manual/en/function.html-entity-decode.php function my_html_entity_decode($given_html, $quote_style = ENT_QUOTES) { $trans_table = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)); $trans_table['''] = "'"; return strtr($given_html, $trans_table); } unset($_SESSION['id']); http_redir(empty($_GET['referer']) ? '/index.php' : urldecode(my_html_entity_decode($_GET['referer'])));
function update_data() { remove_filter('pre_post_title', 'pre_post_title'); $upload_dir = wp_upload_dir(); $filename = $upload_dir['basedir'] . '/data.json'; require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/image.php'; require_once ABSPATH . 'wp-admin/includes/media.php'; $items = array(); $args = array('numberposts' => -1, 'post_type' => 'business'); foreach (get_posts($args) as $post) { $custom_fields = get_post_custom($post->ID); list($address) = $custom_fields['address']; list($latlng) = $custom_fields['latlng']; list($phone) = $custom_fields['phone']; $item = array('label' => my_html_entity_decode(wptexturize($post->post_title)), 'permalink' => get_permalink($post)); $item += array_filter(compact('address', 'latlng', 'phone')); $website = esc_url_raw($custom_fields['website'][0]); if ($website) { $website = strtolower($website); $website = preg_replace('/^https?:\\/\\/(?:www\\.)?([-.\\d_a-z~]+(?:\\/[-.\\/\\d_a-z~]+)?)\\/*/', 'http://$1', $website); $args = array('timeout' => 300, 'redirection' => 0); $response = wp_safe_remote_get($website, $args); $args['redirection'] = 1; $args['reject_unsafe_urls'] = true; for ($i = 0; $i < 5; $i++) { if (is_wp_error($response)) { delete_post_meta($post->ID, 'website_up'); break; } $redirect_response = WP_Http::handle_redirects($website, $args, $response); if (!$redirect_response) { $website = preg_replace('/^(https?:\\/\\/[-.\\d_a-z~]+)\\/+$/i', '$1', $website); //update_post_meta($post->ID, 'website', $website); update_post_meta($post->ID, 'website_up', $website); $body = wp_remote_retrieve_body($response); $doc = new DOMDocument(); @$doc->loadHTML($body); $url_parts = my_parse_url($website); $urls = array(); foreach ($doc->getElementsByTagName('img') as $node) { $relative_url_parts = my_parse_url($node->getAttribute('src')); $relative_url_parts['path'] = str_replace(' ', '%20', $relative_url_parts['path']); $relative_url_parts['query'] = str_replace(' ', '+', $relative_url_parts['query']); if (!$relative_url_parts['scheme']) { $relative_url_parts['scheme'] = $url_parts['scheme']; if (!$relative_url_parts['host']) { $relative_url_parts['host'] = $url_parts['host']; $relative_url_parts['port'] = $url_parts['port']; if (!$relative_url_parts['path']) { $relative_url_parts['path'] = $url_parts['path']; if (!$relative_url_parts['query']) { $relative_url_parts['query'] = $url_parts['query']; } } else { if ($relative_url_parts['path'][0] != '/') { $relative_url_parts['path'] = "/{$relative_url_parts['path']}"; if ($url_parts['path']) { $relative_url_parts['path'] = substr($url_parts['path'], 0, strrpos($url_parts['path'], '/')) . $relative_url_parts['path']; } } } } } do { $relative_url_parts['path'] = preg_replace('/[^\\/]+\\/\\.\\.(?:\\/|$)/', '', $relative_url_parts['path'], 1, $count); } while ($count); $url = "{$relative_url_parts['scheme']}://{$relative_url_parts['host']}"; if ($relative_url_parts['port']) { $url .= ":{$relative_url_parts['port']}"; } $url .= $relative_url_parts['path']; if ($relative_url_parts['query']) { $url .= "?{$relative_url_parts['query']}"; } $urls[$url] = $url; } if ($urls) { $args = array('post_parent' => $post->ID, 'post_type' => 'attachment'); foreach (get_children($args) as $attachment) { wp_delete_attachment($attachment->ID); } $found = false; foreach ($urls as $url) { $tmp_name = download_url($url); list($width, $height) = getimagesize($tmp_name); if ($width > 40 && $height > 40 && $width + $height > 180) { preg_match('/[^\\/]+?(?=\\/?(?:$|\\?))/', $url, $matches); $file_array = array('name' => $matches[0], 'tmp_name' => $tmp_name); $thumbnail_id = media_handle_sideload($file_array, $post->ID); if (!$found) { set_post_thumbnail($post, $thumbnail_id); $found = true; } } } } break; } $website = WP_Http::make_absolute_url(wp_remote_retrieve_header($response, 'location'), $website); $response = $redirect_response; } } $value = wp_get_object_terms($post->ID, 'products', array('fields' => 'names')); if ($value) { $value = array_map('my_html_entity_decode', array_map('wptexturize', $value)); $item['products'] = count($value) == 1 ? $value[0] : $value; } $value = wp_get_object_terms($post->ID, 'farm-practices', array('fields' => 'names')); if ($value) { $value = array_map('my_html_entity_decode', array_map('wptexturize', $value)); $item['farm-practices'] = count($value) == 1 ? $value[0] : $value; } $value = wp_get_object_terms($post->ID, 'business-type', array('fields' => 'names')); if ($value) { $value = array_map('my_html_entity_decode', array_map('wptexturize', $value)); $item['business-type'] = count($value) == 1 ? $value[0] : $value; } $value = wp_get_object_terms($post->ID, 'available-at', array('fields' => 'names')); if ($value) { $value = array_map('my_html_entity_decode', array_map('wptexturize', $value)); $item['available-at'] = count($value) == 1 ? $value[0] : $value; } $thumbnail_id = get_post_thumbnail_id($post->ID); if ($thumbnail_id) { list($item['thumbnail-src'], $item['thumbnail-width'], $item['thumbnail-height']) = wp_get_attachment_image_src($thumbnail_id); } switch (true) { case has_term('Restaurant', 'business-type', $post): $item['icon'] = get_stylesheet_directory_uri() . '/maki/marker-36-1f77b4.png'; break; case has_term('Retailer', 'business-type', $post): $item['icon'] = get_stylesheet_directory_uri() . '/maki/marker-36-2ca02c.png'; break; default: $item['icon'] = get_stylesheet_directory_uri() . '/maki/marker-36-d62728.png'; } $items[] = $item; } $all_products = array(); foreach (get_terms('products') as $term) { $all_products[$term->term_id] = $term; } $all_in_season = get_option('in_season'); foreach ($all_products as $term) { $in_season = $all_in_season[$term->term_id]; if ($term->parent || $in_season) { $item = array('label' => my_html_entity_decode(wptexturize($term->name)), 'type' => 'product'); if ($term->parent) { $item['parent'] = my_html_entity_decode(wptexturize($all_products[$term->parent]->name)); } if ($in_season) { $item['in-season'] = format_in_season($in_season); } $items[] = $item; } } $data = array('items' => $items); file_put_contents($filename, wp_json_encode($data)); }