Plugin Directory

Changeset 2464298


Ignore:
Timestamp:
01/28/2021 01:45:00 PM (5 years ago)
Author:
theode
Message:

for the future

Location:
leaflet-map-widget/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • leaflet-map-widget/trunk/leaflet-map-widget.php

    r1750361 r2464298  
    22/*
    33Plugin Name: Leaflet Map Widget
    4 Plugin URI: http://www.wp-plugin-dev.com
     4Plugin URI: https://emojized.com
    55Description: An extra widget for Leaflet Map and it depends on it.
    6 Author: WP-Plugin-Dev.com
    7 Version: 0.1
    8 Author URI: http://www.wp-plugin-dev.com
     6Author: emojized
     7Version: 0.2
     8Author URI: https://emojized.com
    99License: GPL2
    1010Text Domain: leafletmapwidget
     
    1818GNU General Public License for more details.
    1919
    20  */
     20*/
    2121
    22 function register_LeafletMap_widget() {
    23     register_widget( 'LeafletMapwidget' );
     22/**
     23* Class and Function List:
     24* Function list:
     25* - register_LeafletMap_widget()
     26* - leafletmapwidget_init()
     27* - __construct()
     28* - widget()
     29* - form()
     30* - update()
     31* Classes list:
     32* - LeafletMapWidget extends WP_Widget
     33*/
     34
     35function register_LeafletMap_widget()
     36{
     37    register_widget('LeafletMapwidget');
    2438}
    25 add_action( 'widgets_init', 'register_LeafletMap_widget' );
    26 
     39add_action('widgets_init', 'register_LeafletMap_widget');
    2740
    2841add_action('init', 'leafletmapwidget_init');
    29 function leafletmapwidget_init() {
     42function leafletmapwidget_init()
     43{
    3044
    31     $path = dirname(plugin_basename( __FILE__ )) . '/languages/';
    32     $loaded = load_plugin_textdomain( 'leafletmapwidget', false, $path);
    33 } 
     45    $path   = dirname(plugin_basename(__FILE__)) . '/languages/';
     46    $loaded = load_plugin_textdomain('leafletmapwidget', false, $path);
     47}
    3448
    3549/**
    3650 * Adds LeafletMapWidget widget.
    3751 */
    38 class LeafletMapWidget extends WP_Widget {
     52class LeafletMapWidget extends WP_Widget
     53{
    3954
    40     /**
    41      * Register widget with WordPress.
    42      */
    43     function __construct() {
    44         parent::__construct(
    45             'LeafletMapwidget', // Base ID
    46             __( 'LeafletMap Widget', 'leafletmap' ), // Name
    47             array( 'description' => __( 'A LeafletMap Widget - use this as the solution, that Google needs an API Key for showing their maps.', 'leafletmap' ), ) // Args
    48         );
    49     }
     55    /**
     56     * Register widget with WordPress.
     57     */
     58    function __construct()
     59    {
     60        parent::__construct('LeafletMapwidget', // Base ID
     61        __('LeafletMap Widget', 'leafletmap') , // Name
     62        array(
     63            'description' => __('A LeafletMap Widget - use this as the solution, that Google needs an API Key for showing their maps.', 'leafletmap') ,
     64        ) // Args
     65        );
     66    }
    5067
     68    public function widget($args, $instance)
     69    {
     70        echo $args['before_widget'];
     71        if (!empty($instance['title']))
     72        {
     73            echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
     74        }
    5175
    52     public function widget( $args, $instance ) {
    53         echo $args['before_widget'];
    54         if ( ! empty( $instance['title'] ) ) {
    55             echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
    56         }
     76        echo do_shortcode('[leaflet-map address="' . $instance['address'] . ',' . $instance['postcode_town'] . '" zoom=' . $instance['zoomlevel'] . ' scrollwheel=1][leaflet-marker]');
    5777
    58             echo do_shortcode('[leaflet-map address="'.$instance['address'].','.$instance['postcode_town'].'" zoom='.$instance['zoomlevel'].' scrollwheel=1][leaflet-marker]');
     78        echo $args['after_widget'];
     79    }
    5980
    60         echo $args['after_widget'];
    61     }
     81    public function form($instance)
     82    {
     83        $title         = !empty($instance['title']) ? $instance['title'] : __('New title', 'leafletmapwidget');
     84        $adresse       = !empty($instance['address']) ? $instance['address'] : __('address', 'leafletmapwidget');
     85        $postcode_town = !empty($instance['postcode_town']) ? $instance['postcode_town'] : __('postcode_town', 'leafletmapwidget');
     86        $zoomlevel     = !empty($instance['zoomlevel']) ? $instance['zoomlevel'] : __('17', 'leafletmapwidget');
    6287
    63 
    64     public function form( $instance ) {
    65         $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'New title', 'leafletmapwidget' );
    66         $adresse = ! empty( $instance['address'] ) ? $instance['address'] : __( 'address', 'leafletmapwidget' );
    67         $postcode_town = ! empty( $instance['postcode_town'] ) ? $instance['postcode_town'] : __( 'postcode_town', 'leafletmapwidget' );
    68         $zoomlevel = ! empty( $instance['zoomlevel'] ) ? $instance['zoomlevel'] : __( '17', 'leafletmapwidget' );
    69 
    70         ?>
     88?>
    7189        <p>
    72         <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( esc_attr( 'Title:' ) ); ?></label>
    73         <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
     90        <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e(esc_attr('Title:')); ?></label>
     91        <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>">
    7492        </p>
    7593
    7694        <p>
    77             <label for="adresse" ><?php _e('Address','leafletmapwidget'); ?>:</label><br>
    78             <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'address' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'address' ) ); ?>" type="text" value="<?php echo esc_attr( $adresse ); ?>">
     95            <label for="adresse" ><?php _e('Address', 'leafletmapwidget'); ?>:</label><br>
     96            <input class="widefat" id="<?php echo esc_attr($this->get_field_id('address')); ?>" name="<?php echo esc_attr($this->get_field_name('address')); ?>" type="text" value="<?php echo esc_attr($adresse); ?>">
    7997        </p>
    8098        <p>
    81             <label for="postcode_town" ><?php _e('Postcode Town, Country','leafletmapwidget'); ?>:</label><br>
    82             <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'postcode_town' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'postcode_town' ) ); ?>" type="text" value="<?php echo esc_attr( $postcode_town ); ?>">
     99            <label for="postcode_town" ><?php _e('Postcode Town, Country', 'leafletmapwidget'); ?>:</label><br>
     100            <input class="widefat" id="<?php echo esc_attr($this->get_field_id('postcode_town')); ?>" name="<?php echo esc_attr($this->get_field_name('postcode_town')); ?>" type="text" value="<?php echo esc_attr($postcode_town); ?>">
    83101        </p>
    84102
    85103        <p>
    86             <label for="zoomlevel" ><?php _e('Zoomlevel (1 = World , 18 very detailed)','leafletmapwidget'); ?>:</label><br>
    87             <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'zoomlevel' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'zoomlevel' ) ); ?>" type="number" min=1 max=18 value="<?php echo esc_attr( $zoomlevel ); ?>">
     104            <label for="zoomlevel" ><?php _e('Zoomlevel (1 = World , 18 very detailed)', 'leafletmapwidget'); ?>:</label><br>
     105            <input class="widefat" id="<?php echo esc_attr($this->get_field_id('zoomlevel')); ?>" name="<?php echo esc_attr($this->get_field_name('zoomlevel')); ?>" type="number" min=1 max=18 value="<?php echo esc_attr($zoomlevel); ?>">
    88106        </p>
    89107
    90108
    91109
    92         <?php 
    93     }
     110        <?php
     111    }
    94112
    95     public function update( $new_instance, $old_instance ) {
    96         $instance = array();
    97         $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
    98         $instance['postcode_town'] = ( ! empty( $new_instance['postcode_town'] ) ) ? strip_tags( $new_instance['postcode_town'] ) : '';
    99         $instance['address'] = ( ! empty( $new_instance['address'] ) ) ? strip_tags( $new_instance['address'] ) : '';
    100         $instance['zoomlevel'] = ( ! empty( $new_instance['zoomlevel'] ) ) ? strip_tags( $new_instance['zoomlevel'] ) : '';
     113    public function update($new_instance, $old_instance)
     114    {
     115        $instance = array();
     116        $instance['title']          = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : '';
     117        $instance['postcode_town']          = (!empty($new_instance['postcode_town'])) ? strip_tags($new_instance['postcode_town']) : '';
     118        $instance['address']          = (!empty($new_instance['address'])) ? strip_tags($new_instance['address']) : '';
     119        $instance['zoomlevel']          = (!empty($new_instance['zoomlevel'])) ? strip_tags($new_instance['zoomlevel']) : '';
    101120
    102         return $instance;
    103     }
     121        return $instance;
     122    }
    104123
    105124} // class LeafletMapWidget
    106125
    107126
    108  ?>
     127
     128?>
  • leaflet-map-widget/trunk/readme.txt

    r1750361 r2464298  
    44Tags: leaflet, map, widget
    55Requires at least: 3.0.1
    6 Tested up to: 4.8.2
     6Tested up to: 5.7
    77Stable tag: trunk
    88License: GPLv2 or later
     
    3333== Changelog ==
    3434
     35= 0.2 = for the future
    3536= 0.1 =
    3637* Initial release.
Note: See TracChangeset for help on using the changeset viewer.