Calendar - Version 1.0

Version Description

Download this release

Release Info

Developer KieranOShea
Plugin Icon 128x128 Calendar
Version 1.0
Comparing to
See all releases

Code changes from version 1.1.2 to 1.0

Files changed (5) hide show
  1. README +52 -0
  2. readme.txt +0 -105
  3. wp-admin/edit-calendar.php +13 -110
  4. wp-calendar.php +17 -41
  5. wp-content/plugins/calendar.php +11 -321
README ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ------ Calendar for WordPress v1.0 ------
2
+
3
+ Author: Kieran O'Shea
4
+ E-Mail: kieran@kieranoshea.com
5
+ Website: http://www.kieranoshea.com
6
+
7
+ -----------------------------------------
8
+
9
+ Installing:
10
+
11
+ 1. Add the lines in the .htaccess file to the bottom of you pre-existing .htaccess
12
+ file in your WordPress root directory. Do not simply upload the file or else your
13
+ permalink and other mod_rewrite rules will be deleted and may cause your blog to
14
+ no longer function correctly.
15
+
16
+ 2. Upload the other included files into the same directories as they are in the package
17
+
18
+ 3. Visit the plugins page of your dashboard and activate Calendar 1.0 by Kieran O'Shea
19
+
20
+ 4. Visit Manage -> Calendar in the dashboard to initialise the database and start adding
21
+ calendar events into your system
22
+
23
+ 5. Visit your blog URL /calendar to see your calendar in action
24
+
25
+
26
+
27
+ Modifying the calendar page:
28
+
29
+ 1. You can modify the look and layout of the public calendar page by editing
30
+ wp-calendar.php
31
+
32
+
33
+
34
+ Removing the link to me:
35
+
36
+ 1. If you want to remove the text and link to my site from underneath the calendar you can
37
+ do so in the calendar.php file. Please only do this if you have to though as it will stop
38
+ other people from finding out how to get their own copy. You could always link to me in
39
+ your blogroll or in your site footer as an alternative if you prefer. Ultimately it's your
40
+ site however and if you don't want to link to me you are under no obligation to do so.
41
+
42
+
43
+
44
+ Uninstalling:
45
+
46
+ 1. Deactivate the plugin on the plugins page of your blog dashboard
47
+
48
+ 2. Delete the uploaded files for the plugin
49
+
50
+ 3. Remove the added lines from the .htaccess file
51
+
52
+ 4. Drop the wp_calendar table from your database
readme.txt DELETED
@@ -1,105 +0,0 @@
1
- === Calendar ===
2
- Contributors: KieranOShea
3
- Donate link: http://www.kieranoshea.com
4
- Tags: calendar, dates, times, events
5
- Requires at least: 2.0
6
- Tested up to: 2.1
7
- Stable tag: 1.1.2
8
-
9
- A simple but effective Calendar plugin for WordPress that allows you to
10
- manage your events and appointments and display them to the world.
11
-
12
- == Description ==
13
-
14
- A simple but effective Calendar plugin for WordPress that allows you to
15
- manage your events and appointments and display them to the world on your
16
- website.
17
-
18
- Features:
19
-
20
- * Monthly view of events
21
- * Mouse-over details for each event
22
- * Events can have a timestamp (optional)
23
- * Events can span more than one day
24
- * Multiple events per day possible
25
- * Events can repeat on a weekly, monthly or yearly basis
26
- * Repeats can occur indefinitely or a limited number of times
27
- * User and search friendly URL scheme
28
- * Easy to use events manager in admin dashboard
29
-
30
-
31
- == Installation ==
32
-
33
- The installation process is simple and only takes a few minutes. Please read
34
- these steps carefully though to ensure a trouble free install.
35
-
36
- Installing:
37
-
38
- 1. Ensure you have a permalink structure defined in your WordPress settings.
39
- You can do this by selecting the appropriate option in the WP admin panel
40
-
41
- Options -> Permalinks
42
-
43
- If you already have a permalink structure enabled, there is no need to
44
- enable it again
45
-
46
- 2. Once you have enabled permalinks, you should have a file called .htaccess
47
- in the root directory of your blog. Check it is there - this may be
48
- difficult on Windows due to the way files are displayed.
49
-
50
- 3. Add the following lines to your .htaccess file to enable the nice URLs
51
- the calendar uses. The calendar WILL NOT WORK properly without these lines!
52
-
53
- After the line containing:
54
- RewriteBase
55
-
56
- Add:
57
- RewriteRule ^calendar/([^/\.]+)/([^/\.]+)/?$ wp-calendar.php?year=$1&month=$2 [QSA,L]
58
- RewriteRule ^calendar/?$ wp-calendar.php [QSA,L]
59
-
60
- Save and upload the .htaccess file to your install.
61
-
62
- 4. Upload the other included files into the same directories as they are in
63
- the package
64
-
65
- 5. Visit the plugins page of your dashboard and activate Calendar 1.1.2 by
66
- Kieran O'Shea
67
-
68
- 6. Visit Manage -> Calendar in the dashboard to initialise the database and
69
- start adding calendar events into your system
70
-
71
- 7. Visit your blog URL /calendar to see your calendar in action
72
-
73
-
74
- Uninstalling:
75
-
76
- 1. Deactivate the plugin on the plugins page of your blog dashboard
77
-
78
- 2. Delete the uploaded files for the plugin
79
-
80
- 3. Remove the added lines from the .htaccess file
81
-
82
- 4. Drop the wp_calendar table from your database
83
-
84
- == Frequently Asked Questions ==
85
-
86
- = How do I modify the style and layout of the calendar page? =
87
-
88
- You can modify the look and layout of the public calendar page by editing
89
- wp-calendar.php Note the style block it contains and line of php calling
90
- the display of the actual calendar.
91
-
92
- = Can I removing the link to you? =
93
-
94
- If you want to remove the text and link to my site from underneath the
95
- calendar you can do so in the calendar.php file. Please only do this if
96
- you have to though as it will stop other people from finding out how to
97
- get their own copy. You could always link to me in your blogroll or in
98
- your site footer as an alternative if you prefer. Ultimately it's your
99
- site however and if you don't want to link to me you are under no
100
- obligation to do so.
101
-
102
- == Screenshots ==
103
-
104
- There are no screenshots available for the Calednar at this time, however you
105
- can get an idea of how it looks from the [Calendar on my site](http://www.kieranoshea.com/calendar "Personal Website of Kieran O'Shea")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wp-admin/edit-calendar.php CHANGED
@@ -2,8 +2,7 @@
2
  /*
3
  Author: Kieran O'Shea
4
  Author URI: http://www.kieranoshea.com
5
- Description: Admin panel for the calendar plugin
6
- Version: 1.1.2
7
  */
8
 
9
  require_once('admin.php');
@@ -72,10 +71,7 @@ if ( !$tableExists )
72
  `event_begin` DATE NOT NULL ,
73
  `event_end` DATE NOT NULL ,
74
  `event_title` VARCHAR(30) NOT NULL ,
75
- `event_desc` VARCHAR(255) NOT NULL ,
76
- `event_time` TIME ,
77
- `event_recur` CHAR(1) ,
78
- `event_repeats` INT(3) ,
79
  PRIMARY KEY ( `event_id` )
80
  )";
