Simple Calendar – Google Calendar Plugin - Version 0.3.1

Version Description

  • l10n / i18n fixes. Dates should now be localized correctly and should maintain localization after an AJAX request
  • MU / Multi-site issues. Issues preventing adding of feeds have been addressed
Download this release

Release Info

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

Code changes from version 0.3 to 0.3.1

admin/add.php CHANGED
@@ -2,7 +2,7 @@
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
 
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
 
admin/delete.php CHANGED
@@ -2,7 +2,7 @@
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
 
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
 
admin/edit.php CHANGED
@@ -2,7 +2,7 @@
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
 
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
 
admin/main.php CHANGED
@@ -1,7 +1,7 @@
1
  <div class="wrap">
2
  <h3><?php _e('Add a New Feed', GCE_TEXT_DOMAIN); ?></h3>
3
 
4
- <a href="<?php echo esc_url($_SERVER['PHP_SELF'] . '?page=' . GCE_PLUGIN_NAME . '.php&action=add'); ?>" class="button-secondary" title="<?php _e('Click here to add a new feed', GCE_TEXT_DOMAIN); ?>"><?php _e('Add Feed', GCE_TEXT_DOMAIN); ?></a>
5
 
6
  <br /><br />
7
  <h3><?php _e('Current Feeds', GCE_TEXT_DOMAIN); ?></h3>
@@ -43,9 +43,9 @@
43
  <td><?php echo $event['title']; ?></td>
44
  <td><?php echo $event['url']; ?></td>
45
  <td align="right">
46
- <a href="<?php echo esc_url($_SERVER['PHP_SELF'] . '?page=' . GCE_PLUGIN_NAME . '.php&action=edit&id=' . $key); ?>"><?php _e('Edit', GCE_TEXT_DOMAIN); ?></a>
47
  |
48
- <a href="<?php echo esc_url($_SERVER['PHP_SELF'] . '?page=' . GCE_PLUGIN_NAME . '.php&action=delete&id=' . $key); ?>"><?php _e('Delete', GCE_TEXT_DOMAIN); ?></a>
49
  </td>
50
  </tr>
51
  <?php } ?>
1
  <div class="wrap">
2
  <h3><?php _e('Add a New Feed', GCE_TEXT_DOMAIN); ?></h3>
3
 
4
+ <a href="<?php echo admin_url('options-general.php?page=' . GCE_PLUGIN_NAME . '.php&action=add'); ?>" class="button-secondary" title="<?php _e('Click here to add a new feed', GCE_TEXT_DOMAIN); ?>"><?php _e('Add Feed', GCE_TEXT_DOMAIN); ?></a>
5
 
6
  <br /><br />
7
  <h3><?php _e('Current Feeds', GCE_TEXT_DOMAIN); ?></h3>
43
  <td><?php echo $event['title']; ?></td>
44
  <td><?php echo $event['url']; ?></td>
45
  <td align="right">
46
+ <a href="<?php echo admin_url('options-general.php?page=' . GCE_PLUGIN_NAME . '.php&action=edit&id=' . $key); ?>"><?php _e('Edit', GCE_TEXT_DOMAIN); ?></a>
47
  |
48
+ <a href="<?php echo admin_url('options-general.php?page=' . GCE_PLUGIN_NAME . '.php&action=delete&id=' . $key); ?>"><?php _e('Delete', GCE_TEXT_DOMAIN); ?></a>
49
  </td>
50
  </tr>
51
  <?php } ?>
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.3
7
  Author: Ross Hanney
8
  Author URI: http://www.rhanney.co.uk
9
  License: GPL2
@@ -51,6 +51,8 @@ if(!class_exists('Google_Calendar_Events')){
51
  add_action('wp_print_styles', array($this, 'add_styles'));
52
  add_action('wp_print_scripts', array($this, 'add_scripts'));
53
  add_action('widgets_init', create_function('', 'return register_widget("GCE_Widget");'));
 
 
54
  add_shortcode('google-calendar-events', array($this, 'shortcode_handler'));
55
  }
56
 
