Version Description
- Fixed bug causing event dates / times to be displayed in the wrong timezone
- Changed the [link-path] Event Display Builder shortcode to [url]
- Fixed an Opera specific CSS issue causing page lists to be hidden
- Lists can now be displayed in descending or ascending order
- Added [event-id] and [cal-id] Event Display Builder shortcodes
- Added an offset parameter for date / time based Event Display Builder shortcodes
- Added an autolink parameter for enabling / disabling automatic linking of URLs
- Added gce-day-past or gce-day-future classes to calendar grid cells
- Cleaned up CSS
Download this release
Release Info
Developer | rosshanney |
Plugin | Simple Calendar – Google Calendar Plugin |
Version | 0.7 |
Comparing to | |
See all releases |
Code changes from version 0.6 to 0.7
- admin/add.php +176 -162
- admin/edit.php +51 -46
- admin/main.php +7 -0
- admin/refresh.php +13 -13
- css/gce-old-style.css +28 -0
- css/gce-style.css +25 -45
- google-calendar-events.php +309 -246
- inc/gce-event.php +296 -167
- inc/gce-feed.php +79 -65
- inc/gce-parser.php +140 -103
- inc/php-calendar.php +31 -25
- languages/google-calendar-events.pot +403 -306
- readme.txt +18 -13
- uninstall.php +10 -9
- widget/gce-widget.php +118 -94
admin/add.php
CHANGED
@@ -1,55 +1,54 @@
|
|
1 |
<?php
|
2 |
//Redirect to the main plugin options page if form has been submitted
|
3 |
-
if(isset($_GET['action'])){
|
4 |
-
if($_GET['action']
|
5 |
-
wp_redirect(admin_url('options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=added'));
|
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_retrieve_from_field', __('Retrieve events from', GCE_TEXT_DOMAIN), 'gce_add_retrieve_from_field', 'add_feed', 'gce_add');
|
15 |
-
add_settings_field('gce_add_retrieve_until_field', __('Retrieve events until', GCE_TEXT_DOMAIN), 'gce_add_retrieve_until_field', 'add_feed', 'gce_add');
|
16 |
-
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');
|
17 |
-
add_settings_field('gce_add_date_format_field', __('Date format', GCE_TEXT_DOMAIN), 'gce_add_date_format_field', 'add_feed', 'gce_add');
|
18 |
-
add_settings_field('gce_add_time_format_field', __('Time format', GCE_TEXT_DOMAIN), 'gce_add_time_format_field', 'add_feed', 'gce_add');
|
19 |
-
add_settings_field('gce_add_timezone_field', __('Timezone adjustment', GCE_TEXT_DOMAIN), 'gce_add_timezone_field', 'add_feed', 'gce_add');
|
20 |
-
add_settings_field('gce_add_cache_duration_field', __('Cache duration', GCE_TEXT_DOMAIN), 'gce_add_cache_duration_field', 'add_feed', 'gce_add');
|
21 |
-
add_settings_field('gce_add_multiple_field', __('Show multiple day events on each day?', GCE_TEXT_DOMAIN), 'gce_add_multiple_field', 'add_feed', 'gce_add');
|
22 |
|
23 |
-
add_settings_section('gce_add_display', __('Display Options', GCE_TEXT_DOMAIN), 'gce_add_display_main_text', 'add_display');
|
24 |
-
add_settings_field('gce_add_use_builder_field', __('Select display customization method', GCE_TEXT_DOMAIN), 'gce_add_use_builder_field', 'add_display', 'gce_add_display');
|
25 |
|
26 |
-
add_settings_section('gce_add_builder', __('Event Display Builder'), 'gce_add_builder_main_text', 'add_builder');
|
27 |
-
add_settings_field('gce_add_builder_field', __('Event display builder HTML and shortcodes', GCE_TEXT_DOMAIN), 'gce_add_builder_field', 'add_builder', 'gce_add_builder');
|
28 |
|
29 |
-
add_settings_section('gce_add_simple_display', __('Simple Display Options'), 'gce_add_simple_display_main_text', 'add_simple_display');
|
30 |
-
add_settings_field('gce_add_display_start_field', __('Display start time / date?', GCE_TEXT_DOMAIN), 'gce_add_display_start_field', 'add_simple_display', 'gce_add_simple_display');
|
31 |
-
add_settings_field('gce_add_display_end_field', __('Display end time / date?', GCE_TEXT_DOMAIN), 'gce_add_display_end_field', 'add_simple_display', 'gce_add_simple_display');
|
32 |
-
add_settings_field('gce_add_display_separator_field', __('Separator text / characters', GCE_TEXT_DOMAIN), 'gce_add_display_separator_field', 'add_simple_display', 'gce_add_simple_display');
|
33 |
-
add_settings_field('gce_add_display_location_field', __('Display location?', GCE_TEXT_DOMAIN), 'gce_add_display_location_field', 'add_simple_display', 'gce_add_simple_display');
|
34 |
-
add_settings_field('gce_add_display_desc_field', __('Display description?', GCE_TEXT_DOMAIN), 'gce_add_display_desc_field', 'add_simple_display', 'gce_add_simple_display');
|
35 |
-
add_settings_field('gce_add_display_link_field', __('Display link to event?', GCE_TEXT_DOMAIN), 'gce_add_display_link_field', 'add_simple_display', 'gce_add_simple_display');
|
36 |
|
37 |
//Main text
|
38 |
-
function gce_add_main_text(){
|
39 |
?>
|
40 |
-
<p><?php _e('Enter the feed details below, then click the Add Feed button.', GCE_TEXT_DOMAIN); ?></p>
|
41 |
<?php
|
42 |
}
|
43 |
|
44 |
//ID
|
45 |
-
function gce_add_id_field(){
|
46 |
-
$options = get_option(GCE_OPTIONS_NAME);
|
47 |
$id = 1;
|
48 |
-
if(!empty($options)){ //If there are no saved feeds
|
49 |
//Go to last saved feed
|
50 |
-
end($options);
|
51 |
//Set id to last feed id + 1
|
52 |
-
$id = key($options) + 1;
|
53 |
}
|
54 |
|
55 |
?>
|
@@ -59,56 +58,60 @@ function gce_add_id_field(){
|
|
59 |
}
|
60 |
|
61 |
//Title
|
62 |
-
function gce_add_title_field(){
|
63 |
?>
|
64 |
-
<span class="description"><?php _e('Anything you like. \'Upcoming Club Events\', for example.', GCE_TEXT_DOMAIN); ?></span>
|
65 |
<br />
|
66 |
<input type="text" name="gce_options[title]" size="50" />
|
67 |
<?php
|
68 |
}
|
69 |
|
70 |
//URL
|
71 |
-
function gce_add_url_field(){
|
72 |
?>
|
73 |
-
<span class="description"><?php _e('This will probably be something like: <code>http://www.google.com/calendar/feeds/your-email@gmail.com/public/basic</code
|
74 |
<br />
|
75 |
-
<span class="description"><?php _e('or: <code>http://www.google.com/calendar/feeds/your-email@gmail.com/private-d65741b037h695ff274247f90746b2ty/basic</code
|
76 |
<br />
|
77 |
<input type="text" name="gce_options[url]" size="100" class="required" />
|
78 |
<?php
|
79 |
}
|
80 |
|
81 |
//Retrieve events from
|
82 |
-
function gce_add_retrieve_from_field(){
|
83 |
?>
|
84 |
-
<span class="description"
|
|
|
|
|
|
|
|
|
85 |
<br />
|
86 |
<select name="gce_options[retrieve_from]">
|
87 |
-
<option value="now"><?php _e('Now', GCE_TEXT_DOMAIN); ?></option>
|
88 |
-
<option value="today" selected="selected"><?php _e('00:00 today', GCE_TEXT_DOMAIN); ?></option>
|
89 |
-
<option value="week"><?php _e('Start of current week', GCE_TEXT_DOMAIN); ?></option>
|
90 |
-
<option value="month-start"><?php _e('Start of current month', GCE_TEXT_DOMAIN); ?></option>
|
91 |
-
<option value="month-end"><?php _e('End of current month', GCE_TEXT_DOMAIN); ?></option>
|
92 |
-
<option value="any"><?php _e('The beginning of time', GCE_TEXT_DOMAIN); ?></option>
|
93 |
-
<option value="date"><?php _e('Specific date / time', GCE_TEXT_DOMAIN); ?></option>
|
94 |
</select>
|
95 |
<input type="text" name="gce_options[retrieve_from_value]" value="0" />
|
96 |
<?php
|
97 |
}
|
98 |
|
99 |
//Retrieve events until
|
100 |
-
function gce_add_retrieve_until_field(){
|
101 |
?>
|
102 |
-
<span class="description"><?php _e('The point in time at which to stop retrieving events. The instructions for the above option also apply here.', GCE_TEXT_DOMAIN); ?></span>
|
103 |
<br />
|
104 |
<select name="gce_options[retrieve_until]">
|
105 |
-
<option value="now"><?php _e('Now', GCE_TEXT_DOMAIN); ?></option>
|
106 |
-
<option value="today"><?php _e('00:00 today', GCE_TEXT_DOMAIN); ?></option>
|
107 |
-
<option value="week"><?php _e('Start of current week', GCE_TEXT_DOMAIN); ?></option>
|
108 |
-
<option value="month-start"><?php _e('Start of current month', GCE_TEXT_DOMAIN); ?></option>
|
109 |
-
<option value="month-end"><?php _e('End of current month', GCE_TEXT_DOMAIN); ?></option>
|
110 |
-
<option value="any" selected="selected"><?php _e('The end of time', GCE_TEXT_DOMAIN); ?></option>
|
111 |
-
<option value="date"><?php _e('Specific date / time', GCE_TEXT_DOMAIN); ?></option>
|
112 |
|
113 |
</select>
|
114 |
<input type="text" name="gce_options[retrieve_until_value]" value="0" />
|
@@ -116,9 +119,9 @@ function gce_add_retrieve_until_field(){
|
|
116 |
}
|
117 |
|
118 |
//Max events
|
119 |
-
function gce_add_max_events_field(){
|
120 |
?>
|
121 |
-
<span class="description"><?php _e('Set this to a few more than you actually want to display (due to caching and timezone issues). The exact number to display can be configured per shortcode / widget.', GCE_TEXT_DOMAIN); ?></span>
|
122 |
<br />
|
123 |
<input type="text" name="gce_options[max_events]" value="25" size="3" />
|
124 |
<?php
|
@@ -127,7 +130,7 @@ function gce_add_max_events_field(){
|
|
127 |
//Date format
|
128 |
function gce_add_date_format_field(){
|
129 |
?>
|
130 |
-
<span class="description"><?php _e('In <a href="http://php.net/manual/en/function.date.php" target="_blank">PHP date format</a>. Leave this blank if you\'d rather stick with the default format for your blog.', GCE_TEXT_DOMAIN); ?></span>
|
131 |
<br />
|
132 |
<input type="text" name="gce_options[date_format]" />
|
133 |
<?php
|
@@ -136,38 +139,38 @@ function gce_add_date_format_field(){
|
|
136 |
//Time format
|
137 |
function gce_add_time_format_field(){
|
138 |
?>
|
139 |
-
<span class="description"><?php _e('In <a href="http://php.net/manual/en/function.date.php" target="_blank">PHP date format</a>. Again, leave this blank to stick with the default.', GCE_TEXT_DOMAIN); ?></span>
|
140 |
<br />
|
141 |
<input type="text" name="gce_options[time_format]" />
|
142 |
<?php
|
143 |
}
|
144 |
|
145 |
//Timezone offset
|
146 |
-
function gce_add_timezone_field(){
|
147 |
require_once 'timezone-choices.php';
|
148 |
$timezone_list = gce_get_timezone_choices();
|
149 |
//Set selected="selected" for default option
|
150 |
-
$timezone_list = str_replace('<option value="default">Default</option>', '<option value="default" selected="selected">Default</option>', $timezone_list);
|
151 |
?>
|
152 |
-
<span class="description"><?php _e('If you are having problems with dates and times displaying in the wrong timezone, select a city in your required timezone here.', GCE_TEXT_DOMAIN); ?></span>
|
153 |
<br />
|
154 |
<?php echo $timezone_list; ?>
|
155 |
<?php
|
156 |
}
|
157 |
|
158 |
//Cache duration
|
159 |
-
function gce_add_cache_duration_field(){
|
160 |
?>
|
161 |
-
<span class="description"><?php _e('The length of time, in seconds, to cache the feed (43200 = 12 hours). If this feed changes regularly, you may want to reduce the cache duration.', GCE_TEXT_DOMAIN); ?></span>
|
162 |
<br />
|
163 |
<input type="text" name="gce_options[cache_duration]" value="43200" />
|
164 |
<?php
|
165 |
}
|
166 |
|
167 |
//Multiple day events
|
168 |
-
function gce_add_multiple_field(){
|
169 |
?>
|
170 |
-
<span class="description"><?php _e('Show events that span multiple days on each day that they span
|
171 |
<br />
|
172 |
<input type="checkbox" name="gce_options[multiple_day]" value="true" />
|
173 |
<br /><br />
|
@@ -176,185 +179,196 @@ function gce_add_multiple_field(){
|
|
176 |
|
177 |
|
178 |
//Display options
|
179 |
-
function gce_add_display_main_text(){
|
180 |
?>
|
181 |
-
<p><?php _e('These settings control what information will be displayed for this feed in the tooltip (for grids), or in a list.', GCE_TEXT_DOMAIN); ?></p>
|
182 |
<?php
|
183 |
}
|
184 |
|
185 |
-
function gce_add_use_builder_field(){
|
186 |
?>
|
187 |
-
<span class="description"><?php _e('It is recommended that you use the event display builder option, as it provides much more flexibility than the simple display options. The event display builder can do everything the simple display options can, plus lots more!', GCE_TEXT_DOMAIN); ?></span>
|
188 |
<br />
|
189 |
<select name="gce_options[use_builder]">
|
190 |
-
<option value="true" selected="selected"><?php _e('Event display builder', GCE_TEXT_DOMAIN); ?></option>
|
191 |
-
<option value="false"><?php _e('Simple display options', GCE_TEXT_DOMAIN); ?></option>
|
192 |
</select>
|
193 |
<?php
|
194 |
}
|
195 |
|
196 |
//Event display builder
|
197 |
-
function gce_add_builder_main_text(){
|
198 |
?>
|
199 |
-
<p class="gce-event-builder"
|
|
|
|
|
|
|
200 |
<?php
|
201 |
}
|
202 |
|
203 |
-
function gce_add_builder_field(){
|
204 |
?>
|
205 |
<textarea name="gce_options[builder]" rows="10" cols="80">
|
206 |
-
<
|
207 |
-
<
|
208 |
-
<
|
209 |
-
[if-location]<
|
210 |
-
[if-description]<
|
211 |
-
<
|
212 |
-
|
213 |
<br />
|
214 |
-
<p style="margin-top:20px;"
|
215 |
-
|
|
|
|
|
|
|
216 |
<ul>
|
217 |
-
<li><code>[event-title]</code><span class="description"> - <?php _e('The event title (possible attributes: <code>html</code>, <code>markdown</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
218 |
-
<li><code>[start-time]</code><span class="description"> - <?php _e('The event start time. Will use the time format specified in the above settings', GCE_TEXT_DOMAIN); ?></span></li>
|
219 |
-
<li><code>[start-date]</code><span class="description"> - <?php _e('The event start date. Will use the date format specified in the above settings', GCE_TEXT_DOMAIN); ?></span></li>
|
220 |
-
<li><code>[start-custom]</code><span class="description"> - <?php _e('The event start date / time. Will use the format specified in the <code>format</code> attribute (possible attributes: <code>format</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
221 |
-
<li><code>[start-human]</code><span class="description"> - <?php _e('The difference between the start time of the event and the time now, in human-readable format, such as \'1 hour\', \'4 days\', \'15 mins\' (possible attributes: <code>precision</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
222 |
-
<li><code>[end-time]</code><span class="description"> - <?php _e('The event end time. Will use the time format specified in the above settings', GCE_TEXT_DOMAIN); ?></span></li>
|
223 |
-
<li><code>[end-date]</code><span class="description"> - <?php _e('The event end date. Will use the date format specified in the above settings', GCE_TEXT_DOMAIN); ?></span></li>
|
224 |
-
<li><code>[end-custom]</code><span class="description"> - <?php _e('The event end date / time. Will use the format specified in the <code>format</code> attribute (possible attributes: <code>format</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
225 |
-
<li><code>[end-human]</code><span class="description"> - <?php _e('The difference between the end time of the event and the time now, in human-readable format (possible attributes: <code>precision</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
226 |
-
<li><code>[location]</code><span class="description"> - <?php _e('The event location (possible attributes: <code>html</code>, <code>markdown</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
227 |
-
<li><code>[maps-link]…[/maps-link]</code><span class="description"> - <?php _e('Anything between the opening and closing shortcode tags (inlcuding further shortcodes) will be linked to Google Maps, using the event location as a search parameter (possible attributes: <code>newwindow</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
228 |
-
<li><code>[description]</code><span class="description"> - <?php _e('The event description (possible attributes: <code>html</code>, <code>markdown</code>, <code>limit</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
229 |
-
<li><code>[link]…[/link]</code><span class="description"> - <?php _e('Anything between the opening and closing shortcode tags (inlcuding further shortcodes) will be linked to the Google Calendar page for the event (possible attributes: <code>newwindow</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
230 |
-
<li><code>[
|
231 |
-
<li><code>[length]</code><span class="description"> - <?php _e('The length of the event, in human-readable format (possible attributes: <code>precision</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
|
|
|
|
232 |
</ul>
|
233 |
-
<h4><?php _e('Feed information shortcodes:', GCE_TEXT_DOMAIN); ?></h4>
|
234 |
<ul>
|
235 |
-
<li><code>[feed-title]</code><span class="description"> - <?php _e('The title of the feed from which the event comes', GCE_TEXT_DOMAIN); ?></span></li>
|
236 |
-
<li><code>[feed-id]</code><span class="description"> - <?php _e('The ID of the feed from which the event comes', GCE_TEXT_DOMAIN); ?></span></li>
|
|
|
237 |
</ul>
|
238 |
-
<h4><?php _e('Conditional shortcodes:', GCE_TEXT_DOMAIN); ?></h4>
|
239 |
-
<p class="description" style="margin-bottom:18px;"><?php _e('Anything entered between the opening and closing tags of each of the following shortcodes will only be displayed if its condition (below) is met.', GCE_TEXT_DOMAIN); ?></p>
|
240 |
<ul>
|
241 |
-
<li><code>[if-all-day]…[/if-all-day]</code><span class="description"> - <?php _e('The event is an all-day event', GCE_TEXT_DOMAIN); ?></span></li>
|
242 |
-
<li><code>[if-not-all-day]…[/if-not-all-day]</code><span class="description"> - <?php _e('The event is not an all-day event', GCE_TEXT_DOMAIN); ?></span></li>
|
243 |
-
<li><code>[if-title]…[/if-title]</code><span class="description"> - <?php _e('The event has a title', GCE_TEXT_DOMAIN); ?></span></li>
|
244 |
-
<li><code>[if-description]…[/if-description]</code><span class="description"> - <?php _e('The event has a description', GCE_TEXT_DOMAIN); ?></span></li>
|
245 |
-
<li><code>[if-location]…[/if-location]</code><span class="description"> - <?php _e('The event has a location', GCE_TEXT_DOMAIN); ?></span></li>
|
246 |
-
<li><code>[if-tooltip]…[/if-tooltip]</code><span class="description"> - <?php _e('The event is to be displayed in a tooltip (not a list)', GCE_TEXT_DOMAIN); ?></span></li>
|
247 |
-
<li><code>[if-list]…[/if-list]</code><span class="description"> - <?php _e('The event is to be displayed in a list (not a tooltip)', GCE_TEXT_DOMAIN); ?></span></li>
|
248 |
-
<li><code>[if-now]…[/if-now]</code><span class="description"> - <?php _e('The event is taking place now (after the start time, but before the end time)', GCE_TEXT_DOMAIN); ?></span></li>
|
249 |
-
<li><code>[if-not-now]…[/if-not-now]</code><span class="description"> - <?php _e('The event is not taking place now (may have ended or not yet started)', GCE_TEXT_DOMAIN); ?></span></li>
|
250 |
-
<li><code>[if-started]…[/if-started]</code><span class="description"> - <?php _e('The event has started (even if it has also ended)', GCE_TEXT_DOMAIN); ?></span></li>
|
251 |
-
<li><code>[if-not-started]…[/if-not-started]</code><span class="description"> - <?php _e('The event has not started', GCE_TEXT_DOMAIN); ?></span></li>
|
252 |
-
<li><code>[if-ended]…[/if-ended]</code><span class="description"> - <?php _e('The event has ended', GCE_TEXT_DOMAIN); ?></span></li>
|
253 |
-
<li><code>[if-not-ended]…[/if-not-ended]</code><span class="description"> - <?php _e('The event has not ended (even if it hasn\'t started)', GCE_TEXT_DOMAIN); ?></span></li>
|
254 |
-
<li><code>[if-first]…[/if-first]</code><span class="description"> - <?php _e('The event is the first of the day', GCE_TEXT_DOMAIN); ?></span></li>
|
255 |
-
<li><code>[if-not-first]…[/if-not-first]</code><span class="description"> - <?php _e('The event is not the first of the day', GCE_TEXT_DOMAIN); ?></span></li>
|
256 |
-
<li><code>[if-multi-day]…[/if-multi-day]</code><span class="description"> - <?php _e('The event spans multiple days', GCE_TEXT_DOMAIN); ?></span></li>
|
257 |
-
<li><code>[if-single-day]…[/if-single-day]</code><span class="description"> - <?php _e('The event does not span multiple days', GCE_TEXT_DOMAIN); ?></span></li>
|
258 |
</ul>
|
259 |
-
<h4><?php _e('Attributes:', GCE_TEXT_DOMAIN); ?></h4>
|
260 |
-
<p class="description" style="margin-bottom:18px;"><?php _e('The possible attributes mentioned above are explained here:', GCE_TEXT_DOMAIN); ?></p>
|
261 |
<ul>
|
262 |
-
<li><code>html</code><span class="description"> - <?php _e('Whether or not to parse HTML that has been entered in the relevant field. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN); ?></span></li>
|
263 |
-
<li><code>markdown</code><span class="description"> - <?php _e('Whether or not to parse <a href="http://daringfireball.net/projects/markdown" target="_blank">Markdown</a> that has been entered in the relevant field. <a href="http://michelf.com/projects/php-markdown" target="_blank">PHP Markdown</a> must be installed for this to work. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN); ?></span></li>
|
264 |
-
<li><code>limit</code><span class="description"> - <?php _e('The word limit for the field. Should be specified as a positive integer', GCE_TEXT_DOMAIN); ?></span></li>
|
265 |
-
<li><code>format</code><span class="description"> - <?php _e('The date / time format to use. Should specified as a <a href="http://php.net/manual/en/function.date.php" target="_blank">PHP date format</a> string', GCE_TEXT_DOMAIN); ?></span></li>
|
266 |
-
<li><code>newwindow</code><span class="description"> - <?php _e('Whether or not the link should open in a new window / tab. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN); ?></span></li>
|
267 |
-
<li><code>precision</code><span class="description"> - <?php _e('How precise to be when displaying a time difference in human-readable format. Should be specified as a positive integer', GCE_TEXT_DOMAIN); ?></span></li>
|
|
|
|
|
268 |
</ul>
|
269 |
<?php
|
270 |
}
|
271 |
|
272 |
//Simple display options
|
273 |
-
function gce_add_simple_display_main_text(){
|
274 |
?>
|
275 |
-
<p class="gce-simple-display-options"><?php _e('You can use some HTML in the text fields, but ensure it is valid or things might go wonky. Text fields can be empty too.', GCE_TEXT_DOMAIN); ?></p>
|
276 |
<?php
|
277 |
}
|
278 |
|
279 |
-
function gce_add_display_start_field(){
|
280 |
?>
|
281 |
-
<span class="description"><?php _e('Select how to display the start date / time.', GCE_TEXT_DOMAIN); ?></span>
|
282 |
<br />
|
283 |
<select name="gce_options[display_start]">
|
284 |
-
<option value="none"><?php _e('Don\'t display start time or date', GCE_TEXT_DOMAIN); ?></option>
|
285 |
-
<option value="time" selected="selected"><?php _e('Display start time', GCE_TEXT_DOMAIN); ?></option>
|
286 |
-
<option value="date"><?php _e('Display start date', GCE_TEXT_DOMAIN); ?></option>
|
287 |
-
<option value="time-date"><?php _e('Display start time and date (in that order)', GCE_TEXT_DOMAIN); ?></option>
|
288 |
-
<option value="date-time"><?php _e('Display start date and time (in that order)', GCE_TEXT_DOMAIN); ?></option>
|
289 |
</select>
|
290 |
<br /><br />
|
291 |
-
<span class="description"><?php _e('Text to display before the start time.', GCE_TEXT_DOMAIN); ?></span>
|
292 |
<br />
|
293 |
<input type="text" name="gce_options[display_start_text]" value="Starts:" />
|
294 |
<?php
|
295 |
}
|
296 |
|
297 |
-
function gce_add_display_end_field(){
|
298 |
?>
|
299 |
-
<span class="description"><?php _e('Select how to display the end date / time.', GCE_TEXT_DOMAIN); ?></span>
|
300 |
<br />
|
301 |
<select name="gce_options[display_end]">
|
302 |
-
<option value="none"><?php _e('Don\'t display end time or date', GCE_TEXT_DOMAIN); ?></option>
|
303 |
-
<option value="time"><?php _e('Display end time', GCE_TEXT_DOMAIN); ?></option>
|
304 |
-
<option value="date"><?php _e('Display end date', GCE_TEXT_DOMAIN); ?></option>
|
305 |
-
<option value="time-date" selected="selected"><?php _e('Display end time and date (in that order)', GCE_TEXT_DOMAIN); ?></option>
|
306 |
-
<option value="date-time"><?php _e('Display end date and time (in that order)', GCE_TEXT_DOMAIN); ?></option>
|
307 |
</select>
|
308 |
<br /><br />
|
309 |
-
<span class="description"><?php _e('Text to display before the end time.', GCE_TEXT_DOMAIN); ?></span>
|
310 |
<br />
|
311 |
<input type="text" name="gce_options[display_end_text]" value="Ends:" />
|
312 |
<?php
|
313 |
}
|
314 |
|
315 |
-
function gce_add_display_separator_field(){
|
316 |
?>
|
317 |
-
<span class="description"><?php _e('If you have chosen to display both the time and date above, enter the text / characters to display between the time and date here (including any spaces).', GCE_TEXT_DOMAIN); ?></span>
|
318 |
<br />
|
319 |
<input type="text" name="gce_options[display_separator]" value=", " />
|
320 |
<?php
|
321 |
}
|
322 |
|
323 |
-
function gce_add_display_location_field(){
|
324 |
?>
|
325 |
<input type="checkbox" name="gce_options[display_location]" value="on" />
|
326 |
-
<span class="description"><?php _e('Show the location of events?', GCE_TEXT_DOMAIN); ?></span>
|
327 |
<br /><br />
|
328 |
-
<span class="description"><?php _e('Text to display before the location.', GCE_TEXT_DOMAIN); ?></span>
|
329 |
<br />
|
330 |
<input type="text" name="gce_options[display_location_text]" value="Location:" />
|
331 |
<?php
|
332 |
}
|
333 |
|
334 |
-
function gce_add_display_desc_field(){
|
335 |
?>
|
336 |
<input type="checkbox" name="gce_options[display_desc]" value="on" />
|
337 |
-
<span class="description"><?php _e('Show the description of events? (URLs in the description will be made into links).', GCE_TEXT_DOMAIN); ?></span>
|
338 |
<br /><br />
|
339 |
-
<span class="description"><?php _e('Text to display before the description.', GCE_TEXT_DOMAIN); ?></span>
|
340 |
<br />
|
341 |
<input type="text" name="gce_options[display_desc_text]" value="Description:" />
|
342 |
<br /><br />
|
343 |
-
<span class="description"><?php _e('Maximum number of words to show from description. Leave blank for no limit.', GCE_TEXT_DOMAIN); ?></span>
|
344 |
<br />
|
345 |
<input type="text" name="gce_options[display_desc_limit]" size="3" />
|
346 |
<?php
|
347 |
}
|
348 |
|
349 |
-
function gce_add_display_link_field(){
|
350 |
?>
|
351 |
<input type="checkbox" name="gce_options[display_link]" value="on" checked="checked" />
|
352 |
-
<span class="description"><?php _e('Show a link to the Google Calendar page for an event?', GCE_TEXT_DOMAIN); ?></span>
|
353 |
<br />
|
354 |
<input type="checkbox" name="gce_options[display_link_target]" value="on" />
|
355 |
-
<span class="description"><?php _e('Links open in a new window / tab?', GCE_TEXT_DOMAIN); ?></span>
|
356 |
<br /><br />
|
357 |
-
<span class="description"><?php _e('The link text to be displayed.', GCE_TEXT_DOMAIN); ?></span>
|
358 |
<br />
|
359 |
<input type="text" name="gce_options[display_link_text]" value="More details" />
|
360 |
<?php
|
1 |
<?php
|
2 |
//Redirect to the main plugin options page if form has been submitted
|
3 |
+
if ( isset( $_GET['action'] ) ) {
|
4 |
+
if ( 'add' == $_GET['action'] && isset( $_GET['updated'] ) )
|
5 |
+
wp_redirect( admin_url( 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=added' ) );
|
|
|
6 |
}
|
7 |
|
8 |
+
add_settings_section( 'gce_add', __( 'Add a Feed', GCE_TEXT_DOMAIN ), 'gce_add_main_text', 'add_feed' );
|
9 |
//Unique ID //Title //Function //Page //Section ID
|
10 |
+
add_settings_field( 'gce_add_id_field', __( 'Feed ID', GCE_TEXT_DOMAIN ), 'gce_add_id_field', 'add_feed', 'gce_add' );
|
11 |
+
add_settings_field( 'gce_add_title_field', __( 'Feed Title', GCE_TEXT_DOMAIN ), 'gce_add_title_field', 'add_feed', 'gce_add' );
|
12 |
+
add_settings_field( 'gce_add_url_field', __( 'Feed URL', GCE_TEXT_DOMAIN ), 'gce_add_url_field', 'add_feed', 'gce_add' );
|
13 |
+
add_settings_field( 'gce_add_retrieve_from_field', __( 'Retrieve events from', GCE_TEXT_DOMAIN ), 'gce_add_retrieve_from_field', 'add_feed', 'gce_add' );
|
14 |
+
add_settings_field( 'gce_add_retrieve_until_field', __( 'Retrieve events until', GCE_TEXT_DOMAIN ), 'gce_add_retrieve_until_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 |
+
add_settings_field( 'gce_add_multiple_field', __( 'Show multiple day events on each day?', GCE_TEXT_DOMAIN ), 'gce_add_multiple_field', 'add_feed', 'gce_add' );
|
21 |
|
22 |
+
add_settings_section( 'gce_add_display', __( 'Display Options', GCE_TEXT_DOMAIN ), 'gce_add_display_main_text', 'add_display' );
|
23 |
+
add_settings_field( 'gce_add_use_builder_field', __( 'Select display customization method', GCE_TEXT_DOMAIN ), 'gce_add_use_builder_field', 'add_display', 'gce_add_display' );
|
24 |
|
25 |
+
add_settings_section( 'gce_add_builder', __( 'Event Display Builder' ), 'gce_add_builder_main_text', 'add_builder' );
|
26 |
+
add_settings_field( 'gce_add_builder_field', __( 'Event display builder HTML and shortcodes', GCE_TEXT_DOMAIN ), 'gce_add_builder_field', 'add_builder', 'gce_add_builder' );
|
27 |
|
28 |
+
add_settings_section( 'gce_add_simple_display', __('Simple Display Options'), 'gce_add_simple_display_main_text', 'add_simple_display' );
|
29 |
+
add_settings_field( 'gce_add_display_start_field', __( 'Display start time / date?', GCE_TEXT_DOMAIN ), 'gce_add_display_start_field', 'add_simple_display', 'gce_add_simple_display' );
|
30 |
+
add_settings_field( 'gce_add_display_end_field', __( 'Display end time / date?', GCE_TEXT_DOMAIN ), 'gce_add_display_end_field', 'add_simple_display', 'gce_add_simple_display' );
|
31 |
+
add_settings_field( 'gce_add_display_separator_field', __( 'Separator text / characters', GCE_TEXT_DOMAIN ), 'gce_add_display_separator_field', 'add_simple_display', 'gce_add_simple_display' );
|
32 |
+
add_settings_field( 'gce_add_display_location_field', __( 'Display location?', GCE_TEXT_DOMAIN ), 'gce_add_display_location_field', 'add_simple_display', 'gce_add_simple_display' );
|
33 |
+
add_settings_field( 'gce_add_display_desc_field', __( 'Display description?', GCE_TEXT_DOMAIN ), 'gce_add_display_desc_field', 'add_simple_display', 'gce_add_simple_display' );
|
34 |
+
add_settings_field( 'gce_add_display_link_field', __( 'Display link to event?', GCE_TEXT_DOMAIN ), 'gce_add_display_link_field', 'add_simple_display', 'gce_add_simple_display' );
|
35 |
|
36 |
//Main text
|
37 |
+
function gce_add_main_text() {
|
38 |
?>
|
39 |
+
<p><?php _e( 'Enter the feed details below, then click the Add Feed button.', GCE_TEXT_DOMAIN ); ?></p>
|
40 |
<?php
|
41 |
}
|
42 |
|
43 |
//ID
|
44 |
+
function gce_add_id_field() {
|
45 |
+
$options = get_option( GCE_OPTIONS_NAME );
|
46 |
$id = 1;
|
47 |
+
if ( !empty( $options ) ) { //If there are no saved feeds
|
48 |
//Go to last saved feed
|
49 |
+
end( $options );
|
50 |
//Set id to last feed id + 1
|
51 |
+
$id = key( $options ) + 1;
|
52 |
}
|
53 |
|
54 |
?>
|
58 |
}
|
59 |
|
60 |
//Title
|
61 |
+
function gce_add_title_field() {
|
62 |
?>
|
63 |
+
<span class="description"><?php _e( 'Anything you like. \'Upcoming Club Events\', for example.', GCE_TEXT_DOMAIN ); ?></span>
|
64 |
<br />
|
65 |
<input type="text" name="gce_options[title]" size="50" />
|
66 |
<?php
|
67 |
}
|
68 |
|
69 |
//URL
|
70 |
+
function gce_add_url_field() {
|
71 |
?>
|
72 |
+
<span class="description"><?php _e( 'This will probably be something like:', GCE_TEXT_DOMAIN ); ?> <code>http://www.google.com/calendar/feeds/your-email@gmail.com/public/basic</code>.</span>
|
73 |
<br />
|
74 |
+
<span class="description"><?php _e( 'or:', GCE_TEXT_DOMAIN ); ?> <code>http://www.google.com/calendar/feeds/your-email@gmail.com/private-d65741b037h695ff274247f90746b2ty/basic</code>.</span>
|
75 |
<br />
|
76 |
<input type="text" name="gce_options[url]" size="100" class="required" />
|
77 |
<?php
|
78 |
}
|
79 |
|
80 |
//Retrieve events from
|
81 |
+
function gce_add_retrieve_from_field() {
|
82 |
?>
|
83 |
+
<span class="description">
|
84 |
+
<?php _e( 'The point in time at which to start retrieving events. Use the text-box to specify an additional offset from you chosen start point. The offset should be provided in seconds (3600 = 1 hour, 86400 = 1 day) and can be negative. If you have selected the \'Specific date / time\' option, enter a', GCE_TEXT_DOMAIN ); ?>
|
85 |
+
<a href="http://www.timestampgenerator.com" target="_blank"><?php _e( 'UNIX timestamp', GCE_TEXT_DOMAIN ); ?></a>
|
86 |
+
<?php _e( 'in the text-box.', GCE_TEXT_DOMAIN ); ?>
|
87 |
+
</span>
|
88 |
<br />
|
89 |
<select name="gce_options[retrieve_from]">
|
90 |
+
<option value="now"><?php _e( 'Now', GCE_TEXT_DOMAIN ); ?></option>
|
91 |
+
<option value="today" selected="selected"><?php _e( '00:00 today', GCE_TEXT_DOMAIN ); ?></option>
|
92 |
+
<option value="week"><?php _e( 'Start of current week', GCE_TEXT_DOMAIN ); ?></option>
|
93 |
+
<option value="month-start"><?php _e( 'Start of current month', GCE_TEXT_DOMAIN ); ?></option>
|
94 |
+
<option value="month-end"><?php _e( 'End of current month', GCE_TEXT_DOMAIN ); ?></option>
|
95 |
+
<option value="any"><?php _e( 'The beginning of time', GCE_TEXT_DOMAIN ); ?></option>
|
96 |
+
<option value="date"><?php _e( 'Specific date / time', GCE_TEXT_DOMAIN ); ?></option>
|
97 |
</select>
|
98 |
<input type="text" name="gce_options[retrieve_from_value]" value="0" />
|
99 |
<?php
|
100 |
}
|
101 |
|
102 |
//Retrieve events until
|
103 |
+
function gce_add_retrieve_until_field() {
|
104 |
?>
|
105 |
+
<span class="description"><?php _e( 'The point in time at which to stop retrieving events. The instructions for the above option also apply here.', GCE_TEXT_DOMAIN ); ?></span>
|
106 |
<br />
|
107 |
<select name="gce_options[retrieve_until]">
|
108 |
+
<option value="now"><?php _e( 'Now', GCE_TEXT_DOMAIN ); ?></option>
|
109 |
+
<option value="today"><?php _e( '00:00 today', GCE_TEXT_DOMAIN ); ?></option>
|
110 |
+
<option value="week"><?php _e( 'Start of current week', GCE_TEXT_DOMAIN ); ?></option>
|
111 |
+
<option value="month-start"><?php _e( 'Start of current month', GCE_TEXT_DOMAIN ); ?></option>
|
112 |
+
<option value="month-end"><?php _e( 'End of current month', GCE_TEXT_DOMAIN ); ?></option>
|
113 |
+
<option value="any" selected="selected"><?php _e( 'The end of time', GCE_TEXT_DOMAIN ); ?></option>
|
114 |
+
<option value="date"><?php _e( 'Specific date / time', GCE_TEXT_DOMAIN ); ?></option>
|
115 |
|
116 |
</select>
|
117 |
<input type="text" name="gce_options[retrieve_until_value]" value="0" />
|
119 |
}
|
120 |
|
121 |
//Max events
|
122 |
+
function gce_add_max_events_field() {
|
123 |
?>
|
124 |
+
<span class="description"><?php _e( 'Set this to a few more than you actually want to display (due to caching and timezone issues). The exact number to display can be configured per shortcode / widget.', GCE_TEXT_DOMAIN ); ?></span>
|
125 |
<br />
|
126 |
<input type="text" name="gce_options[max_events]" value="25" size="3" />
|
127 |
<?php
|
130 |
//Date format
|
131 |
function gce_add_date_format_field(){
|
132 |
?>
|
133 |
+
<span class="description"><?php _e( 'In <a href="http://php.net/manual/en/function.date.php" target="_blank">PHP date format</a>. Leave this blank if you\'d rather stick with the default format for your blog.', GCE_TEXT_DOMAIN ); ?></span>
|
134 |
<br />
|
135 |
<input type="text" name="gce_options[date_format]" />
|
136 |
<?php
|
139 |
//Time format
|
140 |
function gce_add_time_format_field(){
|
141 |
?>
|
142 |
+
<span class="description"><?php _e( 'In <a href="http://php.net/manual/en/function.date.php" target="_blank">PHP date format</a>. Again, leave this blank to stick with the default.', GCE_TEXT_DOMAIN ); ?></span>
|
143 |
<br />
|
144 |
<input type="text" name="gce_options[time_format]" />
|
145 |
<?php
|
146 |
}
|
147 |
|
148 |
//Timezone offset
|
149 |
+
function gce_add_timezone_field() {
|
150 |
require_once 'timezone-choices.php';
|
151 |
$timezone_list = gce_get_timezone_choices();
|
152 |
//Set selected="selected" for default option
|
153 |
+
$timezone_list = str_replace( '<option value="default">Default</option>', '<option value="default" selected="selected">Default</option>', $timezone_list );
|
154 |
?>
|
155 |
+
<span class="description"><?php _e( 'If you are having problems with dates and times displaying in the wrong timezone, select a city in your required timezone here.', GCE_TEXT_DOMAIN ); ?></span>
|
156 |
<br />
|
157 |
<?php echo $timezone_list; ?>
|
158 |
<?php
|
159 |
}
|
160 |
|
161 |
//Cache duration
|
162 |
+
function gce_add_cache_duration_field() {
|
163 |
?>
|
164 |
+
<span class="description"><?php _e( 'The length of time, in seconds, to cache the feed (43200 = 12 hours). If this feed changes regularly, you may want to reduce the cache duration.', GCE_TEXT_DOMAIN ); ?></span>
|
165 |
<br />
|
166 |
<input type="text" name="gce_options[cache_duration]" value="43200" />
|
167 |
<?php
|
168 |
}
|
169 |
|
170 |
//Multiple day events
|
171 |
+
function gce_add_multiple_field() {
|
172 |
?>
|
173 |
+
<span class="description"><?php _e( 'Show events that span multiple days on each day that they span, rather than just the first day.', GCE_TEXT_DOMAIN ); ?></span>
|
174 |
<br />
|
175 |
<input type="checkbox" name="gce_options[multiple_day]" value="true" />
|
176 |
<br /><br />
|
179 |
|
180 |
|
181 |
//Display options
|
182 |
+
function gce_add_display_main_text() {
|
183 |
?>
|
184 |
+
<p><?php _e( 'These settings control what information will be displayed for this feed in the tooltip (for grids), or in a list.', GCE_TEXT_DOMAIN ); ?></p>
|
185 |
<?php
|
186 |
}
|
187 |
|
188 |
+
function gce_add_use_builder_field() {
|
189 |
?>
|
190 |
+
<span class="description"><?php _e( 'It is recommended that you use the event display builder option, as it provides much more flexibility than the simple display options. The event display builder can do everything the simple display options can, plus lots more!', GCE_TEXT_DOMAIN ); ?></span>
|
191 |
<br />
|
192 |
<select name="gce_options[use_builder]">
|
193 |
+
<option value="true" selected="selected"><?php _e( 'Event display builder', GCE_TEXT_DOMAIN ); ?></option>
|
194 |
+
<option value="false"><?php _e( 'Simple display options', GCE_TEXT_DOMAIN ); ?></option>
|
195 |
</select>
|
196 |
<?php
|
197 |
}
|
198 |
|
199 |
//Event display builder
|
200 |
+
function gce_add_builder_main_text() {
|
201 |
?>
|
202 |
+
<p class="gce-event-builder">
|
203 |
+
<?php _e( 'Use the event display builder to customize how event information will be displayed in the grid tooltips and in lists. Use HTML and the shortcodes (explained below) to display the information you require. A basic example display format is provided as a starting point. For more information, take a look at the', GCE_TEXT_DOMAIN ); ?>
|
204 |
+
<a href="http://www.rhanney.co.uk/plugins/google-calendar-events/event-display-builder" target="_blank"><?php _e( 'event display builder guide', GCE_TEXT_DOMAIN ); ?></a>
|
205 |
+
</p>
|
206 |
<?php
|
207 |
}
|
208 |
|
209 |
+
function gce_add_builder_field() {
|
210 |
?>
|
211 |
<textarea name="gce_options[builder]" rows="10" cols="80">
|
212 |
+
<div class="gce-list-event gce-tooltip-event">[event-title]</div>
|
213 |
+
<div><span>Starts:</span> [start-time]</div>
|
214 |
+
<div><span>Ends:</span> [end-date] - [end-time]</div>
|
215 |
+
[if-location]<div><span>Location:</span> [location]</div>[/if-location]
|
216 |
+
[if-description]<div><span>Description:</span> [description]</div>[/if-description]
|
217 |
+
<div>[link newwindow="true"]More details...[/link]</div>
|
218 |
+
</textarea>
|
219 |
<br />
|
220 |
+
<p style="margin-top:20px;">
|
221 |
+
<?php _e( '(More information on all of the below shortcodes and attributes, and working examples, can be found in the', GCE_TEXT_DOMAIN ); ?>
|
222 |
+
<a href="http://www.rhanney.co.uk/plugins/google-calendar-events/event-display-builder" target="_blank"><?php _e( 'event display builder guide', GCE_TEXT_DOMAIN ); ?></a>)
|
223 |
+
</p>
|
224 |
+
<h4><?php _e( 'Event information shortcodes:', GCE_TEXT_DOMAIN ); ?></h4>
|
225 |
<ul>
|
226 |
+
<li><code>[event-title]</code><span class="description"> - <?php _e( 'The event title (possible attributes: <code>html</code>, <code>markdown</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
227 |
+
<li><code>[start-time]</code><span class="description"> - <?php _e( 'The event start time. Will use the time format specified in the above settings', GCE_TEXT_DOMAIN ); ?></span></li>
|
228 |
+
<li><code>[start-date]</code><span class="description"> - <?php _e( 'The event start date. Will use the date format specified in the above settings', GCE_TEXT_DOMAIN ); ?></span></li>
|
229 |
+
<li><code>[start-custom]</code><span class="description"> - <?php _e( 'The event start date / time. Will use the format specified in the <code>format</code> attribute (possible attributes: <code>format</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
230 |
+
<li><code>[start-human]</code><span class="description"> - <?php _e( 'The difference between the start time of the event and the time now, in human-readable format, such as \'1 hour\', \'4 days\', \'15 mins\' (possible attributes: <code>precision</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
231 |
+
<li><code>[end-time]</code><span class="description"> - <?php _e( 'The event end time. Will use the time format specified in the above settings', GCE_TEXT_DOMAIN ); ?></span></li>
|
232 |
+
<li><code>[end-date]</code><span class="description"> - <?php _e( 'The event end date. Will use the date format specified in the above settings', GCE_TEXT_DOMAIN ); ?></span></li>
|
233 |
+
<li><code>[end-custom]</code><span class="description"> - <?php _e( 'The event end date / time. Will use the format specified in the <code>format</code> attribute (possible attributes: <code>format</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
234 |
+
<li><code>[end-human]</code><span class="description"> - <?php _e( 'The difference between the end time of the event and the time now, in human-readable format (possible attributes: <code>precision</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
235 |
+
<li><code>[location]</code><span class="description"> - <?php _e( 'The event location (possible attributes: <code>html</code>, <code>markdown</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
236 |
+
<li><code>[maps-link]…[/maps-link]</code><span class="description"> - <?php _e( 'Anything between the opening and closing shortcode tags (inlcuding further shortcodes) will be linked to Google Maps, using the event location as a search parameter (possible attributes: <code>newwindow</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
237 |
+
<li><code>[description]</code><span class="description"> - <?php _e( 'The event description (possible attributes: <code>html</code>, <code>markdown</code>, <code>limit</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
238 |
+
<li><code>[link]…[/link]</code><span class="description"> - <?php _e( 'Anything between the opening and closing shortcode tags (inlcuding further shortcodes) will be linked to the Google Calendar page for the event (possible attributes: <code>newwindow</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
239 |
+
<li><code>[url]</code><span class="description"> - <?php _e( 'The raw URL to the Google Calendar page for the event', GCE_TEXT_DOMAIN ); ?></span></li>
|
240 |
+
<li><code>[length]</code><span class="description"> - <?php _e( 'The length of the event, in human-readable format (possible attributes: <code>precision</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
241 |
+
<li><code>[event-num]</code><span class="description"> - <?php _e( 'The position of the event in the current list, or the position of the event in the current month (for grids)', GCE_TEXT_DOMAIN ); ?></span></li>
|
242 |
+
<li><code>[event-id]</code><span class="description"> - <?php _e( 'The event UID (a unique identifier assigned to the event by Google)', GCE_TEXT_DOMAIN ); ?></span></li>
|
243 |
</ul>
|
244 |
+
<h4><?php _e( 'Feed information shortcodes:', GCE_TEXT_DOMAIN ); ?></h4>
|
245 |
<ul>
|
246 |
+
<li><code>[feed-title]</code><span class="description"> - <?php _e( 'The title of the feed from which the event comes', GCE_TEXT_DOMAIN ); ?></span></li>
|
247 |
+
<li><code>[feed-id]</code><span class="description"> - <?php _e( 'The ID of the feed from which the event comes', GCE_TEXT_DOMAIN ); ?></span></li>
|
248 |
+
<li><code>[cal-id]</code><span class="description"> - <?php _e( 'The calendar ID (a unique identifier assigned to the calendar by Google)', GCE_TEXT_DOMAIN ); ?></span></li>
|
249 |
</ul>
|
250 |
+
<h4><?php _e( 'Conditional shortcodes:', GCE_TEXT_DOMAIN ); ?></h4>
|
251 |
+
<p class="description" style="margin-bottom:18px;"><?php _e( 'Anything entered between the opening and closing tags of each of the following shortcodes will only be displayed if its condition (below) is met.', GCE_TEXT_DOMAIN ); ?></p>
|
252 |
<ul>
|
253 |
+
<li><code>[if-all-day]…[/if-all-day]</code><span class="description"> - <?php _e( 'The event is an all-day event', GCE_TEXT_DOMAIN ); ?></span></li>
|
254 |
+
<li><code>[if-not-all-day]…[/if-not-all-day]</code><span class="description"> - <?php _e( 'The event is not an all-day event', GCE_TEXT_DOMAIN ); ?></span></li>
|
255 |
+
<li><code>[if-title]…[/if-title]</code><span class="description"> - <?php _e( 'The event has a title', GCE_TEXT_DOMAIN ); ?></span></li>
|
256 |
+
<li><code>[if-description]…[/if-description]</code><span class="description"> - <?php _e( 'The event has a description', GCE_TEXT_DOMAIN ); ?></span></li>
|
257 |
+
<li><code>[if-location]…[/if-location]</code><span class="description"> - <?php _e( 'The event has a location', GCE_TEXT_DOMAIN ); ?></span></li>
|
258 |
+
<li><code>[if-tooltip]…[/if-tooltip]</code><span class="description"> - <?php _e( 'The event is to be displayed in a tooltip (not a list)', GCE_TEXT_DOMAIN ); ?></span></li>
|
259 |
+
<li><code>[if-list]…[/if-list]</code><span class="description"> - <?php _e( 'The event is to be displayed in a list (not a tooltip)', GCE_TEXT_DOMAIN ); ?></span></li>
|
260 |
+
<li><code>[if-now]…[/if-now]</code><span class="description"> - <?php _e( 'The event is taking place now (after the start time, but before the end time)', GCE_TEXT_DOMAIN ); ?></span></li>
|
261 |
+
<li><code>[if-not-now]…[/if-not-now]</code><span class="description"> - <?php _e( 'The event is not taking place now (may have ended or not yet started)', GCE_TEXT_DOMAIN ); ?></span></li>
|
262 |
+
<li><code>[if-started]…[/if-started]</code><span class="description"> - <?php _e( 'The event has started (even if it has also ended)', GCE_TEXT_DOMAIN ); ?></span></li>
|
263 |
+
<li><code>[if-not-started]…[/if-not-started]</code><span class="description"> - <?php _e( 'The event has not started', GCE_TEXT_DOMAIN ); ?></span></li>
|
264 |
+
<li><code>[if-ended]…[/if-ended]</code><span class="description"> - <?php _e( 'The event has ended', GCE_TEXT_DOMAIN ); ?></span></li>
|
265 |
+
<li><code>[if-not-ended]…[/if-not-ended]</code><span class="description"> - <?php _e( 'The event has not ended (even if it hasn\'t started)', GCE_TEXT_DOMAIN ); ?></span></li>
|
266 |
+
<li><code>[if-first]…[/if-first]</code><span class="description"> - <?php _e( 'The event is the first of the day', GCE_TEXT_DOMAIN ); ?></span></li>
|
267 |
+
<li><code>[if-not-first]…[/if-not-first]</code><span class="description"> - <?php _e( 'The event is not the first of the day', GCE_TEXT_DOMAIN ); ?></span></li>
|
268 |
+
<li><code>[if-multi-day]…[/if-multi-day]</code><span class="description"> - <?php _e( 'The event spans multiple days', GCE_TEXT_DOMAIN ); ?></span></li>
|
269 |
+
<li><code>[if-single-day]…[/if-single-day]</code><span class="description"> - <?php _e( 'The event does not span multiple days', GCE_TEXT_DOMAIN ); ?></span></li>
|
270 |
</ul>
|
271 |
+
<h4><?php _e( 'Attributes:', GCE_TEXT_DOMAIN ); ?></h4>
|
272 |
+
<p class="description" style="margin-bottom:18px;"><?php _e( 'The possible attributes mentioned above are explained here:', GCE_TEXT_DOMAIN ); ?></p>
|
273 |
<ul>
|
274 |
+
<li><code>html</code><span class="description"> - <?php _e( 'Whether or not to parse HTML that has been entered in the relevant field. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN ); ?></span></li>
|
275 |
+
<li><code>markdown</code><span class="description"> - <?php _e( 'Whether or not to parse <a href="http://daringfireball.net/projects/markdown" target="_blank">Markdown</a> that has been entered in the relevant field. <a href="http://michelf.com/projects/php-markdown" target="_blank">PHP Markdown</a> must be installed for this to work. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN ); ?></span></li>
|
276 |
+
<li><code>limit</code><span class="description"> - <?php _e( 'The word limit for the field. Should be specified as a positive integer', GCE_TEXT_DOMAIN ); ?></span></li>
|
277 |
+
<li><code>format</code><span class="description"> - <?php _e( 'The date / time format to use. Should specified as a <a href="http://php.net/manual/en/function.date.php" target="_blank">PHP date format</a> string', GCE_TEXT_DOMAIN ); ?></span></li>
|
278 |
+
<li><code>newwindow</code><span class="description"> - <?php _e( 'Whether or not the link should open in a new window / tab. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN ); ?></span></li>
|
279 |
+
<li><code>precision</code><span class="description"> - <?php _e( 'How precise to be when displaying a time difference in human-readable format. Should be specified as a positive integer', GCE_TEXT_DOMAIN ); ?></span></li>
|
280 |
+
<li><code>offset</code><span class="description"> - <?php _e( 'An offset (in seconds) to apply to start / end times before display. Should be specified as a (positive or negative) integer', GCE_TEXT_DOMAIN ); ?></span></li>
|
281 |
+
<li><code>autolink</code><span class="description"> - <?php _e( 'Whether or not to automatically convert URLs in the description to links. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN ); ?></span></li>
|
282 |
</ul>
|
283 |
<?php
|
284 |
}
|
285 |
|
286 |
//Simple display options
|
287 |
+
function gce_add_simple_display_main_text() {
|
288 |
?>
|
289 |
+
<p class="gce-simple-display-options"><?php _e( 'You can use some HTML in the text fields, but ensure it is valid or things might go wonky. Text fields can be empty too.', GCE_TEXT_DOMAIN ); ?></p>
|
290 |
<?php
|
291 |
}
|
292 |
|
293 |
+
function gce_add_display_start_field() {
|
294 |
?>
|
295 |
+
<span class="description"><?php _e( 'Select how to display the start date / time.', GCE_TEXT_DOMAIN ); ?></span>
|
296 |
<br />
|
297 |
<select name="gce_options[display_start]">
|
298 |
+
<option value="none"><?php _e( 'Don\'t display start time or date', GCE_TEXT_DOMAIN ); ?></option>
|
299 |
+
<option value="time" selected="selected"><?php _e( 'Display start time', GCE_TEXT_DOMAIN ); ?></option>
|
300 |
+
<option value="date"><?php _e( 'Display start date', GCE_TEXT_DOMAIN ); ?></option>
|
301 |
+
<option value="time-date"><?php _e( 'Display start time and date (in that order)', GCE_TEXT_DOMAIN ); ?></option>
|
302 |
+
<option value="date-time"><?php _e( 'Display start date and time (in that order)', GCE_TEXT_DOMAIN ); ?></option>
|
303 |
</select>
|
304 |
<br /><br />
|
305 |
+
<span class="description"><?php _e( 'Text to display before the start time.', GCE_TEXT_DOMAIN ); ?></span>
|
306 |
<br />
|
307 |
<input type="text" name="gce_options[display_start_text]" value="Starts:" />
|
308 |
<?php
|
309 |
}
|
310 |
|
311 |
+
function gce_add_display_end_field() {
|
312 |
?>
|
313 |
+
<span class="description"><?php _e( 'Select how to display the end date / time.', GCE_TEXT_DOMAIN ); ?></span>
|
314 |
<br />
|
315 |
<select name="gce_options[display_end]">
|
316 |
+
<option value="none"><?php _e( 'Don\'t display end time or date', GCE_TEXT_DOMAIN ); ?></option>
|
317 |
+
<option value="time"><?php _e( 'Display end time', GCE_TEXT_DOMAIN ); ?></option>
|
318 |
+
<option value="date"><?php _e( 'Display end date', GCE_TEXT_DOMAIN ); ?></option>
|
319 |
+
<option value="time-date" selected="selected"><?php _e( 'Display end time and date (in that order)', GCE_TEXT_DOMAIN ); ?></option>
|
320 |
+
<option value="date-time"><?php _e( 'Display end date and time (in that order)', GCE_TEXT_DOMAIN ); ?></option>
|
321 |
</select>
|
322 |
<br /><br />
|
323 |
+
<span class="description"><?php _e( 'Text to display before the end time.', GCE_TEXT_DOMAIN ); ?></span>
|
324 |
<br />
|
325 |
<input type="text" name="gce_options[display_end_text]" value="Ends:" />
|
326 |
<?php
|
327 |
}
|
328 |
|
329 |
+
function gce_add_display_separator_field() {
|
330 |
?>
|
331 |
+
<span class="description"><?php _e( 'If you have chosen to display both the time and date above, enter the text / characters to display between the time and date here (including any spaces).', GCE_TEXT_DOMAIN ); ?></span>
|
332 |
<br />
|
333 |
<input type="text" name="gce_options[display_separator]" value=", " />
|
334 |
<?php
|
335 |
}
|
336 |
|
337 |
+
function gce_add_display_location_field() {
|
338 |
?>
|
339 |
<input type="checkbox" name="gce_options[display_location]" value="on" />
|
340 |
+
<span class="description"><?php _e( 'Show the location of events?', GCE_TEXT_DOMAIN ); ?></span>
|
341 |
<br /><br />
|
342 |
+
<span class="description"><?php _e( 'Text to display before the location.', GCE_TEXT_DOMAIN ); ?></span>
|
343 |
<br />
|
344 |
<input type="text" name="gce_options[display_location_text]" value="Location:" />
|
345 |
<?php
|
346 |
}
|
347 |
|
348 |
+
function gce_add_display_desc_field() {
|
349 |
?>
|
350 |
<input type="checkbox" name="gce_options[display_desc]" value="on" />
|
351 |
+
<span class="description"><?php _e( 'Show the description of events? (URLs in the description will be made into links).', GCE_TEXT_DOMAIN ); ?></span>
|
352 |
<br /><br />
|
353 |
+
<span class="description"><?php _e( 'Text to display before the description.', GCE_TEXT_DOMAIN ); ?></span>
|
354 |
<br />
|
355 |
<input type="text" name="gce_options[display_desc_text]" value="Description:" />
|
356 |
<br /><br />
|
357 |
+
<span class="description"><?php _e( 'Maximum number of words to show from description. Leave blank for no limit.', GCE_TEXT_DOMAIN ); ?></span>
|
358 |
<br />
|
359 |
<input type="text" name="gce_options[display_desc_limit]" size="3" />
|
360 |
<?php
|
361 |
}
|
362 |
|
363 |
+
function gce_add_display_link_field() {
|
364 |
?>
|
365 |
<input type="checkbox" name="gce_options[display_link]" value="on" checked="checked" />
|
366 |
+
<span class="description"><?php _e( 'Show a link to the Google Calendar page for an event?', GCE_TEXT_DOMAIN ); ?></span>
|
367 |
<br />
|
368 |
<input type="checkbox" name="gce_options[display_link_target]" value="on" />
|
369 |
+
<span class="description"><?php _e( 'Links open in a new window / tab?', GCE_TEXT_DOMAIN ); ?></span>
|
370 |
<br /><br />
|
371 |
+
<span class="description"><?php _e( 'The link text to be displayed.', GCE_TEXT_DOMAIN ); ?></span>
|
372 |
<br />
|
373 |
<input type="text" name="gce_options[display_link_text]" value="More details" />
|
374 |
<?php
|
admin/edit.php
CHANGED
@@ -180,7 +180,7 @@ function gce_edit_multiple_field(){
|
|
180 |
$options = get_option(GCE_OPTIONS_NAME);
|
181 |
$options = $options[$_GET['id']];
|
182 |
?>
|
183 |
-
<span class="description"><?php _e('Show events that span multiple days on each day that they span
|
184 |
<br />
|
185 |
<input type="checkbox" name="gce_options[multiple_day]" value="true"<?php checked($options['multiple_day'], 'true'); ?> />
|
186 |
<br /><br />
|
@@ -224,57 +224,62 @@ function gce_edit_builder_field(){
|
|
224 |
<p style="margin-top:20px;"><?php _e('(More information on all of the below shortcodes and attributes, and working examples, can be found in the <a href="http://www.rhanney.co.uk/plugins/google-calendar-events/event-display-builder" target="_blank">event display builder guide</a>)', GCE_TEXT_DOMAIN); ?></p>
|
225 |
<h4><?php _e('Event information shortcodes:', GCE_TEXT_DOMAIN); ?></h4>
|
226 |
<ul>
|
227 |
-
<li><code>[event-title]</code><span class="description"> - <?php _e('The event title (possible attributes: <code>html</code>, <code>markdown</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
228 |
-
<li><code>[start-time]</code><span class="description"> - <?php _e('The event start time. Will use the time format specified in the above settings', GCE_TEXT_DOMAIN); ?></span></li>
|
229 |
-
<li><code>[start-date]</code><span class="description"> - <?php _e('The event start date. Will use the date format specified in the above settings', GCE_TEXT_DOMAIN); ?></span></li>
|
230 |
-
<li><code>[start-custom]</code><span class="description"> - <?php _e('The event start date / time. Will use the format specified in the <code>format</code> attribute (possible attributes: <code>format</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
231 |
-
<li><code>[start-human]</code><span class="description"> - <?php _e('The difference between the start time of the event and the time now, in human-readable format, such as \'1 hour\', \'4 days\', \'15 mins\' (possible attributes: <code>precision</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
232 |
-
<li><code>[end-time]</code><span class="description"> - <?php _e('The event end time. Will use the time format specified in the above settings', GCE_TEXT_DOMAIN); ?></span></li>
|
233 |
-
<li><code>[end-date]</code><span class="description"> - <?php _e('The event end date. Will use the date format specified in the above settings', GCE_TEXT_DOMAIN); ?></span></li>
|
234 |
-
<li><code>[end-custom]</code><span class="description"> - <?php _e('The event end date / time. Will use the format specified in the <code>format</code> attribute (possible attributes: <code>format</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
235 |
-
<li><code>[end-human]</code><span class="description"> - <?php _e('The difference between the end time of the event and the time now, in human-readable format (possible attributes: <code>precision</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
236 |
-
<li><code>[location]</code><span class="description"> - <?php _e('The event location (possible attributes: <code>html</code>, <code>markdown</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
237 |
-
<li><code>[maps-link]…[/maps-link]</code><span class="description"> - <?php _e('Anything between the opening and closing shortcode tags (inlcuding further shortcodes) will be linked to Google Maps, using the event location as a search parameter (possible attributes: <code>newwindow</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
238 |
-
<li><code>[description]</code><span class="description"> - <?php _e('The event description (possible attributes: <code>html</code>, <code>markdown</code>, <code>limit</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
239 |
-
<li><code>[link]…[/link]</code><span class="description"> - <?php _e('Anything between the opening and closing shortcode tags (inlcuding further shortcodes) will be linked to the Google Calendar page for the event (possible attributes: <code>newwindow</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
240 |
-
<li><code>[
|
241 |
-
<li><code>[length]</code><span class="description"> - <?php _e('The length of the event, in human-readable format (possible attributes: <code>precision</code>)', GCE_TEXT_DOMAIN); ?></span></li>
|
|
|
|
|
242 |
</ul>
|
243 |
-
<h4><?php _e('Feed information shortcodes:', GCE_TEXT_DOMAIN); ?></h4>
|
244 |
<ul>
|
245 |
-
<li><code>[feed-title]</code><span class="description"> - <?php _e('The title of the feed from which the event comes', GCE_TEXT_DOMAIN); ?></span></li>
|
246 |
-
<li><code>[feed-id]</code><span class="description"> - <?php _e('The ID of the feed from which the event comes', GCE_TEXT_DOMAIN); ?></span></li>
|
|
|
247 |
</ul>
|
248 |
-
<h4><?php _e('Conditional shortcodes:', GCE_TEXT_DOMAIN); ?></h4>
|
249 |
-
<p class="description" style="margin-bottom:18px;"><?php _e('Anything entered between the opening and closing tags of each of the following shortcodes will only be displayed if its condition (below) is met.', GCE_TEXT_DOMAIN); ?></p>
|
250 |
<ul>
|
251 |
-
<li><code>[if-all-day]…[/if-all-day]</code><span class="description"> - <?php _e('The event is an all-day event', GCE_TEXT_DOMAIN); ?></span></li>
|
252 |
-
<li><code>[if-not-all-day]…[/if-not-all-day]</code><span class="description"> - <?php _e('The event is not an all-day event', GCE_TEXT_DOMAIN); ?></span></li>
|
253 |
-
<li><code>[if-title]…[/if-title]</code><span class="description"> - <?php _e('The event has a title', GCE_TEXT_DOMAIN); ?></span></li>
|
254 |
-
<li><code>[if-description]…[/if-description]</code><span class="description"> - <?php _e('The event has a description', GCE_TEXT_DOMAIN); ?></span></li>
|
255 |
-
<li><code>[if-location]…[/if-location]</code><span class="description"> - <?php _e('The event has a location', GCE_TEXT_DOMAIN); ?></span></li>
|
256 |
-
<li><code>[if-tooltip]…[/if-tooltip]</code><span class="description"> - <?php _e('The event is to be displayed in a tooltip (not a list)', GCE_TEXT_DOMAIN); ?></span></li>
|
257 |
-
<li><code>[if-list]…[/if-list]</code><span class="description"> - <?php _e('The event is to be displayed in a list (not a tooltip)', GCE_TEXT_DOMAIN); ?></span></li>
|
258 |
-
<li><code>[if-now]…[/if-now]</code><span class="description"> - <?php _e('The event is taking place now (after the start time, but before the end time)', GCE_TEXT_DOMAIN); ?></span></li>
|
259 |
-
<li><code>[if-not-now]…[/if-not-now]</code><span class="description"> - <?php _e('The event is not taking place now (may have ended or not yet started)', GCE_TEXT_DOMAIN); ?></span></li>
|
260 |
-
<li><code>[if-started]…[/if-started]</code><span class="description"> - <?php _e('The event has started (even if it has also ended)', GCE_TEXT_DOMAIN); ?></span></li>
|
261 |
-
<li><code>[if-not-started]…[/if-not-started]</code><span class="description"> - <?php _e('The event has not started', GCE_TEXT_DOMAIN); ?></span></li>
|
262 |
-
<li><code>[if-ended]…[/if-ended]</code><span class="description"> - <?php _e('The event has ended', GCE_TEXT_DOMAIN); ?></span></li>
|
263 |
-
<li><code>[if-not-ended]…[/if-not-ended]</code><span class="description"> - <?php _e('The event has not ended (even if it hasn\'t started)', GCE_TEXT_DOMAIN); ?></span></li>
|
264 |
-
<li><code>[if-first]…[/if-first]</code><span class="description"> - <?php _e('The event is the first of the day', GCE_TEXT_DOMAIN); ?></span></li>
|
265 |
-
<li><code>[if-not-first]…[/if-not-first]</code><span class="description"> - <?php _e('The event is not the first of the day', GCE_TEXT_DOMAIN); ?></span></li>
|
266 |
-
<li><code>[if-multi-day]…[/if-multi-day]</code><span class="description"> - <?php _e('The event spans multiple days', GCE_TEXT_DOMAIN); ?></span></li>
|
267 |
-
<li><code>[if-single-day]…[/if-single-day]</code><span class="description"> - <?php _e('The event does not span multiple days', GCE_TEXT_DOMAIN); ?></span></li>
|
268 |
</ul>
|
269 |
-
<h4><?php _e('Attributes:', GCE_TEXT_DOMAIN); ?></h4>
|
270 |
-
<p class="description" style="margin-bottom:18px;"><?php _e('The possible attributes mentioned above are explained here:', GCE_TEXT_DOMAIN); ?></p>
|
271 |
<ul>
|
272 |
-
<li><code>html</code><span class="description"> - <?php _e('Whether or not to parse HTML that has been entered in the relevant field. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN); ?></span></li>
|
273 |
-
<li><code>markdown</code><span class="description"> - <?php _e('Whether or not to parse <a href="http://daringfireball.net/projects/markdown" target="_blank">Markdown</a> that has been entered in the relevant field. <a href="http://michelf.com/projects/php-markdown" target="_blank">PHP Markdown</a> must be installed for this to work. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN); ?></span></li>
|
274 |
-
<li><code>limit</code><span class="description"> - <?php _e('The word limit for the field. Should be specified as a positive integer', GCE_TEXT_DOMAIN); ?></span></li>
|
275 |
-
<li><code>format</code><span class="description"> - <?php _e('The date / time format to use. Should specified as a <a href="http://php.net/manual/en/function.date.php" target="_blank">PHP date format</a> string', GCE_TEXT_DOMAIN); ?></span></li>
|
276 |
-
<li><code>newwindow</code><span class="description"> - <?php _e('Whether or not the link should open in a new window / tab. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN); ?></span></li>
|
277 |
-
<li><code>precision</code><span class="description"> - <?php _e('How precise to be when displaying a time difference in human-readable format. Should be specified as a positive integer', GCE_TEXT_DOMAIN); ?></span></li>
|
|
|
|
|
278 |
</ul>
|
279 |
<?php
|
280 |
}
|
180 |
$options = get_option(GCE_OPTIONS_NAME);
|
181 |
$options = $options[$_GET['id']];
|
182 |
?>
|
183 |
+
<span class="description"><?php _e('Show events that span multiple days on each day that they span, rather than just the first day.', GCE_TEXT_DOMAIN); ?></span>
|
184 |
<br />
|
185 |
<input type="checkbox" name="gce_options[multiple_day]" value="true"<?php checked($options['multiple_day'], 'true'); ?> />
|
186 |
<br /><br />
|
224 |
<p style="margin-top:20px;"><?php _e('(More information on all of the below shortcodes and attributes, and working examples, can be found in the <a href="http://www.rhanney.co.uk/plugins/google-calendar-events/event-display-builder" target="_blank">event display builder guide</a>)', GCE_TEXT_DOMAIN); ?></p>
|
225 |
<h4><?php _e('Event information shortcodes:', GCE_TEXT_DOMAIN); ?></h4>
|
226 |
<ul>
|
227 |
+
<li><code>[event-title]</code><span class="description"> - <?php _e( 'The event title (possible attributes: <code>html</code>, <code>markdown</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
228 |
+
<li><code>[start-time]</code><span class="description"> - <?php _e( 'The event start time. Will use the time format specified in the above settings', GCE_TEXT_DOMAIN ); ?></span></li>
|
229 |
+
<li><code>[start-date]</code><span class="description"> - <?php _e( 'The event start date. Will use the date format specified in the above settings', GCE_TEXT_DOMAIN ); ?></span></li>
|
230 |
+
<li><code>[start-custom]</code><span class="description"> - <?php _e( 'The event start date / time. Will use the format specified in the <code>format</code> attribute (possible attributes: <code>format</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
231 |
+
<li><code>[start-human]</code><span class="description"> - <?php _e( 'The difference between the start time of the event and the time now, in human-readable format, such as \'1 hour\', \'4 days\', \'15 mins\' (possible attributes: <code>precision</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
232 |
+
<li><code>[end-time]</code><span class="description"> - <?php _e( 'The event end time. Will use the time format specified in the above settings', GCE_TEXT_DOMAIN ); ?></span></li>
|
233 |
+
<li><code>[end-date]</code><span class="description"> - <?php _e( 'The event end date. Will use the date format specified in the above settings', GCE_TEXT_DOMAIN ); ?></span></li>
|
234 |
+
<li><code>[end-custom]</code><span class="description"> - <?php _e( 'The event end date / time. Will use the format specified in the <code>format</code> attribute (possible attributes: <code>format</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
235 |
+
<li><code>[end-human]</code><span class="description"> - <?php _e( 'The difference between the end time of the event and the time now, in human-readable format (possible attributes: <code>precision</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
236 |
+
<li><code>[location]</code><span class="description"> - <?php _e( 'The event location (possible attributes: <code>html</code>, <code>markdown</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
237 |
+
<li><code>[maps-link]…[/maps-link]</code><span class="description"> - <?php _e( 'Anything between the opening and closing shortcode tags (inlcuding further shortcodes) will be linked to Google Maps, using the event location as a search parameter (possible attributes: <code>newwindow</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
238 |
+
<li><code>[description]</code><span class="description"> - <?php _e( 'The event description (possible attributes: <code>html</code>, <code>markdown</code>, <code>limit</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
239 |
+
<li><code>[link]…[/link]</code><span class="description"> - <?php _e( 'Anything between the opening and closing shortcode tags (inlcuding further shortcodes) will be linked to the Google Calendar page for the event (possible attributes: <code>newwindow</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
240 |
+
<li><code>[url]</code><span class="description"> - <?php _e( 'The raw URL to the Google Calendar page for the event', GCE_TEXT_DOMAIN ); ?></span></li>
|
241 |
+
<li><code>[length]</code><span class="description"> - <?php _e( 'The length of the event, in human-readable format (possible attributes: <code>precision</code>)', GCE_TEXT_DOMAIN ); ?></span></li>
|
242 |
+
<li><code>[event-num]</code><span class="description"> - <?php _e( 'The position of the event in the current list, or the position of the event in the current month (for grids)', GCE_TEXT_DOMAIN ); ?></span></li>
|
243 |
+
<li><code>[event-id]</code><span class="description"> - <?php _e( 'The event UID (a unique identifier assigned to the event by Google)', GCE_TEXT_DOMAIN ); ?></span></li>
|
244 |
</ul>
|
245 |
+
<h4><?php _e( 'Feed information shortcodes:', GCE_TEXT_DOMAIN ); ?></h4>
|
246 |
<ul>
|
247 |
+
<li><code>[feed-title]</code><span class="description"> - <?php _e( 'The title of the feed from which the event comes', GCE_TEXT_DOMAIN ); ?></span></li>
|
248 |
+
<li><code>[feed-id]</code><span class="description"> - <?php _e( 'The ID of the feed from which the event comes', GCE_TEXT_DOMAIN ); ?></span></li>
|
249 |
+
<li><code>[cal-id]</code><span class="description"> - <?php _e( 'The calendar ID (a unique identifier assigned to the calendar by Google)', GCE_TEXT_DOMAIN ); ?></span></li>
|
250 |
</ul>
|
251 |
+
<h4><?php _e( 'Conditional shortcodes:', GCE_TEXT_DOMAIN ); ?></h4>
|
252 |
+
<p class="description" style="margin-bottom:18px;"><?php _e( 'Anything entered between the opening and closing tags of each of the following shortcodes will only be displayed if its condition (below) is met.', GCE_TEXT_DOMAIN ); ?></p>
|
253 |
<ul>
|
254 |
+
<li><code>[if-all-day]…[/if-all-day]</code><span class="description"> - <?php _e( 'The event is an all-day event', GCE_TEXT_DOMAIN ); ?></span></li>
|
255 |
+
<li><code>[if-not-all-day]…[/if-not-all-day]</code><span class="description"> - <?php _e( 'The event is not an all-day event', GCE_TEXT_DOMAIN ); ?></span></li>
|
256 |
+
<li><code>[if-title]…[/if-title]</code><span class="description"> - <?php _e( 'The event has a title', GCE_TEXT_DOMAIN ); ?></span></li>
|
257 |
+
<li><code>[if-description]…[/if-description]</code><span class="description"> - <?php _e( 'The event has a description', GCE_TEXT_DOMAIN ); ?></span></li>
|
258 |
+
<li><code>[if-location]…[/if-location]</code><span class="description"> - <?php _e( 'The event has a location', GCE_TEXT_DOMAIN ); ?></span></li>
|
259 |
+
<li><code>[if-tooltip]…[/if-tooltip]</code><span class="description"> - <?php _e( 'The event is to be displayed in a tooltip (not a list)', GCE_TEXT_DOMAIN ); ?></span></li>
|
260 |
+
<li><code>[if-list]…[/if-list]</code><span class="description"> - <?php _e( 'The event is to be displayed in a list (not a tooltip)', GCE_TEXT_DOMAIN ); ?></span></li>
|
261 |
+
<li><code>[if-now]…[/if-now]</code><span class="description"> - <?php _e( 'The event is taking place now (after the start time, but before the end time)', GCE_TEXT_DOMAIN ); ?></span></li>
|
262 |
+
<li><code>[if-not-now]…[/if-not-now]</code><span class="description"> - <?php _e( 'The event is not taking place now (may have ended or not yet started)', GCE_TEXT_DOMAIN ); ?></span></li>
|
263 |
+
<li><code>[if-started]…[/if-started]</code><span class="description"> - <?php _e( 'The event has started (even if it has also ended)', GCE_TEXT_DOMAIN ); ?></span></li>
|
264 |
+
<li><code>[if-not-started]…[/if-not-started]</code><span class="description"> - <?php _e( 'The event has not started', GCE_TEXT_DOMAIN ); ?></span></li>
|
265 |
+
<li><code>[if-ended]…[/if-ended]</code><span class="description"> - <?php _e( 'The event has ended', GCE_TEXT_DOMAIN ); ?></span></li>
|
266 |
+
<li><code>[if-not-ended]…[/if-not-ended]</code><span class="description"> - <?php _e( 'The event has not ended (even if it hasn\'t started)', GCE_TEXT_DOMAIN ); ?></span></li>
|
267 |
+
<li><code>[if-first]…[/if-first]</code><span class="description"> - <?php _e( 'The event is the first of the day', GCE_TEXT_DOMAIN ); ?></span></li>
|
268 |
+
<li><code>[if-not-first]…[/if-not-first]</code><span class="description"> - <?php _e( 'The event is not the first of the day', GCE_TEXT_DOMAIN ); ?></span></li>
|
269 |
+
<li><code>[if-multi-day]…[/if-multi-day]</code><span class="description"> - <?php _e( 'The event spans multiple days', GCE_TEXT_DOMAIN ); ?></span></li>
|
270 |
+
<li><code>[if-single-day]…[/if-single-day]</code><span class="description"> - <?php _e( 'The event does not span multiple days', GCE_TEXT_DOMAIN ); ?></span></li>
|
271 |
</ul>
|
272 |
+
<h4><?php _e( 'Attributes:', GCE_TEXT_DOMAIN ); ?></h4>
|
273 |
+
<p class="description" style="margin-bottom:18px;"><?php _e( 'The possible attributes mentioned above are explained here:', GCE_TEXT_DOMAIN ); ?></p>
|
274 |
<ul>
|
275 |
+
<li><code>html</code><span class="description"> - <?php _e( 'Whether or not to parse HTML that has been entered in the relevant field. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN ); ?></span></li>
|
276 |
+
<li><code>markdown</code><span class="description"> - <?php _e( 'Whether or not to parse <a href="http://daringfireball.net/projects/markdown" target="_blank">Markdown</a> that has been entered in the relevant field. <a href="http://michelf.com/projects/php-markdown" target="_blank">PHP Markdown</a> must be installed for this to work. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN ); ?></span></li>
|
277 |
+
<li><code>limit</code><span class="description"> - <?php _e( 'The word limit for the field. Should be specified as a positive integer', GCE_TEXT_DOMAIN ); ?></span></li>
|
278 |
+
<li><code>format</code><span class="description"> - <?php _e( 'The date / time format to use. Should specified as a <a href="http://php.net/manual/en/function.date.php" target="_blank">PHP date format</a> string', GCE_TEXT_DOMAIN ); ?></span></li>
|
279 |
+
<li><code>newwindow</code><span class="description"> - <?php _e( 'Whether or not the link should open in a new window / tab. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN ); ?></span></li>
|
280 |
+
<li><code>precision</code><span class="description"> - <?php _e( 'How precise to be when displaying a time difference in human-readable format. Should be specified as a positive integer', GCE_TEXT_DOMAIN ); ?></span></li>
|
281 |
+
<li><code>offset</code><span class="description"> - <?php _e( 'An offset (in seconds) to apply to start / end times before display. Should be specified as a (positive or negative) integer', GCE_TEXT_DOMAIN ); ?></span></li>
|
282 |
+
<li><code>autolink</code><span class="description"> - <?php _e( 'Whether or not to automatically convert URLs in the description to links. Can be <code>true</code> or <code>false</code>', GCE_TEXT_DOMAIN ); ?></span></li>
|
283 |
</ul>
|
284 |
<?php
|
285 |
}
|
admin/main.php
CHANGED
@@ -96,6 +96,13 @@
|
|
96 |
<br />
|
97 |
<input type="checkbox" name="gce_general[fields]"<?php checked($options['fields'], true); ?> value="on" />
|
98 |
</td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
</tr>
|
100 |
</table>
|
101 |
|
96 |
<br />
|
97 |
<input type="checkbox" name="gce_general[fields]"<?php checked($options['fields'], true); ?> value="on" />
|
98 |
</td>
|
99 |
+
</tr><tr>
|
100 |
+
<th scope="row"><?php _e('Use old styles?', GCE_TEXT_DOMAIN); ?></th>
|
101 |
+
<td>
|
102 |
+
<span class="description"><?php _e('Some CSS changes were made in version 0.7. If this option is enabled, the old CSS will still be added along with the main stylesheet. You should consider updating your stylesheet so that you don\'t need this enabled.', GCE_TEXT_DOMAIN); ?></span>
|
103 |
+
<br />
|
104 |
+
<input type="checkbox" name="gce_general[old_stylesheet]"<?php checked($options['old_stylesheet'], true); ?> value="on" />
|
105 |
+
</td>
|
106 |
</tr>
|
107 |
</table>
|
108 |
|
admin/refresh.php
CHANGED
@@ -1,27 +1,27 @@
|
|
1 |
<?php
|
2 |
//Redirect to the main plugin options page if form has been submitted
|
3 |
-
if(isset($_GET['action'])){
|
4 |
-
if($_GET['action']
|
5 |
-
wp_redirect(admin_url('options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=refreshed'));
|
6 |
}
|
7 |
}
|
8 |
|
9 |
-
add_settings_section('gce_refresh', __('Refresh Feed Cache', GCE_TEXT_DOMAIN), 'gce_refresh_main_text', 'refresh_feed');
|
10 |
//Unique ID //Title //Function //Page //Section ID
|
11 |
-
add_settings_field('gce_refresh_id_field', __('Feed ID', GCE_TEXT_DOMAIN), 'gce_refresh_id_field', 'refresh_feed', 'gce_refresh');
|
12 |
-
add_settings_field('gce_refresh_title_field', __('Feed Title', GCE_TEXT_DOMAIN), 'gce_refresh_title_field', 'refresh_feed', 'gce_refresh');
|
13 |
|
14 |
//Main text
|
15 |
-
function gce_refresh_main_text(){
|
16 |
?>
|
17 |
-
<p><?php _e('The plugin will automatically refresh the cache when it expires, but you can manually clear the cache now by clicking the button below.', GCE_TEXT_DOMAIN); ?></p>
|
18 |
-
<p><?php _e('Are you want you want to clear the cache data for this feed?', GCE_TEXT_DOMAIN); ?></p>
|
19 |
<?php
|
20 |
}
|
21 |
|
22 |
//ID
|
23 |
-
function gce_refresh_id_field(){
|
24 |
-
$options = get_option(GCE_OPTIONS_NAME);
|
25 |
$options = $options[$_GET['id']];
|
26 |
?>
|
27 |
<input type="text" disabled="disabled" value="<?php echo $options['id']; ?>" size="3" />
|
@@ -30,8 +30,8 @@ function gce_refresh_id_field(){
|
|
30 |
}
|
31 |
|
32 |
//Title
|
33 |
-
function gce_refresh_title_field(){
|
34 |
-
$options = get_option(GCE_OPTIONS_NAME);
|
35 |
$options = $options[$_GET['id']];
|
36 |
?>
|
37 |
<input type="text" name="gce_options[title]" disabled="disabled" value="<?php echo $options['title']; ?>" size="50" />
|
1 |
<?php
|
2 |
//Redirect to the main plugin options page if form has been submitted
|
3 |
+
if ( isset( $_GET['action'] ) ) {
|
4 |
+
if ( 'refresh' == $_GET['action'] && isset( $_GET['updated'] ) ) {
|
5 |
+
wp_redirect( admin_url( 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=refreshed' ) );
|
6 |
}
|
7 |
}
|
8 |
|
9 |
+
add_settings_section( 'gce_refresh', __( 'Refresh Feed Cache', GCE_TEXT_DOMAIN ), 'gce_refresh_main_text', 'refresh_feed' );
|
10 |
//Unique ID //Title //Function //Page //Section ID
|
11 |
+
add_settings_field( 'gce_refresh_id_field', __( 'Feed ID', GCE_TEXT_DOMAIN ), 'gce_refresh_id_field', 'refresh_feed', 'gce_refresh' );
|
12 |
+
add_settings_field( 'gce_refresh_title_field', __( 'Feed Title', GCE_TEXT_DOMAIN ), 'gce_refresh_title_field', 'refresh_feed', 'gce_refresh' );
|
13 |
|
14 |
//Main text
|
15 |
+
function gce_refresh_main_text() {
|
16 |
?>
|
17 |
+
<p><?php _e( 'The plugin will automatically refresh the cache when it expires, but you can manually clear the cache now by clicking the button below.', GCE_TEXT_DOMAIN ); ?></p>
|
18 |
+
<p><?php _e( 'Are you want you want to clear the cache data for this feed?', GCE_TEXT_DOMAIN ); ?></p>
|
19 |
<?php
|
20 |
}
|
21 |
|
22 |
//ID
|
23 |
+
function gce_refresh_id_field() {
|
24 |
+
$options = get_option( GCE_OPTIONS_NAME );
|
25 |
$options = $options[$_GET['id']];
|
26 |
?>
|
27 |
<input type="text" disabled="disabled" value="<?php echo $options['id']; ?>" size="3" />
|
30 |
}
|
31 |
|
32 |
//Title
|
33 |
+
function gce_refresh_title_field() {
|
34 |
+
$options = get_option( GCE_OPTIONS_NAME );
|
35 |
$options = $options[$_GET['id']];
|
36 |
?>
|
37 |
<input type="text" name="gce_options[title]" disabled="disabled" value="<?php echo $options['title']; ?>" size="50" />
|
css/gce-old-style.css
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.gce-page-grid .gce-calendar th{
|
2 |
+
padding:0 !important;
|
3 |
+
}
|
4 |
+
|
5 |
+
.gce-page-grid .gce-calendar th abbr,
|
6 |
+
.gce-widget-grid .gce-calendar th abbr{
|
7 |
+
border-bottom:none !important;
|
8 |
+
}
|
9 |
+
|
10 |
+
.gce-page-list .gce-list p{
|
11 |
+
margin:0 !important;
|
12 |
+
}
|
13 |
+
|
14 |
+
.gce-page-list .gce-list ul,
|
15 |
+
.gce-widget-list .gce-list ul{
|
16 |
+
margin:0 !important;
|
17 |
+
padding:0 !important;
|
18 |
+
}
|
19 |
+
|
20 |
+
.gce-event-info .gce-tooltip-title{
|
21 |
+
margin:5px !important;
|
22 |
+
}
|
23 |
+
|
24 |
+
.gce-event-info ul{
|
25 |
+
padding:0 !important;
|
26 |
+
margin:5px !important;
|
27 |
+
list-style-type:none !important;
|
28 |
+
}
|
css/gce-style.css
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
|
3 |
.gce-page-grid .gce-calendar .gce-caption{ /* Caption at top of calendar */
|
4 |
color:#333333;
|
|
|
5 |
}
|
6 |
|
7 |
.gce-page-grid .gce-calendar{ /* Main calendar table */
|
@@ -15,14 +16,15 @@
|
|
15 |
border:1px solid #CCCCCC;
|
16 |
text-align:center;
|
17 |
width:14.29%;
|
18 |
-
padding:0
|
19 |
}
|
20 |
|
21 |
.gce-page-grid .gce-calendar td{ /* Day table cells */
|
22 |
border:1px solid #CCCCCC;
|
23 |
text-align:center;
|
24 |
-
height:
|
25 |
vertical-align:middle;
|
|
|
26 |
}
|
27 |
|
28 |
.gce-page-grid .gce-calendar .gce-has-events{ /* Table cells with events */
|
@@ -55,25 +57,17 @@
|
|
55 |
}
|
56 |
|
57 |
.gce-page-grid .gce-calendar th abbr{ /* Day letter abbreviation */
|
58 |
-
border-bottom:none
|
59 |
}
|
60 |
|
61 |
/* PAGE LIST */
|
62 |
|
63 |
-
.gce-page-list .gce-list{ /* The list itself */
|
64 |
-
margin-top:10px;
|
65 |
-
}
|
66 |
-
|
67 |
-
.gce-page-list .gce-list li{ /* Each event in the list */
|
68 |
-
margin-top:5px;
|
69 |
-
content:none;
|
70 |
-
}
|
71 |
-
|
72 |
.gce-page-list .gce-list p{ /* Each piece of information in the list */
|
73 |
-
margin:0
|
74 |
}
|
75 |
|
76 |
-
.gce-page-list .gce-list p span
|
|
|
77 |
color:#999999;
|
78 |
}
|
79 |
|
@@ -87,21 +81,17 @@
|
|
87 |
|
88 |
.gce-page-list .gce-list ul{
|
89 |
list-style-type:none;
|
90 |
-
margin:0
|
91 |
-
padding:0
|
92 |
}
|
93 |
|
94 |
-
/* Also available: .gce-list-start, .gce-list-end, .gce-list-loc, .gce-list-desc, .gce-list-link */
|
95 |
-
|
96 |
-
|
97 |
/* WIDGET GRID */
|
98 |
|
99 |
.gce-widget-grid .gce-calendar .gce-caption{
|
100 |
-
|
101 |
}
|
102 |
|
103 |
.gce-widget-grid .gce-calendar{ /* Main calendar table */
|
104 |
-
text-align:center;
|
105 |
width:100%;
|
106 |
border:1px solid #CCCCCC;
|
107 |
border-collapse:collapse;
|
@@ -110,12 +100,14 @@
|
|
110 |
.gce-widget-grid .gce-calendar th{ /* Day headings (S, M etc.) */
|
111 |
width:14.29%;
|
112 |
border:1px solid #CCCCCC;
|
|
|
113 |
}
|
114 |
|
115 |
.gce-widget-grid .gce-calendar td{ /* Day table cells */
|
116 |
color:#CCCCCC;
|
117 |
width:14.29%;
|
118 |
border:1px solid #CCCCCC;
|
|
|
119 |
}
|
120 |
|
121 |
.gce-widget-grid .gce-calendar .gce-has-events{ /* Table cells with events */
|
@@ -144,24 +136,17 @@
|
|
144 |
}
|
145 |
|
146 |
.gce-widget-grid .gce-calendar th abbr{ /* Day name abbreviations */
|
147 |
-
border-bottom:none
|
148 |
}
|
149 |
|
150 |
/* WIDGET LIST */
|
151 |
|
152 |
-
.gce-widget-list .gce-list{ /* The list itself */
|
153 |
-
margin:10px 0 0 0;
|
154 |
-
}
|
155 |
-
|
156 |
-
.gce-widget-list .gce-list li{ /* Each event in the list */
|
157 |
-
margin:5px 0 0 0;
|
158 |
-
}
|
159 |
-
|
160 |
.gce-widget-list .gce-list p{ /* Each piece of information in the list */
|
161 |
margin:0;
|
162 |
}
|
163 |
|
164 |
-
.gce-widget-list .gce-list p span
|
|
|
165 |
color:#999999;
|
166 |
}
|
167 |
|
@@ -175,32 +160,28 @@
|
|
175 |
|
176 |
.gce-widget-list .gce-list ul{
|
177 |
list-style-type:none;
|
178 |
-
margin:0
|
179 |
-
padding:0
|
180 |
}
|
181 |
|
182 |
-
/* Also available: .gce-list-start, .gce-list-end, .gce-list-loc, .gce-list-desc, .gce-list-link */
|
183 |
-
|
184 |
-
|
185 |
/* TOOLTIP */
|
186 |
|
187 |
.gce-event-info{ /* Tooltip container */
|
188 |
background-color:#FFFFFF;
|
189 |
border:1px solid #333333;
|
190 |
-
text-align:left;
|
191 |
max-width:300px;
|
192 |
}
|
193 |
|
194 |
.gce-event-info .gce-tooltip-title{ /* 'Events on...' text */
|
195 |
-
margin:5px
|
196 |
font-weight:bold;
|
197 |
font-size:1.2em;
|
198 |
}
|
199 |
|
200 |
.gce-event-info ul{ /* Events list */
|
201 |
-
padding:0
|
202 |
-
margin:5px
|
203 |
-
list-style-type:none
|
204 |
}
|
205 |
|
206 |
.gce-event-info ul li{ /* Event list item */
|
@@ -211,13 +192,12 @@
|
|
211 |
margin:0;
|
212 |
}
|
213 |
|
214 |
-
.gce-event-info ul li p span
|
|
|
215 |
color:#999999;
|
216 |
}
|
217 |
|
218 |
.gce-event-info .gce-tooltip-event{ /* The event title */
|
219 |
background-color:#DDDDDD;
|
220 |
font-weight:bold;
|
221 |
-
}
|
222 |
-
|
223 |
-
/* Also available: .gce-tooltip-start, .gce-tooltip-end, .gce-tooltip-loc, .gce-tooltip-desc, .gce-tooltip-link */
|
2 |
|
3 |
.gce-page-grid .gce-calendar .gce-caption{ /* Caption at top of calendar */
|
4 |
color:#333333;
|
5 |
+
text-align:center;
|
6 |
}
|
7 |
|
8 |
.gce-page-grid .gce-calendar{ /* Main calendar table */
|
16 |
border:1px solid #CCCCCC;
|
17 |
text-align:center;
|
18 |
width:14.29%;
|
19 |
+
padding:0;
|
20 |
}
|
21 |
|
22 |
.gce-page-grid .gce-calendar td{ /* Day table cells */
|
23 |
border:1px solid #CCCCCC;
|
24 |
text-align:center;
|
25 |
+
height:80px;
|
26 |
vertical-align:middle;
|
27 |
+
padding:0;
|
28 |
}
|
29 |
|
30 |
.gce-page-grid .gce-calendar .gce-has-events{ /* Table cells with events */
|
57 |
}
|
58 |
|
59 |
.gce-page-grid .gce-calendar th abbr{ /* Day letter abbreviation */
|
60 |
+
border-bottom:none;
|
61 |
}
|
62 |
|
63 |
/* PAGE LIST */
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
.gce-page-list .gce-list p{ /* Each piece of information in the list */
|
66 |
+
margin:0;
|
67 |
}
|
68 |
|
69 |
+
.gce-page-list .gce-list p span,
|
70 |
+
.gce-page-list .gce-list div span{ /* The text displayed before each piece of info, 'Starts:' for example */
|
71 |
color:#999999;
|
72 |
}
|
73 |
|
81 |
|
82 |
.gce-page-list .gce-list ul{
|
83 |
list-style-type:none;
|
84 |
+
margin:0;
|
85 |
+
padding:0;
|
86 |
}
|
87 |
|
|
|
|
|
|
|
88 |
/* WIDGET GRID */
|
89 |
|
90 |
.gce-widget-grid .gce-calendar .gce-caption{
|
91 |
+
text-align:center;
|
92 |
}
|
93 |
|
94 |
.gce-widget-grid .gce-calendar{ /* Main calendar table */
|
|
|
95 |
width:100%;
|
96 |
border:1px solid #CCCCCC;
|
97 |
border-collapse:collapse;
|
100 |
.gce-widget-grid .gce-calendar th{ /* Day headings (S, M etc.) */
|
101 |
width:14.29%;
|
102 |
border:1px solid #CCCCCC;
|
103 |
+
text-align:center;
|
104 |
}
|
105 |
|
106 |
.gce-widget-grid .gce-calendar td{ /* Day table cells */
|
107 |
color:#CCCCCC;
|
108 |
width:14.29%;
|
109 |
border:1px solid #CCCCCC;
|
110 |
+
text-align:center;
|
111 |
}
|
112 |
|
113 |
.gce-widget-grid .gce-calendar .gce-has-events{ /* Table cells with events */
|
136 |
}
|
137 |
|
138 |
.gce-widget-grid .gce-calendar th abbr{ /* Day name abbreviations */
|
139 |
+
border-bottom:none;
|
140 |
}
|
141 |
|
142 |
/* WIDGET LIST */
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
.gce-widget-list .gce-list p{ /* Each piece of information in the list */
|
145 |
margin:0;
|
146 |
}
|
147 |
|
148 |
+
.gce-widget-list .gce-list p span,
|
149 |
+
.gce-widget-list .gce-list div span{ /* The text displayed before each piece of info, 'Starts:' for example */
|
150 |
color:#999999;
|
151 |
}
|
152 |
|
160 |
|
161 |
.gce-widget-list .gce-list ul{
|
162 |
list-style-type:none;
|
163 |
+
margin:0;
|
164 |
+
padding:0;
|
165 |
}
|
166 |
|
|
|
|
|
|
|
167 |
/* TOOLTIP */
|
168 |
|
169 |
.gce-event-info{ /* Tooltip container */
|
170 |
background-color:#FFFFFF;
|
171 |
border:1px solid #333333;
|
|
|
172 |
max-width:300px;
|
173 |
}
|
174 |
|
175 |
.gce-event-info .gce-tooltip-title{ /* 'Events on...' text */
|
176 |
+
margin:5px;
|
177 |
font-weight:bold;
|
178 |
font-size:1.2em;
|
179 |
}
|
180 |
|
181 |
.gce-event-info ul{ /* Events list */
|
182 |
+
padding:0;
|
183 |
+
margin:5px;
|
184 |
+
list-style-type:none;
|
185 |
}
|
186 |
|
187 |
.gce-event-info ul li{ /* Event list item */
|
192 |
margin:0;
|
193 |
}
|
194 |
|
195 |
+
.gce-event-info ul li p span,
|
196 |
+
.gce-event-info ul li div span{ /* The text displayed before each piece of info, 'Starts:' for example */
|
197 |
color:#999999;
|
198 |
}
|
199 |
|
200 |
.gce-event-info .gce-tooltip-event{ /* The event title */
|
201 |
background-color:#DDDDDD;
|
202 |
font-weight:bold;
|
203 |
+
}
|
|
|
|
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.
|
7 |
Author: Ross Hanney
|
8 |
Author URI: http://www.rhanney.co.uk
|
9 |
License: GPL2
|
@@ -24,60 +24,67 @@ GNU General Public License for more details.
|
|
24 |
You should have received a copy of the GNU General Public License
|
25 |
along with this program; if not, write to the Free Software
|
26 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
*/
|
28 |
|
29 |
-
define('GCE_PLUGIN_NAME', str_replace('.php', '', basename(__FILE__)));
|
30 |
-
define('GCE_TEXT_DOMAIN', 'google-calendar-events');
|
31 |
-
define('GCE_OPTIONS_NAME', 'gce_options');
|
32 |
-
define('GCE_GENERAL_OPTIONS_NAME', 'gce_general');
|
33 |
-
define('GCE_VERSION', 0.
|
34 |
-
|
35 |
-
if(!class_exists('Google_Calendar_Events')){
|
36 |
-
class Google_Calendar_Events{
|
37 |
-
function __construct(){
|
38 |
-
|
39 |
-
add_action('init', array($this, 'init_plugin'));
|
40 |
-
add_action('wp_ajax_gce_ajax', array($this, 'gce_ajax'));
|
41 |
-
add_action('wp_ajax_nopriv_gce_ajax', array($this, 'gce_ajax'));
|
42 |
-
add_action('widgets_init', array($this, 'add_widget'));
|
43 |
|
44 |
//No point doing any of this if currently processing an AJAX request
|
45 |
-
if(!defined('DOING_AJAX') || !DOING_AJAX){
|
46 |
-
add_action('admin_menu', array($this, 'setup_admin'));
|
47 |
-
add_action('admin_init', array($this, 'init_admin'));
|
48 |
-
add_action('wp_print_styles', array($this, 'add_styles'));
|
49 |
-
add_action('wp_print_scripts', array($this, 'add_scripts'));
|
50 |
-
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'add_settings_link'));
|
51 |
-
add_shortcode('google-calendar-events', array($this, 'shortcode_handler'));
|
52 |
}
|
53 |
}
|
54 |
|
55 |
//PHP 5.2 is required (json_decode), so if PHP version is lower then 5.2, display an error message and deactivate the plugin
|
56 |
function activate_plugin(){
|
57 |
-
if(version_compare(PHP_VERSION, '5.2', '<')){
|
58 |
-
if(is_admin() && (!defined('DOING_AJAX') || !DOING_AJAX)){
|
59 |
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
60 |
-
deactivate_plugins(basename(__FILE__));
|
61 |
-
wp_die('Google Calendar Events requires the server on which your site resides to be running PHP 5.2 or higher. As of version 3.2, WordPress itself will also <a href="http://wordpress.org/news/2010/07/eol-for-php4-and-mysql4">have this requirement</a>. You should get in touch with your web hosting provider and ask them to update PHP.<br /><br /><a href="' . admin_url('plugins.php') . '">Back to Plugins</a>');
|
62 |
}
|
63 |
}
|
64 |
}
|
65 |
|
66 |
//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)
|
67 |
-
function update_settings(){
|
68 |
//If there are some plugin options in the database, but no version info, then this must be an upgrade from version 0.5 or below, so add flag that will provide user with option to clear old transients
|
69 |
-
if(get_option(GCE_OPTIONS_NAME) && !get_option('gce_version')
|
|
|
70 |
|
71 |
-
add_option('gce_version', GCE_VERSION);
|
72 |
|
73 |
-
add_option(GCE_OPTIONS_NAME);
|
74 |
-
add_option(GCE_GENERAL_OPTIONS_NAME);
|
75 |
|
76 |
//Get feed options
|
77 |
-
$options = get_option(GCE_OPTIONS_NAME);
|
78 |
|
79 |
-
if(!empty($options)){
|
80 |
-
foreach($options as $key => $saved_feed_options){
|
81 |
$defaults = array(
|
82 |
'id' => 1,
|
83 |
'title' => '',
|
@@ -110,32 +117,32 @@ if(!class_exists('Google_Calendar_Events')){
|
|
110 |
);
|
111 |
|
112 |
//If necessary, copy saved behaviour of old show_past_events and day_limit options into the new from / until options
|
113 |
-
if(isset($saved_feed_options['show_past_events'])){
|
114 |
-
if($saved_feed_options['show_past_events']
|
115 |
$saved_feed_options['retrieve_from'] = 'month-start';
|
116 |
-
}else{
|
117 |
$saved_feed_options['retrieve_from'] = 'today';
|
118 |
}
|
119 |
}
|
120 |
|
121 |
-
if(isset($saved_feed_options['day_limit']) && $saved_feed_options['day_limit']
|
122 |
$saved_feed_options['retrieve_until'] = 'today';
|
123 |
-
$saved_feed_options['retrieve_until_value'] = (int)$saved_feed_options['day_limit'] * 86400;
|
124 |
}
|
125 |
|
126 |
//Update old display_start / display_end values
|
127 |
-
if(!isset($saved_feed_options['display_start']))
|
128 |
$saved_feed_options['display_start'] = 'none';
|
129 |
-
elseif($saved_feed_options['display_start']
|
130 |
$saved_feed_options['display_start'] = 'time';
|
131 |
|
132 |
-
if(!isset($saved_feed_options['display_end']))
|
133 |
$saved_feed_options['display_end'] = 'none';
|
134 |
-
elseif($saved_feed_options['display_end']
|
135 |
$saved_feed_options['display_end'] = 'time-date';
|
136 |
|
137 |
//Merge saved options with defaults
|
138 |
-
foreach($saved_feed_options as $option_name => $option){
|
139 |
$defaults[$option_name] = $saved_feed_options[$option_name];
|
140 |
}
|
141 |
|
@@ -144,112 +151,123 @@ if(!class_exists('Google_Calendar_Events')){
|
|
144 |
}
|
145 |
|
146 |
//Save feed options
|
147 |
-
update_option(GCE_OPTIONS_NAME, $options);
|
148 |
|
149 |
//Get general options
|
150 |
-
$options = get_option(GCE_GENERAL_OPTIONS_NAME);
|
151 |
|
152 |
$defaults = array(
|
153 |
'stylesheet' => '',
|
154 |
'javascript' => false,
|
155 |
'loading' => 'Loading...',
|
156 |
'error' => 'Events cannot currently be displayed, sorry! Please check back later.',
|
157 |
-
'fields' => true
|
|
|
158 |
);
|
159 |
|
160 |
-
$old_stylesheet_option = get_option('gce_stylesheet');
|
161 |
|
162 |
-
//If old custom stylesheet
|
163 |
-
if($old_stylesheet_option
|
164 |
$defaults['stylesheet'] = $old_stylesheet_option;
|
165 |
-
delete_option('gce_stylesheet');
|
166 |
-
}elseif(isset($options['stylesheet'])){
|
167 |
$defaults['stylesheet'] = $options['stylesheet'];
|
168 |
}
|
169 |
|
170 |
-
if(isset($options['javascript']))
|
171 |
-
|
172 |
-
|
173 |
-
if(isset($options['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
//Save general options
|
176 |
-
update_option(GCE_GENERAL_OPTIONS_NAME, $defaults);
|
177 |
}
|
178 |
|
179 |
-
function init_plugin(){
|
180 |
//Load text domain for i18n
|
181 |
-
load_plugin_textdomain(GCE_TEXT_DOMAIN, false, dirname(plugin_basename(__FILE__)) . '/languages');
|
182 |
-
if(get_option('timezone_string') != '') date_default_timezone_set(get_option('timezone_string'));
|
183 |
}
|
184 |
|
185 |
//Adds 'Settings' link to main WordPress Plugins page
|
186 |
-
function add_settings_link($links){
|
187 |
-
array_unshift($links, '<a href="options-general.php?page=google-calendar-events.php">' . __('Settings', GCE_TEXT_DOMAIN) . '</a>');
|
188 |
return $links;
|
189 |
}
|
190 |
|
191 |
//Setup admin settings page
|
192 |
function setup_admin(){
|
193 |
-
if(function_exists('add_options_page'
|
|
|
194 |
}
|
195 |
|
196 |
//Prints admin settings page
|
197 |
-
function admin_page(){
|
198 |
?>
|
199 |
<div class="wrap">
|
200 |
<div id="icon-options-general" class="icon32"><br /></div>
|
201 |
|
202 |
-
<h2><?php _e('Google Calendar Events', GCE_TEXT_DOMAIN); ?></h2>
|
203 |
|
204 |
-
<?php if(get_option('gce_clear_old_transients')): ?>
|
205 |
<div class="error">
|
206 |
-
<p><?php _e('
|
207 |
-
<p><a href="<?php echo wp_nonce_url(add_query_arg(array('gce_action' => 'clear_old_transients')), 'gce_action_clear_old_transients'); ?>"><?php _e('Clear expired cached data', GCE_TEXT_DOMAIN); ?></a></p>
|
208 |
-
<p><?php _e('or', GCE_TEXT_DOMAIN); ?></p>
|
209 |
-
<p><a href="<?php echo wp_nonce_url(add_query_arg(array('gce_action' => 'ignore_old_transients')), 'gce_action_ignore_old_transients'); ?>"><?php _e('Ignore this notice', GCE_TEXT_DOMAIN); ?></a></p>
|
210 |
</div>
|
211 |
<?php endif; ?>
|
212 |
|
213 |
<form method="post" action="options.php" id="test-form">
|
214 |
<?php
|
215 |
-
if(isset($_GET['action']) && !isset($_GET['settings-updated'])){
|
216 |
-
switch($_GET['action']){
|
217 |
//Add feed section
|
218 |
case 'add':
|
219 |
-
settings_fields('gce_options');
|
220 |
-
do_settings_sections('add_feed');
|
221 |
-
do_settings_sections('add_display');
|
222 |
-
do_settings_sections('add_builder');
|
223 |
-
do_settings_sections('add_simple_display');
|
224 |
-
?><p class="submit"><input type="submit" class="button-primary submit" name="gce_options[submit_add]" value="<?php _e('Add Feed', GCE_TEXT_DOMAIN); ?>" /></p>
|
225 |
-
<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
|
226 |
break;
|
227 |
case 'refresh':
|
228 |
-
settings_fields('gce_options');
|
229 |
-
do_settings_sections('refresh_feed');
|
230 |
-
?><p class="submit"><input type="submit" class="button-primary submit" name="gce_options[submit_refresh]" value="<?php _e('Refresh Feed', GCE_TEXT_DOMAIN); ?>" /></p>
|
231 |
-
<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
|
232 |
break;
|
233 |
//Edit feed section
|
234 |
case 'edit':
|
235 |
-
settings_fields('gce_options');
|
236 |
-
do_settings_sections('edit_feed');
|
237 |
-
do_settings_sections('edit_display');
|
238 |
-
do_settings_sections('edit_builder');
|
239 |
-
do_settings_sections('edit_simple_display');
|
240 |
-
?><p class="submit"><input type="submit" class="button-primary submit" name="gce_options[submit_edit]" value="<?php _e('Save Changes', GCE_TEXT_DOMAIN); ?>" /></p>
|
241 |
-
<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
|
242 |
break;
|
243 |
//Delete feed section
|
244 |
case 'delete':
|
245 |
-
settings_fields('gce_options');
|
246 |
-
do_settings_sections('delete_feed');
|
247 |
-
?><p class="submit"><input type="submit" class="button-primary submit" name="gce_options[submit_delete]" value="<?php _e('Delete Feed', GCE_TEXT_DOMAIN); ?>" /></p>
|
248 |
-
<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
|
249 |
}
|
250 |
}else{
|
251 |
//Main admin section
|
252 |
-
settings_fields('gce_general');
|
253 |
require_once 'admin/main.php';
|
254 |
}
|
255 |
?>
|
@@ -259,27 +277,35 @@ if(!class_exists('Google_Calendar_Events')){
|
|
259 |
}
|
260 |
|
261 |
//Initialize admin stuff
|
262 |
-
function init_admin(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
//If updating from a previous version, update the settings
|
264 |
-
$version
|
265 |
-
|
266 |
|
267 |
//If the message about old transients was displayed, check authority and intention, and then either clear transients or clear flag
|
268 |
-
if(isset($_GET['gce_action']) && current_user_can('manage_options')){
|
269 |
-
switch($_GET['gce_action']){
|
270 |
case 'clear_old_transients':
|
271 |
-
check_admin_referer('gce_action_clear_old_transients');
|
272 |
$this->clear_old_transients();
|
273 |
-
add_settings_error('gce_options', 'gce_cleared_old_transients', __('Old cached data cleared.', GCE_TEXT_DOMAIN), 'updated');
|
274 |
break;
|
275 |
case 'ignore_old_transients':
|
276 |
-
check_admin_referer('gce_action_ignore_old_transients');
|
277 |
-
delete_option('gce_clear_old_transients');
|
278 |
}
|
279 |
}
|
280 |
|
281 |
-
register_setting('gce_options', 'gce_options', array($this, 'validate_feed_options'));
|
282 |
-
register_setting('gce_general', 'gce_general', array($this, 'validate_general_options'));
|
283 |
|
284 |
require_once 'admin/add.php';
|
285 |
require_once 'admin/edit.php';
|
@@ -288,111 +314,112 @@ if(!class_exists('Google_Calendar_Events')){
|
|
288 |
}
|
289 |
|
290 |
//Clears any expired transients from the database
|
291 |
-
function clear_old_transients(){
|
292 |
global $wpdb;
|
293 |
|
294 |
//Retrieve names of all transients
|
295 |
-
$transients = $wpdb->get_results("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%transient%' AND option_name NOT LIKE '%transient_timeout%'");
|
296 |
|
297 |
-
if(!empty($transients)){
|
298 |
-
foreach($transients as $transient){
|
299 |
//Attempt to retrieve the transient. If it has expired, it will be deleted
|
300 |
-
get_transient(str_replace('_transient_', '', $transient->option_name));
|
301 |
}
|
302 |
}
|
303 |
|
304 |
//Remove the flag
|
305 |
-
delete_option('gce_clear_old_transients');
|
306 |
}
|
307 |
|
308 |
//Register the widget
|
309 |
-
function add_widget(){
|
310 |
require_once 'widget/gce-widget.php';
|
311 |
-
return register_widget('GCE_Widget');
|
312 |
}
|
313 |
|
314 |
//Check / validate submitted feed options data before being stored
|
315 |
-
function validate_feed_options($input){
|
316 |
//Get saved options
|
317 |
-
$options = get_option(GCE_OPTIONS_NAME);
|
318 |
|
319 |
-
if(isset($input['submit_delete'])){
|
320 |
//If delete button was clicked, delete feed from options array and remove associated transients
|
321 |
-
unset($options[$input['id']]);
|
322 |
-
$this->delete_feed_transients((int)$input['id']);
|
323 |
-
add_settings_error('gce_options', 'gce_deleted', __(sprintf('Feed %s deleted.', absint($input['id'])), GCE_TEXT_DOMAIN), 'updated');
|
324 |
-
}
|
325 |
//If refresh button was clicked, delete transients associated with feed
|
326 |
-
$this->delete_feed_transients((int)$input['id']);
|
327 |
-
add_settings_error('gce_options', 'gce_refreshed', __(sprintf('Cached data for feed %s cleared.', absint($input['id'])), GCE_TEXT_DOMAIN), 'updated');
|
328 |
-
}else{
|
329 |
//Otherwise, validate options and add / update them
|
330 |
|
331 |
//Check id is positive integer
|
332 |
-
$id = absint($input['id']);
|
333 |
//Escape title text
|
334 |
-
$title = esc_html($input['title']);
|
335 |
//Escape feed url
|
336 |
-
$url = esc_url($input['url']);
|
337 |
|
338 |
//Array of valid options for retrieve_from and retrieve_until settings
|
339 |
-
$valid_retrieve_options = array('now', 'today', 'week', 'month-start', 'month-end', 'any', 'date');
|
340 |
|
341 |
$retrieve_from = 'today';
|
342 |
$retrieve_from_value = 0;
|
343 |
|
344 |
//Ensure retrieve_from is valid
|
345 |
-
if(in_array($input['retrieve_from'], $valid_retrieve_options)){
|
346 |
$retrieve_from = $input['retrieve_from'];
|
347 |
-
$retrieve_from_value = (int)$input['retrieve_from_value'];
|
348 |
}
|
349 |
|
350 |
$retrieve_until = 'any';
|
351 |
$retrieve_until_value = 0;
|
352 |
|
353 |
//Ensure retrieve_until is valid
|
354 |
-
if(in_array($input['retrieve_until'], $valid_retrieve_options)){
|
355 |
$retrieve_until = $input['retrieve_until'];
|
356 |
-
$retrieve_until_value = (int)$input['retrieve_until_value'];
|
357 |
}
|
358 |
|
359 |
//Check max events is a positive integer. If absint returns 0, reset to default (25)
|
360 |
-
$max_events = (absint($input['max_events'])
|
361 |
|
362 |
-
$date_format = wp_filter_kses($input['date_format']);
|
363 |
-
$time_format = wp_filter_kses($input['time_format']);
|
364 |
|
365 |
//Escape timezone
|
366 |
-
$timezone = esc_html($input['timezone']);
|
367 |
|
368 |
//Make sure cache duration is a positive integer or 0. If user has typed 0, leave as 0 but if 0 is returned from absint, set to default (43200)
|
369 |
$cache_duration = $input['cache_duration'];
|
370 |
-
if(
|
|
|
371 |
|
372 |
-
$multiple_day = (isset($input['multiple_day']) ? 'true' : 'false'
|
373 |
|
374 |
-
$display_start = esc_html($input['display_start']);
|
375 |
-
$display_end = esc_html($input['display_end']);
|
376 |
|
377 |
//Display options must be 'on' or null
|
378 |
-
$display_location = (isset($input['display_location']) ? 'on' : null
|
379 |
-
$display_desc = (isset($input['display_desc']) ? 'on' : null
|
380 |
-
$display_link = (isset($input['display_link']) ? 'on' : null
|
381 |
-
$display_link_target = (isset($input['display_link_target']) ? 'on' : null
|
382 |
|
383 |
//Filter display text
|
384 |
-
$display_start_text = wp_filter_kses($input['display_start_text']);
|
385 |
-
$display_end_text = wp_filter_kses($input['display_end_text']);
|
386 |
-
$display_location_text = wp_filter_kses($input['display_location_text']);
|
387 |
-
$display_desc_text = wp_filter_kses($input['display_desc_text']);
|
388 |
-
$display_link_text = wp_filter_kses($input['display_link_text']);
|
389 |
|
390 |
-
$display_separator = wp_filter_kses($input['display_separator']);
|
391 |
|
392 |
-
$display_desc_limit = absint($input['display_desc_limit'])
|
393 |
|
394 |
-
$use_builder = (
|
395 |
-
$builder = wp_kses_post($input['builder']);
|
396 |
|
397 |
//Fill options array with validated values
|
398 |
$options[$id] = array(
|
@@ -426,130 +453,163 @@ if(!class_exists('Google_Calendar_Events')){
|
|
426 |
'builder' => $builder
|
427 |
);
|
428 |
|
429 |
-
if(isset($input['submit_add']))
|
430 |
-
add_settings_error('gce_options', 'gce_added', __(sprintf('Feed %s added.', absint($input['id'])), GCE_TEXT_DOMAIN), 'updated');
|
431 |
-
|
432 |
-
add_settings_error('gce_options', 'gce_edited', __(sprintf('Settings for feed %s updated.', absint($input['id'])), GCE_TEXT_DOMAIN), 'updated');
|
433 |
-
}
|
434 |
}
|
435 |
|
436 |
return $options;
|
437 |
}
|
438 |
|
439 |
//Validate submitted general options
|
440 |
-
function validate_general_options($input){
|
441 |
$options = get_option(GCE_GENERAL_OPTIONS_NAME);
|
442 |
|
443 |
-
$options['stylesheet'] = esc_url($input['stylesheet']);
|
444 |
-
$options['javascript'] = (isset($input['javascript']) ? true : false
|
445 |
-
$options['loading'] = esc_html($input['loading']);
|
446 |
-
$options['error'] = wp_filter_kses($input['error']);
|
447 |
-
$options['fields'] = (isset($input['fields']) ? true : false
|
|
|
448 |
|
449 |
-
add_settings_error('gce_general', 'gce_general_updated', __('General options updated.', GCE_TEXT_DOMAIN), 'updated');
|
450 |
|
451 |
return $options;
|
452 |
}
|
453 |
|
454 |
-
//Delete all transients (cached feed data) associated with
|
455 |
-
function delete_feed_transients($id){
|
456 |
-
delete_transient('gce_feed_' . $id);
|
457 |
-
delete_transient('gce_feed_' . $id . '_url');
|
458 |
}
|
459 |
|
460 |
//Handles the shortcode stuff
|
461 |
-
function shortcode_handler($atts){
|
462 |
-
$options = get_option(GCE_OPTIONS_NAME);
|
463 |
|
464 |
//Check that any feeds have been added
|
465 |
-
if(is_array($options) && !empty($options)){
|
466 |
-
extract(shortcode_atts(array(
|
467 |
-
'id' => '
|
468 |
'type' => 'grid',
|
469 |
'title' => false,
|
470 |
-
'max' => 0
|
471 |
-
|
|
|
472 |
|
473 |
-
|
474 |
-
$feed_ids =
|
475 |
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
}
|
480 |
|
481 |
-
|
|
|
|
|
|
|
|
|
482 |
|
483 |
-
|
484 |
-
|
485 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
}
|
487 |
|
488 |
//Ensure max events is a positive integer
|
489 |
-
$max_events = absint($max);
|
|
|
|
|
|
|
490 |
|
491 |
//Check that at least one valid feed id has been entered
|
492 |
-
if(
|
493 |
-
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);
|
494 |
-
}else{
|
495 |
-
//
|
496 |
-
$feed_ids = implode('-', $feed_ids);
|
497 |
|
498 |
//If title has been omitted from shortcode, set title_text to null, otherwise set to title (even if empty string)
|
499 |
-
$title_text = ($title
|
500 |
-
|
501 |
-
switch($type){
|
502 |
-
case 'grid':
|
503 |
-
|
504 |
-
case '
|
505 |
-
|
|
|
|
|
|
|
|
|
506 |
}
|
507 |
}
|
508 |
-
}else{
|
509 |
-
return __('No feeds have been added yet. You can add a feed in the Google Calendar Events settings.', GCE_TEXT_DOMAIN);
|
510 |
}
|
511 |
}
|
512 |
|
513 |
//Adds the required CSS
|
514 |
-
function add_styles(){
|
515 |
//Don't add styles if on admin screens
|
516 |
-
if(!is_admin()){
|
517 |
-
wp_enqueue_style('gce_styles', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/css/gce-style.css');
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
|
519 |
//If user has entered a URL to a custom stylesheet, enqueue it too
|
520 |
-
$options
|
521 |
-
|
522 |
}
|
523 |
}
|
524 |
|
525 |
//Adds the required scripts
|
526 |
-
function add_scripts(){
|
527 |
//Don't add scripts if on admin screens
|
528 |
-
if(!is_admin()){
|
529 |
-
$options = get_option(GCE_GENERAL_OPTIONS_NAME);
|
530 |
-
$add_to_footer = (bool)$options['javascript'];
|
531 |
-
|
532 |
-
wp_enqueue_script('jquery');
|
533 |
-
wp_enqueue_script('gce_jquery_qtip', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/js/jquery-qtip.js', array('jquery'), null, $add_to_footer);
|
534 |
-
wp_enqueue_script('gce_scripts', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/js/gce-script.js', array('jquery'), null, $add_to_footer);
|
535 |
-
wp_localize_script('gce_scripts', 'GoogleCalendarEvents', array(
|
536 |
-
'ajaxurl' => admin_url('admin-ajax.php'),
|
537 |
'loading' => $options['loading']
|
538 |
-
));
|
539 |
-
}else{
|
540 |
-
wp_enqueue_script('gce_scripts', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/js/gce-admin-script.js', array('jquery'));
|
541 |
}
|
542 |
}
|
543 |
|
544 |
//AJAX stuffs
|
545 |
-
function gce_ajax(){
|
546 |
-
if(isset($_GET['gce_feed_ids'])){
|
547 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
548 |
//The page grid markup to be returned via AJAX
|
549 |
-
echo gce_print_grid($
|
550 |
-
}elseif($_GET['gce_type']
|
|
|
|
|
551 |
//The widget grid markup to be returned via AJAX
|
552 |
-
gce_widget_content_grid($
|
553 |
}
|
554 |
}
|
555 |
die();
|
@@ -557,66 +617,69 @@ if(!class_exists('Google_Calendar_Events')){
|
|
557 |
}
|
558 |
}
|
559 |
|
560 |
-
function gce_print_list($feed_ids, $title_text, $max_events, $grouped = false){
|
561 |
require_once 'inc/gce-parser.php';
|
562 |
|
563 |
-
$ids = explode('-', $feed_ids);
|
564 |
|
565 |
//Create new GCE_Parser object, passing array of feed id(s)
|
566 |
-
$list = new GCE_Parser($ids, $title_text, $max_events);
|
567 |
|
568 |
$num_errors = $list->get_num_errors();
|
569 |
|
570 |
//If there are less errors than feeds parsed, at least one feed must have parsed successfully so continue to display the list
|
571 |
-
if($num_errors < count($ids)){
|
572 |
-
$markup = '<div class="gce-page-list">' . $list->get_list($grouped) . '</div>';
|
573 |
|
574 |
//If there was at least one error, return the list markup with error messages (for admins only)
|
575 |
-
if($num_errors > 0 && current_user_can('manage_options')
|
|
|
576 |
|
577 |
//Otherwise just return the list markup
|
578 |
return $markup;
|
579 |
-
}else{
|
580 |
//If current user is an admin, display an error message explaining problem(s). Otherwise, display a 'nice' error messsage
|
581 |
-
if(current_user_can('manage_options')){
|
582 |
return $list->error_messages();
|
583 |
-
}else{
|
584 |
-
$options = get_option(GCE_GENERAL_OPTIONS_NAME);
|
585 |
return $options['error'];
|
586 |
}
|
587 |
}
|
588 |
}
|
589 |
|
590 |
-
function gce_print_grid($feed_ids, $title_text, $max_events, $ajaxified = false, $month = null, $year = null){
|
591 |
require_once 'inc/gce-parser.php';
|
592 |
|
593 |
-
$ids = explode('-', $feed_ids);
|
594 |
|
595 |
//Create new GCE_Parser object, passing array of feed id(s) returned from gce_get_feed_ids()
|
596 |
-
$grid = new GCE_Parser($ids, $title_text, $max_events);
|
597 |
|
598 |
$num_errors = $grid->get_num_errors();
|
599 |
|
600 |
//If there are less errors than feeds parsed, at least one feed must have parsed successfully so continue to display the grid
|
601 |
-
if($num_errors < count($ids)){
|
602 |
$markup = '<div class="gce-page-grid" id="gce-page-grid-' . $feed_ids .'">';
|
603 |
|
604 |
//Add AJAX script if required
|
605 |
-
if
|
|
|
606 |
|
607 |
-
$markup .= $grid->get_grid($year, $month, $ajaxified) . '</div>';
|
608 |
|
609 |
//If there was at least one error, return the grid markup with an error message (for admins only)
|
610 |
-
if($num_errors > 0 && current_user_can('manage_options')
|
|
|
611 |
|
612 |
//Otherwise just return the grid markup
|
613 |
return $markup;
|
614 |
-
}else{
|
615 |
//If current user is an admin, display an error message explaining problem. Otherwise, display a 'nice' error messsage
|
616 |
-
if(current_user_can('manage_options')){
|
617 |
return $grid->error_messages();
|
618 |
-
}else{
|
619 |
-
$options = get_option(GCE_GENERAL_OPTIONS_NAME);
|
620 |
return $options['error'];
|
621 |
}
|
622 |
}
|
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.7
|
7 |
Author: Ross Hanney
|
8 |
Author URI: http://www.rhanney.co.uk
|
9 |
License: GPL2
|
24 |
You should have received a copy of the GNU General Public License
|
25 |
along with this program; if not, write to the Free Software
|
26 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
+
|
28 |
+
---
|
29 |
+
|
30 |
+
Contains code inspired by and adapted from GCalendar - http://g4j.laoneo.net/content/extensions/download/cat_view/2-simplepie-gcalendar.html
|
31 |
+
|
32 |
+
GCalendar: Copyright 2007-2009 Allon Moritz
|
33 |
*/
|
34 |
|
35 |
+
define( 'GCE_PLUGIN_NAME', str_replace( '.php', '', basename( __FILE__ ) ) );
|
36 |
+
define( 'GCE_TEXT_DOMAIN', 'google-calendar-events' );
|
37 |
+
define( 'GCE_OPTIONS_NAME', 'gce_options' );
|
38 |
+
define( 'GCE_GENERAL_OPTIONS_NAME', 'gce_general' );
|
39 |
+
define( 'GCE_VERSION', 0.7 );
|
40 |
+
|
41 |
+
if ( ! class_exists( 'Google_Calendar_Events' ) ) {
|
42 |
+
class Google_Calendar_Events {
|
43 |
+
function __construct() {
|
44 |
+
register_activation_hook( __FILE__, array( $this, 'activate_plugin' ) );
|
45 |
+
add_action( 'init', array( $this, 'init_plugin' ) );
|
46 |
+
add_action( 'wp_ajax_gce_ajax', array( $this, 'gce_ajax' ) );
|
47 |
+
add_action( 'wp_ajax_nopriv_gce_ajax', array( $this, 'gce_ajax' ) );
|
48 |
+
add_action( 'widgets_init', array( $this, 'add_widget' ) );
|
49 |
|
50 |
//No point doing any of this if currently processing an AJAX request
|
51 |
+
if ( ! defined( 'DOING_AJAX' ) || !DOING_AJAX ) {
|
52 |
+
add_action( 'admin_menu', array( $this, 'setup_admin' ) );
|
53 |
+
add_action( 'admin_init', array( $this, 'init_admin' ) );
|
54 |
+
add_action( 'wp_print_styles', array( $this, 'add_styles' ) );
|
55 |
+
add_action( 'wp_print_scripts', array( $this, 'add_scripts' ) );
|
56 |
+
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_settings_link' ) );
|
57 |
+
add_shortcode( 'google-calendar-events', array( $this, 'shortcode_handler' ) );
|
58 |
}
|
59 |
}
|
60 |
|
61 |
//PHP 5.2 is required (json_decode), so if PHP version is lower then 5.2, display an error message and deactivate the plugin
|
62 |
function activate_plugin(){
|
63 |
+
if( version_compare( PHP_VERSION, '5.2', '<' ) ) {
|
64 |
+
if( is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ) ) {
|
65 |
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
66 |
+
deactivate_plugins( basename( __FILE__ ) );
|
67 |
+
wp_die( 'Google Calendar Events requires the server on which your site resides to be running PHP 5.2 or higher. As of version 3.2, WordPress itself will also <a href="http://wordpress.org/news/2010/07/eol-for-php4-and-mysql4">have this requirement</a>. You should get in touch with your web hosting provider and ask them to update PHP.<br /><br /><a href="' . admin_url( 'plugins.php' ) . '">Back to Plugins</a>' );
|
68 |
}
|
69 |
}
|
70 |
}
|
71 |
|
72 |
//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)
|
73 |
+
function update_settings() {
|
74 |
//If there are some plugin options in the database, but no version info, then this must be an upgrade from version 0.5 or below, so add flag that will provide user with option to clear old transients
|
75 |
+
if ( get_option( GCE_OPTIONS_NAME ) && ! get_option( 'gce_version' ) )
|
76 |
+
add_option( 'gce_clear_old_transients', true );
|
77 |
|
78 |
+
add_option( 'gce_version', GCE_VERSION );
|
79 |
|
80 |
+
add_option( GCE_OPTIONS_NAME );
|
81 |
+
add_option( GCE_GENERAL_OPTIONS_NAME );
|
82 |
|
83 |
//Get feed options
|
84 |
+
$options = get_option( GCE_OPTIONS_NAME );
|
85 |
|
86 |
+
if ( ! empty( $options ) ) {
|
87 |
+
foreach ( $options as $key => $saved_feed_options ) {
|
88 |
$defaults = array(
|
89 |
'id' => 1,
|
90 |
'title' => '',
|
117 |
);
|
118 |
|
119 |
//If necessary, copy saved behaviour of old show_past_events and day_limit options into the new from / until options
|
120 |
+
if ( isset( $saved_feed_options['show_past_events'] ) ) {
|
121 |
+
if ( 'true' == $saved_feed_options['show_past_events'] ) {
|
122 |
$saved_feed_options['retrieve_from'] = 'month-start';
|
123 |
+
} else {
|
124 |
$saved_feed_options['retrieve_from'] = 'today';
|
125 |
}
|
126 |
}
|
127 |
|
128 |
+
if ( isset( $saved_feed_options['day_limit'] ) && '' != $saved_feed_options['day_limit'] ) {
|
129 |
$saved_feed_options['retrieve_until'] = 'today';
|
130 |
+
$saved_feed_options['retrieve_until_value'] = (int) $saved_feed_options['day_limit'] * 86400;
|
131 |
}
|
132 |
|
133 |
//Update old display_start / display_end values
|
134 |
+
if ( ! isset( $saved_feed_options['display_start'] ) )
|
135 |
$saved_feed_options['display_start'] = 'none';
|
136 |
+
elseif ( 'on' == $saved_feed_options['display_start'] )
|
137 |
$saved_feed_options['display_start'] = 'time';
|
138 |
|
139 |
+
if( ! isset( $saved_feed_options['display_end'] ) )
|
140 |
$saved_feed_options['display_end'] = 'none';
|
141 |
+
elseif ( 'on' == $saved_feed_options['display_end'] )
|
142 |
$saved_feed_options['display_end'] = 'time-date';
|
143 |
|
144 |
//Merge saved options with defaults
|
145 |
+
foreach ( $saved_feed_options as $option_name => $option ) {
|
146 |
$defaults[$option_name] = $saved_feed_options[$option_name];
|
147 |
}
|
148 |
|
151 |
}
|
152 |
|
153 |
//Save feed options
|
154 |
+
update_option( GCE_OPTIONS_NAME, $options );
|
155 |
|
156 |
//Get general options
|
157 |
+
$options = get_option( GCE_GENERAL_OPTIONS_NAME );
|
158 |
|
159 |
$defaults = array(
|
160 |
'stylesheet' => '',
|
161 |
'javascript' => false,
|
162 |
'loading' => 'Loading...',
|
163 |
'error' => 'Events cannot currently be displayed, sorry! Please check back later.',
|
164 |
+
'fields' => true,
|
165 |
+
'old_stylesheet' => false
|
166 |
);
|
167 |
|
168 |
+
$old_stylesheet_option = get_option( 'gce_stylesheet' );
|
169 |
|
170 |
+
//If old custom stylesheet option was set, add it to general options, then delete old option
|
171 |
+
if( false !== $old_stylesheet_option ) {
|
172 |
$defaults['stylesheet'] = $old_stylesheet_option;
|
173 |
+
delete_option( 'gce_stylesheet' );
|
174 |
+
} elseif ( isset($options['stylesheet'] ) ) {
|
175 |
$defaults['stylesheet'] = $options['stylesheet'];
|
176 |
}
|
177 |
|
178 |
+
if ( isset($options['javascript'] ) )
|
179 |
+
$defaults['javascript'] = $options['javascript'];
|
180 |
+
|
181 |
+
if ( isset( $options['loading'] ) )
|
182 |
+
$defaults['loading'] = $options['loading'];
|
183 |
+
|
184 |
+
if ( isset($options['error'] ) )
|
185 |
+
$defaults['error'] = $options['error'];
|
186 |
+
|
187 |
+
if ( isset($options['fields'] ) )
|
188 |
+
$defaults['fields'] = $options['fields'];
|
189 |
+
|
190 |
+
if( isset( $options['old_stylesheet'] ) )
|
191 |
+
$defaults['old_stylesheet'] = $options['old_stylesheet'];
|
192 |
|
193 |
//Save general options
|
194 |
+
update_option( GCE_GENERAL_OPTIONS_NAME, $defaults );
|
195 |
}
|
196 |
|
197 |
+
function init_plugin() {
|
198 |
//Load text domain for i18n
|
199 |
+
load_plugin_textdomain( GCE_TEXT_DOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
|
|
200 |
}
|
201 |
|
202 |
//Adds 'Settings' link to main WordPress Plugins page
|
203 |
+
function add_settings_link( $links ) {
|
204 |
+
array_unshift( $links, '<a href="options-general.php?page=google-calendar-events.php">' . __( 'Settings', GCE_TEXT_DOMAIN ) . '</a>' );
|
205 |
return $links;
|
206 |
}
|
207 |
|
208 |
//Setup admin settings page
|
209 |
function setup_admin(){
|
210 |
+
if ( function_exists( 'add_options_page' ) )
|
211 |
+
add_options_page( 'Google Calendar Events', 'Google Calendar Events', 'manage_options', basename( __FILE__ ), array( $this, 'admin_page' ) );
|
212 |
}
|
213 |
|
214 |
//Prints admin settings page
|
215 |
+
function admin_page() {
|
216 |
?>
|
217 |
<div class="wrap">
|
218 |
<div id="icon-options-general" class="icon32"><br /></div>
|
219 |
|
220 |
+
<h2><?php _e( 'Google Calendar Events', GCE_TEXT_DOMAIN ); ?></h2>
|
221 |
|
222 |
+
<?php if ( get_option( 'gce_clear_old_transients' ) ): ?>
|
223 |
<div class="error">
|
224 |
+
<p><strong><?php _e( 'Notice:', GCE_TEXT_DOMAIN ); ?></strong> <?php _e( 'The way in which Google Calendar Events stores cached data has been much improved in version 0.6. As you have upgraded from a previous version of the plugin, there is likely to be some data from the old caching system hanging around in your database that is now useless. Click below to clear expired cached data from your database.', GCE_TEXT_DOMAIN); ?></p>
|
225 |
+
<p><a href="<?php echo wp_nonce_url( add_query_arg( array( 'gce_action' => 'clear_old_transients' ) ), 'gce_action_clear_old_transients' ); ?>"><?php _e( 'Clear expired cached data', GCE_TEXT_DOMAIN ); ?></a></p>
|
226 |
+
<p><?php _e( 'or', GCE_TEXT_DOMAIN ); ?></p>
|
227 |
+
<p><a href="<?php echo wp_nonce_url( add_query_arg( array( 'gce_action' => 'ignore_old_transients' ) ), 'gce_action_ignore_old_transients' ); ?>"><?php _e( 'Ignore this notice', GCE_TEXT_DOMAIN ); ?></a></p>
|
228 |
</div>
|
229 |
<?php endif; ?>
|
230 |
|
231 |
<form method="post" action="options.php" id="test-form">
|
232 |
<?php
|
233 |
+
if ( isset( $_GET['action'] ) && ! isset( $_GET['settings-updated'] ) ) {
|
234 |
+
switch ( $_GET['action'] ) {
|
235 |
//Add feed section
|
236 |
case 'add':
|
237 |
+
settings_fields( 'gce_options' );
|
238 |
+
do_settings_sections( 'add_feed' );
|
239 |
+
do_settings_sections( 'add_display' );
|
240 |
+
do_settings_sections( 'add_builder' );
|
241 |
+
do_settings_sections( 'add_simple_display' );
|
242 |
+
?><p class="submit"><input type="submit" class="button-primary submit" name="gce_options[submit_add]" value="<?php _e( 'Add Feed', GCE_TEXT_DOMAIN ); ?>" /></p>
|
243 |
+
<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
|
244 |
break;
|
245 |
case 'refresh':
|
246 |
+
settings_fields( 'gce_options' );
|
247 |
+
do_settings_sections( 'refresh_feed' );
|
248 |
+
?><p class="submit"><input type="submit" class="button-primary submit" name="gce_options[submit_refresh]" value="<?php _e( 'Refresh Feed', GCE_TEXT_DOMAIN ); ?>" /></p>
|
249 |
+
<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
|
250 |
break;
|
251 |
//Edit feed section
|
252 |
case 'edit':
|
253 |
+
settings_fields( 'gce_options' );
|
254 |
+
do_settings_sections( 'edit_feed' );
|
255 |
+
do_settings_sections( 'edit_display' );
|
256 |
+
do_settings_sections( 'edit_builder' );
|
257 |
+
do_settings_sections( 'edit_simple_display' );
|
258 |
+
?><p class="submit"><input type="submit" class="button-primary submit" name="gce_options[submit_edit]" value="<?php _e( 'Save Changes', GCE_TEXT_DOMAIN ); ?>" /></p>
|
259 |
+
<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
|
260 |
break;
|
261 |
//Delete feed section
|
262 |
case 'delete':
|
263 |
+
settings_fields( 'gce_options' );
|
264 |
+
do_settings_sections( 'delete_feed' );
|
265 |
+
?><p class="submit"><input type="submit" class="button-primary submit" name="gce_options[submit_delete]" value="<?php _e( 'Delete Feed', GCE_TEXT_DOMAIN ); ?>" /></p>
|
266 |
+
<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
|
267 |
}
|
268 |
}else{
|
269 |
//Main admin section
|
270 |
+
settings_fields( 'gce_general' );
|
271 |
require_once 'admin/main.php';
|
272 |
}
|
273 |
?>
|
277 |
}
|
278 |
|
279 |
//Initialize admin stuff
|
280 |
+
function init_admin() {
|
281 |
+
$version = get_option( 'gce_version' );
|
282 |
+
|
283 |
+
//If updating from before 0.7, set old_stylesheet option to true
|
284 |
+
if ( false === $version || version_compare( $version, '0.7', '<' ) ) {
|
285 |
+
$options = get_option( GCE_GENERAL_OPTIONS_NAME );
|
286 |
+
$options['old_stylesheet'] = true;
|
287 |
+
}
|
288 |
+
|
289 |
//If updating from a previous version, update the settings
|
290 |
+
if ( false === $version || version_compare( $version, GCE_VERSION, '<' ) )
|
291 |
+
$this->update_settings();
|
292 |
|
293 |
//If the message about old transients was displayed, check authority and intention, and then either clear transients or clear flag
|
294 |
+
if ( isset( $_GET['gce_action'] ) && current_user_can( 'manage_options' ) ) {
|
295 |
+
switch ( $_GET['gce_action'] ) {
|
296 |
case 'clear_old_transients':
|
297 |
+
check_admin_referer( 'gce_action_clear_old_transients' );
|
298 |
$this->clear_old_transients();
|
299 |
+
add_settings_error( 'gce_options', 'gce_cleared_old_transients', __( 'Old cached data cleared.', GCE_TEXT_DOMAIN ), 'updated' );
|
300 |
break;
|
301 |
case 'ignore_old_transients':
|
302 |
+
check_admin_referer( 'gce_action_ignore_old_transients' );
|
303 |
+
delete_option( 'gce_clear_old_transients' );
|
304 |
}
|
305 |
}
|
306 |
|
307 |
+
register_setting( 'gce_options', 'gce_options', array( $this, 'validate_feed_options' ) );
|
308 |
+
register_setting( 'gce_general', 'gce_general', array( $this, 'validate_general_options' ) );
|
309 |
|
310 |
require_once 'admin/add.php';
|
311 |
require_once 'admin/edit.php';
|
314 |
}
|
315 |
|
316 |
//Clears any expired transients from the database
|
317 |
+
function clear_old_transients() {
|
318 |
global $wpdb;
|
319 |
|
320 |
//Retrieve names of all transients
|
321 |
+
$transients = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%transient%' AND option_name NOT LIKE '%transient_timeout%'" );
|
322 |
|
323 |
+
if ( ! empty( $transients ) ) {
|
324 |
+
foreach ( $transients as $transient ) {
|
325 |
//Attempt to retrieve the transient. If it has expired, it will be deleted
|
326 |
+
get_transient( str_replace( '_transient_', '', $transient->option_name ) );
|
327 |
}
|
328 |
}
|
329 |
|
330 |
//Remove the flag
|
331 |
+
delete_option( 'gce_clear_old_transients' );
|
332 |
}
|
333 |
|
334 |
//Register the widget
|
335 |
+
function add_widget() {
|
336 |
require_once 'widget/gce-widget.php';
|
337 |
+
return register_widget( 'GCE_Widget' );
|
338 |
}
|
339 |
|
340 |
//Check / validate submitted feed options data before being stored
|
341 |
+
function validate_feed_options( $input ) {
|
342 |
//Get saved options
|
343 |
+
$options = get_option( GCE_OPTIONS_NAME );
|
344 |
|
345 |
+
if ( isset( $input['submit_delete'] ) ) {
|
346 |
//If delete button was clicked, delete feed from options array and remove associated transients
|
347 |
+
unset( $options[$input['id']] );
|
348 |
+
$this->delete_feed_transients( (int) $input['id'] );
|
349 |
+
add_settings_error( 'gce_options', 'gce_deleted', __( sprintf('Feed %s deleted.', absint( $input['id'] ) ), GCE_TEXT_DOMAIN ), 'updated' );
|
350 |
+
} elseif ( isset($input['submit_refresh'] ) ) {
|
351 |
//If refresh button was clicked, delete transients associated with feed
|
352 |
+
$this->delete_feed_transients( (int) $input['id'] );
|
353 |
+
add_settings_error( 'gce_options', 'gce_refreshed', __( sprintf('Cached data for feed %s cleared.', absint( $input['id'] ) ), GCE_TEXT_DOMAIN ), 'updated' );
|
354 |
+
} else {
|
355 |
//Otherwise, validate options and add / update them
|
356 |
|
357 |
//Check id is positive integer
|
358 |
+
$id = absint( $input['id'] );
|
359 |
//Escape title text
|
360 |
+
$title = esc_html( $input['title'] );
|
361 |
//Escape feed url
|
362 |
+
$url = esc_url( $input['url'] );
|
363 |
|
364 |
//Array of valid options for retrieve_from and retrieve_until settings
|
365 |
+
$valid_retrieve_options = array( 'now', 'today', 'week', 'month-start', 'month-end', 'any', 'date' );
|
366 |
|
367 |
$retrieve_from = 'today';
|
368 |
$retrieve_from_value = 0;
|
369 |
|
370 |
//Ensure retrieve_from is valid
|
371 |
+
if( in_array( $input['retrieve_from'], $valid_retrieve_options ) ) {
|
372 |
$retrieve_from = $input['retrieve_from'];
|
373 |
+
$retrieve_from_value = (int) $input['retrieve_from_value'];
|
374 |
}
|
375 |
|
376 |
$retrieve_until = 'any';
|
377 |
$retrieve_until_value = 0;
|
378 |
|
379 |
//Ensure retrieve_until is valid
|
380 |
+
if ( in_array( $input['retrieve_until'], $valid_retrieve_options ) ) {
|
381 |
$retrieve_until = $input['retrieve_until'];
|
382 |
+
$retrieve_until_value = (int) $input['retrieve_until_value'];
|
383 |
}
|
384 |
|
385 |
//Check max events is a positive integer. If absint returns 0, reset to default (25)
|
386 |
+
$max_events = ( 0 == absint($input['max_events'] ) ) ? 25 : absint( $input['max_events'] );
|
387 |
|
388 |
+
$date_format = wp_filter_kses( $input['date_format'] );
|
389 |
+
$time_format = wp_filter_kses( $input['time_format'] );
|
390 |
|
391 |
//Escape timezone
|
392 |
+
$timezone = esc_html( $input['timezone'] );
|
393 |
|
394 |
//Make sure cache duration is a positive integer or 0. If user has typed 0, leave as 0 but if 0 is returned from absint, set to default (43200)
|
395 |
$cache_duration = $input['cache_duration'];
|
396 |
+
if ( '0' != $cache_duration )
|
397 |
+
$cache_duration = ( 0 == absint( $cache_duration ) ) ? 43200 : absint( $cache_duration );
|
398 |
|
399 |
+
$multiple_day = ( isset( $input['multiple_day'] ) ) ? 'true' : 'false';
|
400 |
|
401 |
+
$display_start = esc_html( $input['display_start'] );
|
402 |
+
$display_end = esc_html( $input['display_end'] );
|
403 |
|
404 |
//Display options must be 'on' or null
|
405 |
+
$display_location = ( isset( $input['display_location'] ) ) ? 'on' : null;
|
406 |
+
$display_desc = ( isset( $input['display_desc'] ) ) ? 'on' : null;
|
407 |
+
$display_link = ( isset( $input['display_link'] ) ) ? 'on' : null;
|
408 |
+
$display_link_target = ( isset( $input['display_link_target'] ) ) ? 'on' : null;
|
409 |
|
410 |
//Filter display text
|
411 |
+
$display_start_text = wp_filter_kses( $input['display_start_text'] );
|
412 |
+
$display_end_text = wp_filter_kses( $input['display_end_text'] );
|
413 |
+
$display_location_text = wp_filter_kses( $input['display_location_text'] );
|
414 |
+
$display_desc_text = wp_filter_kses( $input['display_desc_text'] );
|
415 |
+
$display_link_text = wp_filter_kses( $input['display_link_text'] );
|
416 |
|
417 |
+
$display_separator = wp_filter_kses( $input['display_separator'] );
|
418 |
|
419 |
+
$display_desc_limit = ( 0 == absint( $input['display_desc_limit'] ) ) ? '' : absint( $input['display_desc_limit'] );
|
420 |
|
421 |
+
$use_builder = ( 'false' == $input['use_builder'] ) ? 'false' : 'true';
|
422 |
+
$builder = wp_kses_post( $input['builder'] );
|
423 |
|
424 |
//Fill options array with validated values
|
425 |
$options[$id] = array(
|
453 |
'builder' => $builder
|
454 |
);
|
455 |
|
456 |
+
if ( isset( $input['submit_add'] ) )
|
457 |
+
add_settings_error( 'gce_options', 'gce_added', __( sprintf( 'Feed %s added.', absint( $input['id'] ) ), GCE_TEXT_DOMAIN ), 'updated' );
|
458 |
+
else
|
459 |
+
add_settings_error( 'gce_options', 'gce_edited', __( sprintf( 'Settings for feed %s updated.', absint( $input['id'] ) ), GCE_TEXT_DOMAIN ), 'updated' );
|
|
|
460 |
}
|
461 |
|
462 |
return $options;
|
463 |
}
|
464 |
|
465 |
//Validate submitted general options
|
466 |
+
function validate_general_options( $input ) {
|
467 |
$options = get_option(GCE_GENERAL_OPTIONS_NAME);
|
468 |
|
469 |
+
$options['stylesheet'] = esc_url( $input['stylesheet'] );
|
470 |
+
$options['javascript'] = ( isset( $input['javascript'] ) ) ? true : false;
|
471 |
+
$options['loading'] = esc_html( $input['loading'] );
|
472 |
+
$options['error'] = wp_filter_kses( $input['error'] );
|
473 |
+
$options['fields'] = ( isset( $input['fields'] ) ) ? true : false;
|
474 |
+
$options['old_stylesheet'] = ( isset( $input['old_stylesheet'] ) ) ? true : false;
|
475 |
|
476 |
+
add_settings_error( 'gce_general', 'gce_general_updated', __( 'General options updated.', GCE_TEXT_DOMAIN ), 'updated' );
|
477 |
|
478 |
return $options;
|
479 |
}
|
480 |
|
481 |
+
//Delete all transients (cached feed data) associated with feed specified
|
482 |
+
function delete_feed_transients( $id ) {
|
483 |
+
delete_transient( 'gce_feed_' . $id );
|
484 |
+
delete_transient( 'gce_feed_' . $id . '_url' );
|
485 |
}
|
486 |
|
487 |
//Handles the shortcode stuff
|
488 |
+
function shortcode_handler( $atts ) {
|
489 |
+
$options = get_option( GCE_OPTIONS_NAME );
|
490 |
|
491 |
//Check that any feeds have been added
|
492 |
+
if ( is_array( $options ) && ! empty( $options ) ) {
|
493 |
+
extract( shortcode_atts( array(
|
494 |
+
'id' => '',
|
495 |
'type' => 'grid',
|
496 |
'title' => false,
|
497 |
+
'max' => 0,
|
498 |
+
'order' => 'asc'
|
499 |
+
), $atts ) );
|
500 |
|
501 |
+
$no_feeds_exist = true;
|
502 |
+
$feed_ids = array();
|
503 |
|
504 |
+
if ( '' != $id ) {
|
505 |
+
//Break comma delimited list of feed ids into array
|
506 |
+
$feed_ids = explode( ',', str_replace( ' ', '', $id ) );
|
|
|
507 |
|
508 |
+
//Check each id is an integer, if not, remove it from the array
|
509 |
+
foreach ( $feed_ids as $key => $feed_id ) {
|
510 |
+
if ( 0 == absint( $feed_id ) )
|
511 |
+
unset( $feed_ids[$key] );
|
512 |
+
}
|
513 |
|
514 |
+
//If at least one of the feed ids entered exists, set no_feeds_exist to false
|
515 |
+
foreach ( $feed_ids as $feed_id ) {
|
516 |
+
if ( isset($options[$feed_id] ) )
|
517 |
+
$no_feeds_exist = false;
|
518 |
+
}
|
519 |
+
} else {
|
520 |
+
foreach ( $options as $feed ) {
|
521 |
+
$feed_ids[] = $feed['id'];
|
522 |
+
}
|
523 |
+
|
524 |
+
$no_feeds_exist = false;
|
525 |
}
|
526 |
|
527 |
//Ensure max events is a positive integer
|
528 |
+
$max_events = absint( $max );
|
529 |
+
|
530 |
+
//Ensure sort order is asc or desc
|
531 |
+
$sort_order = ( 'desc' == $order ) ? 'desc' : 'asc';
|
532 |
|
533 |
//Check that at least one valid feed id has been entered
|
534 |
+
if ( empty( $feed_ids ) || $no_feeds_exist ) {
|
535 |
+
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 );
|
536 |
+
} else {
|
537 |
+
//Turns feed_ids back into string of feed ids delimited by '-' ('1-2-3-4' for example)
|
538 |
+
$feed_ids = implode( '-', $feed_ids );
|
539 |
|
540 |
//If title has been omitted from shortcode, set title_text to null, otherwise set to title (even if empty string)
|
541 |
+
$title_text = ( false === $title ) ? null : $title;
|
542 |
+
|
543 |
+
switch ( $type ) {
|
544 |
+
case 'grid':
|
545 |
+
return gce_print_grid( $feed_ids, $title_text, $max_events );
|
546 |
+
case 'ajax':
|
547 |
+
return gce_print_grid( $feed_ids, $title_text, $max_events, true );
|
548 |
+
case 'list':
|
549 |
+
return gce_print_list( $feed_ids, $title_text, $max_events, $sort_order );
|
550 |
+
case 'list-grouped':
|
551 |
+
return gce_print_list( $feed_ids, $title_text, $max_events, $sort_order, true );
|
552 |
}
|
553 |
}
|
554 |
+
} else {
|
555 |
+
return __( 'No feeds have been added yet. You can add a feed in the Google Calendar Events settings.', GCE_TEXT_DOMAIN );
|
556 |
}
|
557 |
}
|
558 |
|
559 |
//Adds the required CSS
|
560 |
+
function add_styles() {
|
561 |
//Don't add styles if on admin screens
|
562 |
+
if( ! is_admin() ) {
|
563 |
+
wp_enqueue_style( 'gce_styles', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/css/gce-style.css' );
|
564 |
+
|
565 |
+
$options = get_option( GCE_GENERAL_OPTIONS_NAME );
|
566 |
+
|
567 |
+
//If old stylesheet option is enabled, enqueue old styles
|
568 |
+
if ( $options['old_stylesheet'] )
|
569 |
+
wp_enqueue_style( 'gce_old_styles', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/css/gce-old-style.css' );
|
570 |
|
571 |
//If user has entered a URL to a custom stylesheet, enqueue it too
|
572 |
+
if( '' != $options['stylesheet'] )
|
573 |
+
wp_enqueue_style( 'gce_custom_styles', $options['stylesheet'] );
|
574 |
}
|
575 |
}
|
576 |
|
577 |
//Adds the required scripts
|
578 |
+
function add_scripts() {
|
579 |
//Don't add scripts if on admin screens
|
580 |
+
if ( ! is_admin() ) {
|
581 |
+
$options = get_option( GCE_GENERAL_OPTIONS_NAME );
|
582 |
+
$add_to_footer = (bool) $options['javascript'];
|
583 |
+
|
584 |
+
wp_enqueue_script( 'jquery' );
|
585 |
+
wp_enqueue_script( 'gce_jquery_qtip', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/js/jquery-qtip.js', array( 'jquery' ), null, $add_to_footer );
|
586 |
+
wp_enqueue_script( 'gce_scripts', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/js/gce-script.js', array( 'jquery' ), null, $add_to_footer );
|
587 |
+
wp_localize_script( 'gce_scripts', 'GoogleCalendarEvents', array(
|
588 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
589 |
'loading' => $options['loading']
|
590 |
+
) );
|
591 |
+
} else {
|
592 |
+
wp_enqueue_script( 'gce_scripts', WP_PLUGIN_URL . '/' . GCE_PLUGIN_NAME . '/js/gce-admin-script.js', array( 'jquery' ) );
|
593 |
}
|
594 |
}
|
595 |
|
596 |
//AJAX stuffs
|
597 |
+
function gce_ajax() {
|
598 |
+
if ( isset( $_GET['gce_feed_ids'] ) ) {
|
599 |
+
$ids = esc_html( $_GET['gce_feed_ids'] );
|
600 |
+
$title = esc_html( $_GET['gce_title_text'] );
|
601 |
+
$max = absint( $_GET['gce_max_events'] );
|
602 |
+
$month = absint( $_GET['gce_month'] );
|
603 |
+
$year = absint( $_GET['gce_year'] );
|
604 |
+
|
605 |
+
if ( 'page' == $_GET['gce_type'] ) {
|
606 |
//The page grid markup to be returned via AJAX
|
607 |
+
echo gce_print_grid( $ids, $title, $max, true, $month, $year );
|
608 |
+
} elseif ( 'widget' == $_GET['gce_type'] ) {
|
609 |
+
$widget = esc_html( $_GET['gce_widget_id'] );
|
610 |
+
|
611 |
//The widget grid markup to be returned via AJAX
|
612 |
+
gce_widget_content_grid( $ids, $title, $max, $widget, true, $month, $year );
|
613 |
}
|
614 |
}
|
615 |
die();
|
617 |
}
|
618 |
}
|
619 |
|
620 |
+
function gce_print_list( $feed_ids, $title_text, $max_events, $sort_order, $grouped = false ) {
|
621 |
require_once 'inc/gce-parser.php';
|
622 |
|
623 |
+
$ids = explode( '-', $feed_ids );
|
624 |
|
625 |
//Create new GCE_Parser object, passing array of feed id(s)
|
626 |
+
$list = new GCE_Parser( $ids, $title_text, $max_events, $sort_order );
|
627 |
|
628 |
$num_errors = $list->get_num_errors();
|
629 |
|
630 |
//If there are less errors than feeds parsed, at least one feed must have parsed successfully so continue to display the list
|
631 |
+
if ( $num_errors < count( $ids ) ) {
|
632 |
+
$markup = '<div class="gce-page-list">' . $list->get_list( $grouped ) . '</div>';
|
633 |
|
634 |
//If there was at least one error, return the list markup with error messages (for admins only)
|
635 |
+
if ( $num_errors > 0 && current_user_can( 'manage_options' ) )
|
636 |
+
return $list->error_messages() . $markup;
|
637 |
|
638 |
//Otherwise just return the list markup
|
639 |
return $markup;
|
640 |
+
} else {
|
641 |
//If current user is an admin, display an error message explaining problem(s). Otherwise, display a 'nice' error messsage
|
642 |
+
if ( current_user_can( 'manage_options' ) ) {
|
643 |
return $list->error_messages();
|
644 |
+
} else {
|
645 |
+
$options = get_option( GCE_GENERAL_OPTIONS_NAME );
|
646 |
return $options['error'];
|
647 |
}
|
648 |
}
|
649 |
}
|
650 |
|
651 |
+
function gce_print_grid( $feed_ids, $title_text, $max_events, $ajaxified = false, $month = null, $year = null ) {
|
652 |
require_once 'inc/gce-parser.php';
|
653 |
|
654 |
+
$ids = explode( '-', $feed_ids );
|
655 |
|
656 |
//Create new GCE_Parser object, passing array of feed id(s) returned from gce_get_feed_ids()
|
657 |
+
$grid = new GCE_Parser( $ids, $title_text, $max_events );
|
658 |
|
659 |
$num_errors = $grid->get_num_errors();
|
660 |
|
661 |
//If there are less errors than feeds parsed, at least one feed must have parsed successfully so continue to display the grid
|
662 |
+
if ( $num_errors < count( $ids ) ) {
|
663 |
$markup = '<div class="gce-page-grid" id="gce-page-grid-' . $feed_ids .'">';
|
664 |
|
665 |
//Add AJAX script if required
|
666 |
+
if ( $ajaxified )
|
667 |
+
$markup .= '<script type="text/javascript">jQuery(document).ready(function($){gce_ajaxify("gce-page-grid-' . $feed_ids . '", "' . $feed_ids . '", "' . $max_events . '", "' . $title_text . '", "page");});</script>';
|
668 |
|
669 |
+
$markup .= $grid->get_grid( $year, $month, $ajaxified ) . '</div>';
|
670 |
|
671 |
//If there was at least one error, return the grid markup with an error message (for admins only)
|
672 |
+
if ( $num_errors > 0 && current_user_can( 'manage_options' ) )
|
673 |
+
return $grid->error_messages() . $markup;
|
674 |
|
675 |
//Otherwise just return the grid markup
|
676 |
return $markup;
|
677 |
+
} else {
|
678 |
//If current user is an admin, display an error message explaining problem. Otherwise, display a 'nice' error messsage
|
679 |
+
if ( current_user_can( 'manage_options' ) ) {
|
680 |
return $grid->error_messages();
|
681 |
+
} else {
|
682 |
+
$options = get_option( GCE_GENERAL_OPTIONS_NAME );
|
683 |
return $options['error'];
|
684 |
}
|
685 |
}
|
inc/gce-event.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
class GCE_Event{
|
|
|
3 |
private $title;
|
4 |
private $description;
|
5 |
private $location;
|
@@ -8,10 +9,12 @@ class GCE_Event{
|
|
8 |
private $link;
|
9 |
private $type;
|
10 |
private $num_in_day;
|
|
|
11 |
private $feed;
|
12 |
private $day_type;
|
13 |
|
14 |
-
function __construct($title, $description, $location, $start_time, $end_time, $link){
|
|
|
15 |
$this->title = $title;
|
16 |
$this->description = $description;
|
17 |
$this->location = $location;
|
@@ -20,66 +23,66 @@ class GCE_Event{
|
|
20 |
$this->link = $link;
|
21 |
|
22 |
//Calculate which day type this event is (SWD = single whole day, SPD = single part day, MWD = multiple whole day, MPD = multiple part day)
|
23 |
-
if(($start_time + 86400) <= $end_time){
|
24 |
-
if(($start_time + 86400) == $end_time){
|
25 |
$this->day_type = 'SWD';
|
26 |
-
}else{
|
27 |
-
if((date('g:i a', $start_time)
|
28 |
$this->day_type = 'MWD';
|
29 |
-
}else{
|
30 |
$this->day_type = 'MPD';
|
31 |
}
|
32 |
}
|
33 |
-
}else{
|
34 |
$this->day_type = 'SPD';
|
35 |
}
|
36 |
}
|
37 |
|
38 |
-
function set_feed($feed){
|
39 |
$this->feed = $feed;
|
40 |
}
|
41 |
|
42 |
-
function get_feed(){
|
43 |
return $this->feed;
|
44 |
}
|
45 |
|
46 |
-
function get_start_time(){
|
47 |
return $this->start_time;
|
48 |
}
|
49 |
|
50 |
-
function get_end_time(){
|
51 |
return $this->end_time;
|
52 |
}
|
53 |
|
54 |
-
function get_day_type(){
|
55 |
return $this->day_type;
|
56 |
}
|
57 |
|
58 |
//Returns an array of days (as UNIX timestamps) that this events spans
|
59 |
-
function get_days(){
|
60 |
//Round start date to nearest day
|
61 |
-
$start_time = mktime(0, 0, 0, date('m', $this->start_time), date('d', $this->start_time) , date('Y', $this->start_time));
|
62 |
|
63 |
$days = array();
|
64 |
|
65 |
//If multiple day events should be handled, and this event is a multi-day event, add multiple day event to required days
|
66 |
-
if($this->feed->get_multi_day() && ($this->day_type == 'MPD' || $this->day_type == 'MWD')){
|
67 |
$on_next_day = true;
|
68 |
$next_day = $start_time;
|
69 |
|
70 |
-
while($on_next_day){
|
71 |
//If the end time of the event is after 00:00 on the next day (therefore, not doesn't end on this day)
|
72 |
-
if($this->end_time > $next_day){
|
73 |
-
//
|
74 |
-
if($next_day >= $this->feed->get_feed_start() && $next_day < $this->feed->get_feed_end()){
|
75 |
$days[] = $next_day;
|
76 |
}
|
77 |
-
}else{
|
78 |
$on_next_day = false;
|
79 |
}
|
80 |
$next_day += 86400;
|
81 |
}
|
82 |
-
}else{
|
83 |
//Add event into array of events for that day
|
84 |
$days[] = $start_time;
|
85 |
}
|
@@ -88,59 +91,72 @@ class GCE_Event{
|
|
88 |
}
|
89 |
|
90 |
//Returns the markup for this event, so that it can be used in the construction of a grid / list
|
91 |
-
function get_event_markup($display_type, $
|
92 |
//Set the display type (either tooltip or list)
|
93 |
$this->type = $display_type;
|
94 |
|
95 |
//Set which number event this is in day (first in day etc)
|
96 |
-
$this->num_in_day = $
|
|
|
|
|
|
|
97 |
|
98 |
//Use the builder or the old display options to create the markup, depending on user choice
|
99 |
-
if($this->feed->get_use_builder()
|
|
|
|
|
100 |
return $this->use_old_display_options();
|
101 |
}
|
102 |
|
103 |
//Return the event markup using the builder
|
104 |
-
function use_builder(){
|
105 |
//Array of valid shortcodes
|
106 |
-
$shortcodes =
|
107 |
-
|
108 |
-
|
109 |
-
'
|
110 |
-
'start-
|
111 |
-
'start-
|
112 |
-
'
|
113 |
-
'
|
114 |
-
'end-
|
115 |
-
'end-
|
116 |
-
'
|
117 |
-
'
|
118 |
-
'
|
119 |
-
'
|
120 |
-
'
|
121 |
-
'
|
122 |
-
'
|
123 |
-
'
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
//Anything between the opening and closing tags of the following logical shortcodes (including further shortcodes) will only be displayed if:
|
126 |
|
127 |
-
'if-all-day
|
128 |
-
'if-not-all-day
|
129 |
-
'if-title
|
130 |
-
'if-description
|
131 |
-
'if-location
|
132 |
-
'if-tooltip
|
133 |
-
'if-list
|
134 |
-
'if-now
|
135 |
-
'if-not-now
|
136 |
-
'if-started
|
137 |
-
'if-not-started
|
138 |
-
'if-ended
|
139 |
-
'if-not-ended
|
140 |
-
'if-first
|
141 |
-
'if-not-first
|
142 |
-
'if-multi-day
|
143 |
-
'if-single-day'
|
|
|
|
|
|
|
144 |
|
145 |
$markup = $this->feed->get_builder();
|
146 |
|
@@ -148,179 +164,288 @@ class GCE_Event{
|
|
148 |
|
149 |
//Go through the builder text looking for valid shortcodes. If one is found, send it to parse_shortcodes(). Once $count reaches 0, there are no un-parsed shortcodes
|
150 |
//left, so return the markup (which now contains all the appropriate event information)
|
151 |
-
do{
|
152 |
-
$markup = preg_replace_callback(
|
153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
return $markup;
|
156 |
}
|
157 |
|
158 |
//Parse a shortcode, returning the appropriate event information
|
159 |
//Much of this code is 'borrowed' from WordPress' own shortcode handling stuff!
|
160 |
-
function parse_shortcode($m){
|
161 |
-
if(
|
|
|
162 |
|
163 |
//Extract any attributes contained in the shortcode
|
164 |
-
extract(shortcode_atts(array(
|
165 |
'newwindow' => 'false',
|
166 |
-
'format'
|
167 |
-
'limit'
|
168 |
-
'html'
|
169 |
-
'markdown'
|
170 |
-
'precision' => '1'
|
171 |
-
|
|
|
|
|
172 |
|
173 |
//Sanitize the attributes
|
174 |
-
$
|
175 |
-
$
|
176 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
//Do the appropriate stuff depending on which shortcode we're looking at. See valid shortcode list (above) for explanation of each shortcode
|
179 |
-
switch($m[2]){
|
180 |
case 'event-title':
|
181 |
-
$title = esc_html(trim($this->title));
|
182 |
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
|
|
186 |
|
187 |
return $m[1] . $title . $m[6];
|
|
|
188 |
case 'start-time':
|
189 |
-
return $m[1] . date_i18n($this->feed->get_time_format(), $this->start_time) . $m[6];
|
|
|
190 |
case 'start-date':
|
191 |
-
return $m[1] . date_i18n($this->feed->get_date_format(), $this->start_time) . $m[6];
|
|
|
192 |
case 'start-custom':
|
193 |
-
return $m[1] . date_i18n($format, $this->start_time) . $m[6];
|
|
|
194 |
case 'start-human':
|
195 |
-
return $m[1] . $this->gce_human_time_diff($this->start_time,
|
|
|
196 |
case 'end-time':
|
197 |
-
return $m[1] . date_i18n($this->feed->get_time_format(), $this->end_time) . $m[6];
|
|
|
198 |
case 'end-date':
|
199 |
-
return $m[1] . date_i18n($this->feed->get_date_format(), $this->end_time) . $m[6];
|
|
|
200 |
case 'end-custom':
|
201 |
-
return $m[1] . date_i18n($format, $this->end_time) . $m[6];
|
|
|
202 |
case 'end-human':
|
203 |
-
return $m[1] . $this->gce_human_time_diff($this->end_time,
|
|
|
204 |
case 'location':
|
205 |
-
$location = esc_html(trim($this->location));
|
206 |
|
207 |
-
|
208 |
-
|
209 |
-
|
|
|
|
|
210 |
|
211 |
return $m[1] . $location . $m[6];
|
|
|
212 |
case 'description':
|
213 |
-
$description = esc_html(trim($this->description));
|
214 |
|
215 |
//If a word limit has been set, trim the description to the required length
|
216 |
-
if($limit
|
217 |
-
preg_match('/([\S]+\s*){0,' . $limit . '}/', esc_html($this->description), $description);
|
218 |
-
$description = trim($description[0]);
|
219 |
}
|
220 |
|
221 |
-
if($markdown
|
222 |
-
|
223 |
-
|
224 |
-
|
|
|
|
|
225 |
}else{
|
226 |
-
//Otherwise, preserve line breaks
|
227 |
-
$description =
|
|
|
|
|
|
|
|
|
228 |
}
|
229 |
|
230 |
return $m[1] . $description . $m[6];
|
|
|
231 |
case 'link':
|
232 |
-
$new_window = ($newwindow
|
233 |
-
return $m[1] . '<a href="' . $this->link . '&ctz=' . $this->feed->get_timezone() . '"' . $new_window . '>' . $m[5] . '</a>' . $m[6];
|
234 |
-
|
235 |
-
|
|
|
|
|
236 |
case 'feed-id':
|
237 |
return $m[1] . $this->feed->get_feed_id() . $m[6];
|
|
|
238 |
case 'feed-title':
|
239 |
return $m[1] . $this->feed->get_feed_title() . $m[6];
|
|
|
240 |
case 'maps-link':
|
241 |
-
$new_window = ($newwindow
|
242 |
-
return $m[1] . '<a href="http://maps.google.com?q=' . urlencode($this->location) . '"' . $new_window . '>' . $m[5] . '</a>' . $m[6];
|
|
|
243 |
case 'length':
|
244 |
-
return $m[1] . $this->gce_human_time_diff($this->start_time, $this->end_time, $precision) . $m[6];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
case 'if-all-day':
|
246 |
-
if(
|
247 |
-
|
|
|
|
|
|
|
248 |
case 'if-not-all-day':
|
249 |
-
if(
|
|
|
|
|
250 |
return '';
|
|
|
251 |
case 'if-title':
|
252 |
-
if(
|
|
|
|
|
253 |
return '';
|
|
|
254 |
case 'if-description':
|
255 |
-
if(
|
|
|
|
|
256 |
return '';
|
|
|
257 |
case 'if-location':
|
258 |
-
if(
|
|
|
|
|
259 |
return '';
|
|
|
260 |
case 'if-tooltip':
|
261 |
-
if(
|
|
|
|
|
262 |
return '';
|
|
|
263 |
case 'if-list':
|
264 |
-
if(
|
|
|
|
|
265 |
return '';
|
|
|
266 |
case 'if-now':
|
267 |
-
if(
|
|
|
|
|
268 |
return '';
|
|
|
269 |
case 'if-not-now':
|
270 |
-
if($this->end_time <
|
|
|
|
|
271 |
return '';
|
|
|
272 |
case 'if-started':
|
273 |
-
if($this->start_time <
|
|
|
|
|
274 |
return '';
|
|
|
275 |
case 'if-not-started':
|
276 |
-
if($this->start_time >
|
|
|
|
|
277 |
return '';
|
|
|
278 |
case 'if-ended':
|
279 |
-
if($this->end_time <
|
|
|
|
|
280 |
return '';
|
|
|
281 |
case 'if-not-ended':
|
282 |
-
if($this->end_time >
|
|
|
|
|
283 |
return '';
|
|
|
284 |
case 'if-first':
|
285 |
-
if($this->num_in_day
|
|
|
|
|
286 |
return '';
|
|
|
287 |
case 'if-not-first':
|
288 |
-
if($this->num_in_day
|
|
|
|
|
289 |
return '';
|
|
|
290 |
case 'if-multi-day':
|
291 |
-
if(
|
|
|
|
|
292 |
return '';
|
|
|
293 |
case 'if-single-day':
|
294 |
-
if(
|
|
|
|
|
295 |
return '';
|
296 |
}
|
297 |
}
|
298 |
|
299 |
//Return the event markup using the old display options
|
300 |
-
function use_old_display_options(){
|
301 |
$display_options = $this->feed->get_display_options();
|
302 |
|
303 |
-
$markup = '<p class="gce-' . $this->type . '-event">' . esc_html($this->title) . '</p>';
|
304 |
|
305 |
$start_end = array();
|
306 |
|
307 |
//If start date / time should be displayed, set up array of start date and time
|
308 |
-
if($display_options['display_start']
|
309 |
$sd = $this->start_time;
|
310 |
-
$start_end['start'] = array(
|
|
|
|
|
|
|
311 |
}
|
312 |
|
313 |
//If end date / time should be displayed, set up array of end date and time
|
314 |
-
if($display_options['display_end']
|
315 |
$ed = $this->end_time;
|
316 |
-
$start_end['end'] = array(
|
|
|
|
|
|
|
317 |
}
|
318 |
|
319 |
//Add the correct start / end, date / time information to $markup
|
320 |
-
foreach($start_end as $start_or_end => $info){
|
321 |
$markup .= '<p class="gce-' . $this->type . '-' . $start_or_end . '"><span>' . $display_options['display_' . $start_or_end . '_text'] . '</span> ';
|
322 |
|
323 |
-
switch($display_options['display_' . $start_or_end]){
|
324 |
case 'time': $markup .= $info['time'];
|
325 |
break;
|
326 |
case 'date': $markup .= $info['date'];
|
@@ -334,73 +459,77 @@ class GCE_Event{
|
|
334 |
}
|
335 |
|
336 |
//If location should be displayed (and is not empty) add to $markup
|
337 |
-
if(isset($display_options['display_location'])){
|
338 |
$event_location = $this->location;
|
339 |
-
if(
|
|
|
340 |
}
|
341 |
|
342 |
//If description should be displayed (and is not empty) add to $markup
|
343 |
-
if(isset($display_options['display_desc'])){
|
344 |
$event_desc = $this->description;
|
345 |
|
346 |
-
if($event_desc
|
347 |
//Limit number of words of description to display, if required
|
348 |
-
if($display_options['display_desc_limit']
|
349 |
-
preg_match('/([\S]+\s*){0,' . $display_options['display_desc_limit'] . '}/', $this->description, $event_desc);
|
350 |
-
$event_desc = trim($event_desc[0]);
|
351 |
}
|
352 |
|
353 |
-
$markup .= '<p class="gce-' . $this->type . '-desc"><span>' . $display_options['display_desc_text'] . '</span> ' . make_clickable(nl2br(esc_html($event_desc))) . '</p>';
|
354 |
}
|
355 |
}
|
356 |
|
357 |
//If link should be displayed add to $markup
|
358 |
-
if(isset($display_options['display_link']))
|
359 |
-
$markup .= '<p class="gce-' . $this->type . '-link"><a href="' . $this->link . '&ctz=' . $this->feed->get_timezone() . '"' . (isset($display_options['display_link_target']) ? ' target="_blank"' : '') . '>' . $display_options['display_link_text'] . '</a></p>';
|
360 |
-
}
|
361 |
|
362 |
return $markup;
|
363 |
}
|
364 |
|
365 |
//Returns the difference between two times in human-readable format. Based on a patch for human_time_diff posted in the WordPress trac (http://core.trac.wordpress.org/ticket/9272) by Viper007Bond
|
366 |
-
function gce_human_time_diff($from, $to = '', $limit = 1){
|
367 |
$units = array(
|
368 |
-
31556926 => array(__('%s year'), __('%s years')),
|
369 |
-
2629744 => array(__('%s month'), __('%s months')),
|
370 |
-
604800 => array(__('%s week'), __('%s weeks')),
|
371 |
-
86400 => array(__('%s day'), __('%s days')),
|
372 |
-
3600 => array(__('%s hour'), __('%s hours')),
|
373 |
-
60 => array(__('%s min'), __('%s mins')),
|
374 |
);
|
375 |
|
376 |
-
if(empty(
|
|
|
377 |
|
378 |
$from = (int) $from;
|
379 |
$to = (int) $to;
|
380 |
-
$diff = (int) abs($to - $from);
|
381 |
|
382 |
$items = 0;
|
383 |
$output = array();
|
384 |
|
385 |
-
foreach($units as $unitsec => $unitnames){
|
386 |
-
if($items >= $limit)
|
|
|
387 |
|
388 |
-
if($diff < $unitsec)
|
|
|
389 |
|
390 |
-
$numthisunits = floor($diff / $unitsec);
|
391 |
-
$diff = $diff - ($numthisunits * $unitsec);
|
392 |
$items++;
|
393 |
|
394 |
-
if($numthisunits > 0
|
|
|
395 |
}
|
396 |
|
397 |
-
$seperator = _x(', ', 'human_time_diff');
|
398 |
|
399 |
-
if(!empty($output)){
|
400 |
-
return implode($seperator, $output);
|
401 |
-
}else{
|
402 |
-
$smallest = array_pop($units);
|
403 |
-
return sprintf($smallest[0], 1);
|
404 |
}
|
405 |
}
|
406 |
}
|
1 |
<?php
|
2 |
class GCE_Event{
|
3 |
+
private $id;
|
4 |
private $title;
|
5 |
private $description;
|
6 |
private $location;
|
9 |
private $link;
|
10 |
private $type;
|
11 |
private $num_in_day;
|
12 |
+
private $pos;
|
13 |
private $feed;
|
14 |
private $day_type;
|
15 |
|
16 |
+
function __construct( $id, $title, $description, $location, $start_time, $end_time, $link ) {
|
17 |
+
$this->id = $id;
|
18 |
$this->title = $title;
|
19 |
$this->description = $description;
|
20 |
$this->location = $location;
|
23 |
$this->link = $link;
|
24 |
|
25 |
//Calculate which day type this event is (SWD = single whole day, SPD = single part day, MWD = multiple whole day, MPD = multiple part day)
|
26 |
+
if ( ( $start_time + 86400 ) <= $end_time ) {
|
27 |
+
if ( ( $start_time + 86400 ) == $end_time ) {
|
28 |
$this->day_type = 'SWD';
|
29 |
+
} else {
|
30 |
+
if ( ( '12:00 am' == date( 'g:i a', $start_time ) ) && ( '12:00 am' == date( 'g:i a', $end_time ) ) ) {
|
31 |
$this->day_type = 'MWD';
|
32 |
+
} else {
|
33 |
$this->day_type = 'MPD';
|
34 |
}
|
35 |
}
|
36 |
+
} else {
|
37 |
$this->day_type = 'SPD';
|
38 |
}
|
39 |
}
|
40 |
|
41 |
+
function set_feed( $feed ) {
|
42 |
$this->feed = $feed;
|
43 |
}
|
44 |
|
45 |
+
function get_feed() {
|
46 |
return $this->feed;
|
47 |
}
|
48 |
|
49 |
+
function get_start_time() {
|
50 |
return $this->start_time;
|
51 |
}
|
52 |
|
53 |
+
function get_end_time() {
|
54 |
return $this->end_time;
|
55 |
}
|
56 |
|
57 |
+
function get_day_type() {
|
58 |
return $this->day_type;
|
59 |
}
|
60 |
|
61 |
//Returns an array of days (as UNIX timestamps) that this events spans
|
62 |
+
function get_days() {
|
63 |
//Round start date to nearest day
|
64 |
+
$start_time = mktime( 0, 0, 0, date( 'm', $this->start_time ), date( 'd', $this->start_time ) , date( 'Y', $this->start_time ) );
|
65 |
|
66 |
$days = array();
|
67 |
|
68 |
//If multiple day events should be handled, and this event is a multi-day event, add multiple day event to required days
|
69 |
+
if ( $this->feed->get_multi_day() && ( $this->day_type == 'MPD' || $this->day_type == 'MWD' ) ) {
|
70 |
$on_next_day = true;
|
71 |
$next_day = $start_time;
|
72 |
|
73 |
+
while ( $on_next_day ) {
|
74 |
//If the end time of the event is after 00:00 on the next day (therefore, not doesn't end on this day)
|
75 |
+
if ( $this->end_time > $next_day ) {
|
76 |
+
//If $next_day is within the event retrieval date range (specified by retrieve events from / until settings)
|
77 |
+
if ( $next_day >= $this->feed->get_feed_start() && $next_day < $this->feed->get_feed_end() ) {
|
78 |
$days[] = $next_day;
|
79 |
}
|
80 |
+
} else {
|
81 |
$on_next_day = false;
|
82 |
}
|
83 |
$next_day += 86400;
|
84 |
}
|
85 |
+
} else {
|
86 |
//Add event into array of events for that day
|
87 |
$days[] = $start_time;
|
88 |
}
|
91 |
}
|
92 |
|
93 |
//Returns the markup for this event, so that it can be used in the construction of a grid / list
|
94 |
+
function get_event_markup( $display_type, $num_in_day, $num ) {
|
95 |
//Set the display type (either tooltip or list)
|
96 |
$this->type = $display_type;
|
97 |
|
98 |
//Set which number event this is in day (first in day etc)
|
99 |
+
$this->num_in_day = $num_in_day;
|
100 |
+
|
101 |
+
//Set the position of this event in array of events currently being processed
|
102 |
+
$this->pos = $num;
|
103 |
|
104 |
//Use the builder or the old display options to create the markup, depending on user choice
|
105 |
+
if ( $this->feed->get_use_builder() )
|
106 |
+
return $this->use_builder();
|
107 |
+
|
108 |
return $this->use_old_display_options();
|
109 |
}
|
110 |
|
111 |
//Return the event markup using the builder
|
112 |
+
function use_builder() {
|
113 |
//Array of valid shortcodes
|
114 |
+
$shortcodes = array(
|
115 |
+
//Event / feed information shortcodes
|
116 |
+
|
117 |
+
'event-title', //The event title
|
118 |
+
'start-time', //The start time of the event (uses the time format from the feed options, if it is set. Otherwise uses the default WordPress time format)
|
119 |
+
'start-date', //The start date of the event (uses the date format from the feed options, if it is set. Otherwise uses the default WordPress date format)
|
120 |
+
'start-custom', //The start time / date of the event (uses a custom PHP date format, specified in the 'format' attribute)
|
121 |
+
'start-human', //The difference between the start time of the event and the time now, in human-readable format, such as '1 hour', '4 days', '15 mins'
|
122 |
+
'end-time', //The end time of the event (uses the time format from the feed options, if it is set. Otherwise uses the default WordPress time format)
|
123 |
+
'end-date', //The end date of the event (uses the date format from the feed options, if it is set. Otherwise uses the default WordPress date format)
|
124 |
+
'end-custom', //The end time / date of the event (uses a custom PHP date format, specified in the 'format' attribute)
|
125 |
+
'end-human', //The difference between the end time of the event and the time now, in human-readable format, such as '1 hour', '4 days', '15 mins'
|
126 |
+
'location', //The event location
|
127 |
+
'description', //The event deescription (number of words can be limited by the 'limit' attribute)
|
128 |
+
'link', //Anything within this shortcode (including further shortcodes) will be linked to the Google Calendar page for this event
|
129 |
+
'url', //The raw link URL to the Google Calendar page for this event (can be used to construct more customized links)
|
130 |
+
'feed-id', //The ID of this feed (Can be useful for constructing feed specific CSS classes)
|
131 |
+
'feed-title', //The feed title
|
132 |
+
'maps-link', //Anything within this shortcode (including further shortcodes) will be linked to a Google Maps page based on whatever is specified for the event location
|
133 |
+
'length', //How long the events lasts, in human-readable format
|
134 |
+
'event-num', //The position of the event in the current list, or the position of the event in the current month (for grids)
|
135 |
+
'event-id', //The event UID (unique identifier assigned by Google)
|
136 |
+
'cal-id', //The calendar ID
|
137 |
|
138 |
//Anything between the opening and closing tags of the following logical shortcodes (including further shortcodes) will only be displayed if:
|
139 |
|
140 |
+
'if-all-day', //This is an all-day event
|
141 |
+
'if-not-all-day', //This is not an all-day event
|
142 |
+
'if-title', //The event has a title
|
143 |
+
'if-description', //The event has a description
|
144 |
+
'if-location', //The event has a location
|
145 |
+
'if-tooltip', //The current display type is 'tooltip'
|
146 |
+
'if-list', //The current display type is 'list'
|
147 |
+
'if-now', //The event is taking place now (after the start time, but before the end time)
|
148 |
+
'if-not-now', //The event is not taking place now (may have ended or not yet started)
|
149 |
+
'if-started', //The event has started (and even if it has ended)
|
150 |
+
'if-not-started', //The event has not yet started
|
151 |
+
'if-ended', //The event has ended
|
152 |
+
'if-not-ended', //The event has not ended (and even if it hasn't started)
|
153 |
+
'if-first', //The event is the first in the day
|
154 |
+
'if-not-first', //The event is not the first in the day
|
155 |
+
'if-multi-day', //The event spans multiple days
|
156 |
+
'if-single-day' //The event does not span multiple days
|
157 |
+
);
|
158 |
+
|
159 |
+
$shortcodes = implode( '|', $shortcodes );
|
160 |
|
161 |
$markup = $this->feed->get_builder();
|
162 |
|
164 |
|
165 |
//Go through the builder text looking for valid shortcodes. If one is found, send it to parse_shortcodes(). Once $count reaches 0, there are no un-parsed shortcodes
|
166 |
//left, so return the markup (which now contains all the appropriate event information)
|
167 |
+
do {
|
168 |
+
$markup = preg_replace_callback(
|
169 |
+
'/(.?)\[(' . $shortcodes . ')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)/s',
|
170 |
+
array( $this, 'parse_shortcode' ),
|
171 |
+
$markup,
|
172 |
+
-1,
|
173 |
+
$count
|
174 |
+
);
|
175 |
+
} while ( $count > 0 );
|
176 |
|
177 |
return $markup;
|
178 |
}
|
179 |
|
180 |
//Parse a shortcode, returning the appropriate event information
|
181 |
//Much of this code is 'borrowed' from WordPress' own shortcode handling stuff!
|
182 |
+
function parse_shortcode( $m ) {
|
183 |
+
if ( '[' == $m[1] && ']' == $m[6] )
|
184 |
+
return substr( $m[0], 1, -1 );
|
185 |
|
186 |
//Extract any attributes contained in the shortcode
|
187 |
+
extract( shortcode_atts( array(
|
188 |
'newwindow' => 'false',
|
189 |
+
'format' => '',
|
190 |
+
'limit' => '0',
|
191 |
+
'html' => 'false',
|
192 |
+
'markdown' => 'false',
|
193 |
+
'precision' => '1',
|
194 |
+
'offset' => '0',
|
195 |
+
'autolink' => 'true'
|
196 |
+
), shortcode_parse_atts( $m[3] ) ) );
|
197 |
|
198 |
//Sanitize the attributes
|
199 |
+
$newwindow = ( 'true' === $newwindow );
|
200 |
+
$format = esc_attr( $format );
|
201 |
+
$limit = absint( $limit );
|
202 |
+
$html = ( 'true' === $html );
|
203 |
+
$markdown = ( 'true' === $markdown );
|
204 |
+
$precision = absint( $precision );
|
205 |
+
$offset = intval( $offset );
|
206 |
+
$autolink = ( 'true' === $autolink );
|
207 |
+
|
208 |
+
$time_now = current_time( 'timestamp' );
|
209 |
|
210 |
//Do the appropriate stuff depending on which shortcode we're looking at. See valid shortcode list (above) for explanation of each shortcode
|
211 |
+
switch ( $m[2] ) {
|
212 |
case 'event-title':
|
213 |
+
$title = esc_html( trim( $this->title ) );
|
214 |
|
215 |
+
if ( $markdown && function_exists( 'Markdown' ) )
|
216 |
+
$title = Markdown( $title );
|
217 |
+
|
218 |
+
if ( $html )
|
219 |
+
$title = wp_kses_post( html_entity_decode( $title ) );
|
220 |
|
221 |
return $m[1] . $title . $m[6];
|
222 |
+
|
223 |
case 'start-time':
|
224 |
+
return $m[1] . date_i18n( $this->feed->get_time_format(), $this->start_time + $offset ) . $m[6];
|
225 |
+
|
226 |
case 'start-date':
|
227 |
+
return $m[1] . date_i18n( $this->feed->get_date_format(), $this->start_time + $offset ) . $m[6];
|
228 |
+
|
229 |
case 'start-custom':
|
230 |
+
return $m[1] . date_i18n( $format, $this->start_time + $offset ) . $m[6];
|
231 |
+
|
232 |
case 'start-human':
|
233 |
+
return $m[1] . $this->gce_human_time_diff( $this->start_time + $offset, $time_now, $precision ) . $m[6];
|
234 |
+
|
235 |
case 'end-time':
|
236 |
+
return $m[1] . date_i18n( $this->feed->get_time_format(), $this->end_time + $offset ) . $m[6];
|
237 |
+
|
238 |
case 'end-date':
|
239 |
+
return $m[1] . date_i18n( $this->feed->get_date_format(), $this->end_time + $offset ) . $m[6];
|
240 |
+
|
241 |
case 'end-custom':
|
242 |
+
return $m[1] . date_i18n( $format, $this->end_time + $offset ) . $m[6];
|
243 |
+
|
244 |
case 'end-human':
|
245 |
+
return $m[1] . $this->gce_human_time_diff( $this->end_time + $offset, $time_now, $precision ) . $m[6];
|
246 |
+
|
247 |
case 'location':
|
248 |
+
$location = esc_html( trim( $this->location ) );
|
249 |
|
250 |
+
if ( $markdown && function_exists( 'Markdown' ) )
|
251 |
+
$location = Markdown( $location );
|
252 |
+
|
253 |
+
if ( $html )
|
254 |
+
$location = wp_kses_post( html_entity_decode( $location ) );
|
255 |
|
256 |
return $m[1] . $location . $m[6];
|
257 |
+
|
258 |
case 'description':
|
259 |
+
$description = esc_html( trim( $this->description ) );
|
260 |
|
261 |
//If a word limit has been set, trim the description to the required length
|
262 |
+
if ( 0 != $limit ) {
|
263 |
+
preg_match( '/([\S]+\s*){0,' . $limit . '}/', esc_html( $this->description ), $description );
|
264 |
+
$description = trim( $description[0] );
|
265 |
}
|
266 |
|
267 |
+
if ( $markdown || $html ) {
|
268 |
+
if ( $markdown && function_exists( 'Markdown' ) )
|
269 |
+
$description = Markdown( $description );
|
270 |
+
|
271 |
+
if ( $html )
|
272 |
+
$description = wp_kses_post( html_entity_decode( $description ) );
|
273 |
}else{
|
274 |
+
//Otherwise, preserve line breaks
|
275 |
+
$description = nl2br( $description );
|
276 |
+
|
277 |
+
//Make URLs clickable if required
|
278 |
+
if ( $autolink )
|
279 |
+
$description = make_clickable( $description );
|
280 |
}
|
281 |
|
282 |
return $m[1] . $description . $m[6];
|
283 |
+
|
284 |
case 'link':
|
285 |
+
$new_window = ( $newwindow ) ? ' target="_blank"' : '';
|
286 |
+
return $m[1] . '<a href="' . $this->link . '&ctz=' . $this->feed->get_timezone() . '"' . $new_window . '>' . $m[5] . '</a>' . $m[6];
|
287 |
+
|
288 |
+
case 'url':
|
289 |
+
return $m[1] . $this->link . '&ctz=' . $this->feed->get_timezone() . $m[6];
|
290 |
+
|
291 |
case 'feed-id':
|
292 |
return $m[1] . $this->feed->get_feed_id() . $m[6];
|
293 |
+
|
294 |
case 'feed-title':
|
295 |
return $m[1] . $this->feed->get_feed_title() . $m[6];
|
296 |
+
|
297 |
case 'maps-link':
|
298 |
+
$new_window = ( $newwindow ) ? ' target="_blank"' : '';
|
299 |
+
return $m[1] . '<a href="http://maps.google.com?q=' . urlencode( $this->location ) . '"' . $new_window . '>' . $m[5] . '</a>' . $m[6];
|
300 |
+
|
301 |
case 'length':
|
302 |
+
return $m[1] . $this->gce_human_time_diff( $this->start_time, $this->end_time, $precision ) . $m[6];
|
303 |
+
|
304 |
+
case 'event-num':
|
305 |
+
return $m[1] . $this->pos . $m[6];
|
306 |
+
|
307 |
+
case 'event-id':
|
308 |
+
return $m[1] . $this->id . $m[6];
|
309 |
+
|
310 |
+
case 'cal-id':
|
311 |
+
$cal_id = explode( '/', $this->feed->get_feed_url() );
|
312 |
+
return $m[1] . $cal_id[5] . $m[6];
|
313 |
+
|
314 |
case 'if-all-day':
|
315 |
+
if ( 'SWD' == $this->day_type || 'MWD' == $this->day_type )
|
316 |
+
return $m[1] . $m[5] . $m[6];
|
317 |
+
|
318 |
+
return '';
|
319 |
+
|
320 |
case 'if-not-all-day':
|
321 |
+
if ( 'SPD' == $this->day_type || 'MPD' == $this->day_type )
|
322 |
+
return $m[1] . $m[5] . $m[6];
|
323 |
+
|
324 |
return '';
|
325 |
+
|
326 |
case 'if-title':
|
327 |
+
if ( '' != $this->title )
|
328 |
+
return $m[1] . $m[5] . $m[6];
|
329 |
+
|
330 |
return '';
|
331 |
+
|
332 |
case 'if-description':
|
333 |
+
if ( '' != $this->description )
|
334 |
+
return $m[1] . $m[5] . $m[6];
|
335 |
+
|
336 |
return '';
|
337 |
+
|
338 |
case 'if-location':
|
339 |
+
if ( '' != $this->location )
|
340 |
+
return $m[1] . $m[5] . $m[6];
|
341 |
+
|
342 |
return '';
|
343 |
+
|
344 |
case 'if-tooltip':
|
345 |
+
if ( 'tooltip' == $this->type )
|
346 |
+
return $m[1] . $m[5] . $m[6];
|
347 |
+
|
348 |
return '';
|
349 |
+
|
350 |
case 'if-list':
|
351 |
+
if ( 'list' == $this->type )
|
352 |
+
return $m[1] . $m[5] . $m[6];
|
353 |
+
|
354 |
return '';
|
355 |
+
|
356 |
case 'if-now':
|
357 |
+
if ( $time_now >= $this->start_time && $time_now < $this->end_time )
|
358 |
+
return $m[1] . $m[5] . $m[6];
|
359 |
+
|
360 |
return '';
|
361 |
+
|
362 |
case 'if-not-now':
|
363 |
+
if ( $this->end_time < $time_now || $this->start_time > $time_now )
|
364 |
+
return $m[1] . $m[5] . $m[6];
|
365 |
+
|
366 |
return '';
|
367 |
+
|
368 |
case 'if-started':
|
369 |
+
if ( $this->start_time < $time_now )
|
370 |
+
return $m[1] . $m[5] . $m[6];
|
371 |
+
|
372 |
return '';
|
373 |
+
|
374 |
case 'if-not-started':
|
375 |
+
if ( $this->start_time > $time_now )
|
376 |
+
return $m[1] . $m[5] . $m[6];
|
377 |
+
|
378 |
return '';
|
379 |
+
|
380 |
case 'if-ended':
|
381 |
+
if ( $this->end_time < $time_now )
|
382 |
+
return $m[1] . $m[5] . $m[6];
|
383 |
+
|
384 |
return '';
|
385 |
+
|
386 |
case 'if-not-ended':
|
387 |
+
if ( $this->end_time > $time_now )
|
388 |
+
return $m[1] . $m[5] . $m[6];
|
389 |
+
|
390 |
return '';
|
391 |
+
|
392 |
case 'if-first':
|
393 |
+
if ( 0 == $this->num_in_day )
|
394 |
+
return $m[1] . $m[5] . $m[6];
|
395 |
+
|
396 |
return '';
|
397 |
+
|
398 |
case 'if-not-first':
|
399 |
+
if ( 0 != $this->num_in_day )
|
400 |
+
return $m[1] . $m[5] . $m[6];
|
401 |
+
|
402 |
return '';
|
403 |
+
|
404 |
case 'if-multi-day':
|
405 |
+
if ( 'MPD' == $this->day_type || 'MWD' == $this->day_type )
|
406 |
+
return $m[1] . $m[5] . $m[6];
|
407 |
+
|
408 |
return '';
|
409 |
+
|
410 |
case 'if-single-day':
|
411 |
+
if ( 'SPD' == $this->day_type || 'SWD' == $this->day_type )
|
412 |
+
return $m[1] . $m[5] . $m[6];
|
413 |
+
|
414 |
return '';
|
415 |
}
|
416 |
}
|
417 |
|
418 |
//Return the event markup using the old display options
|
419 |
+
function use_old_display_options() {
|
420 |
$display_options = $this->feed->get_display_options();
|
421 |
|
422 |
+
$markup = '<p class="gce-' . $this->type . '-event">' . esc_html( $this->title ) . '</p>';
|
423 |
|
424 |
$start_end = array();
|
425 |
|
426 |
//If start date / time should be displayed, set up array of start date and time
|
427 |
+
if ( 'none' != $display_options['display_start'] ) {
|
428 |
$sd = $this->start_time;
|
429 |
+
$start_end['start'] = array(
|
430 |
+
'time' => date_i18n( $this->feed->get_time_format(), $sd ),
|
431 |
+
'date' => date_i18n( $this->feed->get_date_format(), $sd )
|
432 |
+
);
|
433 |
}
|
434 |
|
435 |
//If end date / time should be displayed, set up array of end date and time
|
436 |
+
if ( 'none' != $display_options['display_end'] ) {
|
437 |
$ed = $this->end_time;
|
438 |
+
$start_end['end'] = array(
|
439 |
+
'time' => date_i18n( $this->feed->get_time_format(), $ed ),
|
440 |
+
'date' => date_i18n( $this->feed->get_date_format(), $ed )
|
441 |
+
);
|
442 |
}
|
443 |
|
444 |
//Add the correct start / end, date / time information to $markup
|
445 |
+
foreach ( $start_end as $start_or_end => $info ) {
|
446 |
$markup .= '<p class="gce-' . $this->type . '-' . $start_or_end . '"><span>' . $display_options['display_' . $start_or_end . '_text'] . '</span> ';
|
447 |
|
448 |
+
switch ( $display_options['display_' . $start_or_end] ) {
|
449 |
case 'time': $markup .= $info['time'];
|
450 |
break;
|
451 |
case 'date': $markup .= $info['date'];
|
459 |
}
|
460 |
|
461 |
//If location should be displayed (and is not empty) add to $markup
|
462 |
+
if ( isset( $display_options['display_location'] ) ) {
|
463 |
$event_location = $this->location;
|
464 |
+
if ( '' != $event_location )
|
465 |
+
$markup .= '<p class="gce-' . $this->type . '-loc"><span>' . $display_options['display_location_text'] . '</span> ' . esc_html( $event_location ) . '</p>';
|
466 |
}
|
467 |
|
468 |
//If description should be displayed (and is not empty) add to $markup
|
469 |
+
if ( isset($display_options['display_desc'] ) ) {
|
470 |
$event_desc = $this->description;
|
471 |
|
472 |
+
if ( '' != $event_desc ) {
|
473 |
//Limit number of words of description to display, if required
|
474 |
+
if ( '' != $display_options['display_desc_limit'] ) {
|
475 |
+
preg_match( '/([\S]+\s*){0,' . $display_options['display_desc_limit'] . '}/', $this->description, $event_desc );
|
476 |
+
$event_desc = trim( $event_desc[0] );
|
477 |
}
|
478 |
|
479 |
+
$markup .= '<p class="gce-' . $this->type . '-desc"><span>' . $display_options['display_desc_text'] . '</span> ' . make_clickable( nl2br( esc_html( $event_desc ) ) ) . '</p>';
|
480 |
}
|
481 |
}
|
482 |
|
483 |
//If link should be displayed add to $markup
|
484 |
+
if ( isset($display_options['display_link'] ) ) //Below: add target="_blank" if required
|
485 |
+
$markup .= '<p class="gce-' . $this->type . '-link"><a href="' . $this->link . '&ctz=' . $this->feed->get_timezone() . '"' . ( ( isset( $display_options['display_link_target'] ) ) ? ' target="_blank"' : '' ) . '>' . $display_options['display_link_text'] . '</a></p>';
|
|
|
486 |
|
487 |
return $markup;
|
488 |
}
|
489 |
|
490 |
//Returns the difference between two times in human-readable format. Based on a patch for human_time_diff posted in the WordPress trac (http://core.trac.wordpress.org/ticket/9272) by Viper007Bond
|
491 |
+
function gce_human_time_diff( $from, $to = '', $limit = 1 ) {
|
492 |
$units = array(
|
493 |
+
31556926 => array( __( '%s year', GCE_TEXT_DOMAIN ), __( '%s years', GCE_TEXT_DOMAIN ) ),
|
494 |
+
2629744 => array( __( '%s month', GCE_TEXT_DOMAIN ), __( '%s months', GCE_TEXT_DOMAIN ) ),
|
495 |
+
604800 => array( __( '%s week', GCE_TEXT_DOMAIN ), __( '%s weeks', GCE_TEXT_DOMAIN ) ),
|
496 |
+
86400 => array( __( '%s day', GCE_TEXT_DOMAIN ), __( '%s days', GCE_TEXT_DOMAIN ) ),
|
497 |
+
3600 => array( __( '%s hour', GCE_TEXT_DOMAIN ), __( '%s hours', GCE_TEXT_DOMAIN ) ),
|
498 |
+
60 => array( __( '%s min', GCE_TEXT_DOMAIN ), __( '%s mins', GCE_TEXT_DOMAIN ) ),
|
499 |
);
|
500 |
|
501 |
+
if ( empty( $to ) )
|
502 |
+
$to = time();
|
503 |
|
504 |
$from = (int) $from;
|
505 |
$to = (int) $to;
|
506 |
+
$diff = (int) abs( $to - $from );
|
507 |
|
508 |
$items = 0;
|
509 |
$output = array();
|
510 |
|
511 |
+
foreach ( $units as $unitsec => $unitnames ) {
|
512 |
+
if ( $items >= $limit )
|
513 |
+
break;
|
514 |
|
515 |
+
if ( $diff < $unitsec )
|
516 |
+
continue;
|
517 |
|
518 |
+
$numthisunits = floor( $diff / $unitsec );
|
519 |
+
$diff = $diff - ( $numthisunits * $unitsec );
|
520 |
$items++;
|
521 |
|
522 |
+
if ( $numthisunits > 0 )
|
523 |
+
$output[] = sprintf( _n( $unitnames[0], $unitnames[1], $numthisunits ), $numthisunits );
|
524 |
}
|
525 |
|
526 |
+
$seperator = _x( ', ', 'human_time_diff' );
|
527 |
|
528 |
+
if ( ! empty( $output ) ) {
|
529 |
+
return implode( $seperator, $output );
|
530 |
+
} else {
|
531 |
+
$smallest = array_pop( $units );
|
532 |
+
return sprintf( $smallest[0], 1 );
|
533 |
}
|
534 |
}
|
535 |
}
|
inc/gce-feed.php
CHANGED
@@ -17,89 +17,93 @@ class GCE_Feed{
|
|
17 |
private $events = array();
|
18 |
private $error = false;
|
19 |
|
20 |
-
function init(){
|
21 |
require_once 'gce-event.php';
|
22 |
|
23 |
//Break the feed URL up into its parts (scheme, host, path, query)
|
24 |
-
$url_parts = parse_url($this->feed_url);
|
25 |
|
26 |
$scheme_and_host = $url_parts['scheme'] . '://' . $url_parts['host'];
|
27 |
|
28 |
//Remove the exisitng projection from the path, and replace it with '/full-noattendees'
|
29 |
-
$path = substr($url_parts['path'], 0, strrpos($url_parts['path'], '/')) . '/full-noattendees';
|
30 |
|
31 |
//Add the default parameters to the querystring (retrieving JSON, not XML)
|
32 |
-
$query = '?alt=json&sortorder=ascending&orderby=starttime
|
33 |
|
34 |
//Append the feed specific parameters to the querystring
|
35 |
-
$query .= '&start-min=' . date('Y-m-d\TH:i:s', $this->feed_start);
|
36 |
-
$query .= '&start-max=' . date('Y-m-d\TH:i:s', $this->feed_end);
|
37 |
$query .= '&max-results=' . $this->max_events;
|
38 |
-
|
|
|
|
|
39 |
|
40 |
//If enabled, use experimental 'fields' parameter of Google Data API, so that only necessary data is retrieved. This *significantly* reduces amount of data to retrieve and process
|
41 |
-
$general_options = get_option(GCE_GENERAL_OPTIONS_NAME);
|
42 |
-
if($general_options['fields']
|
|
|
43 |
|
44 |
//Put the URL back together
|
45 |
$url = $scheme_and_host . $path . $query;
|
46 |
|
47 |
//Attempt to retrieve the cached feed data
|
48 |
-
$this->events = get_transient('gce_feed_' . $this->feed_id);
|
49 |
|
50 |
//If the cached feed data isn't valid any more (has expired), or the URL has changed (settings have changed), then the feed data needs to be retrieved and decoded again
|
51 |
-
if($this->events
|
52 |
$this->events = array();
|
53 |
|
54 |
//Retrieve the feed data
|
55 |
-
$raw_data = wp_remote_get($url, array(
|
56 |
'sslverify' => false, //sslverify is set to false to ensure https URLs work reliably. Data source is Google's servers, so is trustworthy
|
57 |
-
'timeout'
|
58 |
-
));
|
59 |
|
60 |
//If $raw_data is a WP_Error, something went wrong
|
61 |
-
if(!is_wp_error($raw_data)){
|
62 |
//If response code isn't 200, something went wrong
|
63 |
-
if($raw_data['response']['code']
|
64 |
//Attempt to convert the returned JSON into an array
|
65 |
-
$raw_data = json_decode($raw_data['body'], true);
|
66 |
|
67 |
//If decoding was successful
|
68 |
-
if(!empty($raw_data)){
|
69 |
//If there are some entries (events) to process
|
70 |
-
if(isset($raw_data['feed']['entry'])){
|
71 |
//Loop through each event, extracting the relevant information
|
72 |
-
foreach($raw_data['feed']['entry'] as $event){
|
73 |
-
$
|
74 |
-
$
|
75 |
-
$
|
76 |
-
$
|
77 |
-
$
|
78 |
-
$
|
|
|
79 |
|
80 |
//Create a GCE_Event using the above data. Add it to the array of events
|
81 |
-
$this->events[] = new GCE_Event($title, $description, $location, $start_time, $end_time, $link);
|
82 |
}
|
83 |
|
84 |
//Cache the feed data
|
85 |
-
set_transient('gce_feed_' . $this->feed_id, $this->events, $this->cache_duration);
|
86 |
-
set_transient('gce_feed_' . $this->feed_id . '_url', $url, $this->cache_duration);
|
87 |
}
|
88 |
-
}else{
|
89 |
//json_decode failed
|
90 |
-
$this->error = __('Some data was retrieved, but could not be parsed successfully. Please ensure your feed URL is correct.', GCE_TEXT_DOMAIN);
|
91 |
}
|
92 |
-
}else{
|
93 |
//The response code wasn't 200, so generate a helpful(ish) error message depending on error code
|
94 |
-
switch($raw_data['response']['code']){
|
95 |
case 404:
|
96 |
-
$this->error = __('The feed could not be found (404). Please ensure your feed URL is correct.', GCE_TEXT_DOMAIN);
|
97 |
break;
|
98 |
case 403:
|
99 |
-
$this->error = __('Access to this feed was denied (403). Please ensure you have public sharing enabled for your calendar.', GCE_TEXT_DOMAIN);
|
100 |
break;
|
101 |
default:
|
102 |
-
$this->error = sprintf(__('The feed data could not be retrieved. Error code: %s. Please ensure your feed URL is correct.', GCE_TEXT_DOMAIN), $raw_data['response']['code']);
|
103 |
}
|
104 |
}
|
105 |
}else{
|
@@ -109,121 +113,131 @@ class GCE_Feed{
|
|
109 |
}
|
110 |
|
111 |
//Makes sure each event knows it came from this feed
|
112 |
-
foreach($this->events as $event){
|
113 |
-
$event->set_feed($this);
|
114 |
}
|
115 |
}
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
//Return error message, or false if no error occurred
|
118 |
-
function error(){
|
119 |
return $this->error;
|
120 |
}
|
121 |
|
122 |
//Setters
|
123 |
|
124 |
-
function set_feed_id($v){
|
125 |
$this->feed_id = $v;
|
126 |
}
|
127 |
|
128 |
-
function set_feed_title($v){
|
129 |
$this->feed_title = $v;
|
130 |
}
|
131 |
|
132 |
-
function set_feed_url($v){
|
133 |
$this->feed_url = $v;
|
134 |
}
|
135 |
|
136 |
-
function set_max_events($v){
|
137 |
$this->max_events = $v;
|
138 |
}
|
139 |
|
140 |
-
function set_cache_duration($v){
|
141 |
$this->cache_duration = $v;
|
142 |
}
|
143 |
|
144 |
-
function set_date_format($v){
|
145 |
$this->date_format = $v;
|
146 |
}
|
147 |
|
148 |
-
function set_time_format($v){
|
149 |
$this->time_format = $v;
|
150 |
}
|
151 |
|
152 |
-
function set_timezone($v){
|
153 |
$this->timezone = $v;
|
154 |
}
|
155 |
|
156 |
-
function set_display_options($v){
|
157 |
$this->display_opts = $v;
|
158 |
}
|
159 |
|
160 |
-
function set_multi_day($v){
|
161 |
$this->multi_day = $v;
|
162 |
}
|
163 |
|
164 |
-
function set_feed_start($v){
|
165 |
$this->feed_start = $v;
|
166 |
}
|
167 |
|
168 |
-
function set_feed_end($v){
|
169 |
$this->feed_end = $v;
|
170 |
}
|
171 |
|
172 |
-
function set_use_builder($v){
|
173 |
$this->use_builder = $v;
|
174 |
}
|
175 |
|
176 |
-
function set_builder($v){
|
177 |
$this->builder = $v;
|
178 |
}
|
179 |
|
180 |
//Getters
|
181 |
|
182 |
-
function get_events(){
|
183 |
return $this->events;
|
184 |
}
|
185 |
|
186 |
-
function get_feed_id(){
|
187 |
return $this->feed_id;
|
188 |
}
|
189 |
|
190 |
-
function get_feed_title(){
|
191 |
return $this->feed_title;
|
192 |
}
|
193 |
|
194 |
-
function
|
|
|
|
|
|
|
|
|
195 |
return $this->date_format;
|
196 |
}
|
197 |
|
198 |
-
function get_time_format(){
|
199 |
return $this->time_format;
|
200 |
}
|
201 |
|
202 |
-
function get_display_options(){
|
203 |
return $this->display_opts;
|
204 |
}
|
205 |
|
206 |
-
function get_multi_day(){
|
207 |
return $this->multi_day;
|
208 |
}
|
209 |
|
210 |
-
function get_feed_start(){
|
211 |
return $this->feed_start;
|
212 |
}
|
213 |
|
214 |
-
function get_feed_end(){
|
215 |
return $this->feed_end;
|
216 |
}
|
217 |
|
218 |
-
function get_timezone(){
|
219 |
return $this->timezone;
|
220 |
}
|
221 |
|
222 |
-
function get_use_builder(){
|
223 |
return $this->use_builder;
|
224 |
}
|
225 |
|
226 |
-
function get_builder(){
|
227 |
return $this->builder;
|
228 |
}
|
229 |
}
|
17 |
private $events = array();
|
18 |
private $error = false;
|
19 |
|
20 |
+
function init() {
|
21 |
require_once 'gce-event.php';
|
22 |
|
23 |
//Break the feed URL up into its parts (scheme, host, path, query)
|
24 |
+
$url_parts = parse_url( $this->feed_url );
|
25 |
|
26 |
$scheme_and_host = $url_parts['scheme'] . '://' . $url_parts['host'];
|
27 |
|
28 |
//Remove the exisitng projection from the path, and replace it with '/full-noattendees'
|
29 |
+
$path = substr( $url_parts['path'], 0, strrpos( $url_parts['path'], '/' ) ) . '/full-noattendees';
|
30 |
|
31 |
//Add the default parameters to the querystring (retrieving JSON, not XML)
|
32 |
+
$query = '?alt=json&singleevents=true&sortorder=ascending&orderby=starttime';
|
33 |
|
34 |
//Append the feed specific parameters to the querystring
|
35 |
+
$query .= '&start-min=' . date( 'Y-m-d\TH:i:s', $this->feed_start );
|
36 |
+
$query .= '&start-max=' . date( 'Y-m-d\TH:i:s', $this->feed_end );
|
37 |
$query .= '&max-results=' . $this->max_events;
|
38 |
+
|
39 |
+
if ( ! empty( $this->timezone ) )
|
40 |
+
$query .= '&ctz=' . $this->timezone;
|
41 |
|
42 |
//If enabled, use experimental 'fields' parameter of Google Data API, so that only necessary data is retrieved. This *significantly* reduces amount of data to retrieve and process
|
43 |
+
$general_options = get_option( GCE_GENERAL_OPTIONS_NAME );
|
44 |
+
if ( $general_options['fields'] )
|
45 |
+
$query .= '&fields=entry(title,link[@rel="alternate"],content,gd:where,gd:when,gCal:uid)';
|
46 |
|
47 |
//Put the URL back together
|
48 |
$url = $scheme_and_host . $path . $query;
|
49 |
|
50 |
//Attempt to retrieve the cached feed data
|
51 |
+
$this->events = get_transient( 'gce_feed_' . $this->feed_id );
|
52 |
|
53 |
//If the cached feed data isn't valid any more (has expired), or the URL has changed (settings have changed), then the feed data needs to be retrieved and decoded again
|
54 |
+
if ( false === $this->events || get_transient( 'gce_feed_' . $this->feed_id . '_url' ) != $url ) {
|
55 |
$this->events = array();
|
56 |
|
57 |
//Retrieve the feed data
|
58 |
+
$raw_data = wp_remote_get( $url, array(
|
59 |
'sslverify' => false, //sslverify is set to false to ensure https URLs work reliably. Data source is Google's servers, so is trustworthy
|
60 |
+
'timeout' => 10 //Increase timeout from the default 5 seconds to ensure even large feeds are retrieved successfully
|
61 |
+
) );
|
62 |
|
63 |
//If $raw_data is a WP_Error, something went wrong
|
64 |
+
if ( ! is_wp_error( $raw_data ) ) {
|
65 |
//If response code isn't 200, something went wrong
|
66 |
+
if ( 200 == $raw_data['response']['code'] ) {
|
67 |
//Attempt to convert the returned JSON into an array
|
68 |
+
$raw_data = json_decode( $raw_data['body'], true );
|
69 |
|
70 |
//If decoding was successful
|
71 |
+
if ( ! empty( $raw_data ) ) {
|
72 |
//If there are some entries (events) to process
|
73 |
+
if ( isset( $raw_data['feed']['entry'] ) ) {
|
74 |
//Loop through each event, extracting the relevant information
|
75 |
+
foreach ( $raw_data['feed']['entry'] as $event ) {
|
76 |
+
$id = esc_html( substr( $event['gCal$uid']['value'], 0, strpos( $event['gCal$uid']['value'], '@' ) ) );
|
77 |
+
$title = esc_html( $event['title']['$t'] );
|
78 |
+
$description = esc_html( $event['content']['$t'] );
|
79 |
+
$link = esc_url( $event['link'][0]['href'] );
|
80 |
+
$location = esc_html( $event['gd$where'][0]['valueString'] );
|
81 |
+
$start_time = $this->iso_to_ts( $event['gd$when'][0]['startTime'] );
|
82 |
+
$end_time = $this->iso_to_ts( $event['gd$when'][0]['endTime'] );
|
83 |
|
84 |
//Create a GCE_Event using the above data. Add it to the array of events
|
85 |
+
$this->events[] = new GCE_Event( $id, $title, $description, $location, $start_time, $end_time, $link );
|
86 |
}
|
87 |
|
88 |
//Cache the feed data
|
89 |
+
set_transient( 'gce_feed_' . $this->feed_id, $this->events, $this->cache_duration );
|
90 |
+
set_transient( 'gce_feed_' . $this->feed_id . '_url', $url, $this->cache_duration );
|
91 |
}
|
92 |
+
} else {
|
93 |
//json_decode failed
|
94 |
+
$this->error = __( 'Some data was retrieved, but could not be parsed successfully. Please ensure your feed URL is correct.', GCE_TEXT_DOMAIN );
|
95 |
}
|
96 |
+
} else {
|
97 |
//The response code wasn't 200, so generate a helpful(ish) error message depending on error code
|
98 |
+
switch ( $raw_data['response']['code'] ) {
|
99 |
case 404:
|
100 |
+
$this->error = __( 'The feed could not be found (404). Please ensure your feed URL is correct.', GCE_TEXT_DOMAIN );
|
101 |
break;
|
102 |
case 403:
|
103 |
+
$this->error = __( 'Access to this feed was denied (403). Please ensure you have public sharing enabled for your calendar.', GCE_TEXT_DOMAIN );
|
104 |
break;
|
105 |
default:
|
106 |
+
$this->error = sprintf( __( 'The feed data could not be retrieved. Error code: %s. Please ensure your feed URL is correct.', GCE_TEXT_DOMAIN ), $raw_data['response']['code'] );
|
107 |
}
|
108 |
}
|
109 |
}else{
|
113 |
}
|
114 |
|
115 |
//Makes sure each event knows it came from this feed
|
116 |
+
foreach ( $this->events as $event ) {
|
117 |
+
$event->set_feed( $this );
|
118 |
}
|
119 |
}
|
120 |
|
121 |
+
//Convert an ISO date/time to a UNIX timestamp
|
122 |
+
function iso_to_ts( $iso ) {
|
123 |
+
sscanf( $iso, "%u-%u-%uT%u:%u:%uZ", $year, $month, $day, $hour, $minute, $second );
|
124 |
+
return mktime( $hour, $minute, $second, $month, $day, $year );
|
125 |
+
}
|
126 |
+
|
127 |
//Return error message, or false if no error occurred
|
128 |
+
function error() {
|
129 |
return $this->error;
|
130 |
}
|
131 |
|
132 |
//Setters
|
133 |
|
134 |
+
function set_feed_id( $v ) {
|
135 |
$this->feed_id = $v;
|
136 |
}
|
137 |
|
138 |
+
function set_feed_title( $v ) {
|
139 |
$this->feed_title = $v;
|
140 |
}
|
141 |
|
142 |
+
function set_feed_url( $v ) {
|
143 |
$this->feed_url = $v;
|
144 |
}
|
145 |
|
146 |
+
function set_max_events( $v ) {
|
147 |
$this->max_events = $v;
|
148 |
}
|
149 |
|
150 |
+
function set_cache_duration( $v ) {
|
151 |
$this->cache_duration = $v;
|
152 |
}
|
153 |
|
154 |
+
function set_date_format( $v ) {
|
155 |
$this->date_format = $v;
|
156 |
}
|
157 |
|
158 |
+
function set_time_format( $v ) {
|
159 |
$this->time_format = $v;
|
160 |
}
|
161 |
|
162 |
+
function set_timezone( $v ) {
|
163 |
$this->timezone = $v;
|
164 |
}
|
165 |
|
166 |
+
function set_display_options( $v ) {
|
167 |
$this->display_opts = $v;
|
168 |
}
|
169 |
|
170 |
+
function set_multi_day( $v ) {
|
171 |
$this->multi_day = $v;
|
172 |
}
|
173 |
|
174 |
+
function set_feed_start( $v ) {
|
175 |
$this->feed_start = $v;
|
176 |
}
|
177 |
|
178 |
+
function set_feed_end( $v ) {
|
179 |
$this->feed_end = $v;
|
180 |
}
|
181 |
|
182 |
+
function set_use_builder( $v ) {
|
183 |
$this->use_builder = $v;
|
184 |
}
|
185 |
|
186 |
+
function set_builder( $v ) {
|
187 |
$this->builder = $v;
|
188 |
}
|
189 |
|
190 |
//Getters
|
191 |
|
192 |
+
function get_events() {
|
193 |
return $this->events;
|
194 |
}
|
195 |
|
196 |
+
function get_feed_id() {
|
197 |
return $this->feed_id;
|
198 |
}
|
199 |
|
200 |
+
function get_feed_title() {
|
201 |
return $this->feed_title;
|
202 |
}
|
203 |
|
204 |
+
function get_feed_url() {
|
205 |
+
return $this->feed_url;
|
206 |
+
}
|
207 |
+
|
208 |
+
function get_date_format() {
|
209 |
return $this->date_format;
|
210 |
}
|
211 |
|
212 |
+
function get_time_format() {
|
213 |
return $this->time_format;
|
214 |
}
|
215 |
|
216 |
+
function get_display_options() {
|
217 |
return $this->display_opts;
|
218 |
}
|
219 |
|
220 |
+
function get_multi_day() {
|
221 |
return $this->multi_day;
|
222 |
}
|
223 |
|
224 |
+
function get_feed_start() {
|
225 |
return $this->feed_start;
|
226 |
}
|
227 |
|
228 |
+
function get_feed_end() {
|
229 |
return $this->feed_end;
|
230 |
}
|
231 |
|
232 |
+
function get_timezone() {
|
233 |
return $this->timezone;
|
234 |
}
|
235 |
|
236 |
+
function get_use_builder() {
|
237 |
return $this->use_builder;
|
238 |
}
|
239 |
|
240 |
+
function get_builder() {
|
241 |
return $this->builder;
|
242 |
}
|
243 |
}
|
inc/gce-parser.php
CHANGED
@@ -1,96 +1,101 @@
|
|
1 |
<?php
|
2 |
-
class GCE_Parser{
|
3 |
private $feeds = array();
|
4 |
private $merged_feed_data = array();
|
5 |
private $errors = array();
|
6 |
private $title = null;
|
7 |
private $max_events_display = 0;
|
8 |
private $start_of_week = 0;
|
|
|
9 |
|
10 |
-
function __construct($feed_ids, $title_text = null, $max_events = 0){
|
11 |
require_once 'gce-feed.php';
|
12 |
|
13 |
$this->title = $title_text;
|
14 |
$this->max_events_display = $max_events;
|
|
|
15 |
|
16 |
//Get the feed options
|
17 |
-
$options = get_option(GCE_OPTIONS_NAME);
|
18 |
|
19 |
-
$this->start_of_week = get_option('start_of_week');
|
20 |
|
21 |
-
foreach($feed_ids as $single_feed){
|
22 |
//Get the options for this particular feed
|
23 |
-
if(isset($options[$single_feed])){
|
24 |
$feed_options = $options[$single_feed];
|
25 |
|
26 |
$feed = new GCE_Feed();
|
27 |
|
28 |
-
$feed->set_feed_id($feed_options['id']);
|
29 |
-
$feed->set_feed_title($feed_options['title']);
|
30 |
-
$feed->set_feed_url($feed_options['url']);
|
31 |
-
$feed->set_max_events($feed_options['max_events']);
|
32 |
-
$feed->set_cache_duration($feed_options['cache_duration']);
|
33 |
|
34 |
//Set the timezone if anything other than default
|
35 |
-
if(
|
|
|
|
|
|
|
36 |
|
37 |
//Set the start date to the appropriate value based on the retrieve_from option
|
38 |
-
switch($feed_options['retrieve_from']){
|
39 |
//Don't just use time() for 'now', as this will effectively make cache duration 1 second. Instead set to previous minute. Events in Google Calendar cannot be set to precision of seconds anyway
|
40 |
case 'now':
|
41 |
-
$feed->set_feed_start(mktime(date('H'), date('i'), 0, date('m'), date('j'), date('Y')) + $feed_options['retrieve_from_value']
|
42 |
break;
|
43 |
case 'today':
|
44 |
-
$feed->set_feed_start(mktime(0, 0, 0, date('m'), date('j'), date('Y')) + $feed_options['retrieve_from_value']
|
45 |
break;
|
46 |
case 'week':
|
47 |
-
$feed->set_feed_start(mktime(0, 0, 0, date('m'), (date('j') - date('w') + $this->start_of_week), date('Y')) + $feed_options['retrieve_from_value']
|
48 |
break;
|
49 |
case 'month-start':
|
50 |
-
$feed->set_feed_start(mktime(0, 0, 0, date('m'), 1, date('Y')) + $feed_options['retrieve_from_value']
|
51 |
break;
|
52 |
case 'month-end':
|
53 |
-
$feed->set_feed_start(mktime(0, 0, 0, date('m') + 1, 1, date('Y')) + $feed_options['retrieve_from_value']
|
54 |
break;
|
55 |
case 'date':
|
56 |
-
$feed->set_feed_start($feed_options['retrieve_from_value']);
|
57 |
break;
|
58 |
-
|
59 |
-
$feed->set_feed_start(0); //1970-01-01 00:00
|
60 |
}
|
61 |
|
62 |
//Set the end date to the appropriate value based on the retrieve_until option
|
63 |
-
switch($feed_options['retrieve_until']){
|
64 |
case 'now':
|
65 |
-
$feed->set_feed_end(mktime(date('H'), date('i'), 0, date('m'), date('j'), date('Y')) + $feed_options['retrieve_until_value']
|
66 |
break;
|
67 |
case 'today':
|
68 |
-
$feed->set_feed_end(mktime(0, 0, 0, date('m'), date('j'), date('Y')) + $feed_options['retrieve_until_value']
|
69 |
break;
|
70 |
case 'week':
|
71 |
-
$feed->set_feed_end(mktime(0, 0, 0, date('m'), (date('j') - date('w') + $this->start_of_week), date('Y')) + $feed_options['retrieve_until_value']
|
72 |
break;
|
73 |
case 'month-start':
|
74 |
-
$feed->set_feed_end(mktime(0, 0, 0, date('m'), 1, date('Y')) + $feed_options['retrieve_until_value']
|
75 |
break;
|
76 |
case 'month-end':
|
77 |
-
$feed->set_feed_end(mktime(0, 0, 0, date('m') + 1, 1, date('Y')) + $feed_options['retrieve_until_value']
|
78 |
break;
|
79 |
case 'date':
|
80 |
-
$feed->set_feed_end($feed_options['retrieve_until_value']);
|
81 |
break;
|
82 |
case 'any':
|
83 |
-
$feed->set_feed_end(2145916800); //2038-01-01 00:00
|
84 |
}
|
85 |
|
86 |
//Set date and time formats. If they have not been set by user, set to global WordPress formats
|
87 |
-
$feed->set_date_format($feed_options['date_format']
|
88 |
-
$feed->set_time_format($feed_options['time_format']
|
89 |
//Set whether to handle multiple day events
|
90 |
-
$feed->set_multi_day($feed_options['multiple_day']
|
91 |
|
92 |
//Sets all display options
|
93 |
-
$feed->set_display_options(array(
|
94 |
'display_start' => $feed_options['display_start'],
|
95 |
'display_end' => $feed_options['display_end'],
|
96 |
'display_location' => $feed_options['display_location'],
|
@@ -104,10 +109,10 @@ class GCE_Parser{
|
|
104 |
'display_link_text' => $feed_options['display_link_text'],
|
105 |
'display_link_target' => $feed_options['display_link_target'],
|
106 |
'display_separator' => $feed_options['display_separator']
|
107 |
-
));
|
108 |
|
109 |
-
$feed->set_use_builder($feed_options['use_builder']
|
110 |
-
$feed->set_builder($feed_options['builder']);
|
111 |
|
112 |
//Parse the feed
|
113 |
$feed->init();
|
@@ -120,63 +125,68 @@ class GCE_Parser{
|
|
120 |
$this->merged_feed_data = array();
|
121 |
|
122 |
//Merge the feeds together into one array of events
|
123 |
-
foreach($this->feeds as $feed_id => $feed){
|
124 |
$errors_occurred = $feed->error();
|
125 |
|
126 |
-
if($errors_occurred
|
127 |
-
$this->merged_feed_data = array_merge($this->merged_feed_data, $feed->get_events());
|
128 |
-
|
129 |
$this->errors[$feed_id] = $errors_occurred;
|
130 |
-
}
|
131 |
}
|
132 |
|
133 |
//Sort the items into date order
|
134 |
-
if(!empty(
|
|
|
135 |
}
|
136 |
|
137 |
//Comparison function for use when sorting merged feed data (with usort)
|
138 |
-
function compare($event1, $event2){
|
139 |
-
|
|
|
|
|
|
|
|
|
140 |
}
|
141 |
|
142 |
//Returns number of errors that have occurred
|
143 |
-
function get_num_errors(){
|
144 |
-
return count($this->errors);
|
145 |
}
|
146 |
|
147 |
//Outputs a message describing each error that has occurred
|
148 |
-
function error_messages(){
|
149 |
-
$message = '<p>' . __('1 or more of your feeds could not be displayed. The following errors occurred:', GCE_TEXT_DOMAIN) . '</p><ul>';
|
150 |
|
151 |
-
foreach($this->errors as $feed_id => $error){
|
152 |
-
$message .= '<li><strong>' . sprintf(__('Feed %s:', GCE_TEXT_DOMAIN), $feed_id) . '</strong> ' . $error . '</li>';
|
153 |
}
|
154 |
|
155 |
return $message . '</ul>';
|
156 |
}
|
157 |
|
158 |
//Returns array of days with events, with sub-arrays of events for that day
|
159 |
-
function get_event_days(){
|
160 |
$event_days = array();
|
161 |
|
162 |
//Total number of events retrieved
|
163 |
-
$count = count($this->merged_feed_data);
|
164 |
|
165 |
//If maximum events to display is 0 (unlimited) set $max to 1, otherwise use maximum of events specified by user
|
166 |
-
$max = $this->max_events_display
|
167 |
|
168 |
//Loop through entire array of events, or until maximum number of events to be displayed has been reached
|
169 |
-
for($i = 0; $i < $count && $max > 0; $i++){
|
170 |
$event = $this->merged_feed_data[$i];
|
171 |
|
172 |
//Check that event end time isn't before start time of feed (ignores events from before start time that may have been inadvertently retrieved)
|
173 |
-
if($event->get_end_time() >
|
174 |
-
foreach($event->get_days() as $day){
|
175 |
$event_days[$day][] = $event;
|
176 |
}
|
177 |
|
178 |
//If maximum events to display isn't 0 (unlimited) decrement $max counter
|
179 |
-
if($this->max_events_display
|
|
|
180 |
}
|
181 |
}
|
182 |
|
@@ -184,132 +194,159 @@ class GCE_Parser{
|
|
184 |
}
|
185 |
|
186 |
//Returns grid markup
|
187 |
-
function get_grid($year = null, $month = null, $ajaxified = false){
|
188 |
-
require_once
|
|
|
|
|
189 |
|
190 |
//If year and month have not been passed as paramaters, use current month and year
|
191 |
-
if(
|
192 |
-
|
|
|
|
|
|
|
193 |
|
194 |
//Get timestamps for the start and end of current month
|
195 |
-
$current_month_start = mktime(0, 0, 0, date('m'), 1, date('Y'));
|
196 |
-
$current_month_end = mktime(0, 0, 0, date('m') + 1, 1, date('Y'));
|
197 |
|
198 |
//Get timestamps for the start and end of the month to be displayed in the grid
|
199 |
-
$display_month_start = mktime(0, 0, 0, $month, 1, $year);
|
200 |
-
$display_month_end = mktime(0, 0, 0, $month + 1, 1, $year);
|
201 |
|
202 |
//It should always be possible to navigate to the current month, even if it doesn't have any events
|
203 |
//So, if the display month is before the current month, set $nav_next to true, otherwise false
|
204 |
//If the display month is after the current month, set $nav_prev to true, otherwise false
|
205 |
-
$nav_next = $display_month_start < $current_month_start;
|
206 |
-
$nav_prev = $display_month_start >= $current_month_end;
|
207 |
|
208 |
//Get events data
|
209 |
$event_days = $this->get_event_days();
|
210 |
|
211 |
//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)
|
212 |
-
if(
|
|
|
213 |
|
214 |
-
$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
|
215 |
|
216 |
-
|
|
|
|
|
217 |
//If event day is in the month and year specified (by $month and $year)
|
218 |
-
if($key >= $display_month_start && $key < $display_month_end){
|
219 |
//Create array of CSS classes. Add gce-has-events
|
220 |
-
$css_classes = array('gce-has-events');
|
221 |
|
222 |
//Create markup for display
|
223 |
$markup = '<div class="gce-event-info">';
|
224 |
|
225 |
-
//If title option has been set for display, add it
|
226 |
-
if(isset(
|
|
|
227 |
|
228 |
$markup .= '<ul>';
|
229 |
|
230 |
-
foreach($event_day as $
|
231 |
$feed_id = $event->get_feed()->get_feed_id();
|
232 |
-
$markup .= '<li class="gce-tooltip-feed-' . $feed_id . '">' . $event->get_event_markup('tooltip', $
|
233 |
|
234 |
//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.
|
235 |
$css_classes['feed-' . $feed_id] = 'gce-feed-' . $feed_id;
|
|
|
|
|
236 |
}
|
237 |
|
238 |
$markup .= '</ul></div>';
|
239 |
|
240 |
//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
|
241 |
-
if(count($css_classes) > 2)
|
242 |
-
|
243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
|
245 |
//Change array entry to array of link href, CSS classes, and markup for use in gce_generate_calendar (below)
|
246 |
-
$event_days[$key] = array(null, implode(' ', $css_classes), $markup);
|
247 |
-
}elseif($key < $display_month_start){
|
248 |
//This day is before the display month, so set $nav_prev to true. Remove the day from $event_days, as it's no use for displaying this month
|
249 |
$nav_prev = true;
|
250 |
-
unset($event_days[$key]);
|
251 |
-
}else{
|
252 |
//This day is after the display month, so set $nav_next to true. Remove the day from $event_days, as it's no use for displaying this month
|
253 |
$nav_next = true;
|
254 |
-
unset($event_days[$key]);
|
255 |
}
|
256 |
}
|
257 |
|
258 |
//Ensures that gce-today CSS class is added even if there are no events for 'today'. A bit messy :(
|
259 |
-
if(!isset(
|
|
|
260 |
|
261 |
$pn = array();
|
262 |
|
263 |
//Only add previous / next functionality if AJAX grid is enabled
|
264 |
-
if($ajaxified){
|
265 |
//If there are events to display in a previous month, add previous month link
|
266 |
-
$prev_key = ($nav_prev ? '«' : ' '
|
267 |
-
$prev = ($nav_prev ? date('m-Y', mktime(0, 0, 0, $month - 1, 1, $year)) : null
|
268 |
|
269 |
//If there are events to display in a future month, add next month link
|
270 |
-
$next_key = ($nav_next ? '»' : ' '
|
271 |
-
$next = ($nav_next ? date('m-Y', mktime(0, 0, 0, $month + 1, 1, $year)) : null
|
272 |
|
273 |
//Array of previous and next link stuff for use in gce_generate_calendar (below)
|
274 |
-
$pn = array($prev_key => $prev, $next_key => $next);
|
275 |
}
|
276 |
|
277 |
//Generate the calendar markup and return it
|
278 |
-
return gce_generate_calendar($year, $month, $event_days, 1, null, $this->start_of_week, $pn);
|
279 |
}
|
280 |
|
281 |
-
function get_list($grouped = false){
|
|
|
|
|
282 |
$event_days = $this->get_event_days();
|
283 |
|
284 |
//If event_days is empty, there are no events in the feed(s), so return a message indicating this
|
285 |
-
if(
|
|
|
|
|
|
|
286 |
|
287 |
-
$
|
288 |
|
289 |
$markup = '<ul class="gce-list">';
|
290 |
|
291 |
-
foreach($event_days as $key => $event_day){
|
292 |
//If this is a grouped list, add the date title and begin the nested list for this day
|
293 |
-
if($grouped){
|
294 |
$markup .=
|
295 |
-
'<li' . ($key == $today ? ' class="gce-today"' : '') . '>' .
|
296 |
-
'<
|
297 |
'<ul>';
|
298 |
}
|
299 |
|
300 |
-
foreach($event_day as $
|
301 |
//Create the markup for this event
|
302 |
$markup .=
|
303 |
'<li class="gce-feed-' . $event->get_feed()->get_feed_id() . '">' .
|
304 |
//If this isn't a grouped list and a date title should be displayed, add the date title
|
305 |
-
((
|
306 |
//Add the event markup
|
307 |
-
$event->get_event_markup('list', $
|
308 |
'</li>';
|
|
|
|
|
309 |
}
|
310 |
|
311 |
//If this is a grouped list, close the nested list for this day
|
312 |
-
if($grouped)
|
|
|
313 |
}
|
314 |
|
315 |
$markup .= '</ul>';
|
1 |
<?php
|
2 |
+
class GCE_Parser {
|
3 |
private $feeds = array();
|
4 |
private $merged_feed_data = array();
|
5 |
private $errors = array();
|
6 |
private $title = null;
|
7 |
private $max_events_display = 0;
|
8 |
private $start_of_week = 0;
|
9 |
+
private $sort_order = 'asc';
|
10 |
|
11 |
+
function __construct( $feed_ids, $title_text = null, $max_events = 0, $sort_order = 'asc' ) {
|
12 |
require_once 'gce-feed.php';
|
13 |
|
14 |
$this->title = $title_text;
|
15 |
$this->max_events_display = $max_events;
|
16 |
+
$this->sort_order = $sort_order;
|
17 |
|
18 |
//Get the feed options
|
19 |
+
$options = get_option( GCE_OPTIONS_NAME );
|
20 |
|
21 |
+
$this->start_of_week = get_option( 'start_of_week' );
|
22 |
|
23 |
+
foreach ( $feed_ids as $single_feed ) {
|
24 |
//Get the options for this particular feed
|
25 |
+
if ( isset( $options[$single_feed] ) ) {
|
26 |
$feed_options = $options[$single_feed];
|
27 |
|
28 |
$feed = new GCE_Feed();
|
29 |
|
30 |
+
$feed->set_feed_id( $feed_options['id'] );
|
31 |
+
$feed->set_feed_title( $feed_options['title'] );
|
32 |
+
$feed->set_feed_url( $feed_options['url'] );
|
33 |
+
$feed->set_max_events( $feed_options['max_events'] );
|
34 |
+
$feed->set_cache_duration( $feed_options['cache_duration'] );
|
35 |
|
36 |
//Set the timezone if anything other than default
|
37 |
+
if ( 'default' != $feed_options['timezone'] )
|
38 |
+
$feed->set_timezone( $feed_options['timezone'] );
|
39 |
+
|
40 |
+
$gmt_offset = get_option( 'gmt_offset' ) * 3600;
|
41 |
|
42 |
//Set the start date to the appropriate value based on the retrieve_from option
|
43 |
+
switch ( $feed_options['retrieve_from'] ) {
|
44 |
//Don't just use time() for 'now', as this will effectively make cache duration 1 second. Instead set to previous minute. Events in Google Calendar cannot be set to precision of seconds anyway
|
45 |
case 'now':
|
46 |
+
$feed->set_feed_start( mktime( date( 'H' ), date( 'i' ), 0, date( 'm' ), date( 'j' ), date( 'Y' ) ) + $feed_options['retrieve_from_value'] + $gmt_offset );
|
47 |
break;
|
48 |
case 'today':
|
49 |
+
$feed->set_feed_start( mktime( 0, 0, 0, date( 'm' ), date( 'j' ), date( 'Y' ) ) + $feed_options['retrieve_from_value'] + $gmt_offset );
|
50 |
break;
|
51 |
case 'week':
|
52 |
+
$feed->set_feed_start( mktime( 0, 0, 0, date( 'm' ), ( date( 'j' ) - date( 'w' ) + $this->start_of_week ), date( 'Y' ) ) + $feed_options['retrieve_from_value'] + $gmt_offset );
|
53 |
break;
|
54 |
case 'month-start':
|
55 |
+
$feed->set_feed_start( mktime( 0, 0, 0, date( 'm' ), 1, date( 'Y' ) ) + $feed_options['retrieve_from_value'] + $gmt_offset );
|
56 |
break;
|
57 |
case 'month-end':
|
58 |
+
$feed->set_feed_start( mktime( 0, 0, 0, date( 'm' ) + 1, 1, date( 'Y' ) ) + $feed_options['retrieve_from_value'] + $gmt_offset );
|
59 |
break;
|
60 |
case 'date':
|
61 |
+
$feed->set_feed_start( $feed_options['retrieve_from_value'] );
|
62 |
break;
|
63 |
+
default:
|
64 |
+
$feed->set_feed_start( 0 ); //any - 1970-01-01 00:00
|
65 |
}
|
66 |
|
67 |
//Set the end date to the appropriate value based on the retrieve_until option
|
68 |
+
switch ( $feed_options['retrieve_until'] ) {
|
69 |
case 'now':
|
70 |
+
$feed->set_feed_end( mktime( date( 'H' ), date( 'i' ), 0, date( 'm' ), date( 'j' ), date( 'Y' ) ) + $feed_options['retrieve_until_value'] + $gmt_offset );
|
71 |
break;
|
72 |
case 'today':
|
73 |
+
$feed->set_feed_end( mktime( 0, 0, 0, date( 'm' ), date( 'j' ), date( 'Y' ) ) + $feed_options['retrieve_until_value'] + $gmt_offset );
|
74 |
break;
|
75 |
case 'week':
|
76 |
+
$feed->set_feed_end( mktime( 0, 0, 0, date( 'm' ), ( date( 'j' ) - date( 'w' ) + $this->start_of_week ), date( 'Y' ) ) + $feed_options['retrieve_until_value'] + $gmt_offset );
|
77 |
break;
|
78 |
case 'month-start':
|
79 |
+
$feed->set_feed_end( mktime( 0, 0, 0, date( 'm' ), 1, date( 'Y' ) ) + $feed_options['retrieve_until_value'] + $gmt_offset );
|
80 |
break;
|
81 |
case 'month-end':
|
82 |
+
$feed->set_feed_end( mktime( 0, 0, 0, date( 'm' ) + 1, 1, date( 'Y' ) ) + $feed_options['retrieve_until_value'] + $gmt_offset );
|
83 |
break;
|
84 |
case 'date':
|
85 |
+
$feed->set_feed_end( $feed_options['retrieve_until_value'] );
|
86 |
break;
|
87 |
case 'any':
|
88 |
+
$feed->set_feed_end( 2145916800 ); //any - 2038-01-01 00:00
|
89 |
}
|
90 |
|
91 |
//Set date and time formats. If they have not been set by user, set to global WordPress formats
|
92 |
+
$feed->set_date_format( ( empty( $feed_options['date_format'] ) ) ? get_option( 'date_format' ) : $feed_options['date_format'] );
|
93 |
+
$feed->set_time_format( ( empty( $feed_options['time_format'] ) ) ? get_option( 'time_format' ) : $feed_options['time_format'] );
|
94 |
//Set whether to handle multiple day events
|
95 |
+
$feed->set_multi_day( ( 'true' == $feed_options['multiple_day'] ) ? true : false );
|
96 |
|
97 |
//Sets all display options
|
98 |
+
$feed->set_display_options( array(
|
99 |
'display_start' => $feed_options['display_start'],
|
100 |
'display_end' => $feed_options['display_end'],
|
101 |
'display_location' => $feed_options['display_location'],
|
109 |
'display_link_text' => $feed_options['display_link_text'],
|
110 |
'display_link_target' => $feed_options['display_link_target'],
|
111 |
'display_separator' => $feed_options['display_separator']
|
112 |
+
) );
|
113 |
|
114 |
+
$feed->set_use_builder( ( 'true' == $feed_options['use_builder'] ) ? true : false );
|
115 |
+
$feed->set_builder( $feed_options['builder'] );
|
116 |
|
117 |
//Parse the feed
|
118 |
$feed->init();
|
125 |
$this->merged_feed_data = array();
|
126 |
|
127 |
//Merge the feeds together into one array of events
|
128 |
+
foreach ( $this->feeds as $feed_id => $feed ) {
|
129 |
$errors_occurred = $feed->error();
|
130 |
|
131 |
+
if ( false === $errors_occurred )
|
132 |
+
$this->merged_feed_data = array_merge( $this->merged_feed_data, $feed->get_events() );
|
133 |
+
else
|
134 |
$this->errors[$feed_id] = $errors_occurred;
|
|
|
135 |
}
|
136 |
|
137 |
//Sort the items into date order
|
138 |
+
if ( ! empty( $this->merged_feed_data ) )
|
139 |
+
usort( $this->merged_feed_data, array( $this, 'compare' ) );
|
140 |
}
|
141 |
|
142 |
//Comparison function for use when sorting merged feed data (with usort)
|
143 |
+
function compare( $event1, $event2 ) {
|
144 |
+
//Sort ascending or descending
|
145 |
+
if ( 'asc' == $this->sort_order )
|
146 |
+
return $event1->get_start_time() - $event2->get_start_time();
|
147 |
+
|
148 |
+
return $event2->get_start_time() - $event1->get_start_time();
|
149 |
}
|
150 |
|
151 |
//Returns number of errors that have occurred
|
152 |
+
function get_num_errors() {
|
153 |
+
return count( $this->errors );
|
154 |
}
|
155 |
|
156 |
//Outputs a message describing each error that has occurred
|
157 |
+
function error_messages() {
|
158 |
+
$message = '<p>' . __( '1 or more of your feeds could not be displayed. The following errors occurred:', GCE_TEXT_DOMAIN ) . '</p><ul>';
|
159 |
|
160 |
+
foreach ( $this->errors as $feed_id => $error ) {
|
161 |
+
$message .= '<li><strong>' . sprintf( __( 'Feed %s:', GCE_TEXT_DOMAIN ), $feed_id ) . '</strong> ' . $error . '</li>';
|
162 |
}
|
163 |
|
164 |
return $message . '</ul>';
|
165 |
}
|
166 |
|
167 |
//Returns array of days with events, with sub-arrays of events for that day
|
168 |
+
function get_event_days() {
|
169 |
$event_days = array();
|
170 |
|
171 |
//Total number of events retrieved
|
172 |
+
$count = count( $this->merged_feed_data );
|
173 |
|
174 |
//If maximum events to display is 0 (unlimited) set $max to 1, otherwise use maximum of events specified by user
|
175 |
+
$max = ( 0 == $this->max_events_display ) ? 1 : $this->max_events_display;
|
176 |
|
177 |
//Loop through entire array of events, or until maximum number of events to be displayed has been reached
|
178 |
+
for ( $i = 0; $i < $count && $max > 0; $i++ ) {
|
179 |
$event = $this->merged_feed_data[$i];
|
180 |
|
181 |
//Check that event end time isn't before start time of feed (ignores events from before start time that may have been inadvertently retrieved)
|
182 |
+
if ( $event->get_end_time() > $event->get_feed()->get_feed_start() ) {
|
183 |
+
foreach ( $event->get_days() as $day ) {
|
184 |
$event_days[$day][] = $event;
|
185 |
}
|
186 |
|
187 |
//If maximum events to display isn't 0 (unlimited) decrement $max counter
|
188 |
+
if ( 0 != $this->max_events_display )
|
189 |
+
$max--;
|
190 |
}
|
191 |
}
|
192 |
|
194 |
}
|
195 |
|
196 |
//Returns grid markup
|
197 |
+
function get_grid ( $year = null, $month = null, $ajaxified = false ) {
|
198 |
+
require_once 'php-calendar.php';
|
199 |
+
|
200 |
+
$time_now = current_time( 'timestamp' );
|
201 |
|
202 |
//If year and month have not been passed as paramaters, use current month and year
|
203 |
+
if( ! isset( $year ) )
|
204 |
+
$year = date( 'Y', $time_now );
|
205 |
+
|
206 |
+
if( ! isset( $month ) )
|
207 |
+
$month = date( 'm', $time_now );
|
208 |
|
209 |
//Get timestamps for the start and end of current month
|
210 |
+
$current_month_start = mktime( 0, 0, 0, date( 'm', $time_now ), 1, date( 'Y', $time_now ) );
|
211 |
+
$current_month_end = mktime( 0, 0, 0, date( 'm', $time_now ) + 1, 1, date( 'Y', $time_now ) );
|
212 |
|
213 |
//Get timestamps for the start and end of the month to be displayed in the grid
|
214 |
+
$display_month_start = mktime( 0, 0, 0, $month, 1, $year );
|
215 |
+
$display_month_end = mktime( 0, 0, 0, $month + 1, 1, $year );
|
216 |
|
217 |
//It should always be possible to navigate to the current month, even if it doesn't have any events
|
218 |
//So, if the display month is before the current month, set $nav_next to true, otherwise false
|
219 |
//If the display month is after the current month, set $nav_prev to true, otherwise false
|
220 |
+
$nav_next = ( $display_month_start < $current_month_start );
|
221 |
+
$nav_prev = ( $display_month_start >= $current_month_end );
|
222 |
|
223 |
//Get events data
|
224 |
$event_days = $this->get_event_days();
|
225 |
|
226 |
//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)
|
227 |
+
if ( empty( $event_days ) )
|
228 |
+
$ajaxified = false;
|
229 |
|
230 |
+
$today = mktime( 0, 0, 0, date( 'm', $time_now ), date( 'd', $time_now ), date( 'Y', $time_now ) );
|
231 |
|
232 |
+
$i = 1;
|
233 |
+
|
234 |
+
foreach ( $event_days as $key => $event_day ) {
|
235 |
//If event day is in the month and year specified (by $month and $year)
|
236 |
+
if ( $key >= $display_month_start && $key < $display_month_end ) {
|
237 |
//Create array of CSS classes. Add gce-has-events
|
238 |
+
$css_classes = array( 'gce-has-events' );
|
239 |
|
240 |
//Create markup for display
|
241 |
$markup = '<div class="gce-event-info">';
|
242 |
|
243 |
+
//If title option has been set for display, add it
|
244 |
+
if ( isset( $this->title ) )
|
245 |
+
$markup .= '<div class="gce-tooltip-title">' . $this->title . ' ' . date_i18n( $event_day[0]->get_feed()->get_date_format(), $key ) . '</div>';
|
246 |
|
247 |
$markup .= '<ul>';
|
248 |
|
249 |
+
foreach ( $event_day as $num_in_day => $event ) {
|
250 |
$feed_id = $event->get_feed()->get_feed_id();
|
251 |
+
$markup .= '<li class="gce-tooltip-feed-' . $feed_id . '">' . $event->get_event_markup( 'tooltip', $num_in_day, $i ) . '</li>';
|
252 |
|
253 |
//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.
|
254 |
$css_classes['feed-' . $feed_id] = 'gce-feed-' . $feed_id;
|
255 |
+
|
256 |
+
$i++;
|
257 |
}
|
258 |
|
259 |
$markup .= '</ul></div>';
|
260 |
|
261 |
//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
|
262 |
+
if ( count( $css_classes ) > 2 )
|
263 |
+
$css_classes[] = 'gce-multiple';
|
264 |
+
|
265 |
+
//If event day is today, add gce-today CSS class, otherwise add past or future class
|
266 |
+
if ( $key == $today )
|
267 |
+
$css_classes[] = 'gce-today gce-today-has-events';
|
268 |
+
elseif ( $key < $today )
|
269 |
+
$css_classes[] = 'gce-day-past';
|
270 |
+
else
|
271 |
+
$css_classes[] = 'gce-day-future';
|
272 |
|
273 |
//Change array entry to array of link href, CSS classes, and markup for use in gce_generate_calendar (below)
|
274 |
+
$event_days[$key] = array( null, implode( ' ', $css_classes ), $markup );
|
275 |
+
} elseif ( $key < $display_month_start ) {
|
276 |
//This day is before the display month, so set $nav_prev to true. Remove the day from $event_days, as it's no use for displaying this month
|
277 |
$nav_prev = true;
|
278 |
+
unset( $event_days[$key] );
|
279 |
+
} else {
|
280 |
//This day is after the display month, so set $nav_next to true. Remove the day from $event_days, as it's no use for displaying this month
|
281 |
$nav_next = true;
|
282 |
+
unset( $event_days[$key] );
|
283 |
}
|
284 |
}
|
285 |
|
286 |
//Ensures that gce-today CSS class is added even if there are no events for 'today'. A bit messy :(
|
287 |
+
if ( ! isset( $event_days[$today] ) )
|
288 |
+
$event_days[$today] = array( null, 'gce-today gce-today-no-events', null );
|
289 |
|
290 |
$pn = array();
|
291 |
|
292 |
//Only add previous / next functionality if AJAX grid is enabled
|
293 |
+
if ( $ajaxified ) {
|
294 |
//If there are events to display in a previous month, add previous month link
|
295 |
+
$prev_key = ( $nav_prev ) ? '«' : ' ';
|
296 |
+
$prev = ( $nav_prev ) ? date( 'm-Y', mktime( 0, 0, 0, $month - 1, 1, $year ) ) : null;
|
297 |
|
298 |
//If there are events to display in a future month, add next month link
|
299 |
+
$next_key = ( $nav_next ) ? '»' : ' ';
|
300 |
+
$next = ( $nav_next ) ? date( 'm-Y', mktime( 0, 0, 0, $month + 1, 1, $year ) ) : null;
|
301 |
|
302 |
//Array of previous and next link stuff for use in gce_generate_calendar (below)
|
303 |
+
$pn = array( $prev_key => $prev, $next_key => $next );
|
304 |
}
|
305 |
|
306 |
//Generate the calendar markup and return it
|
307 |
+
return gce_generate_calendar( $year, $month, $event_days, 1, null, $this->start_of_week, $pn );
|
308 |
}
|
309 |
|
310 |
+
function get_list( $grouped = false ) {
|
311 |
+
$time_now = current_time( 'timestamp' );
|
312 |
+
|
313 |
$event_days = $this->get_event_days();
|
314 |
|
315 |
//If event_days is empty, there are no events in the feed(s), so return a message indicating this
|
316 |
+
if( empty( $event_days) )
|
317 |
+
return '<p>' . __( 'There are currently no events to display.', GCE_TEXT_DOMAIN ) . '</p>';
|
318 |
+
|
319 |
+
$today = mktime( 0, 0, 0, date( 'm', $time_now ), date( 'd', $time_now ), date( 'Y', $time_now ) );
|
320 |
|
321 |
+
$i = 1;
|
322 |
|
323 |
$markup = '<ul class="gce-list">';
|
324 |
|
325 |
+
foreach ( $event_days as $key => $event_day ) {
|
326 |
//If this is a grouped list, add the date title and begin the nested list for this day
|
327 |
+
if ( $grouped ) {
|
328 |
$markup .=
|
329 |
+
'<li' . ( ( $key == $today ) ? ' class="gce-today"' : '' ) . '>' .
|
330 |
+
'<div class="gce-list-title">' . $this->title . ' ' . date_i18n( $event_day[0]->get_feed()->get_date_format(), $key ) . '</div>' .
|
331 |
'<ul>';
|
332 |
}
|
333 |
|
334 |
+
foreach ( $event_day as $num_in_day => $event ) {
|
335 |
//Create the markup for this event
|
336 |
$markup .=
|
337 |
'<li class="gce-feed-' . $event->get_feed()->get_feed_id() . '">' .
|
338 |
//If this isn't a grouped list and a date title should be displayed, add the date title
|
339 |
+
( ( ! $grouped && isset( $this->title ) ) ? '<div class="gce-list-title">' . $this->title . ' ' . date_i18n( $event->get_feed()->get_date_format(), $key ) . '</div>' : '' ) .
|
340 |
//Add the event markup
|
341 |
+
$event->get_event_markup( 'list', $num_in_day, $i ) .
|
342 |
'</li>';
|
343 |
+
|
344 |
+
$i++;
|
345 |
}
|
346 |
|
347 |
//If this is a grouped list, close the nested list for this day
|
348 |
+
if ( $grouped )
|
349 |
+
$markup .= '</ul></li>';
|
350 |
}
|
351 |
|
352 |
$markup .= '</ul>';
|
inc/php-calendar.php
CHANGED
@@ -17,60 +17,66 @@ Changes made to original PHP Calendar script by me (Ross Hanney):
|
|
17 |
- Replaced gmmktime() with mktime()
|
18 |
*/
|
19 |
|
20 |
-
function gce_generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
|
21 |
global $wp_locale;
|
22 |
|
23 |
-
$first_of_month = mktime(0, 0, 0, $month, 1, $year);
|
24 |
#remember that mktime will automatically correct if invalid dates are entered
|
25 |
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
|
26 |
# this provides a built in "rounding" feature to generate_calendar()
|
27 |
|
28 |
$day_names = array(); #generate all the day names according to the current locale
|
29 |
-
for($n = 0, $t = (3 + $first_day) * 86400; $n < 7; $n++, $t += 86400){ #January 4, 1970 was a Sunday
|
30 |
-
$day_names[$n]['full'] = date_i18n('l', $t, true);
|
31 |
-
$day_names[$n]['initial'] = $wp_locale->get_weekday_initial(date_i18n('l', $t, true));
|
32 |
}
|
33 |
|
34 |
-
list($month, $year, $month_name, $weekday) = explode(',', date_i18n('m, Y, F, w', $first_of_month));
|
35 |
-
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
|
36 |
-
$title = esc_html($month_name) . ' ' . $year; #note that some locales don't capitalize month and day names
|
37 |
|
38 |
#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
|
39 |
-
|
40 |
-
|
41 |
|
42 |
-
if
|
43 |
-
|
|
|
|
|
44 |
|
45 |
-
$calendar = '<table class="gce-calendar">' . "\n" . '<caption class="gce-caption">' . $p . '<span class="gce-month-title">' . ($month_href ? '<a href="' . esc_attr($month_href) . '">' . $title . '</a>' : $title) . '</span>' . $n . "</caption>\n<tr>";
|
46 |
|
47 |
-
if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
|
48 |
#if day_name_length is >3, the full name of the day will be printed
|
49 |
-
foreach($day_names as $d){
|
50 |
-
$calendar .= '<th><abbr title="' . esc_attr($d['full']) . '">' . esc_html($d['initial']) . '</abbr></th>';
|
51 |
}
|
52 |
|
53 |
$calendar .= "</tr>\n<tr>";
|
54 |
}
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
59 |
$weekday = 0; #start a new week
|
60 |
$calendar .= "</tr>\n<tr>";
|
61 |
}
|
62 |
|
63 |
-
$timestamp = mktime(0, 0, 0, $month, $day, $year);
|
64 |
|
65 |
-
if(isset($days[$timestamp])
|
66 |
-
|
67 |
-
$calendar .= '<td' . ($classes ? ' class="' . $classes . '">' : '>') . ($link ? '<a href="' . $link . '"><span class="gce-day-number">' . $day . '</span></a>' . $content : '<span class="gce-day-number">' . $day . '</span>' . $content) . '</td>';
|
68 |
}else{
|
69 |
-
$
|
|
|
70 |
}
|
71 |
}
|
72 |
|
73 |
-
if($weekday
|
74 |
|
75 |
return $calendar . "</tr>\n</table>\n";
|
76 |
}
|
17 |
- Replaced gmmktime() with mktime()
|
18 |
*/
|
19 |
|
20 |
+
function gce_generate_calendar( $year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array() ) {
|
21 |
global $wp_locale;
|
22 |
|
23 |
+
$first_of_month = mktime( 0, 0, 0, $month, 1, $year );
|
24 |
#remember that mktime will automatically correct if invalid dates are entered
|
25 |
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
|
26 |
# this provides a built in "rounding" feature to generate_calendar()
|
27 |
|
28 |
$day_names = array(); #generate all the day names according to the current locale
|
29 |
+
for ( $n = 0, $t = ( 3 + $first_day ) * 86400; $n < 7; $n++, $t += 86400 ) { #January 4, 1970 was a Sunday
|
30 |
+
$day_names[$n]['full'] = date_i18n( 'l', $t, true );
|
31 |
+
$day_names[$n]['initial'] = $wp_locale->get_weekday_initial( date_i18n( 'l', $t, true ) );
|
32 |
}
|
33 |
|
34 |
+
list( $month, $year, $month_name, $weekday ) = explode( ',', date_i18n( 'm, Y, F, w', $first_of_month ) );
|
35 |
+
$weekday = ( $weekday + 7 - $first_day ) % 7; #adjust for $first_day
|
36 |
+
$title = esc_html( $month_name ) . ' ' . $year; #note that some locales don't capitalize month and day names
|
37 |
|
38 |
#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
|
39 |
+
list( $p, $pl ) = each( $pn );
|
40 |
+
list( $n, $nl ) = each( $pn ); #previous and next links, if applicable
|
41 |
|
42 |
+
if ( $p )
|
43 |
+
$p = '<span class="gce-prev">' . ( ( $pl ) ? ( '<a class="gce-change-month" title="Previous month" name="' . $pl . '">' . $p . '</a>' ) : $p ) . '</span> ';
|
44 |
+
if ( $n )
|
45 |
+
$n = ' <span class="gce-next">' . ( ( $nl ) ? ( '<a class="gce-change-month" title="Next month" name="' . $nl . '">' . $n . '</a>' ) : $n ) . '</span>';
|
46 |
|
47 |
+
$calendar = '<table class="gce-calendar">' . "\n" . '<caption class="gce-caption">' . $p . '<span class="gce-month-title">' . ( ( $month_href ) ? ( '<a href="' . esc_attr( $month_href ) . '">' . $title . '</a>' ) : $title ) . '</span>' . $n . "</caption>\n<tr>";
|
48 |
|
49 |
+
if ( $day_name_length ) { #if the day names should be shown ($day_name_length > 0)
|
50 |
#if day_name_length is >3, the full name of the day will be printed
|
51 |
+
foreach ( $day_names as $d ) {
|
52 |
+
$calendar .= '<th><abbr title="' . esc_attr( $d['full'] ) . '">' . esc_html( $d['initial'] ) . '</abbr></th>';
|
53 |
}
|
54 |
|
55 |
$calendar .= "</tr>\n<tr>";
|
56 |
}
|
57 |
|
58 |
+
$time_now = current_time( 'timestamp' );
|
59 |
+
$today = mktime( 0, 0, 0, date( 'm', $time_now ), date( 'd', $time_now ), date( 'Y', $time_now ) );
|
60 |
+
|
61 |
+
if ( $weekday > 0 ) $calendar .= '<td colspan="' . $weekday . '"> </td>'; #initial 'empty' days
|
62 |
+
for ( $day = 1, $days_in_month = date( 't', $first_of_month ); $day <= $days_in_month; $day++, $weekday++ ) {
|
63 |
+
if ( 7 == $weekday ) {
|
64 |
$weekday = 0; #start a new week
|
65 |
$calendar .= "</tr>\n<tr>";
|
66 |
}
|
67 |
|
68 |
+
$timestamp = mktime( 0, 0, 0, $month, $day, $year );
|
69 |
|
70 |
+
if ( isset( $days[$timestamp] ) && is_array( $days[$timestamp] ) ) {
|
71 |
+
list( $link, $classes, $content ) = $days[$timestamp];
|
72 |
+
$calendar .= '<td' . ( ( $classes ) ? ( ' class="' . $classes . '">' ) : '>' ) . ( ( $link ) ? ( '<a href="' . $link . '"><span class="gce-day-number">' . $day . '</span></a>' . $content ) : '<span class="gce-day-number">' . $day . '</span>' . $content ) . '</td>';
|
73 |
}else{
|
74 |
+
$css_class = ( $timestamp < $time_now ) ? 'gce-day-past' : 'gce-day-future';
|
75 |
+
$calendar .= '<td class="' . $css_class . '"><span class="gce-day-number">' . $day . '</span></td>';
|
76 |
}
|
77 |
}
|
78 |
|
79 |
+
if ( 7 != $weekday ) $calendar .= '<td colspan="' . ( 7 - $weekday ) . '"> </td>'; #remaining "empty" days
|
80 |
|
81 |
return $calendar . "</tr>\n</table>\n";
|
82 |
}
|
languages/google-calendar-events.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the same license as the Google Calendar Events package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Google Calendar Events 0.
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/google-calendar-events\n"
|
7 |
-
"POT-Creation-Date: 2011-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -12,422 +12,490 @@ msgstr ""
|
|
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
|
15 |
-
#: inc/gce-feed.php:
|
16 |
msgid ""
|
17 |
"Some data was retrieved, but could not be parsed successfully. Please ensure "
|
18 |
"your feed URL is correct."
|
19 |
msgstr ""
|
20 |
|
21 |
-
#: inc/gce-feed.php:
|
22 |
msgid ""
|
23 |
"The feed could not be found (404). Please ensure your feed URL is correct."
|
24 |
msgstr ""
|
25 |
|
26 |
-
#: inc/gce-feed.php:
|
27 |
msgid ""
|
28 |
"Access to this feed was denied (403). Please ensure you have public sharing "
|
29 |
"enabled for your calendar."
|
30 |
msgstr ""
|
31 |
|
32 |
-
#: inc/gce-feed.php:
|
33 |
msgid ""
|
34 |
"The feed data could not be retrieved. Error code: %s. Please ensure your "
|
35 |
"feed URL is correct."
|
36 |
msgstr ""
|
37 |
|
38 |
-
#: inc/gce-
|
39 |
-
msgid ""
|
40 |
-
"1 or more of your feeds could not be displayed. The following errors "
|
41 |
-
"occurred:"
|
42 |
-
msgstr ""
|
43 |
-
|
44 |
-
#: inc/gce-parser.php:152
|
45 |
-
msgid "Feed %s:"
|
46 |
-
msgstr ""
|
47 |
-
|
48 |
-
#: inc/gce-parser.php:285
|
49 |
-
msgid "There are currently no events to display."
|
50 |
-
msgstr ""
|
51 |
-
|
52 |
-
#: inc/gce-event.php:368
|
53 |
msgid "%s year"
|
54 |
msgstr ""
|
55 |
|
56 |
-
#: inc/gce-event.php:
|
57 |
msgid "%s years"
|
58 |
msgstr ""
|
59 |
|
60 |
-
#: inc/gce-event.php:
|
61 |
msgid "%s month"
|
62 |
msgstr ""
|
63 |
|
64 |
-
#: inc/gce-event.php:
|
65 |
msgid "%s months"
|
66 |
msgstr ""
|
67 |
|
68 |
-
#: inc/gce-event.php:
|
69 |
msgid "%s week"
|
70 |
msgstr ""
|
71 |
|
72 |
-
#: inc/gce-event.php:
|
73 |
msgid "%s weeks"
|
74 |
msgstr ""
|
75 |
|
76 |
-
#: inc/gce-event.php:
|
77 |
msgid "%s day"
|
78 |
msgstr ""
|
79 |
|
80 |
-
#: inc/gce-event.php:
|
81 |
msgid "%s days"
|
82 |
msgstr ""
|
83 |
|
84 |
-
#: inc/gce-event.php:
|
85 |
msgid "%s hour"
|
86 |
msgstr ""
|
87 |
|
88 |
-
#: inc/gce-event.php:
|
89 |
msgid "%s hours"
|
90 |
msgstr ""
|
91 |
|
92 |
-
#: inc/gce-event.php:
|
93 |
msgid "%s min"
|
94 |
msgstr ""
|
95 |
|
96 |
-
#: inc/gce-event.php:
|
97 |
msgid "%s mins"
|
98 |
msgstr ""
|
99 |
|
100 |
-
#: inc/gce-event.php:
|
101 |
msgctxt "human_time_diff"
|
102 |
msgid ", "
|
103 |
msgstr ""
|
104 |
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
#. Plugin Name of the plugin/theme
|
107 |
-
#: widget/gce-widget.php:6
|
108 |
msgid "Google Calendar Events"
|
109 |
msgstr ""
|
110 |
|
111 |
-
#:
|
|
|
|
|
|
|
|
|
112 |
msgid ""
|
113 |
-
"
|
114 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
msgstr ""
|
116 |
|
117 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
msgid ""
|
119 |
-
"No valid Feed IDs have been entered for this
|
120 |
-
"have entered the IDs correctly
|
121 |
-
"Widgets), and that the Feeds have not been deleted."
|
122 |
msgstr ""
|
123 |
|
124 |
-
#:
|
125 |
msgid ""
|
126 |
"No feeds have been added yet. You can add a feed in the Google Calendar "
|
127 |
"Events settings."
|
128 |
msgstr ""
|
129 |
|
130 |
-
#:
|
131 |
-
msgid ""
|
132 |
-
"No feeds have been added yet. You can add feeds in the Google Calendar "
|
133 |
-
"Events settings."
|
134 |
msgstr ""
|
135 |
|
136 |
-
#:
|
137 |
-
msgid "
|
138 |
msgstr ""
|
139 |
|
140 |
-
#:
|
141 |
-
msgid "
|
142 |
msgstr ""
|
143 |
|
144 |
-
#:
|
145 |
-
msgid "Calendar
|
146 |
msgstr ""
|
147 |
|
148 |
-
#:
|
149 |
-
msgid "
|
150 |
msgstr ""
|
151 |
|
152 |
-
#:
|
153 |
-
msgid "
|
154 |
msgstr ""
|
155 |
|
156 |
-
#:
|
157 |
-
msgid "
|
158 |
msgstr ""
|
159 |
|
160 |
-
#:
|
161 |
-
msgid "
|
162 |
msgstr ""
|
163 |
|
164 |
-
#:
|
165 |
-
msgid "
|
166 |
msgstr ""
|
167 |
|
168 |
-
#:
|
169 |
-
msgid ""
|
170 |
-
"<strong>Notice:</strong> The way in which Google Calendar Events stores "
|
171 |
-
"cached data has been much improved in version 0.6. As you have upgraded from "
|
172 |
-
"a previous version of the plugin, there is likely to be some data from the "
|
173 |
-
"old caching system hanging around in your database that is now useless. "
|
174 |
-
"Click below to clear expired cached data from your database."
|
175 |
msgstr ""
|
176 |
|
177 |
-
#:
|
178 |
-
msgid "
|
179 |
msgstr ""
|
180 |
|
181 |
-
#:
|
182 |
-
msgid "
|
183 |
msgstr ""
|
184 |
|
185 |
-
#:
|
186 |
-
msgid "
|
|
|
|
|
|
|
187 |
msgstr ""
|
188 |
|
189 |
-
#:
|
190 |
-
msgid "Add
|
191 |
msgstr ""
|
192 |
|
193 |
-
#:
|
194 |
-
|
195 |
-
|
|
|
196 |
msgstr ""
|
197 |
|
198 |
-
#:
|
199 |
-
msgid "
|
200 |
msgstr ""
|
201 |
|
202 |
-
#:
|
203 |
-
msgid "
|
204 |
msgstr ""
|
205 |
|
206 |
-
#:
|
207 |
-
msgid "
|
208 |
msgstr ""
|
209 |
|
210 |
-
#:
|
211 |
-
msgid "
|
|
|
|
|
|
|
212 |
msgstr ""
|
213 |
|
214 |
-
#:
|
215 |
-
msgid "
|
216 |
msgstr ""
|
217 |
|
218 |
-
#:
|
219 |
msgid ""
|
220 |
-
"
|
221 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
msgstr ""
|
223 |
|
224 |
-
#: admin/
|
|
|
|
|
|
|
|
|
225 |
msgid "Add a Feed"
|
226 |
msgstr ""
|
227 |
|
228 |
-
#: admin/add.php:
|
229 |
msgid "Feed ID"
|
230 |
msgstr ""
|
231 |
|
232 |
-
#: admin/add.php:
|
233 |
msgid "Feed Title"
|
234 |
msgstr ""
|
235 |
|
236 |
-
#: admin/add.php:
|
237 |
msgid "Feed URL"
|
238 |
msgstr ""
|
239 |
|
240 |
-
#: admin/add.php:
|
241 |
msgid "Retrieve events from"
|
242 |
msgstr ""
|
243 |
|
244 |
-
#: admin/add.php:
|
245 |
msgid "Retrieve events until"
|
246 |
msgstr ""
|
247 |
|
248 |
-
#: admin/add.php:
|
249 |
msgid "Maximum number of events to retrieve"
|
250 |
msgstr ""
|
251 |
|
252 |
-
#: admin/add.php:
|
253 |
msgid "Date format"
|
254 |
msgstr ""
|
255 |
|
256 |
-
#: admin/add.php:
|
257 |
msgid "Time format"
|
258 |
msgstr ""
|
259 |
|
260 |
-
#: admin/add.php:
|
261 |
msgid "Timezone adjustment"
|
262 |
msgstr ""
|
263 |
|
264 |
-
#: admin/add.php:
|
265 |
msgid "Cache duration"
|
266 |
msgstr ""
|
267 |
|
268 |
-
#: admin/add.php:
|
269 |
msgid "Show multiple day events on each day?"
|
270 |
msgstr ""
|
271 |
|
272 |
-
#: admin/add.php:
|
273 |
msgid "Display Options"
|
274 |
msgstr ""
|
275 |
|
276 |
-
#: admin/add.php:
|
277 |
msgid "Select display customization method"
|
278 |
msgstr ""
|
279 |
|
280 |
-
#: admin/add.php:
|
281 |
msgid "Event Display Builder"
|
282 |
msgstr ""
|
283 |
|
284 |
-
#: admin/add.php:
|
285 |
msgid "Event display builder HTML and shortcodes"
|
286 |
msgstr ""
|
287 |
|
288 |
-
#: admin/add.php:
|
289 |
msgid "Simple Display Options"
|
290 |
msgstr ""
|
291 |
|
292 |
-
#: admin/add.php:
|
293 |
msgid "Display start time / date?"
|
294 |
msgstr ""
|
295 |
|
296 |
-
#: admin/add.php:
|
297 |
msgid "Display end time / date?"
|
298 |
msgstr ""
|
299 |
|
300 |
-
#: admin/add.php:
|
301 |
msgid "Separator text / characters"
|
302 |
msgstr ""
|
303 |
|
304 |
-
#: admin/add.php:
|
305 |
msgid "Display location?"
|
306 |
msgstr ""
|
307 |
|
308 |
-
#: admin/add.php:
|
309 |
msgid "Display description?"
|
310 |
msgstr ""
|
311 |
|
312 |
-
#: admin/add.php:
|
313 |
msgid "Display link to event?"
|
314 |
msgstr ""
|
315 |
|
316 |
-
#: admin/add.php:
|
317 |
msgid "Enter the feed details below, then click the Add Feed button."
|
318 |
msgstr ""
|
319 |
|
320 |
-
#: admin/add.php:
|
321 |
msgid "Anything you like. 'Upcoming Club Events', for example."
|
322 |
msgstr ""
|
323 |
|
324 |
-
#: admin/add.php:
|
325 |
-
msgid ""
|
326 |
-
"This will probably be something like: <code>http://www.google.com/calendar/"
|
327 |
-
"feeds/your-email@gmail.com/public/basic</code>."
|
328 |
msgstr ""
|
329 |
|
330 |
-
#: admin/add.php:
|
331 |
-
msgid ""
|
332 |
-
"or: <code>http://www.google.com/calendar/feeds/your-email@gmail.com/private-"
|
333 |
-
"d65741b037h695ff274247f90746b2ty/basic</code>."
|
334 |
msgstr ""
|
335 |
|
336 |
-
#: admin/add.php:84
|
337 |
msgid ""
|
338 |
"The point in time at which to start retrieving events. Use the text-box to "
|
339 |
"specify an additional offset from you chosen start point. The offset should "
|
340 |
"be provided in seconds (3600 = 1 hour, 86400 = 1 day) and can be negative. "
|
341 |
-
"If you have selected the 'Specific date / time' option, enter a
|
342 |
-
|
343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
msgstr ""
|
345 |
|
346 |
-
#: admin/add.php:
|
347 |
msgid "Now"
|
348 |
msgstr ""
|
349 |
|
350 |
-
#: admin/add.php:
|
351 |
msgid "00:00 today"
|
352 |
msgstr ""
|
353 |
|
354 |
-
#: admin/add.php:
|
355 |
msgid "Start of current week"
|
356 |
msgstr ""
|
357 |
|
358 |
-
#: admin/add.php:
|
359 |
msgid "Start of current month"
|
360 |
msgstr ""
|
361 |
|
362 |
-
#: admin/add.php:
|
363 |
msgid "End of current month"
|
364 |
msgstr ""
|
365 |
|
366 |
-
#: admin/add.php:
|
367 |
msgid "The beginning of time"
|
368 |
msgstr ""
|
369 |
|
370 |
-
#: admin/add.php:
|
371 |
msgid "Specific date / time"
|
372 |
msgstr ""
|
373 |
|
374 |
-
#: admin/add.php:
|
375 |
msgid ""
|
376 |
"The point in time at which to stop retrieving events. The instructions for "
|
377 |
"the above option also apply here."
|
378 |
msgstr ""
|
379 |
|
380 |
-
#: admin/add.php:
|
381 |
msgid "The end of time"
|
382 |
msgstr ""
|
383 |
|
384 |
-
#: admin/add.php:
|
385 |
msgid ""
|
386 |
"Set this to a few more than you actually want to display (due to caching and "
|
387 |
"timezone issues). The exact number to display can be configured per "
|
388 |
"shortcode / widget."
|
389 |
msgstr ""
|
390 |
|
391 |
-
#: admin/add.php:
|
392 |
msgid ""
|
393 |
"In <a href=\"http://php.net/manual/en/function.date.php\" target=\"_blank"
|
394 |
"\">PHP date format</a>. Leave this blank if you'd rather stick with the "
|
395 |
"default format for your blog."
|
396 |
msgstr ""
|
397 |
|
398 |
-
#: admin/add.php:
|
399 |
msgid ""
|
400 |
"In <a href=\"http://php.net/manual/en/function.date.php\" target=\"_blank"
|
401 |
"\">PHP date format</a>. Again, leave this blank to stick with the default."
|
402 |
msgstr ""
|
403 |
|
404 |
-
#: admin/add.php:
|
405 |
msgid ""
|
406 |
"If you are having problems with dates and times displaying in the wrong "
|
407 |
"timezone, select a city in your required timezone here."
|
408 |
msgstr ""
|
409 |
|
410 |
-
#: admin/add.php:
|
411 |
msgid ""
|
412 |
"The length of time, in seconds, to cache the feed (43200 = 12 hours). If "
|
413 |
"this feed changes regularly, you may want to reduce the cache duration."
|
414 |
msgstr ""
|
415 |
|
416 |
-
#: admin/add.php:
|
417 |
msgid ""
|
418 |
-
"Show events that span multiple days on each day that they span
|
419 |
-
"
|
420 |
-
"4#multiday\" target=\"_blank\">limitations</a> of this feature to be aware "
|
421 |
-
"of)."
|
422 |
msgstr ""
|
423 |
|
424 |
-
#: admin/add.php:
|
425 |
msgid ""
|
426 |
"These settings control what information will be displayed for this feed in "
|
427 |
"the tooltip (for grids), or in a list."
|
428 |
msgstr ""
|
429 |
|
430 |
-
#: admin/add.php:
|
431 |
msgid ""
|
432 |
"It is recommended that you use the event display builder option, as it "
|
433 |
"provides much more flexibility than the simple display options. The event "
|
@@ -435,232 +503,247 @@ msgid ""
|
|
435 |
"more!"
|
436 |
msgstr ""
|
437 |
|
438 |
-
#: admin/add.php:
|
439 |
msgid "Event display builder"
|
440 |
msgstr ""
|
441 |
|
442 |
-
#: admin/add.php:
|
443 |
msgid "Simple display options"
|
444 |
msgstr ""
|
445 |
|
446 |
-
#: admin/add.php:
|
447 |
msgid ""
|
448 |
"Use the event display builder to customize how event information will be "
|
449 |
"displayed in the grid tooltips and in lists. Use HTML and the shortcodes "
|
450 |
"(explained below) to display the information you require. A basic example "
|
451 |
"display format is provided as a starting point. For more information, take a "
|
452 |
-
"look at the
|
453 |
-
"events/event-display-builder\" target=\"_blank\">event display builder "
|
454 |
-
"guide</a>."
|
455 |
msgstr ""
|
456 |
|
457 |
-
#: admin/add.php:
|
|
|
|
|
|
|
|
|
458 |
msgid ""
|
459 |
"(More information on all of the below shortcodes and attributes, and working "
|
460 |
-
"examples, can be found in the
|
461 |
-
"google-calendar-events/event-display-builder\" target=\"_blank\">event "
|
462 |
-
"display builder guide</a>)"
|
463 |
msgstr ""
|
464 |
|
465 |
-
#: admin/add.php:
|
466 |
msgid "Event information shortcodes:"
|
467 |
msgstr ""
|
468 |
|
469 |
-
#: admin/add.php:
|
470 |
msgid ""
|
471 |
"The event title (possible attributes: <code>html</code>, <code>markdown</"
|
472 |
"code>)"
|
473 |
msgstr ""
|
474 |
|
475 |
-
#: admin/add.php:
|
476 |
msgid ""
|
477 |
"The event start time. Will use the time format specified in the above "
|
478 |
"settings"
|
479 |
msgstr ""
|
480 |
|
481 |
-
#: admin/add.php:
|
482 |
msgid ""
|
483 |
"The event start date. Will use the date format specified in the above "
|
484 |
"settings"
|
485 |
msgstr ""
|
486 |
|
487 |
-
#: admin/add.php:
|
488 |
msgid ""
|
489 |
"The event start date / time. Will use the format specified in the "
|
490 |
"<code>format</code> attribute (possible attributes: <code>format</code>)"
|
491 |
msgstr ""
|
492 |
|
493 |
-
#: admin/add.php:
|
494 |
msgid ""
|
495 |
"The difference between the start time of the event and the time now, in "
|
496 |
"human-readable format, such as '1 hour', '4 days', '15 mins' (possible "
|
497 |
"attributes: <code>precision</code>)"
|
498 |
msgstr ""
|
499 |
|
500 |
-
#: admin/add.php:
|
501 |
msgid ""
|
502 |
"The event end time. Will use the time format specified in the above settings"
|
503 |
msgstr ""
|
504 |
|
505 |
-
#: admin/add.php:
|
506 |
msgid ""
|
507 |
"The event end date. Will use the date format specified in the above settings"
|
508 |
msgstr ""
|
509 |
|
510 |
-
#: admin/add.php:
|
511 |
msgid ""
|
512 |
"The event end date / time. Will use the format specified in the "
|
513 |
"<code>format</code> attribute (possible attributes: <code>format</code>)"
|
514 |
msgstr ""
|
515 |
|
516 |
-
#: admin/add.php:
|
517 |
msgid ""
|
518 |
"The difference between the end time of the event and the time now, in human-"
|
519 |
"readable format (possible attributes: <code>precision</code>)"
|
520 |
msgstr ""
|
521 |
|
522 |
-
#: admin/add.php:
|
523 |
msgid ""
|
524 |
"The event location (possible attributes: <code>html</code>, <code>markdown</"
|
525 |
"code>)"
|
526 |
msgstr ""
|
527 |
|
528 |
-
#: admin/add.php:
|
529 |
msgid ""
|
530 |
"Anything between the opening and closing shortcode tags (inlcuding further "
|
531 |
"shortcodes) will be linked to Google Maps, using the event location as a "
|
532 |
"search parameter (possible attributes: <code>newwindow</code>)"
|
533 |
msgstr ""
|
534 |
|
535 |
-
#: admin/add.php:
|
536 |
msgid ""
|
537 |
"The event description (possible attributes: <code>html</code>, "
|
538 |
"<code>markdown</code>, <code>limit</code>)"
|
539 |
msgstr ""
|
540 |
|
541 |
-
#: admin/add.php:
|
542 |
msgid ""
|
543 |
"Anything between the opening and closing shortcode tags (inlcuding further "
|
544 |
"shortcodes) will be linked to the Google Calendar page for the event "
|
545 |
"(possible attributes: <code>newwindow</code>)"
|
546 |
msgstr ""
|
547 |
|
548 |
-
#: admin/add.php:
|
549 |
msgid "The raw URL to the Google Calendar page for the event"
|
550 |
msgstr ""
|
551 |
|
552 |
-
#: admin/add.php:
|
553 |
msgid ""
|
554 |
"The length of the event, in human-readable format (possible attributes: "
|
555 |
"<code>precision</code>)"
|
556 |
msgstr ""
|
557 |
|
558 |
-
#: admin/add.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
msgid "Feed information shortcodes:"
|
560 |
msgstr ""
|
561 |
|
562 |
-
#: admin/add.php:
|
563 |
msgid "The title of the feed from which the event comes"
|
564 |
msgstr ""
|
565 |
|
566 |
-
#: admin/add.php:
|
567 |
msgid "The ID of the feed from which the event comes"
|
568 |
msgstr ""
|
569 |
|
570 |
-
#: admin/add.php:
|
|
|
|
|
|
|
|
|
|
|
571 |
msgid "Conditional shortcodes:"
|
572 |
msgstr ""
|
573 |
|
574 |
-
#: admin/add.php:
|
575 |
msgid ""
|
576 |
"Anything entered between the opening and closing tags of each of the "
|
577 |
"following shortcodes will only be displayed if its condition (below) is met."
|
578 |
msgstr ""
|
579 |
|
580 |
-
#: admin/add.php:
|
581 |
msgid "The event is an all-day event"
|
582 |
msgstr ""
|
583 |
|
584 |
-
#: admin/add.php:
|
585 |
msgid "The event is not an all-day event"
|
586 |
msgstr ""
|
587 |
|
588 |
-
#: admin/add.php:
|
589 |
msgid "The event has a title"
|
590 |
msgstr ""
|
591 |
|
592 |
-
#: admin/add.php:
|
593 |
msgid "The event has a description"
|
594 |
msgstr ""
|
595 |
|
596 |
-
#: admin/add.php:
|
597 |
msgid "The event has a location"
|
598 |
msgstr ""
|
599 |
|
600 |
-
#: admin/add.php:
|
601 |
msgid "The event is to be displayed in a tooltip (not a list)"
|
602 |
msgstr ""
|
603 |
|
604 |
-
#: admin/add.php:
|
605 |
msgid "The event is to be displayed in a list (not a tooltip)"
|
606 |
msgstr ""
|
607 |
|
608 |
-
#: admin/add.php:
|
609 |
msgid ""
|
610 |
"The event is taking place now (after the start time, but before the end time)"
|
611 |
msgstr ""
|
612 |
|
613 |
-
#: admin/add.php:
|
614 |
msgid "The event is not taking place now (may have ended or not yet started)"
|
615 |
msgstr ""
|
616 |
|
617 |
-
#: admin/add.php:
|
618 |
msgid "The event has started (even if it has also ended)"
|
619 |
msgstr ""
|
620 |
|
621 |
-
#: admin/add.php:
|
622 |
msgid "The event has not started"
|
623 |
msgstr ""
|
624 |
|
625 |
-
#: admin/add.php:
|
626 |
msgid "The event has ended"
|
627 |
msgstr ""
|
628 |
|
629 |
-
#: admin/add.php:
|
630 |
msgid "The event has not ended (even if it hasn't started)"
|
631 |
msgstr ""
|
632 |
|
633 |
-
#: admin/add.php:
|
634 |
msgid "The event is the first of the day"
|
635 |
msgstr ""
|
636 |
|
637 |
-
#: admin/add.php:
|
638 |
msgid "The event is not the first of the day"
|
639 |
msgstr ""
|
640 |
|
641 |
-
#: admin/add.php:
|
642 |
msgid "The event spans multiple days"
|
643 |
msgstr ""
|
644 |
|
645 |
-
#: admin/add.php:
|
646 |
msgid "The event does not span multiple days"
|
647 |
msgstr ""
|
648 |
|
649 |
-
#: admin/add.php:
|
650 |
msgid "Attributes:"
|
651 |
msgstr ""
|
652 |
|
653 |
-
#: admin/add.php:
|
654 |
msgid "The possible attributes mentioned above are explained here:"
|
655 |
msgstr ""
|
656 |
|
657 |
-
#: admin/add.php:
|
658 |
msgid ""
|
659 |
"Whether or not to parse HTML that has been entered in the relevant field. "
|
660 |
"Can be <code>true</code> or <code>false</code>"
|
661 |
msgstr ""
|
662 |
|
663 |
-
#: admin/add.php:
|
664 |
msgid ""
|
665 |
"Whether or not to parse <a href=\"http://daringfireball.net/projects/markdown"
|
666 |
"\" target=\"_blank\">Markdown</a> that has been entered in the relevant "
|
@@ -669,129 +752,141 @@ msgid ""
|
|
669 |
"code> or <code>false</code>"
|
670 |
msgstr ""
|
671 |
|
672 |
-
#: admin/add.php:
|
673 |
msgid "The word limit for the field. Should be specified as a positive integer"
|
674 |
msgstr ""
|
675 |
|
676 |
-
#: admin/add.php:
|
677 |
msgid ""
|
678 |
"The date / time format to use. Should specified as a <a href=\"http://php."
|
679 |
"net/manual/en/function.date.php\" target=\"_blank\">PHP date format</a> "
|
680 |
"string"
|
681 |
msgstr ""
|
682 |
|
683 |
-
#: admin/add.php:
|
684 |
msgid ""
|
685 |
"Whether or not the link should open in a new window / tab. Can be "
|
686 |
"<code>true</code> or <code>false</code>"
|
687 |
msgstr ""
|
688 |
|
689 |
-
#: admin/add.php:
|
690 |
msgid ""
|
691 |
"How precise to be when displaying a time difference in human-readable "
|
692 |
"format. Should be specified as a positive integer"
|
693 |
msgstr ""
|
694 |
|
695 |
-
#: admin/add.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
696 |
msgid ""
|
697 |
"You can use some HTML in the text fields, but ensure it is valid or things "
|
698 |
"might go wonky. Text fields can be empty too."
|
699 |
msgstr ""
|
700 |
|
701 |
-
#: admin/add.php:
|
702 |
msgid "Select how to display the start date / time."
|
703 |
msgstr ""
|
704 |
|
705 |
-
#: admin/add.php:
|
706 |
msgid "Don't display start time or date"
|
707 |
msgstr ""
|
708 |
|
709 |
-
#: admin/add.php:
|
710 |
msgid "Display start time"
|
711 |
msgstr ""
|
712 |
|
713 |
-
#: admin/add.php:
|
714 |
msgid "Display start date"
|
715 |
msgstr ""
|
716 |
|
717 |
-
#: admin/add.php:
|
718 |
msgid "Display start time and date (in that order)"
|
719 |
msgstr ""
|
720 |
|
721 |
-
#: admin/add.php:
|
722 |
msgid "Display start date and time (in that order)"
|
723 |
msgstr ""
|
724 |
|
725 |
-
#: admin/add.php:
|
726 |
msgid "Text to display before the start time."
|
727 |
msgstr ""
|
728 |
|
729 |
-
#: admin/add.php:
|
730 |
msgid "Select how to display the end date / time."
|
731 |
msgstr ""
|
732 |
|
733 |
-
#: admin/add.php:
|
734 |
msgid "Don't display end time or date"
|
735 |
msgstr ""
|
736 |
|
737 |
-
#: admin/add.php:
|
738 |
msgid "Display end time"
|
739 |
msgstr ""
|
740 |
|
741 |
-
#: admin/add.php:
|
742 |
msgid "Display end date"
|
743 |
msgstr ""
|
744 |
|
745 |
-
#: admin/add.php:
|
746 |
msgid "Display end time and date (in that order)"
|
747 |
msgstr ""
|
748 |
|
749 |
-
#: admin/add.php:
|
750 |
msgid "Display end date and time (in that order)"
|
751 |
msgstr ""
|
752 |
|
753 |
-
#: admin/add.php:
|
754 |
msgid "Text to display before the end time."
|
755 |
msgstr ""
|
756 |
|
757 |
-
#: admin/add.php:
|
758 |
msgid ""
|
759 |
"If you have chosen to display both the time and date above, enter the text / "
|
760 |
"characters to display between the time and date here (including any spaces)."
|
761 |
msgstr ""
|
762 |
|
763 |
-
#: admin/add.php:
|
764 |
msgid "Show the location of events?"
|
765 |
msgstr ""
|
766 |
|
767 |
-
#: admin/add.php:
|
768 |
msgid "Text to display before the location."
|
769 |
msgstr ""
|
770 |
|
771 |
-
#: admin/add.php:
|
772 |
msgid ""
|
773 |
"Show the description of events? (URLs in the description will be made into "
|
774 |
"links)."
|
775 |
msgstr ""
|
776 |
|
777 |
-
#: admin/add.php:
|
778 |
msgid "Text to display before the description."
|
779 |
msgstr ""
|
780 |
|
781 |
-
#: admin/add.php:
|
782 |
msgid ""
|
783 |
"Maximum number of words to show from description. Leave blank for no limit."
|
784 |
msgstr ""
|
785 |
|
786 |
-
#: admin/add.php:
|
787 |
msgid "Show a link to the Google Calendar page for an event?"
|
788 |
msgstr ""
|
789 |
|
790 |
-
#: admin/add.php:
|
791 |
msgid "Links open in a new window / tab?"
|
792 |
msgstr ""
|
793 |
|
794 |
-
#: admin/add.php:
|
795 |
msgid "The link text to be displayed."
|
796 |
msgstr ""
|
797 |
|
@@ -801,20 +896,6 @@ msgid ""
|
|
801 |
"widgets or shortcodes associated with this feed)."
|
802 |
msgstr ""
|
803 |
|
804 |
-
#: admin/refresh.php:9
|
805 |
-
msgid "Refresh Feed Cache"
|
806 |
-
msgstr ""
|
807 |
-
|
808 |
-
#: admin/refresh.php:17
|
809 |
-
msgid ""
|
810 |
-
"The plugin will automatically refresh the cache when it expires, but you can "
|
811 |
-
"manually clear the cache now by clicking the button below."
|
812 |
-
msgstr ""
|
813 |
-
|
814 |
-
#: admin/refresh.php:18
|
815 |
-
msgid "Are you want you want to clear the cache data for this feed?"
|
816 |
-
msgstr ""
|
817 |
-
|
818 |
#: admin/edit.php:9
|
819 |
msgid "Edit Feed"
|
820 |
msgstr ""
|
@@ -831,110 +912,126 @@ msgid ""
|
|
831 |
"feeds/your-email@gmail.com/public/full</code>."
|
832 |
msgstr ""
|
833 |
|
834 |
-
#: admin/edit.php:
|
835 |
msgid ""
|
836 |
-
"
|
837 |
-
"
|
838 |
msgstr ""
|
839 |
|
840 |
-
#: admin/
|
841 |
-
msgid "
|
|
|
|
|
|
|
|
|
|
|
|
|
842 |
msgstr ""
|
843 |
|
844 |
-
#: admin/
|
845 |
-
msgid "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
846 |
msgstr ""
|
847 |
|
848 |
-
#: admin/
|
849 |
-
msgid "
|
|
|
|
|
|
|
|
|
850 |
msgstr ""
|
851 |
|
852 |
-
#: admin/
|
853 |
-
msgid "
|
|
|
|
|
854 |
msgstr ""
|
855 |
|
856 |
-
#: admin/
|
857 |
-
msgid "
|
858 |
msgstr ""
|
859 |
|
860 |
-
#: admin/
|
861 |
-
msgid "
|
|
|
|
|
862 |
msgstr ""
|
863 |
|
864 |
-
#: admin/
|
865 |
-
msgid "
|
866 |
msgstr ""
|
867 |
|
868 |
-
#:
|
869 |
-
msgid "
|
|
|
|
|
870 |
msgstr ""
|
871 |
|
872 |
-
#:
|
873 |
-
msgid "
|
|
|
|
|
|
|
874 |
msgstr ""
|
875 |
|
876 |
-
#:
|
877 |
-
msgid "
|
|
|
|
|
878 |
msgstr ""
|
879 |
|
880 |
-
#:
|
881 |
-
msgid "
|
|
|
|
|
882 |
msgstr ""
|
883 |
|
884 |
-
#:
|
885 |
-
msgid "
|
886 |
msgstr ""
|
887 |
|
888 |
-
#:
|
889 |
-
msgid ""
|
890 |
-
"If you want to alter the default plugin styling, create a new stylesheet on "
|
891 |
-
"your server (not in the <code>google-calendar-events</code> directory) and "
|
892 |
-
"then enter its URL below."
|
893 |
msgstr ""
|
894 |
|
895 |
-
#:
|
896 |
-
msgid "
|
897 |
msgstr ""
|
898 |
|
899 |
-
#:
|
900 |
-
msgid ""
|
901 |
-
"If you are having issues with tooltips not appearing or the AJAX "
|
902 |
-
"functionality not working, try ticking the checkbox below."
|
903 |
msgstr ""
|
904 |
|
905 |
-
#:
|
906 |
-
msgid "
|
907 |
msgstr ""
|
908 |
|
909 |
-
#:
|
910 |
-
msgid "
|
911 |
msgstr ""
|
912 |
|
913 |
-
#:
|
914 |
-
msgid "
|
915 |
msgstr ""
|
916 |
|
917 |
-
#:
|
918 |
-
msgid ""
|
919 |
-
"An error message to display to non-admin users if events cannot be displayed "
|
920 |
-
"for any reason (admins will see a message indicating the cause of the "
|
921 |
-
"problem)."
|
922 |
msgstr ""
|
923 |
|
924 |
-
#:
|
925 |
-
msgid "
|
926 |
msgstr ""
|
927 |
|
928 |
-
#:
|
929 |
msgid ""
|
930 |
-
"
|
931 |
-
"
|
932 |
-
"with large numbers of events. Google could potentially remove / change this "
|
933 |
-
"feature at any time."
|
934 |
-
msgstr ""
|
935 |
-
|
936 |
-
#: admin/main.php:104
|
937 |
-
msgid "Save"
|
938 |
msgstr ""
|
939 |
|
940 |
#. Plugin URI of the plugin/theme
|
2 |
# This file is distributed under the same license as the Google Calendar Events package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Google Calendar Events 0.7\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/google-calendar-events\n"
|
7 |
+
"POT-Creation-Date: 2011-06-25 18:33:59+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
|
15 |
+
#: inc/gce-feed.php:94
|
16 |
msgid ""
|
17 |
"Some data was retrieved, but could not be parsed successfully. Please ensure "
|
18 |
"your feed URL is correct."
|
19 |
msgstr ""
|
20 |
|
21 |
+
#: inc/gce-feed.php:100
|
22 |
msgid ""
|
23 |
"The feed could not be found (404). Please ensure your feed URL is correct."
|
24 |
msgstr ""
|
25 |
|
26 |
+
#: inc/gce-feed.php:103
|
27 |
msgid ""
|
28 |
"Access to this feed was denied (403). Please ensure you have public sharing "
|
29 |
"enabled for your calendar."
|
30 |
msgstr ""
|
31 |
|
32 |
+
#: inc/gce-feed.php:106
|
33 |
msgid ""
|
34 |
"The feed data could not be retrieved. Error code: %s. Please ensure your "
|
35 |
"feed URL is correct."
|
36 |
msgstr ""
|
37 |
|
38 |
+
#: inc/gce-event.php:493
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
msgid "%s year"
|
40 |
msgstr ""
|
41 |
|
42 |
+
#: inc/gce-event.php:493
|
43 |
msgid "%s years"
|
44 |
msgstr ""
|
45 |
|
46 |
+
#: inc/gce-event.php:494
|
47 |
msgid "%s month"
|
48 |
msgstr ""
|
49 |
|
50 |
+
#: inc/gce-event.php:494
|
51 |
msgid "%s months"
|
52 |
msgstr ""
|
53 |
|
54 |
+
#: inc/gce-event.php:495
|
55 |
msgid "%s week"
|
56 |
msgstr ""
|
57 |
|
58 |
+
#: inc/gce-event.php:495
|
59 |
msgid "%s weeks"
|
60 |
msgstr ""
|
61 |
|
62 |
+
#: inc/gce-event.php:496
|
63 |
msgid "%s day"
|
64 |
msgstr ""
|
65 |
|
66 |
+
#: inc/gce-event.php:496
|
67 |
msgid "%s days"
|
68 |
msgstr ""
|
69 |
|
70 |
+
#: inc/gce-event.php:497
|
71 |
msgid "%s hour"
|
72 |
msgstr ""
|
73 |
|
74 |
+
#: inc/gce-event.php:497
|
75 |
msgid "%s hours"
|
76 |
msgstr ""
|
77 |
|
78 |
+
#: inc/gce-event.php:498
|
79 |
msgid "%s min"
|
80 |
msgstr ""
|
81 |
|
82 |
+
#: inc/gce-event.php:498
|
83 |
msgid "%s mins"
|
84 |
msgstr ""
|
85 |
|
86 |
+
#: inc/gce-event.php:526
|
87 |
msgctxt "human_time_diff"
|
88 |
msgid ", "
|
89 |
msgstr ""
|
90 |
|
91 |
+
#: inc/gce-parser.php:158
|
92 |
+
msgid ""
|
93 |
+
"1 or more of your feeds could not be displayed. The following errors "
|
94 |
+
"occurred:"
|
95 |
+
msgstr ""
|
96 |
+
|
97 |
+
#: inc/gce-parser.php:161
|
98 |
+
msgid "Feed %s:"
|
99 |
+
msgstr ""
|
100 |
+
|
101 |
+
#: inc/gce-parser.php:317
|
102 |
+
msgid "There are currently no events to display."
|
103 |
+
msgstr ""
|
104 |
+
|
105 |
+
#: google-calendar-events.php:204
|
106 |
+
msgid "Settings"
|
107 |
+
msgstr ""
|
108 |
+
|
109 |
+
#. #-#-#-#-# plugin.pot (Google Calendar Events 0.7) #-#-#-#-#
|
110 |
#. Plugin Name of the plugin/theme
|
111 |
+
#: google-calendar-events.php:220 widget/gce-widget.php:6
|
112 |
msgid "Google Calendar Events"
|
113 |
msgstr ""
|
114 |
|
115 |
+
#: google-calendar-events.php:224
|
116 |
+
msgid "Notice:"
|
117 |
+
msgstr ""
|
118 |
+
|
119 |
+
#: google-calendar-events.php:224
|
120 |
msgid ""
|
121 |
+
"The way in which Google Calendar Events stores cached data has been much "
|
122 |
+
"improved in version 0.6. As you have upgraded from a previous version of the "
|
123 |
+
"plugin, there is likely to be some data from the old caching system hanging "
|
124 |
+
"around in your database that is now useless. Click below to clear expired "
|
125 |
+
"cached data from your database."
|
126 |
+
msgstr ""
|
127 |
+
|
128 |
+
#: google-calendar-events.php:225
|
129 |
+
msgid "Clear expired cached data"
|
130 |
+
msgstr ""
|
131 |
+
|
132 |
+
#: google-calendar-events.php:226
|
133 |
+
msgid "or"
|
134 |
msgstr ""
|
135 |
|
136 |
+
#: google-calendar-events.php:227
|
137 |
+
msgid "Ignore this notice"
|
138 |
+
msgstr ""
|
139 |
+
|
140 |
+
#: google-calendar-events.php:242 admin/main.php:4
|
141 |
+
msgid "Add Feed"
|
142 |
+
msgstr ""
|
143 |
+
|
144 |
+
#: google-calendar-events.php:243 google-calendar-events.php:249
|
145 |
+
#: google-calendar-events.php:259 google-calendar-events.php:266
|
146 |
+
msgid "Cancel"
|
147 |
+
msgstr ""
|
148 |
+
|
149 |
+
#: google-calendar-events.php:248
|
150 |
+
msgid "Refresh Feed"
|
151 |
+
msgstr ""
|
152 |
+
|
153 |
+
#: google-calendar-events.php:258
|
154 |
+
msgid "Save Changes"
|
155 |
+
msgstr ""
|
156 |
+
|
157 |
+
#: google-calendar-events.php:265 admin/delete.php:9
|
158 |
+
msgid "Delete Feed"
|
159 |
+
msgstr ""
|
160 |
+
|
161 |
+
#: google-calendar-events.php:299
|
162 |
+
msgid "Old cached data cleared."
|
163 |
+
msgstr ""
|
164 |
+
|
165 |
+
#: google-calendar-events.php:476
|
166 |
+
msgid "General options updated."
|
167 |
+
msgstr ""
|
168 |
+
|
169 |
+
#: google-calendar-events.php:535
|
170 |
msgid ""
|
171 |
+
"No valid Feed IDs have been entered for this shortcode. Please check that "
|
172 |
+
"you have entered the IDs correctly and that the Feeds have not been deleted."
|
|
|
173 |
msgstr ""
|
174 |
|
175 |
+
#: google-calendar-events.php:555 widget/gce-widget.php:100
|
176 |
msgid ""
|
177 |
"No feeds have been added yet. You can add a feed in the Google Calendar "
|
178 |
"Events settings."
|
179 |
msgstr ""
|
180 |
|
181 |
+
#: admin/main.php:2
|
182 |
+
msgid "Add a New Feed"
|
|
|
|
|
183 |
msgstr ""
|
184 |
|
185 |
+
#: admin/main.php:4
|
186 |
+
msgid "Click here to add a new feed"
|
187 |
msgstr ""
|
188 |
|
189 |
+
#: admin/main.php:7
|
190 |
+
msgid "Current Feeds"
|
191 |
msgstr ""
|
192 |
|
193 |
+
#: admin/main.php:16
|
194 |
+
msgid "You haven't added any Google Calendar feeds yet."
|
195 |
msgstr ""
|
196 |
|
197 |
+
#: admin/main.php:24 admin/main.php:32
|
198 |
+
msgid "ID"
|
199 |
msgstr ""
|
200 |
|
201 |
+
#: admin/main.php:25 admin/main.php:33
|
202 |
+
msgid "Title"
|
203 |
msgstr ""
|
204 |
|
205 |
+
#: admin/main.php:26 admin/main.php:34
|
206 |
+
msgid "URL"
|
207 |
msgstr ""
|
208 |
|
209 |
+
#: admin/main.php:47
|
210 |
+
msgid "Refresh"
|
211 |
msgstr ""
|
212 |
|
213 |
+
#: admin/main.php:47
|
214 |
+
msgid "Edit"
|
215 |
msgstr ""
|
216 |
|
217 |
+
#: admin/main.php:47
|
218 |
+
msgid "Delete"
|
|
|
|
|
|
|
|
|
|
|
219 |
msgstr ""
|
220 |
|
221 |
+
#: admin/main.php:61
|
222 |
+
msgid "General Options"
|
223 |
msgstr ""
|
224 |
|
225 |
+
#: admin/main.php:65
|
226 |
+
msgid "Custom stylesheet URL"
|
227 |
msgstr ""
|
228 |
|
229 |
+
#: admin/main.php:67
|
230 |
+
msgid ""
|
231 |
+
"If you want to alter the default plugin styling, create a new stylesheet on "
|
232 |
+
"your server (not in the <code>google-calendar-events</code> directory) and "
|
233 |
+
"then enter its URL below."
|
234 |
msgstr ""
|
235 |
|
236 |
+
#: admin/main.php:72
|
237 |
+
msgid "Add JavaScript to footer?"
|
238 |
msgstr ""
|
239 |
|
240 |
+
#: admin/main.php:74
|
241 |
+
msgid ""
|
242 |
+
"If you are having issues with tooltips not appearing or the AJAX "
|
243 |
+
"functionality not working, try ticking the checkbox below."
|
244 |
msgstr ""
|
245 |
|
246 |
+
#: admin/main.php:79
|
247 |
+
msgid "Loading text"
|
248 |
msgstr ""
|
249 |
|
250 |
+
#: admin/main.php:81
|
251 |
+
msgid "Text to display while calendar data is loading (on AJAX requests)."
|
252 |
msgstr ""
|
253 |
|
254 |
+
#: admin/main.php:86
|
255 |
+
msgid "Error message"
|
256 |
msgstr ""
|
257 |
|
258 |
+
#: admin/main.php:88
|
259 |
+
msgid ""
|
260 |
+
"An error message to display to non-admin users if events cannot be displayed "
|
261 |
+
"for any reason (admins will see a message indicating the cause of the "
|
262 |
+
"problem)."
|
263 |
msgstr ""
|
264 |
|
265 |
+
#: admin/main.php:93
|
266 |
+
msgid "Optimise event retrieval?"
|
267 |
msgstr ""
|
268 |
|
269 |
+
#: admin/main.php:95
|
270 |
msgid ""
|
271 |
+
"If this option is enabled, the plugin will use an experimental feature of "
|
272 |
+
"the Google Data API, which can improve performance significantly, especially "
|
273 |
+
"with large numbers of events. Google could potentially remove / change this "
|
274 |
+
"feature at any time."
|
275 |
+
msgstr ""
|
276 |
+
|
277 |
+
#: admin/main.php:100
|
278 |
+
msgid "Use old styles?"
|
279 |
+
msgstr ""
|
280 |
+
|
281 |
+
#: admin/main.php:102
|
282 |
+
msgid ""
|
283 |
+
"Some CSS changes were made in version 0.7. If this option is enabled, the "
|
284 |
+
"old CSS will still be added along with the main stylesheet. You should "
|
285 |
+
"consider updating your stylesheet so that you don't need this enabled."
|
286 |
msgstr ""
|
287 |
|
288 |
+
#: admin/main.php:111
|
289 |
+
msgid "Save"
|
290 |
+
msgstr ""
|
291 |
+
|
292 |
+
#: admin/add.php:8
|
293 |
msgid "Add a Feed"
|
294 |
msgstr ""
|
295 |
|
296 |
+
#: admin/add.php:10 admin/delete.php:11 admin/edit.php:11 admin/refresh.php:11
|
297 |
msgid "Feed ID"
|
298 |
msgstr ""
|
299 |
|
300 |
+
#: admin/add.php:11 admin/delete.php:12 admin/edit.php:12 admin/refresh.php:12
|
301 |
msgid "Feed Title"
|
302 |
msgstr ""
|
303 |
|
304 |
+
#: admin/add.php:12 admin/edit.php:13
|
305 |
msgid "Feed URL"
|
306 |
msgstr ""
|
307 |
|
308 |
+
#: admin/add.php:13 admin/edit.php:14
|
309 |
msgid "Retrieve events from"
|
310 |
msgstr ""
|
311 |
|
312 |
+
#: admin/add.php:14 admin/edit.php:15
|
313 |
msgid "Retrieve events until"
|
314 |
msgstr ""
|
315 |
|
316 |
+
#: admin/add.php:15 admin/edit.php:16
|
317 |
msgid "Maximum number of events to retrieve"
|
318 |
msgstr ""
|
319 |
|
320 |
+
#: admin/add.php:16 admin/edit.php:17
|
321 |
msgid "Date format"
|
322 |
msgstr ""
|
323 |
|
324 |
+
#: admin/add.php:17 admin/edit.php:18
|
325 |
msgid "Time format"
|
326 |
msgstr ""
|
327 |
|
328 |
+
#: admin/add.php:18 admin/edit.php:19
|
329 |
msgid "Timezone adjustment"
|
330 |
msgstr ""
|
331 |
|
332 |
+
#: admin/add.php:19 admin/edit.php:20
|
333 |
msgid "Cache duration"
|
334 |
msgstr ""
|
335 |
|
336 |
+
#: admin/add.php:20 admin/edit.php:21
|
337 |
msgid "Show multiple day events on each day?"
|
338 |
msgstr ""
|
339 |
|
340 |
+
#: admin/add.php:22 admin/edit.php:23
|
341 |
msgid "Display Options"
|
342 |
msgstr ""
|
343 |
|
344 |
+
#: admin/add.php:23 admin/edit.php:24
|
345 |
msgid "Select display customization method"
|
346 |
msgstr ""
|
347 |
|
348 |
+
#: admin/add.php:25 admin/edit.php:26
|
349 |
msgid "Event Display Builder"
|
350 |
msgstr ""
|
351 |
|
352 |
+
#: admin/add.php:26 admin/edit.php:27
|
353 |
msgid "Event display builder HTML and shortcodes"
|
354 |
msgstr ""
|
355 |
|
356 |
+
#: admin/add.php:28 admin/edit.php:29
|
357 |
msgid "Simple Display Options"
|
358 |
msgstr ""
|
359 |
|
360 |
+
#: admin/add.php:29 admin/edit.php:30
|
361 |
msgid "Display start time / date?"
|
362 |
msgstr ""
|
363 |
|
364 |
+
#: admin/add.php:30 admin/edit.php:31
|
365 |
msgid "Display end time / date?"
|
366 |
msgstr ""
|
367 |
|
368 |
+
#: admin/add.php:31 admin/edit.php:32
|
369 |
msgid "Separator text / characters"
|
370 |
msgstr ""
|
371 |
|
372 |
+
#: admin/add.php:32 admin/edit.php:33
|
373 |
msgid "Display location?"
|
374 |
msgstr ""
|
375 |
|
376 |
+
#: admin/add.php:33 admin/edit.php:34
|
377 |
msgid "Display description?"
|
378 |
msgstr ""
|
379 |
|
380 |
+
#: admin/add.php:34 admin/edit.php:35
|
381 |
msgid "Display link to event?"
|
382 |
msgstr ""
|
383 |
|
384 |
+
#: admin/add.php:39
|
385 |
msgid "Enter the feed details below, then click the Add Feed button."
|
386 |
msgstr ""
|
387 |
|
388 |
+
#: admin/add.php:63 admin/edit.php:59
|
389 |
msgid "Anything you like. 'Upcoming Club Events', for example."
|
390 |
msgstr ""
|
391 |
|
392 |
+
#: admin/add.php:72
|
393 |
+
msgid "This will probably be something like:"
|
|
|
|
|
394 |
msgstr ""
|
395 |
|
396 |
+
#: admin/add.php:74
|
397 |
+
msgid "or:"
|
|
|
|
|
398 |
msgstr ""
|
399 |
|
400 |
+
#: admin/add.php:84
|
401 |
msgid ""
|
402 |
"The point in time at which to start retrieving events. Use the text-box to "
|
403 |
"specify an additional offset from you chosen start point. The offset should "
|
404 |
"be provided in seconds (3600 = 1 hour, 86400 = 1 day) and can be negative. "
|
405 |
+
"If you have selected the 'Specific date / time' option, enter a"
|
406 |
+
msgstr ""
|
407 |
+
|
408 |
+
#: admin/add.php:85
|
409 |
+
msgid "UNIX timestamp"
|
410 |
+
msgstr ""
|
411 |
+
|
412 |
+
#: admin/add.php:86
|
413 |
+
msgid "in the text-box."
|
414 |
msgstr ""
|
415 |
|
416 |
+
#: admin/add.php:90 admin/add.php:108
|
417 |
msgid "Now"
|
418 |
msgstr ""
|
419 |
|
420 |
+
#: admin/add.php:91 admin/add.php:109
|
421 |
msgid "00:00 today"
|
422 |
msgstr ""
|
423 |
|
424 |
+
#: admin/add.php:92 admin/add.php:110
|
425 |
msgid "Start of current week"
|
426 |
msgstr ""
|
427 |
|
428 |
+
#: admin/add.php:93 admin/add.php:111
|
429 |
msgid "Start of current month"
|
430 |
msgstr ""
|
431 |
|
432 |
+
#: admin/add.php:94 admin/add.php:112
|
433 |
msgid "End of current month"
|
434 |
msgstr ""
|
435 |
|
436 |
+
#: admin/add.php:95
|
437 |
msgid "The beginning of time"
|
438 |
msgstr ""
|
439 |
|
440 |
+
#: admin/add.php:96 admin/add.php:114
|
441 |
msgid "Specific date / time"
|
442 |
msgstr ""
|
443 |
|
444 |
+
#: admin/add.php:105 admin/edit.php:103
|
445 |
msgid ""
|
446 |
"The point in time at which to stop retrieving events. The instructions for "
|
447 |
"the above option also apply here."
|
448 |
msgstr ""
|
449 |
|
450 |
+
#: admin/add.php:113
|
451 |
msgid "The end of time"
|
452 |
msgstr ""
|
453 |
|
454 |
+
#: admin/add.php:124 admin/edit.php:124
|
455 |
msgid ""
|
456 |
"Set this to a few more than you actually want to display (due to caching and "
|
457 |
"timezone issues). The exact number to display can be configured per "
|
458 |
"shortcode / widget."
|
459 |
msgstr ""
|
460 |
|
461 |
+
#: admin/add.php:133 admin/edit.php:135
|
462 |
msgid ""
|
463 |
"In <a href=\"http://php.net/manual/en/function.date.php\" target=\"_blank"
|
464 |
"\">PHP date format</a>. Leave this blank if you'd rather stick with the "
|
465 |
"default format for your blog."
|
466 |
msgstr ""
|
467 |
|
468 |
+
#: admin/add.php:142 admin/edit.php:146
|
469 |
msgid ""
|
470 |
"In <a href=\"http://php.net/manual/en/function.date.php\" target=\"_blank"
|
471 |
"\">PHP date format</a>. Again, leave this blank to stick with the default."
|
472 |
msgstr ""
|
473 |
|
474 |
+
#: admin/add.php:155 admin/edit.php:161
|
475 |
msgid ""
|
476 |
"If you are having problems with dates and times displaying in the wrong "
|
477 |
"timezone, select a city in your required timezone here."
|
478 |
msgstr ""
|
479 |
|
480 |
+
#: admin/add.php:164 admin/edit.php:172
|
481 |
msgid ""
|
482 |
"The length of time, in seconds, to cache the feed (43200 = 12 hours). If "
|
483 |
"this feed changes regularly, you may want to reduce the cache duration."
|
484 |
msgstr ""
|
485 |
|
486 |
+
#: admin/add.php:173 admin/edit.php:183
|
487 |
msgid ""
|
488 |
+
"Show events that span multiple days on each day that they span, rather than "
|
489 |
+
"just the first day."
|
|
|
|
|
490 |
msgstr ""
|
491 |
|
492 |
+
#: admin/add.php:184 admin/edit.php:194
|
493 |
msgid ""
|
494 |
"These settings control what information will be displayed for this feed in "
|
495 |
"the tooltip (for grids), or in a list."
|
496 |
msgstr ""
|
497 |
|
498 |
+
#: admin/add.php:190 admin/edit.php:202
|
499 |
msgid ""
|
500 |
"It is recommended that you use the event display builder option, as it "
|
501 |
"provides much more flexibility than the simple display options. The event "
|
503 |
"more!"
|
504 |
msgstr ""
|
505 |
|
506 |
+
#: admin/add.php:193 admin/edit.php:205
|
507 |
msgid "Event display builder"
|
508 |
msgstr ""
|
509 |
|
510 |
+
#: admin/add.php:194 admin/edit.php:206
|
511 |
msgid "Simple display options"
|
512 |
msgstr ""
|
513 |
|
514 |
+
#: admin/add.php:203
|
515 |
msgid ""
|
516 |
"Use the event display builder to customize how event information will be "
|
517 |
"displayed in the grid tooltips and in lists. Use HTML and the shortcodes "
|
518 |
"(explained below) to display the information you require. A basic example "
|
519 |
"display format is provided as a starting point. For more information, take a "
|
520 |
+
"look at the"
|
|
|
|
|
521 |
msgstr ""
|
522 |
|
523 |
+
#: admin/add.php:204 admin/add.php:222
|
524 |
+
msgid "event display builder guide"
|
525 |
+
msgstr ""
|
526 |
+
|
527 |
+
#: admin/add.php:221
|
528 |
msgid ""
|
529 |
"(More information on all of the below shortcodes and attributes, and working "
|
530 |
+
"examples, can be found in the"
|
|
|
|
|
531 |
msgstr ""
|
532 |
|
533 |
+
#: admin/add.php:224 admin/edit.php:225
|
534 |
msgid "Event information shortcodes:"
|
535 |
msgstr ""
|
536 |
|
537 |
+
#: admin/add.php:226 admin/edit.php:227
|
538 |
msgid ""
|
539 |
"The event title (possible attributes: <code>html</code>, <code>markdown</"
|
540 |
"code>)"
|
541 |
msgstr ""
|
542 |
|
543 |
+
#: admin/add.php:227 admin/edit.php:228
|
544 |
msgid ""
|
545 |
"The event start time. Will use the time format specified in the above "
|
546 |
"settings"
|
547 |
msgstr ""
|
548 |
|
549 |
+
#: admin/add.php:228 admin/edit.php:229
|
550 |
msgid ""
|
551 |
"The event start date. Will use the date format specified in the above "
|
552 |
"settings"
|
553 |
msgstr ""
|
554 |
|
555 |
+
#: admin/add.php:229 admin/edit.php:230
|
556 |
msgid ""
|
557 |
"The event start date / time. Will use the format specified in the "
|
558 |
"<code>format</code> attribute (possible attributes: <code>format</code>)"
|
559 |
msgstr ""
|
560 |
|
561 |
+
#: admin/add.php:230 admin/edit.php:231
|
562 |
msgid ""
|
563 |
"The difference between the start time of the event and the time now, in "
|
564 |
"human-readable format, such as '1 hour', '4 days', '15 mins' (possible "
|
565 |
"attributes: <code>precision</code>)"
|
566 |
msgstr ""
|
567 |
|
568 |
+
#: admin/add.php:231 admin/edit.php:232
|
569 |
msgid ""
|
570 |
"The event end time. Will use the time format specified in the above settings"
|
571 |
msgstr ""
|
572 |
|
573 |
+
#: admin/add.php:232 admin/edit.php:233
|
574 |
msgid ""
|
575 |
"The event end date. Will use the date format specified in the above settings"
|
576 |
msgstr ""
|
577 |
|
578 |
+
#: admin/add.php:233 admin/edit.php:234
|
579 |
msgid ""
|
580 |
"The event end date / time. Will use the format specified in the "
|
581 |
"<code>format</code> attribute (possible attributes: <code>format</code>)"
|
582 |
msgstr ""
|
583 |
|
584 |
+
#: admin/add.php:234 admin/edit.php:235
|
585 |
msgid ""
|
586 |
"The difference between the end time of the event and the time now, in human-"
|
587 |
"readable format (possible attributes: <code>precision</code>)"
|
588 |
msgstr ""
|
589 |
|
590 |
+
#: admin/add.php:235 admin/edit.php:236
|
591 |
msgid ""
|
592 |
"The event location (possible attributes: <code>html</code>, <code>markdown</"
|
593 |
"code>)"
|
594 |
msgstr ""
|
595 |
|
596 |
+
#: admin/add.php:236 admin/edit.php:237
|
597 |
msgid ""
|
598 |
"Anything between the opening and closing shortcode tags (inlcuding further "
|
599 |
"shortcodes) will be linked to Google Maps, using the event location as a "
|
600 |
"search parameter (possible attributes: <code>newwindow</code>)"
|
601 |
msgstr ""
|
602 |
|
603 |
+
#: admin/add.php:237 admin/edit.php:238
|
604 |
msgid ""
|
605 |
"The event description (possible attributes: <code>html</code>, "
|
606 |
"<code>markdown</code>, <code>limit</code>)"
|
607 |
msgstr ""
|
608 |
|
609 |
+
#: admin/add.php:238 admin/edit.php:239
|
610 |
msgid ""
|
611 |
"Anything between the opening and closing shortcode tags (inlcuding further "
|
612 |
"shortcodes) will be linked to the Google Calendar page for the event "
|
613 |
"(possible attributes: <code>newwindow</code>)"
|
614 |
msgstr ""
|
615 |
|
616 |
+
#: admin/add.php:239 admin/edit.php:240
|
617 |
msgid "The raw URL to the Google Calendar page for the event"
|
618 |
msgstr ""
|
619 |
|
620 |
+
#: admin/add.php:240 admin/edit.php:241
|
621 |
msgid ""
|
622 |
"The length of the event, in human-readable format (possible attributes: "
|
623 |
"<code>precision</code>)"
|
624 |
msgstr ""
|
625 |
|
626 |
+
#: admin/add.php:241 admin/edit.php:242
|
627 |
+
msgid ""
|
628 |
+
"The position of the event in the current list, or the position of the event "
|
629 |
+
"in the current month (for grids)"
|
630 |
+
msgstr ""
|
631 |
+
|
632 |
+
#: admin/add.php:242 admin/edit.php:243
|
633 |
+
msgid "The event UID (a unique identifier assigned to the event by Google)"
|
634 |
+
msgstr ""
|
635 |
+
|
636 |
+
#: admin/add.php:244 admin/edit.php:245
|
637 |
msgid "Feed information shortcodes:"
|
638 |
msgstr ""
|
639 |
|
640 |
+
#: admin/add.php:246 admin/edit.php:247
|
641 |
msgid "The title of the feed from which the event comes"
|
642 |
msgstr ""
|
643 |
|
644 |
+
#: admin/add.php:247 admin/edit.php:248
|
645 |
msgid "The ID of the feed from which the event comes"
|
646 |
msgstr ""
|
647 |
|
648 |
+
#: admin/add.php:248 admin/edit.php:249
|
649 |
+
msgid ""
|
650 |
+
"The calendar ID (a unique identifier assigned to the calendar by Google)"
|
651 |
+
msgstr ""
|
652 |
+
|
653 |
+
#: admin/add.php:250 admin/edit.php:251
|
654 |
msgid "Conditional shortcodes:"
|
655 |
msgstr ""
|
656 |
|
657 |
+
#: admin/add.php:251 admin/edit.php:252
|
658 |
msgid ""
|
659 |
"Anything entered between the opening and closing tags of each of the "
|
660 |
"following shortcodes will only be displayed if its condition (below) is met."
|
661 |
msgstr ""
|
662 |
|
663 |
+
#: admin/add.php:253 admin/edit.php:254
|
664 |
msgid "The event is an all-day event"
|
665 |
msgstr ""
|
666 |
|
667 |
+
#: admin/add.php:254 admin/edit.php:255
|
668 |
msgid "The event is not an all-day event"
|
669 |
msgstr ""
|
670 |
|
671 |
+
#: admin/add.php:255 admin/edit.php:256
|
672 |
msgid "The event has a title"
|
673 |
msgstr ""
|
674 |
|
675 |
+
#: admin/add.php:256 admin/edit.php:257
|
676 |
msgid "The event has a description"
|
677 |
msgstr ""
|
678 |
|
679 |
+
#: admin/add.php:257 admin/edit.php:258
|
680 |
msgid "The event has a location"
|
681 |
msgstr ""
|
682 |
|
683 |
+
#: admin/add.php:258 admin/edit.php:259
|
684 |
msgid "The event is to be displayed in a tooltip (not a list)"
|
685 |
msgstr ""
|
686 |
|
687 |
+
#: admin/add.php:259 admin/edit.php:260
|
688 |
msgid "The event is to be displayed in a list (not a tooltip)"
|
689 |
msgstr ""
|
690 |
|
691 |
+
#: admin/add.php:260 admin/edit.php:261
|
692 |
msgid ""
|
693 |
"The event is taking place now (after the start time, but before the end time)"
|
694 |
msgstr ""
|
695 |
|
696 |
+
#: admin/add.php:261 admin/edit.php:262
|
697 |
msgid "The event is not taking place now (may have ended or not yet started)"
|
698 |
msgstr ""
|
699 |
|
700 |
+
#: admin/add.php:262 admin/edit.php:263
|
701 |
msgid "The event has started (even if it has also ended)"
|
702 |
msgstr ""
|
703 |
|
704 |
+
#: admin/add.php:263 admin/edit.php:264
|
705 |
msgid "The event has not started"
|
706 |
msgstr ""
|
707 |
|
708 |
+
#: admin/add.php:264 admin/edit.php:265
|
709 |
msgid "The event has ended"
|
710 |
msgstr ""
|
711 |
|
712 |
+
#: admin/add.php:265 admin/edit.php:266
|
713 |
msgid "The event has not ended (even if it hasn't started)"
|
714 |
msgstr ""
|
715 |
|
716 |
+
#: admin/add.php:266 admin/edit.php:267
|
717 |
msgid "The event is the first of the day"
|
718 |
msgstr ""
|
719 |
|
720 |
+
#: admin/add.php:267 admin/edit.php:268
|
721 |
msgid "The event is not the first of the day"
|
722 |
msgstr ""
|
723 |
|
724 |
+
#: admin/add.php:268 admin/edit.php:269
|
725 |
msgid "The event spans multiple days"
|
726 |
msgstr ""
|
727 |
|
728 |
+
#: admin/add.php:269 admin/edit.php:270
|
729 |
msgid "The event does not span multiple days"
|
730 |
msgstr ""
|
731 |
|
732 |
+
#: admin/add.php:271 admin/edit.php:272
|
733 |
msgid "Attributes:"
|
734 |
msgstr ""
|
735 |
|
736 |
+
#: admin/add.php:272 admin/edit.php:273
|
737 |
msgid "The possible attributes mentioned above are explained here:"
|
738 |
msgstr ""
|
739 |
|
740 |
+
#: admin/add.php:274 admin/edit.php:275
|
741 |
msgid ""
|
742 |
"Whether or not to parse HTML that has been entered in the relevant field. "
|
743 |
"Can be <code>true</code> or <code>false</code>"
|
744 |
msgstr ""
|
745 |
|
746 |
+
#: admin/add.php:275 admin/edit.php:276
|
747 |
msgid ""
|
748 |
"Whether or not to parse <a href=\"http://daringfireball.net/projects/markdown"
|
749 |
"\" target=\"_blank\">Markdown</a> that has been entered in the relevant "
|
752 |
"code> or <code>false</code>"
|
753 |
msgstr ""
|
754 |
|
755 |
+
#: admin/add.php:276 admin/edit.php:277
|
756 |
msgid "The word limit for the field. Should be specified as a positive integer"
|
757 |
msgstr ""
|
758 |
|
759 |
+
#: admin/add.php:277 admin/edit.php:278
|
760 |
msgid ""
|
761 |
"The date / time format to use. Should specified as a <a href=\"http://php."
|
762 |
"net/manual/en/function.date.php\" target=\"_blank\">PHP date format</a> "
|
763 |
"string"
|
764 |
msgstr ""
|
765 |
|
766 |
+
#: admin/add.php:278 admin/edit.php:279
|
767 |
msgid ""
|
768 |
"Whether or not the link should open in a new window / tab. Can be "
|
769 |
"<code>true</code> or <code>false</code>"
|
770 |
msgstr ""
|
771 |
|
772 |
+
#: admin/add.php:279 admin/edit.php:280
|
773 |
msgid ""
|
774 |
"How precise to be when displaying a time difference in human-readable "
|
775 |
"format. Should be specified as a positive integer"
|
776 |
msgstr ""
|
777 |
|
778 |
+
#: admin/add.php:280 admin/edit.php:281
|
779 |
+
msgid ""
|
780 |
+
"An offset (in seconds) to apply to start / end times before display. Should "
|
781 |
+
"be specified as a (positive or negative) integer"
|
782 |
+
msgstr ""
|
783 |
+
|
784 |
+
#: admin/add.php:281 admin/edit.php:282
|
785 |
+
msgid ""
|
786 |
+
"Whether or not to automatically convert URLs in the description to links. "
|
787 |
+
"Can be <code>true</code> or <code>false</code>"
|
788 |
+
msgstr ""
|
789 |
+
|
790 |
+
#: admin/add.php:289 admin/edit.php:290
|
791 |
msgid ""
|
792 |
"You can use some HTML in the text fields, but ensure it is valid or things "
|
793 |
"might go wonky. Text fields can be empty too."
|
794 |
msgstr ""
|
795 |
|
796 |
+
#: admin/add.php:295 admin/edit.php:298
|
797 |
msgid "Select how to display the start date / time."
|
798 |
msgstr ""
|
799 |
|
800 |
+
#: admin/add.php:298 admin/edit.php:301
|
801 |
msgid "Don't display start time or date"
|
802 |
msgstr ""
|
803 |
|
804 |
+
#: admin/add.php:299 admin/edit.php:302
|
805 |
msgid "Display start time"
|
806 |
msgstr ""
|
807 |
|
808 |
+
#: admin/add.php:300 admin/edit.php:303
|
809 |
msgid "Display start date"
|
810 |
msgstr ""
|
811 |
|
812 |
+
#: admin/add.php:301 admin/edit.php:304
|
813 |
msgid "Display start time and date (in that order)"
|
814 |
msgstr ""
|
815 |
|
816 |
+
#: admin/add.php:302 admin/edit.php:305
|
817 |
msgid "Display start date and time (in that order)"
|
818 |
msgstr ""
|
819 |
|
820 |
+
#: admin/add.php:305 admin/edit.php:308
|
821 |
msgid "Text to display before the start time."
|
822 |
msgstr ""
|
823 |
|
824 |
+
#: admin/add.php:313 admin/edit.php:318
|
825 |
msgid "Select how to display the end date / time."
|
826 |
msgstr ""
|
827 |
|
828 |
+
#: admin/add.php:316 admin/edit.php:321
|
829 |
msgid "Don't display end time or date"
|
830 |
msgstr ""
|
831 |
|
832 |
+
#: admin/add.php:317 admin/edit.php:322
|
833 |
msgid "Display end time"
|
834 |
msgstr ""
|
835 |
|
836 |
+
#: admin/add.php:318 admin/edit.php:323
|
837 |
msgid "Display end date"
|
838 |
msgstr ""
|
839 |
|
840 |
+
#: admin/add.php:319 admin/edit.php:324
|
841 |
msgid "Display end time and date (in that order)"
|
842 |
msgstr ""
|
843 |
|
844 |
+
#: admin/add.php:320 admin/edit.php:325
|
845 |
msgid "Display end date and time (in that order)"
|
846 |
msgstr ""
|
847 |
|
848 |
+
#: admin/add.php:323 admin/edit.php:328
|
849 |
msgid "Text to display before the end time."
|
850 |
msgstr ""
|
851 |
|
852 |
+
#: admin/add.php:331 admin/edit.php:338
|
853 |
msgid ""
|
854 |
"If you have chosen to display both the time and date above, enter the text / "
|
855 |
"characters to display between the time and date here (including any spaces)."
|
856 |
msgstr ""
|
857 |
|
858 |
+
#: admin/add.php:340 admin/edit.php:349
|
859 |
msgid "Show the location of events?"
|
860 |
msgstr ""
|
861 |
|
862 |
+
#: admin/add.php:342 admin/edit.php:351
|
863 |
msgid "Text to display before the location."
|
864 |
msgstr ""
|
865 |
|
866 |
+
#: admin/add.php:351
|
867 |
msgid ""
|
868 |
"Show the description of events? (URLs in the description will be made into "
|
869 |
"links)."
|
870 |
msgstr ""
|
871 |
|
872 |
+
#: admin/add.php:353 admin/edit.php:364
|
873 |
msgid "Text to display before the description."
|
874 |
msgstr ""
|
875 |
|
876 |
+
#: admin/add.php:357 admin/edit.php:368
|
877 |
msgid ""
|
878 |
"Maximum number of words to show from description. Leave blank for no limit."
|
879 |
msgstr ""
|
880 |
|
881 |
+
#: admin/add.php:366 admin/edit.php:379
|
882 |
msgid "Show a link to the Google Calendar page for an event?"
|
883 |
msgstr ""
|
884 |
|
885 |
+
#: admin/add.php:369 admin/edit.php:382
|
886 |
msgid "Links open in a new window / tab?"
|
887 |
msgstr ""
|
888 |
|
889 |
+
#: admin/add.php:371 admin/edit.php:384
|
890 |
msgid "The link text to be displayed."
|
891 |
msgstr ""
|
892 |
|
896 |
"widgets or shortcodes associated with this feed)."
|
897 |
msgstr ""
|
898 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
899 |
#: admin/edit.php:9
|
900 |
msgid "Edit Feed"
|
901 |
msgstr ""
|
912 |
"feeds/your-email@gmail.com/public/full</code>."
|
913 |
msgstr ""
|
914 |
|
915 |
+
#: admin/edit.php:72
|
916 |
msgid ""
|
917 |
+
"or: <code>http://www.google.com/calendar/feeds/your-email@gmail.com/private-"
|
918 |
+
"d65741b037h695ff274247f90746b2ty/basic</code>."
|
919 |
msgstr ""
|
920 |
|
921 |
+
#: admin/edit.php:83
|
922 |
+
msgid ""
|
923 |
+
"The point in time at which to start retrieving events. Use the text-box to "
|
924 |
+
"specify an additional offset from you chosen start point. The offset should "
|
925 |
+
"be provided in seconds (3600 = 1 hour, 86400 = 1 day) and can be negative. "
|
926 |
+
"If you have selected the 'Specific date / time' option, enter a <a href="
|
927 |
+
"\"http://www.timestampgenerator.com\" target=\"_blank\">UNIX timestamp</a> "
|
928 |
+
"in the text-box."
|
929 |
msgstr ""
|
930 |
|
931 |
+
#: admin/edit.php:214
|
932 |
+
msgid ""
|
933 |
+
"Use the event display builder to customize how event information will be "
|
934 |
+
"displayed in the grid tooltips and in lists. Use HTML and the shortcodes "
|
935 |
+
"(explained below) to display the information you require. A basic example "
|
936 |
+
"display format is provided as a starting point. For more information, take a "
|
937 |
+
"look at the <a href=\"http://www.rhanney.co.uk/plugins/google-calendar-"
|
938 |
+
"events/event-display-builder\" target=\"_blank\">event display builder "
|
939 |
+
"guide</a>."
|
940 |
msgstr ""
|
941 |
|
942 |
+
#: admin/edit.php:224
|
943 |
+
msgid ""
|
944 |
+
"(More information on all of the below shortcodes and attributes, and working "
|
945 |
+
"examples, can be found in the <a href=\"http://www.rhanney.co.uk/plugins/"
|
946 |
+
"google-calendar-events/event-display-builder\" target=\"_blank\">event "
|
947 |
+
"display builder guide</a>)"
|
948 |
msgstr ""
|
949 |
|
950 |
+
#: admin/edit.php:362
|
951 |
+
msgid ""
|
952 |
+
"Show the description of events? (URLs in the description will be made into "
|
953 |
+
"links)."
|
954 |
msgstr ""
|
955 |
|
956 |
+
#: admin/refresh.php:9
|
957 |
+
msgid "Refresh Feed Cache"
|
958 |
msgstr ""
|
959 |
|
960 |
+
#: admin/refresh.php:17
|
961 |
+
msgid ""
|
962 |
+
"The plugin will automatically refresh the cache when it expires, but you can "
|
963 |
+
"manually clear the cache now by clicking the button below."
|
964 |
msgstr ""
|
965 |
|
966 |
+
#: admin/refresh.php:18
|
967 |
+
msgid "Are you want you want to clear the cache data for this feed?"
|
968 |
msgstr ""
|
969 |
|
970 |
+
#: widget/gce-widget.php:7
|
971 |
+
msgid ""
|
972 |
+
"Display a list or calendar grid of events from one or more Google Calendar "
|
973 |
+
"feeds you have added"
|
974 |
msgstr ""
|
975 |
|
976 |
+
#: widget/gce-widget.php:57
|
977 |
+
msgid ""
|
978 |
+
"No valid Feed IDs have been entered for this widget. Please check that you "
|
979 |
+
"have entered the IDs correctly in the widget settings (Appearance > "
|
980 |
+
"Widgets), and that the Feeds have not been deleted."
|
981 |
msgstr ""
|
982 |
|
983 |
+
#: widget/gce-widget.php:129
|
984 |
+
msgid ""
|
985 |
+
"No feeds have been added yet. You can add feeds in the Google Calendar "
|
986 |
+
"Events settings."
|
987 |
msgstr ""
|
988 |
|
989 |
+
#: widget/gce-widget.php:145
|
990 |
+
msgid ""
|
991 |
+
"Feeds to display, as a comma separated list (e.g. 1, 2, 4). Leave blank to "
|
992 |
+
"display all feeds:"
|
993 |
msgstr ""
|
994 |
|
995 |
+
#: widget/gce-widget.php:149
|
996 |
+
msgid "Display events as:"
|
997 |
msgstr ""
|
998 |
|
999 |
+
#: widget/gce-widget.php:151
|
1000 |
+
msgid "Calendar Grid"
|
|
|
|
|
|
|
1001 |
msgstr ""
|
1002 |
|
1003 |
+
#: widget/gce-widget.php:152
|
1004 |
+
msgid "Calendar Grid - with AJAX"
|
1005 |
msgstr ""
|
1006 |
|
1007 |
+
#: widget/gce-widget.php:153
|
1008 |
+
msgid "List"
|
|
|
|
|
1009 |
msgstr ""
|
1010 |
|
1011 |
+
#: widget/gce-widget.php:154
|
1012 |
+
msgid "List - grouped by date"
|
1013 |
msgstr ""
|
1014 |
|
1015 |
+
#: widget/gce-widget.php:157
|
1016 |
+
msgid "Maximum no. events to display. Enter 0 to show all retrieved."
|
1017 |
msgstr ""
|
1018 |
|
1019 |
+
#: widget/gce-widget.php:160
|
1020 |
+
msgid "Sort order (only applies to lists):"
|
1021 |
msgstr ""
|
1022 |
|
1023 |
+
#: widget/gce-widget.php:162
|
1024 |
+
msgid "Ascending"
|
|
|
|
|
|
|
1025 |
msgstr ""
|
1026 |
|
1027 |
+
#: widget/gce-widget.php:163
|
1028 |
+
msgid "Descending"
|
1029 |
msgstr ""
|
1030 |
|
1031 |
+
#: widget/gce-widget.php:166
|
1032 |
msgid ""
|
1033 |
+
"Display title on tooltip / list item? (e.g. 'Events on 7th March') Grouped "
|
1034 |
+
"lists always have a title displayed."
|
|
|
|
|
|
|
|
|
|
|
|
|
1035 |
msgstr ""
|
1036 |
|
1037 |
#. Plugin URI of the plugin/theme
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: rosshanney
|
3 |
Donate link: http://www.rhanney.co.uk/plugins/google-calendar-events/#donate
|
4 |
Tags: google, google calendar, calendar, event, events, ajax, widget
|
5 |
-
Requires at least:
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 0.
|
8 |
|
9 |
Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
|
10 |
|
@@ -20,19 +20,13 @@ Parses Google Calendar feeds and displays the events as a calendar grid or list
|
|
20 |
* Lists and grids can be displayed in posts, pages or within a widget
|
21 |
* Options to change the number of events retrieved, date / time format, cache duration etc
|
22 |
* Complete customisation of the event information displayed
|
23 |
-
* Calendar grids can have the ability to change the month displayed
|
24 |
|
25 |
-
Please visit the plugin homepage for how to get started and other help
|
26 |
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
* [Demo Page](http://www.rhanney.co.uk/plugins/google-calendar-events/gce-demo)
|
32 |
-
|
33 |
-
I've also written a post explaining the improvements and changes in version 0.6:
|
34 |
-
|
35 |
-
* [0.6 Features](http://www.rhanney.co.uk/2011/04/29/google-calendar-events-0-6)
|
36 |
|
37 |
== Installation ==
|
38 |
|
@@ -56,6 +50,17 @@ You can now start adding feeds. Visit the [plugin homepage](http://www.rhanney.c
|
|
56 |
|
57 |
== Changelog ==
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
= 0.6 =
|
60 |
* Drastically reduced memory usage
|
61 |
* Improved feed data caching system
|
2 |
Contributors: rosshanney
|
3 |
Donate link: http://www.rhanney.co.uk/plugins/google-calendar-events/#donate
|
4 |
Tags: google, google calendar, calendar, event, events, ajax, widget
|
5 |
+
Requires at least: 3.0
|
6 |
+
Tested up to: 3.2
|
7 |
+
Stable tag: 0.7
|
8 |
|
9 |
Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
|
10 |
|
20 |
* Lists and grids can be displayed in posts, pages or within a widget
|
21 |
* Options to change the number of events retrieved, date / time format, cache duration etc
|
22 |
* Complete customisation of the event information displayed
|
23 |
+
* Calendar grids can have the ability to change the month displayed
|
24 |
|
25 |
+
Please visit the [plugin homepage](http://www.rhanney.co.uk/plugins/google-calendar-events) for how to get started and other help.
|
26 |
|
27 |
+
There is also a [demonstration page](http://www.rhanney.co.uk/plugins/google-calendar-events/gce-demo) showing the plugin in action.
|
28 |
|
29 |
+
[Changes in 0.7](http://www.rhanney.co.uk/2011/06/25/google-calendar-events-0-7).
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
== Installation ==
|
32 |
|
50 |
|
51 |
== Changelog ==
|
52 |
|
53 |
+
= 0.7 =
|
54 |
+
* Fixed bug causing event dates / times to be displayed in the wrong timezone
|
55 |
+
* Changed the [link-path] Event Display Builder shortcode to [url]
|
56 |
+
* Fixed an Opera specific CSS issue causing page lists to be hidden
|
57 |
+
* Lists can now be displayed in descending or ascending order
|
58 |
+
* Added [event-id] and [cal-id] Event Display Builder shortcodes
|
59 |
+
* Added an offset parameter for date / time based Event Display Builder shortcodes
|
60 |
+
* Added an autolink parameter for enabling / disabling automatic linking of URLs
|
61 |
+
* Added gce-day-past or gce-day-future classes to calendar grid cells
|
62 |
+
* Cleaned up CSS
|
63 |
+
|
64 |
= 0.6 =
|
65 |
* Drastically reduced memory usage
|
66 |
* Improved feed data caching system
|
uninstall.php
CHANGED
@@ -1,18 +1,19 @@
|
|
1 |
<?php
|
2 |
-
if(!defined('WP_UNINSTALL_PLUGIN')
|
|
|
3 |
|
4 |
-
$gce_options = get_option('gce_options');
|
5 |
|
6 |
//Remove any cached feed data
|
7 |
-
foreach($gce_options as $gce_feed){
|
8 |
-
if(isset($gce_feed['id'])){
|
9 |
-
delete_transient('gce_feed_' . $gce_feed['id']);
|
10 |
-
delete_transient('gce_feed_' . $gce_feed['id'] . '_url');
|
11 |
}
|
12 |
}
|
13 |
|
14 |
//Delete plugin options
|
15 |
-
delete_option('gce_options');
|
16 |
-
delete_option('gce_general');
|
17 |
-
delete_option('gce_version');
|
18 |
?>
|
1 |
<?php
|
2 |
+
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
|
3 |
+
die();
|
4 |
|
5 |
+
$gce_options = get_option( 'gce_options' );
|
6 |
|
7 |
//Remove any cached feed data
|
8 |
+
foreach ( $gce_options as $gce_feed ) {
|
9 |
+
if ( isset( $gce_feed['id'] ) ) {
|
10 |
+
delete_transient( 'gce_feed_' . $gce_feed['id'] );
|
11 |
+
delete_transient( 'gce_feed_' . $gce_feed['id'] . '_url' );
|
12 |
}
|
13 |
}
|
14 |
|
15 |
//Delete plugin options
|
16 |
+
delete_option( 'gce_options' );
|
17 |
+
delete_option( 'gce_general' );
|
18 |
+
delete_option( 'gce_version' );
|
19 |
?>
|
widget/gce-widget.php
CHANGED
@@ -1,92 +1,105 @@
|
|
1 |
<?php
|
2 |
-
class GCE_Widget extends WP_Widget{
|
3 |
-
function GCE_Widget(){
|
4 |
parent::WP_Widget(
|
5 |
false,
|
6 |
-
$name = __('Google Calendar Events', GCE_TEXT_DOMAIN),
|
7 |
-
array('description' => __('Display a list or calendar grid of events from one or more Google Calendar feeds you have added', GCE_TEXT_DOMAIN))
|
8 |
);
|
9 |
}
|
10 |
|
11 |
-
function widget($args, $instance){
|
12 |
-
extract($args);
|
13 |
|
14 |
//Output before widget stuff
|
15 |
echo $before_widget;
|
16 |
|
17 |
//Get saved feed options
|
18 |
-
$options = get_option(GCE_OPTIONS_NAME);
|
19 |
|
20 |
//Check whether any feeds have been added yet
|
21 |
-
if(is_array($options) && !empty($options)){
|
22 |
//Output title stuff
|
23 |
-
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
|
24 |
-
if(!empty($title)) echo $before_title . $title . $after_title;
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
//Check each id is an integer, if not, remove it from the array
|
30 |
-
foreach($feed_ids as $key => $feed_id){
|
31 |
-
if(absint($feed_id) == 0) unset($feed_ids[$key]);
|
32 |
-
}
|
33 |
|
34 |
$no_feeds_exist = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
|
37 |
-
foreach($feed_ids as $feed_id){
|
38 |
-
if(isset($options[$feed_id])) $no_feeds_exist = false;
|
39 |
}
|
40 |
|
41 |
//Check that at least one valid feed id has been entered
|
42 |
-
if(
|
43 |
-
if(current_user_can('manage_options')){
|
44 |
-
_e('No valid Feed IDs have been entered for this widget. Please check that you have entered the IDs correctly in the widget settings (Appearance > Widgets), and that the Feeds have not been deleted.', GCE_TEXT_DOMAIN);
|
45 |
-
}else{
|
46 |
-
$options = get_option(GCE_GENERAL_OPTIONS_NAME);
|
47 |
echo $options['error'];
|
48 |
}
|
49 |
-
}else{
|
50 |
//Turns feed_ids back into string or feed ids delimited by '-' ('1-2-3-4' for example)
|
51 |
-
$feed_ids = implode('-', $feed_ids);
|
52 |
|
53 |
-
$title_text = $instance['display_title'] ? $instance['display_title_text'] : null;
|
54 |
-
|
55 |
-
$
|
56 |
|
57 |
//Output correct widget content based on display type chosen
|
58 |
-
switch($instance['display_type']){
|
59 |
case 'grid':
|
60 |
echo '<div class="gce-widget-grid" id="' . $args['widget_id'] . '-container">';
|
61 |
//Output main widget content as grid (no AJAX)
|
62 |
-
gce_widget_content_grid($feed_ids, $title_text, $max_events, $args['widget_id'] . '-container');
|
63 |
echo '</div>';
|
64 |
break;
|
65 |
case 'ajax':
|
66 |
echo '<div class="gce-widget-grid" id="' . $args['widget_id'] . '-container">';
|
67 |
//Output main widget content as grid (with AJAX)
|
68 |
-
gce_widget_content_grid($feed_ids, $title_text, $max_events, $args['widget_id'] . '-container', true);
|
69 |
echo '</div>';
|
70 |
break;
|
71 |
case 'list':
|
72 |
echo '<div class="gce-widget-list" id="' . $args['widget_id'] . '-container">';
|
73 |
//Output main widget content as list
|
74 |
-
gce_widget_content_list($feed_ids, $title_text, $max_events);
|
75 |
echo '</div>';
|
76 |
break;
|
77 |
case 'list-grouped':
|
78 |
echo '<div class="gce-widget-list" id="' . $args['widget_id'] . '-container">';
|
79 |
//Output main widget content as a grouped list
|
80 |
-
gce_widget_content_list($feed_ids, $title_text, $max_events, true);
|
81 |
echo '</div>';
|
82 |
break;
|
83 |
}
|
84 |
}
|
85 |
-
}else{
|
86 |
-
if(current_user_can('manage_options')){
|
87 |
-
_e('No feeds have been added yet. You can add a feed in the Google Calendar Events settings.', GCE_TEXT_DOMAIN);
|
88 |
-
}else{
|
89 |
-
$options = get_option(GCE_GENERAL_OPTIONS_NAME);
|
90 |
echo $options['error'];
|
91 |
}
|
92 |
}
|
@@ -95,115 +108,126 @@ class GCE_Widget extends WP_Widget{
|
|
95 |
echo $after_widget;
|
96 |
}
|
97 |
|
98 |
-
function update($new_instance, $old_instance){
|
99 |
$instance = $old_instance;
|
100 |
-
$instance['title'] = esc_html($new_instance['title']);
|
101 |
-
$instance['id'] = esc_html($new_instance['id']);
|
102 |
-
$instance['display_type'] = esc_html($new_instance['display_type']);
|
103 |
-
$instance['max_events'] = absint($new_instance['max_events']);
|
104 |
-
$instance['
|
105 |
-
$instance['
|
|
|
106 |
return $instance;
|
107 |
}
|
108 |
|
109 |
-
function form($instance){
|
110 |
//Get saved feed options
|
111 |
-
$options = get_option(GCE_OPTIONS_NAME);
|
112 |
|
113 |
-
if(empty($options)){
|
114 |
//If no feeds or groups ?>
|
115 |
-
<p><?php _e('No feeds have been added yet. You can add feeds in the Google Calendar Events settings.', GCE_TEXT_DOMAIN); ?></p>
|
116 |
<?php
|
117 |
}else{
|
118 |
-
$title = isset($instance['title']) ? $instance['title'] : '';
|
119 |
-
$ids = isset($instance['id']) ? $instance['id'] : '';
|
120 |
-
$display_type = isset($instance['display_type']) ? $instance['display_type'] : 'grid';
|
121 |
-
$max_events = isset($instance['max_events']) ? $instance['max_events'] : 0;
|
122 |
-
$
|
123 |
-
$
|
|
|
124 |
?>
|
125 |
<p>
|
126 |
-
<label for="<?php echo $this->get_field_id('title'); ?>">Title:</label>
|
127 |
-
<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" />
|
128 |
</p><p>
|
129 |
-
<label for="<?php echo $this->get_field_id('id'); ?>">
|
130 |
-
<?php _e('
|
131 |
</label>
|
132 |
-
<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" />
|
133 |
</p><p>
|
134 |
-
<label for="<?php echo $this->get_field_id('display_type'); ?>"><?php _e('Display as:', GCE_TEXT_DOMAIN); ?></label>
|
135 |
-
<select id="<?php echo $this->get_field_id('display_type'); ?>" name="<?php echo $this->get_field_name('display_type'); ?>" class="widefat">
|
136 |
-
<option value="grid"<?php selected($display_type, 'grid')
|
137 |
-
<option value="ajax"<?php selected($display_type, 'ajax')
|
138 |
-
<option value="list"<?php selected($display_type, 'list')
|
139 |
-
<option value="list-grouped"<?php selected($display_type, 'list-grouped');?>><?php _e('List - grouped by date', GCE_TEXT_DOMAIN); ?></option>
|
140 |
</select>
|
141 |
</p><p>
|
142 |
-
<label for="<?php echo $this->get_field_id('max_events'); ?>"><?php _e('Maximum no. events to display. Enter 0 to show all retrieved.'); ?></label>
|
143 |
-
<input type="text" id="<?php echo $this->get_field_id('max_events'); ?>" name="<?php echo $this->get_field_name('max_events'); ?>" value="<?php echo $max_events; ?>" class="widefat" />
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
</p><p>
|
145 |
-
<label for="<?php echo $this->get_field_id('display_title'); ?>"
|
146 |
<br />
|
147 |
-
<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" />
|
148 |
-
<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%;" />
|
149 |
</p>
|
150 |
<?php
|
151 |
}
|
152 |
}
|
153 |
}
|
154 |
|
155 |
-
function gce_widget_content_grid($feed_ids, $title_text, $max_events, $widget_id, $ajaxified = false, $month = null, $year = null){
|
156 |
require_once WP_PLUGIN_DIR . '/' . GCE_PLUGIN_NAME . '/inc/gce-parser.php';
|
157 |
|
158 |
-
$ids = explode('-', $feed_ids);
|
159 |
|
160 |
//Create new GCE_Parser object, passing array of feed id(s)
|
161 |
-
$grid = new GCE_Parser($ids, $title_text, $max_events);
|
162 |
|
163 |
$num_errors = $grid->get_num_errors();
|
164 |
|
165 |
//If there are less errors than feeds parsed, at least one feed must have parsed successfully so continue to display the grid
|
166 |
-
if($num_errors < count($ids)){
|
167 |
//If there was at least one error, and user is an admin, output error messages
|
168 |
-
if($num_errors > 0 && current_user_can('manage_options')
|
|
|
169 |
|
170 |
//Add AJAX script if required
|
171 |
-
if
|
|
|
172 |
|
173 |
-
echo $grid->get_grid($year, $month, $ajaxified);
|
174 |
-
}else{
|
175 |
//If current user is an admin, display an error message explaining problem. Otherwise, display a 'nice' error messsage
|
176 |
-
if(current_user_can('manage_options')){
|
177 |
echo $grid->error_messages();
|
178 |
-
}else{
|
179 |
-
$options = get_option(GCE_GENERAL_OPTIONS_NAME);
|
180 |
echo $options['error'];
|
181 |
}
|
182 |
}
|
183 |
}
|
184 |
|
185 |
-
function gce_widget_content_list($feed_ids, $title_text, $max_events, $grouped = false){
|
186 |
require_once WP_PLUGIN_DIR . '/' . GCE_PLUGIN_NAME . '/inc/gce-parser.php';
|
187 |
|
188 |
-
$ids = explode('-', $feed_ids);
|
189 |
|
190 |
//Create new GCE_Parser object, passing array of feed id(s)
|
191 |
-
$list = new GCE_Parser($ids, $title_text, $max_events);
|
192 |
|
193 |
$num_errors = $list->get_num_errors();
|
194 |
|
195 |
//If there are less errors than feeds parsed, at least one feed must have parsed successfully so continue to display the list
|
196 |
-
if($num_errors < count($ids)){
|
197 |
//If there was at least one error, and user is an admin, output error messages
|
198 |
-
if($num_errors > 0 && current_user_can('manage_options')
|
|
|
199 |
|
200 |
-
echo $list->get_list($grouped);
|
201 |
-
}else{
|
202 |
//If current user is an admin, display an error message explaining problem(s). Otherwise, display a 'nice' error messsage
|
203 |
-
if(current_user_can('manage_options')){
|
204 |
echo $list->error_messages();
|
205 |
-
}else{
|
206 |
-
$options = get_option(GCE_GENERAL_OPTIONS_NAME);
|
207 |
echo $options['error'];
|
208 |
}
|
209 |
}
|
1 |
<?php
|
2 |
+
class GCE_Widget extends WP_Widget {
|
3 |
+
function GCE_Widget() {
|
4 |
parent::WP_Widget(
|
5 |
false,
|
6 |
+
$name = __( 'Google Calendar Events', GCE_TEXT_DOMAIN ),
|
7 |
+
array( 'description' => __( 'Display a list or calendar grid of events from one or more Google Calendar feeds you have added', GCE_TEXT_DOMAIN ) )
|
8 |
);
|
9 |
}
|
10 |
|
11 |
+
function widget( $args, $instance ) {
|
12 |
+
extract( $args );
|
13 |
|
14 |
//Output before widget stuff
|
15 |
echo $before_widget;
|
16 |
|
17 |
//Get saved feed options
|
18 |
+
$options = get_option( GCE_OPTIONS_NAME );
|
19 |
|
20 |
//Check whether any feeds have been added yet
|
21 |
+
if( is_array( $options ) && ! empty( $options ) ) {
|
22 |
//Output title stuff
|
23 |
+
$title = empty( $instance['title'] ) ? '' : apply_filters( 'widget_title', $instance['title'] );
|
|
|
24 |
|
25 |
+
if ( ! empty( $title ) )
|
26 |
+
echo $before_title . $title . $after_title;
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
$no_feeds_exist = true;
|
29 |
+
$feed_ids = array();
|
30 |
+
|
31 |
+
if ( '' != $instance['id'] ) {
|
32 |
+
//Break comma delimited list of feed ids into array
|
33 |
+
$feed_ids = explode( ',', str_replace( ' ', '', $instance['id'] ) );
|
34 |
+
|
35 |
+
//Check each id is an integer, if not, remove it from the array
|
36 |
+
foreach ( $feed_ids as $key => $feed_id ) {
|
37 |
+
if ( 0 == absint( $feed_id ) )
|
38 |
+
unset( $feed_ids[$key] );
|
39 |
+
}
|
40 |
+
|
41 |
+
//If at least one of the feed ids entered exists, set no_feeds_exist to false
|
42 |
+
foreach ( $feed_ids as $feed_id ) {
|
43 |
+
if ( isset($options[$feed_id] ) )
|
44 |
+
$no_feeds_exist = false;
|
45 |
+
}
|
46 |
+
} else {
|
47 |
+
foreach ( $options as $feed ) {
|
48 |
+
$feed_ids[] = $feed['id'];
|
49 |
+
}
|
50 |
|
51 |
+
$no_feeds_exist = false;
|
|
|
|
|
52 |
}
|
53 |
|
54 |
//Check that at least one valid feed id has been entered
|
55 |
+
if ( empty( $feed_ids ) || $no_feeds_exist ) {
|
56 |
+
if ( current_user_can( 'manage_options' ) ) {
|
57 |
+
_e( 'No valid Feed IDs have been entered for this widget. Please check that you have entered the IDs correctly in the widget settings (Appearance > Widgets), and that the Feeds have not been deleted.', GCE_TEXT_DOMAIN );
|
58 |
+
} else {
|
59 |
+
$options = get_option( GCE_GENERAL_OPTIONS_NAME );
|
60 |
echo $options['error'];
|
61 |
}
|
62 |
+
} else {
|
63 |
//Turns feed_ids back into string or feed ids delimited by '-' ('1-2-3-4' for example)
|
64 |
+
$feed_ids = implode( '-', $feed_ids );
|
65 |
|
66 |
+
$title_text = ( $instance['display_title'] ) ? $instance['display_title_text'] : null;
|
67 |
+
$max_events = ( isset( $instance['max_events'] ) ) ? $instance['max_events'] : 0;
|
68 |
+
$sort_order = ( isset( $instance['order'] ) ) ? $instance['order'] : 'asc';
|
69 |
|
70 |
//Output correct widget content based on display type chosen
|
71 |
+
switch ( $instance['display_type'] ) {
|
72 |
case 'grid':
|
73 |
echo '<div class="gce-widget-grid" id="' . $args['widget_id'] . '-container">';
|
74 |
//Output main widget content as grid (no AJAX)
|
75 |
+
gce_widget_content_grid( $feed_ids, $title_text, $max_events, $args['widget_id'] . '-container' );
|
76 |
echo '</div>';
|
77 |
break;
|
78 |
case 'ajax':
|
79 |
echo '<div class="gce-widget-grid" id="' . $args['widget_id'] . '-container">';
|
80 |
//Output main widget content as grid (with AJAX)
|
81 |
+
gce_widget_content_grid( $feed_ids, $title_text, $max_events, $args['widget_id'] . '-container', true );
|
82 |
echo '</div>';
|
83 |
break;
|
84 |
case 'list':
|
85 |
echo '<div class="gce-widget-list" id="' . $args['widget_id'] . '-container">';
|
86 |
//Output main widget content as list
|
87 |
+
gce_widget_content_list( $feed_ids, $title_text, $max_events, $sort_order );
|
88 |
echo '</div>';
|
89 |
break;
|
90 |
case 'list-grouped':
|
91 |
echo '<div class="gce-widget-list" id="' . $args['widget_id'] . '-container">';
|
92 |
//Output main widget content as a grouped list
|
93 |
+
gce_widget_content_list( $feed_ids, $title_text, $max_events, $sort_order, true );
|
94 |
echo '</div>';
|
95 |
break;
|
96 |
}
|
97 |
}
|
98 |
+
} else {
|
99 |
+
if ( current_user_can( 'manage_options' ) ) {
|
100 |
+
_e( 'No feeds have been added yet. You can add a feed in the Google Calendar Events settings.', GCE_TEXT_DOMAIN );
|
101 |
+
} else {
|
102 |
+
$options = get_option( GCE_GENERAL_OPTIONS_NAME );
|
103 |
echo $options['error'];
|
104 |
}
|
105 |
}
|
108 |
echo $after_widget;
|
109 |
}
|
110 |
|
111 |
+
function update( $new_instance, $old_instance ) {
|
112 |
$instance = $old_instance;
|
113 |
+
$instance['title'] = esc_html( $new_instance['title'] );
|
114 |
+
$instance['id'] = esc_html( $new_instance['id'] );
|
115 |
+
$instance['display_type'] = esc_html( $new_instance['display_type'] );
|
116 |
+
$instance['max_events'] = absint( $new_instance['max_events'] );
|
117 |
+
$instance['order'] = ( 'asc' == $new_instance['order'] ) ? 'asc' : 'desc';
|
118 |
+
$instance['display_title'] = ( 'on' == $new_instance['display_title'] ) ? true : false;
|
119 |
+
$instance['display_title_text'] = wp_filter_kses( $new_instance['display_title_text'] );
|
120 |
return $instance;
|
121 |
}
|
122 |
|
123 |
+
function form( $instance ) {
|
124 |
//Get saved feed options
|
125 |
+
$options = get_option( GCE_OPTIONS_NAME );
|
126 |
|
127 |
+
if ( empty( $options ) ) {
|
128 |
//If no feeds or groups ?>
|
129 |
+
<p><?php _e( 'No feeds have been added yet. You can add feeds in the Google Calendar Events settings.', GCE_TEXT_DOMAIN ); ?></p>
|
130 |
<?php
|
131 |
}else{
|
132 |
+
$title = ( isset( $instance['title'] ) ) ? $instance['title'] : '';
|
133 |
+
$ids = ( isset( $instance['id'] ) ) ? $instance['id'] : '';
|
134 |
+
$display_type = ( isset( $instance['display_type'] ) ) ? $instance['display_type'] : 'grid';
|
135 |
+
$max_events = ( isset( $instance['max_events'] ) ) ? $instance['max_events'] : 0;
|
136 |
+
$order = ( isset( $instance['order'] ) ) ? $instance['order'] : 'asc';
|
137 |
+
$display_title = ( isset($instance['display_title'] ) ) ? $instance['display_title'] : true;
|
138 |
+
$title_text = ( isset($instance['display_title_text'] ) ) ? $instance['display_title_text'] : 'Events on';
|
139 |
?>
|
140 |
<p>
|
141 |
+
<label for="<?php echo $this->get_field_id( 'title' ); ?>">Title:</label>
|
142 |
+
<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" />
|
143 |
</p><p>
|
144 |
+
<label for="<?php echo $this->get_field_id( 'id' ); ?>">
|
145 |
+
<?php _e( 'Feeds to display, as a comma separated list (e.g. 1, 2, 4). Leave blank to display all feeds:', GCE_TEXT_DOMAIN ); ?>
|
146 |
</label>
|
147 |
+
<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" />
|
148 |
</p><p>
|
149 |
+
<label for="<?php echo $this->get_field_id( 'display_type' ); ?>"><?php _e( 'Display events as:', GCE_TEXT_DOMAIN ); ?></label>
|
150 |
+
<select id="<?php echo $this->get_field_id( 'display_type' ); ?>" name="<?php echo $this->get_field_name( 'display_type' ); ?>" class="widefat">
|
151 |
+
<option value="grid"<?php selected( $display_type, 'grid' ); ?>><?php _e( 'Calendar Grid', GCE_TEXT_DOMAIN ); ?></option>
|
152 |
+
<option value="ajax"<?php selected( $display_type, 'ajax' ); ?>><?php _e( 'Calendar Grid - with AJAX', GCE_TEXT_DOMAIN ); ?></option>
|
153 |
+
<option value="list"<?php selected( $display_type, 'list' ); ?>><?php _e( 'List', GCE_TEXT_DOMAIN ); ?></option>
|
154 |
+
<option value="list-grouped"<?php selected( $display_type, 'list-grouped' );?>><?php _e( 'List - grouped by date', GCE_TEXT_DOMAIN ); ?></option>
|
155 |
</select>
|
156 |
</p><p>
|
157 |
+
<label for="<?php echo $this->get_field_id( 'max_events' ); ?>"><?php _e( 'Maximum no. events to display. Enter 0 to show all retrieved.' ); ?></label>
|
158 |
+
<input type="text" id="<?php echo $this->get_field_id( 'max_events' ); ?>" name="<?php echo $this->get_field_name( 'max_events' ); ?>" value="<?php echo $max_events; ?>" class="widefat" />
|
159 |
+
</p><p>
|
160 |
+
<label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php _e( 'Sort order (only applies to lists):' ); ?></label>
|
161 |
+
<select id="<?php echo $this->get_field_id( 'order' ); ?>" name="<?php echo $this->get_field_name( 'order' ); ?>" class="widefat">
|
162 |
+
<option value="asc"<?php selected( $order, 'asc' ); ?>><?php _e( 'Ascending', GCE_TEXT_DOMAIN ); ?></option>
|
163 |
+
<option value="desc"<?php selected( $order, 'desc' ); ?>><?php _e( 'Descending', GCE_TEXT_DOMAIN ); ?></option>
|
164 |
+
</select>
|
165 |
</p><p>
|
166 |
+
<label for="<?php echo $this->get_field_id( 'display_title' ); ?>"><?php _e( 'Display title on tooltip / list item? (e.g. \'Events on 7th March\') Grouped lists always have a title displayed.', GCE_TEXT_DOMAIN ); ?></label>
|
167 |
<br />
|
168 |
+
<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" />
|
169 |
+
<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%;" />
|
170 |
</p>
|
171 |
<?php
|
172 |
}
|
173 |
}
|
174 |
}
|
175 |
|
176 |
+
function gce_widget_content_grid( $feed_ids, $title_text, $max_events, $widget_id, $ajaxified = false, $month = null, $year = null ) {
|
177 |
require_once WP_PLUGIN_DIR . '/' . GCE_PLUGIN_NAME . '/inc/gce-parser.php';
|
178 |
|
179 |
+
$ids = explode( '-', $feed_ids );
|
180 |
|
181 |
//Create new GCE_Parser object, passing array of feed id(s)
|
182 |
+
$grid = new GCE_Parser( $ids, $title_text, $max_events );
|
183 |
|
184 |
$num_errors = $grid->get_num_errors();
|
185 |
|
186 |
//If there are less errors than feeds parsed, at least one feed must have parsed successfully so continue to display the grid
|
187 |
+
if ( $num_errors < count( $ids ) ) {
|
188 |
//If there was at least one error, and user is an admin, output error messages
|
189 |
+
if ( $num_errors > 0 && current_user_can( 'manage_options' ) )
|
190 |
+
echo $grid->error_messages();
|
191 |
|
192 |
//Add AJAX script if required
|
193 |
+
if ( $ajaxified )
|
194 |
+
?><script type="text/javascript">jQuery(document).ready(function($){gce_ajaxify("<?php echo $widget_id; ?>", "<?php echo $feed_ids; ?>", "<?php echo $max_events; ?>", "<?php echo $title_text; ?>", "widget");});</script><?php
|
195 |
|
196 |
+
echo $grid->get_grid( $year, $month, $ajaxified );
|
197 |
+
} else {
|
198 |
//If current user is an admin, display an error message explaining problem. Otherwise, display a 'nice' error messsage
|
199 |
+
if ( current_user_can( 'manage_options' ) ) {
|
200 |
echo $grid->error_messages();
|
201 |
+
} else {
|
202 |
+
$options = get_option( GCE_GENERAL_OPTIONS_NAME );
|
203 |
echo $options['error'];
|
204 |
}
|
205 |
}
|
206 |
}
|
207 |
|
208 |
+
function gce_widget_content_list( $feed_ids, $title_text, $max_events, $sort_order, $grouped = false ) {
|
209 |
require_once WP_PLUGIN_DIR . '/' . GCE_PLUGIN_NAME . '/inc/gce-parser.php';
|
210 |
|
211 |
+
$ids = explode( '-', $feed_ids );
|
212 |
|
213 |
//Create new GCE_Parser object, passing array of feed id(s)
|
214 |
+
$list = new GCE_Parser( $ids, $title_text, $max_events, $sort_order );
|
215 |
|
216 |
$num_errors = $list->get_num_errors();
|
217 |
|
218 |
//If there are less errors than feeds parsed, at least one feed must have parsed successfully so continue to display the list
|
219 |
+
if ( $num_errors < count( $ids ) ) {
|
220 |
//If there was at least one error, and user is an admin, output error messages
|
221 |
+
if ( $num_errors > 0 && current_user_can( 'manage_options' ) )
|
222 |
+
echo $list->error_messages();
|
223 |
|
224 |
+
echo $list->get_list( $grouped );
|
225 |
+
} else {
|
226 |
//If current user is an admin, display an error message explaining problem(s). Otherwise, display a 'nice' error messsage
|
227 |
+
if ( current_user_can( 'manage_options' ) ) {
|
228 |
echo $list->error_messages();
|
229 |
+
} else {
|
230 |
+
$options = get_option( GCE_GENERAL_OPTIONS_NAME );
|
231 |
echo $options['error'];
|
232 |
}
|
233 |
}
|