81
  $wpdb->get_results($sql);
@@ -99,10 +95,7 @@ if ( $action == 'add' )
99
  $title = !empty($_REQUEST['event_title']) ? $_REQUEST['event_title'] : '';
100
  $desc = !empty($_REQUEST['event_desc']) ? $_REQUEST['event_desc'] : '';
101
  $begin = !empty($_REQUEST['event_begin']) ? $_REQUEST['event_begin'] : '';
102
- $end = !empty($_REQUEST['event_end']) ? $_REQUEST['event_end'] : '';
103
- $time = !empty($_REQUEST['event_time']) ? $_REQUEST['event_time'] : '';
104
- $recur = !empty($_REQUEST['event_recur']) ? $_REQUEST['event_recur'] : '';
105
- $repeats = !empty($_REQUEST['event_repeats']) ? $_REQUEST['event_repeats'] : '';
106
 
107
  // Deal with the fools who have left magic quotes turned on
108
  if ( ini_get('magic_quotes_gpc') )
@@ -110,20 +103,17 @@ if ( $action == 'add' )
110
  $title = stripslashes($title);
111
  $desc = stripslashes($desc);
112
  $begin = stripslashes($begin);
113
- $end = stripslashes($end);
114
- $time = stripslashes($time);
115
- $recur = stripslashes($recur);
116
- $repeats = stripslashes($repeats);
117
  }
118
 
119
  $sql = "INSERT INTO " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
120
  . "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
121
- . "', event_end='" . mysql_escape_string($end) . "', event_time='" . mysql_escape_string($time) . "', event_recur='" . mysql_escape_string($recur) . "', event_repeats='" . mysql_escape_string($repeats) . "'";
122
 
123
  $wpdb->get_results($sql);
124
 
125
  $sql = "SELECT event_id FROM " . WP_CALENDAR_TABLE . " WHERE event_title='" . mysql_escape_string($title) . "'"
126
- . " AND event_desc='" . mysql_escape_string($desc) . "' AND event_begin='" . mysql_escape_string($begin) . "' AND event_end='" . mysql_escape_string($end) . "' AND event_recur='" . mysql_escape_string($recur) . "' AND event_repeats='" . mysql_escape_string($repeats) . "' LIMIT 1";
127
  $result = $wpdb->get_results($sql);
128
 
129
  if ( empty($result) || empty($result[0]->event_id) )
