function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); if (!class_exists('GeoMashupDB')) { return; } global $wp_query; global $post; $backup = $wp_query->in_the_loop; $wp_query->in_the_loop = true; $location = GeoMashupDB::get_object_location('post', $post->ID); if (!empty($location)) { echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo do_shortcode('[geo_mashup_map]'); echo '<div class="clearboth"></div>'; echo $after_widget; } $wp_query->in_the_loop = $backup; }
/** * When a comment is saved, save any posted location with it. * * save_comment {@link http://codex.wordpress.org/Plugin_API/Filter_Reference filter} * called by WordPress. * * @since 1.3 * @uses GeoMashupDB::set_object_location() */ public function save_comment($comment_id = 0, $approval = '') { if (!$comment_id || 'spam' === $approval || empty($_POST['comment_location']) || !is_array($_POST['comment_location'])) { return false; } GeoMashupDB::set_object_location('comment', $comment_id, $_POST['comment_location']); }
/** * WordPress action to emit GeoRSS tags. * * rss_item {@link http://codex.wordpress.org/Plugin_API/Action_Reference#Feed_Actions action} * called by WordPress. * * @since 1.0 */ public static function rss_item() { global $wp_query; // Using Simple GeoRSS for now $location = GeoMashupDB::get_object_location('post', $wp_query->post->ID); if (!empty($location)) { echo '<georss:point>' . esc_html($location->lat . ' ' . $location->lng) . '</georss:point>'; } }
/** * Generates SQL clauses to be appended to a main query. * * @since 3.1.0 * @access public * * @param string $primary_table * @param string $primary_id_column * @return array columns, join, where, groupby */ public function get_sql($primary_table, $primary_id_column) { /** @var wpdb $wpdb */ global $wpdb; if (empty($this->query_args)) { return self::$no_results; } if (empty($this->query_args['object_name'])) { $this->query_args['object_name'] = GeoMashupDB::table_to_object_name($primary_table); } $location_table = $wpdb->prefix . 'geo_mashup_locations'; $relationship_table = $wpdb->prefix . 'geo_mashup_location_relationships'; $cols = ", {$location_table}.lat" . ", {$location_table}.lng" . ", {$location_table}.address" . ", {$location_table}.saved_name " . ", {$location_table}.postal_code " . ", {$location_table}.admin_code " . ", {$location_table}.sub_admin_code " . ", {$location_table}.country_code " . ", {$location_table}.locality_name "; $join = " INNER JOIN {$relationship_table} ON {$relationship_table}.object_id = {$primary_table}.{$primary_id_column}\n\t\t\tINNER JOIN {$location_table} ON {$location_table}.id = {$relationship_table}.location_id"; $where = array($wpdb->prepare("{$relationship_table}.object_name=%s", $this->query_args['object_name'])); $groupby = ''; // Check for a radius query if (!empty($this->query_args['radius_mi'])) { $this->query_args['radius_km'] = 1.609344 * floatval($this->query_args['radius_mi']); } if (!empty($this->query_args['radius_km']) and is_numeric($this->query_args['near_lat']) and is_numeric($this->query_args['near_lng'])) { // Earth radius = 6371 km, 3959 mi $near_lat = floatval($this->query_args['near_lat']); $near_lng = floatval($this->query_args['near_lng']); $radius_km = floatval($this->query_args['radius_km']); $cols .= ", 6371 * 2 * ASIN( SQRT( POWER( SIN( RADIANS( {$near_lat} - {$location_table}.lat ) / 2 ), 2 ) +\n\t\t\t\tCOS( RADIANS( {$near_lat} ) ) * COS( RADIANS( {$location_table}.lat ) ) *\n\t\t\t\tPOWER( SIN( RADIANS( {$near_lng} - {$location_table}.lng ) / 2 ), 2 ) ) ) AS distance_km"; $groupby = "{$primary_table}.{$primary_id_column} HAVING distance_km < {$radius_km}"; // approx 111 km per degree latitude $this->query_args['minlat'] = $near_lat - $radius_km / 111; $this->query_args['maxlat'] = $near_lat + $radius_km / 111; $this->query_args['minlon'] = $near_lng - $radius_km / (abs(cos(deg2rad($near_lat))) * 111); $this->query_args['maxlon'] = $near_lng + $radius_km / (abs(cos(deg2rad($near_lat))) * 111); } // Ignore nonsense bounds if ($this->query_args['minlat'] && $this->query_args['maxlat'] && $this->query_args['minlat'] > $this->query_args['maxlat']) { $this->query_args['minlat'] = $this->query_args['maxlat'] = null; } if ($this->query_args['minlon'] && $this->query_args['maxlon'] && $this->query_args['minlon'] > $this->query_args['maxlon']) { $this->query_args['minlon'] = $this->query_args['maxlon'] = null; } // Build bounding where clause if (is_numeric($this->query_args['minlat'])) { $where[] = "{$location_table}.lat > {$this->query_args['minlat']}"; } if (is_numeric($this->query_args['minlon'])) { $where[] = "{$location_table}.lng > {$this->query_args['minlon']}"; } if (is_numeric($this->query_args['maxlat'])) { $where[] = "{$location_table}.lat < {$this->query_args['maxlat']}"; } if (is_numeric($this->query_args['maxlon'])) { $where[] = "{$location_table}.lng < {$this->query_args['maxlon']}"; } $where_fields = array('sub_admin_code', 'admin_code', 'country_code', 'postal_code', 'geoname', 'locality_name', 'saved_name'); foreach ($where_fields as $field) { if (!empty($this->query_args[$field])) { $where[] = $wpdb->prepare("{$location_table}.{$field} = %s", $this->query_args[$field]); } } if (count($where) === 1 and empty($groupby)) { return self::$no_results; } $where = ' AND ( ' . implode(" AND ", $where) . ' )'; return array($cols, $join, $where, $groupby); }
public function reverse_geocode($lat, $lng) { if (!is_numeric($lat) or !is_numeric($lng)) { // Bad Request return new WP_Error('bad_reverse_geocode_request', __('Reverse geocoding requires numeric coordinates.', 'GeoMashup')); } $geocode_url = 'http://nominatim.openstreetmap.org/reverse?format=json&zoom=18&address_details=1&lat=' . $lat . '&lon=' . $lng . '&email=' . urlencode(get_option('admin_email')); $response = $this->http->get($geocode_url, $this->request_params); if (is_wp_error($response)) { return $response; } $status = $response['response']['code']; if ('200' != $status) { return new WP_Error('geocoder_http_request_failed', $status . ': ' . $response['response']['message'], $response); } $data = json_decode($response['body']); if (empty($data)) { return array(); } $location = GeoMashupDB::blank_location(); $location->lat = $lat; $location->lng = $lng; $location->address = $data->display_name; if (!empty($data->address)) { if (!empty($data->address->country_code)) { $location->country_code = strtoupper($data->address->country_code); } // Returns admin name in address->state, but no code if (!empty($data->address->county)) { $location->sub_admin_code = $data->address->county; } if (!empty($data->address->postcode)) { $location->postal_code = $data->address->postcode; } if (!empty($data->address->city)) { $location->locality_name = $data->address->city; } } return array($location); }
/** * Add missing location fields, and update country and admin codes with * authoritative Geonames values. * * @since 1.3 * * @param array $location The location to geocode, modified. * @param string $language Optional ISO language code. * @return bool Success. */ private static function reverse_geocode_location(&$location, $language = '') { global $geo_mashup_options; // Coordinates are required if (self::are_any_location_fields_empty($location, array('lat', 'lng'))) { return false; } // Don't bother unless there are missing geocodable fields $geocodable_fields = array('country_code', 'admin_code', 'address', 'locality_name', 'postal_code'); $have_empties = self::are_any_location_fields_empty($location, $geocodable_fields); if (!$have_empties) { return false; } $status = false; if (!class_exists('GeoMashupHttpGeocoder')) { include_once path_join(GEO_MASHUP_DIR_PATH, 'geo-mashup-geocoders.php'); } $geonames_geocoder = new GeoMashupGeonamesGeocoder(); $geonames_results = $geonames_geocoder->reverse_geocode($location['lat'], $location['lng']); if (is_wp_error($geonames_results) or empty($geonames_results)) { self::$geocode_error = $geonames_results; } else { if (!empty($geonames_results[0]->admin_code)) { $location['admin_code'] = $geonames_results[0]->admin_code; } if (!empty($geonames_results[0]->country_code)) { $location['country_code'] = $geonames_results[0]->country_code; } self::fill_empty_location_fields($location, (array) $geonames_results[0]); $status = true; } $have_empties = self::are_any_location_fields_empty($location, $geocodable_fields); if ($have_empties) { // Choose a geocoding service based on the default API in use if ('google' == substr($geo_mashup_options->get('overall', 'map_api'), 0, 6)) { $next_geocoder = new GeoMashupGoogleGeocoder(); } else { if ('openlayers' == $geo_mashup_options->get('overall', 'map_api')) { $next_geocoder = new GeoMashupNominatimGeocoder(); } } $next_results = $next_geocoder->reverse_geocode($location['lat'], $location['lng']); if (is_wp_error($next_results) or empty($next_results)) { self::$geocode_error = $next_results; } else { self::fill_empty_location_fields($location, (array) $next_results[0]); } $status = true; } return $status; }
/** * Add missing location fields, and update country and admin codes with * authoritative Geonames values. * * @since 1.3 * * @param array $location The location to geocode, modified. * @param string $language Optional ISO language code. * @return bool Success. */ private static function reverse_geocode_location(&$location, $language = '') { // Coordinates are required if (self::are_any_location_fields_empty($location, array('lat', 'lng'))) { return false; } // Don't bother unless there are missing geocodable fields $geocodable_fields = array('country_code', 'admin_code', 'address', 'locality_name', 'postal_code'); $have_empties = self::are_any_location_fields_empty($location, $geocodable_fields); if (!$have_empties) { return false; } $status = false; if (!class_exists('GeoMashupHttpGeocoder')) { include_once path_join(GEO_MASHUP_DIR_PATH, 'geo-mashup-geocoders.php'); } $geonames_geocoder = new GeoMashupGeonamesGeocoder(); $geonames_results = $geonames_geocoder->reverse_geocode($location['lat'], $location['lng']); if (is_wp_error($geonames_results) or empty($geonames_results)) { self::$geocode_error = $geonames_results; } else { if (!empty($geonames_results[0]->admin_code)) { $location['admin_code'] = $geonames_results[0]->admin_code; } if (!empty($geonames_results[0]->country_code)) { $location['country_code'] = $geonames_results[0]->country_code; } self::fill_empty_location_fields($location, (array) $geonames_results[0]); $status = true; } $have_empties = self::are_any_location_fields_empty($location, $geocodable_fields); $alternate_geocoder = self::make_alternate_reverse_geocoder(); if ($have_empties and $alternate_geocoder) { $next_results = $alternate_geocoder->reverse_geocode($location['lat'], $location['lng']); if (is_wp_error($next_results) or empty($next_results)) { self::$geocode_error = $next_results; } else { self::fill_empty_location_fields($location, (array) $next_results[0]); } $status = true; } return $status; }
/** * Run a search query. * * @since 1.5 * @uses apply_filters() geo_mashup_search_query_args Filter the geo query arguments. * * @param string|array $args Search parameters. * @return array Search results. **/ public function query($args) { $default_args = array('object_name' => 'post', 'object_ids' => null, 'exclude_object_ids' => null, 'units' => 'km', 'location_text' => '', 'radius' => null, 'sort' => 'distance_km ASC'); $this->query_vars = wp_parse_args($args, $default_args); /** @var $units */ extract($this->query_vars); $this->results = array(); $this->result_count = 0; $this->result = null; $this->current_result = -1; $this->units = $units; $this->max_km = 20000; $this->distance_factor = 'km' == $units ? 1 : self::MILES_PER_KILOMETER; $this->near_location = GeoMashupDB::blank_location(ARRAY_A); $geo_query_args = wp_array_slice_assoc($this->query_vars, array('object_name', 'sort', 'exclude_object_ids', 'limit')); if (!empty($near_lat) and !empty($near_lng)) { $this->near_location['lat'] = $near_lat; $this->near_location['lng'] = $near_lng; } else { if (!empty($location_text)) { $geocode_text = empty($geolocation) ? $location_text : $geolocation; if (!GeoMashupDB::geocode($geocode_text, $this->near_location)) { // No search center was found, we can't continue return $this->results; } } else { // No coordinates to search near return $this->results; } } $radius_km = $this->max_km; if (!empty($radius)) { $radius_km = abs($radius) / $this->distance_factor; } $geo_query_args['radius_km'] = $radius_km; $geo_query_args['near_lat'] = $this->near_location['lat']; $geo_query_args['near_lng'] = $this->near_location['lng']; if (isset($map_cat)) { $geo_query_args['map_cat'] = $map_cat; } $geo_query_args = apply_filters('geo_mashup_search_query_args', $geo_query_args); $this->results = GeoMashupDB::get_object_locations($geo_query_args); $this->result_count = count($this->results); if ($this->result_count > 0) { $this->max_km = $this->results[$this->result_count - 1]->distance_km; } else { $this->max_km = $radius_km; } return $this->results; }
/** * Print Geo Mashup Options HTML * * @since 1.2 * @access public */ function geo_mashup_options_page() { global $geo_mashup_options; $activated_copy_geodata = false; if (isset($_POST['submit'])) { // Process option updates check_admin_referer('geo-mashup-update-options'); // Missing add_map_type_control means empty array if (empty($_POST['global_map']['add_map_type_control'])) { $_POST['global_map']['add_map_type_control'] = array(); } if (empty($_POST['single_map']['add_map_type_control'])) { $_POST['single_map']['add_map_type_control'] = array(); } if (empty($_POST['context_map']['add_map_type_control'])) { $_POST['context_map']['add_map_type_control'] = array(); } if (empty($_POST['overall']['located_post_types'])) { $_POST['overall']['located_post_types'] = array(); } if (empty($_POST['overall']['located_object_name'])) { $_POST['overall']['located_object_name'] = array(); } if (empty($_POST['overall']['include_taxonomies'])) { $_POST['overall']['include_taxonomies'] = array(); } if ('true' != $geo_mashup_options->get('overall', 'copy_geodata') and isset($_POST['overall']['copy_geodata'])) { $activated_copy_geodata = true; } $geo_mashup_options->set_valid_options($_POST); if ($geo_mashup_options->save()) { echo '<div class="updated fade"><p>' . __('Options updated. Browser or server caching may delay updates for recently viewed maps.', 'GeoMashup') . '</p></div>'; } } if ($activated_copy_geodata) { GeoMashupDB::duplicate_geodata(); echo '<div class="updated fade"><p>' . __('Copied existing geodata, see log for details.', 'GeoMashup') . '</p></div>'; } if (isset($_POST['bulk_reverse_geocode'])) { check_admin_referer('geo-mashup-update-options'); $log = GeoMashupDB::bulk_reverse_geocode(); echo '<div class="updated fade">' . $log . '</div>'; } if (isset($_POST['geo_mashup_run_tests'])) { if (!function_exists('mb_check_encoding')) { echo '<div class="updated fade">'; printf(__('%s Multibyte string functions %s are not installed.', 'GeoMashup'), '<a href="http://www.php.net/manual/en/mbstring.installation.php" title="">', '</a>'); echo ' '; _e('Geocoding and other web services may not work properly.', 'GeoMashup'); echo '</div>'; } $test_transient = get_transient('geo_mashup_test'); if (!$test_transient) { echo '<div class="updated fade">'; _e('WordPress transients may not be working. Try deactivating or reconfiguring caching plugins.', 'GeoMashup'); echo ' <a href="https://github.com/cyberhobo/wordpress-geo-mashup/issues/425">issue 425</a>'; echo '</div>'; unset($_POST['geo_mashup_run_tests']); } else { // load tests } } else { // Set a test transient set_transient('geo_mashup_test', 'true', 60 * 60); } if (GEO_MASHUP_DB_VERSION != GeoMashupDB::installed_version()) { // This happens at init now if (GeoMashupDB::install()) { echo '<div class="updated fade"><p>' . __('Database upgraded, see log for details.', 'GeoMashup') . '</p></div>'; } } if (isset($_POST['delete_log'])) { check_admin_referer('geo-mashup-delete-log'); if (update_option('geo_mashup_activation_log', '')) { echo '<div class="updated fade"><p>' . __('Log deleted.', 'GeoMashup') . '</p></div>'; } } if (!empty($geo_mashup_options->corrupt_options)) { // Options didn't load correctly $message = ' ' . __('Saved options may be corrupted, try updating again. Corrupt values: ') . '<code>' . $geo_mashup_options->corrupt_options . '</code>'; echo '<div class="updated"><p>' . $message . '</p></div>'; } if (!empty($geo_mashup_options->validation_errors)) { // There were invalid options echo '<div class="updated"><p>' . __('Some invalid options will not be used. If you\'ve just upgraded, do an update to initialize new options.', 'GeoMashup'); echo '<ul>'; foreach ($geo_mashup_options->validation_errors as $message) { echo "<li>{$message}</li>"; } echo '</ul></p></div>'; } // Create marker and color arrays $colorNames = array('aqua' => '#00ffff', 'black' => '#000000', 'blue' => '#0000ff', 'fuchsia' => '#ff00ff', 'gray' => '#808080', 'green' => '#008000', 'lime' => '#00ff00', 'maroon' => '#800000', 'navy' => '#000080', 'olive' => '#808000', 'orange' => '#ffa500', 'purple' => '#800080', 'red' => '#ff0000', 'silver' => '#c0c0c0', 'teal' => '#008080', 'white' => '#ffffff', 'yellow' => '#ffff00'); $mapTypes = array('G_NORMAL_MAP' => __('Roadmap', 'GeoMashup'), 'G_SATELLITE_MAP' => __('Satellite', 'GeoMashup'), 'G_HYBRID_MAP' => __('Hybrid', 'GeoMashup'), 'G_PHYSICAL_MAP' => __('Terrain', 'GeoMashup'), 'G_SATELLITE_3D_MAP' => __('Earth Plugin', 'GeoMashup')); $mapControls = array('GSmallZoomControl' => __('Small Zoom', 'GeoMashup'), 'GSmallZoomControl3D' => __('Small Zoom 3D', 'GeoMashup'), 'GSmallMapControl' => __('Small Pan/Zoom', 'GeoMashup'), 'GLargeMapControl' => __('Large Pan/Zoom', 'GeoMashup'), 'GLargeMapControl3D' => __('Large Pan/Zoom 3D', 'GeoMashup')); $futureOptions = array('true' => __('Yes', 'GeoMashup'), 'false' => __('No', 'GeoMashup'), 'only' => __('Only', 'GeoMashup')); $mapApis = array('google' => __('Google v2', 'GeoMashup'), 'googlev3' => __('Google v3', 'GeoMashup'), 'openlayers' => __('OpenLayers', 'GeoMashup'), 'leaflet' => __('Leaflet', 'GeoMashup')); $zoomOptions = array('auto' => __('auto', 'GeoMashup')); for ($i = 0; $i < GEO_MASHUP_MAX_ZOOM; $i++) { $zoomOptions[$i] = $i; } $selected_tab = empty($_POST['geo_mashup_selected_tab']) ? 0 : $_POST['geo_mashup_selected_tab']; $google_key = $geo_mashup_options->get('overall', 'google_key'); $include_taxonomies = $geo_mashup_options->get('overall', 'include_taxonomies'); $map_api = $geo_mashup_options->get('overall', 'map_api'); // Now for the HTML ?> <script type="text/javascript"> jQuery(function( $ ) { var selector = '#geo-mashup-settings-form', $obscure_settings = $('.obscure').hide(); $( selector ).tabs( { active: <?php echo $selected_tab; ?> , activate: function ( event, ui ) { $( '#geo-mashup-selected-tab' ).val( ui.newTab.index() ); } } ); $( '#import_custom_field' ).suggest( ajaxurl + '?action=geo_mashup_suggest_custom_keys', { multiple: true, multipleSep: ',', onSelect: function( $input ) { // Remove the trailing comma $(this).val( $(this).val().replace( /,\s*$/, '' ) ); } } ); $( 'input.overall-submit' ).keypress( function( e ) { if ( ( e.keyCode && e.keyCode === 13 ) || ( e.which && e.which === 13 ) ) { e.preventDefault(); $( '#overall-submit' ).click(); } } ); $( '#map_api' ).change( function() { $( '#overall-submit' ).click(); } ); $( '#show_obscure_settings').click( function( e ) { var $link = $(this); e.preventDefault(); if ( $link.hasClass( 'ui-icon-triangle-1-e' ) ) { $link.removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s'); $obscure_settings.show(); } else { $link.removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e'); $obscure_settings.hide(); } }) } ); </script> <div class="wrap"> <h2><?php _e('Geo Mashup Options', 'GeoMashup'); ?> </h2> <form method="post" id="geo-mashup-settings-form" action="<?php echo $_SERVER['REQUEST_URI']; ?> "> <ul> <li><a href="#geo-mashup-overall-settings"><span><?php _e('Overall', 'GeoMashup'); ?> </span></a></li> <li><a href="#geo-mashup-single-map-settings"><span><?php _e('Single Maps', 'GeoMashup'); ?> </span></a></li> <li><a href="#geo-mashup-global-map-settings"><span><?php _e('Global Maps', 'GeoMashup'); ?> </span></a></li> <li><a href="#geo-mashup-context-map-settings"><span><?php _e('Contextual Maps', 'GeoMashup'); ?> </span></a></li> <li><a href="#geo-mashup-tests"><span><?php _e('Tests', 'GeoMashup'); ?> </span></a></li> </ul> <fieldset id="geo-mashup-overall-settings"> <?php wp_nonce_field('geo-mashup-update-options'); ?> <input id="geo-mashup-selected-tab" name="geo_mashup_selected_tab" type="hidden" value="<?php echo $selected_tab; ?> " /> <p><?php _e('Overall Geo Mashup Settings', 'GeoMashup'); ?> </p> <table width="100%" cellspacing="2" cellpadding="5" class="editform"> <tr> <th scope="row"> <?php _e('Map Provider', 'GeoMashup'); ?> </th> <td> <select id="map_api" name="overall[map_api]"><?php foreach ($mapApis as $value => $label) { ?> <option value="<?php echo $value; ?> "<?php if ($geo_mashup_options->get('overall', 'map_api') == $value) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <?php if ('google' == $map_api) { ?> <span class="description"> <a href="https://developers.google.com/maps/documentation/javascript/v2/reference"><?php _e('Google v2 has expired and will be removed in version 1.9.', 'GeoMashup'); ?> </a> </span> <?php } ?> </td> </tr> <?php if ('google' == $map_api) { ?> <tr> <th width="33%" scope="row"><?php _e('Google API Key', 'GeoMashup'); ?> </th> <td<?php if (empty($google_key)) { echo ' class="error"'; } ?> > <input id="google_key" name="overall[google_key]" class="overall-submit" type="text" size="40" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'google_key')); ?> " /> <a href="http://maps.google.com/apis/maps/signup.html"><?php _e('Get yours here', 'GeoMashup'); ?> </a> <?php if (empty($google_key)) { ?> <p class="description"> <?php _e('This setting is required for Geo Mashup to work.', 'GeoMashup'); ?> </p> <?php } ?> </td> </tr> <?php } ?> <?php if ('googlev3' == $map_api) { ?> <tr> <th width="33%" scope="row"><?php _e('Google API Key', 'GeoMashup'); ?> </th> <td> <input id="googlev3_key" name="overall[googlev3_key]" class="overall-submit" type="text" size="40" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'googlev3_key')); ?> " /> <a href="https://developers.google.com/maps/documentation/javascript/tutorial#api_key"><?php _e('Get yours here', 'GeoMashup'); ?> </a> <p class="description"> <?php _e('It\'s easiest to leave this blank and use Google v3 without a key, but Google recommends using one. ' . 'If you do, follow the instructions carefully - there are multiple steps.', 'GeoMashup'); ?> </p> </td> </tr> <?php } ?> <tr> <th scope="row" title="<?php _e('Generated links go here', 'GeoMashup'); ?> "> <?php _e('Global Mashup Page', 'GeoMashup'); ?> </th> <td> <?php wp_dropdown_pages(array('name' => 'overall[mashup_page]', 'id' => 'mashup_page', 'show_option_none' => __('— Select —'), 'option_none_value' => 0, 'selected' => $geo_mashup_options->get('overall', 'mashup_page'))); ?> <span class="description"><?php _e('Geo Mashup will use this page for generated location links', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Collect Location For', 'GeoMashup'); ?> </th> <td> <?php foreach (get_post_types(array('show_ui' => true), 'objects') as $post_type) { ?> <input id="locate_posts" name="overall[located_post_types][]" type="checkbox" value="<?php echo $post_type->name; ?> "<?php if (in_array($post_type->name, $geo_mashup_options->get('overall', 'located_post_types'))) { echo ' checked="checked"'; } ?> /> <?php echo $post_type->labels->name; ?> <?php } ?> <input id="locate_users" name="overall[located_object_name][user]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'located_object_name', 'user') == 'true') { echo ' checked="checked"'; } ?> /> <?php _e('Users', 'GeoMashup'); ?> <input id="locate_comments" name="overall[located_object_name][comment]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'located_object_name', 'comment') == 'true') { echo ' checked="checked"'; } ?> /> <?php _e('Comments', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Enable Geo Search', 'GeoMashup'); ?> </th> <td> <input id="enable_geo_search" name="overall[enable_geo_search]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'enable_geo_search') == 'true') { echo ' checked="checked"'; } ?> /> <span class="description"><?php _e('Creates a customizable widget and other features for performing radius searches.', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Include Taxonomies', 'GeoMashup'); ?> </th> <td> <?php foreach (get_taxonomies(array('show_ui' => true), 'objects') as $taxonomy) { ?> <input id="locate_posts" name="overall[include_taxonomies][]" type="checkbox" value="<?php echo $taxonomy->name; ?> "<?php if (in_array($taxonomy->name, $geo_mashup_options->get('overall', 'include_taxonomies'))) { echo ' checked="checked"'; } ?> /> <?php echo $taxonomy->labels->name; ?> <?php } ?> <br /> <span class="description"><?php _e('Makes legends, colors, and other features available. Minimize use of these for best performance.', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th width="33%" scope="row"><?php _e('Copy Geodata Meta Fields', 'GeoMashup'); ?> </th> <td> <input id="copy_geodata" name="overall[copy_geodata]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'copy_geodata') == 'true') { echo ' checked="checked"'; } ?> /> <span class="description"><?php printf(__('Copy coordinates to and from %s geodata meta fields %s, for integration with the Geolocation and other plugins.', 'GeoMashup'), '<a href="http://codex.wordpress.org/Geodata" title="">', '</a>'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Geocode Custom Field', 'GeoMashup'); ?> </th> <td> <input id="import_custom_field" name="overall[import_custom_field]" class="overall-submit" type="text" size="35" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'import_custom_field')); ?> " /><br/> <span class="description"><?php _e('Comma separated keys of custom fields to be geocoded when saved. Multiple fields will be combined in order before geocoding. Saves a location for the post if found.', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Enable Reverse Geocoding', 'GeoMashup'); ?> </th> <td> <input id="enable_reverse_geocoding" name="overall[enable_reverse_geocoding]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'enable_reverse_geocoding') == 'true') { echo ' checked="checked"'; } ?> /> <span class="description"><?php _e('Try to look up missing address fields for new locations.', 'GeoMashup'); ?> </span> </td> </tr> <?php if ($geo_mashup_options->get('overall', 'enable_reverse_geocoding') == 'true') { ?> <tr> <th scope="row"><?php _e('Bulk Reverse Geocode', 'GeoMashup'); ?> </th> <td> <input type="submit" name="bulk_reverse_geocode" value="<?php _e('Start', 'GeoMashup'); ?> " class="button" /> <span class="description"><?php _e('Try to look up missing address fields for existing locations. Could be slow.', 'GeoMashup'); ?> </span> </td> </tr> <?php } ?> <tr> <th scope="row"><?php _e('Use Theme Style Sheet with Maps', 'GeoMashup'); ?> </th> <td> <input id="theme_stylesheet_with_maps" name="overall[theme_stylesheet_with_maps]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'theme_stylesheet_with_maps') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <tr> <th scope="row"><?php _e('Obscure Settings', 'GeoMashup'); ?> </th> <td> <a id="show_obscure_settings" href="#show_obscure_settings" class="ui-icon ui-icon-triangle-1-e alignleft"></a> <span class="description"><?php _e('Reveal some less commonly used settings.', 'GeoMashup'); ?> </span> </td> </tr> <tr class="obscure"> <th scope="row"><?php _e('GeoNames ID', 'GeoMashup'); ?> </th> <td> <input id="geonames_username_text" name="overall[geonames_username]" class="overall-submit" type="text" size="35" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'geonames_username')); ?> " /><br/> <span class="description"><?php printf(__('Your %sGeoNames username%s, used with GeoNames API requests. Leave the default value to use Geo Mashup\'s.', 'GeoMashup'), '<a href="http://geonames.wordpress.com/2011/01/28/application-identification-for-free-geonames-web-services/" title="">', '</a>'); ?> </span> </td> </tr> <?php if ('google' == $map_api) { ?> <tr class="obscure"> <th scope="row"><?php _e('AdSense For Search ID', 'GeoMashup'); ?> </th> <td> <input id="adsense_code_text" name="overall[adsense_code]" class="overall-submit" type="text" size="35" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'adsense_code')); ?> " /><br/> <span class="description"><?php _e('Your client ID, used with the Google Bar. Leave the default value to use Geo Mashup\'s :).', 'GeoMashup'); ?> </span> </td> </tr> <?php } ?> <tr class="obscure"> <th scope="row"><?php _e('Add Category Links', 'GeoMashup'); ?> </th> <td> <input id="add_category_links" name="overall[add_category_links]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'add_category_links') == 'true') { echo ' checked="checked"'; } ?> /> <span class="description"><?php _e('Add map links to category lists. Categories must have descriptions for this to work.', 'GeoMashup'); ?> </span> </td> </tr> <tr class="obscure"> <th scope="row"><?php _e('Category Link Separator', 'GeoMashup'); ?> </th> <td> <input id="category_link_separator" name="overall[category_link_separator]" class="add-category-links-dep" class="overall-submit" type="text" size="3" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'category_link_separator')); ?> " /> </td> </tr> <tr class="obscure"> <th scope="row"><?php _e('Category Link Text', 'GeoMashup'); ?> </th> <td> <input id="category_link_text" name="overall[category_link_text]" class="overall-submit" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'category_link_text')); ?> " /> </td> </tr> <tr class="obscure"> <th scope="row"><?php _e('Category Link Zoom Level', 'GeoMashup'); ?> </th> <td> <select id="category_zoom" name="overall[category_zoom]"> <?php foreach ($zoomOptions as $value => $label) { ?> <option value="<?php echo esc_attr($value); ?> "<?php if (strcmp($value, $geo_mashup_options->get('overall', 'category_zoom')) == 0) { echo ' selected="selected"'; } ?> ><?php echo esc_attr($label); ?> </option> <?php } ?> </select> <span class="description"><?php _e('0 is zoomed all the way out.', 'GeoMashup'); ?> </span> </td> </tr> </table> <div class="submit"> <input id="overall-submit" class="button button-primary" type="submit" name="submit" value="<?php _e('Update Options', 'GeoMashup'); ?> " /> </div> </fieldset> <fieldset id="geo-mashup-single-map-settings"> <p><?php _e('Default settings for maps of a single located post.', 'GeoMashup'); ?> </p> <table width="100%" cellspacing="2" cellpadding="5" class="editform"> <tr> <th scope="row"><?php _e('Map Width', 'GeoMashup'); ?> </th> <td> <input id="in_post_map_width" name="single_map[width]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('single_map', 'width')); ?> " /> <?php _e('Pixels, or append %.', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Map Height', 'GeoMashup'); ?> </th> <td> <input id="in_post_map_height" name="single_map[height]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('single_map', 'height')); ?> " /> <?php _e('px', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Map Control', 'GeoMashup'); ?> </th> <td> <select id="in_post_map_control" name="single_map[map_control]"> <?php foreach ($mapControls as $type => $label) { ?> <option value="<?php echo esc_attr($type); ?> "<?php if ($type == $geo_mashup_options->get('single_map', 'map_control')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Default Map Type', 'GeoMashup'); ?> </th> <td> <select id="in_post_map_type" name="single_map[map_type]"> <?php foreach ($mapTypes as $type => $label) { ?> <option value="<?php echo esc_attr($type); ?> "<?php if ($type == $geo_mashup_options->get('single_map', 'map_type')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Add Map Type Control', 'GeoMashup'); ?> </th> <td> <?php foreach ($mapTypes as $type => $label) { ?> <input id="in_post_add_map_type_<?php echo esc_attr($type); ?> " name="single_map[add_map_type_control][]" type="checkbox" value="<?php echo esc_attr($type); ?> " <?php if (in_array($type, $geo_mashup_options->get('single_map', 'add_map_type_control'))) { echo ' checked="checked"'; } ?> /> <?php echo esc_html($label); ?> <?php } ?> </td> </tr> <tr> <th scope="row"><?php _e('Add Overview Control', 'GeoMashup'); ?> </th> <td><input id="in_post_add_overview_control" name="single_map[add_overview_control]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('single_map', 'add_overview_control') == 'true') { echo ' checked="checked"'; } ?> /></td> </tr> <?php if ('google' == $map_api) { ?> <tr> <th scope="row"><?php _e('Add Google Bar', 'GeoMashup'); ?> </th> <td><input id="in_post_add_google_bar" name="single_map[add_google_bar]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('single_map', 'add_google_bar') == 'true') { echo ' checked="checked"'; } ?> /></td> </tr> <?php } ?> <tr> <th scope="row"><?php _e('Enable Scroll Wheel Zoom', 'GeoMashup'); ?> </th> <td><input id="in_post_enable_scroll_wheel_zoom" name="single_map[enable_scroll_wheel_zoom]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('single_map', 'enable_scroll_wheel_zoom') == 'true') { echo ' checked="checked"'; } ?> /></td> </tr> <tr> <th scope="row"><?php _e('Default Zoom Level', 'GeoMashup'); ?> </th> <td> <select id="in_post_zoom" name="single_map[zoom]"> <?php foreach ($zoomOptions as $value => $label) { ?> <option value="<?php echo esc_attr($value); ?> "<?php if (strcmp($value, $geo_mashup_options->get('single_map', 'zoom')) == 0) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <span class="description"><?php _e('0 is zoomed all the way out.', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Click To Load', 'GeoMashup'); ?> </th> <td> <input id="in_post_click_to_load" name="single_map[click_to_load]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('single_map', 'click_to_load') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <tr> <th scope="row"><?php _e('Click To Load Text', 'GeoMashup'); ?> </th> <td> <input id="in_post_click_to_load_text" name="single_map[click_to_load_text]" type="text" size="50" value="<?php echo esc_attr($geo_mashup_options->get('single_map', 'click_to_load_text')); ?> " /> </td> </tr> </table> <div class="submit"><input type="submit" name="submit" value="<?php _e('Update Options', 'GeoMashup'); ?> " /></div> </fieldset> <fieldset id="geo-mashup-global-map-settings"> <p><?php _e('Default settings for global maps of located items.', 'GeoMashup'); ?> </p> <div class="submit"><input type="submit" name="submit" value="<?php _e('Update Options', 'GeoMashup'); ?> " /></div> <table width="100%" cellspacing="2" cellpadding="5" class="editform"> <tr> <th scope="row"><?php _e('Map Width', 'GeoMashup'); ?> </th> <td> <input id="map_width" name="global_map[width]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('global_map', 'width')); ?> " /> <?php _e('Pixels, or append %.', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Map Height', 'GeoMashup'); ?> </th> <td> <input id="map_height" name="global_map[height]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('global_map', 'height')); ?> " /> <?php _e('px', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Map Control', 'GeoMashup'); ?> </th> <td> <select id="map_control" name="global_map[map_control]"> <?php foreach ($mapControls as $type => $label) { ?> <option value="<?php echo esc_attr($type); ?> "<?php if ($type == $geo_mashup_options->get('global_map', 'map_control')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Default Map Type', 'GeoMashup'); ?> </th> <td> <select id="map_type" name="global_map[map_type]"> <?php foreach ($mapTypes as $type => $label) { ?> <option value="<?php echo esc_attr($type); ?> "<?php if ($type == $geo_mashup_options->get('global_map', 'map_type')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Add Map Type Control', 'GeoMashup'); ?> </th> <td> <?php foreach ($mapTypes as $type => $label) { ?> <input id="add_map_type_<?php echo esc_attr($type); ?> " name="global_map[add_map_type_control][]" type="checkbox" value="<?php echo esc_attr($type); ?> " <?php if (in_array($type, $geo_mashup_options->get('global_map', 'add_map_type_control'))) { echo ' checked="checked"'; } ?> /> <?php echo esc_html($label); ?> <?php } ?> </td> </tr> <tr> <th scope="row"><?php _e('Add Overview Control', 'GeoMashup'); ?> </th> <td> <input id="add_overview_control" name="global_map[add_overview_control]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('global_map', 'add_overview_control') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <?php if ('google' == $map_api) { ?> <tr> <th scope="row"><?php _e('Add Google Bar', 'GeoMashup'); ?> </th> <td> <input id="add_google_bar" name="global_map[add_google_bar]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('global_map', 'add_google_bar') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <?php } ?> <tr> <th scope="row"><?php _e('Enable Scroll Wheel Zoom', 'GeoMashup'); ?> </th> <td><input id="enable_scroll_wheel_zoom" name="global_map[enable_scroll_wheel_zoom]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('global_map', 'enable_scroll_wheel_zoom') == 'true') { echo ' checked="checked"'; } ?> /></td> </tr> <tr> <th scope="row"><?php _e('Default Zoom Level', 'GeoMashup'); ?> </th> <td> <select id="zoom" name="global_map[zoom]"> <?php foreach ($zoomOptions as $value => $label) { ?> <option value="<?php echo esc_attr($value); ?> "<?php if (strcmp($value, $geo_mashup_options->get('global_map', 'zoom')) == 0) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <span class="description"><?php _e('0 is zoomed all the way out.', 'GeoMashup'); ?> </span> </td> </tr> <?php if ('google' == substr($map_api, 0, 6)) { ?> <tr> <th scope="row"><?php _e('Cluster Markers Until Zoom Level', 'GeoMashup'); ?> </th> <td> <input id="cluster_max_zoom" name="global_map[cluster_max_zoom]" type="text" size="2" value="<?php echo esc_attr($geo_mashup_options->get('global_map', 'cluster_max_zoom')); ?> " /> <span class="description"><?php _e('Highest zoom level to cluster markers, or blank for no clustering.', 'GeoMashup'); ?> </span> </td> </tr> <?php } ?> <tr> <th scope="row"><?php _e('Marker Selection Behaviors', 'GeoMashup'); ?> </th> <td> <input id="global_marker_select_info_window" name="global_map[marker_select_info_window]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('global_map', 'marker_select_info_window') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Open info window', 'GeoMashup'); ?> <input id="global_marker_select_highlight" name="global_map[marker_select_highlight]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('global_map', 'marker_select_highlight') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Highlight', 'GeoMashup'); ?> <input id="global_marker_select_center" name="global_map[marker_select_center]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('global_map', 'marker_select_center') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Center', 'GeoMashup'); ?> <input id="global_marker_select_attachments" name="global_map[marker_select_attachments]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('global_map', 'marker_select_attachments') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Show Geo Attachments', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Automatic Selection', 'GeoMashup'); ?> </th> <td> <input id="auto_info_open" name="global_map[auto_info_open]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('global_map', 'auto_info_open') == 'true') { echo ' checked="checked"'; } ?> /> <span class="description"><?php _e('Selects the linked or most recent item when the map loads.', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Show Only Most Recent Items', 'GeoMashup'); ?> </th> <td> <input id="max_posts" name="global_map[max_posts]" type="text" size="4" value="<?php echo esc_attr($geo_mashup_options->get('global_map', 'max_posts')); ?> " /> <span class="description"><?php _e('Number of items to show, leave blank for all', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Show Future Posts', 'GeoMashup'); ?> </th> <td><select id="show_future" name="global_map[show_future]"> <?php foreach ($futureOptions as $value => $label) { ?> <option value="<?php echo esc_attr($value); ?> "<?php if ($value == $geo_mashup_options->get('global_map', 'show_future')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select></td> </tr> <tr> <th scope="row"><?php _e('Click To Load', 'GeoMashup'); ?> </th> <td> <input id="click_to_load" name="global_map[click_to_load]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('global_map', 'click_to_load') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <tr> <th scope="row"><?php _e('Click To Load Text', 'GeoMashup'); ?> </th> <td> <input id="click_to_load_text" name="global_map[click_to_load_text]" type="text" size="50" value="<?php echo esc_attr($geo_mashup_options->get('global_map', 'click_to_load_text')); ?> " /> </td> </tr> <?php if (!empty($include_taxonomies) and !defined('GEO_MASHUP_DISABLE_CATEGORIES')) { ?> <tr><td colspan="2" align="center"> <?php foreach ($include_taxonomies as $include_taxonomy) { ?> <?php $taxonomy_object = get_taxonomy($include_taxonomy); ?> <?php $taxonomy_options = $geo_mashup_options->get('global_map', 'term_options', $include_taxonomy); ?> <table> <tr><th><?php echo $taxonomy_object->label; ?> </th><th><?php _e('Color', 'GeoMashup'); ?> </th> <th><?php _e('Show Connecting Line Until Zoom Level (0-20 or none)', 'GeoMashup'); ?> </th></tr> <?php $terms = get_terms($include_taxonomy, array('hide_empty' => false)); ?> <?php if (is_array($terms)) { ?> <?php foreach ($terms as $term) { ?> <tr><td><?php echo esc_html($term->name); ?> </td> <td> <select id="<?php echo $include_taxonomy; ?> _color_<?php echo esc_attr($term->slug); ?> " name="global_map[term_options][<?php echo $include_taxonomy; ?> ][color][<?php echo esc_attr($term->slug); ?> ]"> <?php foreach ($colorNames as $name => $rgb) { ?> <option value="<?php echo esc_attr($name); ?> "<?php if (isset($taxonomy_options['color'][$term->slug]) and $taxonomy_options['color'][$term->slug] == $name) { echo ' selected="selected"'; } ?> style="background-color:<?php echo esc_attr($rgb); ?> ;"><?php echo esc_html($name); ?> </option> <?php } // color name ?> </select> </td><td> <input id="<?php echo $include_taxonomy; ?> _line_zoom_<?php echo esc_attr($term->slug); ?> " name="global_map[term_options][<?php echo $include_taxonomy; ?> ][line_zoom][<?php echo esc_attr($term->slug); ?> ]" value="<?php if (isset($taxonomy_options['line_zoom'][$term->slug])) { echo esc_attr($taxonomy_options['line_zoom'][$term->slug]); } ?> " type="text" size="2" maxlength="2" /></td></tr> <?php } // taxonomy term ?> <?php } ?> </table> <?php } // included taxonomy ?> </td></tr> <?php } ?> </table> <div class="submit"><input type="submit" name="submit" value="<?php _e('Update Options', 'GeoMashup'); ?> " /></div> </fieldset> <fieldset id="geo-mashup-context-map-settings"> <p><?php _e('Default settings for contextual maps, which include just the items shown on a page, for example.', 'GeoMashup'); ?> </p> <table width="100%" cellspacing="2" cellpadding="5" class="editform"> <tr> <th scope="row"><?php _e('Map Width', 'GeoMashup'); ?> </th> <td> <input id="context_map_width" name="context_map[width]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('context_map', 'width')); ?> " /> <?php _e('Pixels, or append %.', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Map Height', 'GeoMashup'); ?> </th> <td> <input id="context_map_height" name="context_map[height]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('context_map', 'height')); ?> " /> <?php _e('px', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Map Control', 'GeoMashup'); ?> </th> <td> <select id="context_map_control" name="context_map[map_control]"> <?php foreach ($mapControls as $type => $label) { ?> <option value="<?php echo esc_attr($type); ?> "<?php if ($type == $geo_mashup_options->get('context_map', 'map_control')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Default Map Type', 'GeoMashup'); ?> </th> <td> <select id="context_map_type" name="context_map[map_type]"> <?php foreach ($mapTypes as $type => $label) { ?> <option value="<?php echo esc_attr($type); ?> "<?php if ($type == $geo_mashup_options->get('context_map', 'map_type')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Add Map Type Control', 'GeoMashup'); ?> </th> <td> <?php foreach ($mapTypes as $type => $label) { ?> <input id="context_add_map_type_<?php echo esc_attr($type); ?> " name="context_map[add_map_type_control][]" type="checkbox" value="<?php echo esc_attr($type); ?> " <?php if (in_array($type, $geo_mashup_options->get('context_map', 'add_map_type_control'))) { echo ' checked="checked"'; } ?> /> <?php echo esc_html($label); ?> <?php } ?> </td> </tr> <tr> <th scope="row"><?php _e('Add Overview Control', 'GeoMashup'); ?> </th> <td> <input id="context_add_overview_control" name="context_map[add_overview_control]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('context_map', 'add_overview_control') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <?php if ('google' == $map_api) { ?> <tr> <th scope="row"><?php _e('Add Google Bar', 'GeoMashup'); ?> </th> <td> <input id="context_add_google_bar" name="context_map[add_google_bar]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('context_map', 'add_google_bar') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <?php } ?> <tr> <th scope="row"><?php _e('Enable Scroll Wheel Zoom', 'GeoMashup'); ?> </th> <td><input id="context_enable_scroll_wheel_zoom" name="context_map[enable_scroll_wheel_zoom]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('context_map', 'enable_scroll_wheel_zoom') == 'true') { echo ' checked="checked"'; } ?> /></td> </tr> <tr> <th scope="row"><?php _e('Default Zoom Level', 'GeoMashup'); ?> </th> <td> <select id="context_zoom" name="context_map[zoom]"> <?php foreach ($zoomOptions as $value => $label) { ?> <option value="<?php echo esc_attr($value); ?> "<?php if (strcmp($value, $geo_mashup_options->get('context_map', 'zoom')) == 0) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <span class="description"><?php _e('0 is zoomed all the way out.', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Marker Selection Behaviors', 'GeoMashup'); ?> </th> <td> <input id="context_marker_select_info_window" name="context_map[marker_select_info_window]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('context_map', 'marker_select_info_window') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Open info window', 'GeoMashup'); ?> <input id="context_marker_select_highlight" name="context_map[marker_select_highlight]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('context_map', 'marker_select_highlight') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Highlight', 'GeoMashup'); ?> <input id="context_marker_select_center" name="context_map[marker_select_center]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('context_map', 'marker_select_center') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Center', 'GeoMashup'); ?> <input id="context_marker_select_attachments" name="context_map[marker_select_attachments]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('context_map', 'marker_select_attachments') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Show Geo Attachments', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Click To Load', 'GeoMashup'); ?> </th> <td> <input id="context_click_to_load" name="context_map[click_to_load]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('context_map', 'click_to_load') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <tr> <th scope="row"><?php _e('Click To Load Text', 'GeoMashup'); ?> </th> <td> <input id="context_click_to_load_text" name="context_map[click_to_load_text]" type="text" size="50" value="<?php echo esc_attr($geo_mashup_options->get('context_map', 'click_to_load_text')); ?> " /> </td> </tr> </table> <div class="submit"><input type="submit" name="submit" value="<?php _e('Update Options', 'GeoMashup'); ?> " /></div> </fieldset> <fieldset id="geo-mashup-tests"> <p> <?php _e('Some checks that Geo Mashup is working properly.', 'GeoMashup'); ?> <?php _e('Not working in Firefox yet - free Geo Mashup license to the first to figure out why!', 'GeoMashup'); ?> </p> <?php if (isset($_POST['geo_mashup_run_tests'])) { ?> <div id="qunit-fixture"></div> <div id="qunit"></div> <?php } else { ?> <input type="submit" name="geo_mashup_run_tests" value="<?php _e('Run Tests', 'GeoMashup'); ?> " class="button" /> <?php } ?> </fieldset> </form> <?php if (isset($_GET['view_activation_log'])) { ?> <div class="updated"> <p><strong><?php _e('Update Log', 'GeoMashup'); ?> </strong></p> <pre><?php echo get_option('geo_mashup_activation_log'); ?> </pre> <form method="post" id="geo-mashup-log-form" action="<?php echo $_SERVER['REQUEST_URI']; ?> "> <?php wp_nonce_field('geo-mashup-delete-log'); ?> <input type="submit" name="delete_log" value="<?php _e('Delete Log', 'GeoMashup'); ?> " class="button" /> <p><?php _e('You can keep this log as a record, future entries will be appended.', 'GeoMashup'); ?> </p> </form> </div> <?php } else { ?> <p><a href="<?php echo $_SERVER['REQUEST_URI']; ?> &view_activation_log=1"><?php _e('View Update Log', 'GeoMashup'); ?> </a></p> <?php } ?> <p><a href="https://github.com/cyberhobo/wordpress-geo-mashup/wiki/Getting-Started"><?php _e('Geo Mashup Documentation', 'GeoMashup'); ?> </a></p> <p> <a href="http://wpquestions.com/affiliates/register/name/cyberhobo"> <img src="<?php echo path_join(GEO_MASHUP_URL_PATH, 'images/wpquestions-logo.png'); ?> " alt="WP Questions"> </a> </p> <p>Geo Mashup needs you: <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=11045324">donate</a>, contribute <a href="https://github.com/cyberhobo/wordpress-geo-mashup/wiki/How-To-Guides">a guide</a> or <a href="https://github.com/cyberhobo/wordpress-geo-mashup">code</a>, share your experience in the <a href="https://wordpress.org/support/plugin/geo-mashup">volunteer support forum</a>, or use this HTML to add a link to your site: <input id="geo-mashup-credit-input" type="text" size="80" value="<?php echo esc_attr('<a href="https://wordpress.org/plugins/geo-mashup/" title="Geo Mashup"><img src="' . path_join(GEO_MASHUP_URL_PATH, 'images/gm-credit.png') . '" alt="Geo Mashup" /></a>'); ?> " /><br /> Thanks! </p> <script type="text/javascript"> jQuery( function( $ ) { $( '#geo-mashup-credit-input' ).focus( function() { this.select(); } ) } ); </script> </div> <?php }
/** * Print Geo Mashup Options HTML * * @since 1.2 * @access public */ function geo_mashup_options_page() { global $geo_mashup_options; $activated_copy_geodata = false; if (isset($_POST['submit'])) { // Process option updates check_admin_referer('geo-mashup-update-options'); // Missing add_map_type_control means empty array if (empty($_POST['global_map']['add_map_type_control'])) { $_POST['global_map']['add_map_type_control'] = array(); } if (empty($_POST['single_map']['add_map_type_control'])) { $_POST['single_map']['add_map_type_control'] = array(); } if (empty($_POST['context_map']['add_map_type_control'])) { $_POST['context_map']['add_map_type_control'] = array(); } if (empty($_POST['overall']['located_post_types'])) { $_POST['overall']['located_post_types'] = array(); } if ('true' != $geo_mashup_options->get('overall', 'copy_geodata') and isset($_POST['overall']['copy_geodata'])) { $activated_copy_geodata = true; } $geo_mashup_options->set_valid_options($_POST); if ($geo_mashup_options->save()) { echo '<div class="updated fade"><p>' . __('Options updated.', 'GeoMashup') . '</p></div>'; } } if ($activated_copy_geodata) { GeoMashupDB::duplicate_geodata(); echo '<div class="updated fade"><p>' . __('Copied existing geodata, see log for details.', 'GeoMashup') . '</p></div>'; } if (isset($_POST['bulk_reverse_geocode'])) { check_admin_referer('geo-mashup-update-options'); $log = GeoMashupDB::bulk_reverse_geocode(); echo '<div class="updated fade">' . $log . '</div>'; } if (GEO_MASHUP_DB_VERSION != GeoMashupDB::installed_version()) { if (GeoMashupDB::install()) { echo '<div class="updated fade"><p>' . __('Database upgraded, see log for details.', 'GeoMashup') . '</p></div>'; } } if (isset($_POST['delete_log'])) { check_admin_referer('geo-mashup-delete-log'); if (update_option('geo_mashup_activation_log', '')) { echo '<div class="updated fade"><p>' . __('Log deleted.', 'GeoMashup') . '</p></div>'; } } if (!empty($geo_mashup_options->corrupt_options)) { // Options didn't load correctly $message .= ' ' . __('Saved options may be corrupted, try updating again. Corrupt values: ') . '<code>' . $geo_mashup_options->corrupt_options . '</code>'; echo '<div class="updated"><p>' . $message . '</p></div>'; } if (!empty($geo_mashup_options->validation_errors)) { // There were invalid options echo '<div class="updated"><p>' . __('Some invalid options will not be used. If you\'ve just upgraded, do an update to initialize new options.', 'GeoMashup'); echo '<ul>'; foreach ($geo_mashup_options->validation_errors as $message) { echo "<li>{$message}</li>"; } echo '</ul></p></div>'; } // Create marker and color arrays $colorNames = array('aqua' => '#00ffff', 'black' => '#000000', 'blue' => '#0000ff', 'fuchsia' => '#ff00ff', 'gray' => '#808080', 'green' => '#008000', 'lime' => '#00ff00', 'maroon' => '#800000', 'navy' => '#000080', 'olive' => '#808000', 'orange' => '#ffa500', 'purple' => '#800080', 'red' => '#ff0000', 'silver' => '#c0c0c0', 'teal' => '#008080', 'white' => '#ffffff', 'yellow' => '#ffff00'); $mapTypes = array('G_NORMAL_MAP' => __('Roadmap', 'GeoMashup'), 'G_SATELLITE_MAP' => __('Satellite', 'GeoMashup'), 'G_HYBRID_MAP' => __('Hybrid', 'GeoMashup'), 'G_PHYSICAL_MAP' => __('Terrain', 'GeoMashup'), 'G_SATELLITE_3D_MAP' => __('Earth Plugin', 'GeoMashup')); $mapControls = array('GSmallZoomControl' => __('Small Zoom', 'GeoMashup'), 'GSmallZoomControl3D' => __('Small Zoom 3D', 'GeoMashup'), 'GSmallMapControl' => __('Small Pan/Zoom', 'GeoMashup'), 'GLargeMapControl' => __('Large Pan/Zoom', 'GeoMashup'), 'GLargeMapControl3D' => __('Large Pan/Zoom 3D', 'GeoMashup')); $futureOptions = array('true' => __('Yes', 'GeoMashup'), 'false' => __('No', 'GeoMashup'), 'only' => __('Only', 'GeoMashup')); $mapApis = array('google' => __('Google v2', 'GeoMashup'), 'googlev3' => __('Google v3', 'GeoMashup'), 'openlayers' => __('OpenLayers', 'GeoMashup')); $zoomOptions = array('auto' => __('auto', 'GeoMashup')); for ($i = 0; $i < GEO_MASHUP_MAX_ZOOM; $i++) { $zoomOptions[$i] = $i; } $clusterOptions = array('clustermarker' => __('Cluster Marker', 'GeoMashup'), 'markerclusterer' => __('Marker Clusterer', 'GeoMashup')); $selected_tab = empty($_POST['geo_mashup_selected_tab']) ? 0 : $_POST['geo_mashup_selected_tab']; $google_key = $geo_mashup_options->get('overall', 'google_key'); $map_api = $geo_mashup_options->get('overall', 'map_api'); // Now for the HTML ?> <script type="text/javascript"> jQuery(function( $ ) { var selector = '#geo-mashup-settings-form'; $( selector ).tabs( { selected: <?php echo $selected_tab; ?> , select: function ( event, ui ) { $( '#geo-mashup-selected-tab' ).val( ui.index ); } } ); $( '#import_custom_field' ).suggest( ajaxurl + '?action=geo_mashup_suggest_custom_keys' ); $( '#map_api' ).change( function() { $( '#overall-submit' ).click(); } ); } ); </script> <div class="wrap"> <h2><?php _e('Geo Mashup Options', 'GeoMashup'); ?> </h2> <form method="post" id="geo-mashup-settings-form" action="<?php echo $_SERVER['REQUEST_URI']; ?> "> <ul> <li><a href="#geo-mashup-overall-settings"><span><?php _e('Overall', 'GeoMashup'); ?> </span></a></li> <li><a href="#geo-mashup-single-map-settings"><span><?php _e('Single Maps', 'GeoMashup'); ?> </span></a></li> <li><a href="#geo-mashup-global-map-settings"><span><?php _e('Global Maps', 'GeoMashup'); ?> </span></a></li> <li><a href="#geo-mashup-context-map-settings"><span><?php _e('Contextual Maps', 'GeoMashup'); ?> </span></a></li> </ul> <fieldset id="geo-mashup-overall-settings"> <?php wp_nonce_field('geo-mashup-update-options'); ?> <input id="geo-mashup-selected-tab" name="geo_mashup_selected_tab" type="hidden" value="<?php echo $selected_tab; ?> " /> <p><?php _e('Overall Geo Mashup Settings', 'GeoMashup'); ?> </p> <table width="100%" cellspacing="2" cellpadding="5" class="editform"> <tr> <th scope="row"> <?php _e('Map Provider', 'GeoMashup'); ?> </th> <td> <select id="map_api" name="overall[map_api]"><?php foreach ($mapApis as $value => $label) { ?> <option value="<?php echo $value; ?> "<?php if ($geo_mashup_options->get('overall', 'map_api') == $value) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <span class="description"><?php _e('Some features still work only with Google v2.', 'GeoMashup'); ?> </span> </td> </tr> <?php if ('google' == $map_api) { ?> <tr> <th width="33%" scope="row"><?php _e('Google API Key', 'GeoMashup'); ?> </th> <td<?php if (empty($google_key)) { echo ' class="error"'; } ?> > <input id="google_key" name="overall[google_key]" type="text" size="40" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'google_key')); ?> " /> <a href="http://maps.google.com/apis/maps/signup.html"><?php _e('Get yours here', 'GeoMashup'); ?> </a> <?php if (empty($google_key)) { ?> <p class="description"> <?php _e('This setting is required for Geo Mashup to work.', 'GeoMashup'); ?> </p> <?php } ?> </td> </tr> <?php } ?> <tr> <th scope="row" title="<?php _e('Generated links go here', 'GeoMashup'); ?> "> <?php _e('Global Mashup Page', 'GeoMashup'); ?> </th> <td> <select id="mashup_page" name="overall[mashup_page]"><?php $pages = get_pages(); if ($pages) { foreach ($pages as $page) { ?> <option value="<?php echo esc_attr($page->ID); ?> "<?php if ($geo_mashup_options->get('overall', 'mashup_page') == $page->ID) { echo ' selected="selected"'; } ?> ><?php echo esc_html($page->post_name); ?> </option> <?php } ?> <?php } else { ?> <option value=""><?php _e('No pages available.', 'GeoMashup'); ?> </option> <?php } ?> </select> <span class="description"><?php _e('Geo Mashup will use this page for generated location links', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Collect Location For', 'GeoMashup'); ?> </th> <td> <?php foreach (get_post_types(array('show_ui' => true), 'objects') as $post_type) { ?> <input id="locate_posts" name="overall[located_post_types][]" type="checkbox" value="<?php echo $post_type->name; ?> "<?php if (in_array($post_type->name, $geo_mashup_options->get('overall', 'located_post_types'))) { echo ' checked="checked"'; } ?> /> <?php echo $post_type->labels->name; ?> <?php } ?> <input id="locate_users" name="overall[located_object_name][user]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'located_object_name', 'user') == 'true') { echo ' checked="checked"'; } ?> /> <?php _e('Users', 'GeoMashup'); ?> <input id="locate_comments" name="overall[located_object_name][comment]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'located_object_name', 'comment') == 'true') { echo ' checked="checked"'; } ?> /> <?php _e('Comments', 'GeoMashup'); ?> </td> </tr> <tr> <th width="33%" scope="row"><?php _e('Copy Geodata Meta Fields', 'GeoMashup'); ?> </th> <td> <input id="copy_geodata" name="overall[copy_geodata]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'copy_geodata') == 'true') { echo ' checked="checked"'; } ?> /> <span class="description"><?php printf(__('Copy coordinates to and from %sgeodata meta fields%s, for integration with the Geolocation and other plugins.', 'GeoMashup'), '<a href="http://codex.wordpress.org/Geodata" title="">', '</a>'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Geocode Custom Field', 'GeoMashup'); ?> </th> <td> <input id="import_custom_field" name="overall[import_custom_field]" type="text" size="35" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'import_custom_field')); ?> " /><br/> <span class="description"><?php _e('Custom fields with this key will be geocoded and the resulting location saved for the post.', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Enable Reverse Geocoding', 'GeoMashup'); ?> </th> <td> <input id="enable_reverse_geocoding" name="overall[enable_reverse_geocoding]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'enable_reverse_geocoding') == 'true') { echo ' checked="checked"'; } ?> /> <span class="description"><?php _e('Try to look up missing address fields for new locations.', 'GeoMashup'); ?> </span> </td> </tr> <?php if ($geo_mashup_options->get('overall', 'enable_reverse_geocoding') == 'true') { ?> <tr> <th scope="row"><?php _e('Bulk Reverse Geocode', 'GeoMashup'); ?> </th> <td> <input type="submit" name="bulk_reverse_geocode" value="<?php _e('Start', 'GeoMashup'); ?> " class="button" /> <span class="description"><?php _e('Try to look up missing address fields for existing locations. Could be slow.', 'GeoMashup'); ?> </span> </td> </tr> <?php } ?> <tr> <th scope="row"><?php _e('Use Theme Style Sheet with Maps', 'GeoMashup'); ?> </th> <td> <input id="theme_stylesheet_with_maps" name="overall[theme_stylesheet_with_maps]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'theme_stylesheet_with_maps') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <tr> <th scope="row"><?php _e('Add Category Links', 'GeoMashup'); ?> </th> <td> <input id="add_category_links" name="overall[add_category_links]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('overall', 'add_category_links') == 'true') { echo ' checked="checked"'; } ?> /> <span class="description"><?php _e('Add map links to category lists. Categories must have descriptions for this to work.', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Category Link Separator', 'GeoMashup'); ?> </th> <td> <input id="category_link_separator" name="overall[category_link_separator]" class="add-category-links-dep" type="text" size="3" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'category_link_separator')); ?> " /> </td> </tr> <tr> <th scope="row"><?php _e('Category Link Text', 'GeoMashup'); ?> </th> <td> <input id="category_link_text" name="overall[category_link_text]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'category_link_text')); ?> " /> </td> </tr> <tr> <th scope="row"><?php _e('Category Link Zoom Level', 'GeoMashup'); ?> </th> <td> <select id="category_zoom" name="overall[category_zoom]"> <?php foreach ($zoomOptions as $value => $label) { ?> <option value="<?php echo esc_attr($value); ?> "<?php if (strcmp($value, $geo_mashup_options->get('overall', 'category_zoom')) == 0) { echo ' selected="selected"'; } ?> ><?php echo esc_attr($label); ?> </option> <?php } ?> </select> <span class="description"><?php _e('0 is zoomed all the way out.', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('GeoNames ID', 'GeoMashup'); ?> </th> <td> <input id="geonames_username_text" name="overall[geonames_username]" type="text" size="35" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'geonames_username')); ?> " /><br/> <span class="description"><?php printf(__('Your %sGeoNames username%s, used with GeoNames API requests. Leave the default value to use Geo Mashup\'s.', 'GeoMashup'), '<a href="http://geonames.wordpress.com/2011/01/28/application-identification-for-free-geonames-web-services/" title="">', '</a>'); ?> </span> </td> </tr> <?php if ('google' == $map_api) { ?> <tr> <th scope="row"><?php _e('AdSense For Search ID', 'GeoMashup'); ?> </th> <td> <input id="adsense_code_text" name="overall[adsense_code]" type="text" size="35" value="<?php echo esc_attr($geo_mashup_options->get('overall', 'adsense_code')); ?> " /><br/> <span class="description"><?php _e('Your client ID, used with the Google Bar. Leave the default value to use Geo Mashup\'s :).', 'GeoMashup'); ?> </span> </td> </tr> <?php } ?> </table> <div class="submit"><input id="overall-submit" type="submit" name="submit" value="<?php _e('Update Options', 'GeoMashup'); ?> " /></div> </fieldset> <fieldset id="geo-mashup-single-map-settings"> <p><?php _e('Default settings for maps of a single located post.', 'GeoMashup'); ?> </p> <table width="100%" cellspacing="2" cellpadding="5" class="editform"> <tr> <th scope="row"><?php _e('Map Width', 'GeoMashup'); ?> </th> <td> <input id="in_post_map_width" name="single_map[width]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('single_map', 'width')); ?> " /> <?php _e('Pixels, or append %.', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Map Height', 'GeoMashup'); ?> </th> <td> <input id="in_post_map_height" name="single_map[height]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('single_map', 'height')); ?> " /> <?php _e('px', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Map Control', 'GeoMashup'); ?> </th> <td> <select id="in_post_map_control" name="single_map[map_control]"> <?php foreach ($mapControls as $type => $label) { ?> <option value="<?php echo esc_attr($type); ?> "<?php if ($type == $geo_mashup_options->get('single_map', 'map_control')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Default Map Type', 'GeoMashup'); ?> </th> <td> <select id="in_post_map_type" name="single_map[map_type]"> <?php foreach ($mapTypes as $type => $label) { ?> <option value="<?php echo esc_attr($type); ?> "<?php if ($type == $geo_mashup_options->get('single_map', 'map_type')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Add Map Type Control', 'GeoMashup'); ?> </th> <td> <?php foreach ($mapTypes as $type => $label) { ?> <input id="in_post_add_map_type_<?php echo esc_attr($type); ?> " name="single_map[add_map_type_control][]" type="checkbox" value="<?php echo esc_attr($type); ?> " <?php if (in_array($type, $geo_mashup_options->get('single_map', 'add_map_type_control'))) { echo ' checked="checked"'; } ?> /> <?php echo esc_html($label); ?> <?php } ?> </td> </tr> <tr> <th scope="row"><?php _e('Add Overview Control', 'GeoMashup'); ?> </th> <td><input id="in_post_add_overview_control" name="single_map[add_overview_control]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('single_map', 'add_overview_control') == 'true') { echo ' checked="checked"'; } ?> /></td> </tr> <?php if ('google' == $map_api) { ?> <tr> <th scope="row"><?php _e('Add Google Bar', 'GeoMashup'); ?> </th> <td><input id="in_post_add_google_bar" name="single_map[add_google_bar]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('single_map', 'add_google_bar') == 'true') { echo ' checked="checked"'; } ?> /></td> </tr> <?php } ?> <tr> <th scope="row"><?php _e('Enable Scroll Wheel Zoom', 'GeoMashup'); ?> </th> <td><input id="in_post_enable_scroll_wheel_zoom" name="single_map[enable_scroll_wheel_zoom]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('single_map', 'enable_scroll_wheel_zoom') == 'true') { echo ' checked="checked"'; } ?> /></td> </tr> <tr> <th scope="row"><?php _e('Default Zoom Level', 'GeoMashup'); ?> </th> <td> <select id="in_post_zoom" name="single_map[zoom]"> <?php foreach ($zoomOptions as $value => $label) { ?> <option value="<?php echo esc_attr($value); ?> "<?php if (strcmp($value, $geo_mashup_options->get('single_map', 'zoom')) == 0) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <span class="description"><?php _e('0 is zoomed all the way out.', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Click To Load', 'GeoMashup'); ?> </th> <td> <input id="in_post_click_to_load" name="single_map[click_to_load]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('single_map', 'click_to_load') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <tr> <th scope="row"><?php _e('Click To Load Text', 'GeoMashup'); ?> </th> <td> <input id="in_post_click_to_load_text" name="single_map[click_to_load_text]" type="text" size="50" value="<?php echo esc_attr($geo_mashup_options->get('single_map', 'click_to_load_text')); ?> " /> </td> </tr> </table> <div class="submit"><input type="submit" name="submit" value="<?php _e('Update Options', 'GeoMashup'); ?> " /></div> </fieldset> <fieldset id="geo-mashup-global-map-settings"> <p><?php _e('Default settings for global maps of located items.', 'GeoMashup'); ?> </p> <div class="submit"><input type="submit" name="submit" value="<?php _e('Update Options', 'GeoMashup'); ?> " /></div> <table width="100%" cellspacing="2" cellpadding="5" class="editform"> <tr> <th scope="row"><?php _e('Map Width', 'GeoMashup'); ?> </th> <td> <input id="map_width" name="global_map[width]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('global_map', 'width')); ?> " /> <?php _e('Pixels, or append %.', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Map Height', 'GeoMashup'); ?> </th> <td> <input id="map_height" name="global_map[height]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('global_map', 'height')); ?> " /> <?php _e('px', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Map Control', 'GeoMashup'); ?> </th> <td> <select id="map_control" name="global_map[map_control]"> <?php foreach ($mapControls as $type => $label) { ?> <option value="<?php echo esc_attr($type); ?> "<?php if ($type == $geo_mashup_options->get('global_map', 'map_control')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Default Map Type', 'GeoMashup'); ?> </th> <td> <select id="map_type" name="global_map[map_type]"> <?php foreach ($mapTypes as $type => $label) { ?> <option value="<?php echo esc_attr($type); ?> "<?php if ($type == $geo_mashup_options->get('global_map', 'map_type')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Add Map Type Control', 'GeoMashup'); ?> </th> <td> <?php foreach ($mapTypes as $type => $label) { ?> <input id="add_map_type_<?php echo esc_attr($type); ?> " name="global_map[add_map_type_control][]" type="checkbox" value="<?php echo esc_attr($type); ?> " <?php if (in_array($type, $geo_mashup_options->get('global_map', 'add_map_type_control'))) { echo ' checked="checked"'; } ?> /> <?php echo esc_html($label); ?> <?php } ?> </td> </tr> <tr> <th scope="row"><?php _e('Add Overview Control', 'GeoMashup'); ?> </th> <td> <input id="add_overview_control" name="global_map[add_overview_control]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('global_map', 'add_overview_control') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <?php if ('google' == $map_api) { ?> <tr> <th scope="row"><?php _e('Add Google Bar', 'GeoMashup'); ?> </th> <td> <input id="add_google_bar" name="global_map[add_google_bar]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('global_map', 'add_google_bar') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <?php } ?> <tr> <th scope="row"><?php _e('Enable Scroll Wheel Zoom', 'GeoMashup'); ?> </th> <td><input id="enable_scroll_wheel_zoom" name="global_map[enable_scroll_wheel_zoom]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('global_map', 'enable_scroll_wheel_zoom') == 'true') { echo ' checked="checked"'; } ?> /></td> </tr> <tr> <th scope="row"><?php _e('Default Zoom Level', 'GeoMashup'); ?> </th> <td> <select id="zoom" name="global_map[zoom]"> <?php foreach ($zoomOptions as $value => $label) { ?> <option value="<?php echo esc_attr($value); ?> "<?php if (strcmp($value, $geo_mashup_options->get('global_map', 'zoom')) == 0) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <span class="description"><?php _e('0 is zoomed all the way out.', 'GeoMashup'); ?> </span> </td> </tr> <?php if ('google' == $map_api) { ?> <tr> <th scope="row"><?php _e('Cluster Markers Until Zoom Level', 'GeoMashup'); ?> </th> <td> <input id="cluster_library" name="global_map[cluster_lib]" type="hidden" value="clustermarker" /> <input id="cluster_max_zoom" name="global_map[cluster_max_zoom]" type="text" size="2" value="<?php echo esc_attr($geo_mashup_options->get('global_map', 'cluster_max_zoom')); ?> " /> <span class="description"><?php _e('Highest zoom level to cluster markers, or blank for no clustering.', 'GeoMashup'); ?> </span> </td> </tr> <?php } ?> <tr> <th scope="row"><?php _e('Marker Selection Behaviors', 'GeoMashup'); ?> </th> <td> <input id="global_marker_select_info_window" name="global_map[marker_select_info_window]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('global_map', 'marker_select_info_window') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Open info window', 'GeoMashup'); ?> <input id="global_marker_select_highlight" name="global_map[marker_select_highlight]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('global_map', 'marker_select_highlight') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Highlight', 'GeoMashup'); ?> <input id="global_marker_select_center" name="global_map[marker_select_center]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('global_map', 'marker_select_center') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Center', 'GeoMashup'); ?> <input id="global_marker_select_attachments" name="global_map[marker_select_attachments]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('global_map', 'marker_select_attachments') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Show Geo Attachments', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Automatic Selection', 'GeoMashup'); ?> </th> <td> <input id="auto_info_open" name="global_map[auto_info_open]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('global_map', 'auto_info_open') == 'true') { echo ' checked="checked"'; } ?> /> <span class="description"><?php _e('Selects the linked or most recent item when the map loads.', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Show Only Most Recent Items', 'GeoMashup'); ?> </th> <td> <input id="max_posts" name="global_map[max_posts]" type="text" size="4" value="<?php echo esc_attr($geo_mashup_options->get('global_map', 'max_posts')); ?> " /> <span class="description"><?php _e('Number of items to show, leave blank for all', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Show Future Posts', 'GeoMashup'); ?> </th> <td><select id="show_future" name="global_map[show_future]"> <?php foreach ($futureOptions as $value => $label) { ?> <option value="<?php echo esc_attr($value); ?> "<?php if ($value == $geo_mashup_options->get('global_map', 'show_future')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select></td> </tr> <tr> <th scope="row"><?php _e('Click To Load', 'GeoMashup'); ?> </th> <td> <input id="click_to_load" name="global_map[click_to_load]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('global_map', 'click_to_load') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <tr> <th scope="row"><?php _e('Click To Load Text', 'GeoMashup'); ?> </th> <td> <input id="click_to_load_text" name="global_map[click_to_load_text]" type="text" size="50" value="<?php echo esc_attr($geo_mashup_options->get('global_map', 'click_to_load_text')); ?> " /> </td> </tr> <tr><td colspan="2" align="center"> <table> <tr><th><?php _e('Category', 'GeoMashup'); ?> </th><th><?php _e('Color'); ?> </th> <th><?php _e('Show Connecting Line Until Zoom Level (0-20 or none)', 'GeoMashup'); ?> </th></tr> <?php $categories = get_categories(array('hide_empty' => false)); ?> <?php if (is_array($categories)) { ?> <?php foreach ($categories as $category) { ?> <tr><td><?php echo esc_html($category->name); ?> </td> <td> <select id="category_color_<?php echo esc_attr($category->slug); ?> " name="global_map[category_color][<?php echo esc_attr($category->slug); ?> ]"> <?php foreach ($colorNames as $name => $rgb) { ?> <option value="<?php echo esc_attr($name); ?> "<?php if ($name == $geo_mashup_options->get('global_map', 'category_color', $category->slug)) { echo ' selected="selected"'; } ?> style="background-color:<?php echo esc_attr($rgb); ?> '"><?php echo esc_html($name); ?> </option> <?php } ?> </select> </td><td> <input id="category_line_zoom_<?php echo esc_attr($category->slug); ?> " name="global_map[category_line_zoom][<?php echo esc_attr($category->slug); ?> ]" value="<?php echo esc_attr($geo_mashup_options->get('global_map', 'category_line_zoom', $category->slug)); ?> " type="text" size="2" maxlength="2" /></td></tr> <?php } ?> <?php } ?> </table> </td></tr> </table> <div class="submit"><input type="submit" name="submit" value="<?php _e('Update Options', 'GeoMashup'); ?> " /></div> </fieldset> <fieldset id="geo-mashup-context-map-settings"> <p><?php _e('Default settings for contextual maps, which include just the items shown on a page, for example.', 'GeoMashup'); ?> </p> <table width="100%" cellspacing="2" cellpadding="5" class="editform"> <tr> <th scope="row"><?php _e('Map Width', 'GeoMashup'); ?> </th> <td> <input id="context_map_width" name="context_map[width]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('context_map', 'width')); ?> " /> <?php _e('Pixels, or append %.', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Map Height', 'GeoMashup'); ?> </th> <td> <input id="context_map_height" name="context_map[height]" type="text" size="5" value="<?php echo esc_attr($geo_mashup_options->get('context_map', 'height')); ?> " /> <?php _e('px', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Map Control', 'GeoMashup'); ?> </th> <td> <select id="context_map_control" name="context_map[map_control]"> <?php foreach ($mapControls as $type => $label) { ?> <option value="<?php echo esc_attr($type); ?> "<?php if ($type == $geo_mashup_options->get('context_map', 'map_control')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Default Map Type', 'GeoMashup'); ?> </th> <td> <select id="context_map_type" name="context_map[map_type]"> <?php foreach ($mapTypes as $type => $label) { ?> <option value="<?php echo esc_attr($type); ?> "<?php if ($type == $geo_mashup_options->get('context_map', 'map_type')) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Add Map Type Control', 'GeoMashup'); ?> </th> <td> <?php foreach ($mapTypes as $type => $label) { ?> <input id="context_add_map_type_<?php echo esc_attr($type); ?> " name="context_map[add_map_type_control][]" type="checkbox" value="<?php echo esc_attr($type); ?> " <?php if (in_array($type, $geo_mashup_options->get('context_map', 'add_map_type_control'))) { echo ' checked="checked"'; } ?> /> <?php echo esc_html($label); ?> <?php } ?> </td> </tr> <tr> <th scope="row"><?php _e('Add Overview Control', 'GeoMashup'); ?> </th> <td> <input id="context_add_overview_control" name="context_map[add_overview_control]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('context_map', 'add_overview_control') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <?php if ('google' == $map_api) { ?> <tr> <th scope="row"><?php _e('Add Google Bar', 'GeoMashup'); ?> </th> <td> <input id="context_add_google_bar" name="context_map[add_google_bar]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('context_map', 'add_google_bar') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <?php } ?> <tr> <th scope="row"><?php _e('Enable Scroll Wheel Zoom', 'GeoMashup'); ?> </th> <td><input id="context_enable_scroll_wheel_zoom" name="context_map[enable_scroll_wheel_zoom]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('context_map', 'enable_scroll_wheel_zoom') == 'true') { echo ' checked="checked"'; } ?> /></td> </tr> <tr> <th scope="row"><?php _e('Default Zoom Level', 'GeoMashup'); ?> </th> <td> <select id="zoom" name="context_map[zoom]"> <?php foreach ($zoomOptions as $value => $label) { ?> <option value="<?php echo esc_attr($value); ?> "<?php if (strcmp($value, $geo_mashup_options->get('context_map', 'zoom')) == 0) { echo ' selected="selected"'; } ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <span class="description"><?php _e('0 is zoomed all the way out.', 'GeoMashup'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Marker Selection Behaviors', 'GeoMashup'); ?> </th> <td> <input id="context_marker_select_info_window" name="context_map[marker_select_info_window]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('context_map', 'marker_select_info_window') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Open info window', 'GeoMashup'); ?> <input id="context_marker_select_highlight" name="context_map[marker_select_highlight]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('context_map', 'marker_select_highlight') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Highlight', 'GeoMashup'); ?> <input id="context_marker_select_center" name="context_map[marker_select_center]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('context_map', 'marker_select_center') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Center', 'GeoMashup'); ?> <input id="context_marker_select_attachments" name="context_map[marker_select_attachments]" type="checkbox" value="true"<?php echo $geo_mashup_options->get('context_map', 'marker_select_attachments') == 'true' ? ' checked="checked"' : ''; ?> /> <?php _e('Show Geo Attachments', 'GeoMashup'); ?> </td> </tr> <tr> <th scope="row"><?php _e('Click To Load', 'GeoMashup'); ?> </th> <td> <input id="context_click_to_load" name="context_map[click_to_load]" type="checkbox" value="true"<?php if ($geo_mashup_options->get('context_map', 'click_to_load') == 'true') { echo ' checked="checked"'; } ?> /> </td> </tr> <tr> <th scope="row"><?php _e('Click To Load Text', 'GeoMashup'); ?> </th> <td> <input id="context_click_to_load_text" name="context_map[click_to_load_text]" type="text" size="50" value="<?php echo esc_attr($geo_mashup_options->get('context_map', 'click_to_load_text')); ?> " /> </td> </tr> </table> <div class="submit"><input type="submit" name="submit" value="<?php _e('Update Options', 'GeoMashup'); ?> " /></div> </fieldset> </form> <?php if (isset($_GET['view_activation_log'])) { ?> <div class="updated"> <p><strong><?php _e('Update Log', 'GeoMashup'); ?> </strong></p> <pre><?php echo get_option('geo_mashup_activation_log'); ?> </pre> <form method="post" id="geo-mashup-log-form" action="<?php echo $_SERVER['REQUEST_URI']; ?> "> <?php wp_nonce_field('geo-mashup-delete-log'); ?> <input type="submit" name="delete_log" value="<?php _e('Delete Log', 'GeoMashup'); ?> " class="button" /> <p><?php _e('You can keep this log as a record, future entries will be appended.', 'GeoMashup'); ?> </p> </form> </div> <?php } else { ?> <p><a href="<?php echo $_SERVER['REQUEST_URI']; ?> &view_activation_log=1"><?php _e('View Update Log', 'GeoMashup'); ?> </a></p> <?php } ?> <p><a href="http://code.google.com/p/wordpress-geo-mashup/wiki/Documentation"><?php _e('Geo Mashup Documentation', 'GeoMashup'); ?> </a></p> <p><a href="http://wpquestions.com/affiliates/register/name/cyberhobo"><img src="http://wpquestions.com/images/ad-affiliate-200.png" alt="WP Questions"></a></p> <p>Geo Mashup needs you: <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=11045324">donate</a>, contribute <a href="http://wiki.geo-mashup.org/guides">a guide</a> or <a href="http://code.google.com/p/wordpress-geo-mashup/source/checkout">code</a>, answer a question in the <a href="http://groups.google.com/group/wordpress-geo-mashup-plugin">community support group</a>, or use this HTML to add a link to your site: <input id="geo-mashup-credit-input" type="text" size="80" value="<?php echo esc_attr('<a href="http://code.google.com/p/wordpress-geo-mashup/" title="Geo Mashup"><img src="' . path_join(GEO_MASHUP_URL_PATH, 'images/gm-credit.png') . '" alt="Geo Mashup" /></a>'); ?> " /><br /> Thanks! </p> <script type="text/javascript"> jQuery( function( $ ) { $( '#geo-mashup-credit-input' ).focus( function() { this.select(); } ) } ); </script> </div> <?php }
/** * Use templates to output content for objects. * * @since 1.3 */ public static function generate_object_html() { global $geo_mashup_options, $geo_mashup_custom, $comments, $users; $object_ids = $_GET['object_ids']; if (!is_array($object_ids)) { $object_ids = split(',', $object_ids); } $object_name = isset($_GET['object_name']) ? $_GET['object_name'] : 'post'; $template_base = isset($_GET['template']) ? $_GET['template'] : ''; switch ($object_name) { case 'post': $query_vars = array('post__in' => $object_ids, 'post_type' => 'any', 'post_status' => 'publish,future'); // Don't filter this query through other plugins (e.g. event-calendar) $query_vars['suppress_filters'] = true; // No sticky posts please if (function_exists('get_queried_object')) { $query_vars['ignore_sticky_posts'] = true; } else { $query_vars['caller_get_posts'] = true; } // Necessary only for WP 3.0 support // Don't limit the number of results $query_vars['posts_per_page'] = -1; query_posts($query_vars); if (have_posts()) { status_header(200); } $template_base = empty($template_base) ? 'info-window' : $template_base; break; case 'comment': $comments = GeoMashupDB::get_comment_in(array('comment__in' => $object_ids)); if (!empty($comments)) { status_header(200); } $template_base = empty($template_base) ? 'comment' : $template_base; break; case 'user': $users = GeoMashupDB::get_user_in(array('user__in' => $object_ids)); if (!empty($users)) { status_header(200); } $template_base = empty($template_base) ? 'user' : $template_base; break; } load_template(GeoMashup::locate_template($template_base)); }
public static function action_wp_ajax_betareno_add_idea() { $response = array('code' => 200, 'message' => 'ok'); $required_fields = array('api_key', 'what', 'who', 'longitude', 'latitude'); foreach ($required_fields as $field) { if (empty($_POST[$field])) { $response['code'] = 400; $response['message'] = 'Missing required field "' . $field . '"'; echo json_encode($response); exit; } } if (!self::verify_api_key($_POST['api_key'])) { $response['code'] = 403; $response['message'] = 'Invalid API key.' . $field . '"'; echo json_encode($response); exit; } // Create the post $postdata = array('post_type' => 'idea', 'post_title' => $_POST['what'], 'post_status' => 'publish'); $post_id = wp_insert_post($postdata, true); if (is_wp_error($post_id)) { $response['code'] = 500; $response['message'] = $post_id->get_error_message(); echo json_encode($response); exit; } $post = get_post($post_id); // Set the actor $term_ids = wp_set_object_terms($post_id, $_POST['who'], 'actor'); if (is_wp_error($term_ids)) { $response['code'] = 500; $response['message'] = $term_ids->get_error_message(); echo json_encode($response); exit; } $actor = get_term($term_ids[0], 'actor'); // Set the location $location_id = GeoMashupDB::set_object_location('post', $post_id, array('lat' => $_POST['latitude'], 'lng' => $_POST['longitude'])); if (is_wp_error($location_id)) { $response['code'] = 500; $response['message'] = $location_id->get_error_message(); echo json_encode($response); exit; } $location = GeoMashupDB::get_location($location_id); // Set the when $when = ''; if (isset($_POST['when'])) { $time = strtotime($_POST['when']); if ($time) { // Use Reno's timezone $dtzone = new DateTimeZone('America/Los Angeles'); $date = date('r', $time); $dtime = new DateTime($date); $dtime->setTimezone($dtzone); $when = $dtime->format('Y-m-d h:i:00 e'); update_post_meta($post_id, 'when', $when); } } // Handle photos $before_photo_url = ''; if (isset($_FILES['before_photo'])) { $before_photo_id = media_handle_upload('before_photo', $post_id, array('post_title' => 'Before')); if (!is_wp_error($before_photo_id)) { update_post_meta($before_photo_id, 'photo_type', 'before'); list($before_photo_url, $width, $height) = wp_get_attachment_image_src($before_photo_id); } } $after_photo_url = ''; if (isset($_FILES['after_photo'])) { $after_photo_id = media_handle_upload('after_photo', $post_id, array('post_title' => 'After')); if (!is_wp_error($after_photo_id)) { update_post_meta($after_photo_id, 'photo_type', 'after'); list($after_photo_url, $width, $height) = wp_get_attachment_image_src($after_photo_id); } } // Respond with the new idea $response['idea'] = array('ID' => $post_id, 'what' => $post->post_title, 'who' => $actor->name, 'when' => $when, 'latitude' => $location->lat, 'longitude' => $location->lng, 'votes' => 1, 'before_photo_url' => $before_photo_url, 'after_photo_url' => $after_photo_url); echo json_encode($response); exit; }
private function generate_rand_located_posts($count) { $post_ids = $this->factory->post->create_many($count); foreach ($post_ids as $post_id) { GeoMashupDB::set_object_location('post', $post_id, $this->rand_location(), false); } return $post_ids; }
/** * Print the Geo Mashup location editor HTML for an object. * * Goals for this interface are to make it usable for any kind of locatable * object, to be usable without javascript, functional on the front end or admin, * and eventually adaptable to editing multiple locations for an object. * * It's assumed this will go inside an existing form for editing the object, * such as the WordPress admin post edit form. * * @since 1.2 * @see geo-mashup-ui-managers.php * @see geo-mashup-location-editor.js * @uses edit-form.css * @access public * * @param string $object_name The type of object, e.g. 'post', 'user', etc. * @param string $object_id The ID of the object being edited. * @param string $ui_manager Optionally the name of UI Manager class to use for AJAX operations. */ function geo_mashup_edit_form($object_name, $object_id, $ui_manager = '') { global $geo_mashup_options; $help_class = 'geo-mashup-js'; $add_input_style = 'style="display:none;"'; $update_input_style = $delete_input_style = ''; $coordinate_string = ''; // Load any existing location for the object $location = GeoMashupDB::get_object_location($object_name, $object_id); if (empty($location)) { $location = GeoMashupDB::blank_object_location(); $help_class = ''; $add_input_style = ''; $update_input_style = $delete_input_style = 'style="display:none;"'; } else { $coordinate_string = $location->lat . ',' . $location->lng; } $post_location_name = $location->saved_name; $kml_url = ''; // Set a Geo date default when needed & possible $date_missing = empty($location->geo_date) || '0000-00-00 00:00:00' == $location->geo_date; if ('post' == $object_name) { if ($date_missing) { // Geo date defaults to post date $post = get_post($object_id); $location->geo_date = $post->post_date; if (!empty($location->id)) { GeoMashupDB::set_object_location($object_name, $object_id, $location->id, false, $location->geo_date); } } // For posts, look for a KML attachment $kml_urls = GeoMashup::get_kml_attachment_urls($object_id); if (count($kml_urls) > 0) { $kml_url = array_pop($kml_urls); } } else { if ('user' == $object_name && $date_missing) { // Geo date defaults to registration date $user = get_userdata($object_id); $location->geo_date = $user->user_registered; if (!empty($location->id)) { GeoMashupDB::set_object_location($object_name, $object_id, $location->id, false, $location->geo_date); } } else { if ('comment' == $object_name && $date_missing) { // Geo date defaults to comment date $comment = get_comment($object_id); $location->geo_date = $comment->comment_date; if (!empty($location->id)) { GeoMashupDB::set_object_location($object_name, $object_id, $location->id, false, $location->geo_date); } } } } if (empty($location->geo_date)) { $location_datetime = mktime(); } else { $location_datetime = strtotime($location->geo_date); } $location_date = date('M j, Y', $location_datetime); $location_hour = date('G', $location_datetime); $location_minute = date('i', $location_datetime); // Load saved locations $saved_locations = GeoMashupDB::get_saved_locations(); $saved_location_options = array(); if (!empty($saved_locations)) { foreach ($saved_locations as $saved_location) { $escaped_name = str_replace(array("\r\n", "\r", "\n"), '', $saved_location->saved_name); if ($saved_location->id != $location->id) { $selected = ''; } else { $selected = ' selected="selected"'; } $saved_location_options[] = '<option value="' . esc_attr($saved_location->id . '|' . $saved_location->lat . '|' . $saved_location->lng . '|' . $saved_location->address) . '"' . $selected . '>' . esc_html($escaped_name) . '</option>'; } } $saved_location_options = implode('', $saved_location_options); $nonce = wp_create_nonce('geo-mashup-edit'); $static_maps_base_url = 'http://maps.google.com/maps/api/staticmap?sensor=false&key=' . $geo_mashup_options->get('overall', 'google_key'); ?> <div id="geo_mashup_location_editor"> <div id="geo_mashup_ajax_message" class="geo-mashup-js ui-state-highlight"></div> <input id="geo_mashup_nonce" name="geo_mashup_nonce" type="hidden" value="<?php echo $nonce; ?> " /> <input id="geo_mashup_changed" name="geo_mashup_changed" type="hidden" value="" /> <?php ob_start(); ?> <table id="geo-mashup-location-table"> <thead class="ui-widget-header"> <tr> <th><?php _e('Address', 'GeoMashup'); ?> </th> <th><?php _e('Saved Name', 'GeoMashup'); ?> </th> <th><?php _e('Geo Date', 'GeoMashup'); ?> </th> </tr> </thead> <tbody class="ui-widget-content"> <tr id="geo_mashup_display" class="geo-mashup-display-row"> <td class="geo-mashup-info"> <div class="geo-mashup-address"><?php echo esc_html($location->address); ?> </div> <div class="geo-mashup-coordinates"><?php echo esc_attr($coordinate_string); ?> </div> </td> <td id="geo_mashup_saved_name_ui"> <input id="geo_mashup_location_name" name="geo_mashup_location_name" size="50" type="text" value="<?php echo esc_attr($post_location_name); ?> " /> </td> <td id="geo_mashup_date_ui"> <input id="geo_mashup_date" name="geo_mashup_date" type="text" size="20" value="<?php echo esc_attr($location_date); ?> " /><br /> @ <input id="geo_mashup_hour" name="geo_mashup_hour" type="text" size="2" maxlength="2" value="<?php echo esc_attr($location_hour); ?> " /> : <input id="geo_mashup_minute" name="geo_mashup_minute" type="text" size="2" maxlength="2" value="<?php echo esc_attr($location_minute); ?> " /> </td> <td id="geo_mashup_ajax_buttons"> </td> </tr> </tbody> </table> <?php $location_table_html = ob_get_clean(); ?> <?php ob_start(); ?> <div id="geo_mashup_map" class="geo-mashup-js"> <?php _e('Loading Google map. Check Geo Mashup options if the map fails to load.', 'GeoMashup'); ?> </div> <?php if (!empty($location->id)) { ?> <noscript> <div id="geo_mashup_static_map"> <img src="<?php echo $static_maps_base_url; ?> &size=400x300&zoom=4&markers=size:small|color:green|<?php echo esc_attr($location->lat . ',' . $location->lng); ?> " alt="<?php _e('Location Map Image', 'GeoMashup'); ?> " /> </div> </noscript> <?php } ?> <?php $map_html = ob_get_clean(); ?> <?php ob_start(); ?> <label for="geo_mashup_search"><?php _e('Find a new location:', 'GeoMashup'); ?> <input id="geo_mashup_search" name="geo_mashup_search" type="text" size="35" /> </label> <?php _e('or select from', 'GeoMashup'); ?> <select id="geo_mashup_select" name="geo_mashup_select"> <option value=""><?php _e('[Saved Locations]', 'GeoMashup'); ?> </option> <?php echo $saved_location_options; ?> </select> <?php $search_html = ob_get_clean(); ?> <?php echo empty($location->id) ? $search_html . $map_html . $location_table_html : $location_table_html . $map_html . $search_html; ?> <input id="geo_mashup_ui_manager" name="geo_mashup_ui_manager" type="hidden" value="<?php echo $ui_manager; ?> " /> <input id="geo_mashup_object_id" name="geo_mashup_object_id" type="hidden" value="<?php echo $object_id; ?> " /> <input id="geo_mashup_no_js" name="geo_mashup_no_js" type="hidden" value="true" /> <input id="geo_mashup_location_id" name="geo_mashup_location_id" type="hidden" value="<?php echo esc_attr($location->id); ?> " /> <input id="geo_mashup_location" name="geo_mashup_location" type="hidden" value="<?php echo esc_attr($coordinate_string); ?> " /> <input id="geo_mashup_geoname" name="geo_mashup_geoname" type="hidden" value="<?php echo esc_attr($location->geoname); ?> " /> <input id="geo_mashup_address" name="geo_mashup_address" type="hidden" value="<?php echo esc_attr($location->address); ?> " /> <input id="geo_mashup_postal_code" name="geo_mashup_postal_code" type="hidden" value="<?php echo esc_attr($location->postal_code); ?> " /> <input id="geo_mashup_country_code" name="geo_mashup_country_code" type="hidden" value="<?php echo esc_attr($location->country_code); ?> " /> <input id="geo_mashup_admin_code" name="geo_mashup_admin_code" type="hidden" value="<?php echo esc_attr($location->admin_code); ?> " /> <input id="geo_mashup_admin_name" name="geo_mashup_admin_name" type="hidden" value="" /> <input id="geo_mashup_kml_url" name="geo_mashup_kml_url" type="hidden" value="<?php echo $kml_url; ?> " /> <input id="geo_mashup_sub_admin_code" name="geo_mashup_sub_admin_code" type="hidden" value="<?php echo esc_attr($location->sub_admin_code); ?> " /> <input id="geo_mashup_sub_admin_name" name="geo_mashup_sub_admin_name" type="hidden" value="" /> <input id="geo_mashup_locality_name" name="geo_mashup_locality_name" type="hidden" value="<?php echo esc_attr($location->locality_name); ?> " /> <div id="geo_mashup_submit" class="submit"> <input id="geo_mashup_add_location" name="geo_mashup_add_location" type="submit" <?php echo $add_input_style; ?> value="<?php _e('Add Location', 'GeoMashup'); ?> " /> <input id="geo_mashup_delete_location" name="geo_mashup_delete_location" type="submit" <?php echo $delete_input_style; ?> value="<?php _e('Delete', 'GeoMashup'); ?> " /> <input id="geo_mashup_update_location" name="geo_mashup_update_location" type="submit" <?php echo $update_input_style; ?> value="<?php _e('Save', 'GeoMashup'); ?> " /> </div> <div id="geo-mashup-inline-help-link-wrap" class="geo-mashup-js"> <a href="#geo-mashup-inline-help" id="geo-mashup-inline-help-link"><?php _e('help', 'GeoMashup'); ?> <span class="ui-icon ui-icon-triangle-1-s"></span></a> </div> <div id="geo-mashup-inline-help" class="<?php echo $help_class; ?> ui-widget-content"> <p><?php _e('<em>Saved Name</em> is an optional name you may use to add entries to the Saved Locations menu.', 'GeoMashup'); ?> </p> <p><?php _e('<em>Geo Date</em> associates a date (most formats work) and time with a location. Leave the default value if uncertain.', 'GeoMashup'); ?> </p> <div class="geo-mashup-js"> <p><?php _e('Put a green pin at a new location. There are many ways to do it:', 'GeoMashup'); ?> </p> <ul> <li><?php _e('Search for a location name.', 'GeoMashup'); ?> </li> <li><?php _e('For multiple search results, mouse over pins to see location names, and click a result pin to select that location.', 'GeoMashup'); ?> </li> <li><?php _e('Search for a decimal latitude and longitude separated by a comma, like <em>40.123,-105.456</em>. Seven decimal places are stored. Negative latitude is used for the southern hemisphere, and negative longitude for the western hemisphere.', 'GeoMashup'); ?> </li> <li><?php _e('Search for a street address, like <em>123 main st, anytown, acity</em>.', 'GeoMashup'); ?> </li> <li><?php _e('Click on the location. Zoom in if necessary so you can refine the location by dragging it or clicking a new location.', 'GeoMashup'); ?> </li> </ul> <p><?php _e('To execute a search, type search text into the Find Location box and hit the enter key. If you type a name next to "Save As", the location will be saved under that name and added to the Saved Locations dropdown list.', 'GeoMashup'); ?> </p> <p><?php _e('To remove the location (green pin), clear the search box and hit the enter key.', 'GeoMashup'); ?> </p> <p><?php _e('When you are satisfied with the location, save or update.', 'GeoMashup'); ?> </p> </div> <noscript> <div> <p><?php _e('To add or update location choose a saved location, or find a new location using one of these formats:', 'GeoMashup'); ?> </p> <ul> <li><?php _e('A place name like <em>Yellowstone National Park</em>', 'GeoMashup'); ?> </li> <li><?php _e('A decimal latitude and longitude, like <em>40.123,-105.456</em>.', 'GeoMashup'); ?> </li> <li><?php _e('A full or partial street address, like <em>123 main st, anytown, acity 12345 USA</em>.', 'GeoMashup'); ?> </li> </ul> <p><?php _e('When you save or update, the closest match available will be saved as the location.', 'GeoMashup'); ?> </p> </div> </noscript> </div> </div><!-- id="geo_mashup_location_editor" --> <?php }
/** * Process form input for widget * * @access public * @return Mixed */ function post($args, $options) { extract($args); if (isset($geo_mashup_location)) { $geo_mashup_location = trim($geo_mashup_location); } if (!isset($geo_mashup_location) || $options['required'] && (empty($geo_mashup_location) || $geo_mashup_location == ',')) { return __("You must specific a location using the map!", "tdomf"); } if (!empty($geo_mashup_location) && $geo_mashup_location != ',') { if (class_exists('GeoMashupDB')) { /* latest version: 1.2beta1x */ if (!empty($args['geo_mashup_location_id'])) { $ok = GeoMashupDB::set_post_location($post_ID, $geo_mashup_location_id); } else { list($lat, $lng) = split(',', $geo_mashup_location); $post_location = array(); $post_location['lat'] = trim($lat); $post_location['lng'] = trim($lng); $post_location['saved_name'] = $geo_mashup_location_name; $post_location['geoname'] = $geo_mashup_geoname; $post_location['address'] = $geo_mashup_address; $post_location['postal_code'] = $geo_mashup_postal_code; $post_location['country_code'] = $geo_mashup_country_code; $post_location['admin_code'] = $geo_mashup_admin_code; $post_location['admin_name'] = $geo_mashup_admin_name; $post_location['sub_admin_code'] = $geo_mashup_sub_admin_code; $post_location['sub_admin_name'] = $geo_mashup_sub_admin_name; $post_location['locality_name'] = $geo_mashup_locality_name; $ok = GeoMashupDB::set_post_location($post_ID, $post_location); } if (!$ok) { return __('GeoMashup reported an error when attempting to process location', 'tdomf'); } } else { /* old version: 1.1.2.0 */ add_post_meta($post_ID, '_geo_location', $geo_mashup_location); } if ($options['append']) { $post = wp_get_single_post($post_ID, ARRAY_A); if (!empty($post['post_content'])) { $post = add_magic_quotes($post); } $postdata = array("ID" => $post_ID, "post_content" => $post['post_content'] . '[geo_mashup_map]'); sanitize_post($postdata, "db"); wp_update_post($postdata); } } return NULL; }