@@ -137,7 +139,7 @@ if(!class_exists('Google_Calendar_Events')){
137
  do_settings_sections('add_feed');
138
  do_settings_sections('add_display');
139
  ?><p class="submit"><input type="submit" class="button-primary submit" value="<?php _e('Add Feed', GCE_TEXT_DOMAIN); ?>" /></p>
140
- <p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary"><?php _e('Cancel', GCE_TEXT_DOMAIN); ?></a></p><?php
141
  break;
142
  //Edit feed section
143
  case 'edit':
@@ -145,14 +147,14 @@ if(!class_exists('Google_Calendar_Events')){
145
  do_settings_sections('edit_feed');
146
  do_settings_sections('edit_display');
147
  ?><p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes', GCE_TEXT_DOMAIN); ?>" /></p>
148
- <p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary"><?php _e('Cancel', GCE_TEXT_DOMAIN); ?></a></p><?php
149
  break;
150
  //Delete feed section
151
  case 'delete':
152
  settings_fields('gce_options');
153
  do_settings_sections('delete_feed');
154
  ?><p class="submit"><input type="submit" class="button-primary" name="gce_options[submit_delete]" value="<?php _e('Delete Feed', GCE_TEXT_DOMAIN); ?>" /></p>
155
- <p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary"><?php _e('Cancel', GCE_TEXT_DOMAIN); ?></a></p><?php
156
  }
157
  }else{
158
  //Main admin section
@@ -321,7 +323,21 @@ if(!class_exists('Google_Calendar_Events')){
321
  wp_enqueue_script('jquery');
322
  wp_enqueue_script('gce_jquery_qtip', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/js/jquery-qtip.js');
323
  wp_enqueue_script('gce_scripts', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/js/gce-script.js');
324
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  }
326
  }
327
  }
@@ -356,16 +372,5 @@ function gce_print_grid($feed_ids, $title_text, $ajaxified = false, $month = nul
356
  }
357
  }
358
 
359
- function gce_handle_ajax($feed_ids, $title_text, $month = null, $year = null){
360
- echo gce_print_grid($feed_ids, $title_text, true, $month, $year);
361
- }
362
-
363
- if(isset($_GET['gce_type']) && $_GET['gce_type'] == 'page'){
364
- if(isset($_GET['gce_feed_ids'])){
365
- gce_handle_ajax($_GET['gce_feed_ids'], $_GET['gce_title_text'], $_GET['gce_month'], $_GET['gce_year']);
366
- die();
367
- }
368
- }
369
-
370
  $gce = new Google_Calendar_Events();
371
  ?>
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.3.1
7
  Author: Ross Hanney
8
  Author URI: http://www.rhanney.co.uk
9
  License: GPL2
51
  add_action('wp_print_styles', array($this, 'add_styles'));
52
  add_action('wp_print_scripts', array($this, 'add_scripts'));
53
  add_action('widgets_init', create_function('', 'return register_widget("GCE_Widget");'));
54
+ add_action('wp_ajax_gce_ajax', array($this, 'gce_ajax'));
55
+ add_action('wp_ajax_nopriv_gce_ajax', array($this, 'gce_ajax'));
56
  add_shortcode('google-calendar-events', array($this, 'shortcode_handler'));
57
  }
58
 
139
  do_settings_sections('add_feed');
140
  do_settings_sections('add_display');
141
  ?><p class="submit"><input type="submit" class="button-primary submit" value="<?php _e('Add Feed', GCE_TEXT_DOMAIN); ?>" /></p>
142
+ <p><a href="<?php echo admin_url('options-general.php?page=' . GCE_PLUGIN_NAME . '.php'); ?>" class="button-secondary"><?php _e('Cancel', GCE_TEXT_DOMAIN); ?></a></p><?php
143
  break;
144
  //Edit feed section
145
  case 'edit':
147
  do_settings_sections('edit_feed');
148
  do_settings_sections('edit_display');
149
  ?><p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes', GCE_TEXT_DOMAIN); ?>" /></p>
150
+ <p><a href="<?php echo admin_url('options-general.php?page=' . GCE_PLUGIN_NAME . '.php'); ?>" class="button-secondary"><?php _e('Cancel', GCE_TEXT_DOMAIN); ?></a></p><?php
151
  break;
152
  //Delete feed section
153
  case 'delete':
154
  settings_fields('gce_options');
155
  do_settings_sections('delete_feed');
156
  ?><p class="submit"><input type="submit" class="button-primary" name="gce_options[submit_delete]" value="<?php _e('Delete Feed', GCE_TEXT_DOMAIN); ?>" /></p>
157
+ <p><a href="<?php echo admin_url('options-general.php?page=' . GCE_PLUGIN_NAME . '.php'); ?>" class="button-secondary"><?php _e('Cancel', GCE_TEXT_DOMAIN); ?></a></p><?php
158
  }