@@ -145,9 +135,6 @@ elseif ( $action == 'edit_save' )
145
  $desc = !empty($_REQUEST['event_desc']) ? $_REQUEST['event_desc'] : '';
146
  $begin = !empty($_REQUEST['event_begin']) ? $_REQUEST['event_begin'] : '';
147
  $end = !empty($_REQUEST['event_end']) ? $_REQUEST['event_end'] : '';
148
- $time = !empty($_REQUEST['event_time']) ? $_REQUEST['event_time'] : '';
149
- $recur = !empty($_REQUEST['event_recur']) ? $_REQUEST['event_recur'] : '';
150
- $repeats = !empty($_REQUEST['event_repeats']) ? $_REQUEST['event_repeats'] : '';
151
 
152
  // Deal with the fools who have left magic quotes turned on
153
  if ( ini_get('magic_quotes_gpc') )
@@ -155,10 +142,7 @@ elseif ( $action == 'edit_save' )
155
  $title = stripslashes($title);
156
  $desc = stripslashes($desc);
157
  $begin = stripslashes($begin);
158
- $end = stripslashes($end);
159
- $time = stripslashes($time);
160
- $recur = stripslashes($recur);
161
- $repeats = stripslashes($repeats);
162
  }
163
 
164
  if ( empty($event_id) )
@@ -171,12 +155,12 @@ elseif ( $action == 'edit_save' )
171
  {
172
  $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
173
  . "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
174
- . "', event_end='" . mysql_escape_string($end) . "', event_time='" . mysql_escape_string($time) . "', event_recur='" . mysql_escape_string($recur) . "', event_repeats='" . mysql_escape_string($repeats) . "'" . " WHERE event_id='" . mysql_escape_string($event_id) . "'";
175
 
176
  $wpdb->get_results($sql);
177
 
178
  $sql = "SELECT event_id FROM " . WP_CALENDAR_TABLE . " WHERE event_title='" . mysql_escape_string($title) . "'"
179
- . " AND event_desc='" . mysql_escape_string($desc) . "' AND event_begin='" . mysql_escape_string($begin) . "' AND event_end='" . mysql_escape_string($end) . "' AND event_recur='" . mysql_escape_string($recur) . "' AND event_repeats='" . mysql_escape_string($repeats) . "' LIMIT 1";
180
  $result = $wpdb->get_results($sql);
181
 
182
  if ( empty($result) || empty($result[0]->event_id) )
@@ -281,9 +265,7 @@ function wp_events_display_list()
281
  <th scope="col"><?php _e('Title') ?></th>
282
  <th scope="col"><?php _e('Description') ?></th>
283
  <th scope="col"><?php _e('Start Date') ?></th>
284
- <th scope="col"><?php _e('End Date') ?></th>
285
- <th scope="col"><?php _e('Recurs') ?></th>
286
- <th scope="col"><?php _e('Repeats') ?></th>
287
  <th scope="col"><?php _e('Edit') ?></th>
288
  <th scope="col"><?php _e('Delete') ?></th>
289
  </tr>
@@ -298,22 +280,7 @@ function wp_events_display_list()
298
  <td><?php echo $event->event_title; ?></td>
299
  <td><?php echo $event->event_desc; ?></td>
300
  <td><?php echo $event->event_begin; ?></td>
301
- <td><?php echo $event->event_end; ?></td>
302
- <td>
303
- <?php
304
- if ($event->event_recur == 'S') { echo 'Never'; }
305
- else if ($event->event_recur == 'W') { echo 'Weekly'; }
306
- else if ($event->event_recur == 'M') { echo 'Monthly'; }
307
- else if ($event->event_recur == 'Y') { echo 'Yearly'; }
308
- ?>
309
- </td>
310
- <td>
311
- <?php
312
- if ($event->event_recur == 'S') { echo 'N/A'; }
313
- else if ($event->event_repeats == 0) { echo 'Forever'; }
314
- else if ($event->event_repeats > 0) { echo $event->event_repeats.' Times'; }
315
- ?>
316
- </td>
317
  <td><a href="edit-calendar.php?action=edit&amp;event_id=<?php echo $event->event_id;?>" class='edit'><?php echo __('Edit'); ?></a></td>
318
  <td><a href="edit-calendar.php?action=delete&amp;event_id=<?php echo $event->event_id;?>" class="delete" onclick="return confirm('Are you sure you want to delete this event?')"><?php echo __('Delete'); ?></a></td>
319
  </tr>
@@ -387,7 +354,7 @@ function wp_events_edit_form($mode='add', $event_id=false)
387
  }
388
  else
389
  {
390
- echo date("Y-m-d");
391
  }
392
  ?>
393
  " />
@@ -403,73 +370,9 @@ function wp_events_edit_form($mode='add', $event_id=false)
403
  }
404
  else
405
  {
406
- echo date("Y-m-d");
407
- }
408
- ?>" />
409
- </fieldset>
410
-
411
- <fieldset class="small"><legend><?php _e('Time (optional, set blank if not required)'); ?></legend>
412
- <input type="text" name="event_time" class="input" size=12
413
- value="
414
- <?php
415
- if ( !empty($data) )
416
- {
417
- if ($data->event_time == "00:00:00")
418
- {
419
- echo '';
420
- }
421
- else
422
- {
423
- echo date("H:i",strtotime(htmlspecialchars($data->event_time)));
424
- }
425
- }
426
- else
427
- {
428
- echo date("H:i");
429
  }
430
  ?>" />
431
- </fieldset>
432
-
433
- <fieldset class="small"><legend><?php _e('Recurring Events: '); ?></legend>
434
- <?php
435
- if ($data->event_repeats != NULL)
436
- {
437
- $repeats = $data->event_repeats;
438
- }
439
- else
440
- {
441
- $repeats = 0;
442
- }
443
-
444
- if ($data->event_recur == "S")
445
- {
446
- $selected_s = 'selected="selected"';
447
- }
448
- else if ($data->event_recur == "W")
449
- {
450
- $selected_w = 'selected="selected"';
451
- }
452
- else if ($data->event_recur == "M")
453
- {
454
- $selected_m = 'selected="selected"';
455
- }
456
- else if ($data->event_recur == "Y")
457
- {
458
- $selected_y = 'selected="selected"';
459
- }
460
- ?>
461
- Repeats for
462
- <input type="text" name="event_repeats" class="input" size=1 value="
463
- <?php echo $repeats; ?>
464
- " />
465
- <select name="event_recur" class="input">
466
- <option class="input" <?php echo $selected_s; ?> value="S">None</option>
467
- <option class="input" <?php echo $selected_w; ?> value="W">Weeks</option>
468
- <option class="input" <?php echo $selected_m; ?> value="M">Months</option>
469
- <option class="input" <?php echo $selected_y; ?> value="Y">Years</option>
470
- </select><br />
471
- Entering 0 means forever. Where the recurrance interval <br />
472
- is left at none, the event will not reoccur.
473
  </fieldset>
474
  <br />
475
  <input type="submit" name="save" class="button bold" value="Save &raquo;" />
2
  /*
3
  Author: Kieran O'Shea
4
  Author URI: http://www.kieranoshea.com
5
+ Description: Admin panel for the calendar plugin
 
6
  */
7
 
8
  require_once('admin.php');
71
  `event_begin` DATE NOT NULL ,
72
  `event_end` DATE NOT NULL ,
73
  `event_title` VARCHAR(30) NOT NULL ,
74
+ `event_desc` VARCHAR(255) NOT NULL ,
 
 
 
75
  PRIMARY KEY ( `event_id` )
76
  )";
77
  $wpdb->get_results($sql);
95
  $title = !empty($_REQUEST['event_title']) ? $_REQUEST['event_title'] : '';
96
  $desc = !empty($_REQUEST['event_desc']) ? $_REQUEST['event_desc'] : '';
97
  $begin = !empty($_REQUEST['event_begin']) ? $_REQUEST['event_begin'] : '';
98
+ $end = !empty($_REQUEST['event_end']) ? $_REQUEST['event_end'] : '';
 
 
 
99
 
100
  // Deal with the fools who have left magic quotes turned on
101
  if ( ini_get('magic_quotes_gpc') )
103
  $title = stripslashes($title);
104
  $desc = stripslashes($desc);
105
  $begin = stripslashes($begin);
106
+ $end = stripslashes($end);
 
 
 
107
  }
108
 
109
  $sql = "INSERT INTO " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
110
  . "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
111
+ . "', event_end='" . mysql_escape_string($end) . "'";
112
 
113
  $wpdb->get_results($sql);
114
 
115
  $sql = "SELECT event_id FROM " . WP_CALENDAR_TABLE . " WHERE event_title='" . mysql_escape_string($title) . "'"
116
+ . " AND event_desc='" . mysql_escape_string($desc) . "' AND event_begin='" . mysql_escape_string($begin) . "' AND event_end='" . mysql_escape_string($end) . "' LIMIT 1";
117
  $result = $wpdb->get_results($sql);
118
 
119
  if ( empty($result) || empty($result[0]->event_id) )
135
  $desc = !empty($_REQUEST['event_desc']) ? $_REQUEST['event_desc'] : '';
136
  $begin = !empty($_REQUEST['event_begin']) ? $_REQUEST['event_begin'] : '';
137
  $end = !empty($_REQUEST['event_end']) ? $_REQUEST['event_end'] : '';
 
 
 
138
 
139
  // Deal with the fools who have left magic quotes turned on
140
  if ( ini_get('magic_quotes_gpc') )
142
  $title = stripslashes($title);
