PluginProbe
Maps Plugin using Google Maps for WordPress – WP Google Map / 1.4.2
Maps Plugin using Google Maps for WordPress – WP Google Map v1.4.2
1.9.7 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 All 96 releases
gmap-embed / includes / widget.php

widget.php in Maps Plugin using Google Maps for WordPress – WP Google Map 1.4.2, at includes/widget.php

77 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit;
3 /**
4 * Creating widget for Google Map SRM
5 */
6 class srmgmap_widget extends WP_Widget
7 {
8
9 public $base_id = 'srmgmap_widget'; //widget id
10 public $widget_name = 'Google Map SRM'; //widget name
11 public $widget_options = array(
12 'description' => 'Google Map SRM' //widget description
13 );
14
15 public function __construct()
16 {
17 parent::__construct(
18 $this->base_id,
19 $this->widget_name,
20 $this->widget_options
21 );
22
23 add_action( 'widgets_init', function() { register_widget( 'srmgmap_widget' ); });
24 }
25
26 // Map display in front
27 public function widget( $args, $instance )
28 {
29 $title = apply_filters( 'widget_title', $instance['title'] );
30
31 extract( $args );
32 extract( $instance );
33 echo $before_widget;
34 if ( ! empty( $title ) ) {
35 echo $before_title . $title . $after_title;
36 }
37 echo do_shortcode( $instance['srmgmap_shortcode'] );
38 echo $after_widget;
39 }
40
41 /**
42 * Google Map Widget
43 * @return String $instance
44 */
45 public function form( $instance )
46 {
47 $title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( '', 'text_domain' );
48 $text = ! empty( $instance['srmgmap_shortcode'] ) ? $instance['srmgmap_shortcode'] : esc_html__( '', 'text_domain' );
49 ?>
50 <p>
51 <label for="<?php echo $this->get_field_id( 'title' ); ?>">Title: </label>
52 </p>
53 <p>
54 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name('title');?>" type="text" value="<?php echo esc_attr($title); ?>" />
55 </p>
56 <p>
57 <label for="<?php echo $this->get_field_id( 'srmgmap_shortcode' ); ?>"> Enter Google Map Shortcode:</label>
58 </p>
59 <p>
60 <input id="<?php echo $this->get_field_id( 'srmgmap_shortcode' ); ?>"
61 name="<?php echo $this->get_field_name( 'srmgmap_shortcode' ); ?>"
62 value='<?php echo esc_attr( esc_html( isset( $instance['srmgmap_shortcode'] ) ? $instance['srmgmap_shortcode']:'') ); ?>' type="text" class="widefat">
63 </p>
64
65 <?php
66 }
67
68 public function update( $new_instance, $old_instance ) {
69 $instance = array();
70 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
71 $instance['srmgmap_shortcode'] = ( ! empty( $new_instance['srmgmap_shortcode'] ) ) ? $new_instance['srmgmap_shortcode'] : '';
72 return $instance;
73 }
74
75 }
76
77 $srmgmap = new srmgmap_widget();