'Google Map SRM' //widget description ); public function __construct() { parent::__construct( $this->base_id, $this->widget_name, $this->widget_options ); add_action( 'widgets_init', function() { register_widget( 'srmgmap_widget' ); }); } // Map display in front public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', $instance['title'] ); extract( $args ); extract( $instance ); echo $before_widget; if ( ! empty( $title ) ) { echo $before_title . $title . $after_title; } echo do_shortcode( $instance['srmgmap_shortcode'] ); echo $after_widget; } /** * Google Map Widget * @return String $instance */ public function form( $instance ) { $title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( '', 'text_domain' ); $map_shortcodes_list = ''; $args = array( 'post_type' => 'wpgmapembed', 'posts_per_page' => - 1 ); $mapsList = new WP_Query( $args ); if ( $mapsList->have_posts() ) { while ( $mapsList->have_posts() ) { $mapsList->the_post(); $gmap_title = get_post_meta( get_the_ID(), 'wpgmap_title', true ); if($gmap_title==''){ $gmap_title = 'No title'; } $option_value = esc_attr( '[gmap-embed id="' . get_the_ID() . '"]' ); $selected = ''; if(isset($instance['srmgmap_shortcode']) and $instance['srmgmap_shortcode']==html_entity_decode($option_value)){ $selected = 'selected'; } $map_shortcodes_list .= ''; } } ?>