143
  $desc = stripslashes($desc);
144
  $begin = stripslashes($begin);
145
+ $end = stripslashes($end);
 
 
 
146
  }
147
 
148
  if ( empty($event_id) )
155
  {
156
  $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
157
  . "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
158
+ . "', event_end='" . mysql_escape_string($end) . "'" . " WHERE event_id='" . mysql_escape_string($event_id) . "'";
159
 
160
  $wpdb->get_results($sql);
161
 
162
  $sql = "SELECT event_id FROM " . WP_CALENDAR_TABLE . " WHERE event_title='" . mysql_escape_string($title) . "'"
163
+ . " AND event_desc='" . mysql_escape_string($desc) . "' AND event_begin='" . mysql_escape_string($begin) . "' AND event_end='" . mysql_escape_string($end) . "' LIMIT 1";
164
  $result = $wpdb->get_results($sql);
165
 
166
  if ( empty($result) || empty($result[0]->event_id) )
265
  <th scope="col"><?php _e('Title') ?></th>
266
  <th scope="col"><?php _e('Description') ?></th>
267
  <th scope="col"><?php _e('Start Date') ?></th>
268
+ <th scope="col"><?php _e('End Date') ?></th>
 
 
269
  <th scope="col"><?php _e('Edit') ?></th>
270
  <th scope="col"><?php _e('Delete') ?></th>
271
  </tr>
280
  <td><?php echo $event->event_title; ?></td>
281
  <td><?php echo $event->event_desc; ?></td>
282
  <td><?php echo $event->event_begin; ?></td>
283
+ <td><?php echo $event->event_end; ?></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  <td><a href="edit-calendar.php?action=edit&amp;event_id=<?php echo $event->event_id;?>" class='edit'><?php echo __('Edit'); ?></a></td>
285
  <td><a href="edit-calendar.php?action=delete&amp;event_id=<?php echo $event->event_id;?>" class="delete" onclick="return confirm('Are you sure you want to delete this event?')"><?php echo __('Delete'); ?></a></td>
286
  </tr>
354
  }
355
  else
356
  {
357
+ echo date("Y-m-j");
358
  }
359
  ?>
360
  " />
370
  }
371
  else
372
  {
373
+ echo date("Y-m-j");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
374
  }
375
  ?>" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  </fieldset>
377
  <br />
378
  <input type="submit" name="save" class="button bold" value="Save &raquo;" />
wp-calendar.php CHANGED
@@ -1,53 +1,29 @@
1
  <?php
2
  /*
3
- Plugin Name: Calendar
4
- Plugin URI: http://www.kieranoshea.com/programming
5
- Description: This plugin allows you to display a calendar of all your events an\d appointments as a page on your site.
6
- Author: Kieran O'Shea
7
- Version: 1.1.2
8
- Author URI: http://www.kieranoshea.com
9
  */
10
 
11
- // Require the standard WordPress header
 
12
  require(dirname(__FILE__).'/wp-blog-header.php');
13
 
 
 
 
 
 
 
14
  // Begin content of page
15
 
16
- get_header();
17
  ?>
18
-
19
- <style type="text/css">
20
- span.calnk a {
21
- text-decoration:none;
22
- color:#000000;
23
- border-bottom:1px dotted #000000;
24
- }
25
- span.calnk a:hover {
26
- text-decoration:none;
27
- color:#000000;
28
- border-bottom:1px dotted #000000;
29
- }
30
- span.calnk {
31
- position:relative;
32
- }
33
- span.calnk a span {
34
- display:none;
35
- }
36
- span.calnk a:hover span {
37
- color:#333333;
38
- background:#F6F79B;
39
- display:block;
40
- position:absolute;
41
- margin-top:1px;
42
- padding:5px;
43
- width:150px;
44
- z-index:100;
45
- }
46
- </style>
47
-
48
  <h2>Calendar</h2>
49
-
50
- <?php echo calendar(); ?>
51
 
52
  <?php get_sidebar(); ?>
53
- <?php get_footer(); ?>
1
  <?php
2
  /*
3
+ Calendar v1.0 for WordPress
4
+ Author: Kieran O'Shea
5
+ E-Mail: kieran@kieranoshea.com
6
+ Website: http://www.kieranoshea.com
 
 
7
  */
8
 
9
+
10
+ ### Require the standard WordPress header
11
  require(dirname(__FILE__).'/wp-blog-header.php');
12
 
13
+ ### Get the title right
14
+ add_filter('wp_title', 'calendar_pagetitle');
15
+ function allquotes_pagetitle($calendar_pagetitle) {
16
+ return ' &raquo; Calendar';
17
+ }
18
+
19
  // Begin content of page
20
 
21
+ get_header();
22
  ?>
23
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  <h2>Calendar</h2>
25
+
26
+ <?php echo calendar(); ?>
27
 
28
  <?php get_sidebar(); ?>