159
  }else{
160
  //Main admin section
323
  wp_enqueue_script('jquery');
324
  wp_enqueue_script('gce_jquery_qtip', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/js/jquery-qtip.js');
325
  wp_enqueue_script('gce_scripts', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/js/gce-script.js');
326
+ wp_localize_script('gce_scripts', 'GoogleCalendarEvents', array('ajaxurl' => admin_url('admin-ajax.php')));
327
+ }
328
+ }
329
+
330
+ //AJAX stuffs
331
+ function gce_ajax(){
332
+ if(isset($_GET['gce_feed_ids'])){
333
+ if($_GET['gce_type'] == 'page'){
334
+ //The page grid markup to be returned via AJAX
335
+ echo gce_print_grid($_GET['gce_feed_ids'], $_GET['gce_title_text'], true, $_GET['gce_month'], $_GET['gce_year']);
336
+ }elseif($_GET['gce_type'] == 'widget'){
337
+ //The widget grid markup to be returned via AJAX
338
+ gce_widget_content_grid($_GET['gce_feed_ids'], $_GET['gce_title_text'], $_GET['gce_widget_id'], true, $_GET['gce_month'], $_GET['gce_year']);
339
+ }
340
+ die();
341
  }
342
  }
343
  }
372
  }
373
  }
374
 
 
 
 
 
 
 
 
 
 
 
 
375
  $gce = new Google_Calendar_Events();
376
  ?>
