function form($instance)
    {
        $instance = wp_parse_args((array) $instance, $this->w_arg);
        ?>
<p>
	<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title', 'eventorganiser');
        ?>
: </label>
	<input type="text" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" value="<?php 
        echo esc_attr($instance['title']);
        ?>
" />
</p>
  <p>
  <label for="<?php 
        echo $this->get_field_id('numberposts');
        ?>
"><?php 
        _e('Number of events', 'eventorganiser');
        ?>
:   </label>
	  <input id="<?php 
        echo $this->get_field_id('numberposts');
        ?>
" name="<?php 
        echo $this->get_field_name('numberposts');
        ?>
" type="number" size="3" value="<?php 
        echo intval($instance['numberposts']);
        ?>
" />
</p>
  <p>
  <label for="<?php 
        echo $this->get_field_id('event-category');
        ?>
"><?php 
        _e('Event categories', 'eventorganiser');
        ?>
:   </label>
  <input  id="<?php 
        echo $this->get_field_id('event-category');
        ?>
" class="widefat" name="<?php 
        echo $this->get_field_name('event-category');
        ?>
" type="text" value="<?php 
        echo esc_attr($instance['event-category']);
        ?>
" />
   <em><?php 
        _e('List category slug(s), seperate by comma. Leave blank for all', 'eventorganiser');
        ?>
 </em>
</p>
<?php 
        if (taxonomy_exists('event-venue')) {
            ?>
  		<p>
	  		<label for="<?php 
            echo $this->get_field_id('venue');
            ?>
"><?php 
            _e('Venue', 'eventorganiser');
            ?>
:   </label>
			<?php 
            $venues = get_terms('event-venue', array('hide_empty' => false));
            ?>
			<select id="<?php 
            echo $this->get_field_id('venue');
            ?>
" name="<?php 
            echo $this->get_field_name('venue');
            ?>
" type="text">
				<option value="" <?php 
            selected($instance['venue'], '');
            ?>
><?php 
            _e('All Venues', 'eventorganiser');
            ?>
 </option>
				<?php 
            foreach ($venues as $venue) {
                ?>
					<option <?php 
                selected($instance['venue'], $venue->slug);
                ?>
 value="<?php 
                echo esc_attr($venue->slug);
                ?>
"><?php 
                echo esc_html($venue->name);
                ?>
</option>
				<?php 
            }
            ?>
			</select>
		</p>
	<?php 
        }
        ?>
  <p>
  <label for="<?php 
        echo $this->get_field_id('orderby');
        ?>
"><?php 
        _e('Order by', 'eventorganiser');
        ?>
</label>
	<select id="<?php 
        echo $this->get_field_id('orderby');
        ?>
" name="<?php 
        echo $this->get_field_name('orderby');
        ?>
" type="text">
		<option value="eventstart" <?php 
        selected($instance['orderby'], 'eventstart');
        ?>
><?php 
        _e('Start date', 'eventorganiser');
        ?>
</option>
		<option value="title" <?php 
        selected($instance['orderby'], 'title');
        ?>
><?php 
        _e('Title', 'eventorganiser');
        ?>
 </option>
		<option value="date" <?php 
        selected($instance['orderby'], 'date');
        ?>
><?php 
        _e('Publish date', 'eventorganiser');
        ?>
 </option>
	</select>
	<select id="<?php 
        echo $this->get_field_id('order');
        ?>
" name="<?php 
        echo $this->get_field_name('order');
        ?>
" type="text">
		<option value="asc" <?php 
        selected($instance['order'], 'asc');
        ?>
><?php 
        _e('ASC', 'eventorganiser');
        ?>
 </option>
		<option value="desc" <?php 
        selected($instance['order'], 'desc');
        ?>
><?php 
        _e('DESC', 'eventorganiser');
        ?>
 </option>
	</select>
</p>
  <p>
    <label for="<?php 
        echo $this->get_field_id('showpastevents');
        ?>
"><?php 
        _e('Include past events', 'eventorganiser');
        ?>
  </label>
	<input type="checkbox" id="<?php 
        echo $this->get_field_id('showpastevents');
        ?>
" name="<?php 
        echo $this->get_field_name('showpastevents');
        ?>
" <?php 
        checked($instance['showpastevents'], 1);
        ?>
 value="1" />
</p>
  <p>
    <label for="<?php 
        echo $this->get_field_id('group_events_by');
        ?>
"><?php 
        _e('Group occurrences', 'eventorganiser');
        ?>
  </label>
	<input type="checkbox" id="<?php 
        echo $this->get_field_id('group_events_by');
        ?>
" value="series" name="<?php 
        echo $this->get_field_name('group_events_by');
        ?>
" <?php 
        checked($instance['group_events_by'], 'series');
        ?>
 />
  </p>
  <p>
    <label for="<?php 
        echo $this->get_field_id('template');
        ?>
">
	<?php 
        _e('Template (leave blank for default)', 'eventorganiser');
        echo eventorganiser_inline_help(__('Event list widget placeholders', 'eventorganiser'), sprintf(__('You can use specified tags as placeholders for event information which you want to appear in the widget. <a href="%s" target="_blank"> Find out more</a>.', 'eventorganiser'), 'http://docs.wp-event-organiser.com/widgets/events-list'));
        ?>
	</label>
	  <input  id="<?php 
        echo $this->get_field_id('template');
        ?>
" class="widefat" name="<?php 
        echo $this->get_field_name('template');
        ?>
" type="text" value="<?php 
        echo esc_attr($instance['template']);
        ?>
" />

  </p>
  <p>
    <label for="<?php 
        echo $this->get_field_id('no_events');
        ?>
"><?php 
        _e("'No events' message", 'eventorganiser');
        ?>
  </label>
	  <input  id="<?php 
        echo $this->get_field_id('no_events');
        ?>
" class="widefat" name="<?php 
        echo $this->get_field_name('no_events');
        ?>
" type="text" value="<?php 
        echo esc_attr($instance['no_events']);
        ?>
" />
  </p>

<?php 
    }
        public function field_callback()
        {
            $key = get_site_option($this->id . '_license');
            $check = $this->is_valid($key);
            $valid = !is_wp_error($check);
            $message = false;
            if (!$valid) {
                $message = sprintf('The license key you have entered is invalid. <a href="%s">Purchase a license key</a>.', $this->public_url);
                $message .= eventorganiser_inline_help(sprintf('Invalid license key (%s)', $check->get_error_code()), sprintf('<p>%s</p><p> Without a valid license key you will not be eligable for updates or support. You can purchase a
					license key <a href="%s">here</a>.</p> <p> If you have entered a valid license which does not seem to work, please
					<a href="%s">contact suppport</a>.', $this->_get_verbose_reason($check->get_error_code()), $this->public_url, 'http://wp-event-organiser.com/contact/'));
            } elseif (isset($this->key_data) && !empty($this->key_data['expires'])) {
                $now = new DateTime('now');
                $expires = new DateTime($this->key_data['expires']);
                $time_diff = abs($expires->format('U') - $now->format('U'));
                $days = floor($time_diff / 86400);
                if ($days <= 21) {
                    $message = sprintf('This key expires on %s. <a href="%s">Renew within the next %d days</a> for a 50%% discount', $expires->format(get_option('date_format')), 'http://wp-event-organiser.com/my-account', $days);
                }
            }
            eventorganiser_text_field(array('label_for' => $this->id . '_license', 'value' => $key, 'name' => $this->id . '_license', 'style' => $valid ? 'background:#D7FFD7' : 'background:#FFEBE8', 'class' => 'regular-text', 'help' => $message));
        }