29
+ <?php get_footer(); ?>
wp-content/plugins/calendar.php CHANGED
@@ -5,10 +5,10 @@ Plugin URI: http://www.kieranoshea.com/
5
  Description: This plugin allows you to display a calendar of all your events and appointments as a page on your site.
6
  Author: Kieran O'Shea
7
  Author URI: http://www.kieranoshea.com
8
- Version: 1.1.2
9
  */
10
 
11
- // Define the table for the plugin.
12
  define('WP_CALENDAR_TABLE', $table_prefix . 'calendar');
13
 
14
  // Puts the events management link under manage
@@ -30,13 +30,13 @@ add_action('admin_menu', 'wp_events_admin_menu');
30
 
31
  if ($cur_month == 12)
32
  {
33
- return '<a href="' . get_bloginfo('wpurl') . '/calendar/' . $next_year . '/jan">Next &raquo;</a>';
34
  }
35
  else
36
  {
37
  $next_month = $cur_month + 1;
38
  $month = $mod_rewrite_months[$next_month];
39
- return '<a href="' . get_bloginfo('wpurl') . '/calendar/' . $cur_year . '/' . $month . '">Next &raquo;</a>';
40
  }
41
  }
42
 
@@ -48,13 +48,13 @@ add_action('admin_menu', 'wp_events_admin_menu');
48
 
49
  if ($cur_month == 1)
50
  {
51
- return '<a href="' . get_bloginfo('wpurl') . '/calendar/'. $last_year .'/dec">&laquo; Prev</a>';
52
  }
53
  else
54
  {
55
  $next_month = $cur_month - 1;
56
  $month = $mod_rewrite_months[$next_month];
57
- return '<a href="' . get_bloginfo('wpurl') . '/calendar/' . $cur_year . '/' . $month . '">&laquo; Prev</a>';
58
  }
59
  }
60
 
