'air-quality-mk-widget', 'description' => esc_html__('Adds Air Quality widget for MK stations.', 'air-quality-mk') ); parent::__construct( $id, $title, $options ); } // Dispaly widget public function widget( $args, $instace ) { // extract( $args ); //$markup = ''; //if( isset( $instace['markup']) ) { // echo wp_kses_post( $instace['markup'] ); //} $station_id = isset($instace['station_id'])?$instace['station_id']:false; echo $this->do_select_stations($station_id); } // Admin Form public function form( $instace ) { if ( isset( $instace['station_id'] ) && ! empty( $instace['station_id'] ) ) $station_id = $instace['station_id']; else $station_id = false; echo $this->do_select_stations($station_id); } // Save admin form public function update( $new_instance, $old_instance ) { $instace = array(); if( isset( $new_instance['station_id']) && ! empty( $new_instance['station_id']) ) { $instace['station_id'] = $new_instance['station_id']; } return $instace; } private function do_select_stations($station_id){ $id = $this->get_field_id( 'station_id' ); $name = $this->get_field_name( 'station_id' ); $label = esc_html__( 'Station:', 'air-quality-mk' ); $content = ""; $content .= "'; if($station_id) $content .= air_quality_mk_ajax_display_markup($station_id); return $content; } }