PluginProbe
WP MapIt / 1.2
WP MapIt v1.2
3.1.1 trunk 1.0 1.1 1.2 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.7.1 3.0 3.1.0
wp-mapit / wp_mapit / classes / class.wp_mapit_contextual_map_widget.php

class.wp_mapit_contextual_map_widget.php in WP MapIt 1.2, at wp_mapit/classes/class.wp_mapit_contextual_map_widget.php

82 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if( ! class_exists( 'wp_mapit_contextual_map_widget' ) ) {
4 /**
5 * Class to create a widget to display the map from the current page, post or custom post type
6 */
7 class wp_mapit_contextual_map_widget extends WP_Widget
8 {
9 /**
10 * Constructor of the class, called when the object is initiated.
11 *
12 * @since 1.0
13 * @access public
14 */
15 function __construct()
16 {
17 /* Call the parent constructor */
18 parent::__construct( 'wp_mapit_contextual_map_widget', __( 'WP MAPIT', WP_MAPIT_TEXTDOMAIN ), array( 'description' => __( 'Show map for the current page, post or custom post types.', WP_MAPIT_TEXTDOMAIN ) ) );
19 }
20
21 /**
22 * Function to display the widget on the frontend.
23 *
24 * @since 1.0
25 * @access public
26 * @static
27 * @param $args Array Arguments of the widget
28 * @param $instance Array Instance of the widget
29 */
30 public function widget( $args, $instance ) {
31 $title = apply_filters( 'widget_title', ( isset( $instance['title'] ) ? $instance['title'] : '' ) );
32
33 echo ( isset( $args['before_widget'] ) ? $args['before_widget'] : '' );
34
35 if( ! empty( $title ) ) {
36 echo ( isset( $args['before_title'] ) ? $args['before_title'] : '' ) . $title . ( isset( $args['after_title'] ) ? $args['after_title'] : '' );
37 }
38
39 echo do_shortcode( '[wp_mapit]' );
40
41 echo ( isset( $args['after_widget'] ) ? $args['after_widget'] : '' );
42 }
43
44 /**
45 * Function to display form in the admin panel widget area
46 *
47 * @since 1.0
48 * @access public
49 * @static
50 * @param $instance Array Instance of the widget
51 */
52 public function form( $instance ) {
53 $title = ( isset( $instance['title'] ) ? $instance['title'] : '' );
54
55 $titleId = $this->get_field_id( 'title' );
56 ?>
57 <p>
58 <label for="<?php echo $titleId; ?>"></label>
59 <input class="widefat" type="text" name="<?php echo $this->get_field_name( 'title' ); ?>" id="<?php echo $titleId; ?>" value="<?php echo esc_attr( $title ); ?>" placeholder="<?php _e( 'Enter a title', WP_MAPIT_TEXTDOMAIN ); ?>">
60 </p>
61 <?php
62 }
63
64 /**
65 * Function to save widget fields from admin panel widget area.
66 *
67 * @since 1.0
68 * @access public
69 * @static
70 * @param $new_instance Array New instance of the widget
71 * @param $old_instance Array Old instance of the widget
72 * @return Array Instance of the widget
73 */
74 public function update( $new_instance, $old_instance ) {
75 $instance = array();
76
77 $instance['title'] = ( isset( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '' );
78
79 return $instance;
80 }
81 }
82 }