@@ -62,325 +62,15 @@ add_action('admin_menu', 'wp_events_admin_menu');
62
  {
63
  global $wpdb;
64
  $date = $y . '-' . $m . '-' . $d;
65
- $output = '';
66
-
67
- // Firstly we check for conventional events. These will form the first instance of a recurring event
68
- // or the only instance of a one-off event
69
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_begin <= '$date' AND event_end >= '$date' AND event_recur = 'S' ORDER BY event_id");
70
  if (!empty($events))
71
  {
72
  foreach($events as $event)
73
- {
74
- if ($event->event_time == "00:00:00")
75
- {
76
- $event_time = '';
77
- }
78
- else
79
- {
80
- $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
81
- }
82
- //$output .= '<br />* <a style="color:#333333; border-bottom: 1px dotted #333333;" title="' . $event_time . $event->event_desc . '">' . $event->event_title . '</a>';
83
- $output .= '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
84
  }
85
- }
86
-
87
- // Even if there were results for that query, we may still have events recurring
88
- // from the past on this day. We now methodically check the for these events
89
-
90
- /*
91
- The yearly code - easy because the day and month will be the same, so we return all yearly
92
- events that match the date part. Out of these we show those with a repeat of 0, and fast-foward
93
- a number of years for those with a value more than 0. Those that land in the future are displayed.
94
- */
95
-
96
-
97
- // Deal with forever recurring year events
98
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'Y' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats = 0 ORDER BY event_id");
99
-
100
- if (!empty($events))
101
- {
102
- foreach($events as $event)
103
- {
104
- // This is going to get complex so lets setup what we would place in for
105
- // an event so we can drop it in with ease
106
- if ($event->event_time == "00:00:00")
107
- {
108
- $event_time = '';
109
- }
110
- else
111
- {
112
- $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
113
- }
114
- $event_out = '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
115
-
116
- // Technically we don't care about the years, but we need to find out if the
117
- // event spans the turn of a year so we can deal with it appropriately.
118
- $year_begin = date('Y',strtotime($event->event_begin));
119
- $year_end = date('Y',strtotime($event->event_end));
120
-
121
- if ($year_begin == $year_end)
122
- {
123
- if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) &&
124
- date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
125
- {
126
- $output .= $event_out;
127
- }
128
- }
129
- else if ($year_begin < $year_end)
130
- {
131
- if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) ||
132
- date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
133
- {
134
- $output .= $event_out;
135
- }
136
- }
137
- }
138
- }
139
-
140
- // Now the ones that happen a finite number of times
141
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'Y' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats != 0 AND (EXTRACT(YEAR FROM '$date')-EXTRACT(YEAR FROM event_begin)) <= event_repeats ORDER BY event_id");
142
- if (!empty($events))
143
- {
144
- foreach($events as $event)
145
- {
146
- // This is going to get complex so lets setup what we would place in for
147
- // an event so we can drop it in with ease
148
- if ($event->event_time == "00:00:00")
149
- {
150
- $event_time = '';
151
- }
152
- else
153
- {
154
- $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
155
- }
156
- $event_out = '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
157
-
158
- // Technically we don't care about the years, but we need to find out if the
159
- // event spans the turn of a year so we can deal with it appropriately.
160
- $year_begin = date('Y',strtotime($event->event_begin));
161
- $year_end = date('Y',strtotime($event->event_end));
162
-
163
- if ($year_begin == $year_end)
164
- {
165
- if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) &&
166
- date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
167
- {
168
- $output .= $event_out;
169
- }
170
- }
171
- else if ($year_begin < $year_end)
172
- {
173
- if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) ||
174
- date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
175
- {
176
- $output .= $event_out;
177
- }
178
- }
179
- }
180
- }
181
-
182
- /*
183
- The monthly code - just as easy because as long as the day of the month is correct, then we
184
- show the event
185
- */
186
-
187
- // The monthly events that never stop recurring
188
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'M' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats = 0 ORDER BY event_id");
189
- if (!empty($events))
190
- {
191
- foreach($events as $event)
192
- {
193
- // This is going to get complex so lets setup what we would place in for
194
- // an event so we can drop it in with ease
195
- if ($event->event_time == "00:00:00")
196
- {
197
- $event_time = '';
198
- }
199
- else
200
- {
201
- $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
202
- }
203
- $event_out = '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
204
-
205
- // Technically we don't care about the years or months, but we need to find out if the
206
- // event spans the turn of a year or month so we can deal with it appropriately.
207
- $month_begin = date('m',strtotime($event->event_begin));
208
- $month_end = date('m',strtotime($event->event_end));
209
-
210
- if ($month_begin == $month_end)
211
- {
212
- if (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) &&
213
- date('d',strtotime($event->event_end)) >= date('d',strtotime($date)))
214
- {
215
- $output .= $event_out;
216
- }
217
- }
218
- else if ($month_begin < $month_end)
219
- {
220
- if ( ($event->event_begin <= date('Y-m-d',strtotime($date))) && (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) ||
221
- date('d',strtotime($event->event_end)) >= date('d',strtotime($date))) )
222
- {
223
- $output .= $event_out;
224
- }
225
- }
226
- }
227
- }
228
-
229
-
230
- // Now the ones that happen a finite number of times
231
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'M' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats != 0 AND (PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM '$date'),EXTRACT(YEAR_MONTH FROM event_begin))) <= event_repeats ORDER BY event_id");
232
- if (!empty($events))
233
- {
234
- foreach($events as $event)
235
- {
236
- // This is going to get complex so lets setup what we would place in for
237
- // an event so we can drop it in with ease
238
- if ($event->event_time == "00:00:00")
239
- {
240
- $event_time = '';
241
- }
242
- else
243
- {
244
- $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
245
- }
246
- $event_out = '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
247
-
248
- // Technically we don't care about the years or months, but we need to find out if the
249
- // event spans the turn of a year or month so we can deal with it appropriately.
250
- $month_begin = date('m',strtotime($event->event_begin));
251
- $month_end = date('m',strtotime($event->event_end));
252
-
253
- if ($month_begin == $month_end)
254
- {
255
- if (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) &&
256
- date('d',strtotime($event->event_end)) >= date('d',strtotime($date)))
257
- {
258
- $output .= $event_out;
259
- }
260
- }
261
- else if ($month_begin < $month_end)
262
- {
263
- if ( ($event->event_begin <= date('Y-m-d',strtotime($date))) && (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) ||
264
- date('d',strtotime($event->event_end)) >= date('d',strtotime($date))) )
265
- {
266
- $output .= $event_out;
267
- }
268
- }
269
- }
270
- }
271
-
272
-
273
- /*
274
- Weekly - well isn't this fun! We need to scan all weekly events, find what day they fell on
275
- and see if that matches the current day. If it does, we check to see if the repeats are 0.
276
- If they are, display the event, if not, we fast forward from the original day in week blocks
277
- until the number is exhausted. If the date we arrive at is in the future, display the event.
278
- */
279
-
280
- // The weekly events that never stop recurring
281
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'W' AND '$date' >= event_begin AND event_repeats = 0 ORDER BY event_id");
282
- if (!empty($events))
283
- {
284
- foreach($events as $event)
285
- {
286
- // This is going to get complex so lets setup what we would place in for
287
- // an event so we can drop it in with ease
288
- if ($event->event_time == "00:00:00")
289
- {
290
- $event_time = '';
291
- }
292
- else
293
- {
294
- $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
295
- }
296
- $event_out = '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
297
-
298
- // Now we are going to check to see what day the original event
299
- // fell on and see if the current date is both after it and on
300
- // the correct day. If it is, display the event!
301
- $day_start_event = date('D',strtotime($event->event_begin));
302
- $day_end_event = date('D',strtotime($event->event_end));
303
- $current_day = date('D',strtotime($date));
304
-
305
- $plan = array();
306
- $plan['Mon'] = 1;
307
- $plan['Tue'] = 2;
308
- $plan['Wed'] = 3;
309
- $plan['Thu'] = 4;
310
- $plan['Fri'] = 5;
311
- $plan['Sat'] = 6;
312
- $plan['Sun'] = 7;
313
-
314
- if ($plan[$day_start_event] > $plan[$day_end_event])
315
- {
316
- if (($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event]))
317
- {
318
- $output .= $event_out;
319
- }
320
- }
321
- else if (($plan[$day_start_event] < $plan[$day_end_event]) || ($plan[$day_start_event]== $plan[$day_end_event]))
322
- {
323
- if (($plan[$day_start_event] <= $plan[$current_day]) && ($plan[$current_day] <= $plan[$day_end_event]))
324
- {
325
- $output .= $event_out;
326
- }
327
- }
328
-
329
- }
330
- }
331
-
332
- // The weekly events that have a limit on how many times they occur
333
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'W' AND '$date' >= event_begin AND event_repeats != 0 AND (event_repeats*7) >= (TO_DAYS('$date') - TO_DAYS(event_end)) ORDER BY event_id");
334
- if (!empty($events))
335
- {
336
- foreach($events as $event)
337
- {
338
- // This is going to get complex so lets setup what we would place in for
339
- // an event so we can drop it in with ease
340
- if ($event->event_time == "00:00:00")
341
- {
342
- $event_time = '';
343
- }
344
- else
345
- {
346
- $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
347
- }
348
- $event_out = '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
349
-
350
- // Now we are going to check to see what day the original event
351
- // fell on and see if the current date is both after it and on
352
- // the correct day. If it is, display the event!
353
- $day_start_event = date('D',strtotime($event->event_begin));
354
- $day_end_event = date('D',strtotime($event->event_end));
355
- $current_day = date('D',strtotime($date));
356
-
357
- $plan = array();
358
- $plan['Mon'] = 1;
359
- $plan['Tue'] = 2;
360
- $plan['Wed'] = 3;
361
- $plan['Thu'] = 4;
362
- $plan['Fri'] = 5;
363
- $plan['Sat'] = 6;
364
- $plan['Sun'] = 7;
365
-
366
- if ($plan[$day_start_event] > $plan[$day_end_event])
367
- {
368
- if (($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event]))
369
- {
370
- $output .= $event_out;
371
- }
372
- }
373
- else if (($plan[$day_start_event] < $plan[$day_end_event]) || ($plan[$day_start_event]== $plan[$day_end_event]))
374
- {
375
- if (($plan[$day_start_event] <= $plan[$current_day]) && ($plan[$current_day] <= $plan[$day_end_event]))
376
- {
377
- $output .= $event_out;
378
- }
379
- }
380
-
381
- }
382
- }
383
-
384
  return $output;
