Created
May 19, 2016 22:36
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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