Force Geo Mashup to use a different home URL (add a slash)


/ Published in: PHP
Save to your folder(s)

Some hosting configurations do uncontrollable redirects and other oddities that play havoc with Geo Mashup maps. Most commonly the home URL redirects improperly unless a slash is added at the end. This code attempts to add the slash just for Geo Mashup. Put it in a theme functions.php or in mu-plugins.


Copy this code and paste it in your HTML
  1. class CustomGeoMashupWrap {
  2.  
  3. static function add_slash_to_home_url( $url, $path, $scheme, $blog ) {
  4. return trailingslashit( $url );
  5. }
  6.  
  7. static function map_shortcode_wrapper( $args ) {
  8. add_filter( 'get_home_url', array( __CLASS__, 'add_slash_to_home_url' ), 10, 4 );
  9. $map = GeoMashup::map( $args );
  10. remove_filter( 'get_home_url', array( __CLASS__, 'add_slash_to_home_url' ), 10, 4 );
  11. return $map;
  12. }
  13.  
  14. function wrap_map_shortcode() {
  15. remove_shortcode( 'geo_mashup_map' );
  16. add_shortcode( 'geo_mashup_map', array( __CLASS__, 'map_shortcode_wrapper' ) );
  17. }
  18. }
  19. add_action( 'init', array( 'CustomGeoMashupWrap', 'wrap_map_shortcode' ) );

URL: http://wordpress-geo-mashup.googlecode.com/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.