Version Description
- Bug fixes.
Download this release
Release Info
Developer | rosshanney |
Plugin | Simple Calendar – Google Calendar Plugin |
Version | 0.1.2 |
Comparing to | |
See all releases |
Code changes from version 0.1.1 to 0.1.2
- admin/add.php +4 -2
- admin/delete.php +4 -2
- admin/edit.php +4 -2
- google-calendar-events.php +39 -35
- inc/gce-parser.php +5 -3
- readme.txt +4 -1
- widget/gce-widget.php +33 -25
admin/add.php
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
<?php
|
2 |
//Redirect to the main plugin options page if form has been submitted
|
3 |
-
if($_GET['action']
|
4 |
-
|
|
|
|
|
5 |
}
|
6 |
|
7 |
//Main text
|
1 |
<?php
|
2 |
//Redirect to the main plugin options page if form has been submitted
|
3 |
+
if(isset($_GET['action'])){
|
4 |
+
if($_GET['action'] == 'add' && isset($_GET['updated'])){
|
5 |
+
wp_redirect(admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=added');
|
6 |
+
}
|
7 |
}
|
8 |
|
9 |
//Main text
|
admin/delete.php
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
<?php
|
2 |
//Redirect to the main plugin options page if form has been submitted
|
3 |
-
if($_GET['action']
|
4 |
-
|
|
|
|
|
5 |
}
|
6 |
|
7 |
//Main text
|
1 |
<?php
|
2 |
//Redirect to the main plugin options page if form has been submitted
|
3 |
+
if(isset($_GET['action'])){
|
4 |
+
if($_GET['action'] == 'delete' && isset($_GET['updated'])){
|
5 |
+
wp_redirect(admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=deleted');
|
6 |
+
}
|
7 |
}
|
8 |
|
9 |
//Main text
|
admin/edit.php
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
<?php
|
2 |
//Redirect to the main plugin options page if form has been submitted
|
3 |
-
if($_GET['action']
|
4 |
-
|
|
|
|
|
5 |
}
|
6 |
|
7 |
//Main text
|
1 |
<?php
|
2 |
//Redirect to the main plugin options page if form has been submitted
|
3 |
+
if(isset($_GET['action'])){
|
4 |
+
if($_GET['action'] == 'edit' && isset($_GET['updated'])){
|
5 |
+
wp_redirect(admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php&updated=edited');
|
6 |
+
}
|
7 |
}
|
8 |
|
9 |
//Main text
|
google-calendar-events.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Google Calendar Events
|
4 |
Plugin URI: http://www.rhanney.co.uk/plugins/google-calendar-events
|
5 |
Description: Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
|
6 |
-
Version: 0.1
|
7 |
Author: Ross Hanney
|
8 |
Author URI: http://www.rhanney.co.uk
|
9 |
License: GPL2
|
@@ -57,23 +57,25 @@ if(!class_exists('Google_Calendar_Events')){
|
|
57 |
|
58 |
//Setup admin settings page
|
59 |
function setup_admin(){
|
60 |
-
if(function_exists('add_options_page')) add_options_page('Google Calendar Events', 'Google Calendar Events',
|
61 |
add_option(GCE_OPTIONS_NAME);
|
62 |
}
|
63 |
|
64 |
//Prints admin settings page
|
65 |
function admin_page(){
|
66 |
//Add correct updated message (added / edited / deleted)
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
77 |
}?>
|
78 |
|
79 |
<div class="wrap">
|
@@ -84,29 +86,31 @@ if(!class_exists('Google_Calendar_Events')){
|
|
84 |
<?php
|
85 |
settings_fields('gce_options_group');
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
106 |
//Main admin section
|
107 |
-
|
108 |
-
|
109 |
-
require_once 'admin/main.php';
|
110 |
}
|
111 |
?>
|
112 |
</form>
|
@@ -318,7 +322,7 @@ function gce_handle_ajax($feed_id, $month = null, $year = null){
|
|
318 |
echo gce_print_grid($feed_id, true, $month, $year);
|
319 |
}
|
320 |
|
321 |
-
if($_GET['gce_type'] == 'page'){
|
322 |
if(isset($_GET['gce_feed_id'])){
|
323 |
gce_handle_ajax($_GET['gce_feed_id'], $_GET['gce_month'], $_GET['gce_year']);
|
324 |
die();
|
3 |
Plugin Name: Google Calendar Events
|
4 |
Plugin URI: http://www.rhanney.co.uk/plugins/google-calendar-events
|
5 |
Description: Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
|
6 |
+
Version: 0.1.2
|
7 |
Author: Ross Hanney
|
8 |
Author URI: http://www.rhanney.co.uk
|
9 |
License: GPL2
|
57 |
|
58 |
//Setup admin settings page
|
59 |
function setup_admin(){
|
60 |
+
if(function_exists('add_options_page')) add_options_page('Google Calendar Events', 'Google Calendar Events', 'manage_options', basename(__FILE__), array($this, 'admin_page'));
|
61 |
add_option(GCE_OPTIONS_NAME);
|
62 |
}
|
63 |
|
64 |
//Prints admin settings page
|
65 |
function admin_page(){
|
66 |
//Add correct updated message (added / edited / deleted)
|
67 |
+
if(isset($_GET['updated'])){
|
68 |
+
switch($_GET['updated']){
|
69 |
+
case 'added':
|
70 |
+
?><div class="updated"><p><strong>New Feed Added Successfully.</strong></p></div><?php
|
71 |
+
break;
|
72 |
+
case 'edited':
|
73 |
+
?><div class="updated"><p><strong>Feed Details Updated Successfully.</strong></p></div><?php
|
74 |
+
break;
|
75 |
+
case 'deleted':
|
76 |
+
?><div class="updated"><p><strong>Feed Deleted Successfully.</strong></p></div><?php
|
77 |
+
break;
|
78 |
+
}
|
79 |
}?>
|
80 |
|
81 |
<div class="wrap">
|
86 |
<?php
|
87 |
settings_fields('gce_options_group');
|
88 |
|
89 |
+
if(isset($_GET['action'])){
|
90 |
+
switch($_GET['action']){
|
91 |
+
//Add feed section
|
92 |
+
case 'add':
|
93 |
+
do_settings_sections('add_feed');
|
94 |
+
?><p class="submit"><input type="submit" class="button-primary submit" value="<?php esc_attr_e('Add Feed', GCE_TEXT_DOMAIN); ?>" /></p>
|
95 |
+
<p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary">Cancel</a></p><?php
|
96 |
+
break;
|
97 |
+
//Edit feed section
|
98 |
+
case 'edit':
|
99 |
+
do_settings_sections('edit_feed');
|
100 |
+
?><p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes', GCE_TEXT_DOMAIN); ?>" /></p>
|
101 |
+
<p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary">Cancel</a></p><?php
|
102 |
+
break;
|
103 |
+
//Delete feed section
|
104 |
+
case 'delete':
|
105 |
+
do_settings_sections('delete_feed');
|
106 |
+
?><p class="submit"><input type="submit" class="button-primary" name="gce_options[submit_delete]" value="<?php esc_attr_e('Delete Feed', GCE_TEXT_DOMAIN); ?>" /></p>
|
107 |
+
<p><a href="<?php echo admin_url() . 'options-general.php?page=' . GCE_PLUGIN_NAME . '.php'; ?>" class="button-secondary">Cancel</a></p><?php
|
108 |
+
break;
|
109 |
+
}
|
110 |
+
}else{
|
111 |
//Main admin section
|
112 |
+
settings_fields('gce_stylesheet');
|
113 |
+
require_once 'admin/main.php';
|
|
|
114 |
}
|
115 |
?>
|
116 |
</form>
|
322 |
echo gce_print_grid($feed_id, true, $month, $year);
|
323 |
}
|
324 |
|
325 |
+
if(isset($_GET['gce_type']) && $_GET['gce_type'] == 'page'){
|
326 |
if(isset($_GET['gce_feed_id'])){
|
327 |
gce_handle_ajax($_GET['gce_feed_id'], $_GET['gce_month'], $_GET['gce_year']);
|
328 |
die();
|
inc/gce-parser.php
CHANGED
@@ -45,7 +45,7 @@ class GCE_Parser{
|
|
45 |
|
46 |
//Returns array of days with events, with sub-arrays of events for that day
|
47 |
function get_event_days(){
|
48 |
-
$event_days;
|
49 |
|
50 |
foreach($this->feed->get_items() as $item){
|
51 |
$start_date = $item->get_start_date();
|
@@ -53,7 +53,7 @@ class GCE_Parser{
|
|
53 |
//Round start date to nearest day
|
54 |
$start_date = mktime(0, 0, 0, date('m', $start_date), date('d', $start_date) , date('Y', $start_date));
|
55 |
|
56 |
-
if(
|
57 |
//Create new array in $event_days for this date (only dates with events will go into array, so, for
|
58 |
//example $event_days[26] will exist if 26th of month has events, but won't if it has no events
|
59 |
$event_days[$start_date] = array();
|
@@ -110,7 +110,7 @@ class GCE_Parser{
|
|
110 |
//If event day is in the month and year specified (by $month and $year)
|
111 |
if(date('mY', $key) == $m_y){
|
112 |
//If this event day is the last in $event_days, there are no more events so set $no_more_events to true
|
113 |
-
if($event_day
|
114 |
|
115 |
//Create markup for tooltip
|
116 |
$events_markup = '<div class="gce-event-info"><p>Events on ' . date($this->d_format, $key) . ':</p><ul>';
|
@@ -131,6 +131,8 @@ class GCE_Parser{
|
|
131 |
}
|
132 |
}
|
133 |
|
|
|
|
|
134 |
//Only add previous / next functionality if AJAX grid is enabled
|
135 |
if($ajaxified){
|
136 |
//If the month shown is the current month, don't add previous month link. If it isn't, add previous month link
|
45 |
|
46 |
//Returns array of days with events, with sub-arrays of events for that day
|
47 |
function get_event_days(){
|
48 |
+
$event_days = array();
|
49 |
|
50 |
foreach($this->feed->get_items() as $item){
|
51 |
$start_date = $item->get_start_date();
|
53 |
//Round start date to nearest day
|
54 |
$start_date = mktime(0, 0, 0, date('m', $start_date), date('d', $start_date) , date('Y', $start_date));
|
55 |
|
56 |
+
if(!isset($event_days[$start_date])){
|
57 |
//Create new array in $event_days for this date (only dates with events will go into array, so, for
|
58 |
//example $event_days[26] will exist if 26th of month has events, but won't if it has no events
|
59 |
$event_days[$start_date] = array();
|
110 |
//If event day is in the month and year specified (by $month and $year)
|
111 |
if(date('mY', $key) == $m_y){
|
112 |
//If this event day is the last in $event_days, there are no more events so set $no_more_events to true
|
113 |
+
if($event_day === end($event_days)) $no_more_events = true;
|
114 |
|
115 |
//Create markup for tooltip
|
116 |
$events_markup = '<div class="gce-event-info"><p>Events on ' . date($this->d_format, $key) . ':</p><ul>';
|
131 |
}
|
132 |
}
|
133 |
|
134 |
+
$pn = array();
|
135 |
+
|
136 |
//Only add previous / next functionality if AJAX grid is enabled
|
137 |
if($ajaxified){
|
138 |
//If the month shown is the current month, don't add previous month link. If it isn't, add previous month link
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: rosshanney
|
|
3 |
Tags: google, google calendar, calendar, events, ajax, widget
|
4 |
Requires at least: 2.9.2
|
5 |
Tested up to: 3.0
|
6 |
-
Stable tag: 0.1.
|
7 |
|
8 |
Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
|
9 |
|
@@ -39,6 +39,9 @@ You can now start adding feeds. Visit the [plugin homepage](http://www.rhanney.c
|
|
39 |
|
40 |
== Changelog ==
|
41 |
|
|
|
|
|
|
|
42 |
= 0.1.1 =
|
43 |
* Fix to prevent conflicts with other plugins.
|
44 |
* Changes to readme.txt.
|
3 |
Tags: google, google calendar, calendar, events, ajax, widget
|
4 |
Requires at least: 2.9.2
|
5 |
Tested up to: 3.0
|
6 |
+
Stable tag: 0.1.2
|
7 |
|
8 |
Parses Google Calendar feeds and displays the events as a calendar grid or list on a page, post or widget.
|
9 |
|
39 |
|
40 |
== Changelog ==
|
41 |
|
42 |
+
= 0.1.2 =
|
43 |
+
* Bug fixes.
|
44 |
+
|
45 |
= 0.1.1 =
|
46 |
* Fix to prevent conflicts with other plugins.
|
47 |
* Changes to readme.txt.
|
widget/gce-widget.php
CHANGED
@@ -9,34 +9,42 @@ class GCE_Widget extends WP_Widget{
|
|
9 |
function widget($args, $instance){
|
10 |
extract($args);
|
11 |
|
|
|
|
|
|
|
12 |
//Get saved feed options
|
13 |
$options = get_option(GCE_OPTIONS_NAME);
|
14 |
|
15 |
-
//
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
|
38 |
-
echo '</div>';
|
39 |
-
|
40 |
//Output after widget stuff
|
41 |
echo $after_widget;
|
42 |
}
|
@@ -123,7 +131,7 @@ function gce_widget_content_list($id){
|
|
123 |
|
124 |
//Set time and date formats to WordPress defaults if not set by user
|
125 |
$df = $options[$id]['date_format'];
|
126 |
-
$tf = $
|
127 |
if($df == '') $df = get_option('date_format');
|
128 |
if($tf == '') $tf = get_option('time_format');
|
129 |
|
@@ -146,7 +154,7 @@ function gce_widget_content_list($id){
|
|
146 |
}
|
147 |
|
148 |
//AJAX stuff. Passes the data from JavaScript to above gce_widget_content_grid function
|
149 |
-
if($_GET['gce_type'] == 'widget'){
|
150 |
if(isset($_GET['gce_feed_id'])){
|
151 |
gce_widget_content_grid($_GET['gce_feed_id'], $_GET['gce_widget_id'], true, $_GET['gce_month'], $_GET['gce_year']);
|
152 |
die();
|
9 |
function widget($args, $instance){
|
10 |
extract($args);
|
11 |
|
12 |
+
//Output before widget stuff
|
13 |
+
echo $before_widget;
|
14 |
+
|
15 |
//Get saved feed options
|
16 |
$options = get_option(GCE_OPTIONS_NAME);
|
17 |
|
18 |
+
//Check whether any feeds have been added yet
|
19 |
+
if(is_array($options) && !empty($options)){
|
20 |
+
//Output title stuff
|
21 |
+
echo $before_title . $options[$instance['id']]['title'] . $after_title;
|
22 |
+
|
23 |
+
//Output correct widget content based on display type chosen
|
24 |
+
switch($instance['display_type']){
|
25 |
+
case 'grid':
|
26 |
+
echo '<div class="gce-widget-grid" id="' . $args['widget_id'] . '-container">';
|
27 |
+
//Output main widget content as grid (no AJAX)
|
28 |
+
gce_widget_content_grid($instance['id'], $args['widget_id'] . '-container');
|
29 |
+
echo '</div>';
|
30 |
+
break;
|
31 |
+
case 'ajax':
|
32 |
+
echo '<div class="gce-widget-grid" id="' . $args['widget_id'] . '-container">';
|
33 |
+
//Output main widget content as grid (with AJAX)
|
34 |
+
gce_widget_content_grid($instance['id'], $args['widget_id'] . '-container', true);
|
35 |
+
echo '</div>';
|
36 |
+
break;
|
37 |
+
case 'list':
|
38 |
+
echo '<div class="gce-widget-list" id="' . $args['widget_id'] . '-container">';
|
39 |
+
//Output main widget content as list
|
40 |
+
gce_widget_content_list($instance['id']);
|
41 |
+
echo '</div>';
|
42 |
+
break;
|
43 |
+
}
|
44 |
+
}else{
|
45 |
+
echo 'No feeds have been added yet. You can add a feed in the Google Calendar Events settings.';
|
46 |
}
|
47 |
|
|
|
|
|
48 |
//Output after widget stuff
|
49 |
echo $after_widget;
|
50 |
}
|
131 |
|
132 |
//Set time and date formats to WordPress defaults if not set by user
|
133 |
$df = $options[$id]['date_format'];
|
134 |
+
$tf = $options[$id]['time_format'];
|
135 |
if($df == '') $df = get_option('date_format');
|
136 |
if($tf == '') $tf = get_option('time_format');
|
137 |
|
154 |
}
|
155 |
|
156 |
//AJAX stuff. Passes the data from JavaScript to above gce_widget_content_grid function
|
157 |
+
if(isset($_GET['gce_type']) && $_GET['gce_type'] == 'widget'){
|
158 |
if(isset($_GET['gce_feed_id'])){
|
159 |
gce_widget_content_grid($_GET['gce_feed_id'], $_GET['gce_widget_id'], true, $_GET['gce_month'], $_GET['gce_year']);
|
160 |
die();
|