Changeset 2464298
- Timestamp:
- 01/28/2021 01:45:00 PM (5 years ago)
- Location:
- leaflet-map-widget/trunk
- Files:
-
- 2 edited
-
leaflet-map-widget.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
leaflet-map-widget/trunk/leaflet-map-widget.php
r1750361 r2464298 2 2 /* 3 3 Plugin Name: Leaflet Map Widget 4 Plugin URI: http ://www.wp-plugin-dev.com4 Plugin URI: https://emojized.com 5 5 Description: An extra widget for Leaflet Map and it depends on it. 6 Author: WP-Plugin-Dev.com7 Version: 0. 18 Author URI: http ://www.wp-plugin-dev.com6 Author: emojized 7 Version: 0.2 8 Author URI: https://emojized.com 9 9 License: GPL2 10 10 Text Domain: leafletmapwidget … … 18 18 GNU General Public License for more details. 19 19 20 */20 */ 21 21 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 35 function register_LeafletMap_widget() 36 { 37 register_widget('LeafletMapwidget'); 24 38 } 25 add_action( 'widgets_init', 'register_LeafletMap_widget' ); 26 39 add_action('widgets_init', 'register_LeafletMap_widget'); 27 40 28 41 add_action('init', 'leafletmapwidget_init'); 29 function leafletmapwidget_init() { 42 function leafletmapwidget_init() 43 { 30 44 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 } 34 48 35 49 /** 36 50 * Adds LeafletMapWidget widget. 37 51 */ 38 class LeafletMapWidget extends WP_Widget { 52 class LeafletMapWidget extends WP_Widget 53 { 39 54 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 } 50 67 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 } 51 75 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]'); 57 77 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 } 59 80 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'); 62 87 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 ?> 71 89 <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); ?>"> 74 92 </p> 75 93 76 94 <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); ?>"> 79 97 </p> 80 98 <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); ?>"> 83 101 </p> 84 102 85 103 <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); ?>"> 88 106 </p> 89 107 90 108 91 109 92 <?php 93 }110 <?php 111 } 94 112 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']) : ''; 101 120 102 return $instance;103 }121 return $instance; 122 } 104 123 105 124 } // class LeafletMapWidget 106 125 107 126 108 ?> 127 128 ?> -
leaflet-map-widget/trunk/readme.txt
r1750361 r2464298 4 4 Tags: leaflet, map, widget 5 5 Requires at least: 3.0.1 6 Tested up to: 4.8.26 Tested up to: 5.7 7 7 Stable tag: trunk 8 8 License: GPLv2 or later … … 33 33 == Changelog == 34 34 35 = 0.2 = for the future 35 36 = 0.1 = 36 37 * Initial release.
Note: See TracChangeset
for help on using the changeset viewer.