Plugin Directory

Changeset 1936759


Ignore:
Timestamp:
09/06/2018 10:07:29 AM (7 years ago)
Author:
andrekelling
Message:

add customisation possiblity of maps style v1.4.0

Location:
mapple
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • mapple/trunk/admin/class-mapple-admin.php

    r1933348 r1936759  
    202202
    203203    /**
     204     * Creates a textarea field
     205     *
     206     * @param   array       $args           The arguments for the field
     207     * @return  string                      The HTML field
     208     */
     209    public function field_textarea( $args ) {
     210
     211        $defaults['class']          = 'widefat';
     212        $defaults['description']    = '';
     213        $defaults['label']          = '';
     214        $defaults['name']           = $this->plugin_name . '-options[' . $args['id'] . ']';
     215        $defaults['placeholder']    = '';
     216        $defaults['value']          = '';
     217        $defaults['rows']           = 6;
     218
     219        apply_filters( $this->plugin_name . '-field-text-options-defaults', $defaults );
     220
     221        $atts = wp_parse_args( $args, $defaults );
     222
     223        if ( ! empty( $this->options[$atts['id']] ) ) {
     224
     225            $atts['value'] = $this->options[$atts['id']];
     226
     227        }
     228
     229        include( plugin_dir_path( __FILE__ ) . 'partials/' . $this->plugin_name . '-admin-field-textarea.php' );
     230
     231    } // field_textarea()
     232
     233    /**
    204234     * Returns an array of options names, fields types, and default values
    205235     *
     
    211241
    212242        $options[] = array( 'gmap-api-key', 'text', '' );
     243        $options[] = array( 'gmap-style-json', 'text', '' );
    213244
    214245        return $options;
     
    230261            $this->plugin_name . '-api',
    231262            array(
    232                 'description'   => 'Enter your key and save.',
     263                'description'   => esc_html__( 'Enter your key and save.', 'mapple' ),
    233264                'id'            => 'gmap-api-key',
    234265                'placeholder'   => 'tHiSwIlLbEyOuRkEyToGoOgLeMaPsApI'
     266            )
     267        );
     268
     269        add_settings_field(
     270            'gmap-style-json',
     271            apply_filters( $this->plugin_name . 'label-gmap-style-json', esc_html__( 'Google Maps Style JSON', 'mapple' ) ),
     272            array( $this, 'field_textarea' ),
     273            $this->plugin_name,
     274            $this->plugin_name . '-api',
     275            array(
     276                'description'   => esc_html__( 'There is a nice tool https://mapstyle.withgoogle.com/ to create the JSON.', 'mapple' ),
     277                'id'            => 'gmap-style-json',
     278                'placeholder'   => esc_html__( 'put your JSON code inside here', 'mapple' ),
     279                'rows'          => 24,
    235280            )
    236281        );
  • mapple/trunk/admin/partials/mapple-admin-page-settings.php

    r1933348 r1936759  
    3636</ul>
    3737<p><?php echo __( 'There are a few possible attributes you can provide to your `mapple_clients` shortcode. Here a full example with all possible options:', 'mapple' ); ?></p>
    38 <code>[mapple_clients title-name="Name" title-address="Adresse" title-desc="Beschreibung" title-tags="Branche" title-search="Suche" title-search-placeholder="lostippen..." with-tags="true" with-search="true"]</code>
     38<code>[mapple_clients title-name="Name" title-address="Adresse" title-desc="Beschreibung" title-tags="Branche" title-search="Suche" title-search-placeholder="lostippen..." title-filter-label="Nach Branche filtern" with-tags="true" with-search="true"]</code>
    3939<p><?php echo __( 'all `title-` attributes are for customising words', 'mapple' ); ?></p>
    4040<p><?php echo __( 'all `with-` attributes activate the tags coloumn, and filter when search is also active', 'mapple' ); ?></p>
  • mapple/trunk/admin/partials/mapple-admin-settings-section-api.php

    r1860209 r1936759  
    1313 */
    1414
    15 ?><p></p>
     15// nothing to add here
  • mapple/trunk/mapple.php

    r1935166 r1936759  
    1717 * Plugin URI:        https://andrekelling.de/
    1818 * Description:       To show a google map with the locations of your clients. You can output additionally a sorted listing table of all your clients. Just with shortcodes.
    19  * Version:           1.3.0
     19 * Version:           1.4.0
    2020 * Author:            André Kelling
    2121 * Author URI:        https://andrekelling.de/about
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'MAPPLE_VERSION', '1.3.0' );
     38define( 'MAPPLE_VERSION', '1.4.0' );
    3939
    4040/**
  • mapple/trunk/public/class-mapple-public.php

    r1933696 r1936759  
    9999        wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/mapple-public.js', array($this->plugin_name.'gmaps'), $this->version, true );
    100100
    101         $dataToBePassed = array(
    102             'home'            => get_stylesheet_directory_uri(),
    103             'pleaseWaitLabel' => __( 'Please wait...', 'default' )
    104         );
    105         wp_localize_script( $this->plugin_name, 'php_vars', $dataToBePassed );
    106 
    107 
    108101        $options    = get_option( $this->plugin_name . '-options' );
    109102        $apiKey     = $options['gmap-api-key'];
     103        $styleJSON  = $options['gmap-style-json'];
    110104
    111105        if(! empty($apiKey)){
    112106            wp_enqueue_script($this->plugin_name.'gmaps' , 'https://maps.googleapis.com/maps/api/js?key='.$apiKey, '', $this->version, true );
     107
     108            if(! empty($styleJSON)){
     109                $dataToBePassed = array(
     110                    'styleJSON'            => json_decode($styleJSON)
     111                );
     112                wp_localize_script( $this->plugin_name, 'mapple_vars', $dataToBePassed );
     113            }
    113114        }
    114 
    115 
    116115    }
    117116
  • mapple/trunk/public/js/mapple-public.js

    r1935166 r1936759  
    44
    55    const plugin = {};
    6 
     6   
    77    const settings = {
    88        bounds: new google.maps.LatLngBounds(),
    99        infowindow: new google.maps.InfoWindow(),
     10        mapStyle: (typeof(mapple_vars) !== 'undefined') ? mapple_vars.styleJSON : '',
    1011        tableSelector: document.querySelectorAll('.mapple__table')[0],
    1112        tableTagsSelectorClass: 'mapple__tags',
     
    3536            mapTypeControl: false,
    3637            zoomControl: true,
    37             panControl: true
     38            panControl: true,
     39            styles: settings.mapStyle
    3840        };
    3941
  • mapple/trunk/readme.txt

    r1935166 r1936759  
    55Requires at least: 4.7
    66Tested up to: 4.9.5
    7 Stable tag: 1.3.0
     7Stable tag: 1.4.0
    88Requires PHP: 7.0
    99License: GPLv3.0 or later
     
    1919This Plugin does not need jQuery!
    2020
    21 The google map is centered shown to all markers added. Markers got little Infowindows with client's name, website and address
     21The google map is centered shown to all markers added. Markers got little Infowindows with client's name, website and address.
     22Map Style customisation is possible.
    2223
    2324A few notes about technical things:
     
    5253
    53541. Output of Map and Table on the Front End. In between some text. You can place your shortcodes around.
    54 2. New custom clients Post Type with address autocompletion
    55 3. Enable search and filter section for clients in the table
     552. custom styled Map with open infowindow
     563. New custom clients Post Type with address autocompletion
     574. Enable search and filter section for clients in the table
    5658
    5759== Changelog ==
     60
     61= 1.4.0 =
     62* enable google maps style customisation
     63* remove unused `php_vars` from wp_localize_script
    5864
    5965= 1.3.0 =
Note: See TracChangeset for help on using the changeset viewer.