Source for file geo-query.php
Documentation is available at geo-query.php
* Respond to Geo Mashup AJAX requests for object locations.
if ( ( isset ( $_GET['output'] ) and 'json' == $_GET['output'] ) or empty( $_GET['object_ids'] ) ) {
* Class for query handling namespace
* Strip content in square brackets.
* Shortcodes are not registered in the bare-bones query environments,
* but we can strip all bracketed content.
* @param string $content Content to strip square brackets from
* @return string Content minus square brackets
* @return string Content without map shortcodes.
return preg_replace( '/\[geo_mashup_map.*?\]/', '', $content );
* Use templates to output content for objects.
$object_ids = $_GET['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 ) {
$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
$query_vars['ignore_sticky_posts'] = true;
$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 );
$template_base = ( empty( $template_base ) ) ? 'info-window' : $template_base;
if ( !empty( $comments ) ) {
$template_base = ( empty( $template_base ) ) ? 'comment' : $template_base;
$template_base = ( empty( $template_base ) ) ? 'user' : $template_base;
* Set the comment global.
* Not sure why WP 2.7 comment templating requires this for callbacks, but it does.
* @param object $comment The comment object to make global.
$GLOBALS['comment'] = $comment;
* Wrap access to comments global.
* @return bool Whether there are any comments to be listed.
return ( !empty( $comments ) );
* A wrapper for wp_list_comments when it exists,
* otherwise a simple comment loop.
* @see wp_list_comments()
* @param string|array$args Formatting options
global $wp_query, $comments, $in_comment_loop;
wp_list_comments( $args, $comments );
if ( empty( $comments ) ) {
$args = wp_parse_args( $args );
foreach( $comments as $comment) {
if ( !empty( $args['callback'] ) ) {
echo '<p>' . esc_html( $comment->comment_author ) . ':<br/>' . esc_html( $comment->comment_content ) . '</p>';
$in_comment_loop = false;
* Probably only Geo Mashup using it here for a templated list of users.
* @param object $user The user object to make global.
$GLOBALS['user'] = $user;
* Wrap access to users global.
* Probably only Geo Mashup using it here for a templated list of users.
* @returns bool Whether there are any users to be listed.
return ( !empty( $users ) );
* A simple user loop that takes a callback option for formatting.
* @param string|array$args Formatting options
global $wp_query, $users, $in_user_loop;
$defaults = array( 'callback' => '' );
$args = wp_parse_args( $args, $defaults );
foreach( $users as $user) {
if ( !empty( $args['callback'] ) ) {
echo '<p>' . esc_html( $user->display_name ) .
( empty( $user->user_url ) ? '' : ' - ' . $user->url ) . '</p>';
* Run a query for object locations from GET parameters and print JSON results.
/* TODO: Try to track modification?
if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
$http_time = strtotime( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
$mod_time = strtotime( $post->post_modified_gmt . ' GMT' );
if ($mod_time <= $http_time) {
return status_header(304); // Not modified
header( 'Last-Modified: ' . mysql2date( 'D, d M Y H:i:s', $post->post_modified_gmt, false ) . ' GMT' );
header( 'Content-type: text/xml; charset='.get_settings('blog_charset'), true);
header( 'Cache-control: max-age=300, must-revalidate', true);
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 300 ) . " GMT" );
header('Content-type: application/json; charset='. get_option('blog_charset'), true);
header('Cache-Control: no-cache;', true);
if ( isset ( $_REQUEST['callback'] ) )
$json = $_REQUEST['callback'] . '(' . $json . ')';
|