Plugin Directory

Changeset 1809668 for leaflet-map


Ignore:
Timestamp:
01/25/2018 10:29:34 PM (8 years ago)
Author:
bozdoz
Message:

2.10.0: string interpolate geojson properties; added translation potential;

Location:
leaflet-map
Files:
4 added
1 deleted
10 edited
27 copied

Legend:

Unmodified
Added
Removed
  • leaflet-map/tags/2.10.0/class.leaflet-map.php

    r1797863 r1809668  
    1414    * @var string major minor patch version
    1515    */
    16     public static $version = '2.9.1';
     16    public static $version = '2.10.0';
    1717
    1818    /**
     
    2020    * @var string major minor patch version
    2121    */
    22     public static $leaflet_version = '1.2.0';
     22    public static $leaflet_version = '1.3.1';
    2323
    2424    /**
     
    8484     */
    8585    private function __construct() {
    86         $this->includes();
    8786        $this->init_hooks();
    8887        $this->add_shortcodes();
     
    9493    /**
    9594    *
    96     * include classes
    97     *
    98     */
    99     private function includes() {
    100         // Leaflet_Map_Plugin_Settings
    101         include_once(LEAFLET_MAP__PLUGIN_DIR . 'class.plugin-settings.php');
     95    * add actions and filters
     96    *
     97    */
     98    private function init_hooks() {
    10299        // Leaflet_Map_Admin
    103100        include_once(LEAFLET_MAP__PLUGIN_DIR . 'class.admin.php');
    104     }
    105 
    106     /**
    107     *
    108     * add actions and filters
    109     *
    110     */
    111     private function init_hooks() {
    112101       
    113102        // init admin
    114103        Leaflet_Map_Admin::init();
     104
     105        add_action( 'plugins_loaded', array('Leaflet_Map', 'load_text_domain' ));
    115106       
    116107        add_action( 'wp_enqueue_scripts', array('Leaflet_Map', 'enqueue_and_register') );
     
    156147
    157148    /**
     149    * Loads Translations
     150    *
     151    */
     152    public static function load_text_domain() {
     153        load_plugin_textdomain( 'leaflet-map', false, dirname( plugin_basename( LEAFLET_MAP__PLUGIN_FILE ) ) . '/languages/' );
     154    }
     155
     156    /**
    158157    * Enqueue and register styles and scripts (called in __construct)
    159158    *
     
    162161    public static function enqueue_and_register () {
    163162        /* defaults from db */
     163        // Leaflet_Map_Plugin_Settings
     164        include_once(LEAFLET_MAP__PLUGIN_DIR . 'class.plugin-settings.php');
    164165        $settings = Leaflet_Map_Plugin_Settings::init();
    165166
  • leaflet-map/tags/2.10.0/class.plugin-option.php

    r1797861 r1809668  
    3737
    3838        $option_filter = array(
    39             'default'   =>  null,
    40             'type'      =>  FILTER_SANITIZE_STRING,
    41             'options'   =>  array(
    42                 'filter'    => FILTER_SANITIZE_STRING,
    43                 'flags'     => FILTER_FORCE_ARRAY
    44                 ),
    45             'helptext'  =>  FILTER_SANITIZE_STRING
     39            'display_name'  =>  FILTER_SANITIZE_STRING,
     40            'default'       =>  null,
     41            'type'          =>  FILTER_SANITIZE_STRING,
     42            'options'       =>  array(
     43                                'filter' => FILTER_SANITIZE_STRING,
     44                                'flags'  => FILTER_FORCE_ARRAY
     45                            ),
     46            'helptext'      =>  FILTER_SANITIZE_STRING
    4647        );
    4748
  • leaflet-map/tags/2.10.0/class.plugin-settings.php

    r1797861 r1809668  
    2828
    2929    /**
    30     * Default values and admin form information
     30    * Default values and admin form information
     31    * Needs to be created within __construct
     32    * in order to use a function such as __()
    3133    * @var array $options
    3234    */
    33     public $options = array(
    34         'default_lat' => array(
    35             'default'=>'44.67',
    36             'type' => 'text',
    37             'helptext' => 'Default latitude for maps or adjust for each map like so: <br /> <code>[leaflet-map lng="44.67"]</code>'
    38         ),
    39         'default_lng' => array(
    40             'default'=>'-63.61',
    41             'type' => 'text',
    42             'helptext' => 'Default longitude for maps or adjust for each map like so: <br /> <code>[leaflet-map lng="-63.61"]</code>'
    43         ),
    44         'default_zoom' => array(
    45             'default'=>'12',
    46             'type' => 'text',
    47             'helptext' => 'Can set per map in shortcode or adjust for all maps here; e.g. <br /> <code>[leaflet-map zoom="5"]</code>'
    48         ),
    49         'default_height' => array(
    50             'default'=>'250',
    51             'type' => 'text',
    52             'helptext' => 'Can set per map in shortcode or adjust for all maps here. Values can include "px" but it is not necessary.  Can also be %; e.g. <br/> <code>[leaflet-map height="250"]</code>'
    53         ),
    54         'default_width' => array(
    55             'default'=>'100%',
    56             'type' => 'text',
    57             'helptext' => 'Can set per map in shortcode or adjust for all maps here. Values can include "px" but it is not necessary.  Can also be %; e.g. <br/> <code>[leaflet-map width="100%"]</code>'
    58         ),
    59         'fit_markers' => array(
    60             'default' => '0',
    61             'type' => 'checkbox',
    62             'helptext' => 'If enabled, all markers on each map will alter the view of the map; i.e. the map will fit to the bounds of all of the markers on the map.  You can also change this per map in the shortcode: e.g. <br /> <code>[leaflet-map fit_markers="1"]</code>'
    63         ),
    64         'show_zoom_controls' => array(
    65             'default' => '0',
    66             'type' => 'checkbox',
    67             'helptext' => 'The zoom buttons can be large and annoying.  Enabled or disable per map in shortcode: <br/> <code>[leaflet-map zoomcontrol="0"]</code>'
    68         ),
    69         'scroll_wheel_zoom' => array(
    70             'default' => '0',
    71             'type' => 'checkbox',
    72             'helptext' => 'Disable zoom with mouse scroll wheel.  Sometimes someone wants to scroll down the page, and not zoom the map.  Enable or disable per map in shortcode: <br/> <code>[leaflet-map scrollwheel="0"]</code>'
    73         ),
    74         'double_click_zoom' => array(
    75             'default' => '0',
    76             'type' => 'checkbox',
    77             'helptext' => 'If enabled, your maps will zoom with a double click.  By default it is disabled: If we\'re going to remove zoom controls and have scroll wheel zoom off by default, we might as well stick to our guns and not zoom the map.  Enable or disable per map in shortcode: <br/> <code>[leaflet-map doubleClickZoom=false]</code>'
    78         ),
    79         'default_min_zoom' => array(
    80             'default' => '0',
    81             'type' => 'text',
    82             'helptext' => 'Restrict the viewer from zooming in past the minimum zoom.  Can set per map in shortcode or adjust for all maps here; e.g. <br /> <code>[leaflet-map min_zoom="1"]</code>'
    83         ),
    84         'default_max_zoom' => array(
    85             'default' => '20',
    86             'type' => 'text',
    87             'helptext' => 'Restrict the viewer from zooming out past the maximum zoom.  Can set per map in shortcode or adjust for all maps here; e.g. <br /> <code>[leaflet-map max_zoom="10"]</code>'
    88         ),
    89         'default_tiling_service' => array(
    90             'default' => 'other',
    91             'type' => 'select',
    92             'options' => array(
    93                 'other' => 'I will provide my own map tile URL',
    94                 'mapquest' => 'MapQuest (I have an app key)',
    95             ),
    96             'helptext' => 'Choose a tiling service or provide your own.'
    97         ),
    98         'mapquest_appkey' => array(
    99             'default' => 'supply-an-app-key-if-you-choose-mapquest',
    100             'type' => 'text',
    101             'noreset' => true,
    102             'helptext' => 'If you choose MapQuest, you must provide an app key. <a href="https://developer.mapquest.com/plan_purchase/steps/business_edition/business_edition_free/register" target="_blank">Sign up</a>, then <a href="https://developer.mapquest.com/user/me/apps" target="_blank">Create a new app</a> then supply the "Consumer Key" here.'
    103         ),
    104         'map_tile_url' => array(
    105             'default'=>'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
    106             'type' => 'text',
    107             'helptext' => 'See more tile servers here: <a href="http://wiki.openstreetmap.org/wiki/Tile_servers" target="_blank">here</a>.  Please note(!): free tiles from MapQuest have been discontinued without use of an app key (free accounts available) (see <a href="http://devblog.mapquest.com/2016/06/15/modernization-of-mapquest-results-in-changes-to-open-tile-access/" target="_blank">blog post</a>). Can be set per map with the shortcode <br/> <code>[leaflet-map tileurl=http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg subdomains=abcd]</code>'
    108         ),
    109         'map_tile_url_subdomains' => array(
    110             'default'=>'abc',
    111             'type' => 'text',
    112             'helptext' => 'Some maps get tiles from multiple servers with subdomains such as a,b,c,d or 1,2,3,4; can be set per map with the shortcode <br/> <code>[leaflet-map subdomains="1234"]</code>',
    113         ),
    114         'js_url' => array(
    115             'default'=>'https://unpkg.com/leaflet@%s/dist/leaflet.js',
    116             'type' => 'text',
    117             'helptext' => 'If you host your own Leaflet files, specify the URL here.'
    118         ),
    119         'css_url' => array(
    120             'default'=>'https://unpkg.com/leaflet@%s/dist/leaflet.css',
    121             'type' => 'text',
    122             'helptext' => 'Same as above.'
    123         ),
    124         'default_attribution' => array(
    125             'default' => "<a href=\"http://leafletjs.com\" title=\"A JS library for interactive maps\">Leaflet</a>; \r\n© <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors",
    126             'type' => 'textarea',
    127             'helptext' => 'Attribution to a custom tile url.  Use semi-colons (;) to separate multiple.'
    128         ),
    129         'geocoder' => array(
    130             'default' => 'google',
    131             'type' => 'select',
    132             'options' => array(
    133                 'google' => 'Google Maps',
    134                 'osm' => 'OpenStreetMap Nominatim',
    135                 'dawa' => 'Danmarks Adressers'
    136             ),
    137             'helptext' => 'Select the Geocoding provider to use to retrieve addresses defined in shortcode.'
    138         )
    139     );
     35    public $options = array();
    14036
    14137    /**
     
    15652        $leaflet_version = Leaflet_Map::$leaflet_version;
    15753
    158         $this->options['js_url']['default'] = sprintf($this->options['js_url']['default'], $leaflet_version);
    159         $this->options['css_url']['default'] = sprintf($this->options['css_url']['default'], $leaflet_version);
    160 
    161         foreach ($this->options as $name => $details) {
     54        $foreachmap = __('You can also change this for each map');
     55
     56        /*
     57        * initiate options using internationalization!
     58        */
     59        $this->options = array(
     60            'default_lat' => array(
     61                'display_name'=>__('Default Latitude', 'leaflet-map'),
     62                'default'=>'44.67',
     63                'type' => 'text',
     64                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map lat="44.67"]</code>',
     65                    __('Default latitude for maps.', 'leaflet-map'),
     66                    $foreachmap
     67                )
     68            ),
     69            'default_lng' => array(
     70                'display_name'=>__('Default Longitude', 'leaflet-map'),
     71                'default'=>'-63.61',
     72                'type' => 'text',
     73                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map lng="-63.61"]</code>',
     74                    __('Default longitude for maps.', 'leaflet-map'),
     75                    $foreachmap
     76                )
     77            ),
     78            'default_zoom' => array(
     79                'display_name'=>__('Default Zoom', 'leaflet-map'),
     80                'default'=>'12',
     81                'type' => 'text',
     82                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map zoom="5"]</code>',
     83                    __('Default zoom for maps.', 'leaflet-map'),
     84                    $foreachmap
     85                )
     86            ),
     87            'default_height' => array(
     88                'display_name'=>__('Default Height', 'leaflet-map'),
     89                'default'=>'250',
     90                'type' => 'text',
     91                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map height="250"]</code>',
     92                    __('Default height for maps. Values can include "px" but it is not necessary. Can also be "%". ', 'leaflet-map'),
     93                    $foreachmap
     94                )
     95            ),
     96            'default_width' => array(
     97                'display_name'=>__('Default Width', 'leaflet-map'),
     98                'default'=>'100%',
     99                'type' => 'text',
     100                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map width="100%"]</code>',
     101                    __('Default width for maps. Values can include "px" but it is not necessary.  Can also be "%".', 'leaflet-map'),
     102                    $foreachmap
     103                )
     104            ),
     105            'fit_markers' => array(
     106                'display_name'=>__('Fit Markers', 'leaflet-map'),
     107                'default' => '0',
     108                'type' => 'checkbox',
     109                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map fit_markers="1"]</code>',
     110                    __('If enabled, all markers on each map will alter the view of the map; i.e. the map will fit to the bounds of all of the markers on the map.', 'leaflet-map'),
     111                    $foreachmap
     112                )
     113            ),
     114            'show_zoom_controls' => array(
     115                'display_name'=>__('Show Zoom Controls', 'leaflet-map'),
     116                'default' => '0',
     117                'type' => 'checkbox',
     118                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map zoomcontrol="0"]</code>',
     119                    __('The zoom buttons can be large and annoying.', 'leaflet-map'),
     120                    $foreachmap
     121                )
     122            ),
     123            'scroll_wheel_zoom' => array(
     124                'display_name'=>__('Scroll Wheel Zoom', 'leaflet-map'),
     125                'default' => '0',
     126                'type' => 'checkbox',
     127                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map scrollwheel="0"]</code>',
     128                    __('Disable zoom with mouse scroll wheel.  Sometimes someone wants to scroll down the page, and not zoom the map.', 'leaflet-map'),
     129                    $foreachmap
     130                )
     131            ),
     132            'double_click_zoom' => array(
     133                'display_name'=>__('Double Click Zoom', 'leaflet-map'),
     134                'default' => '0',
     135                'type' => 'checkbox',
     136                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map doubleClickZoom=false]</code>',
     137                    __('If enabled, your maps will zoom with a double click.  By default it is disabled: If we\'re going to remove zoom controls and have scroll wheel zoom off by default, we might as well stick to our guns and not zoom the map.', 'leaflet-map'),
     138                    $foreachmap
     139                )
     140            ),
     141            'default_min_zoom' => array(
     142                'display_name'=>__('Default Min Zoom', 'leaflet-map'),
     143                'default' => '0',
     144                'type' => 'text',
     145                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map min_zoom="1"]</code>',
     146                    __('Restrict the viewer from zooming in past the minimum zoom.  Can set per map in shortcode or adjust for all maps here.', 'leaflet-map'),
     147                    $foreachmap
     148                )
     149            ),
     150            'default_max_zoom' => array(
     151                'display_name'=>__('Default Max Zoom', 'leaflet-map'),
     152                'default' => '20',
     153                'type' => 'text',
     154                'helptext' => sprintf('%1$s %2%s <br /> <code>%3$s</code>',
     155                    __('Restrict the viewer from zooming out past the maximum zoom.  Can set per map in shortcode or adjust for all maps here', 'leaflet-map'),
     156                    $foreachmap,
     157                    '[leaflet-map max_zoom="10"]'
     158                )
     159            ),
     160            'default_tiling_service' => array(
     161                'display_name'=>__('Default Tiling Service', 'leaflet-map'),
     162                'default' => 'other',
     163                'type' => 'select',
     164                'options' => array(
     165                    'other' => __('I will provide my own map tile URL', 'leaflet-map'),
     166                    'mapquest' => __('MapQuest (I have an app key)', 'leaflet-map'),
     167                ),
     168                'helptext' => __('Choose a tiling service or provide your own.', 'leaflet-map')
     169            ),
     170            'mapquest_appkey' => array(
     171                'display_name'=>__('MapQuest App Key', 'leaflet-map'),
     172                'default' => __('Supply an app key if you choose MapQuest', 'leaflet-map'),
     173                'type' => 'text',
     174                'noreset' => true,
     175                'helptext' => sprintf('%1$s <a href="https://developer.mapquest.com/plan_purchase/steps/business_edition/business_edition_free/register" target="_blank"> %2$s </a>, %3$s <a href="https://developer.mapquest.com/user/me/apps" target="_blank"> %4$s </a> %5$s',
     176                    __('If you choose MapQuest, you must provide an app key.', 'leaflet-map'),
     177                    __('Sign up', 'leaflet-map'),
     178                    __('then', 'leaflet-map'),
     179                    __('Create a new app', 'leaflet-map'),
     180                    __('then supply the "Consumer Key" here.', 'leaflet-map')
     181                )
     182            ),
     183            'map_tile_url' => array(
     184                'display_name'=>__('Map Tile URL', 'leaflet-map'),
     185                'default'=>'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
     186                'type' => 'text',
     187                'helptext' => sprintf('%1$s: <a href="http://wiki.openstreetmap.org/wiki/Tile_servers" target="_blank"> %2$s </a>. %3$s: <a href="http://devblog.mapquest.com/2016/06/15/modernization-of-mapquest-results-in-changes-to-open-tile-access/" target="_blank"> %4$s </a>. %5$s <br/> <code>[leaflet-map tileurl=http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg subdomains=abcd]</code>',
     188                    __('See more tile servers', 'leaflet-map'),
     189                    __('here', 'leaflet-map'),
     190                    __('Please note: free tiles from MapQuest have been discontinued without use of an app key', 'leaflet-map'),
     191                    __('blog post', 'leaflet-map'),
     192                    $foreachmap
     193                )
     194            ),
     195            'map_tile_url_subdomains' => array(
     196                'display_name'=>__('Map Tile URL Subdomains', 'leaflet-map'),
     197                'default'=>'abc',
     198                'type' => 'text',
     199                'helptext' => sprintf('%1$s %2$s <br/> <code>[leaflet-map subdomains="1234"]</code>',
     200                    __('Some maps get tiles from multiple servers with subdomains such as a,b,c,d or 1,2,3,4', 'leaflet-map'),
     201                    $foreachmap
     202                )
     203            ),
     204            'js_url' => array(
     205                'display_name'=>__('JavaScript URL', 'leaflet-map'),
     206                'default' => sprintf('https://unpkg.com/leaflet@%s/dist/leaflet.js', $leaflet_version),
     207                'type' => 'text',
     208                'helptext' => __('If you host your own Leaflet files, then paste the URL here.', 'leaflet-map')
     209            ),
     210            'css_url' => array(
     211                'display_name'=>__('CSS URL', 'leaflet-map'),
     212                'default' => sprintf('https://unpkg.com/leaflet@%s/dist/leaflet.css', $leaflet_version),
     213                'type' => 'text',
     214                'helptext' => __('Same as above.', 'leaflet-map')
     215            ),
     216            'default_attribution' => array(
     217                'display_name'=>__('Default Attribution', 'leaflet-map'),
     218                'default' => sprintf('<a href="http://leafletjs.com" title="%1$s">Leaflet</a>; \r\n© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> %2$s',
     219                        __("A JS library for interactive maps", 'leaflet-map'),
     220                        __("contributors", 'leaflet-map')
     221                    ),
     222                'type' => 'textarea',
     223                'helptext' => __('Attribution to a custom tile url.  Use semi-colons (;) to separate multiple.', 'leaflet-map')
     224            ),
     225            'geocoder' => array(
     226                'display_name'=>__('Geocoder', 'leaflet-map'),
     227                'default' => 'google',
     228                'type' => 'select',
     229                'options' => array(
     230                    'google' => __('Google Maps', 'leaflet-map'),
     231                    'osm' => __('OpenStreetMap Nominatim', 'leaflet-map'),
     232                    'dawa' => __('Denmark Addresses', 'leaflet-map')
     233                ),
     234                'helptext' => __('Select the Geocoding provider to use to retrieve addresses defined in shortcode.', 'leaflet-map')
     235            )
     236        );
     237
     238        foreach ($this->options as $name => $details) {
    162239            $this->options[ $name ] = new Leaflet_Map_Plugin_Option( $details );
    163240        }
  • leaflet-map/tags/2.10.0/leaflet-map.php

    r1797863 r1809668  
    66    Author: bozdoz
    77    Author URI: https://twitter.com/bozdoz/
    8     Version: 2.9.1
     8    Text Domain: leaflet-map
     9    Domain Path: /languages/
     10    Version: 2.10.0
    911    License: GPL2
    1012
  • leaflet-map/tags/2.10.0/readme.txt

    r1797863 r1809668  
    33Author URI: https://www.twitter.com/bozdoz/
    44Plugin URI: https://wordpress.org/plugins/leaflet-map/
    5 Contributors: bozdoz, Remigr, nielsalstrup, jeromelebleu
     5Contributors: bozdoz, Remigr, nielsalstrup, jeromelebleu, gerital
    66Donate link: https://www.paypal.me/bozdoz
    77Tags: leaflet, map, mobile, javascript, openstreetmap, mapquest, interactive
    88Requires at least: 3.0.1
    99Tested up to: 4.9
    10 Version: 2.9.1
    11 Stable tag: 2.9.1
     10Version: 2.10.0
     11Stable tag: 2.10.0
    1212License: GPLv2
    1313License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7878= Can I add geojson? =
    7979
    80 Yes, just give it a source URL: `[leaflet-geojson src="https://example.com/path/to.geojson"]` It will also support leaflet geojson styles or geojson.io styles. Add a popup message with `[leaflet-geojson popup_text="hello!"]`, or add HTML by adding it to the content of the shortcode: `[leaflet-geojson]<a href="#">Link here</a>[/leaflet-geojson]` or identify a geojson property with `popup_property`, and each shape will use its own popup text if available.
     80Yes, just give it a source URL: `[leaflet-geojson src="https://example.com/path/to.geojson"]` It will also support leaflet geojson styles or geojson.io styles. Add a popup message with `[leaflet-geojson popup_text="hello!"]`, or add HTML by adding it to the content of the shortcode: `[leaflet-geojson]<a href="#">Link here, or use text from a feature property, like {title}</a>[/leaflet-geojson]` or identify a geojson property with `popup_property`, and each shape will use its own popup text if available.
    8181
    8282= Can I add kml/gpx? =
     
    121121== Changelog ==
    122122
     123= 2.10.0 =
     124* Added functions for translating text
     125* Added string interpolation for GeoJSON popups to use feature properties (thanks to [@geraldo](https://github.com/geraldo))
     126
    123127= 2.9.1 =
    124128* Fixes for PHP 7.2: made all method arguments identical
  • leaflet-map/tags/2.10.0/shortcodes/class.geojson-shortcode.php

    r1797863 r1809668  
    107107                function onEachFeature (feature, layer) {
    108108                    var props = feature.properties || {},
    109                         text = popup_property && props[ popup_property ] || popup_text;
     109                        text = popup_property && props[ popup_property ] || template(popup_text, feature.properties);
    110110                    if (text) {
    111111                        layer.bindPopup( text );
    112112                    }
    113                 }         
     113                }
     114                var templateRe = /\{ *([\w_-]+) *\}/g;
     115                function template(str, data) {
     116                    return str.replace(templateRe, function (match, key) {
     117                        var value = data[key];
     118                        if (value === undefined) {
     119                            return match;
     120                        }
     121                        return value;
     122                    });
     123                } 
    114124            });
    115125        </script>
  • leaflet-map/tags/2.10.0/templates/settings.php

    r1709928 r1809668  
    11<?php
    22$title = $plugin_data['Name'];
    3 $description = $plugin_data['Description'];
     3$description = __('A plugin for creating a Leaflet JS map with a shortcode. Boasts two free map tile services and three free geocoders.', 'leaflet-map');
    44$version = $plugin_data['Version'];
    5 
    6 function option_label ($opt) {
    7     $opt = explode('_', $opt);
    8    
    9     foreach($opt as &$v) {
    10         $v = ucfirst($v);
    11     }
    12     echo implode(' ', $opt);
    13 }
    145?>
    156<div class="wrap">
     
    3324?>
    3425<div class="notice notice-success is-dismissible">
    35     <p>Options Updated!</p>
     26    <p><?php _e('Options Updated!', 'leaflet-map'); ?></p>
    3627</div>
    3728<?php
     
    4031?>
    4132<div class="notice notice-success is-dismissible">
    42     <p>Options have been reset to default values!</p>
     33    <p><?php _e('Options have been reset to default values!', 'leaflet-map'); ?></p>
    4334</div>
    4435<?php
     
    4839?>
    4940<div class="notice notice-success is-dismissible">
    50     <p>Location caches have been cleared!</p>
     41    <p><?php _e('Location caches have been cleared!', 'leaflet-map'); ?></p>
    5142</div>
    5243<?php
     
    5748    <form method="post">
    5849        <div class="container">
    59             <h2>Settings</h2>
     50            <h2><?php _e('Settings', 'leaflet-map'); ?></h2>
    6051            <hr>
    6152        </div>
     
    6657    <div class="container">
    6758        <label>
    68             <span class="label"><?php option_label($name); ?></span>
     59            <span class="label"><?php echo $option->display_name; ?></span>
    6960            <span class="input-group">
    7061            <?php
     
    7869        ?>
    7970        <div class="helptext">
    80             <p class="description"><?php
    81                 echo $option->helptext;
    82             ?></p>
     71            <p class="description"><?php echo $option->helptext; ?></p>
    8372        </div>
    8473        <?php
     
    9079    ?>
    9180    <div class="submit">
    92         <input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
    93         <input type="submit" name="reset" id="reset" class="button button-secondary" value="Reset to Defaults">
     81        <input type="submit"
     82            name="submit"
     83            id="submit"
     84            class="button button-primary"
     85            value="<?php _e('Save Changes', 'leaflet-map'); ?>">
     86        <input type="submit"
     87            name="reset"
     88            id="reset"
     89            class="button button-secondary"
     90            value="<?php _e('Reset to Defaults', 'leaflet-map'); ?>">
    9491        <input type="submit"
    9592            name="clear-geocoder-cache"
    9693            id="clear-geocoder-cache"
    9794            class="button button-secondary"
    98             value="Clear Geocoder Cache">
     95            value="<?php _e('Clear Geocoder Cache', 'leaflet-map'); ?>">
    9996    </div>
    10097
  • leaflet-map/tags/2.10.0/templates/shortcode-helper.php

    r1720896 r1809668  
    1515    <div class="wrap">
    1616        <?php
     17        $drag = __('Drag Me', 'leaflet-map');
     18
    1719        echo do_shortcode('[leaflet-map zoom=2 zoomcontrol=1 doubleClickZoom=1 height=300 scrollwheel=1]');
    18         echo do_shortcode('[leaflet-marker draggable=1 message="Drag me!" visible="true"]');
     20        echo do_shortcode(sprintf('[leaflet-marker draggable=1 visible="true"] %s [/leaflet-marker]',
     21            $drag
     22        ));
    1923        ?>
    2024        <div class="wrap">
    2125            <hr>
    22             <h2>Interactive Shortcodes:</h2>
    23             <p class="description">Move the map and the marker to generate shortcodes below:</p>
    24             <div class="flex"><label class="h3" for="map-shortcode">Map Shortcode</label> <input type="text" id="map-shortcode" readonly="readonly" /></div>
    25             <div class="flex"><label class="h3" for="marker-shortcode">Marker Shortcode</label> <input type="text" id="marker-shortcode" readonly="readonly" /></div>
     26            <h2><?php _e('Interactive Shortcodes:', 'leaflet-map'); ?></h2>
     27            <p class="description"><?php _e('Move the map and the marker to generate shortcodes below:', 'leaflet-map'); ?></p>
     28            <div class="flex"><label class="h3" for="map-shortcode"><?php _e('Map Shortcode', 'leaflet-map'); ?></label> <input type="text" id="map-shortcode" readonly="readonly" /></div>
     29            <div class="flex"><label class="h3" for="marker-shortcode"><?php _e('Marker Shortcode', 'leaflet-map'); ?></label> <input type="text" id="marker-shortcode" readonly="readonly" /></div>
    2630            <hr>
    27             <h2>Examples:</h2>
     31            <h2><?php _e('Examples', 'leaflet-map'); ?>:</h2>
    2832            <div class="examples">
    2933            <?php
    3034            $examples = array(
    31                 "Standard" => array(
     35                __("Standard", 'leaflet-map') => array(
    3236                    '[leaflet-map zoom=12 lat=51.05 lng=-114.06]',
    3337                    ),
    34                 "Many Markers!" => array(
     38                __("Many Markers!", 'leaflet-map') => array(
    3539                    '[leaflet-map zoom=10 lat=43.65 lng=-79.385]',
    3640                    '[leaflet-marker]',
     
    3842                    '[leaflet-marker lat=43.67 lng=-79.4]',
    3943                    ),
    40                 "Draggable Marker" => array(
     44                __("Draggable Marker", 'leaflet-map') => array(
    4145                    '[leaflet-map zoom=8 lat=-33.85 lng=151.21 scrollwheel=1]',
    4246                    '[leaflet-marker draggable=1]',
    4347                    ),
    44                 "Marker Icon" => array(
     48                __("Marker Icon", 'leaflet-map') => array(
    4549                    '[leaflet-map zoom=10 address="cochrane, Ontario" scrollwheel=1]',
    4650                    '[leaflet-marker iconUrl="https://i.imgur.com/Q54ueuO.png" iconSize="80,50" iconAnchor="40,60"]'
    4751                    ),
    48                 "Zoom Buttons" => array(
     52                __("Zoom Buttons", 'leaflet-map') => array(
    4953                    '[leaflet-map zoom=9 lat=48.855 lng=2.35 zoomcontrol=1]',
    5054                    ),
    51                 "Alternate Map Tiles w/scrollwheel" => array(
     55                __("Alternate Map Tiles w/scrollwheel", 'leaflet-map') => array(
    5256                    '[leaflet-map zoom=2 scrollwheel=1 lat=-2.507 lng=32.902 tileurl=https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg subdomains=abcd attribution="Map tiles by Stamen Design, under CC BY 3.0."]',
    5357                    ),
    54                 "Marker Popup Messages (on click)" => array(
     58                __("Marker Popup Messages (on click)", 'leaflet-map') => array(
    5559                    '[leaflet-map lat=59.913 lng=10.739 zoom=12]',
    5660                    '[leaflet-marker]OSLO![/leaflet-marker]',
    5761                    ),
    58                 "Links In Marker Messages (visible)" => array(
     62                __("Links In Marker Messages (visible)", 'leaflet-map') => array(
    5963                    '[leaflet-map lat=28.41 lng=-81.58 zoom=15]',
    6064                    '[leaflet-marker visible="true"] Disney World! <a href="https://disneyworld.disney.go.com">Link</a> [/leaflet-marker]',
    6165                    ),
    62                 "Basic Lines w/Scrollwheel" => array(
     66                __("Basic Lines w/Scrollwheel", 'leaflet-map') => array(
    6367                    '[leaflet-map lat=41 lng=29 scrollwheel=1 zoom=6]',
    6468                    '[leaflet-line latlngs="41, 29; 44, 18;"]'
    6569                    ),
    66                 "Fitted Colored Line on Addresses" => array(
     70                __("Fitted Colored Line on Addresses", 'leaflet-map') => array(
    6771                    '[leaflet-map]',
    6872                    '[leaflet-line color="purple" addresses="Sayulita; Puerto Vallarta;" fitline=1]'
    6973                    ),
    70                 "More Crazy Line Attributes" => array(
     74                __("More Crazy Line Attributes", 'leaflet-map') => array(
    7175                    '[leaflet-map]',
    72                     '[leaflet-line color="red" weight=10 dasharray="2,15" addresses="Halifax, NS; Tanzania" classname=marching-ants fitbounds=1]CSS makes me march![/leaflet-line]'
     76                    '[leaflet-line color="red" weight=10 dasharray="2,15" addresses="Halifax, NS; Tanzania" classname=marching-ants fitbounds=1]'
    7377                    ),
    74                 "Disable all Interaction" => array(
     78                __("Disable all Interaction", 'leaflet-map') => array(
    7579                    '[leaflet-map address="las vegas" boxZoom=false doubleClickZoom=false dragging=false keyboard=false scrollwheel=0 attribution=0]',
    7680                    ),
    77                 "Add GeoJSON by URL (with popups)" => array(
     81                __("Add GeoJSON by URL (with popups)", 'leaflet-map') => array(
    7882                    '[leaflet-map doubleClickZoom=true scrollwheel=true]',
    7983                    '[leaflet-geojson src=https://cdn.rawgit.com/bozdoz/064a7101b95a324e8852fe9381ab9a18/raw/03f4f54b13a3a7e256732760a8b679818d9d36fc/map.geojson fitbounds=1 popup_property="popup-text"]'
    8084                    ),
    81                 "Test Image Map" => array(
     85                __("Test Image Map", 'leaflet-map') => array(
    8286                    '[leaflet-image zoom=1 zoomcontrol=1 scrollwheelzoom=1 attribution=0]',
    8387                    '[leaflet-marker]'
  • leaflet-map/trunk/class.leaflet-map.php

    r1797863 r1809668  
    1414    * @var string major minor patch version
    1515    */
    16     public static $version = '2.9.1';
     16    public static $version = '2.10.0';
    1717
    1818    /**
     
    2020    * @var string major minor patch version
    2121    */
    22     public static $leaflet_version = '1.2.0';
     22    public static $leaflet_version = '1.3.1';
    2323
    2424    /**
     
    8484     */
    8585    private function __construct() {
    86         $this->includes();
    8786        $this->init_hooks();
    8887        $this->add_shortcodes();
     
    9493    /**
    9594    *
    96     * include classes
    97     *
    98     */
    99     private function includes() {
    100         // Leaflet_Map_Plugin_Settings
    101         include_once(LEAFLET_MAP__PLUGIN_DIR . 'class.plugin-settings.php');
     95    * add actions and filters
     96    *
     97    */
     98    private function init_hooks() {
    10299        // Leaflet_Map_Admin
    103100        include_once(LEAFLET_MAP__PLUGIN_DIR . 'class.admin.php');
    104     }
    105 
    106     /**
    107     *
    108     * add actions and filters
    109     *
    110     */
    111     private function init_hooks() {
    112101       
    113102        // init admin
    114103        Leaflet_Map_Admin::init();
     104
     105        add_action( 'plugins_loaded', array('Leaflet_Map', 'load_text_domain' ));
    115106       
    116107        add_action( 'wp_enqueue_scripts', array('Leaflet_Map', 'enqueue_and_register') );
     
    156147
    157148    /**
     149    * Loads Translations
     150    *
     151    */
     152    public static function load_text_domain() {
     153        load_plugin_textdomain( 'leaflet-map', false, dirname( plugin_basename( LEAFLET_MAP__PLUGIN_FILE ) ) . '/languages/' );
     154    }
     155
     156    /**
    158157    * Enqueue and register styles and scripts (called in __construct)
    159158    *
     
    162161    public static function enqueue_and_register () {
    163162        /* defaults from db */
     163        // Leaflet_Map_Plugin_Settings
     164        include_once(LEAFLET_MAP__PLUGIN_DIR . 'class.plugin-settings.php');
    164165        $settings = Leaflet_Map_Plugin_Settings::init();
    165166
  • leaflet-map/trunk/class.plugin-option.php

    r1720896 r1809668  
    3737
    3838        $option_filter = array(
    39             'default'   =>  null,
    40             'type'      =>  FILTER_SANITIZE_STRING,
    41             'options'   =>  array(
    42                 'filter'    => FILTER_SANITIZE_STRING,
    43                 'flags'     => FILTER_FORCE_ARRAY
    44                 ),
    45             'helptext'  =>  FILTER_SANITIZE_STRING
     39            'display_name'  =>  FILTER_SANITIZE_STRING,
     40            'default'       =>  null,
     41            'type'          =>  FILTER_SANITIZE_STRING,
     42            'options'       =>  array(
     43                                'filter' => FILTER_SANITIZE_STRING,
     44                                'flags'  => FILTER_FORCE_ARRAY
     45                            ),
     46            'helptext'      =>  FILTER_SANITIZE_STRING
    4647        );
    4748
  • leaflet-map/trunk/class.plugin-settings.php

    r1720896 r1809668  
    2828
    2929    /**
    30     * Default values and admin form information
     30    * Default values and admin form information
     31    * Needs to be created within __construct
     32    * in order to use a function such as __()
    3133    * @var array $options
    3234    */
    33     public $options = array(
    34         'default_lat' => array(
    35             'default'=>'44.67',
    36             'type' => 'text',
    37             'helptext' => 'Default latitude for maps or adjust for each map like so: <br /> <code>[leaflet-map lng="44.67"]</code>'
    38         ),
    39         'default_lng' => array(
    40             'default'=>'-63.61',
    41             'type' => 'text',
    42             'helptext' => 'Default longitude for maps or adjust for each map like so: <br /> <code>[leaflet-map lng="-63.61"]</code>'
    43         ),
    44         'default_zoom' => array(
    45             'default'=>'12',
    46             'type' => 'text',
    47             'helptext' => 'Can set per map in shortcode or adjust for all maps here; e.g. <br /> <code>[leaflet-map zoom="5"]</code>'
    48         ),
    49         'default_height' => array(
    50             'default'=>'250',
    51             'type' => 'text',
    52             'helptext' => 'Can set per map in shortcode or adjust for all maps here. Values can include "px" but it is not necessary.  Can also be %; e.g. <br/> <code>[leaflet-map height="250"]</code>'
    53         ),
    54         'default_width' => array(
    55             'default'=>'100%',
    56             'type' => 'text',
    57             'helptext' => 'Can set per map in shortcode or adjust for all maps here. Values can include "px" but it is not necessary.  Can also be %; e.g. <br/> <code>[leaflet-map width="100%"]</code>'
    58         ),
    59         'fit_markers' => array(
    60             'default' => '0',
    61             'type' => 'checkbox',
    62             'helptext' => 'If enabled, all markers on each map will alter the view of the map; i.e. the map will fit to the bounds of all of the markers on the map.  You can also change this per map in the shortcode: e.g. <br /> <code>[leaflet-map fit_markers="1"]</code>'
    63         ),
    64         'show_zoom_controls' => array(
    65             'default' => '0',
    66             'type' => 'checkbox',
    67             'helptext' => 'The zoom buttons can be large and annoying.  Enabled or disable per map in shortcode: <br/> <code>[leaflet-map zoomcontrol="0"]</code>'
    68         ),
    69         'scroll_wheel_zoom' => array(
    70             'default' => '0',
    71             'type' => 'checkbox',
    72             'helptext' => 'Disable zoom with mouse scroll wheel.  Sometimes someone wants to scroll down the page, and not zoom the map.  Enable or disable per map in shortcode: <br/> <code>[leaflet-map scrollwheel="0"]</code>'
    73         ),
    74         'double_click_zoom' => array(
    75             'default' => '0',
    76             'type' => 'checkbox',
    77             'helptext' => 'If enabled, your maps will zoom with a double click.  By default it is disabled: If we\'re going to remove zoom controls and have scroll wheel zoom off by default, we might as well stick to our guns and not zoom the map.  Enable or disable per map in shortcode: <br/> <code>[leaflet-map doubleClickZoom=false]</code>'
    78         ),
    79         'default_min_zoom' => array(
    80             'default' => '0',
    81             'type' => 'text',
    82             'helptext' => 'Restrict the viewer from zooming in past the minimum zoom.  Can set per map in shortcode or adjust for all maps here; e.g. <br /> <code>[leaflet-map min_zoom="1"]</code>'
    83         ),
    84         'default_max_zoom' => array(
    85             'default' => '20',
    86             'type' => 'text',
    87             'helptext' => 'Restrict the viewer from zooming out past the maximum zoom.  Can set per map in shortcode or adjust for all maps here; e.g. <br /> <code>[leaflet-map max_zoom="10"]</code>'
    88         ),
    89         'default_tiling_service' => array(
    90             'default' => 'other',
    91             'type' => 'select',
    92             'options' => array(
    93                 'other' => 'I will provide my own map tile URL',
    94                 'mapquest' => 'MapQuest (I have an app key)',
    95             ),
    96             'helptext' => 'Choose a tiling service or provide your own.'
    97         ),
    98         'mapquest_appkey' => array(
    99             'default' => 'supply-an-app-key-if-you-choose-mapquest',
    100             'type' => 'text',
    101             'noreset' => true,
    102             'helptext' => 'If you choose MapQuest, you must provide an app key. <a href="https://developer.mapquest.com/plan_purchase/steps/business_edition/business_edition_free/register" target="_blank">Sign up</a>, then <a href="https://developer.mapquest.com/user/me/apps" target="_blank">Create a new app</a> then supply the "Consumer Key" here.'
    103         ),
    104         'map_tile_url' => array(
    105             'default'=>'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
    106             'type' => 'text',
    107             'helptext' => 'See more tile servers here: <a href="http://wiki.openstreetmap.org/wiki/Tile_servers" target="_blank">here</a>.  Please note(!): free tiles from MapQuest have been discontinued without use of an app key (free accounts available) (see <a href="http://devblog.mapquest.com/2016/06/15/modernization-of-mapquest-results-in-changes-to-open-tile-access/" target="_blank">blog post</a>). Can be set per map with the shortcode <br/> <code>[leaflet-map tileurl=http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg subdomains=abcd]</code>'
    108         ),
    109         'map_tile_url_subdomains' => array(
    110             'default'=>'abc',
    111             'type' => 'text',
    112             'helptext' => 'Some maps get tiles from multiple servers with subdomains such as a,b,c,d or 1,2,3,4; can be set per map with the shortcode <br/> <code>[leaflet-map subdomains="1234"]</code>',
    113         ),
    114         'js_url' => array(
    115             'default'=>'https://unpkg.com/leaflet@%s/dist/leaflet.js',
    116             'type' => 'text',
    117             'helptext' => 'If you host your own Leaflet files, specify the URL here.'
    118         ),
    119         'css_url' => array(
    120             'default'=>'https://unpkg.com/leaflet@%s/dist/leaflet.css',
    121             'type' => 'text',
    122             'helptext' => 'Same as above.'
    123         ),
    124         'default_attribution' => array(
    125             'default' => "<a href=\"http://leafletjs.com\" title=\"A JS library for interactive maps\">Leaflet</a>; \r\n© <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors",
    126             'type' => 'textarea',
    127             'helptext' => 'Attribution to a custom tile url.  Use semi-colons (;) to separate multiple.'
    128         ),
    129         'geocoder' => array(
    130             'default' => 'google',
    131             'type' => 'select',
    132             'options' => array(
    133                 'google' => 'Google Maps',
    134                 'osm' => 'OpenStreetMap Nominatim',
    135                 'dawa' => 'Danmarks Adressers'
    136             ),
    137             'helptext' => 'Select the Geocoding provider to use to retrieve addresses defined in shortcode.'
    138         )
    139     );
     35    public $options = array();
    14036
    14137    /**
     
    15652        $leaflet_version = Leaflet_Map::$leaflet_version;
    15753
    158         $this->options['js_url']['default'] = sprintf($this->options['js_url']['default'], $leaflet_version);
    159         $this->options['css_url']['default'] = sprintf($this->options['css_url']['default'], $leaflet_version);
    160 
    161         foreach ($this->options as $name => $details) {
     54        $foreachmap = __('You can also change this for each map');
     55
     56        /*
     57        * initiate options using internationalization!
     58        */
     59        $this->options = array(
     60            'default_lat' => array(
     61                'display_name'=>__('Default Latitude', 'leaflet-map'),
     62                'default'=>'44.67',
     63                'type' => 'text',
     64                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map lat="44.67"]</code>',
     65                    __('Default latitude for maps.', 'leaflet-map'),
     66                    $foreachmap
     67                )
     68            ),
     69            'default_lng' => array(
     70                'display_name'=>__('Default Longitude', 'leaflet-map'),
     71                'default'=>'-63.61',
     72                'type' => 'text',
     73                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map lng="-63.61"]</code>',
     74                    __('Default longitude for maps.', 'leaflet-map'),
     75                    $foreachmap
     76                )
     77            ),
     78            'default_zoom' => array(
     79                'display_name'=>__('Default Zoom', 'leaflet-map'),
     80                'default'=>'12',
     81                'type' => 'text',
     82                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map zoom="5"]</code>',
     83                    __('Default zoom for maps.', 'leaflet-map'),
     84                    $foreachmap
     85                )
     86            ),
     87            'default_height' => array(
     88                'display_name'=>__('Default Height', 'leaflet-map'),
     89                'default'=>'250',
     90                'type' => 'text',
     91                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map height="250"]</code>',
     92                    __('Default height for maps. Values can include "px" but it is not necessary. Can also be "%". ', 'leaflet-map'),
     93                    $foreachmap
     94                )
     95            ),
     96            'default_width' => array(
     97                'display_name'=>__('Default Width', 'leaflet-map'),
     98                'default'=>'100%',
     99                'type' => 'text',
     100                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map width="100%"]</code>',
     101                    __('Default width for maps. Values can include "px" but it is not necessary.  Can also be "%".', 'leaflet-map'),
     102                    $foreachmap
     103                )
     104            ),
     105            'fit_markers' => array(
     106                'display_name'=>__('Fit Markers', 'leaflet-map'),
     107                'default' => '0',
     108                'type' => 'checkbox',
     109                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map fit_markers="1"]</code>',
     110                    __('If enabled, all markers on each map will alter the view of the map; i.e. the map will fit to the bounds of all of the markers on the map.', 'leaflet-map'),
     111                    $foreachmap
     112                )
     113            ),
     114            'show_zoom_controls' => array(
     115                'display_name'=>__('Show Zoom Controls', 'leaflet-map'),
     116                'default' => '0',
     117                'type' => 'checkbox',
     118                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map zoomcontrol="0"]</code>',
     119                    __('The zoom buttons can be large and annoying.', 'leaflet-map'),
     120                    $foreachmap
     121                )
     122            ),
     123            'scroll_wheel_zoom' => array(
     124                'display_name'=>__('Scroll Wheel Zoom', 'leaflet-map'),
     125                'default' => '0',
     126                'type' => 'checkbox',
     127                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map scrollwheel="0"]</code>',
     128                    __('Disable zoom with mouse scroll wheel.  Sometimes someone wants to scroll down the page, and not zoom the map.', 'leaflet-map'),
     129                    $foreachmap
     130                )
     131            ),
     132            'double_click_zoom' => array(
     133                'display_name'=>__('Double Click Zoom', 'leaflet-map'),
     134                'default' => '0',
     135                'type' => 'checkbox',
     136                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map doubleClickZoom=false]</code>',
     137                    __('If enabled, your maps will zoom with a double click.  By default it is disabled: If we\'re going to remove zoom controls and have scroll wheel zoom off by default, we might as well stick to our guns and not zoom the map.', 'leaflet-map'),
     138                    $foreachmap
     139                )
     140            ),
     141            'default_min_zoom' => array(
     142                'display_name'=>__('Default Min Zoom', 'leaflet-map'),
     143                'default' => '0',
     144                'type' => 'text',
     145                'helptext' => sprintf('%1$s %2$s <br /> <code>[leaflet-map min_zoom="1"]</code>',
     146                    __('Restrict the viewer from zooming in past the minimum zoom.  Can set per map in shortcode or adjust for all maps here.', 'leaflet-map'),
     147                    $foreachmap
     148                )
     149            ),
     150            'default_max_zoom' => array(
     151                'display_name'=>__('Default Max Zoom', 'leaflet-map'),
     152                'default' => '20',
     153                'type' => 'text',
     154                'helptext' => sprintf('%1$s %2%s <br /> <code>%3$s</code>',
     155                    __('Restrict the viewer from zooming out past the maximum zoom.  Can set per map in shortcode or adjust for all maps here', 'leaflet-map'),
     156                    $foreachmap,
     157                    '[leaflet-map max_zoom="10"]'
     158                )
     159            ),
     160            'default_tiling_service' => array(
     161                'display_name'=>__('Default Tiling Service', 'leaflet-map'),
     162                'default' => 'other',
     163                'type' => 'select',
     164                'options' => array(
     165                    'other' => __('I will provide my own map tile URL', 'leaflet-map'),
     166                    'mapquest' => __('MapQuest (I have an app key)', 'leaflet-map'),
     167                ),
     168                'helptext' => __('Choose a tiling service or provide your own.', 'leaflet-map')
     169            ),
     170            'mapquest_appkey' => array(
     171                'display_name'=>__('MapQuest App Key', 'leaflet-map'),
     172                'default' => __('Supply an app key if you choose MapQuest', 'leaflet-map'),
     173                'type' => 'text',
     174                'noreset' => true,
     175                'helptext' => sprintf('%1$s <a href="https://developer.mapquest.com/plan_purchase/steps/business_edition/business_edition_free/register" target="_blank"> %2$s </a>, %3$s <a href="https://developer.mapquest.com/user/me/apps" target="_blank"> %4$s </a> %5$s',
     176                    __('If you choose MapQuest, you must provide an app key.', 'leaflet-map'),
     177                    __('Sign up', 'leaflet-map'),
     178                    __('then', 'leaflet-map'),
     179                    __('Create a new app', 'leaflet-map'),
     180                    __('then supply the "Consumer Key" here.', 'leaflet-map')
     181                )
     182            ),
     183            'map_tile_url' => array(
     184                'display_name'=>__('Map Tile URL', 'leaflet-map'),
     185                'default'=>'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
     186                'type' => 'text',
     187                'helptext' => sprintf('%1$s: <a href="http://wiki.openstreetmap.org/wiki/Tile_servers" target="_blank"> %2$s </a>. %3$s: <a href="http://devblog.mapquest.com/2016/06/15/modernization-of-mapquest-results-in-changes-to-open-tile-access/" target="_blank"> %4$s </a>. %5$s <br/> <code>[leaflet-map tileurl=http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg subdomains=abcd]</code>',
     188                    __('See more tile servers', 'leaflet-map'),
     189                    __('here', 'leaflet-map'),
     190                    __('Please note: free tiles from MapQuest have been discontinued without use of an app key', 'leaflet-map'),
     191                    __('blog post', 'leaflet-map'),
     192                    $foreachmap
     193                )
     194            ),
     195            'map_tile_url_subdomains' => array(
     196                'display_name'=>__('Map Tile URL Subdomains', 'leaflet-map'),
     197                'default'=>'abc',
     198                'type' => 'text',
     199                'helptext' => sprintf('%1$s %2$s <br/> <code>[leaflet-map subdomains="1234"]</code>',
     200                    __('Some maps get tiles from multiple servers with subdomains such as a,b,c,d or 1,2,3,4', 'leaflet-map'),
     201                    $foreachmap
     202                )
     203            ),
     204            'js_url' => array(
     205                'display_name'=>__('JavaScript URL', 'leaflet-map'),
     206                'default' => sprintf('https://unpkg.com/leaflet@%s/dist/leaflet.js', $leaflet_version),
     207                'type' => 'text',
     208                'helptext' => __('If you host your own Leaflet files, then paste the URL here.', 'leaflet-map')
     209            ),
     210            'css_url' => array(
     211                'display_name'=>__('CSS URL', 'leaflet-map'),
     212                'default' => sprintf('https://unpkg.com/leaflet@%s/dist/leaflet.css', $leaflet_version),
     213                'type' => 'text',
     214                'helptext' => __('Same as above.', 'leaflet-map')
     215            ),
     216            'default_attribution' => array(
     217                'display_name'=>__('Default Attribution', 'leaflet-map'),
     218                'default' => sprintf('<a href="http://leafletjs.com" title="%1$s">Leaflet</a>; \r\n© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> %2$s',
     219                        __("A JS library for interactive maps", 'leaflet-map'),
     220                        __("contributors", 'leaflet-map')
     221                    ),
     222                'type' => 'textarea',
     223                'helptext' => __('Attribution to a custom tile url.  Use semi-colons (;) to separate multiple.', 'leaflet-map')
     224            ),
     225            'geocoder' => array(
     226                'display_name'=>__('Geocoder', 'leaflet-map'),
     227                'default' => 'google',
     228                'type' => 'select',
     229                'options' => array(
     230                    'google' => __('Google Maps', 'leaflet-map'),
     231                    'osm' => __('OpenStreetMap Nominatim', 'leaflet-map'),
     232                    'dawa' => __('Denmark Addresses', 'leaflet-map')
     233                ),
     234                'helptext' => __('Select the Geocoding provider to use to retrieve addresses defined in shortcode.', 'leaflet-map')
     235            )
     236        );
     237
     238        foreach ($this->options as $name => $details) {
    162239            $this->options[ $name ] = new Leaflet_Map_Plugin_Option( $details );
    163240        }
  • leaflet-map/trunk/leaflet-map.php

    r1797863 r1809668  
    66    Author: bozdoz
    77    Author URI: https://twitter.com/bozdoz/
    8     Version: 2.9.1
     8    Text Domain: leaflet-map
     9    Domain Path: /languages/
     10    Version: 2.10.0
    911    License: GPL2
    1012
  • leaflet-map/trunk/readme.txt

    r1797863 r1809668  
    33Author URI: https://www.twitter.com/bozdoz/
    44Plugin URI: https://wordpress.org/plugins/leaflet-map/
    5 Contributors: bozdoz, Remigr, nielsalstrup, jeromelebleu
     5Contributors: bozdoz, Remigr, nielsalstrup, jeromelebleu, gerital
    66Donate link: https://www.paypal.me/bozdoz
    77Tags: leaflet, map, mobile, javascript, openstreetmap, mapquest, interactive
    88Requires at least: 3.0.1
    99Tested up to: 4.9
    10 Version: 2.9.1
    11 Stable tag: 2.9.1
     10Version: 2.10.0
     11Stable tag: 2.10.0
    1212License: GPLv2
    1313License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7878= Can I add geojson? =
    7979
    80 Yes, just give it a source URL: `[leaflet-geojson src="https://example.com/path/to.geojson"]` It will also support leaflet geojson styles or geojson.io styles. Add a popup message with `[leaflet-geojson popup_text="hello!"]`, or add HTML by adding it to the content of the shortcode: `[leaflet-geojson]<a href="#">Link here</a>[/leaflet-geojson]` or identify a geojson property with `popup_property`, and each shape will use its own popup text if available.
     80Yes, just give it a source URL: `[leaflet-geojson src="https://example.com/path/to.geojson"]` It will also support leaflet geojson styles or geojson.io styles. Add a popup message with `[leaflet-geojson popup_text="hello!"]`, or add HTML by adding it to the content of the shortcode: `[leaflet-geojson]<a href="#">Link here, or use text from a feature property, like {title}</a>[/leaflet-geojson]` or identify a geojson property with `popup_property`, and each shape will use its own popup text if available.
    8181
    8282= Can I add kml/gpx? =
     
    121121== Changelog ==
    122122
     123= 2.10.0 =
     124* Added functions for translating text
     125* Added string interpolation for GeoJSON popups to use feature properties (thanks to [@geraldo](https://github.com/geraldo))
     126
    123127= 2.9.1 =
    124128* Fixes for PHP 7.2: made all method arguments identical
  • leaflet-map/trunk/shortcodes/class.geojson-shortcode.php

    r1797863 r1809668  
    107107                function onEachFeature (feature, layer) {
    108108                    var props = feature.properties || {},
    109                         text = popup_property && props[ popup_property ] || popup_text;
     109                        text = popup_property && props[ popup_property ] || template(popup_text, feature.properties);
    110110                    if (text) {
    111111                        layer.bindPopup( text );
    112112                    }
    113                 }         
     113                }
     114                var templateRe = /\{ *([\w_-]+) *\}/g;
     115                function template(str, data) {
     116                    return str.replace(templateRe, function (match, key) {
     117                        var value = data[key];
     118                        if (value === undefined) {
     119                            return match;
     120                        }
     121                        return value;
     122                    });
     123                } 
    114124            });
    115125        </script>
  • leaflet-map/trunk/templates/settings.php

    r1709928 r1809668  
    11<?php
    22$title = $plugin_data['Name'];
    3 $description = $plugin_data['Description'];
     3$description = __('A plugin for creating a Leaflet JS map with a shortcode. Boasts two free map tile services and three free geocoders.', 'leaflet-map');
    44$version = $plugin_data['Version'];
    5 
    6 function option_label ($opt) {
    7     $opt = explode('_', $opt);
    8    
    9     foreach($opt as &$v) {
    10         $v = ucfirst($v);
    11     }
    12     echo implode(' ', $opt);
    13 }
    145?>
    156<div class="wrap">
     
    3324?>
    3425<div class="notice notice-success is-dismissible">
    35     <p>Options Updated!</p>
     26    <p><?php _e('Options Updated!', 'leaflet-map'); ?></p>
    3627</div>
    3728<?php
     
    4031?>
    4132<div class="notice notice-success is-dismissible">
    42     <p>Options have been reset to default values!</p>
     33    <p><?php _e('Options have been reset to default values!', 'leaflet-map'); ?></p>
    4334</div>
    4435<?php
     
    4839?>
    4940<div class="notice notice-success is-dismissible">
    50     <p>Location caches have been cleared!</p>
     41    <p><?php _e('Location caches have been cleared!', 'leaflet-map'); ?></p>
    5142</div>
    5243<?php
     
    5748    <form method="post">
    5849        <div class="container">
    59             <h2>Settings</h2>
     50            <h2><?php _e('Settings', 'leaflet-map'); ?></h2>
    6051            <hr>
    6152        </div>
     
    6657    <div class="container">
    6758        <label>
    68             <span class="label"><?php option_label($name); ?></span>
     59            <span class="label"><?php echo $option->display_name; ?></span>
    6960            <span class="input-group">
    7061            <?php
     
    7869        ?>
    7970        <div class="helptext">
    80             <p class="description"><?php
    81                 echo $option->helptext;
    82             ?></p>
     71            <p class="description"><?php echo $option->helptext; ?></p>
    8372        </div>
    8473        <?php
     
    9079    ?>
    9180    <div class="submit">
    92         <input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
    93         <input type="submit" name="reset" id="reset" class="button button-secondary" value="Reset to Defaults">
     81        <input type="submit"
     82            name="submit"
     83            id="submit"
     84            class="button button-primary"
     85            value="<?php _e('Save Changes', 'leaflet-map'); ?>">
     86        <input type="submit"
     87            name="reset"
     88            id="reset"
     89            class="button button-secondary"
     90            value="<?php _e('Reset to Defaults', 'leaflet-map'); ?>">
    9491        <input type="submit"
    9592            name="clear-geocoder-cache"
    9693            id="clear-geocoder-cache"
    9794            class="button button-secondary"
    98             value="Clear Geocoder Cache">
     95            value="<?php _e('Clear Geocoder Cache', 'leaflet-map'); ?>">
    9996    </div>
    10097
  • leaflet-map/trunk/templates/shortcode-helper.php

    r1720896 r1809668  
    1515    <div class="wrap">
    1616        <?php
     17        $drag = __('Drag Me', 'leaflet-map');
     18
    1719        echo do_shortcode('[leaflet-map zoom=2 zoomcontrol=1 doubleClickZoom=1 height=300 scrollwheel=1]');
    18         echo do_shortcode('[leaflet-marker draggable=1 message="Drag me!" visible="true"]');
     20        echo do_shortcode(sprintf('[leaflet-marker draggable=1 visible="true"] %s [/leaflet-marker]',
     21            $drag
     22        ));
    1923        ?>
    2024        <div class="wrap">
    2125            <hr>
    22             <h2>Interactive Shortcodes:</h2>
    23             <p class="description">Move the map and the marker to generate shortcodes below:</p>
    24             <div class="flex"><label class="h3" for="map-shortcode">Map Shortcode</label> <input type="text" id="map-shortcode" readonly="readonly" /></div>
    25             <div class="flex"><label class="h3" for="marker-shortcode">Marker Shortcode</label> <input type="text" id="marker-shortcode" readonly="readonly" /></div>
     26            <h2><?php _e('Interactive Shortcodes:', 'leaflet-map'); ?></h2>
     27            <p class="description"><?php _e('Move the map and the marker to generate shortcodes below:', 'leaflet-map'); ?></p>
     28            <div class="flex"><label class="h3" for="map-shortcode"><?php _e('Map Shortcode', 'leaflet-map'); ?></label> <input type="text" id="map-shortcode" readonly="readonly" /></div>
     29            <div class="flex"><label class="h3" for="marker-shortcode"><?php _e('Marker Shortcode', 'leaflet-map'); ?></label> <input type="text" id="marker-shortcode" readonly="readonly" /></div>
    2630            <hr>
    27             <h2>Examples:</h2>
     31            <h2><?php _e('Examples', 'leaflet-map'); ?>:</h2>
    2832            <div class="examples">
    2933            <?php
    3034            $examples = array(
    31                 "Standard" => array(
     35                __("Standard", 'leaflet-map') => array(
    3236                    '[leaflet-map zoom=12 lat=51.05 lng=-114.06]',
    3337                    ),
    34                 "Many Markers!" => array(
     38                __("Many Markers!", 'leaflet-map') => array(
    3539                    '[leaflet-map zoom=10 lat=43.65 lng=-79.385]',
    3640                    '[leaflet-marker]',
     
    3842                    '[leaflet-marker lat=43.67 lng=-79.4]',
    3943                    ),
    40                 "Draggable Marker" => array(
     44                __("Draggable Marker", 'leaflet-map') => array(
    4145                    '[leaflet-map zoom=8 lat=-33.85 lng=151.21 scrollwheel=1]',
    4246                    '[leaflet-marker draggable=1]',
    4347                    ),
    44                 "Marker Icon" => array(
     48                __("Marker Icon", 'leaflet-map') => array(
    4549                    '[leaflet-map zoom=10 address="cochrane, Ontario" scrollwheel=1]',
    4650                    '[leaflet-marker iconUrl="https://i.imgur.com/Q54ueuO.png" iconSize="80,50" iconAnchor="40,60"]'
    4751                    ),
    48                 "Zoom Buttons" => array(
     52                __("Zoom Buttons", 'leaflet-map') => array(
    4953                    '[leaflet-map zoom=9 lat=48.855 lng=2.35 zoomcontrol=1]',
    5054                    ),
    51                 "Alternate Map Tiles w/scrollwheel" => array(
     55                __("Alternate Map Tiles w/scrollwheel", 'leaflet-map') => array(
    5256                    '[leaflet-map zoom=2 scrollwheel=1 lat=-2.507 lng=32.902 tileurl=https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg subdomains=abcd attribution="Map tiles by Stamen Design, under CC BY 3.0."]',
    5357                    ),
    54                 "Marker Popup Messages (on click)" => array(
     58                __("Marker Popup Messages (on click)", 'leaflet-map') => array(
    5559                    '[leaflet-map lat=59.913 lng=10.739 zoom=12]',
    5660                    '[leaflet-marker]OSLO![/leaflet-marker]',
    5761                    ),
    58                 "Links In Marker Messages (visible)" => array(
     62                __("Links In Marker Messages (visible)", 'leaflet-map') => array(
    5963                    '[leaflet-map lat=28.41 lng=-81.58 zoom=15]',
    6064                    '[leaflet-marker visible="true"] Disney World! <a href="https://disneyworld.disney.go.com">Link</a> [/leaflet-marker]',
    6165                    ),
    62                 "Basic Lines w/Scrollwheel" => array(
     66                __("Basic Lines w/Scrollwheel", 'leaflet-map') => array(
    6367                    '[leaflet-map lat=41 lng=29 scrollwheel=1 zoom=6]',
    6468                    '[leaflet-line latlngs="41, 29; 44, 18;"]'
    6569                    ),
    66                 "Fitted Colored Line on Addresses" => array(
     70                __("Fitted Colored Line on Addresses", 'leaflet-map') => array(
    6771                    '[leaflet-map]',
    6872                    '[leaflet-line color="purple" addresses="Sayulita; Puerto Vallarta;" fitline=1]'
    6973                    ),
    70                 "More Crazy Line Attributes" => array(
     74                __("More Crazy Line Attributes", 'leaflet-map') => array(
    7175                    '[leaflet-map]',
    72                     '[leaflet-line color="red" weight=10 dasharray="2,15" addresses="Halifax, NS; Tanzania" classname=marching-ants fitbounds=1]CSS makes me march![/leaflet-line]'
     76                    '[leaflet-line color="red" weight=10 dasharray="2,15" addresses="Halifax, NS; Tanzania" classname=marching-ants fitbounds=1]'
    7377                    ),
    74                 "Disable all Interaction" => array(
     78                __("Disable all Interaction", 'leaflet-map') => array(
    7579                    '[leaflet-map address="las vegas" boxZoom=false doubleClickZoom=false dragging=false keyboard=false scrollwheel=0 attribution=0]',
    7680                    ),
    77                 "Add GeoJSON by URL (with popups)" => array(
     81                __("Add GeoJSON by URL (with popups)", 'leaflet-map') => array(
    7882                    '[leaflet-map doubleClickZoom=true scrollwheel=true]',
    7983                    '[leaflet-geojson src=https://cdn.rawgit.com/bozdoz/064a7101b95a324e8852fe9381ab9a18/raw/03f4f54b13a3a7e256732760a8b679818d9d36fc/map.geojson fitbounds=1 popup_property="popup-text"]'
    8084                    ),
    81                 "Test Image Map" => array(
     85                __("Test Image Map", 'leaflet-map') => array(
    8286                    '[leaflet-image zoom=1 zoomcontrol=1 scrollwheelzoom=1 attribution=0]',
    8387                    '[leaflet-marker]'
Note: See TracChangeset for help on using the changeset viewer.