Version Description
- Fixed bug where retrieve from/until dates were accidentally removed.
Download this release
Release Info
Developer | pderksen |
Plugin | Simple Calendar – Google Calendar Plugin |
Version | 2.0.3.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.3 to 2.0.3.1
- class-google-calendar-events.php +1 -1
- google-calendar-events.php +1 -1
- includes/admin/upgrade.php +47 -0
- includes/class-gce-display.php +34 -45
- includes/class-gce-event.php +4 -1
- includes/class-gce-feed.php +57 -1
- includes/gce-feed-cpt.php +12 -1
- includes/misc-functions.php +5 -26
- includes/shortcodes.php +2 -0
- js/gce-script.js +3 -29
- readme.txt +4 -0
- views/admin/gce-feed-meta-display.php +43 -0
- views/widgets.php +9 -0
class-google-calendar-events.php
CHANGED
@@ -18,7 +18,7 @@ class Google_Calendar_Events {
|
|
18 |
*
|
19 |
* @var string
|
20 |
*/
|
21 |
-
protected $version = '2.0.3';
|
22 |
|
23 |
/**
|
24 |
* Unique identifier for the plugin.
|
18 |
*
|
19 |
* @var string
|
20 |
*/
|
21 |
+
protected $version = '2.0.3.1';
|
22 |
|
23 |
/**
|
24 |
* Unique identifier for the plugin.
|
google-calendar-events.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
* Plugin Name: Google Calendar Events
|
13 |
* Plugin URI: https://github.com/pderksen/WP-Google-Calendar-Events
|
14 |
* Description: Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
|
15 |
-
* Version: 2.0.3
|
16 |
* Author: Phil Derksen
|
17 |
* Author URI: http://philderksen.com
|
18 |
* License: GPL-2.0+
|
12 |
* Plugin Name: Google Calendar Events
|
13 |
* Plugin URI: https://github.com/pderksen/WP-Google-Calendar-Events
|
14 |
* Description: Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
|
15 |
+
* Version: 2.0.3.1
|
16 |
* Author: Phil Derksen
|
17 |
* Author URI: http://philderksen.com
|
18 |
* License: GPL-2.0+
|
includes/admin/upgrade.php
CHANGED
@@ -84,6 +84,52 @@ function convert_to_cpt_posts( $args ) {
|
|
84 |
*/
|
85 |
function create_cpt_meta( $id, $args ) {
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
$gce_expand_recurring = ( isset( $args['expand_recurring'] ) ? ( $args['expand_recurring'] == 'true' ? '1' : '0' ) : '1' );
|
88 |
|
89 |
// An array to hold all of our post meta ids and values so that we can loop through and add as post meta easily
|
@@ -91,6 +137,7 @@ function create_cpt_meta( $id, $args ) {
|
|
91 |
'gce_feed_url' => $args['url'],
|
92 |
'gce_retrieve_from' => $from,
|
93 |
'gce_retrieve_until' => $until,
|
|
|
94 |
'gce_date_format' => $args['date_format'],
|
95 |
'gce_time_format' => $args['time_format'],
|
96 |
'gce_cache' => $args['cache_duration'],
|
84 |
*/
|
85 |
function create_cpt_meta( $id, $args ) {
|
86 |
|
87 |
+
// Convert the dropdown values to the new values for "Retrieve Events From"
|
88 |
+
switch( $args['retrieve_from'] ) {
|
89 |
+
case 'now':
|
90 |
+
case 'today':
|
91 |
+
$from = 'today';
|
92 |
+
break;
|
93 |
+
case 'week':
|
94 |
+
$from = 'start_week';
|
95 |
+
break;
|
96 |
+
case 'month-start':
|
97 |
+
$from = 'start_month';
|
98 |
+
break;
|
99 |
+
case 'month-end':
|
100 |
+
$from = 'end_month';
|
101 |
+
break;
|
102 |
+
case 'date':
|
103 |
+
$from = 'custom_date';
|
104 |
+
break;
|
105 |
+
default:
|
106 |
+
$from = 'start_time';
|
107 |
+
break;
|
108 |
+
}
|
109 |
+
|
110 |
+
// Convert the dropdown values to the new values for "Retrieve Events Until"
|
111 |
+
switch( $args['retrieve_until'] ) {
|
112 |
+
case 'now':
|
113 |
+
case 'today':
|
114 |
+
$until = 'today';
|
115 |
+
break;
|
116 |
+
case 'week':
|
117 |
+
$until = 'start_week';
|
118 |
+
break;
|
119 |
+
case 'month-start':
|
120 |
+
$until = 'start_month';
|
121 |
+
break;
|
122 |
+
case 'month-end':
|
123 |
+
$until = 'end_month';
|
124 |
+
break;
|
125 |
+
case 'date':
|
126 |
+
$until = 'custom_date';
|
127 |
+
break;
|
128 |
+
default:
|
129 |
+
$until = 'end_time';
|
130 |
+
break;
|
131 |
+
}
|
132 |
+
|
133 |
$gce_expand_recurring = ( isset( $args['expand_recurring'] ) ? ( $args['expand_recurring'] == 'true' ? '1' : '0' ) : '1' );
|
134 |
|
135 |
// An array to hold all of our post meta ids and values so that we can loop through and add as post meta easily
|
137 |
'gce_feed_url' => $args['url'],
|
138 |
'gce_retrieve_from' => $from,
|
139 |
'gce_retrieve_until' => $until,
|
140 |
+
'gce_retrieve_max' => $args['max_events'],
|
141 |
'gce_date_format' => $args['date_format'],
|
142 |
'gce_time_format' => $args['time_format'],
|
143 |
'gce_cache' => $args['cache_duration'],
|
includes/class-gce-display.php
CHANGED
@@ -13,10 +13,11 @@ class GCE_Display {
|
|
13 |
|
14 |
private $feeds, $merged_feeds;
|
15 |
|
16 |
-
public function __construct( $ids, $title_text = null, $sort_order = 'asc' ) {
|
17 |
|
18 |
$this->id = $ids;
|
19 |
$this->title = $title_text;
|
|
|
20 |
$this->sort = $sort_order;
|
21 |
|
22 |
foreach( $ids as $id ) {
|
@@ -60,9 +61,11 @@ class GCE_Display {
|
|
60 |
//Total number of events retrieved
|
61 |
$count = count( $this->merged_feeds );
|
62 |
|
|
|
|
|
63 |
|
64 |
//Loop through entire array of events, or until maximum number of events to be displayed has been reached
|
65 |
-
for ( $i = 0; $i < $count; $i++ ) {
|
66 |
$event = $this->merged_feeds[$i];
|
67 |
|
68 |
//Check that event ends, or starts (or both) within the required date range. This prevents all-day events from before / after date range from showing up.
|
@@ -70,6 +73,10 @@ class GCE_Display {
|
|
70 |
foreach ( $event->get_days() as $day ) {
|
71 |
$event_days[$day][] = $event;
|
72 |
}
|
|
|
|
|
|
|
|
|
73 |
}
|
74 |
}
|
75 |
|
@@ -200,7 +207,7 @@ class GCE_Display {
|
|
200 |
*
|
201 |
* @since 2.0.0
|
202 |
*/
|
203 |
-
public function get_list( $grouped = false
|
204 |
$time_now = current_time( 'timestamp' );
|
205 |
|
206 |
// Get all the event days
|
@@ -211,56 +218,38 @@ class GCE_Display {
|
|
211 |
return '<p>' . __( 'There are currently no events to display.', 'gce' ) . '</p>';
|
212 |
}
|
213 |
|
214 |
-
$today
|
215 |
-
$end_month = mktime( 0, 0, 0, date( 'm' ) + $end, 1, date( 'Y' ) );
|
216 |
|
217 |
$i = 1;
|
218 |
-
|
219 |
-
|
220 |
-
$feeds = implode( $this->id, '-' );
|
221 |
-
|
222 |
-
|
223 |
-
$markup = '<ul class="gce-list" data-gce-feeds="' . $feeds . '" data-gce-title="' . $this->title . '" data-gce-grouped="' . $grouped . '" data-gce-sort="' . $this->sort . '">';
|
224 |
-
|
225 |
-
$p = '<span class="gce-prev"><a href="#" class="gce-change-month-list" title="Previous month" data-gce-month="' . ( date( 'n', $today ) - 1 ) . '">Back</a></span>';
|
226 |
-
$n = '<span class="gce-next"><a href="#" class="gce-change-month-list" title="Next month" data-gce-month="' . ( date( 'n', $today ) + 1 ) . '">Next</a></span>';
|
227 |
-
|
228 |
-
$markup .= '' . "\n" . '<caption class="gce-caption">' . $p . '<span class="gce-month-title">' .
|
229 |
-
date( 'F', $today ) . '</span>' . $n . "</caption>\n";
|
230 |
-
|
231 |
-
$max_count = 1;
|
232 |
|
233 |
foreach ( $event_days as $key => $event_day ) {
|
234 |
-
|
235 |
-
if( $key < $end_month ) {
|
236 |
//If this is a grouped list, add the date title and begin the nested list for this day
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
foreach ( $event_day as $num_in_day => $event ) {
|
245 |
-
//Create the markup for this event
|
246 |
-
$markup .=
|
247 |
-
'<li class="gce-feed-' . $event->feed->id . '">' .
|
248 |
-
//If this isn't a grouped list and a date title should be displayed, add the date title
|
249 |
-
( ( ! $grouped && isset( $event->title ) ) ? '<div class="gce-list-title">' . esc_html( $this->title ) . ' ' . date_i18n( $event->feed->date_format, $key ) . '</div>' : '' ) .
|
250 |
-
//Add the event markup
|
251 |
-
$event->get_event_markup( 'list', $num_in_day, $i ) .
|
252 |
-
'</li>';
|
253 |
|
254 |
-
|
255 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
}
|
261 |
}
|
262 |
-
|
263 |
-
$max_count++;
|
264 |
}
|
265 |
|
266 |
$markup .= '</ul>';
|
13 |
|
14 |
private $feeds, $merged_feeds;
|
15 |
|
16 |
+
public function __construct( $ids, $title_text = null, $max_events = 0, $sort_order = 'asc' ) {
|
17 |
|
18 |
$this->id = $ids;
|
19 |
$this->title = $title_text;
|
20 |
+
$this->max_events = $max_events;
|
21 |
$this->sort = $sort_order;
|
22 |
|
23 |
foreach( $ids as $id ) {
|
61 |
//Total number of events retrieved
|
62 |
$count = count( $this->merged_feeds );
|
63 |
|
64 |
+
//If maximum events to display is 0 (unlimited) set $max to 1, otherwise use maximum of events specified by user
|
65 |
+
$max = ( 0 == $this->max_events ) ? 1 : $this->max_events;
|
66 |
|
67 |
//Loop through entire array of events, or until maximum number of events to be displayed has been reached
|
68 |
+
for ( $i = 0; $i < $count && $max > 0; $i++ ) {
|
69 |
$event = $this->merged_feeds[$i];
|
70 |
|
71 |
//Check that event ends, or starts (or both) within the required date range. This prevents all-day events from before / after date range from showing up.
|
73 |
foreach ( $event->get_days() as $day ) {
|
74 |
$event_days[$day][] = $event;
|
75 |
}
|
76 |
+
|
77 |
+
//If maximum events to display isn't 0 (unlimited) decrement $max counter
|
78 |
+
if ( 0 != $this->max_events )
|
79 |
+
$max--;
|
80 |
}
|
81 |
}
|
82 |
|
207 |
*
|
208 |
* @since 2.0.0
|
209 |
*/
|
210 |
+
public function get_list( $grouped = false ) {
|
211 |
$time_now = current_time( 'timestamp' );
|
212 |
|
213 |
// Get all the event days
|
218 |
return '<p>' . __( 'There are currently no events to display.', 'gce' ) . '</p>';
|
219 |
}
|
220 |
|
221 |
+
$today = mktime( 0, 0, 0, date( 'm', $time_now ), date( 'd', $time_now ), date( 'Y', $time_now ) );
|
|
|
222 |
|
223 |
$i = 1;
|
224 |
+
|
225 |
+
$markup = '<ul class="gce-list">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
|
227 |
foreach ( $event_days as $key => $event_day ) {
|
|
|
|
|
228 |
//If this is a grouped list, add the date title and begin the nested list for this day
|
229 |
+
if ( $grouped ) {
|
230 |
+
$markup .=
|
231 |
+
'<li' . ( ( $key == $today ) ? ' class="gce-today"' : '' ) . '>' .
|
232 |
+
'<div class="gce-list-title">' . date_i18n( $event_day[0]->feed->date_format, $key ) . '</div>' .
|
233 |
+
'<ul>';
|
234 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
|
236 |
+
foreach ( $event_day as $num_in_day => $event ) {
|
237 |
+
//Create the markup for this event
|
238 |
+
$markup .=
|
239 |
+
'<li class="gce-feed-' . $event->feed->id . '">' .
|
240 |
+
//If this isn't a grouped list and a date title should be displayed, add the date title
|
241 |
+
( ( ! $grouped && isset( $event->title ) ) ? '<div class="gce-list-title">' . esc_html( $this->title ) . ' ' . date_i18n( $event->feed->date_format, $key ) . '</div>' : '' ) .
|
242 |
+
//Add the event markup
|
243 |
+
$event->get_event_markup( 'list', $num_in_day, $i ) .
|
244 |
+
'</li>';
|
245 |
+
|
246 |
+
$i++;
|
247 |
+
}
|
248 |
|
249 |
+
//If this is a grouped list, close the nested list for this day
|
250 |
+
if ( $grouped ) {
|
251 |
+
$markup .= '</ul></li>';
|
|
|
252 |
}
|
|
|
|
|
253 |
}
|
254 |
|
255 |
$markup .= '</ul>';
|
includes/class-gce-event.php
CHANGED
@@ -64,7 +64,10 @@ class GCE_Event {
|
|
64 |
while ( $on_next_day ) {
|
65 |
//If the end time of the event is after 00:00 on the next day (therefore, not doesn't end on this day)
|
66 |
if ( $this->end_time > $next_day ) {
|
67 |
-
|
|
|
|
|
|
|
68 |
} else {
|
69 |
$on_next_day = false;
|
70 |
}
|
64 |
while ( $on_next_day ) {
|
65 |
//If the end time of the event is after 00:00 on the next day (therefore, not doesn't end on this day)
|
66 |
if ( $this->end_time > $next_day ) {
|
67 |
+
//If $next_day is within the event retrieval date range (specified by retrieve events from / until settings)
|
68 |
+
if ( $next_day >= $this->feed->start && $next_day < $this->feed->end ) {
|
69 |
+
$days[] = $next_day;
|
70 |
+
}
|
71 |
} else {
|
72 |
$on_next_day = false;
|
73 |
}
|
includes/class-gce-feed.php
CHANGED
@@ -13,6 +13,9 @@ class GCE_Feed {
|
|
13 |
|
14 |
public $id,
|
15 |
$feed_url,
|
|
|
|
|
|
|
16 |
$date_format,
|
17 |
$time_format,
|
18 |
$cache,
|
@@ -59,6 +62,9 @@ class GCE_Feed {
|
|
59 |
$time_format = get_post_meta( $this->id, 'gce_time_format', true );
|
60 |
|
61 |
$this->feed_url = get_post_meta( $this->id, 'gce_feed_url', true );
|
|
|
|
|
|
|
62 |
$this->date_format = ( ! empty( $date_format ) ? $date_format : get_option( 'date_format' ) );
|
63 |
$this->time_format = ( ! empty( $time_format ) ? $time_format : get_option( 'time_format' ) );
|
64 |
$this->cache = get_post_meta( $this->id, 'gce_cache', true );
|
@@ -99,7 +105,9 @@ class GCE_Feed {
|
|
99 |
$gmt_offset = get_option( 'gmt_offset' ) * 3600;
|
100 |
|
101 |
//Append the feed specific parameters to the querystring
|
102 |
-
$query .= '&start-min=' . date( 'Y-m-d\TH:i:s',
|
|
|
|
|
103 |
|
104 |
if ( ! empty( $this->search_query ) ) {
|
105 |
$query .= '&q=' . rawurlencode( $this->search_query );
|
@@ -201,6 +209,54 @@ class GCE_Feed {
|
|
201 |
return mktime( $hour, $minute, $second, $month, $day, $year );
|
202 |
}
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
function get_builder() {
|
205 |
|
206 |
$this->builder = get_post( $this->id )->post_content;
|
13 |
|
14 |
public $id,
|
15 |
$feed_url,
|
16 |
+
$start,
|
17 |
+
$end,
|
18 |
+
$max,
|
19 |
$date_format,
|
20 |
$time_format,
|
21 |
$cache,
|
62 |
$time_format = get_post_meta( $this->id, 'gce_time_format', true );
|
63 |
|
64 |
$this->feed_url = get_post_meta( $this->id, 'gce_feed_url', true );
|
65 |
+
$this->start = $this->set_feed_length( get_post_meta( $this->id, 'gce_retrieve_from', true ), 'start' );
|
66 |
+
$this->end = $this->set_feed_length( get_post_meta( $this->id, 'gce_retrieve_until', true ), 'end' );
|
67 |
+
$this->max = get_post_meta( $this->id, 'gce_retrieve_max', true );
|
68 |
$this->date_format = ( ! empty( $date_format ) ? $date_format : get_option( 'date_format' ) );
|
69 |
$this->time_format = ( ! empty( $time_format ) ? $time_format : get_option( 'time_format' ) );
|
70 |
$this->cache = get_post_meta( $this->id, 'gce_cache', true );
|
105 |
$gmt_offset = get_option( 'gmt_offset' ) * 3600;
|
106 |
|
107 |
//Append the feed specific parameters to the querystring
|
108 |
+
$query .= '&start-min=' . date( 'Y-m-d\TH:i:s', $this->start - $gmt_offset );
|
109 |
+
$query .= '&start-max=' . date( 'Y-m-d\TH:i:s', $this->end - $gmt_offset );
|
110 |
+
$query .= '&max-results=' . $this->max;
|
111 |
|
112 |
if ( ! empty( $this->search_query ) ) {
|
113 |
$query .= '&q=' . rawurlencode( $this->search_query );
|
209 |
return mktime( $hour, $minute, $second, $month, $day, $year );
|
210 |
}
|
211 |
|
212 |
+
/**
|
213 |
+
* Return feed start/end
|
214 |
+
*
|
215 |
+
* @since 2.0.0
|
216 |
+
*/
|
217 |
+
private function set_feed_length( $value, $type ) {
|
218 |
+
// All times start at 00:00
|
219 |
+
switch ( $value ) {
|
220 |
+
case 'today':
|
221 |
+
$return = mktime( 0, 0, 0, date( 'm' ), date( 'j' ), date( 'Y' ) );
|
222 |
+
break;
|
223 |
+
case 'start_week':
|
224 |
+
$return = mktime( 0, 0, 0, date( 'm' ), ( date( 'j' ) - date( 'w' ) ), date( 'Y' ) );
|
225 |
+
break;
|
226 |
+
case 'start_month':
|
227 |
+
$return = mktime( 0, 0, 0, date( 'm' ), 1, date( 'Y' ) );
|
228 |
+
break;
|
229 |
+
case 'end_month':
|
230 |
+
$return = mktime( 0, 0, 0, date( 'm' ) + 1, 1, date( 'Y' ) );
|
231 |
+
break;
|
232 |
+
case 'custom_date':
|
233 |
+
if( $type == 'start' ) {
|
234 |
+
$date = get_post_meta( $this->id, 'gce_custom_from', true );
|
235 |
+
$fallback = mktime( 0, 0, 0, date( 'm' ), 1, date( 'Y' ) );
|
236 |
+
} else {
|
237 |
+
$date = get_post_meta( $this->id, 'gce_custom_until', true );
|
238 |
+
$fallback = mktime( 0, 0, 0, date( 'm' ) + 1, 1, date( 'Y' ) );
|
239 |
+
}
|
240 |
+
|
241 |
+
if( ! empty( $date ) ) {
|
242 |
+
$date = explode( '/', $date );
|
243 |
+
$return = mktime( 0, 0, 0, $date[0], $date[1], $date[2] );
|
244 |
+
} else {
|
245 |
+
$return = $fallback;
|
246 |
+
}
|
247 |
+
break;
|
248 |
+
default:
|
249 |
+
if( $type == 'start' ) {
|
250 |
+
$return = 0; //any - 1970-01-01 00:00
|
251 |
+
} else {
|
252 |
+
// Set default end time
|
253 |
+
$return = 2145916800;
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
return $return;
|
258 |
+
}
|
259 |
+
|
260 |
function get_builder() {
|
261 |
|
262 |
$this->builder = get_post( $this->id )->post_content;
|
includes/gce-feed-cpt.php
CHANGED
@@ -142,6 +142,7 @@ function gce_save_meta( $post_id ) {
|
|
142 |
'gce_feed_url',
|
143 |
'gce_retrieve_from',
|
144 |
'gce_retrieve_until',
|
|
|
145 |
'gce_date_format',
|
146 |
'gce_time_format',
|
147 |
'gce_cache',
|
@@ -180,7 +181,12 @@ function gce_save_meta( $post_id ) {
|
|
180 |
update_post_meta( $post_id, $pmf, stripslashes( $_POST[$pmf] ) );
|
181 |
}
|
182 |
} else {
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
184 |
}
|
185 |
}
|
186 |
}
|
@@ -201,6 +207,7 @@ function gce_add_column_headers( $defaults ) {
|
|
201 |
'cb' => $defaults['cb'],
|
202 |
'feed-id' => __( 'Feed ID', 'gce' ),
|
203 |
'feed-sc' => __( 'Feed Shortcode', 'gce' ),
|
|
|
204 |
'display-type' => __( 'Display Type', 'gce' )
|
205 |
);
|
206 |
|
@@ -224,6 +231,10 @@ function gce_column_content( $column_name, $post_ID ) {
|
|
224 |
case 'feed-sc':
|
225 |
echo '<code>[gcal id="' . $post_ID . '"]</code>';
|
226 |
break;
|
|
|
|
|
|
|
|
|
227 |
case 'display-type':
|
228 |
$display = get_post_meta( $post_ID, 'gce_display_mode', true );
|
229 |
|
142 |
'gce_feed_url',
|
143 |
'gce_retrieve_from',
|
144 |
'gce_retrieve_until',
|
145 |
+
'gce_retrieve_max',
|
146 |
'gce_date_format',
|
147 |
'gce_time_format',
|
148 |
'gce_cache',
|
181 |
update_post_meta( $post_id, $pmf, stripslashes( $_POST[$pmf] ) );
|
182 |
}
|
183 |
} else {
|
184 |
+
// We want max to be set to 25 by default if nothing is entered
|
185 |
+
if( $pmf == 'gce_retrieve_max' ) {
|
186 |
+
update_post_meta( $post_id, $pmf, 25 );
|
187 |
+
} else {
|
188 |
+
delete_post_meta( $post_id, $pmf );
|
189 |
+
}
|
190 |
}
|
191 |
}
|
192 |
}
|
207 |
'cb' => $defaults['cb'],
|
208 |
'feed-id' => __( 'Feed ID', 'gce' ),
|
209 |
'feed-sc' => __( 'Feed Shortcode', 'gce' ),
|
210 |
+
'max-events' => __( 'Max Events', 'gce' ),
|
211 |
'display-type' => __( 'Display Type', 'gce' )
|
212 |
);
|
213 |
|
231 |
case 'feed-sc':
|
232 |
echo '<code>[gcal id="' . $post_ID . '"]</code>';
|
233 |
break;
|
234 |
+
case 'max-events':
|
235 |
+
$max = get_post_meta( $post_ID, 'gce_retrieve_max', true );
|
236 |
+
echo $max;
|
237 |
+
break;
|
238 |
case 'display-type':
|
239 |
$display = get_post_meta( $post_ID, 'gce_display_mode', true );
|
240 |
|
includes/misc-functions.php
CHANGED
@@ -9,6 +9,7 @@ function gce_print_calendar( $feed_ids, $display = 'grid', $args = array(), $wid
|
|
9 |
|
10 |
$defaults = array(
|
11 |
'title_text' => '',
|
|
|
12 |
'sort' => 'asc',
|
13 |
'grouped' => 0,
|
14 |
'month' => null,
|
@@ -23,13 +24,13 @@ function gce_print_calendar( $feed_ids, $display = 'grid', $args = array(), $wid
|
|
23 |
$ids = explode( '-', $feed_ids );
|
24 |
|
25 |
//Create new display object, passing array of feed id(s)
|
26 |
-
$d = new GCE_Display( $ids, $title_text, $sort );
|
27 |
$markup = '';
|
28 |
|
29 |
if( 'grid' == $display ) {
|
30 |
|
31 |
$markup = '<script type="text/javascript">jQuery(document).ready(function($){gce_ajaxify("' . ( $widget == 1 ? 'gce-widget-' : 'gce-page-grid-' ) . $feed_ids
|
32 |
-
. '", "' . $feed_ids . '", "' . $title_text . '", "' . ( $widget == 1 ? 'widget' : 'page' ) . '");});</script>';
|
33 |
|
34 |
if( $widget == 1 ) {
|
35 |
$markup .= '<div class="gce-widget-grid" id="gce-widget-' . $feed_ids . '">';
|
@@ -56,6 +57,7 @@ function gce_ajax() {
|
|
56 |
if ( isset( $_GET['gce_feed_ids'] ) ) {
|
57 |
$ids = $_GET['gce_feed_ids'];
|
58 |
$title = $_GET['gce_title_text'];
|
|
|
59 |
$month = $_GET['gce_month'];
|
60 |
$year = $_GET['gce_year'];
|
61 |
|
@@ -63,6 +65,7 @@ function gce_ajax() {
|
|
63 |
|
64 |
$args = array(
|
65 |
'title_text' => $title,
|
|
|
66 |
'month' => $month,
|
67 |
'year' => $year,
|
68 |
);
|
@@ -79,30 +82,6 @@ function gce_ajax() {
|
|
79 |
add_action( 'wp_ajax_nopriv_gce_ajax', 'gce_ajax' );
|
80 |
add_action( 'wp_ajax_gce_ajax', 'gce_ajax' );
|
81 |
|
82 |
-
|
83 |
-
/**
|
84 |
-
* AJAX function for grid pagination
|
85 |
-
*
|
86 |
-
* @since 2.0.0
|
87 |
-
*/
|
88 |
-
function gce_ajax_list() {
|
89 |
-
|
90 |
-
$grouped = $_GET['gce_grouped'];
|
91 |
-
$start = $_GET['gce_month'];
|
92 |
-
$end = $start + 1;
|
93 |
-
$ids = $_GET['gce_feed_ids'];
|
94 |
-
$title_text = $_GET['gce_title_text'];
|
95 |
-
$sort = $_GET['gce_sort'];
|
96 |
-
|
97 |
-
$d = new GCE_Display( explode( '-', $ids ), $title_text, $sort );
|
98 |
-
|
99 |
-
echo $d->get_list( $grouped, $start, $end );
|
100 |
-
|
101 |
-
die();
|
102 |
-
}
|
103 |
-
add_action( 'wp_ajax_nopriv_gce_ajax_list', 'gce_ajax_list' );
|
104 |
-
add_action( 'wp_ajax_gce_ajax_list', 'gce_ajax_list' );
|
105 |
-
|
106 |
function gce_feed_content( $content ) {
|
107 |
global $post;
|
108 |
|
9 |
|
10 |
$defaults = array(
|
11 |
'title_text' => '',
|
12 |
+
'max_events' => 25,
|
13 |
'sort' => 'asc',
|
14 |
'grouped' => 0,
|
15 |
'month' => null,
|
24 |
$ids = explode( '-', $feed_ids );
|
25 |
|
26 |
//Create new display object, passing array of feed id(s)
|
27 |
+
$d = new GCE_Display( $ids, $title_text, $max_events, $sort );
|
28 |
$markup = '';
|
29 |
|
30 |
if( 'grid' == $display ) {
|
31 |
|
32 |
$markup = '<script type="text/javascript">jQuery(document).ready(function($){gce_ajaxify("' . ( $widget == 1 ? 'gce-widget-' : 'gce-page-grid-' ) . $feed_ids
|
33 |
+
. '", "' . $feed_ids . '", "' . absint( $max_events ) . '", "' . $title_text . '", "' . ( $widget == 1 ? 'widget' : 'page' ) . '");});</script>';
|
34 |
|
35 |
if( $widget == 1 ) {
|
36 |
$markup .= '<div class="gce-widget-grid" id="gce-widget-' . $feed_ids . '">';
|
57 |
if ( isset( $_GET['gce_feed_ids'] ) ) {
|
58 |
$ids = $_GET['gce_feed_ids'];
|
59 |
$title = $_GET['gce_title_text'];
|
60 |
+
$max = $_GET['gce_max_events'];
|
61 |
$month = $_GET['gce_month'];
|
62 |
$year = $_GET['gce_year'];
|
63 |
|
65 |
|
66 |
$args = array(
|
67 |
'title_text' => $title,
|
68 |
+
'max_events' => $max,
|
69 |
'month' => $month,
|
70 |
'year' => $year,
|
71 |
);
|
82 |
add_action( 'wp_ajax_nopriv_gce_ajax', 'gce_ajax' );
|
83 |
add_action( 'wp_ajax_gce_ajax', 'gce_ajax' );
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
function gce_feed_content( $content ) {
|
86 |
global $post;
|
87 |
|
includes/shortcodes.php
CHANGED
@@ -22,6 +22,7 @@ function gce_gcal_shortcode( $attr ) {
|
|
22 |
extract( shortcode_atts( array(
|
23 |
'id' => null,
|
24 |
'display' => '',
|
|
|
25 |
'order' => 'asc',
|
26 |
'title' => null,
|
27 |
'type' => null,
|
@@ -61,6 +62,7 @@ function gce_gcal_shortcode( $attr ) {
|
|
61 |
|
62 |
$args = array(
|
63 |
'title_text' => $title,
|
|
|
64 |
'sort' => $order,
|
65 |
'grouped' => ( $display == 'list-grouped' ? 1 : 0 ),
|
66 |
'month' => null,
|
22 |
extract( shortcode_atts( array(
|
23 |
'id' => null,
|
24 |
'display' => '',
|
25 |
+
'max' => 0,
|
26 |
'order' => 'asc',
|
27 |
'title' => null,
|
28 |
'type' => null,
|
62 |
|
63 |
$args = array(
|
64 |
'title_text' => $title,
|
65 |
+
'max_events' => $max,
|
66 |
'sort' => $order,
|
67 |
'grouped' => ( $display == 'list-grouped' ? 1 : 0 ),
|
68 |
'month' => null,
|
js/gce-script.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
*/
|
10 |
|
11 |
|
12 |
-
function gce_ajaxify(target, feed_ids, title_text, type){
|
13 |
|
14 |
//Add click event to change month links
|
15 |
jQuery('#' + target + ' .gce-change-month').click(function(){
|
@@ -24,6 +24,7 @@ function gce_ajaxify(target, feed_ids, title_text, type){
|
|
24 |
gce_feed_ids:feed_ids,
|
25 |
gce_title_text:title_text,
|
26 |
gce_widget_id:target,
|
|
|
27 |
gce_month:month_year[0],
|
28 |
gce_year:month_year[1]
|
29 |
}, function(data){
|
@@ -52,33 +53,6 @@ function gce_tooltips(target_items){
|
|
52 |
});
|
53 |
}
|
54 |
|
55 |
-
jQuery(document).ready(function(
|
56 |
gce_tooltips('.gce-has-events');
|
57 |
-
|
58 |
-
$('.gce-change-month-list').on( 'click', function(e) {
|
59 |
-
|
60 |
-
e.preventDefault();
|
61 |
-
|
62 |
-
var month = $(this).data('gce-month');
|
63 |
-
var grouped = $(this).parent().parent().data('gce-grouped');
|
64 |
-
var title_text = $(this).parent().parent().data('gce-title');
|
65 |
-
var feed_ids = $(this).parent().parent().data( 'gce-feeds');
|
66 |
-
var sort = $(this).parent().parent().data('gce-sort');
|
67 |
-
|
68 |
-
//Add loading text to table caption
|
69 |
-
$('.gce-month-title').html('Loading...');
|
70 |
-
|
71 |
-
//Send AJAX request
|
72 |
-
jQuery.get(gce.ajaxurl,{
|
73 |
-
action:'gce_ajax_list',
|
74 |
-
gce_feed_ids:feed_ids,
|
75 |
-
gce_title_text:title_text,
|
76 |
-
gce_month: month,
|
77 |
-
gce_grouped: grouped,
|
78 |
-
gce_sort: sort
|
79 |
-
}, function(data){
|
80 |
-
console.log( 'Data', data);
|
81 |
-
$('.gce-page-list').html(data);
|
82 |
-
});
|
83 |
-
});
|
84 |
});
|
9 |
*/
|
10 |
|
11 |
|
12 |
+
function gce_ajaxify(target, feed_ids, max_events, title_text, type){
|
13 |
|
14 |
//Add click event to change month links
|
15 |
jQuery('#' + target + ' .gce-change-month').click(function(){
|
24 |
gce_feed_ids:feed_ids,
|
25 |
gce_title_text:title_text,
|
26 |
gce_widget_id:target,
|
27 |
+
gce_max_events:max_events,
|
28 |
gce_month:month_year[0],
|
29 |
gce_year:month_year[1]
|
30 |
}, function(data){
|
53 |
});
|
54 |
}
|
55 |
|
56 |
+
jQuery(document).ready(function(){
|
57 |
gce_tooltips('.gce-has-events');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
});
|
readme.txt
CHANGED
@@ -79,6 +79,10 @@ There are three ways to install this plugin.
|
|
79 |
|
80 |
== Changelog ==
|
81 |
|
|
|
|
|
|
|
|
|
82 |
= 2.0.3 =
|
83 |
|
84 |
* Fixed bug where calendar feed caches weren't getting cleared properly.
|
79 |
|
80 |
== Changelog ==
|
81 |
|
82 |
+
= 2.0.3.1 =
|
83 |
+
|
84 |
+
* Fixed bug where retrieve from/until dates were accidentally removed.
|
85 |
+
|
86 |
= 2.0.3 =
|
87 |
|
88 |
* Fixed bug where calendar feed caches weren't getting cleared properly.
|
views/admin/gce-feed-meta-display.php
CHANGED
@@ -20,6 +20,9 @@
|
|
20 |
|
21 |
// Load up all post meta data
|
22 |
$gce_feed_url = get_post_meta( $post->ID, 'gce_feed_url', true );
|
|
|
|
|
|
|
23 |
$gce_date_format = get_post_meta( $post->ID, 'gce_date_format', true );
|
24 |
$gce_time_format = get_post_meta( $post->ID, 'gce_time_format', true );
|
25 |
$gce_cache = get_post_meta( $post->ID, 'gce_cache', true );
|
@@ -85,6 +88,46 @@
|
|
85 |
</td>
|
86 |
</tr>
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
<tr>
|
89 |
<th scope="row"><label for="gce_date_format"><?php _e( 'Date Format', 'gce' ); ?></label></th>
|
90 |
<td>
|
20 |
|
21 |
// Load up all post meta data
|
22 |
$gce_feed_url = get_post_meta( $post->ID, 'gce_feed_url', true );
|
23 |
+
$gce_retrieve_from = get_post_meta( $post->ID, 'gce_retrieve_from', true );
|
24 |
+
$gce_retrieve_until = get_post_meta( $post->ID, 'gce_retrieve_until', true );
|
25 |
+
$gce_retrieve_max = get_post_meta( $post->ID, 'gce_retrieve_max', true );
|
26 |
$gce_date_format = get_post_meta( $post->ID, 'gce_date_format', true );
|
27 |
$gce_time_format = get_post_meta( $post->ID, 'gce_time_format', true );
|
28 |
$gce_cache = get_post_meta( $post->ID, 'gce_cache', true );
|
88 |
</td>
|
89 |
</tr>
|
90 |
|
91 |
+
<tr>
|
92 |
+
<th scope="row"><label for="gce_retrieve_from"><?php _e( 'Retrieve Events From', 'gce' ); ?></label></th>
|
93 |
+
<td>
|
94 |
+
<select name="gce_retrieve_from" id="gce_retrieve_from">
|
95 |
+
<option value="today" <?php selected( $gce_retrieve_from, 'today', true ); ?>><?php _e( 'Today', 'gce' ); ?></option>
|
96 |
+
<option value="start_week" <?php selected( $gce_retrieve_from, 'start_week', true ); ?>><?php _e( 'Start of current week', 'gce' ); ?></option>
|
97 |
+
<option value="start_month" <?php selected( $gce_retrieve_from, 'start_month', true ); ?>><?php _e( 'Start of current month', 'gce' ); ?></option>
|
98 |
+
<option value="end_month" <?php selected( $gce_retrieve_from, 'end_month', true ); ?>><?php _e( 'End of current month', 'gce' ); ?></option>
|
99 |
+
<option value="start_time" <?php selected( $gce_retrieve_from, 'start_time', true ); ?>><?php _e( 'The beginning of time', 'gce' ); ?></option>
|
100 |
+
<option value="custom_date" <?php selected( $gce_retrieve_from, 'custom_date', true ); ?>><?php _e( 'Specific date', 'gce' ); ?></option>
|
101 |
+
</select>
|
102 |
+
<input type="text" <?php echo ( $gce_retrieve_from != 'custom_date' ? 'class="gce-admin-hidden" ' : ' ' ); ?> name="gce_custom_from" id="gce_custom_from" value="<?php echo $gce_custom_from; ?>" />
|
103 |
+
<p class="description"><?php _e( 'The point in time at which to start retrieving events.', 'gce' ); ?></p>
|
104 |
+
</td>
|
105 |
+
</tr>
|
106 |
+
|
107 |
+
<tr>
|
108 |
+
<th scope="row"><label for="gce_retrieve_until"><?php _e( 'Retrieve Events Until', 'gce' ); ?></label></th>
|
109 |
+
<td>
|
110 |
+
<select name="gce_retrieve_until" id="gce_retrieve_until">
|
111 |
+
<option value="today" <?php selected( $gce_retrieve_until, 'today', true ); ?>><?php _e( 'Today', 'gce' ); ?></option>
|
112 |
+
<option value="start_week" <?php selected( $gce_retrieve_until, 'start_week', true ); ?>><?php _e( 'Start of current week', 'gce' ); ?></option>
|
113 |
+
<option value="start_month" <?php selected( $gce_retrieve_until, 'start_month', true ); ?>><?php _e( 'Start of current month', 'gce' ); ?></option>
|
114 |
+
<option value="end_month" <?php selected( $gce_retrieve_until, 'end_month', true ); ?>><?php _e( 'End of current month', 'gce' ); ?></option>
|
115 |
+
<option value="end_time" <?php selected( $gce_retrieve_until, 'end_time', true ); ?>><?php _e( 'The end of time', 'gce' ); ?></option>
|
116 |
+
<option value="custom_date" <?php selected( $gce_retrieve_until, 'custom_date', true ); ?>><?php _e( 'Specific date', 'gce' ); ?></option>
|
117 |
+
</select>
|
118 |
+
<input type="text" <?php echo ( $gce_retrieve_until != 'custom_date' ? 'class="gce-admin-hidden" ' : ' ' ); ?> name="gce_custom_until" id="gce_custom_until" value="<?php echo $gce_custom_until; ?>" />
|
119 |
+
<p class="description"><?php _e( 'The point in time at which to stop retrieving events.', 'gce' ); ?></p>
|
120 |
+
</td>
|
121 |
+
</tr>
|
122 |
+
|
123 |
+
<tr>
|
124 |
+
<th scope="row"><label for="gce_retrieve_max"><?php _e( 'Max Number of Events', 'gce' ); ?></label></th>
|
125 |
+
<td>
|
126 |
+
<input type="text" class="" name="gce_retrieve_max" id="gce_retrieve_max" value="<?php echo $gce_retrieve_max; ?>" />
|
127 |
+
<p class="description"><?php _e( 'Maximum number of events to show.', 'gce' ); ?></p>
|
128 |
+
<td>
|
129 |
+
</tr>
|
130 |
+
|
131 |
<tr>
|
132 |
<th scope="row"><label for="gce_date_format"><?php _e( 'Date Format', 'gce' ); ?></label></th>
|
133 |
<td>
|
views/widgets.php
CHANGED
@@ -79,10 +79,12 @@ class GCE_Widget extends WP_Widget {
|
|
79 |
$feed_ids = implode( '-', $feed_ids );
|
80 |
|
81 |
$title_text = ( ! empty( $instance['display_title_text'] ) ? $instance['display_title_text'] : null );
|
|
|
82 |
$sort_order = ( isset( $instance['order'] ) ) ? $instance['order'] : 'asc';
|
83 |
|
84 |
$args = array(
|
85 |
'title_text' => $title_text,
|
|
|
86 |
'sort' => $sort_order,
|
87 |
'month' => null,
|
88 |
'year' => null,
|
@@ -120,6 +122,7 @@ class GCE_Widget extends WP_Widget {
|
|
120 |
$instance['title'] = esc_html( $new_instance['title'] );
|
121 |
$instance['id'] = esc_html( $new_instance['id'] );
|
122 |
$instance['display_type'] = esc_html( $new_instance['display_type'] );
|
|
|
123 |
$instance['order'] = ( 'asc' == $new_instance['order'] ) ? 'asc' : 'desc';
|
124 |
$instance['display_title_text'] = wp_filter_kses( $new_instance['display_title_text'] );
|
125 |
|
@@ -145,6 +148,7 @@ class GCE_Widget extends WP_Widget {
|
|
145 |
$title = ( isset( $instance['title'] ) ) ? $instance['title'] : '';
|
146 |
$ids = ( isset( $instance['id'] ) ) ? $instance['id'] : '';
|
147 |
$display_type = ( isset( $instance['display_type'] ) ) ? $instance['display_type'] : 'grid';
|
|
|
148 |
$order = ( isset( $instance['order'] ) ) ? $instance['order'] : 'asc';
|
149 |
$display_title = ( isset( $instance['display_title'] ) ) ? $instance['display_title'] : true;
|
150 |
$title_text = ( isset( $instance['display_title_text'] ) ) ? $instance['display_title_text'] : 'Events on';
|
@@ -170,6 +174,11 @@ class GCE_Widget extends WP_Widget {
|
|
170 |
</select>
|
171 |
</p>
|
172 |
|
|
|
|
|
|
|
|
|
|
|
173 |
<p>
|
174 |
<label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php _e( 'Sort order (only applies to lists):' ); ?></label>
|
175 |
<select id="<?php echo $this->get_field_id( 'order' ); ?>" name="<?php echo $this->get_field_name( 'order' ); ?>" class="widefat">
|
79 |
$feed_ids = implode( '-', $feed_ids );
|
80 |
|
81 |
$title_text = ( ! empty( $instance['display_title_text'] ) ? $instance['display_title_text'] : null );
|
82 |
+
$max_events = ( isset( $instance['max_events'] ) ) ? $instance['max_events'] : 0;
|
83 |
$sort_order = ( isset( $instance['order'] ) ) ? $instance['order'] : 'asc';
|
84 |
|
85 |
$args = array(
|
86 |
'title_text' => $title_text,
|
87 |
+
'max_events' => $max_events,
|
88 |
'sort' => $sort_order,
|
89 |
'month' => null,
|
90 |
'year' => null,
|
122 |
$instance['title'] = esc_html( $new_instance['title'] );
|
123 |
$instance['id'] = esc_html( $new_instance['id'] );
|
124 |
$instance['display_type'] = esc_html( $new_instance['display_type'] );
|
125 |
+
$instance['max_events'] = absint( $new_instance['max_events'] );
|
126 |
$instance['order'] = ( 'asc' == $new_instance['order'] ) ? 'asc' : 'desc';
|
127 |
$instance['display_title_text'] = wp_filter_kses( $new_instance['display_title_text'] );
|
128 |
|
148 |
$title = ( isset( $instance['title'] ) ) ? $instance['title'] : '';
|
149 |
$ids = ( isset( $instance['id'] ) ) ? $instance['id'] : '';
|
150 |
$display_type = ( isset( $instance['display_type'] ) ) ? $instance['display_type'] : 'grid';
|
151 |
+
$max_events = ( isset( $instance['max_events'] ) ) ? $instance['max_events'] : 0;
|
152 |
$order = ( isset( $instance['order'] ) ) ? $instance['order'] : 'asc';
|
153 |
$display_title = ( isset( $instance['display_title'] ) ) ? $instance['display_title'] : true;
|
154 |
$title_text = ( isset( $instance['display_title_text'] ) ) ? $instance['display_title_text'] : 'Events on';
|
174 |
</select>
|
175 |
</p>
|
176 |
|
177 |
+
<p>
|
178 |
+
<label for="<?php echo $this->get_field_id( 'max_events' ); ?>"><?php _e( 'Maximum no. events to display. Enter 0 to show all retrieved.' ); ?></label>
|
179 |
+
<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" />
|
180 |
+
</p>
|
181 |
+
|
182 |
<p>
|
183 |
<label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php _e( 'Sort order (only applies to lists):' ); ?></label>
|
184 |
<select id="<?php echo $this->get_field_id( 'order' ); ?>" name="<?php echo $this->get_field_name( 'order' ); ?>" class="widefat">
|