Created
June 24, 2013 17:36
-
-
Save justinph/5851928 to your computer and use it in GitHub Desktop.
Adds a fake/faux oEmbed provider for google fusion tables.
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 | |
/* Faux Google Maps Fusiontables oEmbed | |
* Embed google maps in a nicer iframe without using their provided embed code | |
* @usage Paste a Google Maps link in your post and it will be replaced with an iframe when published | |
*/ | |
/* | |
* Example embed URL: | |
* https://www.google.com/fusiontables/embedviz?viz=MAP&q=select+col6+from+1is6E5G4IwxTxG43X8F-v1N_OOSy_lJo_JhrI01U&h=false&lat=45.302540427209586&lng=-93.85018772275396&z=7&t=1&l=col6&y=6&tmplt=8 | |
*/ | |
wp_embed_register_handler( 'fusiontables_google_map', '#https://www\.google\.com/fusiontables(.*)#i', 'embed_fusiontables_google_map' ); | |
function embed_fusiontables_google_map( $matches ) { | |
$query = parse_url($matches[0]); | |
parse_str($query['query'], $qvars); | |
$width = isset($qvars['w']) ? $qvars['w'] : 620; | |
$height = isset($qvars['w']) ? $qvars['h'] : 450; | |
$embed = '<div class="flex-video"><iframe class="google-map" width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$matches[0].'"></iframe></div>'; | |
return apply_filters( 'embed_gft_map', $embed ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment