Simple Calendar – Google Calendar Plugin - Version 0.3

Version Description

  • Now allows events from multiple Google Calendar feeds to be displayed on a single calendar grid / list
  • Internationalization support added
Download this release

Release Info

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

Code changes from version 0.2.1 to 0.3

admin/add.php CHANGED
@@ -6,6 +6,25 @@ if(isset($_GET['action'])){
6
  }
7
  }
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  //Main text
10
  function gce_add_main_text(){
11
  ?>
@@ -118,16 +137,6 @@ function gce_add_display_main_text(){
118
  <?php
119
  }
120
 
121
- function gce_add_display_title_field(){
122
- ?>
123
- <input type="checkbox" name="gce_options[display_title]" value="on" checked="checked" />
124
- <span class="description"><?php _e('Show a title ("Events on 7th March:" for example)?', GCE_TEXT_DOMAIN); ?></span>
125
- <br /><br />
126
- <input type="text" name="gce_options[display_title_text]" value="" />
127
- <span class="description"><?php _e('Text to display before the date in the title.', GCE_TEXT_DOMAIN); ?></span>
128
- <?php
129
- }
130
-
131
  function gce_add_display_start_field(){
132
  ?>
133
  <input type="checkbox" name="gce_options[display_start]" value="on" checked="checked" />
6
  }
7
  }
8
 
9
+ add_settings_section('gce_add', __('Add a Feed', GCE_TEXT_DOMAIN), 'gce_add_main_text', 'add_feed');
10
+ //Unique ID //Title //Function //Page //Section ID
11
+ add_settings_field('gce_add_id_field', __('Feed ID', GCE_TEXT_DOMAIN), 'gce_add_id_field', 'add_feed', 'gce_add');
12
+ add_settings_field('gce_add_title_field', __('Feed Title', GCE_TEXT_DOMAIN), 'gce_add_title_field', 'add_feed', 'gce_add');
13
+ add_settings_field('gce_add_url_field', __('Feed URL', GCE_TEXT_DOMAIN), 'gce_add_url_field', 'add_feed', 'gce_add');
14
+ add_settings_field('gce_add_show_past_events_field', __('Retrieve past events for current month?', GCE_TEXT_DOMAIN), 'gce_add_show_past_events_field', 'add_feed', 'gce_add');
15
+ add_settings_field('gce_add_max_events_field', __('Maximum number of events to retrieve', GCE_TEXT_DOMAIN), 'gce_add_max_events_field', 'add_feed', 'gce_add');
16
+ add_settings_field('gce_add_date_format_field', __('Date format', GCE_TEXT_DOMAIN), 'gce_add_date_format_field', 'add_feed', 'gce_add');
17
+ add_settings_field('gce_add_time_format_field', __('Time format', GCE_TEXT_DOMAIN), 'gce_add_time_format_field', 'add_feed', 'gce_add');
18
+ add_settings_field('gce_add_timezone_field', __('Timezone adjustment', GCE_TEXT_DOMAIN), 'gce_add_timezone_field', 'add_feed', 'gce_add');
19
+ add_settings_field('gce_add_cache_duration_field', __('Cache duration', GCE_TEXT_DOMAIN), 'gce_add_cache_duration_field', 'add_feed', 'gce_add');
20
+
21
+ add_settings_section('gce_add_display', __('Display Options', GCE_TEXT_DOMAIN), 'gce_add_display_main_text', 'add_display');
22
+ add_settings_field('gce_add_display_start_field', __('Display start time?', GCE_TEXT_DOMAIN), 'gce_add_display_start_field', 'add_display', 'gce_add_display');
23
+ add_settings_field('gce_add_display_end_field', __('Display end time and date?', GCE_TEXT_DOMAIN), 'gce_add_display_end_field', 'add_display', 'gce_add_display');
24
+ add_settings_field('gce_add_display_location_field', __('Display location?', GCE_TEXT_DOMAIN), 'gce_add_display_location_field', 'add_display', 'gce_add_display');
25
+ add_settings_field('gce_add_display_desc_field', __('Display description?', GCE_TEXT_DOMAIN), 'gce_add_display_desc_field', 'add_display', 'gce_add_display');
26
+ add_settings_field('gce_add_display_link_field', __('Display link to event?', GCE_TEXT_DOMAIN), 'gce_add_display_link_field', 'add_display', 'gce_add_display');
27
+
28
  //Main text
29
  function gce_add_main_text(){
30
  ?>
137
  <?php
138
  }
139
 
 
 
 
 
 
 
 
 
 
 
140
  function gce_add_display_start_field(){
141
  ?>
142
  <input type="checkbox" name="gce_options[display_start]" value="on" checked="checked" />
admin/delete.php CHANGED
@@ -6,6 +6,11 @@ if(isset($_GET['action'])){
6
  }
7
  }
8
 
 
 
 
 
 
9
  //Main text
10
  function gce_delete_main_text(){
11
  ?>
6
  }
7
  }
8
 
9
+ add_settings_section('gce_delete', __('Delete Feed', GCE_TEXT_DOMAIN), 'gce_delete_main_text', 'delete_feed');
10
+ //Unique ID //Title //Function //Page //Section ID
11
+ add_settings_field('gce_delete_id_field', __('Feed ID', GCE_TEXT_DOMAIN), 'gce_delete_id_field', 'delete_feed', 'gce_delete');
12
+ add_settings_field('gce_delete_title_field', __('Feed Title', GCE_TEXT_DOMAIN), 'gce_delete_title_field', 'delete_feed', 'gce_delete');
13
+
14
  //Main text
15
  function gce_delete_main_text(){
16
  ?>
admin/edit.php CHANGED
@@ -6,6 +6,25 @@ if(isset($_GET['action'])){
6
  }
7
  }
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  //Main text
10
  function gce_edit_main_text(){
11
  ?>
@@ -127,18 +146,6 @@ function gce_edit_display_main_text(){
127
  <?php
128
  }
129
 
130
- function gce_edit_display_title_field(){
131
- $options = get_option(GCE_OPTIONS_NAME);
132
- $options = $options[$_GET['id']];
133
- ?>
134
- <input type="checkbox" name="gce_options[display_title]"<?php checked($options['display_title'], 'on'); ?> value="on" />
135
- <span class="description"><?php _e('Show a title ("Events on 7th March:" for example)?', GCE_TEXT_DOMAIN); ?></span>
136
- <br /><br />
137
- <input type="text" name="gce_options[display_title_text]" value="<?php echo stripslashes(esc_html($options['display_title_text'])); ?>" />
138
- <span class="description"><?php _e('Text to display before the date in title.', GCE_TEXT_DOMAIN); ?></span>
139
- <?php
140
- }
141
-
142
  function gce_edit_display_start_field(){
143
  $options = get_option(GCE_OPTIONS_NAME);
144
  $options = $options[$_GET['id']];
6
  }
7
  }
8
 
9
+ add_settings_section('gce_edit', __('Edit Feed', GCE_TEXT_DOMAIN), 'gce_edit_main_text', 'edit_feed');
10
+ //Unique ID //Title //Function //Page //Section ID
11
+ add_settings_field('gce_edit_id_field', __('Feed ID', GCE_TEXT_DOMAIN), 'gce_edit_id_field', 'edit_feed', 'gce_edit');
12
+ add_settings_field('gce_edit_title_field', __('Feed Title', GCE_TEXT_DOMAIN), 'gce_edit_title_field', 'edit_feed', 'gce_edit');
13
+ add_settings_field('gce_edit_url_field', __('Feed URL', GCE_TEXT_DOMAIN), 'gce_edit_url_field', 'edit_feed', 'gce_edit');
14
+ add_settings_field('gce_edit_show_past_events_field', __('Retrieve past events for current month?', GCE_TEXT_DOMAIN), 'gce_edit_show_past_events_field', 'edit_feed', 'gce_edit');
15
+ add_settings_field('gce_edit_max_events_field', __('Maximum number of events to retrieve', GCE_TEXT_DOMAIN), 'gce_edit_max_events_field', 'edit_feed', 'gce_edit');
16
+ add_settings_field('gce_edit_date_format_field', __('Date format', GCE_TEXT_DOMAIN), 'gce_edit_date_format_field', 'edit_feed', 'gce_edit');
17
+ add_settings_field('gce_edit_time_format_field', __('Time format', GCE_TEXT_DOMAIN), 'gce_edit_time_format_field', 'edit_feed', 'gce_edit');
18
+ add_settings_field('gce_edit_timezone_field', __('Timezone adjustment', GCE_TEXT_DOMAIN), 'gce_edit_timezone_field', 'edit_feed', 'gce_edit');
19
+ add_settings_field('gce_edit_cache_duration_field', __('Cache duration', GCE_TEXT_DOMAIN), 'gce_edit_cache_duration_field', 'edit_feed', 'gce_edit');
20
+
21
+ add_settings_section('gce_edit_display', __('Display Options', GCE_TEXT_DOMAIN), 'gce_edit_display_main_text', 'edit_display');
22
+ add_settings_field('gce_edit_display_start_field', __('Display start time?', GCE_TEXT_DOMAIN), 'gce_edit_display_start_field', 'edit_display', 'gce_edit_display');
23
+ add_settings_field('gce_edit_display_end_field', __('Display end time and date?', GCE_TEXT_DOMAIN), 'gce_edit_display_end_field', 'edit_display', 'gce_edit_display');
24
+ add_settings_field('gce_edit_display_location_field', __('Display location?', GCE_TEXT_DOMAIN), 'gce_edit_display_location_field', 'edit_display', 'gce_edit_display');
25
+ add_settings_field('gce_edit_display_desc_field', __('Display description?', GCE_TEXT_DOMAIN), 'gce_edit_display_desc_field', 'edit_display', 'gce_edit_display');
26
+ add_settings_field('gce_edit_display_link_field', __('Display link to event?', GCE_TEXT_DOMAIN), 'gce_edit_display_link_field', 'edit_display', 'gce_edit_display');
27
+
28
  //Main text
29
  function gce_edit_main_text(){
30
  ?>
146
  <?php
147
  }
148
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  function gce_edit_display_start_field(){
150
  $options = get_option(GCE_OPTIONS_NAME);
151
  $options = $options[$_GET['id']];
css/gce-style.css CHANGED
@@ -203,7 +203,6 @@
203
  /* Also available: .gce-tooltip-start, .gce-tooltip-end, .gce-tooltip-loc, .gce-tooltip-desc, .gce-tooltip-link */
204
 
205
 
206
-
207
  /* Sort of fixes weird list stuff in old default theme */
208
  .entry .gce-page-list li:before, #sidebar .gce-widget-list ul li:before {
209
  content:none;
203
  /* Also available: .gce-tooltip-start, .gce-tooltip-end, .gce-tooltip-loc, .gce-tooltip-desc, .gce-tooltip-link */
204
 
205
 
 
206
  /* Sort of fixes weird list stuff in old default theme */
207
  .entry .gce-page-list li:before, #sidebar .gce-widget-list ul li:before {
208
  content:none;
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.2.1
7
  Author: Ross Hanney
8
  Author URI: http://www.rhanney.co.uk
9
  License: GPL2
@@ -30,6 +30,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30
  define('GCE_PLUGIN_NAME', str_replace('.php', '', basename(__FILE__)));
31
  define('GCE_TEXT_DOMAIN', 'google-calendar-events');
32
  define('GCE_OPTIONS_NAME', 'gce_options');
 
33
 
34
  require_once 'widget/gce-widget.php';
35
  require_once 'inc/gce-parser.php';
@@ -43,20 +44,18 @@ 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, 'init_plugin'));
 
47
  add_action('admin_menu', array($this, 'setup_admin'));
48
  add_action('admin_init', array($this, 'init_admin'));
49
-
50
- add_action('widgets_init', create_function('', 'return register_widget("GCE_Widget");'));
51
-
52
- add_shortcode('google-calendar-events', array($this, 'shortcode_handler'));
53
-
54
  add_action('wp_print_styles', array($this, 'add_styles'));
55
  add_action('wp_print_scripts', array($this, 'add_scripts'));
 
 
56
  }
57
 
58
  //If any new options have been added between versions, this will update any saved feeds with defaults for new options (shouldn't overwrite anything saved)
59
- function init_plugin(){
60
  add_option(GCE_OPTIONS_NAME);
61
 
62
  $options = get_option(GCE_OPTIONS_NAME);
@@ -73,13 +72,11 @@ if(!class_exists('Google_Calendar_Events')){
73
  'time_format' => '',
74
  'timezone' => 'default',
75
  'cache_duration' => 43200,
76
- 'display_title' => 'on',
77
  'display_start' => 'on',
78
  'display_end' => '',
79
  'display_location' => '',
80
  'display_desc' => '',
81
  'display_link' => 'on',
82
- 'display_title_text' => '',
83
  'display_start_text' => 'Starts:',
84
  'display_end_text' => 'Ends:',
85
  'display_location_text' => 'Location:',
@@ -100,6 +97,11 @@ if(!class_exists('Google_Calendar_Events')){
100
  update_option(GCE_OPTIONS_NAME, $options);
101
  }
102
 
 
 
 
 
 
103
  //Setup admin settings page
104
  function setup_admin(){
105
  if(function_exists('add_options_page')) add_options_page('Google Calendar Events', 'Google Calendar Events', 'manage_options', basename(__FILE__), array($this, 'admin_page'));
@@ -111,47 +113,46 @@ if(!class_exists('Google_Calendar_Events')){
111
  if(isset($_GET['updated'])){
112
  switch($_GET['updated']){
113
  case 'added':
114
- ?><div class="updated"><p><strong>New Feed Added Successfully.</strong></p></div><?php
115
  break;
116
  case 'edited':
117
- ?><div class="updated"><p><strong>Feed Details Updated Successfully.</strong></p></div><?php
118
  break;
119
  case 'deleted':
120
- ?><div class="updated"><p><strong>Feed Deleted Successfully.</strong></p></div><?php
121
- break;
122
  }
123
  }?>
124
 
125
  <div class="wrap">
126
  <div id="icon-options-general" class="icon32"><br /></div>
127
 
128
- <h2>Google Calendar Events</h2>
129
  <form method="post" action="options.php" id="test-form">
130
  <?php
131
- settings_fields('gce_options_group');
132
-
133
  if(isset($_GET['action'])){
134
  switch($_GET['action']){
135
  //Add feed section
136
  case 'add':
 
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 esc_attr_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">Cancel</a></p><?php
141
  break;
142
  //Edit feed section
143
  case 'edit':
 
144
  do_settings_sections('edit_feed');
145
  do_settings_sections('edit_display');
146
- ?><p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes', GCE_TEXT_DOMAIN); ?>" /></p>
147
- <p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary">Cancel</a></p><?php
148
  break;
149
  //Delete feed section
150
  case 'delete':
 
151
  do_settings_sections('delete_feed');
152
- ?><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>
153
- <p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary">Cancel</a></p><?php
154
- break;
155
  }
156
  }else{
157
  //Main admin section
@@ -166,59 +167,12 @@ if(!class_exists('Google_Calendar_Events')){
166
 
167
  //Initialize admin stuff
168
  function init_admin(){
169
- register_setting('gce_options_group', 'gce_options', array($this, 'validate_options'));
170
  register_setting('gce_stylesheet', 'gce_stylesheet', 'esc_url');
171
 
172
- //Setup add feed admin section and all fields
173
  require_once 'admin/add.php';
174
- add_settings_section('gce_add', __('Add a Feed', GCE_TEXT_DOMAIN), 'gce_add_main_text', 'add_feed');
175
- //Unique ID //Title //Function //Page //Section ID
176
- add_settings_field('gce_add_id_field', __('Feed ID', GCE_TEXT_DOMAIN), 'gce_add_id_field', 'add_feed', 'gce_add');
177
- add_settings_field('gce_add_title_id_field', __('Feed Title', GCE_TEXT_DOMAIN), 'gce_add_title_field', 'add_feed', 'gce_add');
178
- add_settings_field('gce_add_url_field', __('Feed URL', GCE_TEXT_DOMAIN), 'gce_add_url_field', 'add_feed', 'gce_add');
179
- add_settings_field('gce_add_show_past_events_field', __('Retrieve past events for current month?', GCE_TEXT_DOMAIN), 'gce_add_show_past_events_field', 'add_feed', 'gce_add');
180
- add_settings_field('gce_add_max_events_field', __('Maximum number of events to retrieve', GCE_TEXT_DOMAIN), 'gce_add_max_events_field', 'add_feed', 'gce_add');
181
- add_settings_field('gce_add_date_format_field', __('Date format', GCE_TEXT_DOMAIN), 'gce_add_date_format_field', 'add_feed', 'gce_add');
182
- add_settings_field('gce_add_time_format_field', __('Time format', GCE_TEXT_DOMAIN), 'gce_add_time_format_field', 'add_feed', 'gce_add');
183
- add_settings_field('gce_add_timezone_field', __('Timezone adjustment', GCE_TEXT_DOMAIN), 'gce_add_timezone_field', 'add_feed', 'gce_add');
184
- add_settings_field('gce_add_cache_duration_field', __('Cache duration', GCE_TEXT_DOMAIN), 'gce_add_cache_duration_field', 'add_feed', 'gce_add');
185
-
186
- add_settings_section('gce_add_display', __('Display Options', GCE_TEXT_DOMAIN), 'gce_add_display_main_text', 'add_display');
187
- add_settings_field('gce_add_display_title_field', __('Display title?', GCE_TEXT_DOMAIN), 'gce_add_display_title_field', 'add_display', 'gce_add_display');
188
- add_settings_field('gce_add_display_start_field', __('Display start time?', GCE_TEXT_DOMAIN), 'gce_add_display_start_field', 'add_display', 'gce_add_display');
189
- add_settings_field('gce_add_display_end_field', __('Display end time and date?', GCE_TEXT_DOMAIN), 'gce_add_display_end_field', 'add_display', 'gce_add_display');
190
- add_settings_field('gce_add_display_location_field', __('Display location?', GCE_TEXT_DOMAIN), 'gce_add_display_location_field', 'add_display', 'gce_add_display');
191
- add_settings_field('gce_add_display_desc_field', __('Display description?', GCE_TEXT_DOMAIN), 'gce_add_display_desc_field', 'add_display', 'gce_add_display');
192
- add_settings_field('gce_add_display_link_field', __('Display link to event?', GCE_TEXT_DOMAIN), 'gce_add_display_link_field', 'add_display', 'gce_add_display');
193
-
194
- //Setup edit feed admin section and all fields
195
  require_once 'admin/edit.php';
196
- add_settings_section('gce_edit', __('Edit Feed', GCE_TEXT_DOMAIN), 'gce_edit_main_text', 'edit_feed');
197
- //Unique ID //Title //Function //Page //Section ID
198
- add_settings_field('gce_edit_id_field', __('Feed ID', GCE_TEXT_DOMAIN), 'gce_edit_id_field', 'edit_feed', 'gce_edit');
199
- add_settings_field('gce_edit_title_field', __('Feed Title', GCE_TEXT_DOMAIN), 'gce_edit_title_field', 'edit_feed', 'gce_edit');
200
- add_settings_field('gce_edit_url_field', __('Feed URL', GCE_TEXT_DOMAIN), 'gce_edit_url_field', 'edit_feed', 'gce_edit');
201
- add_settings_field('gce_edit_show_past_events_field', __('Retrieve past events for current month?', GCE_TEXT_DOMAIN), 'gce_edit_show_past_events_field', 'edit_feed', 'gce_edit');
202
- add_settings_field('gce_edit_max_events_field', __('Maximum number of events to retrieve', GCE_TEXT_DOMAIN), 'gce_edit_max_events_field', 'edit_feed', 'gce_edit');
203
- add_settings_field('gce_edit_date_format_field', __('Date format', GCE_TEXT_DOMAIN), 'gce_edit_date_format_field', 'edit_feed', 'gce_edit');
204
- add_settings_field('gce_edit_time_format_field', __('Time format', GCE_TEXT_DOMAIN), 'gce_edit_time_format_field', 'edit_feed', 'gce_edit');
205
- add_settings_field('gce_edit_timezone_field', __('Timezone adjustment', GCE_TEXT_DOMAIN), 'gce_edit_timezone_field', 'edit_feed', 'gce_edit');
206
- add_settings_field('gce_edit_cache_duration_field', __('Cache duration', GCE_TEXT_DOMAIN), 'gce_edit_cache_duration_field', 'edit_feed', 'gce_edit');
207
-
208
- add_settings_section('gce_edit_display', __('Display Options', GCE_TEXT_DOMAIN), 'gce_edit_display_main_text', 'edit_display');
209
- add_settings_field('gce_edit_display_title_field', __('Display title?', GCE_TEXT_DOMAIN), 'gce_edit_display_title_field', 'edit_display', 'gce_edit_display');
210
- add_settings_field('gce_edit_display_start_field', __('Display start time?', GCE_TEXT_DOMAIN), 'gce_edit_display_start_field', 'edit_display', 'gce_edit_display');
211
- add_settings_field('gce_edit_display_end_field', __('Display end time and date?', GCE_TEXT_DOMAIN), 'gce_edit_display_end_field', 'edit_display', 'gce_edit_display');
212
- add_settings_field('gce_edit_display_location_field', __('Display location?', GCE_TEXT_DOMAIN), 'gce_edit_display_location_field', 'edit_display', 'gce_edit_display');
213
- add_settings_field('gce_edit_display_desc_field', __('Display description?', GCE_TEXT_DOMAIN), 'gce_edit_display_desc_field', 'edit_display', 'gce_edit_display');
214
- add_settings_field('gce_edit_display_link_field', __('Display link to event?', GCE_TEXT_DOMAIN), 'gce_edit_display_link_field', 'edit_display', 'gce_edit_display');
215
-
216
- //Setup delete feed admin section and all fields
217
  require_once 'admin/delete.php';
218
- add_settings_section('gce_delete', __('Delete Feed', GCE_TEXT_DOMAIN), 'gce_delete_main_text', 'delete_feed');
219
- //Unique ID //Title //Function //Page //Section ID
220
- add_settings_field('gce_delete_id_field', __('Feed ID', GCE_TEXT_DOMAIN), 'gce_delete_id_field', 'delete_feed', 'gce_delete');
221
- add_settings_field('gce_delete_title_field', __('Feed Title', GCE_TEXT_DOMAIN), 'gce_delete_title_field', 'delete_feed', 'gce_delete');
222
  }
223
 
224
  //Check / validate submitted data before being stored
@@ -256,16 +210,14 @@ if(!class_exists('Google_Calendar_Events')){
256
  }
257
 
258
  //Tooltip options must be 'on' or null
259
- $display_title = ($input['display_title'] == 'on' ? 'on' : null);
260
- $display_start = ($input['display_start'] == 'on' ? 'on' : null);
261
- $display_end = ($input['display_end'] == 'on' ? 'on' : null);
262
- $display_location = ($input['display_location'] == 'on' ? 'on' : null);
263
- $display_desc = ($input['display_desc'] == 'on' ? 'on' : null);
264
- $display_link = ($input['display_link'] == 'on' ? 'on' : null);
265
- $display_link_target = ($input['display_link_target'] == 'on' ? 'on' : null);
266
-
267
- //Escape display text
268
- $display_title_text = wp_filter_kses($input['display_title_text']);
269
  $display_start_text = wp_filter_kses($input['display_start_text']);
270
  $display_end_text = wp_filter_kses($input['display_end_text']);
271
  $display_location_text = wp_filter_kses($input['display_location_text']);
@@ -283,13 +235,11 @@ if(!class_exists('Google_Calendar_Events')){
283
  'time_format' => $time_format,
284
  'timezone' => $timezone,
285
  'cache_duration' => $cache_duration,
286
- 'display_title' => $display_title,
287
  'display_start' => $display_start,
288
  'display_end' => $display_end,
289
  'display_location' => $display_location,
290
  'display_desc' => $display_desc,
291
  'display_link' => $display_link,
292
- 'display_title_text' => $display_title_text,
293
  'display_start_text' => $display_start_text,
294
  'display_end_text' => $display_end_text,
295
  'display_location_text' => $display_location_text,
@@ -304,28 +254,50 @@ if(!class_exists('Google_Calendar_Events')){
304
 
305
  //Handles the shortcode stuff
306
  function shortcode_handler($atts){
307
- $options = get_option(GCE_OPTIONS_NAME);
308
 
309
  //Check that any feeds have been added
310
  if(is_array($options) && !empty($options)){
311
  extract(shortcode_atts(array(
312
  'id' => '1',
313
- 'type' => 'grid'
 
314
  ), $atts));
315
 
316
- switch($type){
317
- case 'grid':
318
- return gce_print_grid($id);
319
- break;
320
- case 'ajax':
321
- return gce_print_grid($id, true);
322
- break;
323
- case 'list':
324
- return gce_print_list($id);
325
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
  }
327
  }else{
328
- return 'No feeds have been added yet. You can add a feed in the Google Calendar Events settings.';
329
  }
330
  }
331
 
@@ -355,110 +327,42 @@ if(!class_exists('Google_Calendar_Events')){
355
  }
356
  }
357
 
358
- function gce_print_list($feed_id){
359
- //Get saved feed options
360
- $options = get_option(GCE_OPTIONS_NAME);
361
-
362
- //Set time and date formats to WordPress defaults if not set by user
363
- $df = $options[$feed_id]['date_format'];
364
- $tf = $options[$feed_id]['time_format'];
365
- if($df == '') $df = get_option('date_format');
366
- if($tf == '') $tf = get_option('time_format');
367
-
368
- $display_options = array();
369
-
370
- //Add display options text to array if they have been turned on (if turned off, don't add them)
371
- if($options[$feed_id]['display_title'] == 'on') $display_options['title'] = $options[$feed_id]['display_title_text'];
372
- if($options[$feed_id]['display_start'] == 'on') $display_options['start'] = $options[$feed_id]['display_start_text'];
373
- if($options[$feed_id]['display_end'] == 'on') $display_options['end'] = $options[$feed_id]['display_end_text'];
374
- if($options[$feed_id]['display_location'] == 'on') $display_options['location'] = $options[$feed_id]['display_location_text'];
375
- if($options[$feed_id]['display_desc'] == 'on') $display_options['desc'] = $options[$feed_id]['display_desc_text'];
376
- if($options[$feed_id]['display_link'] == 'on')$display_options['link'] = $options[$feed_id]['display_link_text'];
377
- if($options[$feed_id]['display_link_target'] == 'on') $display_options['link_target'] = 'yeps';
378
-
379
-
380
- //Creates a new GCE_Parser object for $feed_id
381
- $feed_data = new GCE_Parser(
382
- $options[$feed_id]['url'],
383
- $options[$feed_id]['show_past_events'],
384
- $options[$feed_id]['max_events'],
385
- $options[$feed_id]['cache_duration'],
386
- $df,
387
- $tf,
388
- $options[$feed_id]['timezone'],
389
- null,
390
- $display_options
391
- );
392
-
393
- //If the feed parsed ok
394
- if($feed_data->parsed_ok()){
395
- $markup = '<div class="gce-page-list">' . $feed_data->get_list() . '</div>';
396
-
397
- return $markup;
398
  }else{
399
- return 'The Google Calendar feed was not parsed successfully, please check that the feed URL is correct.';
400
  }
401
  }
402
 
403
- function gce_print_grid($feed_id, $ajaxified = false, $month = null, $year = null){
404
- //Get saved feed options
405
- $options = get_option(GCE_OPTIONS_NAME);
406
-
407
- //Set time and date formats to WordPress defaults if not set by user
408
- $df = $options[$feed_id]['date_format'];
409
- $tf = $options[$feed_id]['time_format'];
410
- if($df == '') $df = get_option('date_format');
411
- if($tf == '') $tf = get_option('time_format');
412
-
413
- $display_options = array();
414
-
415
- //Add display options text to array if they have been turned on (if turned off, don't add them)
416
- if($options[$feed_id]['display_title'] == 'on') $display_options['title'] = $options[$feed_id]['display_title_text'];
417
- if($options[$feed_id]['display_start'] == 'on') $display_options['start'] = $options[$feed_id]['display_start_text'];
418
- if($options[$feed_id]['display_end'] == 'on') $display_options['end'] = $options[$feed_id]['display_end_text'];
419
- if($options[$feed_id]['display_location'] == 'on') $display_options['location'] = $options[$feed_id]['display_location_text'];
420
- if($options[$feed_id]['display_desc'] == 'on') $display_options['desc'] = $options[$feed_id]['display_desc_text'];
421
- if($options[$feed_id]['display_link'] == 'on') $display_options['link'] = $options[$feed_id]['display_link_text'];
422
- if($options[$feed_id]['display_link_target'] == 'on') $display_options['link_target'] = 'yeps';
423
-
424
- //Creates a new GCE_Parser object for $feed_id
425
- $feed_data = new GCE_Parser(
426
- $options[$feed_id]['url'],
427
- $options[$feed_id]['show_past_events'],
428
- $options[$feed_id]['max_events'],
429
- $options[$feed_id]['cache_duration'],
430
- $df,
431
- $tf,
432
- $options[$feed_id]['timezone'],
433
- get_option('start_of_week'),
434
- $display_options
435
- );
436
-
437
- //If the feed parsed ok
438
- if($feed_data->parsed_ok()){
439
- $markup = '<div class="gce-page-grid" id="gce-page-grid-' . $feed_id .'">';
440
 
441
- //Add AJAX script if required
442
- if($ajaxified){
443
- $markup .= '<script type="text/javascript">jQuery(document).ready(function($){gce_ajaxify("gce-page-grid-' . $feed_id . '", "' . $feed_id . '", "page");});</script>';
444
- }
445
 
446
- $markup .= $feed_data->get_grid($year, $month, $ajaxified);
 
447
 
448
- $markup .= '</div>';
449
- return $markup;
450
  }else{
451
- return 'The Google Calendar feed was not parsed successfully, please check that the feed URL is correct.';
452
  }
453
  }
454
 
455
- function gce_handle_ajax($feed_id, $month = null, $year = null){
456
- echo gce_print_grid($feed_id, true, $month, $year);
457
  }
458
 
459
  if(isset($_GET['gce_type']) && $_GET['gce_type'] == 'page'){
460
- if(isset($_GET['gce_feed_id'])){
461
- gce_handle_ajax($_GET['gce_feed_id'], $_GET['gce_month'], $_GET['gce_year']);
462
  die();
463
  }
464
  }
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
30
  define('GCE_PLUGIN_NAME', str_replace('.php', '', basename(__FILE__)));
31
  define('GCE_TEXT_DOMAIN', 'google-calendar-events');
32
  define('GCE_OPTIONS_NAME', 'gce_options');
33
+ define('GCE_GROUP_OPTIONS_NAME', 'gce_group_options');
34
 
35
  require_once 'widget/gce-widget.php';
36
  require_once 'inc/gce-parser.php';
44
 
45
  //PHP 5 constructor
46
  function __construct(){
47
+ add_action('activate_google-calendar-events/google-calendar-events.php', array($this, 'activate_plugin'));
48
+ add_action('init', array($this, 'init_plugin'));
49
  add_action('admin_menu', array($this, 'setup_admin'));
50
  add_action('admin_init', array($this, 'init_admin'));
 
 
 
 
 
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
 
57
  //If any new options have been added between versions, this will update any saved feeds with defaults for new options (shouldn't overwrite anything saved)
58
+ function activate_plugin(){
59
  add_option(GCE_OPTIONS_NAME);
60
 
61
  $options = get_option(GCE_OPTIONS_NAME);
72
  'time_format' => '',
73
  'timezone' => 'default',
74
  'cache_duration' => 43200,
 
75
  'display_start' => 'on',
76
  'display_end' => '',
77
  'display_location' => '',
78
  'display_desc' => '',
79
  'display_link' => 'on',
 
80
  'display_start_text' => 'Starts:',
81
  'display_end_text' => 'Ends:',
82
  'display_location_text' => 'Location:',
97
  update_option(GCE_OPTIONS_NAME, $options);
98
  }
99
 
100
+ function init_plugin(){
101
+ //Load text domain for i18n
102
+ load_plugin_textdomain(GCE_TEXT_DOMAIN, false, 'languages');
103
+ }
104
+
105
  //Setup admin settings page
106
  function setup_admin(){
107
  if(function_exists('add_options_page')) add_options_page('Google Calendar Events', 'Google Calendar Events', 'manage_options', basename(__FILE__), array($this, 'admin_page'));
113
  if(isset($_GET['updated'])){
114
  switch($_GET['updated']){
115
  case 'added':
116
+ ?><div class="updated"><p><strong><?php _e('New Feed Added Successfully.', GCE_TEXT_DOMAIN); ?></strong></p></div><?php
117
  break;
118
  case 'edited':
119
+ ?><div class="updated"><p><strong><?php _e('Feed Details Updated Successfully.', GCE_TEXT_DOMAIN); ?></strong></p></div><?php
120
  break;
121
  case 'deleted':
122
+ ?><div class="updated"><p><strong><?php _e('Feed Deleted Successfully.', GCE_TEXT_DOMAIN); ?></strong></p></div><?php
 
123
  }
124
  }?>
125
 
126
  <div class="wrap">
127
  <div id="icon-options-general" class="icon32"><br /></div>
128
 
129
+ <h2><?php _e('Google Calendar Events', GCE_TEXT_DOMAIN); ?></h2>
130
  <form method="post" action="options.php" id="test-form">
131
  <?php
 
 
132
  if(isset($_GET['action'])){
133
  switch($_GET['action']){
134
  //Add feed section
135
  case 'add':
136
+ settings_fields('gce_options');
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':
144
+ settings_fields('gce_options');
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
167
 
168
  //Initialize admin stuff
169
  function init_admin(){
170
+ register_setting('gce_options', 'gce_options', array($this, 'validate_options'));
171
  register_setting('gce_stylesheet', 'gce_stylesheet', 'esc_url');
172
 
 
173
  require_once 'admin/add.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  require_once 'admin/edit.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  require_once 'admin/delete.php';
 
 
 
 
176
  }
177
 
178
  //Check / validate submitted data before being stored
210
  }
211
 
212
  //Tooltip options must be 'on' or null
213
+ $display_start = isset($input['display_start']) ? 'on' : null;
214
+ $display_end = isset($input['display_end']) ? 'on' : null;
215
+ $display_location = isset($input['display_location']) ? 'on' : null;
216
+ $display_desc = isset($input['display_desc']) ? 'on' : null;
217
+ $display_link = isset($input['display_link']) ? 'on' : null;
218
+ $display_link_target = isset($input['display_link_target']) ? 'on' : null;
219
+
220
+ //Filter display text
 
 
221
  $display_start_text = wp_filter_kses($input['display_start_text']);
222
  $display_end_text = wp_filter_kses($input['display_end_text']);
223
  $display_location_text = wp_filter_kses($input['display_location_text']);
235
  'time_format' => $time_format,
236
  'timezone' => $timezone,
237
  'cache_duration' => $cache_duration,
 
238
  'display_start' => $display_start,
239
  'display_end' => $display_end,
240
  'display_location' => $display_location,
241
  'display_desc' => $display_desc,
242
  'display_link' => $display_link,
 
243
  'display_start_text' => $display_start_text,
244
  'display_end_text' => $display_end_text,
245
  'display_location_text' => $display_location_text,
254
 
255
  //Handles the shortcode stuff
256
  function shortcode_handler($atts){
257
+ $options = get_option(GCE_OPTIONS_NAME);
258
 
259
  //Check that any feeds have been added
260
  if(is_array($options) && !empty($options)){
261
  extract(shortcode_atts(array(
262
  'id' => '1',
263
+ 'type' => 'grid',
264
+ 'title' => false
265
  ), $atts));
266
 
267
+ //Break comma delimited list of feed ids into array
268
+ $feed_ids = explode(',', str_replace(' ', '', $id));
269
+
270
+ //Check each id is an integer, if not, remove it from the array
271
+ foreach($feed_ids as $key => $feed_id){
272
+ //$feed_ids[$key] = absint($feed_id);
273
+ if(absint($feed_id) == 0) unset($feed_ids[$key]);
274
+ }
275
+
276
+ $no_feeds_exist = true;
277
+
278
+ //If at least one of the feed ids entered exists, set no_feeds_exist to false
279
+ foreach($feed_ids as $feed_id){
280
+ if(isset($options[$feed_id])) $no_feeds_exist = false;
281
+ }
282
+
283
+ //Check that at least one valid feed id has been entered
284
+ if(count((array)$feed_ids) == 0 || $no_feeds_exist){
285
+ return __('No valid Feed IDs have been entered for this shortcode. Please check that you have entered the IDs correctly and that the Feeds have not been deleted.', GCE_TEXT_DOMAIN);
286
+ }else{
287
+ //Turnd feed_ids back into string or feed ids delimited by '-' ('1-2-3-4' for example)
288
+ $feed_ids = implode('-', $feed_ids);
289
+
290
+ //If title has been omitted from shortcode, set title_text to null, otherwise set to title (even if empty string)
291
+ $title_text = ($title === false ? null : $title);
292
+
293
+ switch($type){
294
+ case 'grid': return gce_print_grid($feed_ids, $title_text);
295
+ case 'ajax': return gce_print_grid($feed_ids, $title_text, true);
296
+ case 'list': return gce_print_list($feed_ids, $title_text);
297
+ }
298
  }
299
  }else{
300
+ return __('No feeds have been added yet. You can add a feed in the Google Calendar Events settings.', GCE_TEXT_DOMAIN);
301
  }
302
  }
303
 
327
  }
328
  }
329
 
330
+ function gce_print_list($feed_ids, $title_text){
331
+ //Create new GCE_Parser object, passing array of feed id(s)
332
+ $list = new GCE_Parser(explode('-', $feed_ids), $title_text);
333
+
334
+ //If the feed(s) parsed ok, return the list markup, otherwise return an error message
335
+ if(count($list->get_errors()) == 0){
336
+ return '<div class="gce-page-list">' . $list->get_list() . '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  }else{
338
+ return sprintf(__('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()));
339
  }
340
  }
341
 
342
+ function gce_print_grid($feed_ids, $title_text, $ajaxified = false, $month = null, $year = null){
343
+ //Create new GCE_Parser object, passing array of feed id(s) returned from gce_get_feed_ids()
344
+ $grid = new GCE_Parser(explode('-', $feed_ids), $title_text);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
 
346
+ //If the feed(s) parsed ok, return the grid markup, otherwise return an error message
347
+ if(count($grid->get_errors()) == 0){
348
+ $markup = '<div class="gce-page-grid" id="gce-page-grid-' . $feed_ids .'">';
 
349
 
350
+ //Add AJAX script if required
351
+ if($ajaxified) $markup .= '<script type="text/javascript">jQuery(document).ready(function($){gce_ajaxify("gce-page-grid-' . $feed_ids . '", "' . $feed_ids . '", "' . $title_text . '", "page");});</script>';
352
 
353
+ return $markup . $grid->get_grid($year, $month, $ajaxified) . '</div>';
 
354
  }else{
355
+ return sprintf(__('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(', ', $grid->get_errors()));
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
  }
inc/gce-feed.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once(ABSPATH . WPINC . '/class-feed.php');
3
+ require_once('simplepie-gcalendar.php');
4
+
5
+ class GCE_Feed extends SimplePie_GCalendar{
6
+ var $feed_id;
7
+ var $d_format;
8
+ var $t_format;
9
+ var $display_opts;
10
+
11
+ function GCE_Feed(){
12
+ $this->__construct();
13
+ }
14
+
15
+ function __construct(){
16
+ parent::__construct();
17
+ $this->set_cache_class('WP_Feed_Cache');
18
+ $this->set_file_class('WP_SimplePie_File');
19
+ }
20
+
21
+ //Setters
22
+
23
+ function set_feed_id($id){
24
+ $this->feed_id = $id;
25
+ }
26
+
27
+ function set_date_format($format_string){
28
+ $this->d_format = $format_string;
29
+ }
30
+
31
+ function set_time_format($format_string){
32
+ $this->t_format = $format_string;
33
+ }
34
+
35
+ function set_display_options($display_options){
36
+ $this->display_opts = $display_options;
37
+ }
38
+
39
+ //Getters
40
+
41
+ function get_feed_id(){
42
+ return $this->feed_id;
43
+ }
44
+
45
+ function get_date_format(){
46
+ return $this->d_format;
47
+ }
48
+
49
+ function get_time_format(){
50
+ return $this->t_format;
51
+ }
52
+
53
+ function get_display_options(){
54
+ return $this->display_opts;
55
+ }
56
+ }
57
+ ?>
inc/gce-parser.php CHANGED
@@ -1,57 +1,86 @@
1
  <?php
2
- require_once(ABSPATH . WPINC . '/class-feed.php');
3
- require_once('simplepie-gcalendar.php');
4
 
5
  class GCE_Parser{
6
- var $feed;
7
- var $d_format;
8
- var $t_format;
9
- var $week_start_day;
10
- var $display_options;
11
-
12
- //PHP 4 constructor
13
- function GCE_Parser($feed_url = null, $past_events = false, $max_events = 25, $cache_duration = 43200, $date_format = 'F j, Y', $time_format = 'g:i a', $timezone = 'default', $week_start = 0, $display_opts = array()){
14
- $this->__construct($feed_url, $past_events, $max_events, $cache_duration, $date_format, $timezone, $week_start, $display_opts);
15
- }
16
-
17
- //PHP 5 constructor
18
- function __construct($feed_url = null, $past_events = false, $max_events = 25, $cache_duration = 43200, $date_format = 'F j, Y', $time_format = 'g:i a', $timezone = 'default', $week_start = 0, $display_opts = array()){
19
- $new_feed = new SimplePie_GCalendar(null, null, $cache_duration);
20
- $new_feed->set_cache_class('WP_Feed_Cache');
21
- $new_feed->set_file_class('WP_SimplePie_File');
22
 
23
- $new_feed->set_feed_url($feed_url);
24
-
25
- //Set start date to 1st of this month if $past_events is true (otherwise leave as todays date)
26
- if($past_events == 'true') $new_feed->set_start_date(mktime(0, 0, 0, date('m'), 1, date('Y')));
27
 
28
- if($timezone != 'default') $new_feed->set_timezone($timezone);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
- $new_feed->set_max_events($max_events);
31
- $new_feed->enable_order_by_date(false);
32
 
33
- $new_feed->init();
34
- $new_feed->handle_content_type();
 
35
 
36
- $this->feed = $new_feed;
 
 
37
 
38
- $this->d_format = $date_format;
39
- $this->t_format = $time_format;
40
- $this->week_start_day = $week_start;
41
- $this->display_options = $display_opts;
42
- }
43
 
44
- //Check for SimplePie errors. Return false if an error occurred, otherwise return true
45
- function parsed_ok(){
46
- if($this->feed->error()) return false;
47
- return true;
48
  }
49
 
50
  //Returns array of days with events, with sub-arrays of events for that day
51
  function get_event_days(){
52
  $event_days = array();
53
 
54
- foreach($this->feed->get_items() as $item){
55
  $start_date = $item->get_start_date();
56
 
57
  //Round start date to nearest day
@@ -71,42 +100,6 @@ class GCE_Parser{
71
  return $event_days;
72
  }
73
 
74
- //Returns list markup
75
- function get_list(){
76
- $event_days = $this->get_event_days();
77
-
78
- $markup = '<ul class="gce-list">';
79
-
80
- foreach($event_days as $key => $event_day){
81
- foreach($event_day as $event){
82
- //Get the various information from the event
83
- $event_start_time = date_i18n($this->t_format, $event->get_start_date());
84
- $event_end_time = date_i18n($this->t_format . ' ' . $this->d_format, $event->get_end_date());
85
- $event_location = $event->get_location();
86
- $event_desc = nl2br(make_clickable($event->get_description()));
87
- $event_link = $event->get_link() . '&ctz=' . $this->feed->get_timezone();
88
- $event_link_target = (isset($this->display_options['link_target']) ? ' target="_blank"' : '');
89
-
90
- $markup .= '<li>';
91
-
92
- //Check whether to add each piece of info. If yes, add info (location and desc are also checked if empty, as they may not have been entered when event was created)
93
- if(isset($this->display_options['title'])) $markup .= '<p class="gce-list-title">' . $this->display_options['title'] . ' ' . date_i18n($this->d_format, $key) . '</p>';
94
- $markup .= '<p class="gce-list-event">' . $event->get_title() . '</p>';
95
- if(isset($this->display_options['start'])) $markup .= '<p class="gce-list-start"><span>' . $this->display_options['start'] . '</span> ' . $event_start_time . '</p>';
96
- if(isset($this->display_options['end'])) $markup .= '<p class="gce-list-end"><span>' . $this->display_options['end'] . '</span> ' . $event_end_time . '</p>';
97
- if(isset($this->display_options['location']) && $event_location != '') $markup .= '<p class="gce-list-loc"><span>' . $this->display_options['location'] . '</span> ' . $event_location . '</p>';
98
- if(isset($this->display_options['desc']) && $event_desc != '') $markup .= '<p class="gce-list-desc"><span>' . $this->display_options['desc'] . '</span> ' . $event_desc . '</p>';
99
- if(isset($this->display_options['link'])) $markup .= '<p class="gce-list-link"><a href="' . $event_link . '"' . $event_link_target . '>' . $this->display_options['link'] . '</a></p>';
100
-
101
- $markup .= '</li>';
102
- }
103
- }
104
-
105
- $markup .= '</ul>';
106
-
107
- return $markup;
108
- }
109
-
110
  //Returns grid markup
111
  function get_grid($year = null, $month = null, $ajaxified = false){
112
  require_once('php-calendar.php');
@@ -120,6 +113,8 @@ class GCE_Parser{
120
 
121
  //Get events data
122
  $event_days = $this->get_event_days();
 
 
123
 
124
  $no_more_events = false;
125
 
@@ -131,44 +126,53 @@ class GCE_Parser{
131
  //If this event day is the last in $event_days, there are no more events so set $no_more_events to true
132
  if($event_day === end($event_days)) $no_more_events = true;
133
 
 
 
 
134
  //Create markup for display
135
  $events_markup = '<div class="gce-event-info">';
136
 
137
- //If title option has been set for display, add it
138
- if(isset($this->display_options['title'])) $events_markup .= '<p class="gce-tooltip-title">' . $this->display_options['title'] . ' ' . date_i18n($this->d_format, $key) . '</p>';
139
 
140
  $events_markup .= '<ul>';
141
 
142
  foreach($event_day as $event){
 
 
143
  //Get the various information from the event
144
- $event_start_time = date_i18n($this->t_format, $event->get_start_date());
145
- $event_end_time = date_i18n($this->t_format . ' ' . $this->d_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=' . $this->feed->get_timezone();
149
- $event_link_target = (isset($this->display_options['link_target']) ? ' target="_blank"' : '');
150
 
151
  //Add event title
152
- $events_markup .= '<li><p class="gce-tooltip-event">' . $event->get_title() . '</p>';
153
 
154
  //Check whether to add each piece of info. If yes, add info (location and desc are also checked if empty, as they may not have been entered when event was created)
155
- if(isset($this->display_options['start'])) $events_markup .= '<p class="gce-tooltip-start"><span>' . $this->display_options['start'] . '</span> ' . $event_start_time . '</p>';
156
- if(isset($this->display_options['end'])) $events_markup .= '<p class="gce-tooltip-end"><span>' . $this->display_options['end'] . '</span> ' . $event_end_time . '</p>';
157
- if(isset($this->display_options['location']) && $event_location != '') $events_markup .= '<p class="gce-tooltip-loc"><span>' . $this->display_options['location'] . '</span> ' . $event_location . '</p>';
158
- if(isset($this->display_options['desc']) && $event_desc != '') $events_markup .= '<p class="gce-tooltip-desc"><span>' . $this->display_options['desc'] . '</span> ' . $event_desc . '</p>';
159
- if(isset($this->display_options['link'])) $events_markup .= '<p class="gce-tooltip-link"><a href="' . $event_link . '"' . $event_link_target . '>' . $this->display_options['link'] . '</a></p>';
160
 
161
  $events_markup .= '</li>';
 
 
 
162
  }
163
 
164
  $events_markup .= '</ul></div>';
165
 
166
- //If this event day is 'today', add gce-today class to $css_classes
167
- $css_classes = 'gce-has-events';
168
- if($key == $today) $css_classes .= ' gce-today';
 
169
 
170
  //Change array entry to array of link href, CSS classes, and markup for use in gce_generate_calendar (below)
171
- $event_days[$key] = array(null, $css_classes, $events_markup);
172
  }else{
173
  //Else if event day isn't in month and year specified, remove event day (and all associated events) from the array
174
  unset($event_days[$key]);
@@ -195,7 +199,47 @@ class GCE_Parser{
195
  }
196
 
197
  //Generate the calendar markup and return it
198
- return gce_generate_calendar($year, $month, $event_days, 1, null, $this->week_start_day, $pn);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  }
200
  }
201
  ?>
1
  <?php
2
+ require_once('gce-feed.php');
 
3
 
4
  class GCE_Parser{
5
+ var $feeds = array();
6
+ var $merged_feed_data = array();
7
+ var $title = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ function GCE_Parser($feed_ids, $title_text = null){
10
+ $this->__construct($feed_ids, $title_text);
11
+ }
 
12
 
13
+ function __construct($feed_ids, $title_text = null){
14
+ $this->title = $title_text;
15
+
16
+ //Get the feed options
17
+ $options = get_option(GCE_OPTIONS_NAME);
18
+
19
+ foreach($feed_ids as $single_feed){
20
+ //Get the options for this particular feed
21
+ if(isset($options[$single_feed])){
22
+ $feed_options = $options[$single_feed];
23
+
24
+ $feed = new GCE_Feed();
25
+
26
+ $feed->set_feed_id($feed_options['id']);
27
+ $feed->set_feed_url($feed_options['url']);
28
+ $feed->set_max_events($feed_options['max_events']);
29
+ $feed->set_cache_duration($feed_options['cache_duration']);
30
+ //Set the timezone if anything other than default
31
+ if($feed_options['timezone'] != 'default') $feed->set_timezone($feed_options['timezone']);
32
+ //If show past events is true, set start date to 1st of this month. Otherwise, start date is today
33
+ if($feed_options['show_past_events'] == 'true') $feed->set_start_date(mktime(0, 0, 0, date('m'), 1, date('Y')));
34
+ //Set date and time formats. If they have not been set by user, set to global WordPress formats
35
+ $feed->set_date_format($feed_options['date_format'] == '' ? get_option('date_format') : $feed_options['date_format']);
36
+ $feed->set_time_format($feed_options['time_format'] == '' ? get_option('time_format') : $feed_options['time_format']);
37
+
38
+ //Sets all display options
39
+ $feed->set_display_options(array(
40
+ 'display_start' => $feed_options['display_start'],
41
+ 'display_end' => $feed_options['display_end'],
42
+ 'display_location' => $feed_options['display_location'],
43
+ 'display_desc' => $feed_options['display_desc'],
44
+ 'display_link' => $feed_options['display_link'],
45
+ 'display_start_text' => $feed_options['display_start_text'],
46
+ 'display_end_text' => $feed_options['display_end_text'],
47
+ 'display_location_text' => $feed_options['display_location_text'],
48
+ 'display_desc_text' => $feed_options['display_desc_text'],
49
+ 'display_link_text' => $feed_options['display_link_text'],
50
+ 'display_link_target' => $feed_options['display_link_target']
51
+ ));
52
+
53
+ //SimplePie does the hard work
54
+ $feed->init();
55
+
56
+ //Add feed object to array of feeds
57
+ $this->feeds[$single_feed] = $feed;
58
+ }
59
+ }
60
 
61
+ //More SimplePie magic to merge items from all feeds together
62
+ $this->merged_feed_data = SimplePie::merge_items($this->feeds);
63
 
64
+ //Sort the items by into date order
65
+ usort($this->merged_feed_data, array('SimplePie_Item_GCalendar', 'compare'));
66
+ }
67
 
68
+ //Returns an array of feed ids that have encountered errors
69
+ function get_errors(){
70
+ $errors = array();
71
 
72
+ foreach($this->feeds as $feed){
73
+ if($feed->error()) $errors[] = $feed->get_feed_id();
74
+ }
 
 
75
 
76
+ return $errors;
 
 
 
77
  }
78
 
79
  //Returns array of days with events, with sub-arrays of events for that day
80
  function get_event_days(){
81
  $event_days = array();
82
 
83
+ foreach($this->merged_feed_data as $item){
84
  $start_date = $item->get_start_date();
85
 
86
  //Round start date to nearest day
100
  return $event_days;
101
  }
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  //Returns grid markup
104
  function get_grid($year = null, $month = null, $ajaxified = false){
105
  require_once('php-calendar.php');
113
 
114
  //Get events data
115
  $event_days = $this->get_event_days();
116
+ //If event_days is empty, then there are no events in the feed(s), so set ajaxified to false (Prevents AJAX calendar from allowing to endlessly click through months with no events)
117
+ if(count((array)$event_days) == 0) $ajaxified = false;
118
 
119
  $no_more_events = false;
120
 
126
  //If this event day is the last in $event_days, there are no more events so set $no_more_events to true
127
  if($event_day === end($event_days)) $no_more_events = true;
128
 
129
+ //Create array of CSS classes. Add gce-has-events
130
+ $css_classes = array('gce-has-events');
131
+
132
  //Create markup for display
133
  $events_markup = '<div class="gce-event-info">';
134
 
135
+ //If title option has been set for display, add it Below: this is rubbish, unsure of better alternative
136
+ if(isset($this->title)) $events_markup .= '<p class="gce-tooltip-title">' . $this->title . ' ' . date_i18n($event_day[0]->get_feed()->get_date_format(), $key) . '</p>';
137
 
138
  $events_markup .= '<ul>';
139
 
140
  foreach($event_day as $event){
141
+ $display_options = $event->get_feed()->get_display_options();
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();
149
+ $event_link_target = (isset($display_options['display_link_target']) ? ' target="_blank"' : '');
150
 
151
  //Add event title
152
+ $events_markup .= '<li class="gce-tooltip-feed-' . $event->get_feed()->get_feed_id() . '"><p class="gce-tooltip-event">' . $event->get_title() . '</p>';
153
 
154
  //Check whether to add each piece of info. If yes, add info (location and desc are also checked if empty, as they may not have been entered when event was created)
155
+ if(isset($display_options['display_start'])) $events_markup .= '<p class="gce-tooltip-start"><span>' . $display_options['display_start_text'] . '</span> ' . $event_start_time . '</p>';
156
+ if(isset($display_options['display_end'])) $events_markup .= '<p class="gce-tooltip-end"><span>' . $display_options['display_end_text'] . '</span> ' . $event_end_time . '</p>';
157
+ if(isset($display_options['display_location']) && $event_location != '') $events_markup .= '<p class="gce-tooltip-loc"><span>' . $display_options['display_location_text'] . '</span> ' . $event_location . '</p>';
158
+ if(isset($display_options['display_desc']) && $event_desc != '') $events_markup .= '<p class="gce-tooltip-desc"><span>' . $display_options['display_desc_text'] . '</span> ' . $event_desc . '</p>';
159
+ if(isset($display_options['display_link'])) $events_markup .= '<p class="gce-tooltip-link"><a href="' . $event_link . '"' . $event_link_target . '>' . $display_options['display_link_text'] . '</a></p>';
160
 
161
  $events_markup .= '</li>';
162
+
163
+ //Add CSS class for the feed from which this event comes. If there are multiple events from the same feed on the same day, the CSS class will only be added once.
164
+ $css_classes['feed-' . $event->get_feed()->get_feed_id()] = 'gce-feed-' . $event->get_feed()->get_feed_id();
165
  }
166
 
167
  $events_markup .= '</ul></div>';
168
 
169
+ //If number of CSS classes is greater than 2 ('gce-has-events' plus one specific feed class) then there must be events from multiple feeds on this day, so add gce-multiple CSS class
170
+ if(count($css_classes) > 2) $css_classes[] = 'gce-multiple';
171
+ //If event day is today, add gce-today CSS class
172
+ if($key == $today) $css_classes[] = 'gce-today';
173
 
174
  //Change array entry to array of link href, CSS classes, and markup for use in gce_generate_calendar (below)
175
+ $event_days[$key] = array(null, implode(' ', $css_classes), $events_markup);
176
  }else{
177
  //Else if event day isn't in month and year specified, remove event day (and all associated events) from the array
178
  unset($event_days[$key]);
199
  }
200
 
201
  //Generate the calendar markup and return it
202
+ return gce_generate_calendar($year, $month, $event_days, 1, null, get_option('start_of_week'), $pn);
203
+ }
204
+
205
+ //Returns list markup
206
+ function get_list(){
207
+ $event_days = $this->get_event_days();
208
+ //If event_days is empty, there are no events in the feed(s), so return a message indicating this
209
+ if(count((array)$event_days) == 0) return __('<p>There are currently no upcoming events.</p>', GCE_TEXT_DOMAIN);
210
+
211
+ $markup = '<ul class="gce-list">';
212
+
213
+ foreach($event_days as $key => $event_day){
214
+ foreach($event_day as $event){
215
+ $display_options = $event->get_feed()->get_display_options();
216
+
217
+ //Get the various information from the event
218
+ $event_start_time = date_i18n($event->get_feed()->get_time_format(), $event->get_start_date());
219
+ $event_end_time = date_i18n($event->get_feed()->get_time_format() . ' ' . $event->get_feed()->get_date_format(), $event->get_end_date());
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
+
227
+ //Check whether to add each piece of info. If yes, add info (location and desc are also checked if empty, as they may not have been entered when event was created)
228
+ if(isset($this->title)) $markup .= '<p class="gce-list-title">' . $this->title . ' ' . date_i18n($event->get_feed()->get_date_format(), $key) . '</p>';
229
+ $markup .= '<p class="gce-list-event">' . $event->get_title() . '</p>';
230
+ if(isset($display_options['display_start'])) $markup .= '<p class="gce-list-start"><span>' . $display_options['display_start_text'] . '</span> ' . $event_start_time . '</p>';
231
+ if(isset($display_options['display_end'])) $markup .= '<p class="gce-list-end"><span>' . $display_options['display_end_text'] . '</span> ' . $event_end_time . '</p>';
232
+ if(isset($display_options['display_location']) && $event_location != '') $markup .= '<p class="gce-list-loc"><span>' . $display_options['display_location_text'] . '</span> ' . $event_location . '</p>';
233
+ if(isset($display_options['display_desc']) && $event_desc != '') $markup .= '<p class="gce-list-desc"><span>' . $display_options['display_desc_text'] . '</span> ' . $event_desc . '</p>';
234
+ if(isset($display_options['display_link'])) $markup .= '<p class="gce-list-link"><a href="' . $event_link . '"' . $event_link_target . '>' . $display_options['display_link_text'] . '</a></p>';
235
+
236
+ $markup .= '</li>';
237
+ }
238
+ }
239
+
240
+ $markup .= '</ul>';
241
+
242
+ return $markup;
243
  }
244
  }
245
  ?>
js/gce-script.js CHANGED
@@ -1,4 +1,4 @@
1
- function gce_ajaxify(target, feed_id, type){
2
  //Add click event to change month links
3
  jQuery('#' + target + ' .gce-change-month').click(function(){
4
  //Extract month and year
@@ -6,7 +6,7 @@ function gce_ajaxify(target, feed_id, 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_id:feed_id, 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);
1
+ function gce_ajaxify(target, feed_ids, title_text, type){
2
  //Add click event to change month links
3
  jQuery('#' + target + ' .gce-change-month').click(function(){
4
  //Extract month and year
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);
languages/google-calendar-events.pot ADDED
@@ -0,0 +1,387 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of the WordPress plugin Google Calendar Events 0.2.1 by Ross Hanney.
2
+ # Copyright (C) 2010 Ross Hanney
3
+ # This file is distributed under the same license as the Google Calendar Events package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: Google Calendar Events 0.2.1\n"
10
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/google-calendar-events\n"
11
+ "POT-Creation-Date: 2010-07-26 20:31+0000\n"
12
+ "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=utf-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+
19
+ #: admin/add.php:9
20
+ msgid "Add a Feed"
21
+ msgstr ""
22
+
23
+ #: admin/add.php:11 admin/delete.php:11 admin/edit.php:11
24
+ msgid "Feed ID"
25
+ msgstr ""
26
+
27
+ #: admin/add.php:12 admin/delete.php:12 admin/edit.php:12
28
+ msgid "Feed Title"
29
+ msgstr ""
30
+
31
+ #: admin/add.php:13 admin/edit.php:13
32
+ msgid "Feed URL"
33
+ msgstr ""
34
+
35
+ #: admin/add.php:14 admin/edit.php:14
36
+ msgid "Retrieve past events for current month?"
37
+ msgstr ""
38
+
39
+ #: admin/add.php:15 admin/edit.php:15
40
+ msgid "Maximum number of events to retrieve"
41
+ msgstr ""
42
+
43
+ #: admin/add.php:16 admin/edit.php:16
44
+ msgid "Date format"
45
+ msgstr ""
46
+
47
+ #: admin/add.php:17 admin/edit.php:17
48
+ msgid "Time format"
49
+ msgstr ""
50
+
51
+ #: admin/add.php:18 admin/edit.php:18
52
+ msgid "Timezone adjustment"
53
+ msgstr ""
54
+
55
+ #: admin/add.php:19 admin/edit.php:19
56
+ msgid "Cache duration"
57
+ msgstr ""
58
+
59
+ #: admin/add.php:21 admin/edit.php:21
60
+ msgid "Display Options"
61
+ msgstr ""
62
+
63
+ #: admin/add.php:22 admin/edit.php:22
64
+ msgid "Display start time?"
65
+ msgstr ""
66
+
67
+ #: admin/add.php:23 admin/edit.php:23
68
+ msgid "Display end time and date?"
69
+ msgstr ""
70
+
71
+ #: admin/add.php:24 admin/edit.php:24
72
+ msgid "Display location?"
73
+ msgstr ""
74
+
75
+ #: admin/add.php:25 admin/edit.php:25
76
+ msgid "Display description?"
77
+ msgstr ""
78
+
79
+ #: admin/add.php:26 admin/edit.php:26
80
+ msgid "Display link to event?"
81
+ msgstr ""
82
+
83
+ #: admin/add.php:31
84
+ msgid "Enter the feed details below, then click the Add Feed button."
85
+ msgstr ""
86
+
87
+ #: admin/add.php:55 admin/edit.php:50
88
+ msgid "Anything you like. 'Upcoming Club Events', for example."
89
+ msgstr ""
90
+
91
+ #: admin/add.php:64 admin/edit.php:61
92
+ msgid ""
93
+ "This will probably be something like: 'http://www.google.com/calendar/feeds/"
94
+ "your-email@gmail.com/public/full'."
95
+ msgstr ""
96
+
97
+ #: admin/add.php:73 admin/edit.php:72
98
+ msgid ""
99
+ "Select No to retrieve events from now onwards. Select Yes to retrieve events "
100
+ "from the first of this month onwards."
101
+ msgstr ""
102
+
103
+ #: admin/add.php:75 admin/edit.php:74
104
+ msgid "No"
105
+ msgstr ""
106
+
107
+ #: admin/add.php:77 admin/edit.php:76
108
+ msgid "Yes"
109
+ msgstr ""
110
+
111
+ #: admin/add.php:85 admin/edit.php:86
112
+ msgid ""
113
+ "The default number of events to retrieve from a Google Calendar feed is 25, "
114
+ "but you may want less for a list, or more for a calendar grid."
115
+ msgstr ""
116
+
117
+ #: admin/add.php:94 admin/edit.php:97
118
+ msgid ""
119
+ "In <a href=\"http://php.net/manual/en/function.date.php\">PHP date format</"
120
+ "a>. Leave this blank if you'd rather stick with the default format for your "
121
+ "blog."
122
+ msgstr ""
123
+
124
+ #: admin/add.php:103 admin/edit.php:108
125
+ msgid ""
126
+ "In <a href=\"http://php.net/manual/en/function.date.php\">PHP date format</"
127
+ "a>. Again, leave this blank to stick with the default."
128
+ msgstr ""
129
+
130
+ #: admin/add.php:116 admin/edit.php:123
131
+ msgid ""
132
+ "If you are having problems with dates and times displaying in the wrong "
133
+ "timezone, select a city in your required timezone here."
134
+ msgstr ""
135
+
136
+ #: admin/add.php:125 admin/edit.php:134
137
+ msgid ""
138
+ "The length of time, in seconds, to cache the feed (43200 = 12 hours). If "
139
+ "this feed changes regularly, you may want to reduce the cache duration."
140
+ msgstr ""
141
+
142
+ #: admin/add.php:135 admin/edit.php:144
143
+ msgid ""
144
+ "These settings control what information will be displayed for this feed in "
145
+ "the tooltip (for grids), or in a list."
146
+ msgstr ""
147
+
148
+ #: admin/add.php:136 admin/edit.php:145
149
+ msgid ""
150
+ "You can use some HTML in the text fields, but ensure it is valid or things "
151
+ "might go wonky. Text fields can be empty too."
152
+ msgstr ""
153
+
154
+ #: admin/add.php:143 admin/edit.php:154
155
+ msgid "Show the start time of events?"
156
+ msgstr ""
157
+
158
+ #: admin/add.php:146 admin/edit.php:157
159
+ msgid "Text to display before the start time."
160
+ msgstr ""
161
+
162
+ #: admin/add.php:153 admin/edit.php:166
163
+ msgid ""
164
+ "Show the end time and date of events? (Date will be shown as well as time as "
165
+ "events can span several days)."
166
+ msgstr ""
167
+
168
+ #: admin/add.php:156 admin/edit.php:169
169
+ msgid "Text to display before the end time / date."
170
+ msgstr ""
171
+
172
+ #: admin/add.php:163 admin/edit.php:178
173
+ msgid "Show the location of events?"
174
+ msgstr ""
175
+
176
+ #: admin/add.php:166 admin/edit.php:181
177
+ msgid "Text to display before the location."
178
+ msgstr ""
179
+
180
+ #: admin/add.php:173
181
+ msgid ""
182
+ "Show the description of events? (URLs in the description will be made into "
183
+ "links)."
184
+ msgstr ""
185
+
186
+ #: admin/add.php:176 admin/edit.php:193
187
+ msgid "Text to display before the description."
188
+ msgstr ""
189
+
190
+ #: admin/add.php:183 admin/edit.php:202
191
+ msgid "Show a link to the Google Calendar page for an event?"
192
+ msgstr ""
193
+
194
+ #: admin/add.php:186 admin/edit.php:205
195
+ msgid "Links open in a new window / tab?"
196
+ msgstr ""
197
+
198
+ #: admin/add.php:189 admin/edit.php:208
199
+ msgid "The link text to be displayed."
200
+ msgstr ""
201
+
202
+ #: admin/delete.php:9 google-calendar-events.php:154
203
+ msgid "Delete Feed"
204
+ msgstr ""
205
+
206
+ #: admin/delete.php:17
207
+ msgid ""
208
+ "Are you want you want to delete this feed? (Remember to remove / adjust any "
209
+ "widgets or shortcodes associated with this feed)."
210
+ msgstr ""
211
+
212
+ #: admin/edit.php:9
213
+ msgid "Edit Feed"
214
+ msgstr ""
215
+
216
+ #: admin/edit.php:31
217
+ msgid ""
218
+ "Make any changes you require to the feed details below, then click the Save "
219
+ "Changes button."
220
+ msgstr ""
221
+
222
+ #: admin/edit.php:190
223
+ msgid ""
224
+ "Show the description of events? (URLs in the description will be made into "
225
+ "links)."
226
+ msgstr ""
227
+
228
+ #: admin/main.php:2
229
+ msgid "Add a New Feed"
230
+ msgstr ""
231
+
232
+ #: admin/main.php:4
233
+ msgid "Click here to add a new feed"
234
+ msgstr ""
235
+
236
+ #: admin/main.php:4 google-calendar-events.php:139
237
+ msgid "Add Feed"
238
+ msgstr ""
239
+
240
+ #: admin/main.php:7
241
+ msgid "Current Feeds"
242
+ msgstr ""
243
+
244
+ #: admin/main.php:15
245
+ msgid "You haven't added any Google Calendar feeds yet."
246
+ msgstr ""
247
+
248
+ #: admin/main.php:23 admin/main.php:31
249
+ msgid "ID"
250
+ msgstr ""
251
+
252
+ #: admin/main.php:24 admin/main.php:32
253
+ msgid "Title"
254
+ msgstr ""
255
+
256
+ #: admin/main.php:25 admin/main.php:33
257
+ msgid "URL"
258
+ msgstr ""
259
+
260
+ #: admin/main.php:46
261
+ msgid "Edit"
262
+ msgstr ""
263
+
264
+ #: admin/main.php:48
265
+ msgid "Delete"
266
+ msgstr ""
267
+
268
+ #: admin/main.php:59
269
+ msgid "Custom Stylesheet"
270
+ msgstr ""
271
+
272
+ #: admin/main.php:60
273
+ msgid ""
274
+ "If you would rather use a custom CSS stylesheet than the default, enter the "
275
+ "stylesheet URL below. Leave blank to use the default."
276
+ msgstr ""
277
+
278
+ #: admin/main.php:64
279
+ msgid "Save URL"
280
+ msgstr ""
281
+
282
+ #: google-calendar-events.php:116
283
+ msgid "New Feed Added Successfully."
284
+ msgstr ""
285
+
286
+ #: google-calendar-events.php:119
287
+ msgid "Feed Details Updated Successfully."
288
+ msgstr ""
289
+
290
+ #: google-calendar-events.php:122
291
+ msgid "Feed Deleted Successfully."
292
+ msgstr ""
293
+
294
+ #. #-#-#-#-# plugin.pot (Google Calendar Events 0.2.1) #-#-#-#-#
295
+ #. Plugin Name of the plugin/theme
296
+ #: google-calendar-events.php:129 widget/gce-widget.php:6
297
+ msgid "Google Calendar Events"
298
+ msgstr ""
299
+
300
+ #: google-calendar-events.php:140 google-calendar-events.php:148
301
+ #: google-calendar-events.php:155
302
+ msgid "Cancel"
303
+ msgstr ""
304
+
305
+ #: google-calendar-events.php:147
306
+ msgid "Save Changes"
307
+ msgstr ""
308
+
309
+ #: google-calendar-events.php:285
310
+ msgid ""
311
+ "No valid Feed IDs have been entered for this shortcode. Please check that "
312
+ "you have entered the IDs correctly and that the Feeds have not been deleted."
313
+ msgstr ""
314
+
315
+ #: google-calendar-events.php:300 widget/gce-widget.php:70
316
+ msgid ""
317
+ "No feeds have been added yet. You can add a feed in the Google Calendar "
318
+ "Events settings."
319
+ msgstr ""
320
+
321
+ #: google-calendar-events.php:338 google-calendar-events.php:355
322
+ #: widget/gce-widget.php:139 widget/gce-widget.php:151
323
+ #, php-format
324
+ msgid ""
325
+ "The following feeds were not parsed successfully: %s. Please check that the "
326
+ "feed URLs are correct and that the feeds have public sharing enabled."
327
+ msgstr ""
328
+
329
+ #: inc/gce-parser.php:209
330
+ msgid "<p>There are currently no upcoming events.</p>"
331
+ msgstr ""
332
+
333
+ #: widget/gce-widget.php:6
334
+ msgid ""
335
+ "Display a list or calendar grid of events from one or more Google Calendar "
336
+ "feeds you have added"
337
+ msgstr ""
338
+
339
+ #: widget/gce-widget.php:40
340
+ msgid ""
341
+ "No valid Feed IDs have been entered for this widget. Please check that you "
342
+ "have entered the IDs correctly and that the Feeds have not been deleted."
343
+ msgstr ""
344
+
345
+ #: widget/gce-widget.php:93
346
+ msgid ""
347
+ "No feeds have been added yet. You can add feeds in the Google Calendar "
348
+ "Events settings."
349
+ msgstr ""
350
+
351
+ #: widget/gce-widget.php:107
352
+ msgid "Feed IDs to display in this widget, separated by commas (e.g. 1, 2, 4):"
353
+ msgstr ""
354
+
355
+ #: widget/gce-widget.php:111
356
+ msgid "Display as:"
357
+ msgstr ""
358
+
359
+ #: widget/gce-widget.php:113
360
+ msgid "Calendar Grid"
361
+ msgstr ""
362
+
363
+ #: widget/gce-widget.php:114
364
+ msgid "Calendar Grid - with AJAX"
365
+ msgstr ""
366
+
367
+ #: widget/gce-widget.php:115
368
+ msgid "List"
369
+ msgstr ""
370
+
371
+ #. Plugin URI of the plugin/theme
372
+ msgid "http://www.rhanney.co.uk/plugins/google-calendar-events"
373
+ msgstr ""
374
+
375
+ #. Description of the plugin/theme
376
+ msgid ""
377
+ "Parses Google Calendar feeds and displays the events as a calendar grid or "
378
+ "list on a page, post or widget."
379
+ msgstr ""
380
+
381
+ #. Author of the plugin/theme
382
+ msgid "Ross Hanney"
383
+ msgstr ""
384
+
385
+ #. Author URI of the plugin/theme
386
+ msgid "http://www.rhanney.co.uk"
387
+ msgstr ""
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Google Calendar Events ===
2
  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.2.1
7
 
8
  Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
9
 
@@ -15,11 +15,14 @@ Parses Google Calendar feeds and displays the events as a calendar grid or list
15
 
16
  * Parses Google Calendar feeds to extract events
17
  * Displays events as a list or within a calendar grid
 
18
  * Lists and grids can be displayed in posts, pages or within a widget
19
  * Options to change the number of events retrieved, date / time format, cache duration etc.
20
  * Options to change the information displayed (start time, location, description etc.).
21
  * Calendar grids can have the ability to change month, utilising AJAX
22
 
 
 
23
  Please visit the plugin homepage for how to get started and other help:
24
 
25
  * [Plugin Homepage](http://www.rhanney.co.uk/plugins/google-calendar-events)
@@ -28,9 +31,9 @@ There is also a demonstration page showing the plugin in action:
28
 
29
  * [Demo Page](http://www.rhanney.co.uk/plugins/google-calendar-events/gce-demo)
30
 
31
- For a summary of the new features in 0.2, visit:
32
 
33
- * [0.2 Features](http://www.rhanney.co.uk/2010/07/09/google-calendar-events-0-2)
34
 
35
  == Installation ==
36
 
@@ -54,6 +57,10 @@ You can now start adding feeds. Visit the [plugin homepage](http://www.rhanney.c
54
 
55
  == Changelog ==
56
 
 
 
 
 
57
  = 0.2.1 =
58
  * Added option to allow 'More details' links to open in new window / tab.
59
  * Added option to choose a specific timezone for each feed
@@ -84,8 +91,8 @@ You can now start adding feeds. Visit the [plugin homepage](http://www.rhanney.c
84
 
85
  == Upgrade Notice ==
86
 
87
- = 0.2 =
88
- Customization options for display of information added.
89
 
90
  == Frequently Asked Questions ==
91
 
1
  === Google Calendar Events ===
2
  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
 
15
 
16
  * Parses Google Calendar feeds to extract events
17
  * Displays events as a list or within a calendar grid
18
+ * Events from multiple Google Calendar feeds can be shown in a single list / grid
19
  * Lists and grids can be displayed in posts, pages or within a widget
20
  * Options to change the number of events retrieved, date / time format, cache duration etc.
21
  * Options to change the information displayed (start time, location, description etc.).
22
  * Calendar grids can have the ability to change month, utilising AJAX
23
 
24
+ Anyone upgrading from an earlier version should note that the 'Display title?' option has been moved from the feed settings to the widget / shortcode settings. You will need to re-enter any titles you specified. Visit the 0.3 features link below for more information.
25
+
26
  Please visit the plugin homepage for how to get started and other help:
27
 
28
  * [Plugin Homepage](http://www.rhanney.co.uk/plugins/google-calendar-events)
31
 
32
  * [Demo Page](http://www.rhanney.co.uk/plugins/google-calendar-events/gce-demo)
33
 
34
+ For a summary of the new features in 0.3, visit:
35
 
36
+ * [0.3 Features](http://www.rhanney.co.uk/2010/07/26/google-calendar-events-0-3)
37
 
38
  == Installation ==
39
 
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
63
+
64
  = 0.2.1 =
65
  * Added option to allow 'More details' links to open in new window / tab.
66
  * Added option to choose a specific timezone for each feed
91
 
92
  == Upgrade Notice ==
93
 
94
+ = 0.3 =
95
+ Now supports display of multiple feeds in one grid / list
96
 
97
  == Frequently Asked Questions ==
98
 
widget/gce-widget.php CHANGED
@@ -3,7 +3,7 @@ require_once WP_PLUGIN_DIR . '/' . GCE_PLUGIN_NAME . '/inc/gce-parser.php';
3
 
4
  class GCE_Widget extends WP_Widget{
5
  function GCE_Widget(){
6
- parent::WP_Widget(false, $name = 'Google Calendar Events', array('description' => 'Display a list or calendar grid of events from a Google Calendar feed you have added'));
7
  }
8
 
9
  function widget($args, $instance){
@@ -18,31 +18,56 @@ class GCE_Widget extends WP_Widget{
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
@@ -51,8 +76,11 @@ class GCE_Widget extends WP_Widget{
51
 
52
  function update($new_instance, $old_instance){
53
  $instance = $old_instance;
54
- $instance['id'] = $new_instance['id'];
55
- $instance['display_type'] = $new_instance['display_type'];
 
 
 
56
  return $instance;
57
  }
58
 
@@ -61,129 +89,73 @@ class GCE_Widget extends WP_Widget{
61
  $options = get_option(GCE_OPTIONS_NAME);
62
 
63
  if(empty($options)){
64
- //If no feeds ?>
65
- <p><?php _e('No feeds have been added yet. You can add a feed in the Google Calendar Events settings.', GCE_TEXT_DOMAIN); ?></p>
66
  <?php
67
  }else{
68
- //If there are feeds, select a feed ?>
69
- <p>
70
- <label for="<?php echo $this->get_field_id('id'); ?>"><?php _e('Select a Feed to Use:', GCE_TEXT_DOMAIN); ?></label>
71
- <select id="<?php echo $this->get_field_id('id'); ?>" name="<?php echo $this->get_field_name('id'); ?>" class="widefat">
72
- <?php foreach($options as $key => $feed){ ?>
73
- <option value="<?php echo $key; ?>"<?php selected($instance['id'], $key);?>><?php echo $key . ' - ' . $feed['title']; ?></option>
74
- <?php } ?>
75
- </select>
76
- </p>
77
- <?php //Display type (grid / ajax / list) ?>
78
  <p>
 
 
 
 
 
 
 
 
79
  <label for="<?php echo $this->get_field_id('display_type'); ?>"><?php _e('Display as:', GCE_TEXT_DOMAIN); ?></label>
80
  <select id="<?php echo $this->get_field_id('display_type'); ?>" name="<?php echo $this->get_field_name('display_type'); ?>" class="widefat">
81
- <option value="grid"<?php selected($instance['display_type'], 'grid');?>><?php _e('Calendar Grid', GCE_TEXT_DOMAIN); ?></option>
82
- <option value="ajax"<?php selected($instance['display_type'], 'ajax');?>><?php _e('Calendar Grid - with AJAX', GCE_TEXT_DOMAIN); ?></option>
83
- <option value="list"<?php selected($instance['display_type'], 'list');?>><?php _e('List', GCE_TEXT_DOMAIN); ?></option>
84
  </select>
 
 
 
 
 
85
  </p>
86
  <?php
87
  }
88
  }
89
  }
90
 
91
- //Outputs the main widget content as a calendar grid
92
- function gce_widget_content_grid($feed_id, $widget_id, $ajaxified = false, $month = null, $year = null){
93
- //Get saved feed options
94
- $options = get_option('gce_options');
95
-
96
- //Set time and date formats to WordPress defaults if not set by user
97
- $df = $options[$feed_id]['date_format'];
98
- $tf = $options[$feed_id]['time_format'];
99
- if($df == '') $df = get_option('date_format');
100
- if($tf == '') $tf = get_option('time_format');
101
-
102
- $display_options = array();
103
-
104
- //Add display options text to array if they have been turned on (if turned off, don't add them)
105
- if($options[$feed_id]['display_title'] == 'on') $display_options['title'] = $options[$feed_id]['display_title_text'];
106
- if($options[$feed_id]['display_start'] == 'on') $display_options['start'] = $options[$feed_id]['display_start_text'];
107
- if($options[$feed_id]['display_end'] == 'on') $display_options['end'] = $options[$feed_id]['display_end_text'];
108
- if($options[$feed_id]['display_location'] == 'on') $display_options['location'] = $options[$feed_id]['display_location_text'];
109
- if($options[$feed_id]['display_desc'] == 'on') $display_options['desc'] = $options[$feed_id]['display_desc_text'];
110
- if($options[$feed_id]['display_link'] == 'on') $display_options['link'] = $options[$feed_id]['display_link_text'];
111
- if($options[$feed_id]['display_link_target'] == 'on') $display_options['link_target'] = 'yeps';
112
-
113
- //Creates a new GCE_Parser object for $feed_id
114
- $widget_feed_data = new GCE_Parser(
115
- $options[$feed_id]['url'],
116
- $options[$feed_id]['show_past_events'],
117
- $options[$feed_id]['max_events'],
118
- $options[$feed_id]['cache_duration'],
119
- $df,
120
- $tf,
121
- $options[$feed_id]['timezone'],
122
- get_option('start_of_week'),
123
- $display_options
124
- );
125
-
126
- //Check that feed parsed ok
127
- if($widget_feed_data->parsed_ok()){
128
- //Only add AJAX script if AJAX grid is enabled
129
- if($ajaxified){
130
- ?><script type="text/javascript">jQuery(document).ready(function($){gce_ajaxify("<?php echo $widget_id; ?>", "<?php echo $feed_id; ?>", "widget");});</script><?php
131
- }
132
 
133
- //Outputs calendar grid for specified month and year
134
- echo $widget_feed_data->get_grid($year, $month, $ajaxified);
135
  }else{
136
- echo 'The Google Calendar feed was not parsed successfully, please check that the feed URL is correct.';
137
  }
138
  }
139
 
140
- //Outputs the main widget content as a list of events
141
- function gce_widget_content_list($id){
142
- //Get saved feed options
143
- $options = get_option(GCE_OPTIONS_NAME);
144
-
145
- //Set time and date formats to WordPress defaults if not set by user
146
- $df = $options[$id]['date_format'];
147
- $tf = $options[$id]['time_format'];
148
- if($df == '') $df = get_option('date_format');
149
- if($tf == '') $tf = get_option('time_format');
150
-
151
- $display_options = array();
152
-
153
- //Add display options text to array if they have been turned on (if turned off, don't add them)
154
- if($options[$id]['display_title'] == 'on') $display_options['title'] = $options[$id]['display_title_text'];
155
- if($options[$id]['display_start'] == 'on') $display_options['start'] = $options[$id]['display_start_text'];
156
- if($options[$id]['display_end'] == 'on') $display_options['end'] = $options[$id]['display_end_text'];
157
- if($options[$id]['display_location'] == 'on') $display_options['location'] = $options[$id]['display_location_text'];
158
- if($options[$id]['display_desc'] == 'on') $display_options['desc'] = $options[$id]['display_desc_text'];
159
- if($options[$id]['display_link'] == 'on') $display_options['link'] = $options[$id]['display_link_text'];
160
- if($options[$id]['display_link_target'] == 'on') $display_options['link_target'] = 'yeps';
161
-
162
- //Creates a new GCE_Parser object for $feed_id
163
- $widget_feed_data = new GCE_Parser(
164
- $options[$id]['url'],
165
- $options[$id]['show_past_events'],
166
- $options[$id]['max_events'],
167
- $options[$id]['cache_duration'],
168
- $df,
169
- $tf,
170
- $options[$id]['timezone'],
171
- null,
172
- $display_options
173
- );
174
-
175
- //Check that feed parsed ok
176
- if($widget_feed_data->parsed_ok()){
177
- echo $widget_feed_data->get_list();
178
  }else{
179
- echo 'The Google Calendar feed was not parsed successfully, please check that the feed URL is correct.';
180
  }
181
  }
182
 
183
  //AJAX stuff. Passes the data from JavaScript to above gce_widget_content_grid function
184
  if(isset($_GET['gce_type']) && $_GET['gce_type'] == 'widget'){
185
- if(isset($_GET['gce_feed_id'])){
186
- gce_widget_content_grid($_GET['gce_feed_id'], $_GET['gce_widget_id'], true, $_GET['gce_month'], $_GET['gce_year']);
187
  die();
188
  }
189
  }
3
 
4
  class GCE_Widget extends WP_Widget{
5
  function GCE_Widget(){
6
+ parent::WP_Widget(false, $name = __('Google Calendar Events', GCE_TEXT_DOMAIN), array('description' => __('Display a list or calendar grid of events from one or more Google Calendar feeds you have added', GCE_TEXT_DOMAIN)));
7
  }
8
 
9
  function widget($args, $instance){
18
  //Check whether any feeds have been added yet
19
  if(is_array($options) && !empty($options)){
20
  //Output title stuff
21
+ echo $before_title . $instance['title'] . $after_title;
22
+
23
+ //Break comma delimited list of feed ids into array
24
+ $feed_ids = explode(',', str_replace(' ', '', $instance['id']));
25
+
26
+ //Check each id is an integer, if not, remove it from the array
27
+ foreach($feed_ids as $key => $feed_id){
28
+ if(absint($feed_id) == 0) unset($feed_ids[$key]);
29
+ }
30
+
31
+ $no_feeds_exist = true;
32
+
33
+ //If at least one of the feed ids entered exists, set no_feeds_exist to false
34
+ foreach($feed_ids as $feed_id){
35
+ if(isset($options[$feed_id])) $no_feeds_exist = false;
36
+ }
37
+
38
+ //Check that at least one valid feed id has been entered
39
+ if(count((array)$feed_ids) == 0 || $no_feeds_exist){
40
+ _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);
41
+ }else{
42
+ //Turns feed_ids back into string or feed ids delimited by '-' ('1-2-3-4' for example)
43
+ $feed_ids = implode('-', $feed_ids);
44
+
45
+ $title_text = $instance['display_title'] ? $instance['display_title_text'] : null;
46
+
47
+ //Output correct widget content based on display type chosen
48
+ switch($instance['display_type']){
49
+ case 'grid':
50
+ echo '<div class="gce-widget-grid" id="' . $args['widget_id'] . '-container">';
51
+ //Output main widget content as grid (no AJAX)
52
+ gce_widget_content_grid($feed_ids, $title_text, $args['widget_id'] . '-container');
53
+ echo '</div>';
54
+ break;
55
+ case 'ajax':
56
+ echo '<div class="gce-widget-grid" id="' . $args['widget_id'] . '-container">';
57
+ //Output main widget content as grid (with AJAX)
58
+ gce_widget_content_grid($feed_ids, $title_text, $args['widget_id'] . '-container', true);
59
+ echo '</div>';
60
+ break;
61
+ case 'list':
62
+ echo '<div class="gce-widget-list" id="' . $args['widget_id'] . '-container">';
63
+ //Output main widget content as list
64
+ gce_widget_content_list($feed_ids, $title_text);
65
+ echo '</div>';
66
+ break;
67
+ }
68
  }
69
  }else{
70
+ _e('No feeds have been added yet. You can add a feed in the Google Calendar Events settings.', GCE_TEXT_DOMAIN);
71
  }
72
 
73
  //Output after widget stuff
76
 
77
  function update($new_instance, $old_instance){
78
  $instance = $old_instance;
79
+ $instance['title'] = esc_html($new_instance['title']);
80
+ $instance['id'] = esc_html($new_instance['id']);
81
+ $instance['display_type'] = esc_html($new_instance['display_type']);
82
+ $instance['display_title'] = $new_instance['display_title'] == 'on' ? true : false;
83
+ $instance['display_title_text'] = wp_filter_kses($new_instance['display_title_text']);
84
  return $instance;
85
  }
86
 
89
  $options = get_option(GCE_OPTIONS_NAME);
90
 
91
  if(empty($options)){
92
+ //If no feeds or groups ?>
93
+ <p><?php _e('No feeds have been added yet. You can add feeds in the Google Calendar Events settings.', GCE_TEXT_DOMAIN); ?></p>
94
  <?php
95
  }else{
96
+ $title = isset($instance['title']) ? $instance['title'] : '';
97
+ $ids = isset($instance['id']) ? $instance['id'] : '';
98
+ $display_type = isset($instance['display_type']) ? $instance['display_type'] : 'grid';
99
+ $display_title = isset($instance['display_title']) ? $instance['display_title'] : true;
100
+ $title_text = isset($instance['display_title_text']) ? $instance['display_title_text'] : 'Events on';
101
+ ?>
 
 
 
 
102
  <p>
103
+ <label for="<?php echo $this->get_field_id('title'); ?>">Title:</label>
104
+ <input type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" class="widefat" />
105
+ </p><p>
106
+ <label for="<?php echo $this->get_field_id('id'); ?>">
107
+ <?php _e('Feed IDs to display in this widget, separated by commas (e.g. 1, 2, 4):', GCE_TEXT_DOMAIN); ?>
108
+ </label>
109
+ <input type="text" id="<?php echo $this->get_field_id('id'); ?>" name="<?php echo $this->get_field_name('id'); ?>" value="<?php echo $ids; ?>" class="widefat" />
110
+ </p><p>
111
  <label for="<?php echo $this->get_field_id('display_type'); ?>"><?php _e('Display as:', GCE_TEXT_DOMAIN); ?></label>
112
  <select id="<?php echo $this->get_field_id('display_type'); ?>" name="<?php echo $this->get_field_name('display_type'); ?>" class="widefat">
113
+ <option value="grid"<?php selected($display_type, 'grid');?>><?php _e('Calendar Grid', GCE_TEXT_DOMAIN); ?></option>
114
+ <option value="ajax"<?php selected($display_type, 'ajax');?>><?php _e('Calendar Grid - with AJAX', GCE_TEXT_DOMAIN); ?></option>
115
+ <option value="list"<?php selected($display_type, 'list');?>><?php _e('List', GCE_TEXT_DOMAIN); ?></option>
116
  </select>
117
+ </p><p>
118
+ <label for="<?php echo $this->get_field_id('display_title'); ?>">Display title on tooltip / list item? (e.g. 'Events on 7th March')</label>
119
+ <br />
120
+ <input type="checkbox" id="<?php echo $this->get_field_id('display_title'); ?>" name="<?php echo $this->get_field_name('display_title'); ?>"<?php checked($display_title, true); ?> value="on" />
121
+ <input type="text" id="<?php echo $this->get_field_id('display_title_text'); ?>" name="<?php echo $this->get_field_name('display_title_text'); ?>" value="<?php echo $title_text; ?>" style="width:90%;" />
122
  </p>
123
  <?php
124
  }
125
  }
126
  }
127
 
128
+ function gce_widget_content_grid($feed_ids, $title_text, $widget_id, $ajaxified = false, $month = null, $year = null){
129
+ //Create new GCE_Parser object, passing array of feed id(s)
130
+ $grid = new GCE_Parser(explode('-', $feed_ids), $title_text);
131
+
132
+ //If the feed(s) parsed ok, output the grid markup, otherwise output an error message
133
+ if(count($grid->get_errors()) == 0){
134
+ //Add AJAX script if required
135
+ if($ajaxified) ?><script type="text/javascript">jQuery(document).ready(function($){gce_ajaxify("<?php echo $widget_id; ?>", "<?php echo $feed_ids; ?>", "<?php echo $title_text; ?>", "widget");});</script><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
+ echo $grid->get_grid($year, $month, $ajaxified);
 
138
  }else{
139
+ 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(', ', $grid->get_errors()));
140
  }
141
  }
142
 
143
+ function gce_widget_content_list($feed_ids, $title_text){
144
+ //Create new GCE_Parser object, passing array of feed id(s)
145
+ $list = new GCE_Parser(explode('-', $feed_ids), $title_text);
146
+
147
+ //If the feed(s) parsed ok, output the list markup, otherwise output an error message
148
+ if(count($list->get_errors()) == 0){
149
+ echo $list->get_list();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  }else{
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
  }