/**
  * AJAX geocode
  */
 public static function ajaxGeocode()
 {
     // ID
     $post_id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT);
     // Latitude
     $latitude = filter_input(INPUT_POST, Pronamic_Google_Maps_Post::META_KEY_LATITUDE, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
     update_post_meta($post_id, Pronamic_Google_Maps_Post::META_KEY_LATITUDE, $latitude);
     // Longitude
     $longitude = filter_input(INPUT_POST, Pronamic_Google_Maps_Post::META_KEY_LONGITUDE, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
     update_post_meta($post_id, Pronamic_Google_Maps_Post::META_KEY_LONGITUDE, $longitude);
     // Status
     $status = filter_input(INPUT_POST, Pronamic_Google_Maps_Post::META_KEY_GEOCODE_STATUS, FILTER_SANITIZE_STRING);
     update_post_meta($post_id, Pronamic_Google_Maps_Post::META_KEY_GEOCODE_STATUS, $status);
     // Result
     $result = new stdClass();
     $result->success = true;
     // Next post
     $query = new WP_Query();
     $query->query(Pronamic_Google_Maps_Admin::getGeocodeQueryArgs());
     $result->foundPosts = $query->found_posts;
     while ($query->have_posts()) {
         $query->the_post();
         $pgm = pronamic_get_google_maps_meta();
         $result->nextPost = new stdClass();
         $result->nextPost->ID = get_the_ID();
         $result->nextPost->title = get_the_title();
         $result->nextPost->address = $pgm->address;
         $result->nextPost->latitude = $pgm->latitude;
         $result->nextPost->longitude = $pgm->longitude;
     }
     $response = json_encode($result);
     header('Content-Type: application/json');
     exit($response);
     /*
     Queries to empty latitude, longitude and geocode status meta
     UPDATE wp_postmeta SET meta_value = '' WHERE meta_key IN ('_pronamic_google_maps_latitude', '_pronamic_google_maps_longitude');
     UPDATE wp_postmeta SET meta_value = '' WHERE meta_key = '_pronamic_google_maps_geocode_status';
     */
 }
 /**
  * Initialize the plugin
  */
 public static function init()
 {
     if (!Pronamic_Google_Maps_Settings::has_settings()) {
         Pronamic_Google_Maps_Settings::set_default_options();
     }
     // Load plugin text domain
     $rel_path = dirname(plugin_basename(self::$file)) . '/languages/';
     load_plugin_textdomain('pronamic_google_maps', false, $rel_path);
     // Scripts
     self::registerScripts();
     // Other
     if (is_admin()) {
         Pronamic_Google_Maps_Admin::bootstrap();
     } else {
         Pronamic_Google_Maps_Site::bootstrap();
     }
 }
<div id="pgm" class="wrap">
	<?php 
screen_icon('pronamic_google_maps');
?>

	<h2><?php 
echo get_admin_page_title();
?>
</h2>

	<?php 
$query = new WP_Query();
$query->query(Pronamic_Google_Maps_Admin::getGeocodeQueryArgs());
?>

	<p>
		<?php 
printf(__('Number posts to geocode: %s', 'pronamic_google_maps'), sprintf('<strong id="pgm-found-posts">%s</strong>', $query->found_posts));
?>
	</p>

	<?php 
if ($query->have_posts()) {
    $query->the_post();
    ?>

		<form id="pgm-geocoder" action="" method="post">
			<table class="form-table">
				<?php 
    $pgm = pronamic_get_google_maps_meta();
    ?>