385
  }
386
 
5
  Description: This plugin allows you to display a calendar of all your events and appointments as a page on your site.
6
  Author: Kieran O'Shea
7
  Author URI: http://www.kieranoshea.com
8
+ Version: 1.0
9
  */
10
 
11
+ // Quotes table. I suppose you could change this.
12
  define('WP_CALENDAR_TABLE', $table_prefix . 'calendar');
13
 
14
  // Puts the events management link under manage
30
 
31
  if ($cur_month == 12)
32
  {
33
+ return '<a href="/calendar/' . $next_year . '/jan">Next &raquo;</a>';
34
  }
35
  else
36
  {
37
  $next_month = $cur_month + 1;
38
  $month = $mod_rewrite_months[$next_month];
39
+ return '<a href="/calendar/' . $cur_year . '/' . $month . '">Next &raquo;</a>';
40
  }
41
  }
42
 
48
 
49
  if ($cur_month == 1)
50
  {
51
+ return '<a href="/calendar/'. $last_year .'/dec">&laquo; Prev</a>';
52
  }
53
  else
54
  {
55
  $next_month = $cur_month - 1;
56
  $month = $mod_rewrite_months[$next_month];
57
+ return '<a href="/calendar/' . $cur_year . '/' . $month . '">&laquo; Prev</a>';
58
  }
59
  }
60
 
62
  {
63
  global $wpdb;
64
  $date = $y . '-' . $m . '-' . $d;
65
+ $output = '';
66
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_begin <= '$date' AND event_end >= '$date' ORDER BY event_id");
 
 
 
67
  if (!empty($events))
68
  {
69
  foreach($events as $event)
70
+ {
71
+ $output .= '<br />* <a style="color:#333333; border-bottom: 1px dotted #333333;" title="' . $event->event_desc . '">' . $event->event_title . '</a>';
 
 
 
 
 
 
 
 
 
72
  }
73
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  return $output;
75
  }
76