inc/gce-parser.php CHANGED
@@ -142,7 +142,7 @@ class GCE_Parser{
142
 
143
  //Get the various information from the event
144
  $event_start_time = date_i18n($event->get_feed()->get_time_format(), $event->get_start_date());
145
- $event_end_time = date_i18n($event->get_feed()->get_time_format() . ' ' . $event->get_feed()->get_date_format(), $event->get_end_date());
146
  $event_location = $event->get_location();
147
  $event_desc = nl2br(make_clickable($event->get_description()));
148
  $event_link = $event->get_link() . '&ctz=' . $event->get_feed()->get_timezone();
@@ -220,7 +220,7 @@ class GCE_Parser{
220
  $event_location = $event->get_location();
221
  $event_desc = nl2br(make_clickable($event->get_description()));
222
  $event_link = $event->get_link() . '&ctz=' . $event->get_feed()->get_timezone();
223
- $event_link_target = (isset($display_options['link_target']) ? ' target="_blank"' : '');
224
 
225
  $markup .= '<li class="gce-feed-' . $event->get_feed()->get_feed_id() . '">';
226
 
142
 
143
  //Get the various information from the event
144
  $event_start_time = date_i18n($event->get_feed()->get_time_format(), $event->get_start_date());
145
+ $event_end_time = date_i18n($event->get_feed()->get_time_format(), $event->get_end_date());
146
  $event_location = $event->get_location();
147
  $event_desc = nl2br(make_clickable($event->get_description()));
148
  $event_link = $event->get_link() . '&ctz=' . $event->get_feed()->get_timezone();
220
  $event_location = $event->get_location();
221
  $event_desc = nl2br(make_clickable($event->get_description()));
222
  $event_link = $event->get_link() . '&ctz=' . $event->get_feed()->get_timezone();
223
+ $event_link_target = (isset($display_options['display_link_target']) ? ' target="_blank"' : '');
224
 
225
  $markup .= '<li class="gce-feed-' . $event->get_feed()->get_feed_id() . '">';
226
 
inc/php-calendar.php CHANGED
@@ -8,9 +8,10 @@
8
  Changes made to original PHP Calendar script by me (Ross Hanney):
9
 
10
  - Renamed CSS classes to fit with my plugin
11
- - Slight modification of lines 56-64 to use Unix timestamp rather than day number
12
  - Other small markup changes
13
  - Renamed function to prevent conflicts
 
14
  */
15
 
16
  function gce_generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
@@ -21,10 +22,10 @@ function gce_generate_calendar($year, $month, $days = array(), $day_name_length
21
 
22
  $day_names = array(); #generate all the day names according to the current locale
23
  for($n = 0, $t = (3 + $first_day) * 86400; $n < 7; $n++, $t += 86400){ #January 4, 1970 was a Sunday
24
- $day_names[$n] = ucfirst(gmstrftime('%A', $t)); #%A means full textual day name
25
  }
26
 
27
- list($month, $year, $month_name, $weekday) = explode(',', gmstrftime('%m, %Y, %B, %w', $first_of_month));
28
  $weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
29
  $title = htmlentities(ucfirst($month_name)) . '&nbsp;' . $year; #note that some locales don't capitalize month and day names
30
 
8
  Changes made to original PHP Calendar script by me (Ross Hanney):
9
 
10
  - Renamed CSS classes to fit with my plugin
11
+ - Slight modification of lines 57-65 to use Unix timestamp rather than day number
12
  - Other small markup changes
13
  - Renamed function to prevent conflicts
14
+ - Replaced strftime with date_i18n on lines 25 and 28 for localization
15
  */
16
 
17
  function gce_generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
22
 
23
  $day_names = array(); #generate all the day names according to the current locale
24
  for($n = 0, $t = (3 + $first_day) * 86400; $n < 7; $n++, $t += 86400){ #January 4, 1970 was a Sunday
25
+ $day_names[$n] = ucfirst(date_i18n('l', $t));
26
  }
27
 
28
+ list($month, $year, $month_name, $weekday) = explode(',', date_i18n('m, Y, F, w', $first_of_month));
29
  $weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
30
  $title = htmlentities(ucfirst($month_name)) . '&nbsp;' . $year; #note that some locales don't capitalize month and day names
31
 
js/gce-script.js CHANGED
@@ -6,7 +6,15 @@ function gce_ajaxify(target, feed_ids, title_text, type){
6
  //Add loading text to table caption
7
  jQuery('#' + target + ' caption').html('Loading...');
8
  //Send AJAX request
9
- jQuery.get('index.php', {gce_type:type, gce_feed_ids:feed_ids, gce_title_text:title_text, gce_widget_id:target, gce_month:month_year[0], gce_year:month_year[1]}, function(data){
 
 
 
 
 
 
 
 
10
  //Replace existing data with returned AJAX data
11
  if(type == 'widget'){
12
  jQuery('#' + target).html(data);
6
  //Add loading text to table caption
7
  jQuery('#' + target + ' caption').html('Loading...');
8
  //Send AJAX request
9
+ jQuery.get(GoogleCalendarEvents.ajaxurl,{
10
+ action:'gce_ajax',
11
+ gce_type:type,
12
+ gce_feed_ids:feed_ids,
13
+ gce_title_text:title_text,
14
+ gce_widget_id:target,
15
+ gce_month:month_year[0],
16
+ gce_year:month_year[1]
17
+ }, function(data){
18
  //Replace existing data with returned AJAX data
19
  if(type == 'widget'){
20
  jQuery('#' + target).html(data);
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: rosshanney
3
  Tags: google, google calendar, calendar, event, events, ajax, widget
4
  Requires at least: 2.9.2
5
  Tested up to: 3.0
6
- Stable tag: 0.3
7
 
8
  Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
9
 
@@ -57,6 +57,10 @@ You can now start adding feeds. Visit the [plugin homepage](http://www.rhanney.c
57
 
58
  == Changelog ==
59
 
 
 
 
 
60
  = 0.3 =
61
  * Now allows events from multiple Google Calendar feeds to be displayed on a single calendar grid / list
62
  * Internationalization support added
@@ -92,7 +96,7 @@ You can now start adding feeds. Visit the [plugin homepage](http://www.rhanney.c
92
  == Upgrade Notice ==
93
 
94
  = 0.3 =
95
- Now supports display of multiple feeds in one grid / list
96
 
97
  == Frequently Asked Questions ==
98
 
3
  Tags: google, google calendar, calendar, event, events, ajax, widget
4
  Requires at least: 2.9.2
5
  Tested up to: 3.0
6
+ Stable tag: 0.3.1
7
 
8
  Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
9
 
57
 
58
  == Changelog ==
59
 
60
+ = 0.3.1 =
61
+ * l10n / i18n fixes. Dates should now be localized correctly and should maintain localization after an AJAX request
62
+ * MU / Multi-site issues. Issues preventing adding of feeds have been addressed
63
+
64
  = 0.3 =
65
  * Now allows events from multiple Google Calendar feeds to be displayed on a single calendar grid / list
66
  * Internationalization support added
96
  == Upgrade Notice ==
97
 
98
  = 0.3 =
99
+ Fixes for internationalization / localization and MU / multi-site.
100
 
101
  == Frequently Asked Questions ==
102
 
widget/gce-widget.php CHANGED
@@ -151,12 +151,4 @@ function gce_widget_content_list($feed_ids, $title_text){
151
  printf(__('The following feeds were not parsed successfully: %s. Please check that the feed URLs are correct and that the feeds have public sharing enabled.'), implode(', ', $list->get_errors()));
152
  }
153
  }
154
-
155
- //AJAX stuff. Passes the data from JavaScript to above gce_widget_content_grid function
156
- if(isset($_GET['gce_type']) && $_GET['gce_type'] == 'widget'){
157
- if(isset($_GET['gce_feed_ids'])){
158
- gce_widget_content_grid($_GET['gce_feed_ids'], $_GET['gce_title_text'], $_GET['gce_widget_id'], true, $_GET['gce_month'], $_GET['gce_year']);
159
- die();
160
- }
161
- }
162
  ?>
151
  printf(__('The following feeds were not parsed successfully: %s. Please check that the feed URLs are correct and that the feeds have public sharing enabled.'), implode(', ', $list->get_errors()));
152
  }
153
  }
 
 
 
 
 
 
 
 
154
  ?>