Skip to content

Instantly share code, notes, and snippets.

@webaware
Created May 19, 2016 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webaware/610810443c96f601960bb59659ac9958 to your computer and use it in GitHub Desktop.
Save webaware/610810443c96f601960bb59659ac9958 to your computer and use it in GitHub Desktop.
Detect coordinates given as address for Flexible Map shortcode, and copy it to the center attribute to avoid address lookups
<?php
/*
Plugin Name: Flxmap Coordinates as Address
Plugin URI: https://gist.github.com/webaware/610810443c96f601960bb59659ac9958
Description: detect coordinates given as address and fix the map attribute
Version: 1
Author: WebAware
Author URI: http://webaware.com.au/
*/
if (!defined('ABSPATH')) {
exit;
}
/**
* check for no center, but coordinates in the address attribute
* @param array $attrs
* @return array
*/
add_filter('flexmap_shortcode_attrs', function($attrs) {
if (empty($attrs['center']) && !empty($attrs['address']) && FlxMapPlugin::isCoordinates($attrs['address'])) {
$attrs['center'] = $attrs['address'];
}
return $attrs;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment