Calendar - Version 1.3.12

Version Description

  • Removed ability to access PHP files directly
  • Change import of admin CSS and JS to enqueue
  • Removed an erroneous direct reference to the wp-content directory
  • Enhance sanitisation of some admin side user input
  • Ensure all functions are prefixed with plugin name to avoid clashes with other plugins
  • Fixed some bugs with short codes and updated the documentation surrounding these and changed function names
Download this release

Release Info

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

Code changes from version 1.3.11 to 1.3.12

Files changed (4) hide show
  1. calendar-admin.css +155 -0
  2. calendar-feed.php +4 -1
  3. calendar.php +180 -420
  4. readme.txt +31 -12
calendar-admin.css ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .bcal-container{
2
+ background-color: #fff;
3
+ border-radius: 4px;
4
+ -moz-border-radius: 4px;
5
+ -webkit-border-radius: 4px;
6
+ float: left;
7
+ padding: 5px;
8
+ border: solid 1px #ccc;
9
+ box-shadow: 0 0 3px #C0C0C0;
10
+ }
11
+ .bcal-table{
12
+ border-collapse: separate;
13
+ border-spacing: 0;
14
+ border: solid 1px #A2A6AF;
15
+ font-family: Tahoma, sans-serif;
16
+ font-size: 11px;
17
+ font-weight: normal;
18
+ float: left;
19
+ margin: 1px;
20
+ padding: 0;
21
+ width: 200px;
22
+ }
23
+ .bcal-table,
24
+ .bcal-table th,
25
+ .bcal-table td {
26
+ box-sizing: border-box;
27
+ -moz-box-sizing: border-box;
28
+ -webkit-box-sizing: border-box;
29
+ }
30
+ .bcal-table thead tr{
31
+ background-color: #CECED2;
32
+ border: 1px solid #A2A6AF;
33
+ background-image: linear-gradient(bottom, rgb(206,206,210) 37%, rgb(241,240,242) 69%);
34
+ background-image: -o-linear-gradient(bottom, rgb(206,206,210) 37%, rgb(241,240,242) 69%);
35
+ background-image: -moz-linear-gradient(bottom, rgb(206,206,210) 37%, rgb(241,240,242) 69%);
36
+ background-image: -webkit-linear-gradient(bottom, rgb(206,206,210) 37%, rgb(241,240,242) 69%);
37
+ background-image: -ms-linear-gradient(bottom, rgb(206,206,210) 37%, rgb(241,240,242) 69%);
38
+ background-image: -webkit-gradient(
39
+ linear,
40
+ left bottom,
41
+ left top,
42
+ color-stop(0.37, rgb(206,206,210)),
43
+ color-stop(0.69, rgb(241,240,242))
44
+ );
45
+ }
46
+ .bcal-table thead tr:first-child{
47
+ line-height: 23px;
48
+ }
49
+ .bcal-table thead th{
50
+ font-weight: bold;
51
+ color: #404D5D;
52
+ height: 20px;
53
+ text-align: center;
54
+ }
55
+ .bcal-table tbody td{
56
+ color: #3B4959;
57
+ cursor: pointer;
58
+ font-weight: normal;
59
+ height: 25px;
60
+ padding: 0 0 1px 1px;
61
+ width: 25px;
62
+ text-align: center;
63
+ }
64
+ .bcal-table tbody tr:first-child td{
65
+ border-top: solid 1px #fff;
66
+ }
67
+ .bcal-table tbody td:first-child{
68
+ border-left: none;
69
+ padding: 0 0 1px;
70
+ }
71
+ .bcal-table .bcal-wday,
72
+ .bcal-table .bcal-wnum{
73
+ font-weight: normal;
74
+ border-right: 1px solid #A2A6AF;
75
+ border-top: 1px solid #A2A6AF;
76
+ border-bottom: 1px solid #A2A6AF;
77
+ padding: 1px 1px 2px 2px;
78
+ }
79
+ .bcal-table .bcal-wnum{
80
+ border-right: 1px solid #A2A6AF;
81
+ border-bottom: 1px solid #A2A6AF;
82
+ color: #CC6600;
83
+ background-image: linear-gradient(bottom, rgb(255,225,159) 23%, rgb(255,250,234) 62%);
84
+ background-image: -o-linear-gradient(bottom, rgb(255,225,159) 23%, rgb(255,250,234) 62%);
85
+ background-image: -moz-linear-gradient(bottom, rgb(255,225,159) 23%, rgb(255,250,234) 62%);
86
+ background-image: -webkit-linear-gradient(bottom, rgb(255,225,159) 23%, rgb(255,250,234) 62%);
87
+ background-image: -ms-linear-gradient(bottom, rgb(255,225,159) 23%, rgb(255,250,234) 62%);
88
+ background-image: -webkit-gradient(
89
+ linear,
90
+ left bottom,
91
+ left top,
92
+ color-stop(0.23, rgb(255,225,159)),
93
+ color-stop(0.62, rgb(255,250,234))
94
+ );
95
+ }
96
+ .bcal-table .bcal-wday:last-child{
97
+ border-right: none;
98
+ }
99
+ .bcal-table .bcal-empty{
100
+ background-color: #F6F6F7;
101
+ border-right: solid 1px #fff;
102
+ border-bottom: solid 1px #fff;
103
+ color: #999;
104
+ cursor: default;
105
+ }
106
+ .bcal-table tr:last-child .bcal-empty,
107
+ .bcal-table tr:last-child .bcal-week,
108
+ .bcal-table tr:last-child .bcal-date{
109
+ border-bottom: none;
110
+ }
111
+ .bcal-table .bcal-date{
112
+ border-right: solid 1px #fff;
113
+ border-bottom: solid 1px #fff;
114
+ background-color: #ECECEE;
115
+ }
116
+ .bcal-table .bcal-past{
117
+ background-color: #e6e6e6;
118
+ color: #999;
119
+ cursor: default;
120
+ }
121
+ .bcal-table .bcal-today{
122
+ background-color: #D6D6D1;
123
+ color: #333;
124
+ }
125
+ .bcal-table .bcal-week{
126
+ background-color: #FEF3DA;
127
+ border-right: solid 1px #fff;
128
+ border-bottom: solid 1px #fff;
129
+ color: #CC6600;
130
+ cursor: default;
131
+ }
132
+ .bcal-table .bcal-selected{
133
+ background-color: #BDBDBD;
134
+ color: #F2F2F2;
135
+ }
136
+ .bcal-table .bcal-over,
137
+ .bcal-table .bcal-date:hover{
138
+ background-color: #B2B2A9;
139
+ color: #fff;
140
+ }
141
+ .bcal-table .bcal-date:last-child,
142
+ .bcal-table .bcal-empty:last-child{
143
+ border-right: none;
144
+ }
145
+ .bcal-table .bcal-past:hover{
146
+ background-color: #e0e0e0;
147
+ color: #666;
148
+ }
149
+ .bcal-table .bcal-month,
150
+ .bcal-table .bcal-navi,
151
+ .bcal-table .bcal-wnum,
152
+ .bcal-table .bcal-wday,
153
+ .bcal-table .bcal-week{
154
+ cursor: text;
155
+ }
calendar-feed.php CHANGED
@@ -16,6 +16,9 @@
16
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
  */
18
 
 
 
 
19
  // Should we allow the feed to go out?
20
  $sql = "SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='enable_feed'";
21
  $feed_yes = $wpdb->get_var($sql);
@@ -52,7 +55,7 @@ END:VTIMEZONE
52
  // Craft our days into the future with the current one as a reference, get the eligible event on that day
53
  list($y,$m,$d) = explode("-",date("Y-m-d",mktime($day_count*24,0,0,date("m"),date("d"),date("Y"))));
54
  $events = grab_events($y,$m,$d,null);
55
- usort($events, "time_cmp");
56
 
57
  // Iterate through the events list and define a iCalendar VEVENT for each
58
  foreach($events as $event) {
16
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
  */
18
 
19
+ // Direct access shouldn't be allowed
20
+ if ( ! defined( 'ABSPATH' ) ) exit;
21
+
22
  // Should we allow the feed to go out?
23
  $sql = "SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='enable_feed'";
24
  $feed_yes = $wpdb->get_var($sql);
55
  // Craft our days into the future with the current one as a reference, get the eligible event on that day
56
  list($y,$m,$d) = explode("-",date("Y-m-d",mktime($day_count*24,0,0,date("m"),date("d"),date("Y"))));
57
  $events = grab_events($y,$m,$d,null);
58
+ usort($events, "calendar_time_cmp");
59
 
60
  // Iterate through the events list and define a iCalendar VEVENT for each
61
  foreach($events as $event) {
calendar.php CHANGED
@@ -7,7 +7,7 @@ Author: Kieran O'Shea
7
  Author URI: http://www.kieranoshea.com
8
  Text Domain: calendar
9
  Domain Path: /languages
10
- Version: 1.3.11
11
  */
12
 
13
  /* Copyright 2008 Kieran O'Shea (email : kieran@kieranoshea.com)
@@ -27,6 +27,9 @@ Version: 1.3.11
27
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
  */
29
 
 
 
 
30
  // Enable internationalisation
31
  $plugin_dir = plugin_basename(dirname(__FILE__));
32
  load_plugin_textdomain( 'calendar',false, $plugin_dir.'/languages');
@@ -39,24 +42,25 @@ define('WP_CALENDAR_CATEGORIES_TABLE', $wpdb->prefix . 'calendar_categories');
39
 
40
  // Check ensure calendar is installed and install it if not - required for
41
  // the successful operation of most functions called from this point on
42
- check_calendar();
43
 
44
  // Create a master category for Calendar and its sub-pages
 
45
  add_action('admin_menu', 'calendar_menu');
46
 
47
  // Enable the ability for the calendar to be loaded from pages
48
  add_filter('the_content','calendar_insert');
49
- add_filter('the_content','minical_insert');
50
 
51
  // Enable the ability for the lists to be loaded from pages
52
- add_filter('the_content','upcoming_insert');
53
- add_filter('the_content','todays_insert');
54
 
55
  // Add the function that puts style information in the header
56
  add_action('wp_head', 'calendar_wp_head');
57
 
58
  // Add the function that deals with deleted users
59
- add_action('delete_user', 'deal_with_deleted_user');
60
 
61
  // Add the widgets if we are using version 2.8
62
  add_action('widgets_init', 'widget_init_calendar_today');
@@ -93,7 +97,7 @@ function calendar_feed_parse_request( &$wp )
93
  }
94
 
95
  // Function to deal with events posted by a user when that user is deleted
96
- function deal_with_deleted_user($id)
97
  {
98
  global $wpdb;
99
 
@@ -116,7 +120,7 @@ function calendar_setup_incomplete_warning() {
116
  }
117
 
118
  // Function to provide time with WordPress offset, localy replaces time()
119
- function ctwo()
120
  {
121
  return (time()+(3600*(get_option('gmt_offset'))));
122
  }
@@ -159,182 +163,22 @@ function calendar_menu()
159
  // Add the admin panel pages for Calendar. Use permissions pulled from above
160
  if (function_exists('add_menu_page'))
161
  {
162
- add_menu_page(__('Calendar','calendar'), __('Calendar','calendar'), $allowed_group, 'calendar', 'edit_calendar');
163
  }
164
  if (function_exists('add_submenu_page'))
165
  {
166
- $calendar_manage_menu = add_submenu_page('calendar', __('Manage Calendar','calendar'), __('Manage Calendar','calendar'), $allowed_group, 'calendar', 'edit_calendar');
167
- add_action( "admin_head-".$calendar_manage_menu, 'calendar_add_javascript' );
168
  // Note only admin can change calendar options
169
- add_submenu_page('calendar', __('Manage Categories','calendar'), __('Manage Categories','calendar'), 'manage_options', 'calendar-categories', 'manage_categories');
170
- add_submenu_page('calendar', __('Calendar Config','calendar'), __('Calendar Options','calendar'), 'manage_options', 'calendar-config', 'edit_calendar_config');
171
  }
172
  }
173
 
174
  // Function to add the javascript to the admin header
175
  function calendar_add_javascript()
176
- {
177
- echo '<script type="text/javascript" src="';
178
- bloginfo('wpurl');
179
- echo '/wp-content/plugins/calendar/javascript.js"></script>
180
- <style type="text/css">
181
- .bcal-container{
182
- background-color: #fff;
183
- border-radius: 4px;
184
- -moz-border-radius: 4px;
185
- -webkit-border-radius: 4px;
186
- float: left;
187
- padding: 5px;
188
- border: solid 1px #ccc;
189
- box-shadow: 0 0 3px #C0C0C0;
190
- }
191
- .bcal-table{
192
- border-collapse: separate;
193
- border-spacing: 0;
194
- border: solid 1px #A2A6AF;
195
- font-family: Tahoma, sans-serif;
196
- font-size: 11px;
197
- font-weight: normal;
198
- float: left;
199
- margin: 1px;
200
- padding: 0;
201
- width: 200px;
202
- }
203
- .bcal-table,
204
- .bcal-table th,
205
- .bcal-table td {
206
- box-sizing: border-box;
207
- -moz-box-sizing: border-box;
208
- -webkit-box-sizing: border-box;
209
- }
210
- .bcal-table thead tr{
211
- background-color: #CECED2;
212
- border: 1px solid #A2A6AF;
213
- background-image: linear-gradient(bottom, rgb(206,206,210) 37%, rgb(241,240,242) 69%);
214
- background-image: -o-linear-gradient(bottom, rgb(206,206,210) 37%, rgb(241,240,242) 69%);
215
- background-image: -moz-linear-gradient(bottom, rgb(206,206,210) 37%, rgb(241,240,242) 69%);
216
- background-image: -webkit-linear-gradient(bottom, rgb(206,206,210) 37%, rgb(241,240,242) 69%);
217
- background-image: -ms-linear-gradient(bottom, rgb(206,206,210) 37%, rgb(241,240,242) 69%);
218
- background-image: -webkit-gradient(
219
- linear,
220
- left bottom,
221
- left top,
222
- color-stop(0.37, rgb(206,206,210)),
223
- color-stop(0.69, rgb(241,240,242))
224
- );
225
- }
226
- .bcal-table thead tr:first-child{
227
- line-height: 23px;
228
- }
229
- .bcal-table thead th{
230
- font-weight: bold;
231
- color: #404D5D;
232
- height: 20px;
233
- text-align: center;
234
- }
235
- .bcal-table tbody td{
236
- color: #3B4959;
237
- cursor: pointer;
238
- font-weight: normal;
239
- height: 25px;
240
- padding: 0 0 1px 1px;
241
- width: 25px;
242
- text-align: center;
243
- }
244
- .bcal-table tbody tr:first-child td{
245
- border-top: solid 1px #fff;
246
- }
247
- .bcal-table tbody td:first-child{
248
- border-left: none;
249
- padding: 0 0 1px;
250
- }
251
- .bcal-table .bcal-wday,
252
- .bcal-table .bcal-wnum{
253
- font-weight: normal;
254
- border-right: 1px solid #A2A6AF;
255
- border-top: 1px solid #A2A6AF;
256
- border-bottom: 1px solid #A2A6AF;
257
- padding: 1px 1px 2px 2px;
258
- }
259
- .bcal-table .bcal-wnum{
260
- border-right: 1px solid #A2A6AF;
261
- border-bottom: 1px solid #A2A6AF;
262
- color: #CC6600;
263
- background-image: linear-gradient(bottom, rgb(255,225,159) 23%, rgb(255,250,234) 62%);
264
- background-image: -o-linear-gradient(bottom, rgb(255,225,159) 23%, rgb(255,250,234) 62%);
265
- background-image: -moz-linear-gradient(bottom, rgb(255,225,159) 23%, rgb(255,250,234) 62%);
266
- background-image: -webkit-linear-gradient(bottom, rgb(255,225,159) 23%, rgb(255,250,234) 62%);
267
- background-image: -ms-linear-gradient(bottom, rgb(255,225,159) 23%, rgb(255,250,234) 62%);
268
- background-image: -webkit-gradient(
269
- linear,
270
- left bottom,
271
- left top,
272
- color-stop(0.23, rgb(255,225,159)),
273
- color-stop(0.62, rgb(255,250,234))
274
- );
275
- }
276
- .bcal-table .bcal-wday:last-child{
277
- border-right: none;
278
- }
279
- .bcal-table .bcal-empty{
280
- background-color: #F6F6F7;
281
- border-right: solid 1px #fff;
282
- border-bottom: solid 1px #fff;
283
- color: #999;
284
- cursor: default;
285
- }
286
- .bcal-table tr:last-child .bcal-empty,
287
- .bcal-table tr:last-child .bcal-week,
288
- .bcal-table tr:last-child .bcal-date{
289
- border-bottom: none;
290
- }
291
- .bcal-table .bcal-date{
292
- border-right: solid 1px #fff;
293
- border-bottom: solid 1px #fff;
294
- background-color: #ECECEE;
295
- }
296
- .bcal-table .bcal-past{
297
- background-color: #e6e6e6;
298
- color: #999;
299
- cursor: default;
300
- }
301
- .bcal-table .bcal-today{
302
- background-color: #D6D6D1;
303
- color: #333;
304
- }
305
- .bcal-table .bcal-week{
306
- background-color: #FEF3DA;
307
- border-right: solid 1px #fff;
308
- border-bottom: solid 1px #fff;
309
- color: #CC6600;
310
- cursor: default;
311
- }
312
- .bcal-table .bcal-selected{
313
- background-color: #BDBDBD;
314
- color: #F2F2F2;
315
- }
316
- .bcal-table .bcal-over,
317
- .bcal-table .bcal-date:hover{
318
- background-color: #B2B2A9;
319
- color: #fff;
320
- }
321
- .bcal-table .bcal-date:last-child,
322
- .bcal-table .bcal-empty:last-child{
323
- border-right: none;
324
- }
325
- .bcal-table .bcal-past:hover{
326
- background-color: #e0e0e0;
327
- color: #666;
328
- }
329
- .bcal-table .bcal-month,
330
- .bcal-table .bcal-navi,
331
- .bcal-table .bcal-wnum,
332
- .bcal-table .bcal-wday,
333
- .bcal-table .bcal-week{
334
- cursor: text;
335
- }
336
- </style>
337
- ';
338
  }
339
 
340
  // Function to deal with loading the calendar into pages
@@ -344,14 +188,22 @@ function calendar_shortcode_insert($atts) {
344
  'type' => ''
345
  ), $atts );
