From fa7329eb8746bc7ed0d992614cb6bf4317b42f1a Mon Sep 17 00:00:00 2001 From: Scot Rumery Date: Tue, 6 Dec 2016 17:15:34 -0700 Subject: [PATCH 1/2] add support for map type: ROADMAP, SATELLITE I took the current version, v1.3 from the WordPress repo and modified the plugin to support a map type. Values are 'roadmap' or 'satellite'. It defaults to ROADMAP just like the v1.3. The GitHub repo I forked it from wasn't up to date either. This brings it up to v1.3 in the repo and adds the new feature. --- simple-google-map-short-code.php | 107 ++++++++++++++++--------------- 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/simple-google-map-short-code.php b/simple-google-map-short-code.php index 8fd0210..572de9c 100644 --- a/simple-google-map-short-code.php +++ b/simple-google-map-short-code.php @@ -3,12 +3,29 @@ Plugin Name: Simple Google Maps Short Code Plugin URL: http://pippinsplugins.com/simple-google-maps-short-code Description: Adds a simple Google Maps short code -Version: 1.1.2 +Version: 1.3.1 Author: Pippin Williamson Author URI: http://pippinsplugins.com Contributors: mordauk */ +/** + * Loads the plugin textdomain + * + * @access private + * @since 1.2 + * @return void +*/ +function pw_map_textdomain() { + + // Set filter for plugin's languages directory + $lang_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/'; + $lang_dir = apply_filters( 'pw_map_languages_directory', $lang_dir ); + + // Load the translations + load_plugin_textdomain( 'simple-google-maps-short-code', false, $lang_dir ); +} +add_action( 'init', 'pw_map_textdomain' ); /** * Displays the map @@ -17,7 +34,6 @@ * @since 1.0 * @return void */ - function pw_map_shortcode( $atts ) { $atts = shortcode_atts( @@ -27,14 +43,18 @@ function pw_map_shortcode( $atts ) { 'height' => '400px', 'enablescrollwheel' => 'true', 'zoom' => 15, - 'disablecontrols' => 'false' + 'disablecontrols' => 'false', + 'type' => 'ROADMAP', // or SATELLITE + 'key' => '' ), $atts ); $address = $atts['address']; - if( $address ) if( $address && wp_script_is( 'google-maps-api', 'registered' ) ) : + wp_enqueue_script( 'google-maps-api', '//maps.google.com/maps/api/js?sensor=false&callback=initMap&key=' . sanitize_text_field( $atts['key'] ) ); + + if( $address ) : wp_print_scripts( 'google-maps-api' ); @@ -47,7 +67,7 @@ function pw_map_shortcode( $atts ) { ob_start(); ?>
-