PageRenderTime 67ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/geolocation/geolocation.php

https://bitbucket.org/geetharani/gordon
PHP | 682 lines | 575 code | 75 blank | 32 comment | 112 complexity | 5e3500bafb3016b1d1c5b885996fb8aa MD5 | raw file
Possible License(s): MIT
  1. <?php
  2. /*
  3. Plugin Name: Geolocation
  4. Plugin URI: http://wordpress.org/extend/plugins/geolocation/
  5. Description: Displays post geotag information on an embedded map.
  6. Version: 0.1.1
  7. Author: Chris Boyd
  8. Author URI: http://geo.chrisboyd.net
  9. License: GPL2
  10. */
  11. /* Copyright 2010 Chris Boyd (email : chris@chrisboyd.net)
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License, version 2, as
  14. published by the Free Software Foundation.
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. add_action('wp_head', 'add_geo_support');
  24. add_action('wp_footer', 'add_geo_div');
  25. add_action('admin_menu', 'add_settings');
  26. add_filter('the_content', 'display_location', 5);
  27. admin_init();
  28. register_activation_hook(__FILE__, 'activate');
  29. wp_enqueue_script("jquery");
  30. define('PROVIDER', 'google');
  31. define('SHORTCODE', '[geolocation]');
  32. function activate() {
  33. register_settings();
  34. add_option('geolocation_map_width', '350');
  35. add_option('geolocation_map_height', '150');
  36. add_option('geolocation_default_zoom', '16');
  37. add_option('geolocation_map_position', 'after');
  38. add_option('geolocation_wp_pin', '1');
  39. }
  40. function geolocation_add_custom_box() {
  41. if(function_exists('add_meta_box')) {
  42. add_meta_box('geolocation_sectionid', __( 'Geolocation', 'myplugin_textdomain' ), 'geolocation_inner_custom_box', 'post', 'advanced' );
  43. }
  44. else {
  45. add_action('dbx_post_advanced', 'geolocation_old_custom_box' );
  46. }
  47. }
  48. function geolocation_inner_custom_box() {
  49. echo '<input type="hidden" id="geolocation_nonce" name="geolocation_nonce" value="' .
  50. wp_create_nonce(plugin_basename(__FILE__) ) . '" />';
  51. echo '
  52. <label class="screen-reader-text" for="geolocation-address">Geolocation</label>
  53. <div class="taghint">Enter your address</div>
  54. <input type="text" id="geolocation-address" name="geolocation-address" class="newtag form-input-tip" size="25" autocomplete="off" value="" />
  55. <input id="geolocation-load" type="button" class="button geolocationadd" value="Load" tabindex="3" />
  56. <input type="hidden" id="geolocation-latitude" name="geolocation-latitude" />
  57. <input type="hidden" id="geolocation-longitude" name="geolocation-longitude" />
  58. <div id="geolocation-map" style="border:solid 1px #c6c6c6;width:265px;height:200px;margin-top:5px;"></div>
  59. <div style="margin:5px 0 0 0;">
  60. <input id="geolocation-public" name="geolocation-public" type="checkbox" value="1" />
  61. <label for="geolocation-public">Public</label>
  62. <div style="float:right">
  63. <input id="geolocation-enabled" name="geolocation-on" type="radio" value="1" />
  64. <label for="geolocation-enabled">On</label>
  65. <input id="geolocation-disabled" name="geolocation-on" type="radio" value="0" />
  66. <label for="geolocation-disabled">Off</label>
  67. </div>
  68. </div>
  69. ';
  70. }
  71. /* Prints the edit form for pre-WordPress 2.5 post/page */
  72. function geolocation_old_custom_box() {
  73. echo '<div class="dbx-b-ox-wrapper">' . "\n";
  74. echo '<fieldset id="geolocation_fieldsetid" class="dbx-box">' . "\n";
  75. echo '<div class="dbx-h-andle-wrapper"><h3 class="dbx-handle">' .
  76. __( 'Geolocation', 'geolocation_textdomain' ) . "</h3></div>";
  77. echo '<div class="dbx-c-ontent-wrapper"><div class="dbx-content">';
  78. geolocation_inner_custom_box();
  79. echo "</div></div></fieldset></div>\n";
  80. }
  81. function geolocation_save_postdata($post_id) {
  82. // Check authorization, permissions, autosave, etc
  83. if (!wp_verify_nonce($_POST['geolocation_nonce'], plugin_basename(__FILE__)))
  84. return $post_id;
  85. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
  86. return $post_id;
  87. if('page' == $_POST['post_type'] ) {
  88. if(!current_user_can('edit_page', $post_id))
  89. return $post_id;
  90. } else {
  91. if(!current_user_can('edit_post', $post_id))
  92. return $post_id;
  93. }
  94. $latitude = clean_coordinate($_POST['geolocation-latitude']);
  95. $longitude = clean_coordinate($_POST['geolocation-longitude']);
  96. $address = reverse_geocode($latitude, $longitude);
  97. $public = $_POST['geolocation-public'];
  98. $on = $_POST['geolocation-on'];
  99. if((clean_coordinate($latitude) != '') && (clean_coordinate($longitude)) != '') {
  100. update_post_meta($post_id, 'geo_latitude', $latitude);
  101. update_post_meta($post_id, 'geo_longitude', $longitude);
  102. if(esc_html($address) != '')
  103. update_post_meta($post_id, 'geo_address', $address);
  104. if($on) {
  105. update_post_meta($post_id, 'geo_enabled', 1);
  106. if($public)
  107. update_post_meta($post_id, 'geo_public', 1);
  108. else
  109. update_post_meta($post_id, 'geo_public', 0);
  110. }
  111. else {
  112. update_post_meta($post_id, 'geo_enabled', 0);
  113. update_post_meta($post_id, 'geo_public', 1);
  114. }
  115. }
  116. return $post_id;
  117. }
  118. function admin_init() {
  119. add_action('admin_head-post-new.php', 'admin_head');
  120. add_action('admin_head-post.php', 'admin_head');
  121. add_action('admin_menu', 'geolocation_add_custom_box');
  122. add_action('save_post', 'geolocation_save_postdata');
  123. }
  124. function admin_head() {
  125. global $post;
  126. $post_id = $post->ID;
  127. $post_type = $post->post_type;
  128. $zoom = (int) get_option('geolocation_default_zoom');
  129. ?>
  130. <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  131. <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
  132. <script type="text/javascript">
  133. var $j = jQuery.noConflict();
  134. $j(function() {
  135. $j(document).ready(function() {
  136. var hasLocation = false;
  137. var center = new google.maps.LatLng(0.0,0.0);
  138. var postLatitude = '<?php echo esc_js(get_post_meta($post_id, 'geo_latitude', true)); ?>';
  139. var postLongitude = '<?php echo esc_js(get_post_meta($post_id, 'geo_longitude', true)); ?>';
  140. var public = '<?php echo get_post_meta($post_id, 'geo_public', true); ?>';
  141. var on = '<?php echo get_post_meta($post_id, 'geo_enabled', true); ?>';
  142. if(public == '0')
  143. $j("#geolocation-public").attr('checked', false);
  144. else
  145. $j("#geolocation-public").attr('checked', true);
  146. if(on == '0')
  147. disableGeo();
  148. else
  149. enableGeo();
  150. if((postLatitude != '') && (postLongitude != '')) {
  151. center = new google.maps.LatLng(postLatitude, postLongitude);
  152. hasLocation = true;
  153. $j("#geolocation-latitude").val(center.lat());
  154. $j("#geolocation-longitude").val(center.lng());
  155. reverseGeocode(center);
  156. }
  157. var myOptions = {
  158. 'zoom': <?php echo $zoom; ?>,
  159. 'center': center,
  160. 'mapTypeId': google.maps.MapTypeId.ROADMAP
  161. };
  162. var image = '<?php echo esc_js(esc_url(plugins_url('img/wp_pin.png', __FILE__ ))); ?>';
  163. var shadow = new google.maps.MarkerImage('<?php echo esc_js(esc_url(plugins_url('img/wp_pin_shadow.png', __FILE__ ))); ?>',
  164. new google.maps.Size(39, 23),
  165. new google.maps.Point(0, 0),
  166. new google.maps.Point(12, 25));
  167. var map = new google.maps.Map(document.getElementById('geolocation-map'), myOptions);
  168. var marker = new google.maps.Marker({
  169. position: center,
  170. map: map,
  171. title:'Post Location'<?php if(get_option('geolocation_wp_pin')) { ?>,
  172. icon: image,
  173. shadow: shadow
  174. <?php } ?>
  175. });
  176. if((!hasLocation) && (google.loader.ClientLocation)) {
  177. center = new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitude);
  178. reverseGeocode(center);
  179. }
  180. else if(!hasLocation) {
  181. map.setZoom(1);
  182. }
  183. google.maps.event.addListener(map, 'click', function(event) {
  184. placeMarker(event.latLng);
  185. });
  186. var currentAddress;
  187. var customAddress = false;
  188. $j("#geolocation-address").click(function(){
  189. currentAddress = $j(this).val();
  190. if(currentAddress != '')
  191. $j("#geolocation-address").val('');
  192. });
  193. $j("#geolocation-load").click(function(){
  194. if($j("#geolocation-address").val() != '') {
  195. customAddress = true;
  196. currentAddress = $j("#geolocation-address").val();
  197. geocode(currentAddress);
  198. }
  199. });
  200. $j("#geolocation-address").keyup(function(e) {
  201. if(e.keyCode == 13)
  202. $j("#geolocation-load").click();
  203. });
  204. $j("#geolocation-enabled").click(function(){
  205. enableGeo();
  206. });
  207. $j("#geolocation-disabled").click(function(){
  208. disableGeo();
  209. });
  210. function placeMarker(location) {
  211. marker.setPosition(location);
  212. map.setCenter(location);
  213. if((location.lat() != '') && (location.lng() != '')) {
  214. $j("#geolocation-latitude").val(location.lat());
  215. $j("#geolocation-longitude").val(location.lng());
  216. }
  217. if(!customAddress)
  218. reverseGeocode(location);
  219. }
  220. function geocode(address) {
  221. var geocoder = new google.maps.Geocoder();
  222. if (geocoder) {
  223. geocoder.geocode({"address": address}, function(results, status) {
  224. if (status == google.maps.GeocoderStatus.OK) {
  225. placeMarker(results[0].geometry.location);
  226. if(!hasLocation) {
  227. map.setZoom(16);
  228. hasLocation = true;
  229. }
  230. }
  231. });
  232. }
  233. $j("#geodata").html(latitude + ', ' + longitude);
  234. }
  235. function reverseGeocode(location) {
  236. var geocoder = new google.maps.Geocoder();
  237. if (geocoder) {
  238. geocoder.geocode({"latLng": location}, function(results, status) {
  239. if (status == google.maps.GeocoderStatus.OK) {
  240. if(results[1]) {
  241. var address = results[1].formatted_address;
  242. if(address == "")
  243. address = results[7].formatted_address;
  244. else {
  245. $j("#geolocation-address").val(address);
  246. placeMarker(location);
  247. }
  248. }
  249. }
  250. });
  251. }
  252. }
  253. function enableGeo() {
  254. $j("#geolocation-address").removeAttr('disabled');
  255. $j("#geolocation-load").removeAttr('disabled');
  256. $j("#geolocation-map").css('filter', '');
  257. $j("#geolocation-map").css('opacity', '');
  258. $j("#geolocation-map").css('-moz-opacity', '');
  259. $j("#geolocation-public").removeAttr('disabled');
  260. $j("#geolocation-map").removeAttr('readonly');
  261. $j("#geolocation-disabled").removeAttr('checked');
  262. $j("#geolocation-enabled").attr('checked', 'checked');
  263. if(public == '1')
  264. $j("#geolocation-public").attr('checked', 'checked');
  265. }
  266. function disableGeo() {
  267. $j("#geolocation-address").attr('disabled', 'disabled');
  268. $j("#geolocation-load").attr('disabled', 'disabled');
  269. $j("#geolocation-map").css('filter', 'alpha(opacity=50)');
  270. $j("#geolocation-map").css('opacity', '0.5');
  271. $j("#geolocation-map").css('-moz-opacity', '0.5');
  272. $j("#geolocation-map").attr('readonly', 'readonly');
  273. $j("#geolocation-public").attr('disabled', 'disabled');
  274. $j("#geolocation-enabled").removeAttr('checked');
  275. $j("#geolocation-disabled").attr('checked', 'checked');
  276. if(public == '1')
  277. $j("#geolocation-public").attr('checked', 'checked');
  278. }
  279. });
  280. });
  281. </script>
  282. <?php
  283. }
  284. function add_geo_div() {
  285. $width = esc_attr(get_option('geolocation_map_width'));
  286. $height = esc_attr(get_option('geolocation_map_height'));
  287. echo '<div id="map" class="geolocation-map" style="width:'.$width.'px;height:'.$height.'px;"></div>';
  288. }
  289. function add_geo_support() {
  290. global $geolocation_options, $posts;
  291. // To do: add support for multiple Map API providers
  292. switch(PROVIDER) {
  293. case 'google':
  294. echo add_google_maps($posts);
  295. break;
  296. case 'yahoo':
  297. echo add_yahoo_maps($posts);
  298. break;
  299. case 'bing':
  300. echo add_bing_maps($posts);
  301. break;
  302. }
  303. echo '<link type="text/css" rel="stylesheet" href="'.esc_url(plugins_url('style.css', __FILE__)).'" />';
  304. }
  305. function add_google_maps($posts) {
  306. default_settings();
  307. $zoom = (int) get_option('geolocation_default_zoom');
  308. global $post_count;
  309. $post_count = count($posts);
  310. echo '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  311. <script type="text/javascript">
  312. var $j = jQuery.noConflict();
  313. $j(function(){
  314. var center = new google.maps.LatLng(0.0, 0.0);
  315. var myOptions = {
  316. zoom: '.$zoom.',
  317. center: center,
  318. mapTypeId: google.maps.MapTypeId.ROADMAP
  319. };
  320. var map = new google.maps.Map(document.getElementById("map"), myOptions);
  321. var image = "'.esc_js(esc_url(plugins_url('img/wp_pin.png', __FILE__ ))).'";
  322. var shadow = new google.maps.MarkerImage("'.plugins_url('img/wp_pin_shadow.png', __FILE__ ).'",
  323. new google.maps.Size(39, 23),
  324. new google.maps.Point(0, 0),
  325. new google.maps.Point(12, 25));
  326. var marker = new google.maps.Marker({
  327. position: center,
  328. map: map,
  329. title:"Post Location"';
  330. if(get_option('geolocation_wp_pin')) {
  331. echo ',
  332. icon: image,
  333. shadow: shadow';
  334. }
  335. echo '});
  336. var allowDisappear = true;
  337. var cancelDisappear = false;
  338. $j(".geolocation-link").mouseover(function(){
  339. $j("#map").stop(true, true);
  340. var lat = $j(this).attr("name").split(",")[0];
  341. var lng = $j(this).attr("name").split(",")[1];
  342. var latlng = new google.maps.LatLng(lat, lng);
  343. placeMarker(latlng);
  344. var offset = $j(this).offset();
  345. $j("#map").fadeTo(250, 1);
  346. $j("#map").css("z-index", "99");
  347. $j("#map").css("visibility", "visible");
  348. $j("#map").css("top", offset.top + 20);
  349. $j("#map").css("left", offset.left);
  350. allowDisappear = false;
  351. $j("#map").css("visibility", "visible");
  352. });
  353. $j(".geolocation-link").mouseover(function(){
  354. });
  355. $j(".geolocation-link").mouseout(function(){
  356. allowDisappear = true;
  357. cancelDisappear = false;
  358. setTimeout(function() {
  359. if((allowDisappear) && (!cancelDisappear))
  360. {
  361. $j("#map").fadeTo(500, 0, function() {
  362. $j("#map").css("z-index", "-1");
  363. allowDisappear = true;
  364. cancelDisappear = false;
  365. });
  366. }
  367. },800);
  368. });
  369. $j("#map").mouseover(function(){
  370. allowDisappear = false;
  371. cancelDisappear = true;
  372. $j("#map").css("visibility", "visible");
  373. });
  374. $j("#map").mouseout(function(){
  375. allowDisappear = true;
  376. cancelDisappear = false;
  377. $j(".geolocation-link").mouseout();
  378. });
  379. function placeMarker(location) {
  380. map.setZoom('.$zoom.');
  381. marker.setPosition(location);
  382. map.setCenter(location);
  383. }
  384. google.maps.event.addListener(map, "click", function() {
  385. window.location = "http://maps.google.com/maps?q=" + map.center.lat() + ",+" + map.center.lng();
  386. });
  387. });
  388. </script>';
  389. }
  390. function geo_has_shortcode($content) {
  391. $pos = strpos($content, SHORTCODE);
  392. if($pos === false)
  393. return false;
  394. else
  395. return true;
  396. }
  397. function display_location($content) {
  398. default_settings();
  399. global $post, $shortcode_tags, $post_count;
  400. // Backup current registered shortcodes and clear them all out
  401. $orig_shortcode_tags = $shortcode_tags;
  402. $shortcode_tags = array();
  403. $post_id = $post->ID;
  404. $latitude = clean_coordinate(get_post_meta($post->ID, 'geo_latitude', true));
  405. $longitude = clean_coordinate(get_post_meta($post->ID, 'geo_longitude', true));
  406. $address = get_post_meta($post->ID, 'geo_address', true);
  407. $public = (bool)get_post_meta($post->ID, 'geo_public', true);
  408. $on = true;
  409. if(get_post_meta($post->ID, 'geo_enabled', true) != '')
  410. $on = (bool)get_post_meta($post->ID, 'geo_enabled', true);
  411. if(empty($address))
  412. $address = reverse_geocode($latitude, $longitude);
  413. if((!empty($latitude)) && (!empty($longitude) && ($public == true) && ($on == true))) {
  414. $html = '<a class="geolocation-link" href="#" id="geolocation'.$post->ID.'" name="'.$latitude.','.$longitude.'" onclick="return false;">Posted from '.esc_html($address).'.</a>';
  415. switch(esc_attr(get_option('geolocation_map_position')))
  416. {
  417. case 'before':
  418. $content = str_replace(SHORTCODE, '', $content);
  419. $content = $html.'<br/><br/>'.$content;
  420. break;
  421. case 'after':
  422. $content = str_replace(SHORTCODE, '', $content);
  423. $content = $content.'<br/><br/>'.$html;
  424. break;
  425. case 'shortcode':
  426. $content = str_replace(SHORTCODE, $html, $content);
  427. break;
  428. }
  429. }
  430. else {
  431. $content = str_replace(SHORTCODE, '', $content);
  432. }
  433. // Put the original shortcodes back
  434. $shortcode_tags = $orig_shortcode_tags;
  435. return $content;
  436. }
  437. function reverse_geocode($latitude, $longitude) {
  438. $url = "http://maps.google.com/maps/api/geocode/json?latlng=".$latitude.",".$longitude."&sensor=false";
  439. $result = wp_remote_get($url);
  440. $json = json_decode($result['body']);
  441. foreach ($json->results as $result)
  442. {
  443. foreach($result->address_components as $addressPart) {
  444. if((in_array('locality', $addressPart->types)) && (in_array('political', $addressPart->types)))
  445. $city = $addressPart->long_name;
  446. else if((in_array('administrative_area_level_1', $addressPart->types)) && (in_array('political', $addressPart->types)))
  447. $state = $addressPart->long_name;
  448. else if((in_array('country', $addressPart->types)) && (in_array('political', $addressPart->types)))
  449. $country = $addressPart->long_name;
  450. }
  451. }
  452. if(($city != '') && ($state != '') && ($country != ''))
  453. $address = $city.', '.$state.', '.$country;
  454. else if(($city != '') && ($state != ''))
  455. $address = $city.', '.$state;
  456. else if(($state != '') && ($country != ''))
  457. $address = $state.', '.$country;
  458. else if($country != '')
  459. $address = $country;
  460. return $address;
  461. }
  462. function clean_coordinate($coordinate) {
  463. $pattern = '/^(\-)?(\d{1,3})\.(\d{1,15})/';
  464. preg_match($pattern, $coordinate, $matches);
  465. return $matches[0];
  466. }
  467. function add_settings() {
  468. if ( is_admin() ){ // admin actions
  469. add_options_page('Geolocation Plugin Settings', 'Geolocation', 'administrator', 'geolocation.php', 'geolocation_settings_page', __FILE__);
  470. add_action( 'admin_init', 'register_settings' );
  471. } else {
  472. // non-admin enqueues, actions, and filters
  473. }
  474. }
  475. function register_settings() {
  476. register_setting( 'geolocation-settings-group', 'geolocation_map_width', 'intval' );
  477. register_setting( 'geolocation-settings-group', 'geolocation_map_height', 'intval' );
  478. register_setting( 'geolocation-settings-group', 'geolocation_default_zoom', 'intval' );
  479. register_setting( 'geolocation-settings-group', 'geolocation_map_position' );
  480. register_setting( 'geolocation-settings-group', 'geolocation_wp_pin');
  481. }
  482. function is_checked($field) {
  483. if (get_option($field))
  484. echo ' checked="checked" ';
  485. }
  486. function is_value($field, $value) {
  487. if (get_option($field) == $value)
  488. echo ' checked="checked" ';
  489. }
  490. function default_settings() {
  491. if(get_option('geolocation_map_width') == '0')
  492. update_option('geolocation_map_width', '450');
  493. if(get_option('geolocation_map_height') == '0')
  494. update_option('geolocation_map_height', '200');
  495. if(get_option('geolocation_default_zoom') == '0')
  496. update_option('geolocation_default_zoom', '16');
  497. if(get_option('geolocation_map_position') == '0')
  498. update_option('geolocation_map_position', 'after');
  499. }
  500. function geolocation_settings_page() {
  501. default_settings();
  502. $zoomImage = get_option('geolocation_default_zoom');
  503. if(get_option('geolocation_wp_pin'))
  504. $zoomImage = 'wp_'.$zoomImage.'.png';
  505. else
  506. $zoomImage = $zoomImage.'.png';
  507. ?>
  508. <style type="text/css">
  509. #zoom_level_sample { background: url('<?php echo esc_url(plugins_url('img/zoom/'.$zoomImage, __FILE__)); ?>'); width:390px; height:190px; border: solid 1px #999; }
  510. #preload { display: none; }
  511. .dimensions strong { width: 50px; float: left; }
  512. .dimensions input { width: 50px; margin-right: 5px; }
  513. .zoom label { width: 50px; margin: 0 5px 0 2px; }
  514. .position label { margin: 0 5px 0 2px; }
  515. </style>
  516. <script type="text/javascript">
  517. var file;
  518. var zoomlevel = <?php echo (int) esc_attr(get_option('geolocation_default_zoom')); ?>;
  519. var path = '<?php echo esc_js(plugins_url('img/zoom/', __FILE__)); ?>';
  520. function swap_zoom_sample(id) {
  521. zoomlevel = document.getElementById(id).value;
  522. pin_click();
  523. }
  524. function pin_click() {
  525. var div = document.getElementById('zoom_level_sample');
  526. file = path + zoomlevel + '.png';
  527. if(document.getElementById('geolocation_wp_pin').checked)
  528. file = path + 'wp_' + zoomlevel + '.png';
  529. div.style.background = 'url(' + file + ')';
  530. }
  531. </script>
  532. <div class="wrap"><h2>Geolocation Plugin Settings</h2></div>
  533. <form method="post" action="options.php">
  534. <?php settings_fields( 'geolocation-settings-group' ); ?>
  535. <table class="form-table">
  536. <tr valign="top">
  537. <tr valign="top">
  538. <th scope="row">Dimensions</th>
  539. <td class="dimensions">
  540. <strong>Width:</strong><input type="text" name="geolocation_map_width" value="<?php echo esc_attr(get_option('geolocation_map_width')); ?>" />px<br/>
  541. <strong>Height:</strong><input type="text" name="geolocation_map_height" value="<?php echo esc_attr(get_option('geolocation_map_height')); ?>" />px
  542. </td>
  543. </tr>
  544. <tr valign="top">
  545. <th scope="row">Position</th>
  546. <td class="position">
  547. <input type="radio" id="geolocation_map_position_before" name="geolocation_map_position" value="before"<?php is_value('geolocation_map_position', 'before'); ?>><label for="geolocation_map_position_before">Before the post.</label><br/>
  548. <input type="radio" id="geolocation_map_position_after" name="geolocation_map_position" value="after"<?php is_value('geolocation_map_position', 'after'); ?>><label for="geolocation_map_position_after">After the post.</label><br/>
  549. <input type="radio" id="geolocation_map_position_shortcode" name="geolocation_map_position" value="shortcode"<?php is_value('geolocation_map_position', 'shortcode'); ?>><label for="geolocation_map_position_shortcode">Wherever I put the <strong>[geolocation]</strong> shortcode.</label>
  550. </td>
  551. </tr>
  552. <tr valign="top">
  553. <th scope="row">Default Zoom Level</th>
  554. <td class="zoom">
  555. <input type="radio" id="geolocation_default_zoom_globe" name="geolocation_default_zoom" value="1"<?php is_value('geolocation_default_zoom', '1'); ?> onclick="javascipt:swap_zoom_sample(this.id);"><label for="geolocation_default_zoom_globe">Globe</label>
  556. <input type="radio" id="geolocation_default_zoom_country" name="geolocation_default_zoom" value="3"<?php is_value('geolocation_default_zoom', '3'); ?> onclick="javascipt:swap_zoom_sample(this.id);"><label for="geolocation_default_zoom_country">Country</label>
  557. <input type="radio" id="geolocation_default_zoom_state" name="geolocation_default_zoom" value="6"<?php is_value('geolocation_default_zoom', '6'); ?> onclick="javascipt:swap_zoom_sample(this.id);"><label for="geolocation_default_zoom_state">State</label>
  558. <input type="radio" id="geolocation_default_zoom_city" name="geolocation_default_zoom" value="9"<?php is_value('geolocation_default_zoom', '9'); ?> onclick="javascipt:swap_zoom_sample(this.id);"><label for="geolocation_default_zoom_city">City</label>
  559. <input type="radio" id="geolocation_default_zoom_street" name="geolocation_default_zoom" value="16"<?php is_value('geolocation_default_zoom', '16'); ?> onclick="javascipt:swap_zoom_sample(this.id);"><label for="geolocation_default_zoom_street">Street</label>
  560. <input type="radio" id="geolocation_default_zoom_block" name="geolocation_default_zoom" value="18"<?php is_value('geolocation_default_zoom', '18'); ?> onclick="javascipt:swap_zoom_sample(this.id);"><label for="geolocation_default_zoom_block">Block</label>
  561. <br/>
  562. <div id="zoom_level_sample"></div>
  563. </td>
  564. </tr>
  565. <tr valign="top">
  566. <th scope="row"></th>
  567. <td class="position">
  568. <input type="checkbox" id="geolocation_wp_pin" name="geolocation_wp_pin" value="1" <?php is_checked('geolocation_wp_pin'); ?> onclick="javascript:pin_click();"><label for="geolocation_wp_pin">Show your support for WordPress by using the WordPress map pin.</label>
  569. </td>
  570. </tr>
  571. </table>
  572. <p class="submit">
  573. <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
  574. </p>
  575. <input type="hidden" name="action" value="update" />
  576. <input type="hidden" name="page_options" value="geolocation_map_width,geolocation_map_height,geolocation_default_zoom,geolocation_map_position,geolocation_wp_pin" />
  577. </form>
  578. <div id="preload">
  579. <img src="<?php echo esc_url(plugins_url('img/zoom/1.png', __FILE__)); ?>"/>
  580. <img src="<?php echo esc_url(plugins_url('img/zoom/3.png', __FILE__)); ?>"/>
  581. <img src="<?php echo esc_url(plugins_url('img/zoom/6.png', __FILE__)); ?>"/>
  582. <img src="<?php echo esc_url(plugins_url('img/zoom/9.png', __FILE__)); ?>"/>
  583. <img src="<?php echo esc_url(plugins_url('img/zoom/16.png', __FILE__)); ?>"/>
  584. <img src="<?php echo esc_url(plugins_url('img/zoom/18.png', __FILE__)); ?>"/>
  585. <img src="<?php echo esc_url(plugins_url('img/zoom/wp_1.png', __FILE__)); ?>"/>
  586. <img src="<?php echo esc_url(plugins_url('img/zoom/wp_3.png', __FILE__)); ?>"/>
  587. <img src="<?php echo esc_url(plugins_url('img/zoom/wp_6.png', __FILE__)); ?>"/>
  588. <img src="<?php echo esc_url(plugins_url('img/zoom/wp_9.png', __FILE__)); ?>"/>
  589. <img src="<?php echo esc_url(plugins_url('img/zoom/wp_16.png', __FILE__)); ?>"/>
  590. <img src="<?php echo esc_url(plugins_url('img/zoom/wp_18.png', __FILE__)); ?>"/>
  591. </div>
  592. <?php
  593. }
  594. ?>