346
  if ($a['categories'] == '') {
347
- if ($a['type'] == 'mini') {
348
- return minical();
 
 
 
 
349
  } else {
350
  return calendar();
351
  }
352
  } else {
353
- if ($a['type'] == 'mini') {
354
- return minical();
 
 
 
 
355
  } else {
356
  return calendar( $a['categories'] );
357
  }
@@ -375,7 +227,7 @@ function calendar_insert($content)
375
  }
376
 
377
  // Function to show a mini calendar in pages
378
- function minical_insert($content)
379
  {
380
  if (preg_match('/\{MINICAL*.+\}/',$content))
381
  {
@@ -383,9 +235,9 @@ function minical_insert($content)
383
  if (sizeof($cat_list) > 1) {
384
  $cat_list = preg_split('/\}/',$cat_list[1]);
385
  $cat_list= $cat_list[0];
386
- $cal_output = minical($cat_list);
387
  } else {
388
- $cal_output = minical();
389
  }
390
  $content = preg_replace('/\{MINICAL*.+\}/',preg_replace('/\$(\d)/','\\\$$1',$cal_output),$content);
391
  }
@@ -393,7 +245,7 @@ function minical_insert($content)
393
  }
394
 
395
  // Functions to allow the widgets to be inserted into posts and pages
396
- function upcoming_insert($content)
397
  {
398
  if (preg_match('/\{UPCOMING_EVENTS*.+\}/',$content))
399
  {
@@ -401,15 +253,15 @@ function upcoming_insert($content)
401
  if (sizeof($cat_list) > 1) {
402
  $cat_list = preg_split('/\}/',$cat_list[1]);
403
  $cat_list= $cat_list[0];
404
- $cal_output = '<span class="page-upcoming-events">'.upcoming_events($cat_list).'</span>';
405
  } else {
406
- $cal_output = '<span class="page-upcoming-events">'.upcoming_events().'</span>';
407
  }
408
  $content = preg_replace('/\{UPCOMING_EVENTS*.+\}/',preg_replace('/\$(\d)/','\\\$$1',$cal_output),$content);
409
  }
410
  return $content;
411
  }
412
- function todays_insert($content)
413
  {
414
  if (preg_match('/\{TODAYS_EVENTS*.+\}/',$content))
415
  {
@@ -417,9 +269,9 @@ function todays_insert($content)
417
  if (sizeof($cat_list) > 1) {
418
  $cat_list = preg_split('/\}/',$cat_list[1]);
419
  $cat_list= $cat_list[0];
420
- $cal_output = '<span class="page-todays-events">'.todays_events($cat_list).'</span>';
421
  } else {
422
- $cal_output = '<span class="page-todays-events">'.todays_events().'</span>';
423
  }
424
  $content = preg_replace('/\{TODAYS_EVENTS*.+\}/',preg_replace('/\$(\d)/','\\\$$1',$cal_output),$content);
425
  }
@@ -427,7 +279,7 @@ function todays_insert($content)
427
  }
428
 
429
  // Function to check what version of Calendar is installed and install if needed
430
- function check_calendar()
431
  {
432
  // Checks to make sure Calendar is installed, if not it adds the default
433
  // database tables and populates them with test data. If it is, then the
@@ -810,7 +662,7 @@ function check_calendar()
810
  }
811
 
812
  // Used on the manage events admin page to display a list of events
813
- function wp_events_display_list(){
814
 
815
  global $wpdb;
816
 
@@ -872,9 +724,9 @@ function wp_events_display_list(){
872
  ?>
873
  <td style="background-color:<?php echo stripslashes($this_cat->category_colour);?>;"><?php echo htmlspecialchars(stripslashes($this_cat->category_name)); ?></td>
874
  <?php unset($this_cat); ?>
875
- <td><a href="<?php echo bloginfo('wpurl') ?>/wp-admin/admin.php?page=calendar&amp;action=edit&amp;event_id=<?php echo stripslashes($event->event_id);?>" class='edit'><?php echo __('Edit','calendar'); ?></a></td>
876
  <td><a href="
877
- <?php echo wp_nonce_url(bloginfo('wpurl').'/wp-admin/admin.php?page=calendar&amp;action=delete&amp;event_id='.stripslashes($event->event_id),'calendar-delete_'.stripslashes($event->event_id)); ?>" class="delete" onclick="return confirm('<?php _e('Are you sure you want to delete this event?','calendar'); ?>')"><?php echo __('Delete','calendar'); ?></a></td>
878
  </tr>
879
  <?php
880
  }
@@ -892,7 +744,7 @@ function wp_events_display_list(){
892
 
893
 
894
  // The event edit form for the manage events admin page
895
- function wp_events_edit_form($mode='add', $event_id=false)
896
  {
897
  global $wpdb,$users_entries;
898
  $data = false;
@@ -928,7 +780,7 @@ function wp_events_edit_form($mode='add', $event_id=false)
928
 
929
  ?>
930
  <div id="pop_up_cal" style="position:absolute;margin-left:150px;visibility:hidden;background-color:white;layer-background-color:white;z-index:1;"></div>
931
- <form name="quoteform" id="quoteform" class="wrap" method="post" action="<?php echo bloginfo('wpurl'); ?>/wp-admin/admin.php?page=calendar">
932
  <input type="hidden" name="action" value="<?php echo $mode; ?>">
933
  <input type="hidden" name="event_id" value="<?php echo stripslashes($event_id); ?>">
934
  <?php
@@ -991,7 +843,7 @@ function wp_events_edit_form($mode='add', $event_id=false)
991
  }
992
  else
993
  {
994
- echo date("Y-m-d",ctwo());
995
  }
996
  ?>" />
997
  <script type="text/javascript">
@@ -1016,7 +868,7 @@ function wp_events_edit_form($mode='add', $event_id=false)
1016
  }
1017
  else
1018
  {
1019
- echo date("Y-m-d",ctwo());
1020
  }
1021
  ?>" />
1022
  <script type="text/javascript">
@@ -1045,7 +897,7 @@ function wp_events_edit_form($mode='add', $event_id=false)
1045
  }
1046
  else
1047
  {
1048
- echo date("H:i",ctwo());
1049
  }
1050
  ?>" /> <?php _e('Optional, set blank if not required.','calendar'); ?> <?php _e('Current time difference from GMT is ','calendar'); echo get_option('gmt_offset'); _e(' hour(s)','calendar'); ?>
1051
  </td>
@@ -1119,62 +971,31 @@ function wp_events_edit_form($mode='add', $event_id=false)
1119
 
1120
  // The actual function called to render the manage events page and
1121
  // to deal with posts
