Simple Calendar – Google Calendar Plugin - Version 0.1.3

Version Description

  • Several bug fixes, including fixing JavaScript problems that prevented tooltips appearing.
Download this release

Release Info

Developer rosshanney
Plugin Icon 128x128 Simple Calendar – Google Calendar Plugin
Version 0.1.3
Comparing to
See all releases

Code changes from version 0.1.1 to 0.1.3

admin/add.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
  //Redirect to the main plugin options page if form has been submitted
3
- if($_GET['action'] == 'add' && $_GET['updated']){
4
- wp_redirect(admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=added');
 
 
5
  }
6
 
7
  //Main text
1
  <?php
2
  //Redirect to the main plugin options page if form has been submitted
3
+ if(isset($_GET['action'])){
4
+ if($_GET['action'] == 'add' && isset($_GET['updated'])){
5
+ wp_redirect(admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=added');
6
+ }
7
  }
8
 
9
  //Main text
admin/delete.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
  //Redirect to the main plugin options page if form has been submitted
3
- if($_GET['action'] == 'delete' && $_GET['updated']){
4
- wp_redirect(admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=deleted');
 
 
5
  }
6
 
7
  //Main text
1
  <?php
2
  //Redirect to the main plugin options page if form has been submitted
3
+ if(isset($_GET['action'])){
4
+ if($_GET['action'] == 'delete' && isset($_GET['updated'])){
5
+ wp_redirect(admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=deleted');
6
+ }
7
  }
8
 
9
  //Main text
admin/edit.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
  //Redirect to the main plugin options page if form has been submitted
3
- if($_GET['action'] == 'edit' && $_GET['updated']){
4
- wp_redirect(admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=edited');
 
 
5
  }
6
 
7
  //Main text
1
  <?php
2
  //Redirect to the main plugin options page if form has been submitted
3
+ if(isset($_GET['action'])){
4
+ if($_GET['action'] == 'edit' && isset($_GET['updated'])){
5
+ wp_redirect(admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=edited');
6
+ }
7
  }
8
 
9
  //Main text
css/gce-style.css CHANGED
@@ -39,7 +39,7 @@
39
  }
40
 
41
  .gce-page-grid .gce-calendar .gce-today{ /* Table cell that represents today */
42
- background-color:#EEEEEE;
43
  }
44
 
45
  .gce-page-grid .gce-calendar .gce-next,
39
  }
40
 
41
  .gce-page-grid .gce-calendar .gce-today{ /* Table cell that represents today */
42
+ background-color:#DDDDDD;
43
  }
44
 
45
  .gce-page-grid .gce-calendar .gce-next,
google-calendar-events.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Google Calendar Events
4
  Plugin URI: http://www.rhanney.co.uk/plugins/google-calendar-events
5
  Description: Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
6
- Version: 0.1
7
  Author: Ross Hanney
8
  Author URI: http://www.rhanney.co.uk
9
  License: GPL2
@@ -43,7 +43,7 @@ if(!class_exists('Google_Calendar_Events')){
43
 
44
  //PHP 5 constructor
45
  function __construct(){
46
- //add_action('activate_google-calendar-events/google-calendar-events.php', array($this, 'get_options'));
47
  add_action('admin_menu', array($this, 'setup_admin'));
48
  add_action('admin_init', array($this, 'init_admin'));
49
 
@@ -55,25 +55,31 @@ if(!class_exists('Google_Calendar_Events')){
55
  add_action('wp_print_scripts', array($this, 'add_scripts'));
56
  }
57
 
 
 
 
 
58
  //Setup admin settings page
59
  function setup_admin(){
60
- if(function_exists('add_options_page')) add_options_page('Google Calendar Events', 'Google Calendar Events', 9, basename(__FILE__), array($this, 'admin_page'));
61
- add_option(GCE_OPTIONS_NAME);
62
  }
63
 
64
  //Prints admin settings page
65
  function admin_page(){
66
  //Add correct updated message (added / edited / deleted)
67
- switch($_GET['updated']){
68
- case 'added':
69
- ?><div class="updated"><p><strong>New Feed Added Successfully.</strong></p></div><?php
70
- break;
71
- case 'edited':
72
- ?><div class="updated"><p><strong>Feed Details Updated Successfully.</strong></p></div><?php
73
- break;
74
- case 'deleted':
75
- ?><div class="updated"><p><strong>Feed Deleted Successfully.</strong></p></div><?php
76
- break;
 
 
77
  }?>
78
 
79
  <div class="wrap">
@@ -84,29 +90,31 @@ if(!class_exists('Google_Calendar_Events')){
84
  <?php
85
  settings_fields('gce_options_group');
86
 
87
- switch($_GET['action']){
88
- //Add feed section
89
- case 'add':
90
- do_settings_sections('add_feed');
91
- ?><p class="submit"><input type="submit" class="button-primary submit" value="<?php esc_attr_e('Add Feed', GCE_TEXT_DOMAIN); ?>" /></p>
92
- <p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary">Cancel</a></p><?php
93
- break;
94
- //Edit feed section
95
- case 'edit':
96
- do_settings_sections('edit_feed');
97
- ?><p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes', GCE_TEXT_DOMAIN); ?>" /></p>
98
- <p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary">Cancel</a></p><?php
99
- break;
100
- //Delete feed section
101
- case 'delete':
102
- do_settings_sections('delete_feed');
103
- ?><p class="submit"><input type="submit" class="button-primary" name="gce_options[submit_delete]" value="<?php esc_attr_e('Delete Feed', GCE_TEXT_DOMAIN); ?>" /></p>
104
- <p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary">Cancel</a></p><?php
105
- break;
 
 
 
106
  //Main admin section
107
- default:
108
- settings_fields('gce_stylesheet');
109
- require_once 'admin/main.php';
110
  }
111
  ?>
112
  </form>
@@ -202,21 +210,28 @@ if(!class_exists('Google_Calendar_Events')){
202
 
203
  //Handles the shortcode stuff
204
  function shortcode_handler($atts){
205
- extract(shortcode_atts(array(
206
- 'id' => '1',
207
- 'type' => 'grid'
208
- ), $atts));
209
-
210
- switch($type){
211
- case 'grid':
212
- return gce_print_grid($id);
213
- break;
214
- case 'ajax':
215
- return gce_print_grid($id, true);
216
- break;
217
- case 'list':
218
- return gce_print_list($id);
219
- break;
 
 
 
 
 
 
 
220
  }
221
  }
222
 
@@ -318,7 +333,7 @@ function gce_handle_ajax($feed_id, $month = null, $year = null){
318
  echo gce_print_grid($feed_id, true, $month, $year);
319
  }
320
 
321
- if($_GET['gce_type'] == 'page'){
322
  if(isset($_GET['gce_feed_id'])){
323
  gce_handle_ajax($_GET['gce_feed_id'], $_GET['gce_month'], $_GET['gce_year']);
324
  die();
3
  Plugin Name: Google Calendar Events
4
  Plugin URI: http://www.rhanney.co.uk/plugins/google-calendar-events
5
  Description: Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
6
+ Version: 0.1.3
7
  Author: Ross Hanney
8
  Author URI: http://www.rhanney.co.uk
9
  License: GPL2
43
 
44
  //PHP 5 constructor
45
  function __construct(){
46
+ add_action('activate_google-calendar-events/google-calendar-events.php', array($this, 'init_plugin'));
47
  add_action('admin_menu', array($this, 'setup_admin'));
48
  add_action('admin_init', array($this, 'init_admin'));
49
 
55
  add_action('wp_print_scripts', array($this, 'add_scripts'));
56
  }
57
 
58
+ function init_plugin(){
59
+ add_option(GCE_OPTIONS_NAME);
60
+ }
61
+
62
  //Setup admin settings page
63
  function setup_admin(){
64
+ if(function_exists('add_options_page')) add_options_page('Google Calendar Events', 'Google Calendar Events', 'manage_options', basename(__FILE__), array($this, 'admin_page'));
65
+
66
  }
67
 
68
  //Prints admin settings page
69
  function admin_page(){
70
  //Add correct updated message (added / edited / deleted)
71
+ if(isset($_GET['updated'])){
72
+ switch($_GET['updated']){
73
+ case 'added':
74
+ ?><div class="updated"><p><strong>New Feed Added Successfully.</strong></p></div><?php
75
+ break;
76
+ case 'edited':
77
+ ?><div class="updated"><p><strong>Feed Details Updated Successfully.</strong></p></div><?php
78
+ break;
79
+ case 'deleted':
80
+ ?><div class="updated"><p><strong>Feed Deleted Successfully.</strong></p></div><?php
81
+ break;
82
+ }
83
  }?>
84
 
85
  <div class="wrap">
90
  <?php
91
  settings_fields('gce_options_group');
92
 
93
+ if(isset($_GET['action'])){
94
+ switch($_GET['action']){
95
+ //Add feed section
96
+ case 'add':
97
+ do_settings_sections('add_feed');
98
+ ?><p class="submit"><input type="submit" class="button-primary submit" value="<?php esc_attr_e('Add Feed', GCE_TEXT_DOMAIN); ?>" /></p>
99
+ <p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary">Cancel</a></p><?php
100
+ break;
101
+ //Edit feed section
102
+ case 'edit':
103
+ do_settings_sections('edit_feed');
104
+ ?><p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes', GCE_TEXT_DOMAIN); ?>" /></p>
105
+ <p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary">Cancel</a></p><?php
106
+ break;
107
+ //Delete feed section
108
+ case 'delete':
109
+ do_settings_sections('delete_feed');
110
+ ?><p class="submit"><input type="submit" class="button-primary" name="gce_options[submit_delete]" value="<?php esc_attr_e('Delete Feed', GCE_TEXT_DOMAIN); ?>" /></p>
111
+ <p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary">Cancel</a></p><?php
112
+ break;
113
+ }
114
+ }else{
115
  //Main admin section
116
+ settings_fields('gce_stylesheet');
117
+ require_once 'admin/main.php';
 
118
  }
119
  ?>
120
  </form>
210
 
211
  //Handles the shortcode stuff
212
  function shortcode_handler($atts){
213
+ $options = get_option(GCE_OPTIONS_NAME);
214
+
215
+ //Check that any feeds have been added
216
+ if(is_array($options) && !empty($options)){
217
+ extract(shortcode_atts(array(
218
+ 'id' => '1',
219
+ 'type' => 'grid'
220
+ ), $atts));
221
+
222
+ switch($type){
223
+ case 'grid':
224
+ return gce_print_grid($id);
225
+ break;
226
+ case 'ajax':
227
+ return gce_print_grid($id, true);
228
+ break;
229
+ case 'list':
230
+ return gce_print_list($id);
231
+ break;
232
+ }
233
+ }else{
234
+ return 'No feeds have been added yet. You can add a feed in the Google Calendar Events settings.';
235
  }
236
  }
237
 
333
  echo gce_print_grid($feed_id, true, $month, $year);
334
  }
335
 
336
+ if(isset($_GET['gce_type']) && $_GET['gce_type'] == 'page'){
337
  if(isset($_GET['gce_feed_id'])){
338
  gce_handle_ajax($_GET['gce_feed_id'], $_GET['gce_month'], $_GET['gce_year']);
339
  die();
inc/gce-parser.php CHANGED
@@ -45,7 +45,7 @@ class GCE_Parser{
45
 
46
  //Returns array of days with events, with sub-arrays of events for that day
47
  function get_event_days(){
48
- $event_days;
49
 
50
  foreach($this->feed->get_items() as $item){
51
  $start_date = $item->get_start_date();
@@ -53,9 +53,10 @@ class GCE_Parser{
53
  //Round start date to nearest day
54
  $start_date = mktime(0, 0, 0, date('m', $start_date), date('d', $start_date) , date('Y', $start_date));
55
 
56
- if(!$event_days[$start_date]){
57
  //Create new array in $event_days for this date (only dates with events will go into array, so, for
58
- //example $event_days[26] will exist if 26th of month has events, but won't if it has no events
 
59
  $event_days[$start_date] = array();
60
  }
61
 
@@ -77,7 +78,7 @@ class GCE_Parser{
77
  $markup .=
78
  '<li>' .
79
  '<p class="gce-date-time">' .
80
- '<span class="gce-date">' . date($this->d_format, $key) . '</span>, ' .
81
  '<span class="gce-time">' . date($this->t_format, $event->get_start_date()) . '</span>' .
82
  '</p>' .
83
  '<p class="gce-event-text">' . $event->get_title() . '</p>' .
@@ -106,11 +107,13 @@ class GCE_Parser{
106
 
107
  $no_more_events = false;
108
 
 
 
109
  foreach($event_days as $key => $event_day){
110
  //If event day is in the month and year specified (by $month and $year)
111
  if(date('mY', $key) == $m_y){
112
  //If this event day is the last in $event_days, there are no more events so set $no_more_events to true
113
- if($event_day == end($event_days)) $no_more_events = true;
114
 
115
  //Create markup for tooltip
116
  $events_markup = '<div class="gce-event-info"><p>Events on ' . date($this->d_format, $key) . ':</p><ul>';
@@ -119,9 +122,9 @@ class GCE_Parser{
119
  }
120
  $events_markup .= '</ul></div>';
121
 
122
- //If this event day is today, add gce-today class to $css_classes
123
  $css_classes = 'gce-has-events';
124
- if($key == mktime(0, 0, 0, date('m'), date('d'), date('Y'))) $css_classes .= ' gce-today';
125
 
126
  //Change array entry to array of link href, CSS classes, and markup for use in gce_generate_calendar (below)
127
  $event_days[$key] = array(null, $css_classes, $events_markup);
@@ -131,6 +134,11 @@ class GCE_Parser{
131
  }
132
  }
133
 
 
 
 
 
 
134
  //Only add previous / next functionality if AJAX grid is enabled
135
  if($ajaxified){
136
  //If the month shown is the current month, don't add previous month link. If it isn't, add previous month link
45
 
46
  //Returns array of days with events, with sub-arrays of events for that day
47
  function get_event_days(){
48
+ $event_days = array();
49
 
50
  foreach($this->feed->get_items() as $item){
51
  $start_date = $item->get_start_date();
53
  //Round start date to nearest day
54
  $start_date = mktime(0, 0, 0, date('m', $start_date), date('d', $start_date) , date('Y', $start_date));
55
 
56
+ if(!isset($event_days[$start_date])){
57
  //Create new array in $event_days for this date (only dates with events will go into array, so, for
58
+ //example $event_days[26] will exist if 26th of month has events, but won't if it has no events)
59
+ //(Now uses unix timestamp rather than day number, but same concept applies).
60
  $event_days[$start_date] = array();
61
  }
62
 
78
  $markup .=
79
  '<li>' .
80
  '<p class="gce-date-time">' .
81
+ '<span class="gce-date">' . date($this->d_format, $key) . '</span> ' .
82
  '<span class="gce-time">' . date($this->t_format, $event->get_start_date()) . '</span>' .
83
  '</p>' .
84
  '<p class="gce-event-text">' . $event->get_title() . '</p>' .
107
 
108
  $no_more_events = false;
109
 
110
+ $today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
111
+
112
  foreach($event_days as $key => $event_day){
113
  //If event day is in the month and year specified (by $month and $year)
114
  if(date('mY', $key) == $m_y){
115
  //If this event day is the last in $event_days, there are no more events so set $no_more_events to true
116
+ if($event_day === end($event_days)) $no_more_events = true;
117
 
118
  //Create markup for tooltip
119
  $events_markup = '<div class="gce-event-info"><p>Events on ' . date($this->d_format, $key) . ':</p><ul>';
122
  }
123
  $events_markup .= '</ul></div>';
124
 
125
+ //If this event day is 'today', add gce-today class to $css_classes
126
  $css_classes = 'gce-has-events';
127
+ if($key == $today) $css_classes .= ' gce-today';
128
 
129
  //Change array entry to array of link href, CSS classes, and markup for use in gce_generate_calendar (below)
130
  $event_days[$key] = array(null, $css_classes, $events_markup);
134
  }
135
  }
136
 
137
+ //Ensures that gce-today CSS class is added even if there are no events for 'today'. A bit messy :(
138
+ if(!isset($event_days[$today])) $event_days[$today] = array(null, 'gce-today', null);
139
+
140
+ $pn = array();
141
+
142
  //Only add previous / next functionality if AJAX grid is enabled
143
  if($ajaxified){
144
  //If the month shown is the current month, don't add previous month link. If it isn't, add previous month link
js/gce-tooltip-script.js CHANGED
@@ -55,8 +55,8 @@ function gce_ajaxify(target, feed_id, type){
55
  jQuery.get('index.php', {gce_type:type, gce_feed_id:feed_id, gce_widget_id:target, gce_month:month_year[0], gce_year:month_year[1]}, function(data){
56
  //Replace existing data with returned AJAX data
57
  if(type == 'widget'){
58
- jQuery('#' + target).children('.gce-widget-grid').html(data);
59
- gce_simple_tooltip('.widget_gce_widget .gce-has-events');
60
  }else{
61
  jQuery('#' + target).replaceWith(data);
62
  gce_simple_tooltip('.gce-page-grid .gce-has-events');
@@ -66,6 +66,6 @@ function gce_ajaxify(target, feed_id, type){
66
  }
67
 
68
  jQuery(document).ready(function(){
69
- gce_simple_tooltip('.widget_gce_widget .gce-has-events');
70
  gce_simple_tooltip('.gce-page-grid .gce-has-events');
71
  });
55
  jQuery.get('index.php', {gce_type:type, gce_feed_id:feed_id, gce_widget_id:target, gce_month:month_year[0], gce_year:month_year[1]}, function(data){
56
  //Replace existing data with returned AJAX data
57
  if(type == 'widget'){
58
+ jQuery('#' + target).html(data);
59
+ gce_simple_tooltip('.gce-widget-grid .gce-has-events');
60
  }else{
61
  jQuery('#' + target).replaceWith(data);
62
  gce_simple_tooltip('.gce-page-grid .gce-has-events');
66
  }
67
 
68
  jQuery(document).ready(function(){
69
+ gce_simple_tooltip('.gce-widget-grid .gce-has-events');
70
  gce_simple_tooltip('.gce-page-grid .gce-has-events');
71
  });
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: rosshanney
3
  Tags: google, google calendar, calendar, events, ajax, widget
4
  Requires at least: 2.9.2
5
  Tested up to: 3.0
6
- Stable tag: 0.1.1
7
 
8
  Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
9
 
@@ -21,7 +21,11 @@ Parses Google Calendar feeds and displays the events as a calendar grid or list
21
 
22
  Please visit the plugin homepage for how to get started and other help:
23
 
24
- * [plugin homepage](http://www.rhanney.co.uk/plugins/google-calendar-events)
 
 
 
 
25
 
26
  == Installation ==
27
 
@@ -37,8 +41,22 @@ After activation a new Google Calendar Events options menu will appear under Set
37
 
38
  You can now start adding feeds. Visit the [plugin homepage](http://www.rhanney.co.uk/plugins/google-calendar-events) for a more in-depth guide on getting started.
39
 
 
 
 
 
 
 
 
 
40
  == Changelog ==
41
 
 
 
 
 
 
 
42
  = 0.1.1 =
43
  * Fix to prevent conflicts with other plugins.
44
  * Changes to readme.txt.
@@ -48,8 +66,8 @@ You can now start adding feeds. Visit the [plugin homepage](http://www.rhanney.c
48
 
49
  == Upgrade Notice ==
50
 
51
- = 0.1.1 =
52
- Bug fix to prevent conflicts with other plugins.
53
 
54
  == Frequently Asked Questions ==
55
 
3
  Tags: google, google calendar, calendar, events, ajax, widget
4
  Requires at least: 2.9.2
5
  Tested up to: 3.0
6
+ Stable tag: 0.1.3
7
 
8
  Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
9
 
21
 
22
  Please visit the plugin homepage for how to get started and other help:
23
 
24
+ * [Plugin Homepage](http://www.rhanney.co.uk/plugins/google-calendar-events)
25
+
26
+ There is also a demonstration page showing the plugin in action:
27
+
28
+ * [Demo Page](http://www.rhanney.co.uk/plugins/google-calendar-events/gce-demo)
29
 
30
  == Installation ==
31
 
41
 
42
  You can now start adding feeds. Visit the [plugin homepage](http://www.rhanney.co.uk/plugins/google-calendar-events) for a more in-depth guide on getting started.
43
 
44
+ == Screenshots ==
45
+
46
+ There is also a [demo page](http://www.rhanney.co.uk/plugins/google-calendar-events/gce-demo) where you can see the plugin in action.
47
+
48
+ 1. The main plugin admin screen.
49
+ 1. The add feed admin screen.
50
+ 1. A page showing a full page calendar grid and various widgets.
51
+
52
  == Changelog ==
53
 
54
+ = 0.1.3 =
55
+ * Several bug fixes, including fixing JavaScript problems that prevented tooltips appearing.
56
+
57
+ = 0.1.2 =
58
+ * Bug fixes.
59
+
60
  = 0.1.1 =
61
  * Fix to prevent conflicts with other plugins.
62
  * Changes to readme.txt.
66
 
67
  == Upgrade Notice ==
68
 
69
+ = 0.1.3 =
70
+ Several bug fixes.
71
 
72
  == Frequently Asked Questions ==
73
 
screenshot-1.jpg ADDED
Binary file
screenshot-2.jpg ADDED
Binary file
screenshot-3.jpg ADDED
Binary file
widget/gce-widget.php CHANGED
@@ -9,34 +9,42 @@ class GCE_Widget extends WP_Widget{
9
  function widget($args, $instance){
10
  extract($args);
11
 
 
 
 
12
  //Get saved feed options
13
  $options = get_option(GCE_OPTIONS_NAME);
14
 
15
- //Output before widget and widget title stuff
16
- echo $before_widget;
17
- echo $before_title . $options[$instance['id']]['title'] . $after_title;
18
-
19
- //Output correct widget content based on display type chosen
20
- switch($instance['display_type']){
21
- case 'grid':
22
- echo '<div class="gce-widget-grid">';
23
- //Output main widget content as grid (no AJAX)
24
- gce_widget_content_grid($instance['id'], $args['widget_id']);
25
- break;
26
- case 'ajax':
27
- echo '<div class="gce-widget-grid">';
28
- //Output main widget content as grid (with AJAX)
29
- gce_widget_content_grid($instance['id'], $args['widget_id'], true);
30
- break;
31
- case 'list':
32
- echo '<div class="gce-widget-list">';
33
- //Output main widget content as list
34
- gce_widget_content_list($instance['id']);
35
- break;
 
 
 
 
 
 
 
36
  }
37
 
38
- echo '</div>';
39
-
40
  //Output after widget stuff
41
  echo $after_widget;
42
  }
@@ -123,7 +131,7 @@ function gce_widget_content_list($id){
123
 
124
  //Set time and date formats to WordPress defaults if not set by user
125
  $df = $options[$id]['date_format'];
126
- $tf = $gce_options[$id]['time_format'];
127
  if($df == '') $df = get_option('date_format');
128
  if($tf == '') $tf = get_option('time_format');
129
 
@@ -146,7 +154,7 @@ function gce_widget_content_list($id){
146
  }
147
 
148
  //AJAX stuff. Passes the data from JavaScript to above gce_widget_content_grid function
149
- if($_GET['gce_type'] == 'widget'){
150
  if(isset($_GET['gce_feed_id'])){
151
  gce_widget_content_grid($_GET['gce_feed_id'], $_GET['gce_widget_id'], true, $_GET['gce_month'], $_GET['gce_year']);
152
  die();
9
  function widget($args, $instance){
10
  extract($args);
11
 
12
+ //Output before widget stuff
13
+ echo $before_widget;
14
+
15
  //Get saved feed options
16
  $options = get_option(GCE_OPTIONS_NAME);
17
 
18
+ //Check whether any feeds have been added yet
19
+ if(is_array($options) && !empty($options)){
20
+ //Output title stuff
21
+ echo $before_title . $options[$instance['id']]['title'] . $after_title;
22
+
23
+ //Output correct widget content based on display type chosen
24
+ switch($instance['display_type']){
25
+ case 'grid':
26
+ echo '<div class="gce-widget-grid" id="' . $args['widget_id'] . '-container">';
27
+ //Output main widget content as grid (no AJAX)
28
+ gce_widget_content_grid($instance['id'], $args['widget_id'] . '-container');
29
+ echo '</div>';
30
+ break;
31
+ case 'ajax':
32
+ echo '<div class="gce-widget-grid" id="' . $args['widget_id'] . '-container">';
33
+ //Output main widget content as grid (with AJAX)
34
+ gce_widget_content_grid($instance['id'], $args['widget_id'] . '-container', true);
35
+ echo '</div>';
36
+ break;
37
+ case 'list':
38
+ echo '<div class="gce-widget-list" id="' . $args['widget_id'] . '-container">';
39
+ //Output main widget content as list
40
+ gce_widget_content_list($instance['id']);
41
+ echo '</div>';
42
+ break;
43
+ }
44
+ }else{
45
+ echo 'No feeds have been added yet. You can add a feed in the Google Calendar Events settings.';
46
  }
47
 
 
 
48
  //Output after widget stuff
49
  echo $after_widget;
50
  }
131
 
132
  //Set time and date formats to WordPress defaults if not set by user
133
  $df = $options[$id]['date_format'];
134
+ $tf = $options[$id]['time_format'];
135
  if($df == '') $df = get_option('date_format');
136
  if($tf == '') $tf = get_option('time_format');
137
 
154
  }
155
 
156
  //AJAX stuff. Passes the data from JavaScript to above gce_widget_content_grid function
157
+ if(isset($_GET['gce_type']) && $_GET['gce_type'] == 'widget'){
158
  if(isset($_GET['gce_feed_id'])){
159
  gce_widget_content_grid($_GET['gce_feed_id'], $_GET['gce_widget_id'], true, $_GET['gce_month'], $_GET['gce_year']);
160
  die();