__('Display a list or calendar grid of events from one or more Google Calendar feeds you have added', GCE_TEXT_DOMAIN))); } function widget($args, $instance){ extract($args); //Output before widget stuff echo $before_widget; //Get saved feed options $options = get_option(GCE_OPTIONS_NAME); //Check whether any feeds have been added yet if(is_array($options) && !empty($options)){ //Output title stuff $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); if(!empty($title)) echo $before_title . $title . $after_title; //Break comma delimited list of feed ids into array $feed_ids = explode(',', str_replace(' ', '', $instance['id'])); //Check each id is an integer, if not, remove it from the array foreach($feed_ids as $key => $feed_id){ if(absint($feed_id) == 0) unset($feed_ids[$key]); } $no_feeds_exist = true; //If at least one of the feed ids entered exists, set no_feeds_exist to false foreach($feed_ids as $feed_id){ if(isset($options[$feed_id])) $no_feeds_exist = false; } //Check that at least one valid feed id has been entered if(count((array)$feed_ids) == 0 || $no_feeds_exist){ _e('No valid Feed IDs have been entered for this widget. Please check that you have entered the IDs correctly and that the Feeds have not been deleted.', GCE_TEXT_DOMAIN); }else{ //Turns feed_ids back into string or feed ids delimited by '-' ('1-2-3-4' for example) $feed_ids = implode('-', $feed_ids); $title_text = $instance['display_title'] ? $instance['display_title_text'] : null; $max_events = $instance['max_events']; //Output correct widget content based on display type chosen switch($instance['display_type']){ case 'grid': echo '
'; break; case 'ajax': echo ''; break; case 'list': echo ''; break; case 'list-grouped': echo ''; break; } } }else{ _e('No feeds have been added yet. You can add a feed in the Google Calendar Events settings.', GCE_TEXT_DOMAIN); } //Output after widget stuff echo $after_widget; } function update($new_instance, $old_instance){ $instance = $old_instance; $instance['title'] = esc_html($new_instance['title']); $instance['id'] = esc_html($new_instance['id']); $instance['display_type'] = esc_html($new_instance['display_type']); $instance['max_events'] = absint($new_instance['max_events']); $instance['display_title'] = $new_instance['display_title'] == 'on' ? true : false; $instance['display_title_text'] = wp_filter_kses($new_instance['display_title_text']); return $instance; } function form($instance){ //Get saved feed options $options = get_option(GCE_OPTIONS_NAME); if(empty($options)){ //If no feeds or groups ?>
value="on" />