1122
- function edit_calendar()
1123
  {
1124
  global $current_user, $wpdb, $users_entries;
1125
- ?>
1126
- <style type="text/css">
1127
- <!--
1128
- .error {
1129
- background: lightcoral;
1130
- border: 1px solid #e64f69;
1131
- margin: 1em 5% 10px;
1132
- padding: 0 1em 0 1em;
1133
- }
1134
 
1135
- .center {
1136
- text-align: center;
1137
- }
1138
- .right { text-align: right;
1139
- }
1140
- .left {
1141
- text-align: left;
1142
- }
1143
- .top {
1144
- vertical-align: top;
1145
- }
1146
- .bold {
1147
- font-weight: bold;
1148
- }
1149
- .private {
1150
- color: #e64f69;
1151
- }
1152
- //-->
1153
- </style>
1154
-
1155
- <?php
1156
-
1157
- // First some quick cleaning up
1158
  $edit = $create = $save = $delete = false;
1159
 
1160
  // Make sure we are collecting the variables we need to select years and months
1161
- $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
1162
- $event_id = !empty($_REQUEST['event_id']) ? $_REQUEST['event_id'] : '';
1163
 
1164
  // Deal with adding an event to the database
1165
  if ( $action == 'add' )
1166
  {
1167
- $title = !empty($_REQUEST['event_title']) ? $_REQUEST['event_title'] : '';
1168
- $desc = !empty($_REQUEST['event_desc']) ? $_REQUEST['event_desc'] : '';
1169
- $begin = !empty($_REQUEST['event_begin']) ? $_REQUEST['event_begin'] : '';
1170
- $end = !empty($_REQUEST['event_end']) ? $_REQUEST['event_end'] : '';
1171
- $time = !empty($_REQUEST['event_time']) ? $_REQUEST['event_time'] : '';
1172
- $recur = !empty($_REQUEST['event_recur']) ? $_REQUEST['event_recur'] : '';
1173
- $repeats = !empty($_REQUEST['event_repeats']) ? $_REQUEST['event_repeats'] : '';
1174
- $category = !empty($_REQUEST['event_category']) ? $_REQUEST['event_category'] : '';
1175
- $linky = !empty($_REQUEST['event_link']) ? $_REQUEST['event_link'] : '';
1176
-
1177
- if (wp_verify_nonce($_POST['_wpnonce'],'calendar-add') == false) {
1178
  ?>
1179
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try adding the event again",'calendar'); ?></p></div>
1180
  <?php
@@ -1322,15 +1143,15 @@ if ( $action == 'add' )
1322
  // Permit saving of events that have been edited
1323
  elseif ( $action == 'edit_save' )
1324
  {
1325
- $title = !empty($_REQUEST['event_title']) ? $_REQUEST['event_title'] : '';
1326
- $desc = !empty($_REQUEST['event_desc']) ? $_REQUEST['event_desc'] : '';
1327
- $begin = !empty($_REQUEST['event_begin']) ? $_REQUEST['event_begin'] : '';
1328
- $end = !empty($_REQUEST['event_end']) ? $_REQUEST['event_end'] : '';
1329
- $time = !empty($_REQUEST['event_time']) ? $_REQUEST['event_time'] : '';
1330
- $recur = !empty($_REQUEST['event_recur']) ? $_REQUEST['event_recur'] : '';
1331
- $repeats = !empty($_REQUEST['event_repeats']) ? $_REQUEST['event_repeats'] : '';
1332
- $category = !empty($_REQUEST['event_category']) ? $_REQUEST['event_category'] : '';
1333
- $linky = !empty($_REQUEST['event_link']) ? $_REQUEST['event_link'] : '';
1334
 
1335
  if ( empty($event_id) )
1336
  {
@@ -1338,7 +1159,7 @@ elseif ( $action == 'edit_save' )
1338
  <div class="error"><p><strong><?php _e('Failure','calendar'); ?>:</strong> <?php _e("You can't update an event if you haven't submitted an event id",'calendar'); ?></p></div>
1339
  <?php
1340
  }
1341
- elseif (wp_verify_nonce($_POST['_wpnonce'],'calendar-edit_save_'.$event_id) == false) {
1342
  ?>
1343
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try editing the event again",'calendar'); ?></p></div>
1344
  <?php
@@ -1492,7 +1313,7 @@ elseif ( $action == 'delete' )
1492
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("You can't delete an event if you haven't submitted an event id",'calendar'); ?></p></div>
1493
  <?php
1494
  }
1495
- elseif (wp_verify_nonce($_GET['_wpnonce'],'calendar-delete_'.$event_id) == false) {
1496
  ?>
1497
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try deleting the event again",'calendar'); ?></p></div>
1498
  <?php
@@ -1539,18 +1360,18 @@ elseif ( $action == 'delete' )
1539
  }
1540
  else
1541
  {
1542
- wp_events_edit_form('edit_save', $event_id);
1543
  }
1544
  }
1545
  else
1546
  {
1547
  ?>
1548
  <h2><?php _e('Add Event','calendar'); ?></h2>
1549
- <?php wp_events_edit_form(); ?>
1550
 
1551
  <h2><?php _e('Manage Events','calendar'); ?></h2>
1552
  <?php
1553
- wp_events_display_list();
1554
  }
1555
  ?>
1556
  </div>
@@ -1560,11 +1381,11 @@ elseif ( $action == 'delete' )
1560
  }
1561
 
1562
  // Display the admin configuration page
1563
- function edit_calendar_config()
1564
  {
1565
  global $wpdb, $initial_style;
1566
 
1567
- if (isset($_POST['permissions']) && isset($_POST['style']) && wp_verify_nonce($_POST['_wpnonce'],'calendar-config') == false) {
1568
  ?>
1569
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try editing the config again",'calendar'); ?></p></div>
1570
  <?php
@@ -1578,8 +1399,9 @@ function edit_calendar_config()
1578
  else if ($_POST['permissions'] == 'admin') { $new_perms = 'manage_options'; }
1579
  else { $new_perms = 'manage_options'; }
1580
 
1581
- $calendar_style = $_POST['style']; // Escape done in query below
1582
- $display_upcoming_days = $_POST['display_upcoming_days']; // Escape done in query below
 
1583
 
1584
  if ($_POST['display_author'] == 'on')
1585
  {
@@ -1825,39 +1647,9 @@ function edit_calendar_config()
1825
 
1826
  // Now we render the form
1827
  ?>
1828
- <style type="text/css">
1829
- <!--
1830
- .error {
1831
- background: lightcoral;
1832
- border: 1px solid #e64f69;
1833
- margin: 1em 5% 10px;
1834
- padding: 0 1em 0 1em;
1835
- }
1836
-
1837
- .center {
1838
- text-align: center;
1839
- }
1840
- .right {
1841
- text-align: right;
1842
- }
1843
- .left {
1844
- text-align: left;
1845
- }
1846
- .top {
1847
- vertical-align: top;
1848
- }
1849
- .bold {
1850
- font-weight: bold;
1851
- }
1852
- .private {
1853
- color: #e64f69;
1854
- }
1855
- //-->
1856
- </style>
1857
-
1858
  <div class="wrap">
1859
  <h2><?php _e('Calendar Options','calendar'); ?></h2>
1860
- <form name="quoteform" id="quoteform" class="wrap" method="post" action="<?php echo bloginfo('wpurl'); ?>/wp-admin/admin.php?page=calendar-config">
1861
  <?php wp_nonce_field('calendar-config'); ?>
1862
  <div id="linkadvanceddiv" class="postbox">
1863
  <div style="float: left; width: 98%; clear: both;" class="inside">
@@ -1951,78 +1743,46 @@ function edit_calendar_config()
1951
  }
1952
 
1953
  // Function to handle the management of categories
1954
- function manage_categories()
1955
  {
1956
  global $wpdb;
1957
 
1958
- ?>
1959
- <style type="text/css">
1960
- <!--
1961
- .error {
1962
- background: lightcoral;
1963
- border: 1px solid #e64f69;
1964
- margin: 1em 5% 10px;
1965
- padding: 0 1em 0 1em;
1966
- }
1967
-
1968
- .center {
1969
- text-align: center;
1970
- }
1971
- .right {
1972
- text-align: right;
1973
- }
1974
- .left {
1975
- text-align: left;
1976
- }
1977
- .top {
1978
- vertical-align: top;
1979
- }
1980
- .bold {
1981
- font-weight: bold;
1982
- }
1983
- .private {
1984
- color: #e64f69;
1985
- }
1986
- //-->
1987
-
1988
- </style>
1989
- <?php
1990
  // We do some checking to see what we're doing
1991
  if (isset($_POST['mode']) && $_POST['mode'] == 'add')
1992
  {
1993
- if (wp_verify_nonce($_POST['_wpnonce'],'calendar-category_add') == false) {
1994
  ?>
1995
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try adding the category again",'calendar'); ?></p></div>
1996
  <?php
1997
  } else {
1998
  // Proceed with the save
1999
- $sql = $wpdb->prepare("INSERT INTO " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_name='%s', category_colour='%s'",$_POST['category_name'],$_POST['category_colour']);
2000
  $wpdb->get_results($sql);
2001
  echo "<div class=\"updated\"><p><strong>".__('Category added successfully','calendar')."</strong></p></div>";
2002
  }
2003
  }
2004
  else if (isset($_GET['mode']) && isset($_GET['category_id']) && $_GET['mode'] == 'delete')
2005
  {
2006
- if (wp_verify_nonce($_GET['_wpnonce'],'calendar-category_delete_'.$_GET['category_id']) == false) {
2007
  ?>
2008
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try deleting the category again",'calendar'); ?></p></div>
2009
  <?php
2010
  } else {
2011
- $sql = $wpdb->prepare("DELETE FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=%d",$_GET['category_id']);
2012
  $wpdb->get_results($sql);
2013
- $sql = $wpdb->prepare("UPDATE " . WP_CALENDAR_TABLE . " SET event_category=1 WHERE event_category=%d",$_GET['category_id']);
2014
  $wpdb->get_results($sql);
2015
  echo "<div class=\"updated\"><p><strong>".__('Category deleted successfully','calendar')."</strong></p></div>";
2016
  }
2017
  }
2018
  else if (isset($_GET['mode']) && isset($_GET['category_id']) && $_GET['mode'] == 'edit' && !isset($_POST['mode']))
2019
  {
2020
- $sql = $wpdb->prepare("SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=%d",$_GET['category_id']);
2021
  $cur_cat = $wpdb->get_row($sql);
2022
  ?>
2023
  <div class="wrap">
2024
  <h2><?php _e('Edit Category','calendar'); ?></h2>
2025
- <form name="catform" id="catform" class="wrap" method="post" action="<?php echo bloginfo('wpurl'); ?>/wp-admin/admin.php?page=calendar-categories">
2026
  <input type="hidden" name="mode" value="edit" />
2027
  <input type="hidden" name="category_id" value="<?php echo stripslashes($cur_cat->category_id) ?>" />
2028
  <?php wp_nonce_field('calendar-category_edit_'.stripslashes($cur_cat->category_id)); ?>
@@ -2048,13 +1808,13 @@ function manage_categories()
2048
  }
2049
  else if (isset($_POST['mode']) && isset($_POST['category_id']) && isset($_POST['category_name']) && isset($_POST['category_colour']) && $_POST['mode'] == 'edit')
2050
  {
2051
- if (wp_verify_nonce($_POST['_wpnonce'],'calendar-category_edit_'.$_POST['category_id']) == false) {
2052
  ?>
2053
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try editing the category again",'calendar'); ?></p></div>
2054
  <?php
2055
  } else {
2056
  // Proceed with the save
2057
- $sql = $wpdb->prepare("UPDATE " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_name='%s', category_colour='%s' WHERE category_id=%d",$_POST['category_name'],$_POST['category_colour'],$_POST['category_id']);
2058
  $wpdb->get_results($sql);
2059
  echo "<div class=\"updated\"><p><strong>".__('Category edited successfully','calendar')."</strong></p></div>";
2060
  }
@@ -2078,7 +1838,7 @@ function manage_categories()
2078
 
2079
  <div class="wrap">
2080
  <h2><?php _e('Add Category','calendar'); ?></h2>
2081
- <form name="catform" id="catform" class="wrap" method="post" action="<?php echo bloginfo('wpurl'); ?>/wp-admin/admin.php?page=calendar-categories">
2082
  <input type="hidden" name="mode" value="add" />
2083
  <input type="hidden" name="category_id" value="">
2084
  <?php wp_nonce_field('calendar-category_add'); ?>
@@ -2128,7 +1888,7 @@ function manage_categories()
2128
  <th scope="row"><?php echo stripslashes($category->category_id); ?></th>
2129
  <td><?php echo htmlspecialchars(stripslashes($category->category_name)); ?></td>
2130
  <td style="background-color:<?php echo stripslashes($category->category_colour); ?>;">&nbsp;</td>
2131
- <td><a href="<?php echo bloginfo('wpurl') ?>/wp-admin/admin.php?page=calendar-categories&amp;mode=edit&amp;category_id=<?php echo stripslashes($category->category_id);?>" class='edit'><?php echo __('Edit','calendar'); ?></a></td>
2132
  <?php
2133
  if ($category->category_id == 1)
2134
  {
@@ -2137,7 +1897,7 @@ function manage_categories()
2137
  else
2138
  {
2139
  ?>
2140
- <td><a href="<?php echo wp_nonce_url(bloginfo('wpurl').'/wp-admin/admin.php?page=calendar-categories&amp;mode=delete&amp;category_id='.stripslashes($category->category_id), 'calendar-category_delete_'.stripslashes($category->category_id)); ?>" class="delete" onclick="return confirm('<?php echo __('Are you sure you want to delete this category?','calendar'); ?>')"><?php echo __('Delete','calendar'); ?></a></td>
2141
  <?php
2142
  }
2143
  ?>
@@ -2161,7 +1921,7 @@ function manage_categories()
2161
  }
2162
 
2163
  // Function to indicate the number of the day passed, eg. 1st or 2nd Sunday
2164
- function np_of_day($date)
2165
  {
2166
  $instance = 0;
2167
  $dom = date('j',strtotime($date));
@@ -2174,7 +1934,7 @@ function np_of_day($date)
2174
  }
2175
 
2176
  // Function to provide date of the nth day passed (eg. 2nd Sunday)
2177
- function dt_of_sun($date,$instance,$day)
2178
  {
2179
  $plan = array();
2180
  $plan['Mon'] = 1;
@@ -2200,7 +1960,7 @@ function dt_of_sun($date,$instance,$day)
2200
 
2201
  // Function to return a prefix which will allow the correct
2202
  // placement of arguments into the query string.
2203
- function permalink_prefix()
2204
  {
2205
  // Get the permalink structure from WordPress
2206
  if (is_home()) {
@@ -2217,7 +1977,7 @@ function permalink_prefix()
2217
  }
2218
 
2219
  // Configure the "Next" link in the calendar
2220
- function next_link($cur_year,$cur_month,$minical = false)
2221
  {
2222
  $mod_rewrite_months = array(1=>'jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec');
2223
  $next_year = $cur_year + 1;
@@ -2225,19 +1985,19 @@ function next_link($cur_year,$cur_month,$minical = false)
2225
  if ($cur_month == 12)
2226
  {
2227
  if ($minical) { $rlink = ''; } else { $rlink = __('Next','calendar'); }
2228
- return '<a href="' . permalink_prefix() . 'month=jan&amp;yr=' . $next_year . '">'.$rlink.' &raquo;</a>';
2229
  }
2230
  else
2231
  {
2232
  $next_month = $cur_month + 1;
2233
  $month = $mod_rewrite_months[$next_month];
2234
  if ($minical) { $rlink = ''; } else { $rlink = __('Next','calendar'); }
2235
- return '<a href="' . permalink_prefix() . 'month='.$month.'&amp;yr=' . $cur_year . '">'.$rlink.' &raquo;</a>';
2236
  }
2237
  }
2238
 
2239
  // Configure the "Previous" link in the calendar
2240
- function prev_link($cur_year,$cur_month,$minical = false)
2241
  {
2242
  $mod_rewrite_months = array(1=>'jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec');
2243
  $last_year = $cur_year - 1;
@@ -2245,19 +2005,19 @@ function prev_link($cur_year,$cur_month,$minical = false)
2245
  if ($cur_month == 1)
2246
  {
2247
  if ($minical) { $llink = ''; } else { $llink = __('Prev','calendar'); }
2248
- return '<a href="' . permalink_prefix() . 'month=dec&amp;yr='. $last_year .'">&laquo; '.$llink.'</a>';
2249
  }
2250
  else
2251
  {
2252
  $next_month = $cur_month - 1;
2253
  $month = $mod_rewrite_months[$next_month];
2254
  if ($minical) { $llink = ''; } else { $llink = __('Prev','calendar'); }
2255
- return '<a href="' . permalink_prefix() . 'month='.$month.'&amp;yr=' . $cur_year . '">&laquo; '.$llink.'</a>';
2256
  }
2257
  }
2258
 
2259
  // Print upcoming events
2260
- function upcoming_events($cat_list = '')
2261
  {
2262
  global $wpdb;
2263
 
@@ -2273,11 +2033,11 @@ function upcoming_events($cat_list = '')
2273
  $output = '';
2274
  while ($day_count < $future_days+1)
2275
  {
2276
- list($y,$m,$d) = explode("-",date("Y-m-d",mktime($day_count*24,0,0,date("m",ctwo()),date("d",ctwo()),date("Y",ctwo()))));
2277
  $events = grab_events($y,$m,$d,'upcoming',$cat_list);
2278
- usort($events, "time_cmp");
2279
  if (count($events) != 0) {
2280
- $output .= '<li>'.date_i18n(get_option('date_format'),mktime($day_count*24,0,0,date("m",ctwo()),date("d",ctwo()),date("Y",ctwo()))).'<ul>';
2281
  }
2282
  foreach($events as $event)
2283
  {
@@ -2287,7 +2047,7 @@ function upcoming_events($cat_list = '')
2287
  else {
2288
  $time_string = ' '.__('at','calendar').' '.date(get_option('time_format'), strtotime(stripslashes($event->event_time)));
2289
  }
2290
- $output .= '<li>'.draw_event($event).$time_string.'</li>';
2291
  }
2292
  if (count($events) != 0) {
2293
  $output .= '</ul></li>';
@@ -2306,7 +2066,7 @@ function upcoming_events($cat_list = '')
2306
  }
2307
 
2308
  // Print todays events
2309
- function todays_events($cat_list = '')
2310
  {
2311
  global $wpdb;
2312
 
@@ -2316,8 +2076,8 @@ function todays_events($cat_list = '')
2316
  if ($display == 'true')
2317
  {
2318
  $output = '<ul>';
2319
- $events = grab_events(date("Y",ctwo()),date("m",ctwo()),date("d",ctwo()),'todays',$cat_list);
2320
- usort($events, "time_cmp");
2321
  foreach($events as $event)
2322
  {
2323
  if ($event->event_time == '00:00:00') {
@@ -2326,7 +2086,7 @@ function todays_events($cat_list = '')
2326
  else {
2327
  $time_string = ' '.__('at','calendar').' '.date(get_option('time_format'), strtotime(stripslashes($event->event_time)));
2328
  }
2329
- $output .= '<li>'.draw_event($event).$time_string.'</li>';
2330
  }
2331
  $output .= '</ul>';
2332
  if (count($events) != 0)
@@ -2337,7 +2097,7 @@ function todays_events($cat_list = '')
2337
  }
2338
 
2339
  // Function to compare time in event objects
2340
- function time_cmp($a, $b)
2341
  {
2342
  if ($a->event_time == $b->event_time) {
2343
  return 0;
@@ -2346,15 +2106,15 @@ function time_cmp($a, $b)
2346
  }
2347
 
2348
  // Used to draw multiple events
2349
- function draw_events($events)
2350
  {
2351
  // We need to sort arrays of objects by time
2352
- usort($events, "time_cmp");
2353
  $output = '';
2354
  // Now process the events
2355
  foreach($events as $event)
2356
  {
2357
- $output .= '* '.draw_event($event).'<br />';
2358
  $output = apply_filters('modify_drawn_event_content', $output, $event);
2359
  }
2360
  return $output;
@@ -2371,7 +2131,7 @@ function widget_init_events_calendar() {
2371
  $the_title = stripslashes(get_option('events_calendar_widget_title'));
2372
  $the_cats = stripslashes(get_option('events_calendar_widget_cats'));
2373
  $widget_title = empty($the_title) ? __('Calendar','calendar') : $the_title;
2374
- $the_events = minical($the_cats);
2375
  if ($the_events != '') {
2376
  echo $before_widget;
2377
  echo $before_title . $widget_title . $after_title;
@@ -2384,8 +2144,8 @@ function widget_init_events_calendar() {
2384
  $widget_title = stripslashes(get_option('events_calendar_widget_title'));
2385
  $widget_cats = stripslashes(get_option('events_calendar_widget_cats'));
2386
  if (isset($_POST['events_calendar_widget_title']) || isset($_POST['events_calendar_widget_cats'])) {
2387
- update_option('events_calendar_widget_title',strip_tags($_POST['events_calendar_widget_title']));
2388
- update_option('events_calendar_widget_cats',strip_tags($_POST['events_calendar_widget_cats']));
2389
  }
2390
  ?>
2391
  <p>
@@ -2412,7 +2172,7 @@ function widget_init_calendar_today() {
2412
  $the_title = stripslashes(get_option('calendar_today_widget_title'));
2413
  $the_cats = stripslashes(get_option('calendar_today_widget_cats'));
2414
  $widget_title = empty($the_title) ? __('Today\'s Events','calendar') : $the_title;
2415
- $the_events = todays_events($the_cats);
2416
  if ($the_events != '') {
2417
  echo $before_widget;
2418
  echo $before_title . $widget_title . $after_title;
@@ -2425,8 +2185,8 @@ function widget_init_calendar_today() {
2425
  $widget_title = stripslashes(get_option('calendar_today_widget_title'));
2426
  $widget_cats = stripslashes(get_option('calendar_today_widget_cats'));
2427
  if (isset($_POST['calendar_today_widget_title']) || isset($_POST['calendar_today_widget_cats'])) {
2428
- update_option('calendar_today_widget_title',strip_tags($_POST['calendar_today_widget_title']));
2429
- update_option('calendar_today_widget_cats',strip_tags($_POST['calendar_today_widget_cats']));
2430
  }
2431
  ?>
2432
  <p>
@@ -2453,7 +2213,7 @@ function widget_init_calendar_upcoming() {
2453
  $the_title = stripslashes(get_option('calendar_upcoming_widget_title'));
2454
  $the_cats = stripslashes(get_option('calendar_upcoming_widget_cats'));
2455
  $widget_title = empty($the_title) ? __('Upcoming Events','calendar') : $the_title;
2456
- $the_events = upcoming_events($the_cats);
2457
  if ($the_events != '') {
2458
  echo $before_widget;
2459
  echo $before_title . $widget_title . $after_title;
@@ -2466,8 +2226,8 @@ function widget_init_calendar_upcoming() {
2466
  $widget_title = stripslashes(get_option('calendar_upcoming_widget_title'));
2467
  $widget_cats = stripslashes(get_option('calendar_upcoming_widget_cats'));
2468
  if (isset($_POST['calendar_upcoming_widget_title']) || isset($_POST['calendar_upcoming_widget_cats'])) {
2469
- update_option('calendar_upcoming_widget_title',strip_tags($_POST['calendar_upcoming_widget_title']));
2470
- update_option('calendar_upcoming_widget_cats',strip_tags($_POST['calendar_upcoming_widget_cats']));
2471
  }
2472
  ?>
2473
  <p>
@@ -2484,7 +2244,7 @@ function widget_init_calendar_upcoming() {
2484
  }
2485
 
2486
  // Used to draw an event to the screen
2487
- function draw_event($event)
2488
  {
2489
  global $wpdb;
2490
 
@@ -2626,7 +2386,7 @@ ORDER BY event_id";
2626
  }
2627
  else if ($event->type == 'MonthSun')
2628
  {
2629
- // This used to be complex but writing the dt_of_sun() function helped loads!
2630
 
2631
  // Technically we don't care about the years or months, but we need to find out if the
2632
  // event spans the turn of a year or month so we can deal with it appropriately.
@@ -2636,8 +2396,8 @@ ORDER BY event_id";
2636
  // Setup some variables and get some values
2637
  $dow = date('w',strtotime($event->event_begin));
2638
  if ($dow == 0) { $dow = 7; }
2639
- $start_ent_this = dt_of_sun($date,np_of_day($event->event_begin),$dow);
2640
- $start_ent_prev = dt_of_sun(date('Y-m-d',strtotime($date.'-1 month')),np_of_day($event->event_begin),$dow);
2641
  $len_ent = strtotime($event->event_end)-strtotime($event->event_begin);
2642
 
2643
  // The grunt work
@@ -2715,9 +2475,9 @@ ORDER BY event_id";
2715
  // Setup comparison functions for building the calendar later
2716
  function calendar_month_comparison($month)
2717
  {
2718
- $get_year = (isset($_GET['yr']) ? $_GET['yr'] : null);
2719
- $get_month = (isset($_GET['month']) ? $_GET['month'] : null);
2720
- $current_month = strtolower(date("M", ctwo()));
2721
  if (isset($get_year) && isset($get_month))
2722
  {
2723
  if ($month == $get_month)
@@ -2732,9 +2492,9 @@ function calendar_month_comparison($month)
2732
  }
2733
  function calendar_year_comparison($year)
2734
  {
2735
- $get_year = (isset($_GET['yr']) ? $_GET['yr'] : null);
2736
- $get_month = (isset($_GET['month']) ? $_GET['month'] : null);
2737
- $current_year = strtolower(date("Y", ctwo()));
2738
  if (isset($get_year) && isset($get_month))
2739
  {
2740
  if ($year == $get_year)
@@ -2755,8 +2515,8 @@ function calendar($cat_list = '')
2755
  {
2756
  global $wpdb;
2757
 
2758
- $get_year = (isset($_GET['yr']) ? $_GET['yr'] : null);
2759
- $get_month = (isset($_GET['month']) ? $_GET['month'] : null);
2760
 
2761
  // Deal with the week not starting on a monday
2762
  if (get_option('start_of_week') == 0)
@@ -2775,9 +2535,9 @@ function calendar($cat_list = '')
2775
  // If we don't pass arguments we want a calendar that is relevant to today
2776
  if (empty($get_month) || empty($get_year))
2777
  {
2778
- $c_year = date("Y",ctwo());
2779
- $c_month = date("m",ctwo());
2780
- $c_day = date("d",ctwo());
2781
  }
2782
 
2783
  // Years get funny if we exceed 3000, so we use this check
@@ -2806,23 +2566,23 @@ function calendar($cat_list = '')
2806
  else if ($get_month == 'nov') { $t_month = 11; }
2807
  else if ($get_month == 'dec') { $t_month = 12; }
2808
  $c_month = $t_month;
2809
- $c_day = date("d",ctwo());
2810
  }
2811
  // No valid month causes the calendar to default to today
2812
  else
2813
  {
2814
- $c_year = date("Y",ctwo());
2815
- $c_month = date("m",ctwo());
2816
- $c_day = date("d",ctwo());
2817
  }
2818
  }
2819
  }
2820
  // No valid year causes the calendar to default to today
2821
  else
2822
  {
2823
- $c_year = date("Y",ctwo());
2824
- $c_month = date("m",ctwo());
2825
- $c_day = date("d",ctwo());
2826
  }
2827
 
2828
  // Fix the days of the week if week start is not on a monday
@@ -2896,23 +2656,23 @@ function calendar($cat_list = '')
2896
  while ($past > 0)
2897
  {
2898
  $p .= ' <option value="';
2899
- $p .= date("Y",ctwo())-$past;
2900
- $p .= '"'.calendar_year_comparison(date("Y",ctwo())-$past).'>';
2901
- $p .= date("Y",ctwo())-$past.'</option>
2902
  ';
2903
  $past = $past - 1;
2904
  }
2905
  while ($fut < $future)
2906
  {
2907
  $f .= ' <option value="';
2908
- $f .= date("Y",ctwo())+$fut;
2909
- $f .= '"'.calendar_year_comparison(date("Y",ctwo())+$fut).'>';
2910
- $f .= date("Y",ctwo())+$fut.'</option>
2911
  ';
2912
  $fut = $fut + 1;
2913
  }
2914
  $calendar_body .= $p;
2915
- $calendar_body .= ' <option value="'.date("Y",ctwo()).'"'.calendar_year_comparison(date("Y",ctwo())).'>'.date("Y",ctwo()).'</option>
2916
  ';
2917
  $calendar_body .= $f;
2918
  $calendar_body .= '</select>
@@ -2928,9 +2688,9 @@ function calendar($cat_list = '')
2928
  <td colspan="7" class="calendar-heading">
2929
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
2930
  <tr>
2931
- <td class="calendar-prev">' . prev_link($c_year,$c_month) . '</td>
2932
  <td class="calendar-month">'.$name_months[(int)$c_month].' '.$c_year.'</td>
2933
- <td class="calendar-next">' . next_link($c_year,$c_month) . '</td>
2934
  </tr>
2935
  </table>
2936
  </td>
@@ -2983,7 +2743,7 @@ function calendar($cat_list = '')
2983
  {
2984
  $no_events_class = ' no-events';
2985
  }
2986
- $calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd",ctwo())?'current-day':'day-with-date').$no_events_class.'"><span '.($ii<7&&$ii>1?'':'class="weekend"').'>'.$i++.'</span><span class="event"><br />' . draw_events($grabbed_events) . '</span></td>
2987
  ';
2988
  }
2989
  else
@@ -2994,7 +2754,7 @@ function calendar($cat_list = '')
2994
  {
2995
  $no_events_class = ' no-events';
2996
  }
2997
- $calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd",ctwo())?'current-day':'day-with-date').$no_events_class.'"><span '.($ii<6?'':'class="weekend"').'>'.$i++.'</span><span class="event"><br />' . draw_events($grabbed_events) . '</span></td>
2998
  ';
2999
  }
3000
  }
@@ -3055,10 +2815,10 @@ function calendar($cat_list = '')
3055
  }
3056
 
3057
  // Used to create a hover will all a day's events in for minical
3058
- function minical_draw_events($events,$day_of_week = '')
3059
  {
3060
  // We need to sort arrays of objects by time
3061
- usort($events, "time_cmp");
3062
  // Only show anything if there are events
3063
  $output = '';
3064
  if (count($events)) {
@@ -3078,12 +2838,12 @@ function minical_draw_events($events,$day_of_week = '')
3078
  return $output;
3079
  }
3080
 
3081
- function minical($cat_list = '') {
3082
 
3083
  global $wpdb;
3084
 
3085
- $get_year = (isset($_GET['yr']) ? $_GET['yr'] : null);
3086
- $get_month = (isset($_GET['month']) ? $_GET['month'] : null);
3087
 
3088
  // Deal with the week not starting on a monday
3089
  if (get_option('start_of_week') == 0)
@@ -3103,9 +2863,9 @@ calendar'),__('August','calendar'),__('September','calendar'),__('October','cale
3103
  // If we don't pass arguments we want a calendar that is relevant to today
3104
  if (empty($get_month) || empty($get_year))
3105
  {
3106
- $c_year = date("Y",ctwo());
3107
- $c_month = date("m",ctwo());
3108
- $c_day = date("d",ctwo());
3109
  }
3110
 
3111
  // Years get funny if we exceed 3000, so we use this check
@@ -3134,23 +2894,23 @@ calendar'),__('August','calendar'),__('September','calendar'),__('October','cale
3134
  else if ($get_month == 'nov') { $t_month = 11; }
3135
  else if ($get_month == 'dec') { $t_month = 12; }
3136
  $c_month = $t_month;
3137
- $c_day = date("d",ctwo());
3138
  }
3139
  // No valid month causes the calendar to default to today
3140
  else
3141
  {
3142
- $c_year = date("Y",ctwo());
3143
- $c_month = date("m",ctwo());
3144
- $c_day = date("d",ctwo());
3145
  }
3146
  }
3147
  }
3148
  // No valid year causes the calendar to default to today
3149
  else
3150
  {
3151
- $c_year = date("Y",ctwo());
3152
- $c_month = date("m",ctwo());
3153
- $c_day = date("d",ctwo());
3154
  }
3155
 
3156
  // Fix the days of the week if week start is not on a monday
@@ -3180,9 +2940,9 @@ calendar'),__('August','calendar'),__('September','calendar'),__('October','cale
3180
  <td colspan="7" class="calendar-heading" style="height:0;">
3181
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
3182
  <tr>
3183
- <td class="calendar-prev">' . prev_link($c_year,$c_month,true) . '</td>
3184
  <td class="calendar-month">'.$name_months[(int)$c_month].' '.$c_year.'</td>
3185
- <td class="calendar-next">' . next_link($c_year,$c_month,true) . '</td>
3186
  </tr>
3187
  </table>
3188
  </td>
@@ -3235,7 +2995,7 @@ calendar'),__('August','calendar'),__('September','calendar'),__('October','cale
3235
  {
3236
  $no_events_class = ' no-events';
3237
  }
3238
- $calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd",ctwo())?'current-day':'day-with-date').$no_events_class.'" style="height:0;"><span '.($ii<7&&$ii>1?'':'class="weekend"').'>'.minical_draw_events($grabbed_events,$i++).'</span></td>
3239
  ';
3240
  }
3241
  else
@@ -3246,7 +3006,7 @@ calendar'),__('August','calendar'),__('September','calendar'),__('October','cale
3246
  {
3247
  $no_events_class = ' no-events';
3248
  }
3249
- $calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd",ctwo())?'current-day':'day-with-date').$no_events_class.'" style="height:0;"><span '.($ii<6?'':'class="weekend"').'>'.minical_draw_events($grabbed_events,$i++).'</span></td>
3250
  ';
3251
  }
3252
  }
7
  Author URI: http://www.kieranoshea.com
8
  Text Domain: calendar
9
  Domain Path: /languages
10
+ Version: 1.3.12
11
  */
12
 
13
  /* Copyright 2008 Kieran O'Shea (email : kieran@kieranoshea.com)
27
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
  */
29
 
30
+ // Direct access shouldn't be allowed
31
+ if ( ! defined( 'ABSPATH' ) ) exit;
32
+
33
  // Enable internationalisation
34
  $plugin_dir = plugin_basename(dirname(__FILE__));
35
  load_plugin_textdomain( 'calendar',false, $plugin_dir.'/languages');
42
 
43
  // Check ensure calendar is installed and install it if not - required for
44
  // the successful operation of most functions called from this point on
45
+ calendar_check();
46
 
47
  // Create a master category for Calendar and its sub-pages
48
+ add_action('admin_enqueue_scripts', 'calendar_add_javascript');
49
  add_action('admin_menu', 'calendar_menu');
50
 
51
  // Enable the ability for the calendar to be loaded from pages
52
  add_filter('the_content','calendar_insert');
53
+ add_filter('the_content','calendar_minical_insert');
54
 
55
  // Enable the ability for the lists to be loaded from pages
56
+ add_filter('the_content','calendar_upcoming_insert');
57
+ add_filter('the_content','calendar_todays_insert');
58
 
59
  // Add the function that puts style information in the header
60
  add_action('wp_head', 'calendar_wp_head');
61
 
62
  // Add the function that deals with deleted users
63
+ add_action('delete_user', 'calendar_deal_with_deleted_user');
64
 
65
  // Add the widgets if we are using version 2.8
66
  add_action('widgets_init', 'widget_init_calendar_today');
97
  }
98
 
99
  // Function to deal with events posted by a user when that user is deleted
100
+ function calendar_deal_with_deleted_user($id)
101
  {
102
  global $wpdb;
103
 
120
  }
121
 
122
  // Function to provide time with WordPress offset, localy replaces time()
123
+ function calendar_ctwo()
124
  {
125
  return (time()+(3600*(get_option('gmt_offset'))));
126
  }
163
  // Add the admin panel pages for Calendar. Use permissions pulled from above
164
  if (function_exists('add_menu_page'))
165
  {
166
+ add_menu_page(__('Calendar','calendar'), __('Calendar','calendar'), $allowed_group, 'calendar', 'calendar_edit');
167
  }
168
  if (function_exists('add_submenu_page'))
169
  {
170
+ add_submenu_page('calendar', __('Manage Calendar','calendar'), __('Manage Calendar','calendar'), $allowed_group, 'calendar', 'calendar_edit');
 
171
  // Note only admin can change calendar options
172
+ add_submenu_page('calendar', __('Manage Categories','calendar'), __('Manage Categories','calendar'), 'manage_options', 'calendar-categories', 'calendar_manage_categories');
173
+ add_submenu_page('calendar', __('Calendar Config','calendar'), __('Calendar Options','calendar'), 'manage_options', 'calendar-config', 'calendar_config_edit');
174
  }
175
  }
176
 
177
  // Function to add the javascript to the admin header
178
  function calendar_add_javascript()
179
+ {
180
+ wp_enqueue_script( 'calendar_custom_wp_admin_js', plugins_url('javascript.js', __FILE__) );
181
+ wp_enqueue_style( 'calendar_custom_wp_admin_css', plugins_url('calendar-admin.css', __FILE__) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  }
183
 
184
  // Function to deal with loading the calendar into pages
188
  'type' => ''
189
  ), $atts );
190
  if ($a['categories'] == '') {
191
+ if ($a['type'] == 'todays') {
192
+ return calendar_todays_events();
193
+ } else if ($a['type'] == 'upcoming') {
194
+ return calendar_upcoming_events();
195
+ } else if ($a['type'] == 'mini') {
196
+ return calendar_minical();
197
  } else {
198
  return calendar();
199
  }
200
  } else {
201
+ if ($a['type'] == 'todays') {
202
+ return calendar_todays_events( $a['categories'] );
203
+ } else if ($a['type'] == 'upcoming') {
204
+ return calendar_upcoming_events( $a['categories'] );
205
+ } else if ($a['type'] == 'mini') {
206
+ return calendar_minical( $a['categories'] );
207
  } else {
208
  return calendar( $a['categories'] );
209
  }
227
  }
228
 
229
  // Function to show a mini calendar in pages
230
+ function calendar_minical_insert($content)
231
  {
232
  if (preg_match('/\{MINICAL*.+\}/',$content))
233
  {
235
  if (sizeof($cat_list) > 1) {
236
  $cat_list = preg_split('/\}/',$cat_list[1]);
237
  $cat_list= $cat_list[0];
238
+ $cal_output = calendar_minical($cat_list);
239
  } else {
240
+ $cal_output = calendar_minical();
241
  }
242
  $content = preg_replace('/\{MINICAL*.+\}/',preg_replace('/\$(\d)/','\\\$$1',$cal_output),$content);
243
  }
245
  }
246
 
247
  // Functions to allow the widgets to be inserted into posts and pages
248
+ function calendar_upcoming_insert($content)
249
  {
250
  if (preg_match('/\{UPCOMING_EVENTS*.+\}/',$content))
251
  {
253
  if (sizeof($cat_list) > 1) {
254
  $cat_list = preg_split('/\}/',$cat_list[1]);
255
  $cat_list= $cat_list[0];
256
+ $cal_output = '<span class="page-upcoming-events">'.calendar_upcoming_events($cat_list).'</span>';
257
  } else {
258
+ $cal_output = '<span class="page-upcoming-events">'.calendar_upcoming_events().'</span>';
259
  }
260
  $content = preg_replace('/\{UPCOMING_EVENTS*.+\}/',preg_replace('/\$(\d)/','\\\$$1',$cal_output),$content);
261
  }
262
  return $content;
263
  }
264
+ function calendar_todays_insert($content)
265
  {
266
  if (preg_match('/\{TODAYS_EVENTS*.+\}/',$content))
267
  {
269
  if (sizeof($cat_list) > 1) {
270
  $cat_list = preg_split('/\}/',$cat_list[1]);
271
  $cat_list= $cat_list[0];
272
+ $cal_output = '<span class="page-todays-events">'.calendar_todays_events($cat_list).'</span>';
273
  } else {
274
+ $cal_output = '<span class="page-todays-events">'.calendar_todays_events().'</span>';
275
  }
276
  $content = preg_replace('/\{TODAYS_EVENTS*.+\}/',preg_replace('/\$(\d)/','\\\$$1',$cal_output),$content);
277
  }
279
  }
280
 
281
  // Function to check what version of Calendar is installed and install if needed
282
+ function calendar_check()
283
  {
284
  // Checks to make sure Calendar is installed, if not it adds the default
285
  // database tables and populates them with test data. If it is, then the
662
  }
663
 
664
  // Used on the manage events admin page to display a list of events
665
+ function calendar_events_display_list(){
666
 
667
  global $wpdb;
668
 
724
  ?>
725
  <td style="background-color:<?php echo stripslashes($this_cat->category_colour);?>;"><?php echo htmlspecialchars(stripslashes($this_cat->category_name)); ?></td>
726
  <?php unset($this_cat); ?>
727
+ <td><a href="<?php echo admin_url('admin.php?page=calendar&amp;action=edit&amp;event_id='.stripslashes($event->event_id)) ?>" class='edit'><?php echo __('Edit','calendar'); ?></a></td>
728
  <td><a href="
729
+ <?php echo wp_nonce_url(admin_url('admin.php?page=calendar&amp;action=delete&amp;event_id='.stripslashes($event->event_id)),'calendar-delete_'.stripslashes($event->event_id)); ?>" class="delete" onclick="return confirm('<?php _e('Are you sure you want to delete this event?','calendar'); ?>')"><?php echo __('Delete','calendar'); ?></a></td>
730
  </tr>
731
  <?php
732
  }
744
 
745
 
746
  // The event edit form for the manage events admin page
747
+ function calendar_events_edit_form($mode='add', $event_id=false)
748
  {
749
  global $wpdb,$users_entries;
750
  $data = false;
780
 
781
  ?>
782
  <div id="pop_up_cal" style="position:absolute;margin-left:150px;visibility:hidden;background-color:white;layer-background-color:white;z-index:1;"></div>
783
+ <form name="quoteform" id="quoteform" class="wrap" method="post" action="<?php echo admin_url('admin.php?page=calendar'); ?>">
784
  <input type="hidden" name="action" value="<?php echo $mode; ?>">
785
  <input type="hidden" name="event_id" value="<?php echo stripslashes($event_id); ?>">
786
  <?php
843
  }
844
  else
845
  {
846
+ echo date("Y-m-d",calendar_ctwo());
847
  }
848
  ?>" />
849
  <script type="text/javascript">
868
  }
869
  else
870
  {
871
+ echo date("Y-m-d",calendar_ctwo());
872
  }
873
  ?>" />
874
  <script type="text/javascript">
897
  }
898
  else
899
  {
900
+ echo date("H:i",calendar_ctwo());
901
  }
902
  ?>" /> <?php _e('Optional, set blank if not required.','calendar'); ?> <?php _e('Current time difference from GMT is ','calendar'); echo get_option('gmt_offset'); _e(' hour(s)','calendar'); ?>
903
  </td>
971
 
972
  // The actual function called to render the manage events page and
973
  // to deal with posts
974
+ function calendar_edit()
975
  {
976
  global $current_user, $wpdb, $users_entries;
 
 
 
 
 
 
 
 
 
977
 
978
+ // First some quick cleaning up
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
979
  $edit = $create = $save = $delete = false;
980
 
981
  // Make sure we are collecting the variables we need to select years and months
982
+ $action = !empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
983
+ $event_id = !empty($_REQUEST['event_id']) ? sanitize_text_field($_REQUEST['event_id']) : '';
984
 
985
  // Deal with adding an event to the database
986
  if ( $action == 'add' )
987
  {
988
+ $title = !empty($_REQUEST['event_title']) ? sanitize_text_field($_REQUEST['event_title']) : '';
989
+ $desc = !empty($_REQUEST['event_desc']) ? wp_filter_nohtml_kses($_REQUEST['event_desc']) : '';
990
+ $begin = !empty($_REQUEST['event_begin']) ? sanitize_text_field($_REQUEST['event_begin']) : '';
991
+ $end = !empty($_REQUEST['event_end']) ? sanitize_text_field($_REQUEST['event_end']) : '';
992
+ $time = !empty($_REQUEST['event_time']) ? sanitize_text_field($_REQUEST['event_time']) : '';
993
+ $recur = !empty($_REQUEST['event_recur']) ? sanitize_text_field($_REQUEST['event_recur']) : '';
994
+ $repeats = !empty($_REQUEST['event_repeats']) ? sanitize_text_field($_REQUEST['event_repeats']) : '';
995
+ $category = !empty($_REQUEST['event_category']) ? sanitize_text_field($_REQUEST['event_category']) : '';
996
+ $linky = !empty($_REQUEST['event_link']) ? wp_filter_nohtml_kses($_REQUEST['event_link']) : '';
997
+
998
+ if (wp_verify_nonce(sanitize_text_field($_POST['_wpnonce']),'calendar-add') == false) {
999
  ?>
1000
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try adding the event again",'calendar'); ?></p></div>
1001
  <?php
1143
  // Permit saving of events that have been edited
1144
  elseif ( $action == 'edit_save' )
1145
  {
1146
+ $title = !empty($_REQUEST['event_title']) ? sanitize_text_field($_REQUEST['event_title']) : '';
1147
+ $desc = !empty($_REQUEST['event_desc']) ? wp_filter_nohtml_kses($_REQUEST['event_desc']) : '';
1148
+ $begin = !empty($_REQUEST['event_begin']) ? sanitize_text_field($_REQUEST['event_begin']) : '';
1149
+ $end = !empty($_REQUEST['event_end']) ? sanitize_text_field($_REQUEST['event_end']) : '';
1150
+ $time = !empty($_REQUEST['event_time']) ? sanitize_text_field($_REQUEST['event_time']) : '';
1151
+ $recur = !empty($_REQUEST['event_recur']) ? sanitize_text_field($_REQUEST['event_recur']) : '';
1152
+ $repeats = !empty($_REQUEST['event_repeats']) ? sanitize_text_field($_REQUEST['event_repeats']) : '';
1153
+ $category = !empty($_REQUEST['event_category']) ? sanitize_text_field($_REQUEST['event_category']) : '';
1154
+ $linky = !empty($_REQUEST['event_link']) ? wp_filter_nohtml_kses($_REQUEST['event_link']) : '';
1155
 
1156
  if ( empty($event_id) )
1157
  {
1159
  <div class="error"><p><strong><?php _e('Failure','calendar'); ?>:</strong> <?php _e("You can't update an event if you haven't submitted an event id",'calendar'); ?></p></div>
1160
  <?php
1161
  }
1162
+ elseif (wp_verify_nonce(sanitize_text_field($_POST['_wpnonce']),'calendar-edit_save_'.$event_id) == false) {
1163
  ?>
1164
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try editing the event again",'calendar'); ?></p></div>
1165
  <?php
1313
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("You can't delete an event if you haven't submitted an event id",'calendar'); ?></p></div>
1314
  <?php
1315
  }
1316
+ elseif (wp_verify_nonce(sanitize_text_field($_GET['_wpnonce']),'calendar-delete_'.$event_id) == false) {
1317
  ?>
1318
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try deleting the event again",'calendar'); ?></p></div>
1319
  <?php
1360
  }
1361
  else
1362
  {
1363
+ calendar_events_edit_form('edit_save', $event_id);
1364
  }
1365
  }
1366
  else
1367
  {
1368
  ?>
1369
  <h2><?php _e('Add Event','calendar'); ?></h2>
1370
+ <?php calendar_events_edit_form(); ?>
1371
 
1372
  <h2><?php _e('Manage Events','calendar'); ?></h2>
1373
  <?php
1374
+ calendar_events_display_list();
1375
  }
1376
  ?>
1377
  </div>
1381
  }
1382
 
1383
  // Display the admin configuration page
1384
+ function calendar_config_edit()
1385
  {
1386
  global $wpdb, $initial_style;
1387
 
1388
+ if (isset($_POST['permissions']) && isset($_POST['style']) && wp_verify_nonce(sanitize_text_field($_POST['_wpnonce']),'calendar-config') == false) {
1389
  ?>
1390
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try editing the config again",'calendar'); ?></p></div>
1391
  <?php
1399
  else if ($_POST['permissions'] == 'admin') { $new_perms = 'manage_options'; }
1400
  else { $new_perms = 'manage_options'; }
1401
 
1402
+ // We want to sanitize this but the inbuilt function clatters an important char, re-instate it!
1403
+ $calendar_style = str_replace("&gt;",">",wp_filter_nohtml_kses($_POST['style']));
1404
+ $display_upcoming_days = sanitize_text_field($_POST['display_upcoming_days']);
1405
 
1406
  if ($_POST['display_author'] == 'on')
1407
  {
1647
 
1648
  // Now we render the form
1649
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1650
  <div class="wrap">
1651
  <h2><?php _e('Calendar Options','calendar'); ?></h2>
1652
+ <form name="quoteform" id="quoteform" class="wrap" method="post" action="<?php echo admin_url('admin.php?page=calendar-config'); ?>">
1653
  <?php wp_nonce_field('calendar-config'); ?>
1654
  <div id="linkadvanceddiv" class="postbox">
1655
  <div style="float: left; width: 98%; clear: both;" class="inside">
1743
  }
1744
 
1745
  // Function to handle the management of categories
1746
+ function calendar_manage_categories()
1747
  {
1748
  global $wpdb;
1749
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1750
  // We do some checking to see what we're doing
1751
  if (isset($_POST['mode']) && $_POST['mode'] == 'add')
1752
  {
1753
+ if (wp_verify_nonce(sanitize_text_field($_POST['_wpnonce']),'calendar-category_add') == false) {
1754
  ?>
1755
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try adding the category again",'calendar'); ?></p></div>
1756
  <?php
1757
  } else {
1758
  // Proceed with the save
1759
+ $sql = $wpdb->prepare("INSERT INTO " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_name='%s', category_colour='%s'",sanitize_text_field($_POST['category_name']),sanitize_text_field($_POST['category_colour']));
1760
  $wpdb->get_results($sql);
1761
  echo "<div class=\"updated\"><p><strong>".__('Category added successfully','calendar')."</strong></p></div>";
1762
  }
1763
  }
1764
  else if (isset($_GET['mode']) && isset($_GET['category_id']) && $_GET['mode'] == 'delete')
1765
  {
1766
+ if (wp_verify_nonce(sanitize_text_field($_GET['_wpnonce']),'calendar-category_delete_'.sanitize_text_field($_GET['category_id'])) == false) {
1767
  ?>
1768
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try deleting the category again",'calendar'); ?></p></div>
1769
  <?php
1770
  } else {
1771
+ $sql = $wpdb->prepare("DELETE FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=%d",sanitize_text_field($_GET['category_id']));
1772
  $wpdb->get_results($sql);
1773
+ $sql = $wpdb->prepare("UPDATE " . WP_CALENDAR_TABLE . " SET event_category=1 WHERE event_category=%d",sanitize_text_field($_GET['category_id']));
1774
  $wpdb->get_results($sql);
1775
  echo "<div class=\"updated\"><p><strong>".__('Category deleted successfully','calendar')."</strong></p></div>";
1776
  }
1777
  }
1778
  else if (isset($_GET['mode']) && isset($_GET['category_id']) && $_GET['mode'] == 'edit' && !isset($_POST['mode']))
1779
  {
1780
+ $sql = $wpdb->prepare("SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=%d",sanitize_text_field($_GET['category_id']));
1781
  $cur_cat = $wpdb->get_row($sql);
1782
  ?>
1783
  <div class="wrap">
1784
  <h2><?php _e('Edit Category','calendar'); ?></h2>
1785
+ <form name="catform" id="catform" class="wrap" method="post" action="<?php echo admin_url('admin.php?page=calendar-categories'); ?>">
1786
  <input type="hidden" name="mode" value="edit" />
1787
  <input type="hidden" name="category_id" value="<?php echo stripslashes($cur_cat->category_id) ?>" />
1788
  <?php wp_nonce_field('calendar-category_edit_'.stripslashes($cur_cat->category_id)); ?>
1808
  }
1809
  else if (isset($_POST['mode']) && isset($_POST['category_id']) && isset($_POST['category_name']) && isset($_POST['category_colour']) && $_POST['mode'] == 'edit')
1810
  {
1811
+ if (wp_verify_nonce(sanitize_text_field($_POST['_wpnonce']),'calendar-category_edit_'.sanitize_text_field($_POST['category_id'])) == false) {
1812
  ?>
1813
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("Security check failure, try editing the category again",'calendar'); ?></p></div>
1814
  <?php
1815
  } else {
1816
  // Proceed with the save
1817
+ $sql = $wpdb->prepare("UPDATE " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_name='%s', category_colour='%s' WHERE category_id=%d",sanitize_text_field($_POST['category_name']),sanitize_text_field($_POST['category_colour']),sanitize_text_field($_POST['category_id']));
1818
  $wpdb->get_results($sql);
1819
  echo "<div class=\"updated\"><p><strong>".__('Category edited successfully','calendar')."</strong></p></div>";
1820
  }
1838
 
1839
  <div class="wrap">
1840
  <h2><?php _e('Add Category','calendar'); ?></h2>
1841
+ <form name="catform" id="catform" class="wrap" method="post" action="<?php echo admin_url('admin.php?page=calendar-categories'); ?>">
1842
  <input type="hidden" name="mode" value="add" />
1843
  <input type="hidden" name="category_id" value="">
1844
  <?php wp_nonce_field('calendar-category_add'); ?>
1888
  <th scope="row"><?php echo stripslashes($category->category_id); ?></th>
1889
  <td><?php echo htmlspecialchars(stripslashes($category->category_name)); ?></td>
1890
  <td style="background-color:<?php echo stripslashes($category->category_colour); ?>;">&nbsp;</td>
1891
+ <td><a href="<?php echo admin_url('admin.php?page=calendar-categories&amp;mode=edit&amp;category_id='.stripslashes($category->category_id)) ?>" class='edit'><?php echo __('Edit','calendar'); ?></a></td>
1892
  <?php
1893
  if ($category->category_id == 1)
1894
  {
1897
  else
1898
  {
1899
  ?>
1900
+ <td><a href="<?php echo wp_nonce_url(admin_url('admin.php?page=calendar-categories&amp;mode=delete&amp;category_id='.stripslashes($category->category_id)), 'calendar-category_delete_'.stripslashes($category->category_id)); ?>" class="delete" onclick="return confirm('<?php echo __('Are you sure you want to delete this category?','calendar'); ?>')"><?php echo __('Delete','calendar'); ?></a></td>
1901
  <?php
1902
  }
1903
  ?>
1921
  }
1922
 
1923
  // Function to indicate the number of the day passed, eg. 1st or 2nd Sunday
1924
+ function calendar_np_of_day($date)
1925
  {
1926
  $instance = 0;
1927
  $dom = date('j',strtotime($date));
1934
  }
1935
 
1936
  // Function to provide date of the nth day passed (eg. 2nd Sunday)
1937
+ function calendar_dt_of_sun($date,$instance,$day)
1938
  {
1939
  $plan = array();
1940
  $plan['Mon'] = 1;
1960
 
1961
  // Function to return a prefix which will allow the correct
1962
  // placement of arguments into the query string.
1963
+ function calendar_permalink_prefix()
1964
  {
1965
  // Get the permalink structure from WordPress
1966
  if (is_home()) {
1977
  }
1978
 
1979
  // Configure the "Next" link in the calendar
1980
+ function calendar_next_link($cur_year,$cur_month,$minical = false)
1981
  {
1982
  $mod_rewrite_months = array(1=>'jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec');
1983
  $next_year = $cur_year + 1;
1985
  if ($cur_month == 12)
1986
  {
1987
  if ($minical) { $rlink = ''; } else { $rlink = __('Next','calendar'); }
1988
+ return '<a href="' . calendar_permalink_prefix() . 'month=jan&amp;yr=' . $next_year . '">'.$rlink.' &raquo;</a>';
1989
  }
1990
  else
1991
  {
1992
  $next_month = $cur_month + 1;
1993
  $month = $mod_rewrite_months[$next_month];
1994
  if ($minical) { $rlink = ''; } else { $rlink = __('Next','calendar'); }
1995
+ return '<a href="' . calendar_permalink_prefix() . 'month='.$month.'&amp;yr=' . $cur_year . '">'.$rlink.' &raquo;</a>';
1996
  }
1997
  }
1998
 
1999
  // Configure the "Previous" link in the calendar
2000
+ function calendar_prev_link($cur_year,$cur_month,$minical = false)
2001
  {
2002
  $mod_rewrite_months = array(1=>'jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec');
2003
  $last_year = $cur_year - 1;
2005
  if ($cur_month == 1)
2006
  {
2007
  if ($minical) { $llink = ''; } else { $llink = __('Prev','calendar'); }
2008
+ return '<a href="' . calendar_permalink_prefix() . 'month=dec&amp;yr='. $last_year .'">&laquo; '.$llink.'</a>';
2009
  }
2010
  else
2011
  {
2012
  $next_month = $cur_month - 1;
2013
  $month = $mod_rewrite_months[$next_month];
2014
  if ($minical) { $llink = ''; } else { $llink = __('Prev','calendar'); }
2015
+ return '<a href="' . calendar_permalink_prefix() . 'month='.$month.'&amp;yr=' . $cur_year . '">&laquo; '.$llink.'</a>';
2016
  }
2017
  }
2018
 
2019
  // Print upcoming events
2020
+ function calendar_upcoming_events($cat_list = '')
2021
  {
2022
  global $wpdb;
2023
 
2033
  $output = '';
2034
  while ($day_count < $future_days+1)
2035
  {
2036
+ list($y,$m,$d) = explode("-",date("Y-m-d",mktime($day_count*24,0,0,date("m",calendar_ctwo()),date("d",calendar_ctwo()),date("Y",calendar_ctwo()))));
2037
  $events = grab_events($y,$m,$d,'upcoming',$cat_list);
2038
+ usort($events, "calendar_time_cmp");
2039
  if (count($events) != 0) {
2040
+ $output .= '<li>'.date_i18n(get_option('date_format'),mktime($day_count*24,0,0,date("m",calendar_ctwo()),date("d",calendar_ctwo()),date("Y",calendar_ctwo()))).'<ul>';
2041
  }
2042
  foreach($events as $event)
2043
  {
2047
  else {
2048
  $time_string = ' '.__('at','calendar').' '.date(get_option('time_format'), strtotime(stripslashes($event->event_time)));
2049
  }
2050
+ $output .= '<li>'.calendar_draw_event($event).$time_string.'</li>';
2051
  }
2052
  if (count($events) != 0) {
2053
  $output .= '</ul></li>';
2066
  }
2067
 
2068
  // Print todays events
2069
+ function calendar_todays_events($cat_list = '')
2070
  {
2071
  global $wpdb;
2072
 
2076
  if ($display == 'true')
2077
  {
2078
  $output = '<ul>';
2079
+ $events = grab_events(date("Y",calendar_ctwo()),date("m",calendar_ctwo()),date("d",calendar_ctwo()),'todays',$cat_list);
2080
+ usort($events, "calendar_time_cmp");
2081
  foreach($events as $event)
2082
  {
2083
  if ($event->event_time == '00:00:00') {
2086
  else {
2087
  $time_string = ' '.__('at','calendar').' '.date(get_option('time_format'), strtotime(stripslashes($event->event_time)));
2088
  }
2089
+ $output .= '<li>'.calendar_draw_event($event).$time_string.'</li>';
2090
  }
2091
  $output .= '</ul>';
2092
  if (count($events) != 0)
2097
  }
2098
 
2099
  // Function to compare time in event objects
2100
+ function calendar_time_cmp($a, $b)
2101
  {
2102
  if ($a->event_time == $b->event_time) {
2103
  return 0;
2106
  }
2107
 
2108
  // Used to draw multiple events
2109
+ function calendar_draw_events($events)
2110
  {
2111
  // We need to sort arrays of objects by time
2112
+ usort($events, "calendar_time_cmp");
2113
  $output = '';
2114
  // Now process the events
2115
  foreach($events as $event)
2116
  {
2117
+ $output .= '* '.calendar_draw_event($event).'<br />';
2118
  $output = apply_filters('modify_drawn_event_content', $output, $event);
2119
  }
2120
  return $output;
2131
  $the_title = stripslashes(get_option('events_calendar_widget_title'));
2132
  $the_cats = stripslashes(get_option('events_calendar_widget_cats'));
2133
  $widget_title = empty($the_title) ? __('Calendar','calendar') : $the_title;
2134
+ $the_events = calendar_minical($the_cats);
2135
  if ($the_events != '') {
2136
  echo $before_widget;
2137
  echo $before_title . $widget_title . $after_title;
2144
  $widget_title = stripslashes(get_option('events_calendar_widget_title'));
2145
  $widget_cats = stripslashes(get_option('events_calendar_widget_cats'));
2146
  if (isset($_POST['events_calendar_widget_title']) || isset($_POST['events_calendar_widget_cats'])) {
2147
+ update_option('events_calendar_widget_title',sanitize_text_field($_POST['events_calendar_widget_title']));
2148
+ update_option('events_calendar_widget_cats',sanitize_text_field($_POST['events_calendar_widget_cats']));
2149
  }
2150
  ?>
2151
  <p>
2172
  $the_title = stripslashes(get_option('calendar_today_widget_title'));
2173
  $the_cats = stripslashes(get_option('calendar_today_widget_cats'));
2174
  $widget_title = empty($the_title) ? __('Today\'s Events','calendar') : $the_title;
2175
+ $the_events = calendar_todays_events($the_cats);
2176
  if ($the_events != '') {
2177
  echo $before_widget;
2178
  echo $before_title . $widget_title . $after_title;
2185
  $widget_title = stripslashes(get_option('calendar_today_widget_title'));
2186
  $widget_cats = stripslashes(get_option('calendar_today_widget_cats'));
2187
  if (isset($_POST['calendar_today_widget_title']) || isset($_POST['calendar_today_widget_cats'])) {
2188
+ update_option('calendar_today_widget_title',sanitize_text_field($_POST['calendar_today_widget_title']));
2189
+ update_option('calendar_today_widget_cats',sanitize_text_field($_POST['calendar_today_widget_cats']));
2190
  }
2191
  ?>
2192
  <p>
2213
  $the_title = stripslashes(get_option('calendar_upcoming_widget_title'));
2214
  $the_cats = stripslashes(get_option('calendar_upcoming_widget_cats'));
2215
  $widget_title = empty($the_title) ? __('Upcoming Events','calendar') : $the_title;
2216
+ $the_events = calendar_upcoming_events($the_cats);
2217
  if ($the_events != '') {
2218
  echo $before_widget;
2219
  echo $before_title . $widget_title . $after_title;
2226
  $widget_title = stripslashes(get_option('calendar_upcoming_widget_title'));
2227
  $widget_cats = stripslashes(get_option('calendar_upcoming_widget_cats'));
2228
  if (isset($_POST['calendar_upcoming_widget_title']) || isset($_POST['calendar_upcoming_widget_cats'])) {
2229
+ update_option('calendar_upcoming_widget_title',sanitize_text_field($_POST['calendar_upcoming_widget_title']));
2230
+ update_option('calendar_upcoming_widget_cats',sanitize_text_field($_POST['calendar_upcoming_widget_cats']));
2231
  }
2232
  ?>
2233
  <p>
2244
  }
2245
 
2246
  // Used to draw an event to the screen
2247
+ function calendar_draw_event($event)
2248
  {
2249
  global $wpdb;
2250
 
2386
  }
2387
  else if ($event->type == 'MonthSun')
2388
  {
2389
+ // This used to be complex but writing the calendar_dt_of_sun() function helped loads!
2390
 
2391
  // Technically we don't care about the years or months, but we need to find out if the
2392
  // event spans the turn of a year or month so we can deal with it appropriately.
2396
  // Setup some variables and get some values
2397
  $dow = date('w',strtotime($event->event_begin));
2398
  if ($dow == 0) { $dow = 7; }
2399
+ $start_ent_this = calendar_dt_of_sun($date,calendar_np_of_day($event->event_begin),$dow);
2400
+ $start_ent_prev = calendar_dt_of_sun(date('Y-m-d',strtotime($date.'-1 month')),calendar_np_of_day($event->event_begin),$dow);
2401
  $len_ent = strtotime($event->event_end)-strtotime($event->event_begin);
2402
 
2403
  // The grunt work
2475
  // Setup comparison functions for building the calendar later
2476
  function calendar_month_comparison($month)
2477
  {
2478
+ $get_year = (isset($_GET['yr']) ? sanitize_text_field($_GET['yr']) : null);
2479
+ $get_month = (isset($_GET['month']) ? sanitize_text_field($_GET['month']) : null);
2480
+ $current_month = strtolower(date("M", calendar_ctwo()));
2481
  if (isset($get_year) && isset($get_month))
2482
  {
2483
  if ($month == $get_month)
2492
  }
2493
  function calendar_year_comparison($year)
2494
  {
2495
+ $get_year = (isset($_GET['yr']) ? sanitize_text_field($_GET['yr']) : null);
2496
+ $get_month = (isset($_GET['month']) ? sanitize_text_field($_GET['month']) : null);
2497
+ $current_year = strtolower(date("Y", calendar_ctwo()));
2498
  if (isset($get_year) && isset($get_month))
2499
  {
2500
  if ($year == $get_year)
2515
  {
2516
  global $wpdb;
2517
 
2518
+ $get_year = (isset($_GET['yr']) ? sanitize_text_field($_GET['yr']) : null);
2519
+ $get_month = (isset($_GET['month']) ? sanitize_text_field($_GET['month']) : null);
2520
 
2521
  // Deal with the week not starting on a monday
2522
  if (get_option('start_of_week') == 0)
2535
  // If we don't pass arguments we want a calendar that is relevant to today
2536
  if (empty($get_month) || empty($get_year))
2537
  {
2538
+ $c_year = date("Y",calendar_ctwo());
2539
+ $c_month = date("m",calendar_ctwo());
2540
+ $c_day = date("d",calendar_ctwo());
2541
  }
2542
 
2543
  // Years get funny if we exceed 3000, so we use this check
2566
  else if ($get_month == 'nov') { $t_month = 11; }
2567
  else if ($get_month == 'dec') { $t_month = 12; }
2568
  $c_month = $t_month;
2569
+ $c_day = date("d",calendar_ctwo());
2570
  }
2571
  // No valid month causes the calendar to default to today
2572
  else
2573
  {
2574
+ $c_year = date("Y",calendar_ctwo());
2575
+ $c_month = date("m",calendar_ctwo());
2576
+ $c_day = date("d",calendar_ctwo());
2577
  }
2578
  }
2579
  }
2580
  // No valid year causes the calendar to default to today
2581
  else
2582
  {
2583
+ $c_year = date("Y",calendar_ctwo());
2584
+ $c_month = date("m",calendar_ctwo());
2585
+ $c_day = date("d",calendar_ctwo());
2586
  }
2587
 
2588
  // Fix the days of the week if week start is not on a monday
2656
  while ($past > 0)
2657
  {
2658
  $p .= ' <option value="';
2659
+ $p .= date("Y",calendar_ctwo())-$past;
2660
+ $p .= '"'.calendar_year_comparison(date("Y",calendar_ctwo())-$past).'>';
2661
+ $p .= date("Y",calendar_ctwo())-$past.'</option>
2662
  ';
2663
  $past = $past - 1;
2664
  }
2665
  while ($fut < $future)
2666
  {
2667
  $f .= ' <option value="';
2668
+ $f .= date("Y",calendar_ctwo())+$fut;
2669
+ $f .= '"'.calendar_year_comparison(date("Y",calendar_ctwo())+$fut).'>';
2670
+ $f .= date("Y",calendar_ctwo())+$fut.'</option>
2671
  ';
2672
  $fut = $fut + 1;
2673
  }
2674
  $calendar_body .= $p;
2675
+ $calendar_body .= ' <option value="'.date("Y",calendar_ctwo()).'"'.calendar_year_comparison(date("Y",calendar_ctwo())).'>'.date("Y",calendar_ctwo()).'</option>
2676
  ';
2677
  $calendar_body .= $f;
2678
  $calendar_body .= '</select>
2688
  <td colspan="7" class="calendar-heading">
2689
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
2690
  <tr>
2691
+ <td class="calendar-prev">' . calendar_prev_link($c_year,$c_month) . '</td>
2692
  <td class="calendar-month">'.$name_months[(int)$c_month].' '.$c_year.'</td>
2693
+ <td class="calendar-next">' . calendar_next_link($c_year,$c_month) . '</td>
2694
  </tr>
2695
  </table>
2696
  </td>
2743
  {
2744
  $no_events_class = ' no-events';
2745
  }
2746
+ $calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd",calendar_ctwo())?'current-day':'day-with-date').$no_events_class.'"><span '.($ii<7&&$ii>1?'':'class="weekend"').'>'.$i++.'</span><span class="event"><br />' . calendar_draw_events($grabbed_events) . '</span></td>
2747
  ';
2748
  }
2749
  else
2754
  {
2755
  $no_events_class = ' no-events';
2756
  }
2757
+ $calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd",calendar_ctwo())?'current-day':'day-with-date').$no_events_class.'"><span '.($ii<6?'':'class="weekend"').'>'.$i++.'</span><span class="event"><br />' . calendar_draw_events($grabbed_events) . '</span></td>
2758
  ';
2759
  }
2760
  }
2815
  }
2816
 
2817
  // Used to create a hover will all a day's events in for minical
2818
+ function calendar_minical_draw_events($events,$day_of_week = '')
2819
  {
2820
  // We need to sort arrays of objects by time
2821
+ usort($events, "calendar_time_cmp");
2822
  // Only show anything if there are events
2823
  $output = '';
2824
  if (count($events)) {
2838
  return $output;
2839
  }
2840
 
2841
+ function calendar_minical($cat_list = '') {
2842
 
2843
  global $wpdb;
2844
 
2845
+ $get_year = (isset($_GET['yr']) ? sanitize_text_field($_GET['yr']) : null);
2846
+ $get_month = (isset($_GET['month']) ? sanitize_text_field($_GET['month']) : null);
2847
 
2848
  // Deal with the week not starting on a monday
2849
  if (get_option('start_of_week') == 0)
2863
  // If we don't pass arguments we want a calendar that is relevant to today
2864
  if (empty($get_month) || empty($get_year))
2865
  {
2866
+ $c_year = date("Y",calendar_ctwo());
2867
+ $c_month = date("m",calendar_ctwo());
2868
+ $c_day = date("d",calendar_ctwo());
2869
  }
2870
 
2871
  // Years get funny if we exceed 3000, so we use this check
2894
  else if ($get_month == 'nov') { $t_month = 11; }
2895
  else if ($get_month == 'dec') { $t_month = 12; }
2896
  $c_month = $t_month;
2897
+ $c_day = date("d",calendar_ctwo());
2898
  }
2899
  // No valid month causes the calendar to default to today
2900
  else
2901
  {
2902
+ $c_year = date("Y",calendar_ctwo());
2903
+ $c_month = date("m",calendar_ctwo());
2904
+ $c_day = date("d",calendar_ctwo());
2905
  }
2906
  }
2907
  }
2908
  // No valid year causes the calendar to default to today
2909
  else
2910
  {
2911
+ $c_year = date("Y",calendar_ctwo());
2912
+ $c_month = date("m",calendar_ctwo());
2913
+ $c_day = date("d",calendar_ctwo());
2914
  }
2915
 
2916
  // Fix the days of the week if week start is not on a monday
2940
  <td colspan="7" class="calendar-heading" style="height:0;">
2941
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
2942
  <tr>
2943
+ <td class="calendar-prev">' . calendar_prev_link($c_year,$c_month,true) . '</td>
2944
  <td class="calendar-month">'.$name_months[(int)$c_month].' '.$c_year.'</td>
2945
+ <td class="calendar-next">' . calendar_next_link($c_year,$c_month,true) . '</td>
2946
  </tr>
2947
  </table>
2948
  </td>
2995
  {
2996
  $no_events_class = ' no-events';
2997
  }
2998
+ $calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd",calendar_ctwo())?'current-day':'day-with-date').$no_events_class.'" style="height:0;"><span '.($ii<7&&$ii>1?'':'class="weekend"').'>'.calendar_minical_draw_events($grabbed_events,$i++).'</span></td>
2999
  ';
3000
  }
3001
  else
3006
  {
3007
  $no_events_class = ' no-events';
3008
  }
3009
+ $calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd",calendar_ctwo())?'current-day':'day-with-date').$no_events_class.'" style="height:0;"><span '.($ii<6?'':'class="weekend"').'>'.calendar_minical_draw_events($grabbed_events,$i++).'</span></td>
3010
  ';
3011
  }
3012
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.kieranoshea.com
4
  Tags: calendar, dates, times, events
5
  Requires at least: 4.3.1
6
  Tested up to: 5.0
7
- Stable tag: 1.3.11
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.
@@ -51,19 +51,33 @@ The installation is extremely simple and straightforward. It only takes a second
51
 
52
  1. Upload the whole calendar directory into your WordPress plugins directory.
53
  2. Activate the plugin on your WordPress plugins page
54
- 3. Configure Calendar using the following pages in the admin panel: **Calendar -> Manage Events**, **Calendar -> Manage Categories**, and **Calendar -> Calendar Options**
55
  4. Edit or create a page on your blog which includes the text `{CALENDAR}` and visit
56
  the page you have edited or created. You should see your calendar in action.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  = Upgrading from 1.2 or later =
59
 
60
  1. Deactivate the plugin (you will not lose any events)
61
  2. Remove your current calendar directory from the WordPress plugins directory
62
- 2. Upload the whole calendar directory into your WordPress plugins directory.
63
- 3. Activate the plugin on your WordPress plugins page
64
- 4. Configure Calendar using the following pages in the admin panel: **Calendar -> Manage Events**, **Calendar -> Manage Categories**, and **Calendar -> Calendar Options**
65
- 5. Edit or create a page on your blog which includes the text `{CALENDAR}` and visit
66
- the page you have edited or created page. You should see your calendar in action.
67
 
68
  = Upgrading from 1.1 =
69
 
@@ -73,9 +87,6 @@ The installation is extremely simple and straightforward. It only takes a second
73
  3. Delete plugins/calendar.php, wp-admin/edit-calendar.php, wp-calendar.php
74
  4. Upload the whole calendar directory into your WordPress plugins directory.
75
  5. Activate the plugin on your WordPress plugins page
76
- 6. Configure Calendar using the following pages in the admin panel: **Calendar -> Manage Events**, **Calendar -> Manage Categories**, and **Calendar -> Calendar Options**
77
- 7. Edit or create a page on your blog which includes the text `{CALENDAR}` and visit
78
- the page you have edited or created page. You should see your calendar in action.
79
 
80
  = Uninstalling =
81
 
@@ -122,8 +133,8 @@ To do this under WordPress 2.8 there are a pair of widgets that you can add to y
122
 
123
  Under WordPress 2.0 or where your theme does not support widgets you need to modify the sidebar.php file of your theme to include the following code as appropriate:
124
  `
125
- <?php echo todays_events(); ?>
126
- <?php echo upcoming_events(); ?>
127
  `
128
 
129
  = How do I place an instance of calendar in a post or page? =
@@ -227,6 +238,14 @@ You've not called wp_head() in your theme's header and/or wp_footer() in your th
227
 
228
  == Changelog ==
229
 
 
 
 
 
 
 
 
 
230
  = 1.3.11 =
231
  * Fixed reported XSS issues with category name and event title
232
 
4
  Tags: calendar, dates, times, events
5
  Requires at least: 4.3.1
6
  Tested up to: 5.0
7
+ Stable tag: 1.3.12
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.
51
 
52
  1. Upload the whole calendar directory into your WordPress plugins directory.
53
  2. Activate the plugin on your WordPress plugins page
54
+ 3. Configure Calendar using the following pages in the admin panel: **Calendar -> Manage Calendar**, **Calendar -> Manage Categories**, and **Calendar -> Calendar Options**
55
  4. Edit or create a page on your blog which includes the text `{CALENDAR}` and visit
56
  the page you have edited or created. You should see your calendar in action.
57
+ 5. You'll see two new widgets, "Today's Events" and "Upcoming Events" that will render data from the plugin. These can
58
+ be configured with custom titles and limited to certain categories by specifying their IDs, comma separated
59
+ 6. Additional data from the calendar may be inserted into posts and pages using the following legacy tags. Note the
60
+ inclusion of optional category ids to limit display in this way
61
+ `{CALENDAR} or {CALENDAR;1} or {CALENDAR;1,2}`
62
+ `{MINICAL} or {MINICAL;1} or {MINICAL;1,2}`
63
+ `{TODAYS_EVENTS} or {TODAYS_EVENTS;1} or {TODAYS_EVENTS;1,3}`
64
+ `{UPCOMING_EVENTS} or {UPCOMING_EVENTS;1} or {UPCOMING_EVENTS;1,3}`
65
+ 7. Later versions of the plugin also support the new WordPress short code system, examples as follows
66
+ `[calendar] or [calendar categories="1,3"] or [calendar type="mini" categories="1"] or [calendar type="upcoming"]`
67
+ 8. There is an iCalendar available within calendar. Once activated on the calendar options page, simply visit your site
68
+ with calendar_feed appended, e.g.
69
+ `example.com/?calendar_feed`
70
+ 9. If you're coding your own theme or plugin, you can call out to calendar functions directly to include content
71
+ `calendar() or calendar("1") or calendar("1,3")`
72
+ alternatively all the below using similar variations to the above for categories
73
+ `calendar_minical() or calendar_upcoming_events() or calendar_todays_events()`
74
 
75
  = Upgrading from 1.2 or later =
76
 
77
  1. Deactivate the plugin (you will not lose any events)
78
  2. Remove your current calendar directory from the WordPress plugins directory
79
+ 3. Upload the whole calendar directory into your WordPress plugins directory.
80
+ 4. Activate the plugin on your WordPress plugins page
 
 
 
81
 
82
  = Upgrading from 1.1 =
83
 
87
  3. Delete plugins/calendar.php, wp-admin/edit-calendar.php, wp-calendar.php
88
  4. Upload the whole calendar directory into your WordPress plugins directory.
89
  5. Activate the plugin on your WordPress plugins page
 
 
 
90
 
91
  = Uninstalling =
92
 
133
 
134
  Under WordPress 2.0 or where your theme does not support widgets you need to modify the sidebar.php file of your theme to include the following code as appropriate:
135
  `
136
+ <?php echo calendar_todays_events(); ?>
137
+ <?php echo calendar_upcoming_events(); ?>
138
  `
139
 
140
  = How do I place an instance of calendar in a post or page? =
238
 
239
  == Changelog ==
240
 
241
+ = 1.3.12 =
242
+ * Removed ability to access PHP files directly
243
+ * Change import of admin CSS and JS to enqueue
244
+ * Removed an erroneous direct reference to the wp-content directory
245
+ * Enhance sanitisation of some admin side user input
246
+ * Ensure all functions are prefixed with plugin name to avoid clashes with other plugins
247
+ * Fixed some bugs with short codes and updated the documentation surrounding these and changed function names
248
+
249
  = 1.3.11 =
250
  * Fixed reported XSS issues with category name and event title
251