My Calendar - Version 1.4.0

Version Description

  • Bug fixed: Today's Events widget was not taking internationalized time as it's argument
  • Added end time field for events
  • Added option for links to expire after events have occurred.
  • Added options for alternate applications of category colors in output.
  • Added ability to use My Calendar shortcodes in text widgets.
  • Added GPS location option for locations
  • Added zoom selection options for map links
  • Lengthened maximum length for category and event titles
  • Added a close link on opened events details boxes.
  • Added an option for a mini calendar display type in shortcode
  • Optimized some SQL queries and reduced total number of queries significantly.
  • Extended the featured to show CSS only on certain pages to include JavaScript as well.
  • Upcoming events widget only allowed up to 99 events to be shown forward or back. Changed to 999.
  • Attempted to solve a problem with infinitely recurring events not appearing in upcoming events. Let me know.
  • Added setting to change Previous Month/Next Month text.
  • Yeah, that's enough for now.
Download this release

Release Info

Developer joedolson
Plugin Icon 128x128 My Calendar
Version 1.4.0
Comparing to
See all releases

Code changes from version 1.3.8 to 1.4.0

images/event-close.png ADDED
Binary file
my-calendar-categories.php CHANGED
@@ -58,7 +58,7 @@ function my_calendar_manage_categories() {
58
</div>
59
<fieldset>
60
<legend><?php _e('Edit Category','my-calendar'); ?></legend>
61
- <label for="category_name"><?php _e('Category Name','my-calendar'); ?>:</label> <input type="text" id="category_name" name="category_name" class="input" size="30" maxlength="30" value="<?php echo $cur_cat->category_name ?>" /><br />
62
<label for="category_color"><?php _e('Category Color (Hex format)','my-calendar'); ?>:</label> <input type="text" id="category_color" name="category_color" class="input" size="10" maxlength="7" value="<?php echo $cur_cat->category_color ?>" /><br />
63
<label for="category_icon"><?php _e('Category Icon','my-calendar'); ?>:</label> <select name="category_icon" id="category_icon">
64
<?php
@@ -111,7 +111,7 @@ if ($cur_cat->category_icon == $value) {
111
</div>
112
<fieldset>
113
<legend><?php _e('Add Category'); ?></legend>
114
- <label for="category_name"><?php _e('Category Name','my-calendar'); ?>:</label> <input type="text" id="category_name" name="category_name" class="input" size="30" maxlength="30" value="" /><br />
115
<label for="category_color"><?php _e('Category Color (Hex format)','my-calendar'); ?>:</label> <input type="text" id="category_color" name="category_color" class="input" size="10" maxlength="7" value="#" /><br />
116
<label for="category_icon"><?php _e('Category Icon','my-calendar'); ?>:</label> <select name="category_icon" id="category_icon">
117
<?php
58
</div>
59
<fieldset>
60
<legend><?php _e('Edit Category','my-calendar'); ?></legend>
61
+ <label for="category_name"><?php _e('Category Name','my-calendar'); ?>:</label> <input type="text" id="category_name" name="category_name" class="input" size="30" value="<?php echo $cur_cat->category_name ?>" /><br />
62
<label for="category_color"><?php _e('Category Color (Hex format)','my-calendar'); ?>:</label> <input type="text" id="category_color" name="category_color" class="input" size="10" maxlength="7" value="<?php echo $cur_cat->category_color ?>" /><br />
63
<label for="category_icon"><?php _e('Category Icon','my-calendar'); ?>:</label> <select name="category_icon" id="category_icon">
64
<?php
111
</div>
112
<fieldset>
113
<legend><?php _e('Add Category'); ?></legend>
114
+ <label for="category_name"><?php _e('Category Name','my-calendar'); ?>:</label> <input type="text" id="category_name" name="category_name" class="input" size="30" value="" /><br />
115
<label for="category_color"><?php _e('Category Color (Hex format)','my-calendar'); ?>:</label> <input type="text" id="category_color" name="category_color" class="input" size="10" maxlength="7" value="#" /><br />
116
<label for="category_icon"><?php _e('Category Icon','my-calendar'); ?>:</label> <select name="category_icon" id="category_icon">
117
<?php
my-calendar-event-manager.php CHANGED
@@ -3,8 +3,8 @@
3
// to deal with posts
4
function edit_my_calendar() {
5
global $current_user, $wpdb, $users_entries;
6
- ?>
7
-
8
<?php
9
if ( get_option('ko_calendar_imported') != 'true' ) {
10
if (function_exists('check_calendar')) {
@@ -75,13 +75,15 @@ if ( $action == 'add' ) {
75
$begin = !empty($_POST['event_begin']) ? $_POST['event_begin'] : '';
76
$end = !empty($_POST['event_end']) ? $_POST['event_end'] : $begin;
77
$time = !empty($_POST['event_time']) ? $_POST['event_time'] : '';
78
$recur = !empty($_POST['event_recur']) ? $_POST['event_recur'] : '';
79
$repeats = !empty($_POST['event_repeats']) ? $_POST['event_repeats'] : 0;
80
$category = !empty($_POST['event_category']) ? $_POST['event_category'] : '';
81
$linky = !empty($_POST['event_link']) ? $_POST['event_link'] : '';
82
- $event_preset = !empty($_POST['event_preset']) ? $_POST['event_preset'] : '';
83
- if ($event_preset != 'none') {
84
- $sql = "SELECT * FROM " . MY_CALENDAR_LOCATIONS_TABLE . " WHERE location_id = $event_preset";
85
$location = $wpdb->get_row($sql);
86
$event_label = $location->location_label;
87
$event_street = $location->location_street;
@@ -90,6 +92,9 @@ if ( $action == 'add' ) {
90
$event_state = $location->location_state;
91
$event_postcode = $location->location_postcode;
92
$event_country = $location->location_country;
93
} else {
94
$event_label = !empty($_POST['event_label']) ? $_POST['event_label'] : '';
95
$event_street = !empty($_POST['event_street']) ? $_POST['event_street'] : '';
@@ -97,7 +102,10 @@ if ( $action == 'add' ) {
97
$event_city = !empty($_POST['event_city']) ? $_POST['event_city'] : '';
98
$event_state = !empty($_POST['event_state']) ? $_POST['event_state'] : '';
99
$event_postcode = !empty($_POST['event_postcode']) ? $_POST['event_postcode'] : '';
100
- $event_country = !empty($_POST['event_country']) ? $_POST['event_country'] : '';
101
}
102
// Deal with the fools who have left magic quotes turned on
103
if ( ini_get('magic_quotes_gpc') ) {
@@ -106,17 +114,23 @@ if ( $action == 'add' ) {
106
$begin = stripslashes($begin);
107
$end = stripslashes($end);
108
$time = stripslashes($time);
109
$recur = stripslashes($recur);
110
$repeats = stripslashes($repeats);
111
$category = stripslashes($category);
112
$linky = stripslashes($linky);
113
$event_label = stripslashes($event_label);
114
$event_street = stripslashes($event_street);
115
$event_street2 = stripslashes($event_street2);
116
$event_city = stripslashes($event_city);
117
$event_state = stripslashes($event_state);
118
$event_postcode = stripslashes($event_postcode);
119
- $event_country = stripslashes($event_country);
120
}
121
122
// Perform some validation on the submitted dates - this checks for valid years and months
@@ -170,13 +184,13 @@ if ( $action == 'add' ) {
170
<div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('The URL entered must either be prefixed with http:// or be completely blank','my-calendar'); ?></p></div>
171
<?php
172
}
173
- // The title must be at least one character in length and no more than 60 - only basic punctuation is allowed
174
$title_length = strlen($title);
175
- if ( $title_length > 1 && $title_length <= 60 ) {
176
$title_ok =1;
177
} else {
178
?>
179
- <div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 60 characters in length.','my-calendar'); ?></p></div>
180
<?php
181
}
182
// We run some checks on recurrance
@@ -188,31 +202,39 @@ if ( $action == 'add' ) {
188
<?php
189
}
190
if ($start_date_ok == 1 && $end_date_ok == 1 && $time_ok == 1 && $url_ok == 1 && $title_ok == 1 && $recurring_ok == 1) {
191
- $sql = "INSERT INTO " . MY_CALENDAR_TABLE . " SET
192
- event_title='" . mysql_real_escape_string($title) . "',
193
- event_desc='" . mysql_real_escape_string($desc) . "',
194
- event_begin='" . mysql_real_escape_string($begin) . "',
195
- event_end='" . mysql_real_escape_string($end) . "',
196
- event_time='" . mysql_real_escape_string($time) . "',
197
- event_recur='" . mysql_real_escape_string($recur) . "',
198
- event_repeats=" . mysql_real_escape_string($repeats) . ",
199
- event_author=".$current_user->ID.",
200
- event_category=".mysql_real_escape_string($category).",
201
- event_link='".mysql_real_escape_string($linky)."',
202
- event_label='".mysql_real_escape_string($event_label)."',
203
- event_street='".mysql_real_escape_string($event_street)."',
204
- event_street2='".mysql_real_escape_string($event_street2)."',
205
- event_city='".mysql_real_escape_string($event_city)."',
206
- event_state='".mysql_real_escape_string($event_state)."',
207
- event_postcode='".mysql_real_escape_string($event_postcode)."',
208
- event_country='".mysql_real_escape_string($event_country)."'";
209
-
210
- $wpdb->get_results($sql);
211
- $sql = "SELECT event_id FROM " . MY_CALENDAR_TABLE . " WHERE event_title='" . mysql_real_escape_string($title) . "'"
212
- . " AND event_desc='" . mysql_real_escape_string($desc) . "' AND event_begin='" . mysql_real_escape_string($begin) . "' AND event_end='" . mysql_real_escape_string($end) . "' AND event_recur='" . mysql_real_escape_string($recur) . "' AND event_repeats=" . mysql_real_escape_string($repeats) . " LIMIT 1";
213
- $result = $wpdb->get_results($sql);
214
-
215
- if ( empty($result) || empty($result[0]->event_id) ) {
216
?>
217
<div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('An event with the details you submitted could not be found in the database. This may indicate a problem with your database or the way in which it is configured.','my-calendar'); ?></p></div>
218
<?php
@@ -228,32 +250,40 @@ if ( $action == 'add' ) {
228
$users_entries->event_begin = $begin;
229
$users_entries->event_end = $end;
230
$users_entries->event_time = $time;
231
$users_entries->event_recur = $recur;
232
$users_entries->event_repeats = $repeats;
233
$users_entries->event_category = $category;
234
$users_entries->event_link = $linky;
235
$users_entries->event_label = $event_label;
236
$users_entries->event_street = $event_street;
237
$users_entries->event_street2 = $event_street2;
238
$users_entries->event_city = $event_city;
239
$users_entries->event_state = $event_state;
240
$users_entries->event_postcode = $event_postcode;
241
- $users_entries->event_country = $event_country;
242
}
243
// Permit saving of events that have been edited
244
} elseif ( $action == 'edit_save' ) {
245
$title = !empty($_POST['event_title']) ? $_POST['event_title'] : '';
246
- $desc = !empty($_POST['event_desc']) ? $_POST['event_desc'] : '';
247
$begin = !empty($_POST['event_begin']) ? $_POST['event_begin'] : '';
248
$end = !empty($_POST['event_end']) ? $_POST['event_end'] : $begin;
249
$time = !empty($_POST['event_time']) ? $_POST['event_time'] : '';
250
$recur = !empty($_POST['event_recur']) ? $_POST['event_recur'] : '';
251
$repeats = !empty($_POST['event_repeats']) ? $_POST['event_repeats'] : 0;
252
$category = !empty($_POST['event_category']) ? $_POST['event_category'] : '';
253
$linky = !empty($_POST['event_link']) ? $_POST['event_link'] : '';
254
- $event_preset = !empty($_POST['event_preset']) ? $_POST['event_preset'] : '';
255
- if ($event_preset != 'none') {
256
- $sql = "SELECT * FROM " . MY_CALENDAR_LOCATIONS_TABLE . " WHERE location_id = $event_preset";
257
$location = $wpdb->get_row($sql);
258
$event_label = $location->location_label;
259
$event_street = $location->location_street;
@@ -262,6 +292,9 @@ if ( $action == 'add' ) {
262
$event_state = $location->location_state;
263
$event_postcode = $location->location_postcode;
264
$event_country = $location->location_country;
265
} else {
266
$event_label = !empty($_POST['event_label']) ? $_POST['event_label'] : '';
267
$event_street = !empty($_POST['event_street']) ? $_POST['event_street'] : '';
@@ -270,6 +303,10 @@ if ( $action == 'add' ) {
270
$event_state = !empty($_POST['event_state']) ? $_POST['event_state'] : '';
271
$event_postcode = !empty($_POST['event_postcode']) ? $_POST['event_postcode'] : '';
272
$event_country = !empty($_POST['event_country']) ? $_POST['event_country'] : '';
273
}
274
$event_author = !empty($_POST['event_author']) ? $_POST['event_author'] : '';
275
@@ -283,10 +320,12 @@ if ( $action == 'add' ) {
283
$begin = stripslashes($begin);
284
$end = stripslashes($end);
285
$time = stripslashes($time);
286
$recur = stripslashes($recur);
287
$repeats = stripslashes($repeats);
288
$category = stripslashes($category);
289
$linky = stripslashes($linky);
290
$event_label = stripslashes($event_label);
291
$event_street = stripslashes($event_street);
292
$event_street2 = stripslashes($event_street2);
@@ -294,6 +333,10 @@ if ( $action == 'add' ) {
294
$event_state = stripslashes($event_state);
295
$event_postcode = stripslashes($event_postcode);
296
$event_country = stripslashes($event_country);
297
$event_author = stripslashes($event_author);
298
}
299
@@ -353,13 +396,13 @@ if ( $action == 'add' ) {
353
<div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('The URL entered must either be prefixed with http:// or be completely blank','my-calendar'); ?></p></div>
354
<?php
355
}
356
- // The title must be at least one character in length and no more than 60 - no non-standard characters allowed
357
$title_length = strlen($title);
358
- if ( $title_length > 1 && $title_length <= 60 ) {
359
$title_ok =1;
360
} else {
361
?>
362
- <div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 60 characters in length.','my-calendar'); ?></p></div>
363
<?php
364
}
365
// We run some checks on recurrance
@@ -371,34 +414,41 @@ if ( $action == 'add' ) {
371
<?php
372
}
373
if ($start_date_ok == 1 && $end_date_ok == 1 && $time_ok == 1 && $url_ok == 1 && $title_ok && $recurring_ok == 1) {
374
- $sql = "UPDATE " . MY_CALENDAR_TABLE . " SET
375
- event_title='" . mysql_real_escape_string($title) . "',
376
- event_desc='" . mysql_real_escape_string($desc) . "',
377
- event_begin='" . mysql_real_escape_string($begin) . "',
378
- event_end='" . mysql_real_escape_string($end) . "',
379
- event_time='" . mysql_real_escape_string($time) . "',
380
- event_recur='" . mysql_real_escape_string($recur) . "',
381
- event_repeats=" . mysql_real_escape_string($repeats) . ",
382
- event_category=".mysql_real_escape_string($category).",
383
- event_link='".mysql_real_escape_string($linky)."',
384
- event_label='".mysql_real_escape_string($event_label)."',
385
- event_street='".mysql_real_escape_string($event_street)."',
386
- event_street2='".mysql_real_escape_string($event_street2)."',
387
- event_city='".mysql_real_escape_string($event_city)."',
388
- event_state='".mysql_real_escape_string($event_state)."',
389
- event_postcode='".mysql_real_escape_string($event_postcode)."',
390
- event_country='".mysql_real_escape_string($event_country)."'
391
- WHERE event_id='" . mysql_real_escape_string($event_id) . "'";
392
-
393
- $wpdb->get_results($sql);
394
395
- $sql = "SELECT event_id FROM " . MY_CALENDAR_TABLE . " WHERE event_title='" . mysql_real_escape_string($title) . "'"
396
- . " AND event_desc='" . mysql_real_escape_string($desc) . "' AND event_begin='" . mysql_real_escape_string($begin) . "' AND event_end='" . mysql_real_escape_string($end) . "' AND event_recur='" . mysql_real_escape_string($recur) . "' AND event_repeats='" . mysql_real_escape_string($repeats) . "' LIMIT 1";
397
- $result = $wpdb->get_results($sql);
398
399
- if ( empty($result) || empty($result[0]->event_id) ) {
400
?>
401
- <div class="error"><p><strong><?php _e('Failure','my-calendar'); ?>:</strong> <?php _e('The database failed to return data to indicate the event has been updated sucessfully. This may indicate a problem with your database or the way in which it is configured.','my-calendar'); ?></p></div>
402
<?php
403
} else {
404
?>
@@ -412,10 +462,12 @@ if ( $action == 'add' ) {
412
$users_entries->event_begin = $begin;
413
$users_entries->event_end = $end;
414
$users_entries->event_time = $time;
415
$users_entries->event_recur = $recur;
416
$users_entries->event_repeats = $repeats;
417
$users_entries->event_category = $category;
418
$users_entries->event_link = $linky;
419
$users_entries->event_label = $event_label;
420
$users_entries->event_street = $event_street;
421
$users_entries->event_street2 = $event_street2;
@@ -423,6 +475,10 @@ if ( $action == 'add' ) {
423
$users_entries->event_state = $event_state;
424
$users_entries->event_postcode = $event_postcode;
425
$users_entries->event_country = $event_country;
426
$users_entries->event_author = $event_author;
427
$error_with_saving = 1;
428
}
@@ -509,7 +565,7 @@ if ( $action == 'add' ) {
509
</div>
510
511
<?php
512
- }
513
514
// The event edit form for the manage events admin page
515
function jd_events_edit_form($mode='add', $event_id=false) {
@@ -553,7 +609,7 @@ function jd_events_edit_form($mode='add', $event_id=false) {
553
<fieldset>
554
<legend><?php _e('Enter your Event Information','my-calendar'); ?></legend>
555
<p>
556
- <label for="event_title"><?php _e('Event Title','my-calendar'); ?></label> <input type="text" id="event_title" name="event_title" class="input" size="40" maxlength="60" value="<?php if ( !empty($data) ) echo htmlspecialchars(stripslashes($data->event_title)); ?>" />
557
</p>
558
<p>
559
<label for="event_desc"><?php _e('Event Description (<abbr title="hypertext markup language">HTML</abbr> allowed)','my-calendar'); ?></label><br /><textarea id="event_desc" name="event_desc" class="input" rows="5" cols="50"><?php if ( !empty($data) ) echo htmlspecialchars(stripslashes($data->event_desc)); ?></textarea>
@@ -578,28 +634,42 @@ function jd_events_edit_form($mode='add', $event_id=false) {
578
</select>
579
</p>
580
<p>
581
- <label for="event_link"><?php _e('Event Link (Optional)','my-calendar'); ?></label> <input type="text" id="event_link" name="event_link" class="input" size="40" value="<?php if ( !empty($data) ) echo htmlspecialchars($data->event_link); ?>" />
582
</p>
583
- <p>
584
<label for="event_begin"><?php _e('Start Date (YYYY-MM-DD)','my-calendar'); ?></label> <input type="text" id="event_begin" name="event_begin" class="calendar_input" size="12" value="<?php if ( !empty($data) ) { echo htmlspecialchars($data->event_begin);} else {echo date_i18n("Y-m-d");} ?>" />
585
</p>
586
<p>
587
- <label for="event_end"><?php _e('End Date (YYYY-MM-DD) (Optional)','calendar'); ?></label> <input type="text" name="event_end" id="event_end" class="calendar_input" size="12" value="<?php if ( !empty($data) ) {echo htmlspecialchars($data->event_end);} ?>" />
588
</p>
589
<p>
590
- <label for="event_time"><?php _e('Time (hh:mm)','calendar'); ?></label> <input type="text" id="event_time" name="event_time" class="input" size="12"
591
value="<?php
592
if ( !empty($data) ) {
593
if ($data->event_time == "00:00:00") {
594
echo '';
595
} else {
596
- echo date_i18n("H:i",strtotime(htmlspecialchars($data->event_time)));
597
}
598
} else {
599
- echo date_i18n("H:i",strtotime(current_time('mysql')));
600
}
601
?>" /> <?php _e('Optional, set blank if your event is an all-day event or does not happen at a specific time.','my-calendar'); ?> <?php _e('Current time difference from GMT is ','my-calendar'); echo get_option('gmt_offset'); _e(' hour(s)', 'my-calendar'); ?>
602
</p>
603
</fieldset>
604
<fieldset>
605
<legend><?php _e('Recurring Events','my-calendar'); ?></legend> <?php
@@ -645,7 +715,7 @@ function jd_events_edit_form($mode='add', $event_id=false) {
645
if ( !empty($locations) ) {
646
?>
647
<p>
648
- <label for="event_preset"><?php _e('Choose a preset location:','my-calendar'); ?></label> <select name="event_preset" id="event_preset">
649
<option value="none"> -- </option>
650
<?php
651
foreach ( $locations as $location ) {
@@ -658,7 +728,7 @@ function jd_events_edit_form($mode='add', $event_id=false) {
658
<?php
659
} else {
660
?>
661
- <input type="hidden" name="event_preset" value="none" />
662
<p><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar-locations"><?php _e('Add recurring locations for later use.','my-calendar'); ?></a></p>
663
<?php
664
}
@@ -678,13 +748,32 @@ function jd_events_edit_form($mode='add', $event_id=false) {
678
<p>
679
<label for="event_country"><?php _e('Country','my-calendar'); ?></label> <input type="text" id="event_country" name="event_country" class="input" size="10" value="<?php if ( !empty($data) ) echo htmlspecialchars(stripslashes($data->event_country)); ?>" />
680
</p>
681
</fieldset>
682
<?php } ?>
683
<p>
684
<input type="submit" name="save" class="button-primary" value="<?php _e('Save Event','my-calendar'); ?> &raquo;" />
685
</p>
686
- <div id="datepicker1">
687
- </div>
688
</form>
689
</div>
690
</div>
@@ -716,6 +805,9 @@ function jd_events_display_list($sortby='default',$sortdir='default') {
716
case 6:
717
$sortbyvalue = 'event_category';
718
break;
719
default:
720
$sortbyvalue = 'event_begin';
721
}
@@ -740,11 +832,11 @@ function jd_events_display_list($sortby='default',$sortdir='default') {
740
<tr>
741
<th class="manage-column n4" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=1<?php echo $sorting; ?>"><?php _e('ID','my-calendar') ?></a></th>
742
<th class="manage-column" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=2<?php echo $sorting; ?>"><?php _e('Title','my-calendar') ?></a></th>
743
<th class="manage-column n8" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=3<?php echo $sorting; ?>"><?php _e('Description','my-calendar') ?></a></th>
744
<th class="manage-column" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=4<?php echo $sorting; ?>"><?php _e('Start Date','my-calendar') ?></a></th>
745
- <?php /* <th class="manage-column" scope="col"><?php _e('End Date','my-calendar') ?></th> */ ?>
746
<th class="manage-column n6" scope="col"><?php _e('Recurs','my-calendar') ?></th>
747
- <th class="manage-column n6" scope="col"><?php _e('Repeats','my-calendar') ?></th>
748
<th class="manage-column" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=5<?php echo $sorting; ?>"><?php _e('Author','my-calendar') ?></a></th>
749
<th class="manage-column" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=6<?php echo $sorting; ?>"><?php _e('Category','my-calendar') ?></a></th>
750
<th class="manage-column n7" scope="col"><?php _e('Edit / Delete','my-calendar') ?></th>
@@ -759,8 +851,10 @@ function jd_events_display_list($sortby='default',$sortdir='default') {
759
<tr class="<?php echo $class; ?>">
760
<th scope="row"><?php echo $event->event_id; ?></th>
761
<td><?php echo htmlentities(stripslashes($event->event_title)); ?></td>
762
- <td><?php echo htmlentities(stripslashes($event->event_desc)); ?></td>
763
- <td><?php echo $event->event_begin; ?></td>
764
<?php /* <td><?php echo $event->event_end; ?></td> */ ?>
765
<td>
766
<?php
@@ -771,15 +865,12 @@ function jd_events_display_list($sortby='default',$sortdir='default') {
771
else if ($event->event_recur == 'B') { _e('Bi-Weekly','my-calendar'); }
772
else if ($event->event_recur == 'M') { _e('Monthly','my-calendar'); }
773
else if ($event->event_recur == 'Y') { _e('Yearly','my-calendar'); }
774
- ?>
775
- </td>
776
- <td>
777
- <?php
778
// Interpret the DB values into something human readable
779
if ($event->event_recur == 'S') { echo __('N/A','my-calendar'); }
780
else if ($event->event_repeats == 0) { echo __('Forever','my-calendar'); }
781
else if ($event->event_repeats > 0) { echo $event->event_repeats.' '.__('Times','my-calendar'); }
782
- ?>
783
</td>
784
<td><?php echo $author->display_name; ?></td>
785
<?php
3
// to deal with posts
4
function edit_my_calendar() {
5
global $current_user, $wpdb, $users_entries;
6
+ ?>
7
+
8
<?php
9
if ( get_option('ko_calendar_imported') != 'true' ) {
10
if (function_exists('check_calendar')) {
75
$begin = !empty($_POST['event_begin']) ? $_POST['event_begin'] : '';
76
$end = !empty($_POST['event_end']) ? $_POST['event_end'] : $begin;
77
$time = !empty($_POST['event_time']) ? $_POST['event_time'] : '';
78
+ $endtime = !empty($_POST['event_endtime']) ? $_POST['event_endtime'] : '';
79
$recur = !empty($_POST['event_recur']) ? $_POST['event_recur'] : '';
80
$repeats = !empty($_POST['event_repeats']) ? $_POST['event_repeats'] : 0;
81
$category = !empty($_POST['event_category']) ? $_POST['event_category'] : '';
82
$linky = !empty($_POST['event_link']) ? $_POST['event_link'] : '';
83
+ $expires = !empty($_POST['event_link_expires']) ? $_POST['event_link_expires'] : '0';
84
+ $location_preset = !empty($_POST['location_preset']) ? $_POST['location_preset'] : '';
85
+ if ($location_preset != 'none') {
86
+ $sql = "SELECT * FROM " . MY_CALENDAR_LOCATIONS_TABLE . " WHERE location_id = $location_preset";
87
$location = $wpdb->get_row($sql);
88
$event_label = $location->location_label;
89
$event_street = $location->location_street;
92
$event_state = $location->location_state;
93
$event_postcode = $location->location_postcode;
94
$event_country = $location->location_country;
95
+ $event_longitude = $location->location_longitude;
96
+ $event_latitude = $location->location_latitude;
97
+ $event_zoom = $location->location_zoom;
98
} else {
99
$event_label = !empty($_POST['event_label']) ? $_POST['event_label'] : '';
100
$event_street = !empty($_POST['event_street']) ? $_POST['event_street'] : '';
102
$event_city = !empty($_POST['event_city']) ? $_POST['event_city'] : '';
103
$event_state = !empty($_POST['event_state']) ? $_POST['event_state'] : '';
104
$event_postcode = !empty($_POST['event_postcode']) ? $_POST['event_postcode'] : '';
105
+ $event_country = !empty($_POST['event_country']) ? $_POST['event_country'] : '';
106
+ $event_longitude = !empty($_POST['event_longitude']) ? $_POST['event_longitude'] : '';
107
+ $event_latitude = !empty($_POST['event_latitude']) ? $_POST['event_latitude'] : '';
108
+ $event_zoom = !empty($_POST['event_zoom']) ? $_POST['event_zoom'] : '';
109
}
110
// Deal with the fools who have left magic quotes turned on
111
if ( ini_get('magic_quotes_gpc') ) {
114
$begin = stripslashes($begin);
115
$end = stripslashes($end);
116
$time = stripslashes($time);
117
+ $endtime = stripslashes($endtime);
118
$recur = stripslashes($recur);
119
$repeats = stripslashes($repeats);
120
$category = stripslashes($category);
121
$linky = stripslashes($linky);
122
+ $expires = stripslashes($expires);
123
$event_label = stripslashes($event_label);
124
$event_street = stripslashes($event_street);
125
$event_street2 = stripslashes($event_street2);
126
$event_city = stripslashes($event_city);
127
$event_state = stripslashes($event_state);
128
$event_postcode = stripslashes($event_postcode);
129
+ $event_country = stripslashes($event_country);
130
+ $event_longitude = stripslashes($event_longitude);
131
+ $event_latitude = stripslashes($event_latitude);
132
+ $event_zoom = stripslashes($event_zoom);
133
+
134
}
135
136
// Perform some validation on the submitted dates - this checks for valid years and months
184
<div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('The URL entered must either be prefixed with http:// or be completely blank','my-calendar'); ?></p></div>
185
<?php
186
}
187
+ // The title must be at least one character in length and no more than 255 - only basic punctuation is allowed
188
$title_length = strlen($title);
189
+ if ( $title_length > 1 && $title_length <= 255 ) {
190
$title_ok =1;
191
} else {
192
?>
193
+ <div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 255 characters in length.','my-calendar'); ?></p></div>
194
<?php
195
}
196
// We run some checks on recurrance
202
<?php
203
}
204
if ($start_date_ok == 1 && $end_date_ok == 1 && $time_ok == 1 && $url_ok == 1 && $title_ok == 1 && $recurring_ok == 1) {
205
+ $update = array(
206
+ 'event_id'=>'',
207
+ 'event_begin'=>$begin,
208
+ 'event_end'=>$end,
209
+ 'event_title'=>$title,
210
+ 'event_desc'=>$desc,
211
+ 'event_time'=>$time,
212
+ 'event_endtime'=>$endtime,
213
+ 'event_recur'=>$recur,
214
+ 'event_repeats'=>$repeats,
215
+ 'event_author'=>$current_user->ID,
216
+ 'event_category'=>$category,
217
+ 'event_link'=>$linky,
218
+ 'event_link_expires'=>$expires,
219
+ 'event_label'=>$event_label,
220
+ 'event_street'=>$event_street,
221
+ 'event_street2'=>$event_street2,
222
+ 'event_city'=>$event_city,
223
+ 'event_state'=>$event_state,
224
+ 'event_postcode'=>$event_postcode,
225
+ 'event_country'=>$event_country,
226
+ 'event_longitude'=>$event_longitude,
227
+ 'event_latitude'=>$event_latitude,
228
+ 'event_zoom'=>$event_zoom);
229
+
230
+ $format = array('%s');
231
+ $result = $wpdb->insert(
232
+ MY_CALENDAR_TABLE,
233
+ $update,
234
+ $formats
235
+ );
236
+
237
+ if ( !$result ) {
238
?>
239
<div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('An event with the details you submitted could not be found in the database. This may indicate a problem with your database or the way in which it is configured.','my-calendar'); ?></p></div>
240
<?php
250
$users_entries->event_begin = $begin;
251
$users_entries->event_end = $end;
252
$users_entries->event_time = $time;
253
+ $users_entries->event_endtime = $endtime;
254
$users_entries->event_recur = $recur;
255
$users_entries->event_repeats = $repeats;
256
$users_entries->event_category = $category;
257
$users_entries->event_link = $linky;
258
+ $users_entries->event_link_expires = $expires;
259
$users_entries->event_label = $event_label;
260
$users_entries->event_street = $event_street;
261
$users_entries->event_street2 = $event_street2;
262
$users_entries->event_city = $event_city;
263
$users_entries->event_state = $event_state;
264
$users_entries->event_postcode = $event_postcode;
265
+ $users_entries->event_country = $event_country;
266
+ $users_entries->event_longitude = $event_longitude;
267
+ $users_entries->event_latitude = $event_latitude;
268
+ $users_entries->event_zoom = $event_zoom;
269
+
270
}
271
// Permit saving of events that have been edited
272
} elseif ( $action == 'edit_save' ) {
273
$title = !empty($_POST['event_title']) ? $_POST['event_title'] : '';
274
+ $desc = !empty($_POST['event_desc']) ? $_POST['event_desc'] : ' ';
275
$begin = !empty($_POST['event_begin']) ? $_POST['event_begin'] : '';
276
$end = !empty($_POST['event_end']) ? $_POST['event_end'] : $begin;
277
$time = !empty($_POST['event_time']) ? $_POST['event_time'] : '';
278
+ $endtime = !empty($_POST['event_endtime']) ? $_POST['event_endtime'] : '';
279
$recur = !empty($_POST['event_recur']) ? $_POST['event_recur'] : '';
280
$repeats = !empty($_POST['event_repeats']) ? $_POST['event_repeats'] : 0;
281
$category = !empty($_POST['event_category']) ? $_POST['event_category'] : '';
282
$linky = !empty($_POST['event_link']) ? $_POST['event_link'] : '';
283
+ $expires = !empty($_POST['event_link_expires']) ? $_POST['event_link_expires'] : '0';
284
+ $location_preset = !empty($_POST['location_preset']) ? $_POST['location_preset'] : '';
285
+ if ($location_preset != 'none') {
286
+ $sql = "SELECT * FROM " . MY_CALENDAR_LOCATIONS_TABLE . " WHERE location_id = $location_preset";
287
$location = $wpdb->get_row($sql);
288
$event_label = $location->location_label;
289
$event_street = $location->location_street;
292
$event_state = $location->location_state;
293
$event_postcode = $location->location_postcode;
294
$event_country = $location->location_country;
295
+ $event_longitude = $location->location_longitude;
296
+ $event_latitude = $location->location_latitude;
297
+ $event_zoom = $location->location_zoom;
298
} else {
299
$event_label = !empty($_POST['event_label']) ? $_POST['event_label'] : '';
300
$event_street = !empty($_POST['event_street']) ? $_POST['event_street'] : '';
303
$event_state = !empty($_POST['event_state']) ? $_POST['event_state'] : '';
304
$event_postcode = !empty($_POST['event_postcode']) ? $_POST['event_postcode'] : '';
305
$event_country = !empty($_POST['event_country']) ? $_POST['event_country'] : '';
306
+ $event_longitude = !empty($_POST['event_longitude']) ? $_POST['event_longitude'] : '';
307
+ $event_latitude = !empty($_POST['event_latitude']) ? $_POST['event_latitude'] : '';
308
+ $event_zoom = !empty($_POST['event_zoom']) ? $_POST['event_zoom'] : '';
309
+
310
}
311
$event_author = !empty($_POST['event_author']) ? $_POST['event_author'] : '';
312
320
$begin = stripslashes($begin);
321
$end = stripslashes($end);
322
$time = stripslashes($time);
323
+ $endtime = stripslashes($endtime);
324
$recur = stripslashes($recur);
325
$repeats = stripslashes($repeats);
326
$category = stripslashes($category);
327
$linky = stripslashes($linky);
328
+ $expires = stripslashes($expires);
329
$event_label = stripslashes($event_label);
330
$event_street = stripslashes($event_street);
331
$event_street2 = stripslashes($event_street2);
333
$event_state = stripslashes($event_state);
334
$event_postcode = stripslashes($event_postcode);
335
$event_country = stripslashes($event_country);
336
+ $event_longitude = stripslashes($event_longitude);
337
+ $event_latitude = stripslashes($event_latitude);
338
+ $event_zoom = stripslashes($event_zoom);
339
+
340
$event_author = stripslashes($event_author);
341
}
342
396
<div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('The URL entered must either be prefixed with http:// or be completely blank','my-calendar'); ?></p></div>
397
<?php
398
}
399
+ // The title must be at least one character in length and no more than 255 - no non-standard characters allowed
400
$title_length = strlen($title);
401
+ if ( $title_length > 1 && $title_length <= 255 ) {
402
$title_ok =1;
403
} else {
404
?>
405
+ <div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 255 characters in length.','my-calendar'); ?></p></div>
406
<?php
407
}
408
// We run some checks on recurrance
414
<?php
415
}
416
if ($start_date_ok == 1 && $end_date_ok == 1 && $time_ok == 1 && $url_ok == 1 && $title_ok && $recurring_ok == 1) {
417
418
+ $update = array(
419
+ 'event_begin'=>$begin,
420
+ 'event_end'=>$end,
421
+ 'event_title'=>$title,
422
+ 'event_desc'=>$desc,
423
+ 'event_time'=>$time,
424
+ 'event_endtime'=>$endtime,
425
+ 'event_recur'=>$recur,
426
+ 'event_repeats'=>$repeats,
427
+ 'event_category'=>$category,
428
+ 'event_link'=>$linky,
429
+ 'event_link_expires'=>$expires,
430
+ 'event_label'=>$event_label,
431
+ 'event_street'=>$event_street,
432
+ 'event_street2'=>$event_street2,
433
+ 'event_city'=>$event_city,
434
+ 'event_state'=>$event_state,
435
+ 'event_postcode'=>$event_postcode,
436
+ 'event_country'=>$event_country,
437
+ 'event_longitude'=>$event_longitude,
438
+ 'event_latitude'=>$event_latitude,
439
+ 'event_zoom'=>$event_zoom);
440
+
441
+ $format = array('%s');
442
+ $result = $wpdb->update(
443
+ MY_CALENDAR_TABLE,
444
+ $update,
445
+ array( 'event_id'=>$event_id ),
446
+ $formats,
447
+ '%d' );
448
449
+ if ( !$result ) {
450
?>
451
+ <div class="error"><p><strong><?php _e('Failure','my-calendar'); ?>:</strong> <?php echo _e('Your event was not updated.','my-calendar'); ?></p></div>
452
<?php
453
} else {
454
?>
462
$users_entries->event_begin = $begin;
463
$users_entries->event_end = $end;
464
$users_entries->event_time = $time;
465
+ $users_entries->event_endtime = $endtime;
466
$users_entries->event_recur = $recur;
467
$users_entries->event_repeats = $repeats;
468
$users_entries->event_category = $category;
469
$users_entries->event_link = $linky;
470
+ $users_entries->event_link_expires = $expires;
471
$users_entries->event_label = $event_label;
472
$users_entries->event_street = $event_street;
473
$users_entries->event_street2 = $event_street2;
475
$users_entries->event_state = $event_state;
476
$users_entries->event_postcode = $event_postcode;
477
$users_entries->event_country = $event_country;
478
+ $users_entries->event_longitude = $event_longitude;
479
+ $users_entries->event_latitude = $event_latitude;
480
+ $users_entries->event_zoom = $event_zoom;
481
+
482
$users_entries->event_author = $event_author;
483
$error_with_saving = 1;
484
}
565
</div>
566
567
<?php
568
+ }
569
570
// The event edit form for the manage events admin page
571
function jd_events_edit_form($mode='add', $event_id=false) {
609
<fieldset>
610
<legend><?php _e('Enter your Event Information','my-calendar'); ?></legend>
611
<p>
612
+ <label for="event_title"><?php _e('Event Title','my-calendar'); ?></label> <input type="text" id="event_title" name="event_title" class="input" size="60" value="<?php if ( !empty($data) ) echo htmlspecialchars(stripslashes($data->event_title)); ?>" />
613
</p>
614
<p>
615
<label for="event_desc"><?php _e('Event Description (<abbr title="hypertext markup language">HTML</abbr> allowed)','my-calendar'); ?></label><br /><textarea id="event_desc" name="event_desc" class="input" rows="5" cols="50"><?php if ( !empty($data) ) echo htmlspecialchars(stripslashes($data->event_desc)); ?></textarea>
634
</select>
635
</p>
636
<p>
637
+ <label for="event_link"><?php _e('Event Link (Optional)','my-calendar'); ?></label> <input type="text" id="event_link" name="event_link" class="input" size="40" value="<?php if ( !empty($data) ) echo htmlspecialchars($data->event_link); ?>" /> <input type="checkbox" value="1" id="event_link_expires" name="event_link_expires"<?php if ( !empty($data) && $data->event_link_expires == '1' ) { echo " checked=\"checked\""; } else if ( !empty($data) && $data->event_link_expires == '0' ) { echo ""; } else if ( get_option( 'mc_event_link_expires' ) == 'true' ) { echo " checked=\"checked\""; } ?> /> <label for="event_link_expires"><?php _e('This link will expire when the event passes.','my-calendar'); ?></label>
638
</p>
639
+ <p>
640
<label for="event_begin"><?php _e('Start Date (YYYY-MM-DD)','my-calendar'); ?></label> <input type="text" id="event_begin" name="event_begin" class="calendar_input" size="12" value="<?php if ( !empty($data) ) { echo htmlspecialchars($data->event_begin);} else {echo date_i18n("Y-m-d");} ?>" />
641
</p>
642
<p>
643
+ <label for="event_end"><?php _e('End Date (YYYY-MM-DD) (Optional)','my-calendar'); ?></label> <input type="text" name="event_end" id="event_end" class="calendar_input" size="12" value="<?php if ( !empty($data) ) {echo htmlspecialchars($data->event_end);} ?>" />
644
</p>
645
<p>
646
+ <label for="event_time"><?php _e('Time (hh:mm)','my-calendar'); ?></label> <input type="text" id="event_time" name="event_time" class="input" size="12"
647
value="<?php
648
if ( !empty($data) ) {
649
if ($data->event_time == "00:00:00") {
650
echo '';
651
} else {
652
+ echo date("H:i",strtotime($data->event_time));
653
}
654
} else {
655
+ echo date_i18n("H:i",time());
656
}
657
?>" /> <?php _e('Optional, set blank if your event is an all-day event or does not happen at a specific time.','my-calendar'); ?> <?php _e('Current time difference from GMT is ','my-calendar'); echo get_option('gmt_offset'); _e(' hour(s)', 'my-calendar'); ?>
658
</p>
659
+ <p>
660
+ <label for="event_endtime"><?php _e('End Time (hh:mm)','my-calendar'); ?></label> <input type="text" id="event_endtime" name="event_endtime" class="input" size="12"
661
+ value="<?php
662
+ if ( !empty($data) ) {
663
+ if ($data->event_endtime == "00:00:00") {
664
+ echo '';
665
+ } else {
666
+ echo date("H:i",strtotime($data->event_time));
667
+ }
668
+ } else {
669
+ echo '';
670
+ }
671
+ ?>" /> <?php _e('Optional. End times will not be displayed on events where this is not set.','my-calendar'); ?>
672
+ </p>
673
</fieldset>
674
<fieldset>
675
<legend><?php _e('Recurring Events','my-calendar'); ?></legend> <?php
715
if ( !empty($locations) ) {
716
?>
717
<p>
718
+ <label for="location_preset"><?php _e('Choose a preset location:','my-calendar'); ?></label> <select name="location_preset" id="location_preset">
719
<option value="none"> -- </option>
720
<?php
721
foreach ( $locations as $location ) {
728
<?php
729
} else {
730
?>
731
+ <input type="hidden" name="location_preset" value="none" />
732
<p><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar-locations"><?php _e('Add recurring locations for later use.','my-calendar'); ?></a></p>
733
<?php
734
}
748
<p>
749
<label for="event_country"><?php _e('Country','my-calendar'); ?></label> <input type="text" id="event_country" name="event_country" class="input" size="10" value="<?php if ( !empty($data) ) echo htmlspecialchars(stripslashes($data->event_country)); ?>" />
750
</p>
751
+ <p>
752
+ <label for="event_zoom"><?php _e('Initial Zoom','my-calendar'); ?></label>
753
+ <select name="event_zoom" id="event_zoom">
754
+ <option value="16"<?php if ( !empty( $data ) && ( $data->event_zoom == 16 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Neighborhood','my-calendar'); ?></option>
755
+ <option value="14"<?php if ( !empty( $data ) && ( $data->event_zoom == 14 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Small City','my-calendar'); ?></option>
756
+ <option value="12"<?php if ( !empty( $data ) && ( $data->event_zoom == 12 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Large City','my-calendar'); ?></option>
757
+ <option value="10"<?php if ( !empty( $data ) && ( $data->event_zoom == 10 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Greater Metro Area','my-calendar'); ?></option>
758
+ <option value="8"<?php if ( !empty( $data ) && ( $data->event_zoom == 8 ) ) { echo " selected=\"selected\""; } ?>><?php _e('State','my-calendar'); ?></option>
759
+ <option value="6"<?php if ( !empty( $data ) && ( $data->event_zoom == 6 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Region','my-calendar'); ?></option>
760
+ </select>
761
+ </p>
762
+ <fieldset>
763
+ <legend><?php _e('GPS Coordinates (optional)','my-calendar'); ?></legend>
764
+ <p>
765
+ <small><?php _e('If you supply GPS coordinates for your location, they will be used in place of any other address information to pinpoint your location.','my-calendar'); ?></small>
766
+ </p>
767
+ <p>
768
+ <label for="event_longitude"><?php _e('Longitude','my-calendar'); ?></label> <input type="text" id="event_longitude" name="event_longitude" class="input" size="10" value="<?php if ( !empty( $data ) ) echo htmlspecialchars(stripslashes($data->event_longitude)); ?>" /> <label for="event_latitude"><?php _e('Latitude','my-calendar'); ?></label> <input type="text" id="event_latitude" name="event_latitude" class="input" size="10" value="<?php if ( !empty( $data ) ) echo htmlspecialchars(stripslashes($data->event_latitude)); ?>" />
769
+ </p>
770
+ </fieldset>
771
</fieldset>
772
<?php } ?>
773
<p>
774
<input type="submit" name="save" class="button-primary" value="<?php _e('Save Event','my-calendar'); ?> &raquo;" />
775
</p>
776
+
777
</form>
778
</div>
779
</div>
805
case 6:
806
$sortbyvalue = 'event_category';
807
break;
808
+ case 7:
809
+ $sortbyvalue = 'event_label';
810
+ break;
811
default:
812
$sortbyvalue = 'event_begin';
813
}
832
<tr>
833
<th class="manage-column n4" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=1<?php echo $sorting; ?>"><?php _e('ID','my-calendar') ?></a></th>
834
<th class="manage-column" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=2<?php echo $sorting; ?>"><?php _e('Title','my-calendar') ?></a></th>
835
+ <th class="manage-column" scope="col"><?php _e('Link','my-calendar') ?></th>
836
+ <th class="manage-column" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=7<?php echo $sorting; ?>"><?php _e('Location','my-calendar') ?></a></th>
837
<th class="manage-column n8" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=3<?php echo $sorting; ?>"><?php _e('Description','my-calendar') ?></a></th>
838
<th class="manage-column" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=4<?php echo $sorting; ?>"><?php _e('Start Date','my-calendar') ?></a></th>
839
<th class="manage-column n6" scope="col"><?php _e('Recurs','my-calendar') ?></th>
840
<th class="manage-column" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=5<?php echo $sorting; ?>"><?php _e('Author','my-calendar') ?></a></th>
841
<th class="manage-column" scope="col"><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;sort=6<?php echo $sorting; ?>"><?php _e('Category','my-calendar') ?></a></th>
842
<th class="manage-column n7" scope="col"><?php _e('Edit / Delete','my-calendar') ?></th>
851
<tr class="<?php echo $class; ?>">
852
<th scope="row"><?php echo $event->event_id; ?></th>
853
<td><?php echo htmlentities(stripslashes($event->event_title)); ?></td>
854
+ <td><?php echo htmlentities(stripslashes($event->event_link)); ?></td>
855
+ <td><?php echo htmlentities(stripslashes($event->event_label)); ?></td>
856
+ <td><?php echo substr(strip_tags(stripslashes($event->event_desc)),0,60); ?>&hellip;</td>
857
+ <td><?php echo "$event->event_begin ($event->event_time)"; ?></td>
858
<?php /* <td><?php echo $event->event_end; ?></td> */ ?>
859
<td>
860
<?php
865
else if ($event->event_recur == 'B') { _e('Bi-Weekly','my-calendar'); }
866
else if ($event->event_recur == 'M') { _e('Monthly','my-calendar'); }
867
else if ($event->event_recur == 'Y') { _e('Yearly','my-calendar'); }
868
+ ?>&thinsp;&ndash;&thinsp;<?php
869
// Interpret the DB values into something human readable
870
if ($event->event_recur == 'S') { echo __('N/A','my-calendar'); }
871
else if ($event->event_repeats == 0) { echo __('Forever','my-calendar'); }
872
else if ($event->event_repeats > 0) { echo $event->event_repeats.' '.__('Times','my-calendar'); }
873
+ ?>
874
</td>
875
<td><?php echo $author->display_name; ?></td>
876
<?php
my-calendar-help.php CHANGED
@@ -6,17 +6,18 @@ function my_calendar_help() {
6
<h2><?php _e('How to use My Calendar','my-calendar'); ?></h2>
7
<?php jd_show_support_box(); ?>
8
9
- <div id="poststuff" class="jd-my-calendar">
10
<div class="postbox">
11
<h3><?php _e('Shortcode Syntax','my-calendar'); ?></h3>
12
<div class="inside">
13
-
14
<ul>
15
<li><code>[my_calendar]</code><br />
16
<?php _e('This basic shortcode will show the calendar on a post or page including all categories and the category key, in a traditional month-by-month format.','my-calendar'); ?>
17
</li>
18
<li><code>[my_calendar category="General|Other" format="list" showkey="no"]</code><br />
19
- <?php _e('The shortcode supports three attributes, <code>category</code>, <code>format</code> and <code>showkey</code>. There is currently only one alternate option for <code>format</code> &mdash; <code>list</code> &mdash; which will show the calendar in a list format, skipping dates without any events. The <code>category</code> attribute requires either the name of or ID number one of your event categories (the name is case-sensitive). This will show a calendar only including events in that category. Multiple categories can be specified by separating the category names or IDs using the pipe character: <code>|</code>. Setting <code>showkey</code> to <code>no</code> will prevent the category key from being displayed &mdash; this can be useful with single-category output.','my-calendar'); ?>
20
</li>
21
<li><code>[my_calendar_upcoming before="3" after="3" type="event" category="General" template="{title} {date}"]</code><br />
22
<?php _e('This shortcode displays the output of the Upcoming Events widget. Without attributes, it will display using the settings in your widget; the attributes are used to override the widget settings. The <code>before</code> and <code>after</code> attributes should be numbers; the <code>type</code> attribute can be either "event" or "days", and the <code>category</code> attribute works the same way as the category attribute on the main calendar shortcode. Templates work using the template codes listed below.','my-calendar'); ?>
@@ -28,7 +29,7 @@ function my_calendar_help() {
28
</div>
29
</div>
30
</div>
31
- <div id="poststuff" class="jd-my-calendar">
32
<div class="postbox">
33
<h3><?php _e('Category Icons','my-calendar'); ?></h3>
34
<div class="inside">
@@ -42,7 +43,7 @@ function my_calendar_help() {
42
</div>
43
</div>
44
45
- <div id="poststuff" class="jd-my-calendar">
46
<div class="postbox">
47
<h3 id="template"><?php _e('Widget Templating','my-calendar'); ?></h3>
48
<div class="inside">
@@ -65,6 +66,9 @@ function my_calendar_help() {
65
<dt><code>{enddate}</code></dt>
66
<dd><?php _e('Displays the date on which the event ends.','my-calendar'); ?></dd>
67
68
<dt><code>{author}</code></dt>
69
<dd><?php _e('Displays the WordPress author who posted the event.','my-calendar'); ?></dd>
70
6
<h2><?php _e('How to use My Calendar','my-calendar'); ?></h2>
7
<?php jd_show_support_box(); ?>
8
9
+ <div id="shortcode" class="jd-my-calendar">
10
<div class="postbox">
11
<h3><?php _e('Shortcode Syntax','my-calendar'); ?></h3>
12
<div class="inside">
13
+ <p>
14
+ <?php _e('These shortcodes can be used in Posts, Pages, or in text widgets.','my-calendar'); ?>
15
<ul>
16
<li><code>[my_calendar]</code><br />
17
<?php _e('This basic shortcode will show the calendar on a post or page including all categories and the category key, in a traditional month-by-month format.','my-calendar'); ?>
18
</li>
19
<li><code>[my_calendar category="General|Other" format="list" showkey="no"]</code><br />
20
+ <?php _e('The shortcode supports three attributes, <code>category</code>, <code>format</code> and <code>showkey</code>. There two alternate option for <code>format</code> &mdash; <code>list</code> &mdash; which will show the calendar in a list format, skipping dates without any events, and <code>mini</code>, which will display the calendar in a form more suitable to being displayed in smaller spaces, such as the sidebar. The <code>category</code> attribute requires either the name of or ID number one of your event categories (the name is case-sensitive). This will show a calendar only including events in that category. Multiple categories can be specified by separating the category names or IDs using the pipe character: <code>|</code>. Setting <code>showkey</code> to <code>no</code> will prevent the category key from being displayed &mdash; this can be useful with single-category output.','my-calendar'); ?>
21
</li>
22
<li><code>[my_calendar_upcoming before="3" after="3" type="event" category="General" template="{title} {date}"]</code><br />
23
<?php _e('This shortcode displays the output of the Upcoming Events widget. Without attributes, it will display using the settings in your widget; the attributes are used to override the widget settings. The <code>before</code> and <code>after</code> attributes should be numbers; the <code>type</code> attribute can be either "event" or "days", and the <code>category</code> attribute works the same way as the category attribute on the main calendar shortcode. Templates work using the template codes listed below.','my-calendar'); ?>
29
</div>
30
</div>
31
</div>
32
+ <div id="icons" class="jd-my-calendar">
33
<div class="postbox">
34
<h3><?php _e('Category Icons','my-calendar'); ?></h3>
35
<div class="inside">
43
</div>
44
</div>
45
46
+ <div id="templates" class="jd-my-calendar">
47
<div class="postbox">
48
<h3 id="template"><?php _e('Widget Templating','my-calendar'); ?></h3>
49
<div class="inside">
66
<dt><code>{enddate}</code></dt>
67
<dd><?php _e('Displays the date on which the event ends.','my-calendar'); ?></dd>
68
69
+ <dt><code>{endtime}</code></dt>
70
+ <dd><?php _e('Displays the time at which the event ends.','my-calendar'); ?></dd>
71
+
72
<dt><code>{author}</code></dt>
73
<dd><?php _e('Displays the WordPress author who posted the event.','my-calendar'); ?></dd>
74
my-calendar-install.php ADDED
@@ -0,0 +1,473 @@
1
+ <?php
2
+
3
+ // define global variables;
4
+ global $initial_listjs, $initial_caljs, $initial_minijs, $initial_style, $initial_db, $initial_loc_db, $initial_cat_db, $default_template;
5
+
6
+ // defaults will go into the options table on a new install
7
+ $initial_listjs = 'var $j = jQuery.noConflict();
8
+
9
+ $j(document).ready(function() {
10
+ $j("#calendar-list li").children().not(".event-date").hide();
11
+ $j("#calendar-list li.current-day").children().show();
12
+ $j(".event-date").toggle(
13
+ function() {
14
+ $j("#calendar-list li").children().not(".event-date").hide();
15
+ $j(this).parent().children().not(".event-date").show("fast");
16
+ },
17
+ function() {
18
+ $j("#calendar-list li").children().not(".event-date").hide("fast");
19
+ }
20
+ );
21
+ });';
22
+
23
+ $initial_caljs = 'var $j = jQuery.noConflict();
24
+
25
+ $j(document).ready(function() {
26
+ $j(".calendar-event").children().not("h3").hide();
27
+ $j(".calendar-event h3").toggle(
28
+ function() {
29
+ $j(".calendar-event").children().not("h3").hide();
30
+ $j(this).parent().children().not("h3").show("fast");
31
+ },
32
+ function() {
33
+ $j(".calendar-event").children().not("h3").hide("fast");
34
+ }
35
+ );
36
+ });';
37
+
38
+ $initial_minijs = 'var $j = jQuery.noConflict();
39
+
40
+ $j(document).ready(function() {
41
+ $j(".mini .has-events").children().not(".trigger").hide();
42
+ $j(".has-events .trigger").toggle(
43
+ function() {
44
+ $j(".mini .has-events").children().not(".trigger").hide();
45
+ $j(this).parent().children().not(".trigger").show("fast");
46
+ },
47
+ function() {
48
+ $j(".mini .has-events").children().not(".trigger").hide("fast");
49
+ }
50
+ );
51
+ });';
52
+
53
+ $initial_style = "
54
+ #jd-calendar * {
55
+ margin: 0;
56
+ padding: 0;
57
+ line-height: 1.5;
58
+ color: #000;
59
+ background: #fff;
60
+ }
61
+ #jd-calendar caption, #jd-calendar .my-calendar-date-switcher {
62
+ background: #edf7ff;
63
+ border: 1px solid #a9e3ff;
64
+ margin: 2px 0;
65
+ font-weight:700;
66
+ padding:2px 0;
67
+ }
68
+
69
+ #jd-calendar table {
70
+ width:100%;
71
+ line-height:1.2;
72
+ border-collapse:collapse;
73
+ }
74
+
75
+ #jd-calendar td {
76
+ vertical-align:top;
77
+ border:1px solid #eee;
78
+ text-align:left;
79
+ width:13%;
80
+ height:70px;
81
+ padding:2px!important;
82
+ }
83
+ .mini td {
84
+ height: auto!important;
85
+ }
86
+ #jd-calendar th {
87
+ text-align: center;
88
+ padding: 5px 0!important;
89
+ letter-spacing: 1px;
90
+ }
91
+ #jd-calendar th abbr {
92
+ border-bottom: none;
93
+ }
94
+ #jd-calendar h3 {
95
+ font-size:.8em;
96
+ font-family: Arial, Verdana, sans-serif;
97
+ font-weight:700;
98
+ margin:3px 0;
99
+ padding:0;
100
+ width: 100%;
101
+ -moz-border-radius: 3px;
102
+ -webkit-border-radius: 3px;
103
+ border-radius: 3px;
104
+ }
105
+ #jd-calendar h3 img {
106
+ vertical-align: middle;
107
+ margin: 0 3px 0 0!important;
108
+ }
109
+ #jd-calendar #calendar-list h3 img {
110
+ vertical-align: middle;
111
+ }
112
+
113
+ #jd-calendar .list-event h3 {
114
+ font-size:1.2em;
115
+ margin:0;
116
+ }
117
+ #jd-calendar .calendar-event .details, #jd-calendar .calendar-events {
118
+ position:absolute;
119
+ width:50%;
120
+ background: #edf7ff;
121
+ color:#000;
122
+ border:1px solid #9b5;
123
+ -moz-border-radius:10px;
124
+ -moz-box-shadow:3px 3px 6px #777;
125
+ -webkit-box-shadow:3px 3px 6px #777;
126
+ box-shadow:3px 3px 6px #777;
127
+ padding:5px;
128
+ z-index: 3;
129
+ }
130
+ #jd-calendar .details .close {
131
+ float: right;
132
+ width: 12px!important;
133
+ margin-top: -2px!important;
134
+ }
135
+ #jd-calendar .calendar-events {
136
+ width: 200px!important;
137
+ left: 0px;
138
+ }
139
+ #jd-calendar .list-event .details {
140
+ background:#fafafa;
141
+ border:1px solid #eee;
142
+ -moz-border-radius:5px;
143
+ -webkit-border-radius:5px;
144
+ border-radius:5px;
145
+ margin:5px 0;
146
+ padding:5px 5px 0;
147
+ color: #333;
148
+ }
149
+ #jd-calendar #calendar-list {
150
+ margin: 0;
151
+ padding: 0;
152
+ }
153
+ #jd-calendar #calendar-list li {
154
+ padding:5px;
155
+ list-style-type: none;
156
+ margin: 0;
157
+ }
158
+
159
+ #jd-calendar #calendar-list .odd {
160
+ background:#d3e3e3;
161
+ }
162
+
163
+ #jd-calendar .odd .list-event .details {
164
+ background:#e3f3f3;
165
+ border:1px solid #c3d3d3;
166
+ }
167
+
168
+ #jd-calendar .current-day {
169
+ background:#ffb;
170
+ }
171
+ #jd-calendar .current-day .mc-date {
172
+ color: #000;
173
+ background: #eee;
174
+ }
175
+
176
+ #jd-calendar .mc-date {
177
+ display:block;
178
+ background:#f6f6f6;
179
+ margin:-2px -2px 2px;
180
+ padding:2px 4px;
181
+ }
182
+
183
+ #jd-calendar .weekend {
184
+ background:#bd7;
185
+ color: #000;
186
+ }
187
+
188
+ #jd-calendar th {
189
+ font-size:.8em;
190
+ text-transform:uppercase;
191
+ padding:2px 4px 2px 0;
192
+ }
193
+ #jd-calendar .category-key {
194
+ background: #edf7ff;
195
+ border: 1px solid #a9e3ff;
196
+ padding: 5px;
197
+ margin: 5px 0;
198
+ }
199
+ #jd-calendar .category-key ul {
200
+ list-style-type: none;
201
+ margin: 0;
202
+ padding: 0;
203
+ }
204
+ #jd-calendar .category-key li {
205
+ margin: 2px 10px;
206
+ }
207
+ #jd-calendar .category-key span {
208
+ margin-right:5px;
209
+ vertical-align:middle;
210
+ }
211
+ #jd-calendar .category-key .no-icon {
212
+ width: 10px;
213
+ height: 10px;
214
+ display: inline-block;
215
+ border: 1px solid #555;
216
+ -moz-border-radius: 2px;
217
+ -webkit-border-radius: 2px;
218
+ border-radius: 2px;
219
+ }
220
+
221
+ #calendar-list li {
222
+ text-indent:0;
223
+ margin:0;
224
+ padding:0;
225
+ }
226
+
227
+ #jd-calendar .calendar-event .event-time, #jd-calendar .list-event .event-time {
228
+ display:block;
229
+ float:left;
230
+ height:100%;
231
+ margin-right:10px;
232
+ margin-bottom:10px;
233
+ font-weight:700;
234
+ font-size:.9em;
235
+ }
236
+
237
+ #jd-calendar p {
238
+ line-height:1.5;
239
+ margin:0 0 1em;
240
+ padding:0;
241
+ }
242
+
243
+ #jd-calendar .sub-details {
244
+ margin-left:6em;
245
+ }
246
+
247
+ #jd-calendar .vcard {
248
+ font-size:.9em;
249
+ margin:10px 0;
250
+ }
251
+
252
+ #jd-calendar .calendar-event .vcard {
253
+ margin:0 0 10px;
254
+ }
255
+
256
+ #jd-calendar,#calendar-list {
257
+ clear:left;
258
+ background: #fff;
259
+ }
260
+ #jd-calendar {
261
+ position: relative;
262
+ }
263
+ #jd-calendar img {
264
+ border: none;
265
+ }
266
+ .category-color-sample img {
267
+ margin-right: 5px;
268
+ vertical-align: top;
269
+ }
270
+
271
+ #jd-calendar .my-calendar-nav ul {
272
+ height: 2.95em;
273
+ list-style-type:none;
274
+ margin:0;
275
+ padding:0;
276
+ }
277
+
278
+ .mini .my-calendar-nav ul {
279
+ height: 2em!important;
280
+ }
281
+
282
+ #jd-calendar .my-calendar-nav li {
283
+ float:left;
284
+ list-style-type: none;
285
+ }
286
+
287
+ #jd-calendar .my-calendar-nav li:before {
288
+ content:'';
289
+ }
290
+ #jd-calendar .my-calendar-nav li a {
291
+ display:block;
292
+ background:#fff;
293
+ border:1px solid #9b5;
294
+ text-align:center;
295
+ padding:1px 20px;
296
+ color: #243f82;
297
+ }
298
+ .mini .my-calendar-nav li a {
299
+ padding: 1px 3px!important;
300
+ font-size: .7em;
301
+ }
302
+ #jd-calendar .my-calendar-nav li a:hover {
303
+ background:#a9e3ff;
304
+ color:#000;
305
+ border: 1px solid #243f82;
306
+ }
307
+ #jd-calendar .my-calendar-next {
308
+ margin-left: 4px;
309
+ text-align:right;
310
+ }
311
+ #jd-calendar .my-calendar-next a {
312
+ -webkit-border-top-right-radius: 8px;
313
+ -webkit-border-bottom-right-radius: 8px;
314
+ -moz-border-radius-topright: 8px;
315
+ -moz-border-radius-bottomright: 8px;
316
+ border-top-right-radius: 8px;
317
+ border-bottom-right-radius: 8px;
318
+ }
319
+ #jd-calendar .my-calendar-prev a {
320
+ -webkit-border-top-left-radius: 8px;
321
+ -webkit-border-bottom-left-radius: 8px;
322
+ -moz-border-radius-topleft: 8px;
323
+ -moz-border-radius-bottomleft: 8px;
324
+ border-top-left-radius: 8px;
325
+ border-bottom-left-radius: 8px;
326
+ }
327
+ #jd-calendar .day-without-date {
328
+ background: #fafafa;
329
+ }
330
+ #upcoming-events .past-event {
331
+ color: #777;
332
+ }
333
+ #upcoming-events .today {
334
+ color: #111;
335
+ }
336
+ #upcoming-events .future-event {
337
+ color: #555;
338
+ }
339
+ #jd-calendar.mini .my-calendar-date-switcher label {
340
+ display: block;
341
+ float: left;
342
+ width: 6em;
343
+ }
344
+ #jd-calendar.mini .my-calendar-date-switcher {
345
+ padding: 4px;
346
+ }
347
+ #jd-calendar.mini td .category-icon {
348
+ display: none;
349
+ }
350
+ #jd-calendar.mini h3 {
351
+ font-size: 1.1em;
352
+ }
353
+
354
+ #jd-calendar.mini .day-with-date span, #jd-calendar.mini .day-with-date a {
355
+ font-family: Arial, Verdana, sans-serif;
356
+ font-size: .9em;
357
+ padding:1px;
358
+ }
359
+ #jd-calendar .mini-event .sub-details {
360
+ margin: 0;
361
+ border-bottom: 1px solid #ccc;
362
+ padding: 2px 0 0;
363
+ margin-bottom: 5px;
364
+ }
365
+ #jd-calendar.mini .day-with-date a {
366
+ display: block;
367
+ margin: -2px;
368
+ font-weight: 700;
369
+ text-decoration: underline;
370
+ }";
371
+
372
+ $default_template = "<strong>{date}</strong> &#8211; {link_title}<br /><span>{time}, {category}</span>";
373
+
374
+ $initial_db = "CREATE TABLE " . MY_CALENDAR_TABLE . " (
375
+ event_id INT(11) NOT NULL AUTO_INCREMENT,
376
+ event_begin DATE NOT NULL,
377
+ event_end DATE NOT NULL,
378
+ event_title VARCHAR(255) NOT NULL,
379
+ event_desc TEXT NOT NULL,
380
+ event_time TIME,
381
+ event_endtime TIME,
382
+ event_recur CHAR(1),
383
+ event_repeats INT(3),
384
+ event_author BIGINT(20) UNSIGNED,
385
+ event_category BIGINT(20) UNSIGNED,
386
+ event_link TEXT,
387
+ event_link_expires TINYINT(1) NOT NULL,
388
+ event_label VARCHAR(60) NOT NULL,
389
+ event_street VARCHAR(60) NOT NULL,
390
+ event_street2 VARCHAR(60) NOT NULL,
391
+ event_city VARCHAR(60) NOT NULL,
392
+ event_state VARCHAR(60) NOT NULL,
393
+ event_postcode VARCHAR(10) NOT NULL,
394
+ event_country VARCHAR(60) NOT NULL,
395
+ event_longitude FLOAT(10,6) NOT NULL DEFAULT '0',
396
+ event_latitude FLOAT(10,6) NOT NULL DEFAULT '0',
397
+ event_zoom INT(2) NOT NULL DEFAULT '14',
398
+ PRIMARY KEY (event_id),
399
+ KEY event_recur (event_recur)
400
+ );";
401
+
402
+ $initial_cat_db = "CREATE TABLE " . MY_CALENDAR_CATEGORIES_TABLE . " (
403
+ category_id INT(11) NOT NULL AUTO_INCREMENT,
404
+ category_name VARCHAR(255) NOT NULL,
405
+ category_color VARCHAR(7) NOT NULL,
406
+ category_icon VARCHAR(128) NOT NULL,
407
+ PRIMARY KEY (category_id)
408
+ );";
409
+
410
+ $initial_loc_db = "CREATE TABLE " . MY_CALENDAR_LOCATIONS_TABLE . " (
411
+ location_id INT(11) NOT NULL AUTO_INCREMENT,
412
+ location_label VARCHAR(60) NOT NULL,
413
+ location_street VARCHAR(60) NOT NULL,
414
+ location_street2 VARCHAR(60) NOT NULL,
415
+ location_city VARCHAR(60) NOT NULL,
416
+ location_state VARCHAR(60) NOT NULL,
417
+ location_postcode VARCHAR(10) NOT NULL,
418
+ location_country VARCHAR(60) NOT NULL,
419
+ location_longitude FLOAT(10,6) NOT NULL DEFAULT '0',
420
+ location_latitude FLOAT(10,6) NOT NULL DEFAULT '0',
421
+ location_zoom INT(2) NOT NULL DEFAULT '14',
422
+ PRIMARY KEY (location_id)
423
+ );";
424
+
425
+ function mc_default_settings( ) {
426
+ global $initial_style, $default_template, $initial_listjs, $initial_caljs, $initial_db, $initial_loc_db, $initial_cat_db;
427
+ // no arguments
428
+ add_option('can_manage_events','edit_posts');
429
+ add_option('my_calendar_style',"$initial_style");
430
+ add_option('display_author','false');
431
+ add_option('display_jump','false');
432
+ add_option('display_todays','true');
433
+ add_option('display_upcoming','true');
434
+ add_option('display_upcoming_days',7);
435
+ add_option('my_calendar_version','1.4.0');
436
+ add_option('display_upcoming_type','false');
437
+ add_option('display_upcoming_events',3);
438
+ add_option('display_past_days',0);
439
+ add_option('display_past_events',2);
440
+ add_option('my_calendar_use_styles','false');
441
+ add_option('my_calendar_show_months',1);
442
+ add_option('my_calendar_show_map','true');
443
+ add_option('my_calendar_show_address','false');
444
+ add_option('my_calendar_today_template',$default_template);
445
+ add_option('my_calendar_upcoming_template',$default_template);
446
+ add_option('my_calendar_today_title','Today\'s Events');
447
+ add_option('my_calendar_upcoming_title','Upcoming Events');
448
+ add_option('calendar_javascript',0);
449
+ add_option('list_javascript',0);
450
+ add_option('mini_javascript',0);
451
+ add_option('my_calendar_minijs',$initial_minijs);
452
+ add_option('my_calendar_listjs',$initial_listjs);
453
+ add_option('my_calendar_caljs',$initial_caljs);
454
+ add_option('my_calendar_notime_text','N/A');
455
+ add_option('my_calendar_hide_icons','false');
456
+ add_option('mc_event_link_expires','no');
457
+ add_option('mc_apply_color','default');
458
+
459
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
460
+ dbDelta($initial_db);
461
+ dbDelta($initial_cat_db);
462
+ dbDelta($initial_loc_db);
463
+
464
+ }
465
+
466
+ function upgrade_db() {
467
+ global $initial_db, $initial_loc_db, $initial_cat_db;
468
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
469
+ dbDelta($initial_db);
470
+ dbDelta($initial_cat_db);
471
+ dbDelta($initial_loc_db);
472
+ }
473
+ ?>
my-calendar-locations.php CHANGED
@@ -13,7 +13,7 @@ function my_calendar_manage_locations() {
13
<?php
14
// We do some checking to see what we're doing
15
if (isset($_POST['mode']) && $_POST['mode'] == 'add') {
16
- $sql = "INSERT INTO " . MY_CALENDAR_LOCATIONS_TABLE . " SET location_label='".mysql_real_escape_string($_POST['location_label'])."', location_street='".mysql_real_escape_string($_POST['location_street'])."', location_street2='".mysql_real_escape_string($_POST['location_street2'])."', location_city='".mysql_real_escape_string($_POST['location_city'])."', location_state='".mysql_real_escape_string($_POST['location_state'])."', location_postcode='".mysql_real_escape_string($_POST['location_postcode'])."', location_country='".mysql_real_escape_string($_POST['location_country'])."'";
17
$wpdb->get_results($sql);
18
echo "<div class=\"updated\"><p><strong>".__('Location added successfully','my-calendar')."</strong></p></div>";
19
} else if (isset($_GET['mode']) && isset($_GET['location_id']) && $_GET['mode'] == 'delete') {
@@ -41,31 +41,51 @@ function my_calendar_manage_locations() {
41
<?php _e('All location fields are optional: <em>insufficient information may result in an inaccurate map</em>.','my-calendar'); ?>
42
</p>
43
<p>
44
- <label for="location_label"><?php _e('Name of Location (e.g. <em>Joe\'s Bar and Grill</em>)','my-calendar'); ?></label> <input type="text" id="location_label" name="location_label" class="input" size="40" value="<?php if ( !empty($cur_loc) ) echo htmlspecialchars(stripslashes($cur_loc->location_label)); ?>" />
45
</p>
46
<p>
47
- <label for="location_street"><?php _e('Street Address','my-calendar'); ?></label> <input type="text" id="location_street" name="location_street" class="input" size="40" value="<?php if ( !empty($cur_loc) ) echo htmlspecialchars(stripslashes($cur_loc->location_street)); ?>" />
48
</p>
49
<p>
50
- <label for="location_street2"><?php _e('Street Address (2)','my-calendar'); ?></label> <input type="text" id="location_street2" name="location_street2" class="input" size="40" value="<?php if ( !empty($cur_loc) ) echo htmlspecialchars(stripslashes($cur_loc->location_street2)); ?>" />
51
</p>
52
<p>
53
- <label for="location_city"><?php _e('City','my-calendar'); ?></label> <input type="text" id="location_city" name="location_city" class="input" size="40" value="<?php if ( !empty($cur_loc) ) echo htmlspecialchars(stripslashes($cur_loc->location_city)); ?>" /> <label for="location_state"><?php _e('State/Province','my-calendar'); ?></label> <input type="text" id="location_state" name="location_state" class="input" size="10" value="<?php if ( !empty($cur_loc) ) echo htmlspecialchars($cur_loc->location_state); ?>" /> <label for="location_postcode"><?php _e('Postal Code','my-calendar'); ?></label> <input type="text" id="location_postcode" name="location_postcode" class="input" size="10" value="<?php if ( !empty($cur_loc) ) echo htmlspecialchars($cur_loc->location_postcode); ?>" />
54
</p>
55
<p>
56
- <label for="location_country"><?php _e('Country','my-calendar'); ?></label> <input type="text" id="location_country" name="location_country" class="input" size="10" value="<?php if ( !empty($cur_loc) ) echo htmlspecialchars(stripslashes($cur_loc->location_country)); ?>" />
57
</p>
58
</fieldset>
59
<p>
60
<input type="submit" name="save" class="button-primary" value="<?php _e('Save Changes','my-calendar'); ?> &raquo;" />
61
</p>
62
</form>
63
</div>
64
</div>
65
</div>
66
<?php
67
} else if (isset($_POST['mode']) && isset($_POST['location_id']) && isset($_POST['location_label']) && isset($_POST['location_street']) && $_POST['mode'] == 'edit') {
68
- $sql = "UPDATE " . MY_CALENDAR_LOCATIONS_TABLE . " SET location_label='".mysql_real_escape_string($_POST['location_label'])."', location_street='".mysql_real_escape_string($_POST['location_street'])."', location_street2='".mysql_real_escape_string($_POST['location_street2'])."', location_city='".mysql_real_escape_string($_POST['location_city'])."', location_state='".mysql_real_escape_string($_POST['location_state'])."', location_postcode='".mysql_real_escape_string($_POST['location_postcode'])."', location_country='".mysql_real_escape_string($_POST['location_country'])."' WHERE location_id=".mysql_real_escape_string($_POST['location_id']);
69
$wpdb->get_results($sql);
70
echo "<div class=\"updated\"><p><strong>".__('Location edited successfully','my-calendar')."</strong></p></div>";
71
}
@@ -104,10 +124,31 @@ function my_calendar_manage_locations() {
104
<p>
105
<label for="location_country"><?php _e('Country','my-calendar'); ?></label> <input type="text" id="location_country" name="location_country" class="input" size="10" value="" />
106
</p>
107
</fieldset>
108
<p>
109
<input type="submit" name="save" class="button-primary" value="<?php _e('Add Location','my-calendar'); ?> &raquo;" />
110
</p>
111
</form>
112
</div>
113
</div>
13
<?php
14
// We do some checking to see what we're doing
15
if (isset($_POST['mode']) && $_POST['mode'] == 'add') {
16
+ $sql = "INSERT INTO " . MY_CALENDAR_LOCATIONS_TABLE . " SET location_label='".mysql_real_escape_string($_POST['location_label'])."', location_street='".mysql_real_escape_string($_POST['location_street'])."', location_street2='".mysql_real_escape_string($_POST['location_street2'])."', location_city='".mysql_real_escape_string($_POST['location_city'])."', location_state='".mysql_real_escape_string($_POST['location_state'])."', location_postcode='".mysql_real_escape_string($_POST['location_postcode'])."', location_country='".mysql_real_escape_string($_POST['location_country'])."', location_longitude='".mysql_real_escape_string($_POST['location_longitude'])."', location_latitude='".mysql_real_escape_string($_POST['location_latitude'])."', location_zoom='".mysql_real_escape_string($_POST['location_zoom'])."'";
17
$wpdb->get_results($sql);
18
echo "<div class=\"updated\"><p><strong>".__('Location added successfully','my-calendar')."</strong></p></div>";
19
} else if (isset($_GET['mode']) && isset($_GET['location_id']) && $_GET['mode'] == 'delete') {
41
<?php _e('All location fields are optional: <em>insufficient information may result in an inaccurate map</em>.','my-calendar'); ?>
42
</p>
43
<p>
44
+ <label for="location_label"><?php _e('Name of Location (e.g. <em>Joe\'s Bar and Grill</em>)','my-calendar'); ?></label> <input type="text" id="location_label" name="location_label" class="input" size="40" value="<?php if ( !empty( $cur_loc ) ) echo htmlspecialchars(stripslashes($cur_loc->location_label)); ?>" />
45
</p>
46
<p>
47
+ <label for="location_street"><?php _e('Street Address','my-calendar'); ?></label> <input type="text" id="location_street" name="location_street" class="input" size="40" value="<?php if ( !empty( $cur_loc ) ) echo htmlspecialchars(stripslashes($cur_loc->location_street)); ?>" />
48
</p>
49
<p>
50
+ <label for="location_street2"><?php _e('Street Address (2)','my-calendar'); ?></label> <input type="text" id="location_street2" name="location_street2" class="input" size="40" value="<?php if ( !empty( $cur_loc ) ) echo htmlspecialchars(stripslashes($cur_loc->location_street2)); ?>" />
51
</p>
52
<p>
53
+ <label for="location_city"><?php _e('City','my-calendar'); ?></label> <input type="text" id="location_city" name="location_city" class="input" size="40" value="<?php if ( !empty( $cur_loc ) ) echo htmlspecialchars(stripslashes($cur_loc->location_city)); ?>" /> <label for="location_state"><?php _e('State/Province','my-calendar'); ?></label> <input type="text" id="location_state" name="location_state" class="input" size="10" value="<?php if ( !empty( $cur_loc ) ) echo htmlspecialchars($cur_loc->location_state); ?>" /> <label for="location_postcode"><?php _e('Postal Code','my-calendar'); ?></label> <input type="text" id="location_postcode" name="location_postcode" class="input" size="10" value="<?php if ( !empty( $cur_loc ) ) echo htmlspecialchars($cur_loc->location_postcode); ?>" />
54
</p>
55
<p>
56
+ <label for="location_country"><?php _e('Country','my-calendar'); ?></label> <input type="text" id="location_country" name="location_country" class="input" size="10" value="<?php if ( !empty( $cur_loc ) ) echo htmlspecialchars(stripslashes($cur_loc->location_country)); ?>" />
57
</p>
58
+ <p>
59
+ <label for="location_zoom"><?php _e('Initial Zoom','my-calendar'); ?></label>
60
+ <select name="location_zoom" id="location_zoom">
61
+ <option value="16"<?php if ( !empty( $cur_loc ) && ( $cur_loc->location_zoom == 16 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Neighborhood','my-calendar'); ?></option>
62
+ <option value="14"<?php if ( !empty( $cur_loc ) && ( $cur_loc->location_zoom == 14 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Small City','my-calendar'); ?></option>
63
+ <option value="12"<?php if ( !empty( $cur_loc ) && ( $cur_loc->location_zoom == 12 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Large City','my-calendar'); ?></option>
64
+ <option value="10"<?php if ( !empty( $cur_loc ) && ( $cur_loc->location_zoom == 10 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Greater Metro Area','my-calendar'); ?></option>
65
+ <option value="8"<?php if ( !empty( $cur_loc ) && ( $cur_loc->location_zoom == 8 ) ) { echo " selected=\"selected\""; } ?>><?php _e('State','my-calendar'); ?></option>
66
+ <option value="6"<?php if ( !empty( $cur_loc ) && ( $cur_loc->location_zoom == 6 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Region','my-calendar'); ?></option>
67
+ </select>
68
+ </p>
69
+ <fieldset>
70
+ <legend><?php _e('GPS Coordinates (optional)','my-calendar'); ?></legend>
71
+ <p>
72
+ <small><?php _e('If you supply GPS coordinates for your location, they will be used in place of any other address information to pinpoint your location.','my-calendar'); ?></small>
73
+ </p>
74
+ <p>
75
+ <label for="location_longitude"><?php _e('Longitude','my-calendar'); ?></label> <input type="text" id="location_longitude" name="location_longitude" class="input" size="10" value="<?php if ( !empty( $cur_loc ) ) echo htmlspecialchars(stripslashes($cur_loc->location_longitude)); ?>" /> <label for="location_latitude"><?php _e('Latitude','my-calendar'); ?></label> <input type="text" id="location_latitude" name="location_latitude" class="input" size="10" value="<?php if ( !empty( $cur_loc ) ) echo htmlspecialchars(stripslashes($cur_loc->location_latitude)); ?>" />
76
+ </p>
77
</fieldset>
78
<p>
79
<input type="submit" name="save" class="button-primary" value="<?php _e('Save Changes','my-calendar'); ?> &raquo;" />
80
</p>
81
+ </fieldset>
82
</form>
83
</div>
84
</div>
85
</div>
86
<?php
87
} else if (isset($_POST['mode']) && isset($_POST['location_id']) && isset($_POST['location_label']) && isset($_POST['location_street']) && $_POST['mode'] == 'edit') {
88
+ $sql = "UPDATE " . MY_CALENDAR_LOCATIONS_TABLE . " SET location_label='".mysql_real_escape_string($_POST['location_label'])."', location_street='".mysql_real_escape_string($_POST['location_street'])."', location_street2='".mysql_real_escape_string($_POST['location_street2'])."', location_city='".mysql_real_escape_string($_POST['location_city'])."', location_state='".mysql_real_escape_string($_POST['location_state'])."', location_postcode='".mysql_real_escape_string($_POST['location_postcode'])."', location_country='".mysql_real_escape_string($_POST['location_country'])."', location_longitude='".mysql_real_escape_string($_POST['location_longitude'])."', location_latitude='".mysql_real_escape_string($_POST['location_latitude'])."', location_zoom='".mysql_real_escape_string($_POST['location_zoom'])."' WHERE location_id=".mysql_real_escape_string($_POST['location_id']);
89
$wpdb->get_results($sql);
90
echo "<div class=\"updated\"><p><strong>".__('Location edited successfully','my-calendar')."</strong></p></div>";
91
}
124
<p>
125
<label for="location_country"><?php _e('Country','my-calendar'); ?></label> <input type="text" id="location_country" name="location_country" class="input" size="10" value="" />
126
</p>
127
+ <p>
128
+ <label for="location_zoom"><?php _e('Initial Zoom','my-calendar'); ?></label>
129
+ <select name="location_zoom" id="location_zoom">
130
+ <option value="16"><?php _e('Neighborhood','my-calendar'); ?></option>
131
+ <option value="14"><?php _e('Small City','my-calendar'); ?></option>
132
+ <option value="12"><?php _e('Large City','my-calendar'); ?></option>
133
+ <option value="10"><?php _e('Greater Metro Area','my-calendar'); ?></option>
134
+ <option value="8"><?php _e('State','my-calendar'); ?></option>
135
+ <option value="6"><?php _e('Region','my-calendar'); ?></option>
136
+ </select>
137
+ </p>
138
+ <fieldset>
139
+ <legend><?php _e('GPS Coordinates (optional)','my-calendar'); ?></legend>
140
+ <p>
141
+ <small><?php _e('If you supply GPS coordinates for your location, they will be used in place of any other address information to pinpoint your location.','my-calendar'); ?></small>
142
+ </p>
143
+ <p>
144
+ <label for="location_longitude"><?php _e('Longitude','my-calendar'); ?></label> <input type="text" id="location_longitude" name="location_longitude" class="input" size="10" value="" /> <label for="location_latitude"><?php _e('Latitude','my-calendar'); ?></label> <input type="text" id="location_latitude" name="location_latitude" class="input" size="10" value="" />
145
+ </p>
146
</fieldset>
147
<p>
148
<input type="submit" name="save" class="button-primary" value="<?php _e('Add Location','my-calendar'); ?> &raquo;" />
149
</p>
150
+ </fieldset>
151
+
152
</form>
153
</div>
154
</div>
my-calendar-settings.php CHANGED
@@ -99,14 +99,21 @@ function edit_my_calendar_config() {
99
$my_calendar_show_months = (int) $_POST['my_calendar_show_months'];
100
$my_calendar_date_format = $_POST['my_calendar_date_format'];
101
102
$disp_author = ($_POST['display_author']=='on')?'true':'false';
103
$disp_jump = ($_POST['display_jump']=='on')?'true':'false';
104
$my_calendar_show_map = ($_POST['my_calendar_show_map']=='on')?'true':'false';
105
$my_calendar_show_address = ($_POST['my_calendar_show_address']=='on')?'true':'false';
106
$my_calendar_show_heading = ($_POST['my_calendar_show_heading']=='on')?'true':'false';
107
$my_calendar_notime_text = $_POST['my_calendar_notime_text'];
108
$my_calendar_hide_icons = ($_POST['my_calendar_hide_icons']=='on')?'true':'false';
109
$my_calendar_caption = $_POST['my_calendar_caption'];
110
111
update_option('can_manage_events',$new_perms);
112
update_option('display_author',$disp_author);
@@ -117,8 +124,14 @@ function edit_my_calendar_config() {
117
update_option('my_calendar_show_address',$my_calendar_show_address);
118
update_option('my_calendar_show_heading',$my_calendar_show_heading);
119
update_option('my_calendar_notime_text',$my_calendar_notime_text);
120
update_option('my_calendar_hide_icons',$my_calendar_hide_icons);
121
update_option('my_calendar_caption',$my_calendar_caption);
122
echo "<div class=\"updated\"><p><strong>".__('Settings saved','my-calendar').".</strong></p></div>";
123
}
124
@@ -128,6 +141,7 @@ function edit_my_calendar_config() {
128
$my_calendar_show_map = get_option('my_calendar_show_map');
129
$my_calendar_show_address = get_option('my_calendar_show_address');
130
$disp_author = get_option('display_author');
131
// checkbox
132
$disp_jump = get_option('display_jump');
133
//checkbox
@@ -190,6 +204,12 @@ function edit_my_calendar_config() {
190
<label for="my_calendar_notime_text"><?php _e('Label for events without a specific time'); ?></label> <input type="text" id="my_calendar_notime_text" name="my_calendar_notime_text" value="<?php if ( get_option('my_calendar_notime_text') == "") { _e('N/A','my-calendar'); } else { echo stripslashes( get_option('my_calendar_notime_text') ); } ?>" />
191
</p>
192
<p>
193
<label for="my_calendar_caption"><?php _e('Additional caption text','my-calendar'); ?></label> <input type="text" id="my_calendar_caption" name="my_calendar_caption" value="<?php echo stripslashes( get_option('my_calendar_caption') ); ?>" /><br /><small><?php _e('The calendar caption is the text containing the displayed month and year in either list or calendar format. This text will be displayed following that existing text.'); ?></small>
194
</p>
195
<p>
@@ -200,6 +220,14 @@ function edit_my_calendar_config() {
200
</p>
201
<p>
202
<input type="checkbox" id="my_calendar_show_address" name="my_calendar_show_address" <?php jd_cal_checkCheckbox('my_calendar_show_address','true'); ?> /> <label for="my_calendar_show_address"><?php _e('Show Event Address in Details','my-calendar'); ?></label>
203
</p>
204
</fieldset>
205
<p>
@@ -233,8 +261,5 @@ if ( get_option( 'ko_calendar_imported' ) != 'true' ) {
233
</div>
234
</div>
235
<?php
236
-
237
-
238
}
239
-
240
?>
99
$my_calendar_show_months = (int) $_POST['my_calendar_show_months'];
100
$my_calendar_date_format = $_POST['my_calendar_date_format'];
101
102
+
103
$disp_author = ($_POST['display_author']=='on')?'true':'false';
104
$disp_jump = ($_POST['display_jump']=='on')?'true':'false';
105
$my_calendar_show_map = ($_POST['my_calendar_show_map']=='on')?'true':'false';
106
$my_calendar_show_address = ($_POST['my_calendar_show_address']=='on')?'true':'false';
107
$my_calendar_show_heading = ($_POST['my_calendar_show_heading']=='on')?'true':'false';
108
$my_calendar_notime_text = $_POST['my_calendar_notime_text'];
109
+ $mc_previous_events = $_POST['mc_previous_events'];
110
+ $mc_next_events = $_POST['mc_next_events'];
111
+
112
$my_calendar_hide_icons = ($_POST['my_calendar_hide_icons']=='on')?'true':'false';
113
+ $mc_apply_color = $_POST['mc_apply_color'];
114
+
115
$my_calendar_caption = $_POST['my_calendar_caption'];
116
+ $my_calendar_event_link_expires = ($_POST['mc_event_link_expires']=='on')?'true':'false';
117
118
update_option('can_manage_events',$new_perms);
119
update_option('display_author',$disp_author);
124
update_option('my_calendar_show_address',$my_calendar_show_address);
125
update_option('my_calendar_show_heading',$my_calendar_show_heading);
126
update_option('my_calendar_notime_text',$my_calendar_notime_text);
127
+ update_option('mc_next_events',$mc_next_events);
128
+ update_option('mc_previous_events',$mc_previous_events);
129
update_option('my_calendar_hide_icons',$my_calendar_hide_icons);
130
update_option('my_calendar_caption',$my_calendar_caption);
131
+ update_option('mc_event_link_expires',$my_calendar_event_link_expires);
132
+ update_option('mc_apply_color',$mc_apply_color);
133
+
134
+
135
echo "<div class=\"updated\"><p><strong>".__('Settings saved','my-calendar').".</strong></p></div>";
136
}
137
141
$my_calendar_show_map = get_option('my_calendar_show_map');
142
$my_calendar_show_address = get_option('my_calendar_show_address');
143
$disp_author = get_option('display_author');
144
+ $mc_event_link_expires = get_option('mc_event_link_expires');
145
// checkbox
146
$disp_jump = get_option('display_jump');
147
//checkbox
204
<label for="my_calendar_notime_text"><?php _e('Label for events without a specific time'); ?></label> <input type="text" id="my_calendar_notime_text" name="my_calendar_notime_text" value="<?php if ( get_option('my_calendar_notime_text') == "") { _e('N/A','my-calendar'); } else { echo stripslashes( get_option('my_calendar_notime_text') ); } ?>" />
205
</p>
206
<p>
207
+ <label for="mc_previous_events"><?php _e('Previous events link text'); ?></label> <input type="text" id="mc_previous_events" name="mc_previous_events" value="<?php if ( get_option('mc_previous_events') == "") { _e('Previous Events','my-calendar'); } else { echo stripslashes( get_option('mc_previous_events') ); } ?>" />
208
+ </p>
209
+ <p>
210
+ <label for="mc_next_events"><?php _e('Next events link text'); ?></label> <input type="text" id="mc_next_events" name="mc_next_events" value="<?php if ( get_option('mc_next_events') == "") { _e('Next Events','my-calendar'); } else { echo stripslashes( get_option('mc_next_events') ); } ?>" />
211
+ </p>
212
+ <p>
213
<label for="my_calendar_caption"><?php _e('Additional caption text','my-calendar'); ?></label> <input type="text" id="my_calendar_caption" name="my_calendar_caption" value="<?php echo stripslashes( get_option('my_calendar_caption') ); ?>" /><br /><small><?php _e('The calendar caption is the text containing the displayed month and year in either list or calendar format. This text will be displayed following that existing text.'); ?></small>
214
</p>
215
<p>
220
</p>
221
<p>
222
<input type="checkbox" id="my_calendar_show_address" name="my_calendar_show_address" <?php jd_cal_checkCheckbox('my_calendar_show_address','true'); ?> /> <label for="my_calendar_show_address"><?php _e('Show Event Address in Details','my-calendar'); ?></label>
223
+ </p>
224
+ <p>
225
+ <input type="checkbox" id="mc_event_link_expires" name="mc_event_link_expires" <?php jd_cal_checkCheckbox('mc_event_link_expires','true'); ?> /> <label for="mc_event_link_expires"><?php _e('Links associated with events will automatically expire after the event has passed.','my-calendar'); ?></label>
226
+ </p>
227
+ <p>
228
+ <input type="radio" id="mc_apply_color_default" name="mc_apply_color" value="default" <?php jd_cal_checkCheckbox('mc_apply_color','default'); ?> /> <label for="mc_apply_color_default"><?php _e('Default usage of category colors.','my-calendar'); ?></label><br />
229
+ <input type="radio" id="mc_apply_color_to_titles" name="mc_apply_color" value="font" <?php jd_cal_checkCheckbox('mc_apply_color','font'); ?> /> <label for="mc_apply_color_to_titles"><?php _e('Apply category colors to event titles as a font color.','my-calendar'); ?></label><br />
230
+ <input type="radio" id="mc_apply_bgcolor_to_titles" name="mc_apply_color" value="background" <?php jd_cal_checkCheckbox('mc_apply_color','background'); ?> /> <label for="mc_apply_bgcolor_to_titles"><?php _e('Apply category colors to event titles as a background color.','my-calendar'); ?></label>
231
</p>
232
</fieldset>
233
<p>
261
</div>
262
</div>
263
<?php
264
}
265
?>
my-calendar-styles.php CHANGED
@@ -2,8 +2,8 @@
2
// Display the admin configuration page
3
4
function edit_my_calendar_styles() {
5
- global $wpdb, $initial_style, $initial_listjs, $initial_caljs;
6
-
7
// We can't use this page unless My Calendar is installed/upgraded
8
check_my_calendar();
9
@@ -12,15 +12,20 @@ function edit_my_calendar_styles() {
12
$my_calendar_style = $_POST['style'];
13
$my_calendar_caljs = $_POST['my_calendar_caljs'];
14
$my_calendar_listjs = $_POST['my_calendar_listjs'];
15
16
17
$use_styles = ($_POST['use_styles']=='on')?'true':'false';
18
19
update_option('my_calendar_style',$my_calendar_style);
20
update_option('my_calendar_use_styles',$use_styles);
21
update_option('calendar_javascript', (int) $_POST['calendar_javascript']);
22
update_option('list_javascript', (int) $_POST['list_javascript']);
23
update_option('my_calendar_listjs',$my_calendar_listjs);
24
update_option('my_calendar_caljs',$my_calendar_caljs);
25
$my_calendar_show_css = ($_POST['my_calendar_show_css']=='')?'':$_POST['my_calendar_show_css'];
26
update_option('my_calendar_show_css',$my_calendar_show_css);
@@ -30,11 +35,14 @@ function edit_my_calendar_styles() {
30
update_option('my_calendar_style',$initial_style);
31
}
32
if ( $_POST['reset_caljs'] == 'on') {
33
- update_option('my_calendar_listjs',$initial_listjs);
34
}
35
if ( $_POST['reset_listjs'] == 'on') {
36
- update_option('my_calendar_caljs',$initial_caljs);
37
}
38
echo "<div class=\"updated\"><p><strong>".__('Style Settings saved','my-calendar').".</strong></p></div>";
39
}
40
@@ -47,12 +55,13 @@ function edit_my_calendar_styles() {
47
$my_calendar_caljs = stripcslashes(get_option('my_calendar_caljs'));
48
$calendar_javascript = get_option('calendar_javascript');
49
50
$my_calendar_show_css = stripcslashes(get_option('my_calendar_show_css'));
51
-
52
53
// Now we render the form
54
55
-
56
?>
57
<div class="wrap">
58
@@ -63,7 +72,10 @@ function edit_my_calendar_styles() {
63
<h3><?php _e('Calendar Style Settings','my-calendar'); ?></h3>
64
<div class="inside">
65
<form name="my-calendar" id="my-calendar" method="post" action="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar-styles">
66
- <fieldset>
67
<legend><?php _e('CSS Style Options','my-calendar'); ?></legend>
68
<p>
69
<input type="checkbox" id="reset_styles" name="reset_styles" /> <label for="reset_styles"><?php _e('Reset the My Calendar stylesheet to the default','my-calendar'); ?></label> <input type="checkbox" id="use_styles" name="use_styles" <?php jd_cal_checkCheckbox('my_calendar_use_styles','true'); ?> /> <label for="use_styles"><?php _e('Disable My Calendar Stylesheet','my-calendar'); ?></label>
@@ -72,8 +84,8 @@ function edit_my_calendar_styles() {
72
<label for="style"><?php _e('Edit the stylesheet for My Calendar','my-calendar'); ?></label><br /><textarea id="style" name="style" rows="30" cols="80"><?php echo $my_calendar_style; ?></textarea>
73
</p>
74
<p>
75
- <label for="my_calendar_show_css"><?php _e('Show CSS only on these pages (comma separated page IDs)','my-calendar'); ?></label> <input type="text" id="my_calendar_show_css" name="my_calendar_show_css" value="<?php echo $my_calendar_show_css; ?>" />
76
- </p>
77
</fieldset>
78
<fieldset>
79
<legend><?php _e('Calendar Behaviors: Calendar View','my-calendar'); ?></legend>
@@ -83,6 +95,9 @@ function edit_my_calendar_styles() {
83
<p>
84
<label for="calendar-javascript"><?php _e('Edit the jQuery scripts for My Calendar in Calendar format','my-calendar'); ?></label><br /><textarea id="calendar-javascript" name="my_calendar_caljs" rows="10" cols="80"><?php echo $my_calendar_caljs; ?></textarea>
85
</p>
86
</fieldset>
87
<fieldset>
88
<legend><?php _e('Calendar Behaviors: List View','my-calendar'); ?></legend>
@@ -92,10 +107,22 @@ function edit_my_calendar_styles() {
92
<p>
93
<label for="list-javascript"><?php _e('Edit the jQuery scripts for My Calendar in List format','my-calendar'); ?></label><br /><textarea id="list-javascript" name="my_calendar_listjs" rows="10" cols="80"><?php echo $my_calendar_listjs; ?></textarea>
94
</p>
95
- </fieldset>
96
<p>
97
<input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-calendar'); ?> &raquo;" />
98
</p>
99
</form>
100
</div>
101
2
// Display the admin configuration page
3
4
function edit_my_calendar_styles() {
5
+ global $wpdb, $initial_style, $initial_listjs, $initial_caljs, $initial_minijs;
6
+
7
// We can't use this page unless My Calendar is installed/upgraded
8
check_my_calendar();
9
12
$my_calendar_style = $_POST['style'];
13
$my_calendar_caljs = $_POST['my_calendar_caljs'];
14
$my_calendar_listjs = $_POST['my_calendar_listjs'];
15
+ $my_calendar_minijs = $_POST['my_calendar_minijs'];
16
17
18
$use_styles = ($_POST['use_styles']=='on')?'true':'false';
19
20
update_option('my_calendar_style',$my_calendar_style);
21
update_option('my_calendar_use_styles',$use_styles);
22
+ // turn info off or on
23
update_option('calendar_javascript', (int) $_POST['calendar_javascript']);
24
update_option('list_javascript', (int) $_POST['list_javascript']);
25
+ update_option('mini_javascript', (int) $_POST['mini_javascript']);
26
+ // set js
27
update_option('my_calendar_listjs',$my_calendar_listjs);
28
+ update_option('my_calendar_minijs',$my_calendar_minijs);
29
update_option('my_calendar_caljs',$my_calendar_caljs);
30
$my_calendar_show_css = ($_POST['my_calendar_show_css']=='')?'':$_POST['my_calendar_show_css'];
31
update_option('my_calendar_show_css',$my_calendar_show_css);
35
update_option('my_calendar_style',$initial_style);
36
}
37
if ( $_POST['reset_caljs'] == 'on') {
38
+ update_option('my_calendar_caljs',$initial_caljs);
39
}
40
if ( $_POST['reset_listjs'] == 'on') {
41
+ update_option('my_calendar_listjs',$initial_listjs);
42
}
43
+ if ( $_POST['reset_minijs'] == 'on') {
44
+ update_option('my_calendar_minijs',$initial_minijs);
45
+ }
46
echo "<div class=\"updated\"><p><strong>".__('Style Settings saved','my-calendar').".</strong></p></div>";
47
}
48
55
$my_calendar_caljs = stripcslashes(get_option('my_calendar_caljs'));
56
$calendar_javascript = get_option('calendar_javascript');
57
58
+ $my_calendar_minijs = stripcslashes(get_option('my_calendar_minijs'));
59
+ $mini_javascript = get_option('mini_javascript');
60
+
61
$my_calendar_show_css = stripcslashes(get_option('my_calendar_show_css'));
62
63
// Now we render the form
64
65
?>
66
<div class="wrap">
67
72
<h3><?php _e('Calendar Style Settings','my-calendar'); ?></h3>
73
<div class="inside">
74
<form name="my-calendar" id="my-calendar" method="post" action="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar-styles">
75
+ <p>
76
+ <label for="my_calendar_show_css"><?php _e('Show CSS & JavaScript only on these pages (comma separated page IDs)','my-calendar'); ?></label> <input type="text" id="my_calendar_show_css" name="my_calendar_show_css" value="<?php echo $my_calendar_show_css; ?>" />
77
+ </p>
78
+ <fieldset>
79
<legend><?php _e('CSS Style Options','my-calendar'); ?></legend>
80
<p>
81
<input type="checkbox" id="reset_styles" name="reset_styles" /> <label for="reset_styles"><?php _e('Reset the My Calendar stylesheet to the default','my-calendar'); ?></label> <input type="checkbox" id="use_styles" name="use_styles" <?php jd_cal_checkCheckbox('my_calendar_use_styles','true'); ?> /> <label for="use_styles"><?php _e('Disable My Calendar Stylesheet','my-calendar'); ?></label>
84
<label for="style"><?php _e('Edit the stylesheet for My Calendar','my-calendar'); ?></label><br /><textarea id="style" name="style" rows="30" cols="80"><?php echo $my_calendar_style; ?></textarea>
85
</p>
86
<p>
87
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-calendar'); ?> &raquo;" />
88
+ </p>
89
</fieldset>
90
<fieldset>
91
<legend><?php _e('Calendar Behaviors: Calendar View','my-calendar'); ?></legend>
95
<p>
96
<label for="calendar-javascript"><?php _e('Edit the jQuery scripts for My Calendar in Calendar format','my-calendar'); ?></label><br /><textarea id="calendar-javascript" name="my_calendar_caljs" rows="10" cols="80"><?php echo $my_calendar_caljs; ?></textarea>
97
</p>
98
+ <p>
99
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-calendar'); ?> &raquo;" />
100
+ </p>
101
</fieldset>
102
<fieldset>
103
<legend><?php _e('Calendar Behaviors: List View','my-calendar'); ?></legend>
107
<p>
108
<label for="list-javascript"><?php _e('Edit the jQuery scripts for My Calendar in List format','my-calendar'); ?></label><br /><textarea id="list-javascript" name="my_calendar_listjs" rows="10" cols="80"><?php echo $my_calendar_listjs; ?></textarea>
109
</p>
110
<p>
111
<input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-calendar'); ?> &raquo;" />
112
+ </p>
113
+ </fieldset>
114
+ <fieldset>
115
+ <legend><?php _e('Calendar Behaviors: Mini Calendar View','my-calendar'); ?></legend>
116
+ <p>
117
+ <input type="checkbox" id="reset_minijs" name="reset_minijs" /> <label for="reset_listjs"><?php _e('Reset the My Calendar Mini Format Javascript','my-calendar'); ?></label> <input type="checkbox" id="list_javascript" name="list_javascript" value="1" <?php jd_cal_checkCheckbox('list_javascript',1); ?> /> <label for="list_javascript"><?php _e('Disable List Javascript Effects','my-calendar'); ?></label>
118
</p>
119
+ <p>
120
+ <label for="mini-javascript"><?php _e('Edit the jQuery scripts for My Calendar in Mini Calendar format','my-calendar'); ?></label><br /><textarea id="mini-javascript" name="my_calendar_minijs" rows="10" cols="80"><?php echo $my_calendar_minijs; ?></textarea>
121
+ </p>
122
+ <p>
123
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-calendar'); ?> &raquo;" />
124
+ </p>
125
+ </fieldset>
126
</form>
127
</div>
128
my-calendar-widgets.php CHANGED
@@ -135,12 +135,12 @@ function init_my_calendar_upcoming() {
135
</select>
136
</p>
137
<p>
138
- <input type="text" id="display_upcoming_events" name="display_upcoming_events" value="<?php if(isset($_POST['display_upcoming_events'])){echo $_POST['display_upcoming_events']; } else { echo $upcoming_events; } ?>" size="1" maxlength="2" /> <label for="display_upcoming_events"><?php _e('events into the future;','my-calendar'); ?></label><br />
139
- <input type="text" id="display_past_events" name="display_past_events" value="<?php if(isset($_POST['display_past_events'])){echo $_POST['display_past_events']; } else { echo $past_events; } ?>" size="1" maxlength="2" /> <label for="display_past_events"><?php _e('events from the past','my-calendar'); ?></label>
140
</p>
141
<p>
142
- <input type="text" id="display_upcoming_days" name="display_upcoming_days" value="<?php if(isset($_POST['display_upcoming_days'])){echo $_POST['display_upcoming_days']; } else { echo $upcoming_days; } ?>" size="1" maxlength="2" /> <label for="display_upcoming_days"><?php _e('days into the future;','my-calendar'); ?></label><br />
143
- <input type="text" id="display_past_days" name="display_past_days" value="<?php if(isset($_POST['display_past_days'])){echo $_POST['display_past_days']; } else { echo $past_days; } ?>" size="1" maxlength="2" /> <label for="display_past_days"><?php _e('days from the past','my-calendar'); ?></label>
144
</p>
145
<p>
146
<label for="display_in_category"><?php _e('Show only this category:','my-calendar'); ?></label><br />
@@ -157,11 +157,11 @@ function init_my_calendar_upcoming() {
157
// Widget upcoming events
158
function my_calendar_upcoming_events($before='default',$after='default',$type='default',$category='default',$template='default') {
159
global $wpdb;
160
161
// This function cannot be called unless calendar is up to date
162
check_my_calendar();
163
- $offset = get_option('gmt_offset');
164
- $today = date('Y',time()+(60*60*$offset)).'-'.date('m',time()+(60*60*$offset)).'-'.date('d',time()+(60*60*$offset));
165
166
if ($type == 'default') {
167
$display_upcoming_type = get_option('display_upcoming_type');
@@ -298,7 +298,7 @@ function my_calendar_todays_events($category='default',$template='default') {
298
$category = $category;
299
}
300
301
- $events = my_calendar_grab_events(date("Y"),date("m"),date("d"),$category);
302
if (count($events) != 0) {
303
$output = "<ul>";
304
}
@@ -339,6 +339,8 @@ function event_as_array($event) {
339
// My Calendar must be updated to run this function
340
check_my_calendar();
341
342
$sql = "SELECT category_name FROM " . MY_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".$event->event_category;
343
$category_name = $wpdb->get_row($sql);
344
$e = get_userdata($event->event_author);
@@ -369,14 +371,20 @@ if ($event->event_country != "") {
369
$hcard .= "</div>\n</div>";
370
371
$map_string = $event->event_street.' '.$event->event_street2.' '.$event->event_city.' '.$event->event_state.' '.$event->event_postcode.' '.$event->event_country;
372
- if (strlen($map_string) > 10) {
373
$map_string = str_replace(" ","+",$map_string);
374
if ($event->event_label != "") {
375
$map_label = $event->event_label;
376
} else {
377
$map_label = $event->event_title;
378
}
379
- $map = "<a href=\"http://maps.google.com/maps?f=q&z=15&q=$map_string\">Map<span> to $map_label</span></a>";
380
} else {
381
$map = "";
382
}
@@ -394,14 +402,27 @@ $date_end = date_i18n(get_option('date_format'),strtotime($event->event_end));
394
$details['category'] = stripslashes($category_name->category_name);
395
$details['title'] = stripslashes($event->event_title);
396
if ($event->event_time == '00:00:00' ) {
397
- $details['time'] = __('N/A','my-calendar');
398
} else {
399
$details['time'] = date(get_option('time_format'),strtotime($event->event_time));
400
}
401
$details['author'] = $e->display_name;
402
$details['link'] = $event->event_link;
403
$details['description'] = stripslashes($event->event_desc);
404
- if ($event->event_link != '') {
405
$details['link_title'] = "<a href='".$event->event_link."'>".stripslashes($event->event_title)."</a>";
406
} else {
407
$details['link_title'] = stripslashes($event->event_title);
@@ -421,5 +442,4 @@ $date_end = date_i18n(get_option('date_format'),strtotime($event->event_end));
421
return $details;
422
}
423
424
-
425
?>
135
</select>
136
</p>
137
<p>
138
+ <input type="text" id="display_upcoming_events" name="display_upcoming_events" value="<?php if(isset($_POST['display_upcoming_events'])){echo $_POST['display_upcoming_events']; } else { echo $upcoming_events; } ?>" size="1" maxlength="3" /> <label for="display_upcoming_events"><?php _e('events into the future;','my-calendar'); ?></label><br />
139
+ <input type="text" id="display_past_events" name="display_past_events" value="<?php if(isset($_POST['display_past_events'])){echo $_POST['display_past_events']; } else { echo $past_events; } ?>" size="1" maxlength="3" /> <label for="display_past_events"><?php _e('events from the past','my-calendar'); ?></label>
140
</p>
141
<p>
142
+ <input type="text" id="display_upcoming_days" name="display_upcoming_days" value="<?php if(isset($_POST['display_upcoming_days'])){echo $_POST['display_upcoming_days']; } else { echo $upcoming_days; } ?>" size="1" maxlength="3" /> <label for="display_upcoming_days"><?php _e('days into the future;','my-calendar'); ?></label><br />
143
+ <input type="text" id="display_past_days" name="display_past_days" value="<?php if(isset($_POST['display_past_days'])){echo $_POST['display_past_days']; } else { echo $past_days; } ?>" size="1" maxlength="3" /> <label for="display_past_days"><?php _e('days from the past','my-calendar'); ?></label>
144
</p>
145
<p>
146
<label for="display_in_category"><?php _e('Show only this category:','my-calendar'); ?></label><br />
157
// Widget upcoming events
158
function my_calendar_upcoming_events($before='default',$after='default',$type='default',$category='default',$template='default') {
159
global $wpdb;
160
+ $offset = (60*60*get_option('gmt_offset'));
161
162
// This function cannot be called unless calendar is up to date
163
check_my_calendar();
164
+ $today = date('Y',time()+($offset)).'-'.date('m',time()+($offset)).'-'.date('d',time()+($offset));
165
166
if ($type == 'default') {
167
$display_upcoming_type = get_option('display_upcoming_type');
298
$category = $category;
299
}
300
301
+ $events = my_calendar_grab_events(date_i18n("Y"),date_i18n("m"),date_i18n("d"),$category);
302
if (count($events) != 0) {
303
$output = "<ul>";
304
}
339
// My Calendar must be updated to run this function
340
check_my_calendar();
341
342
+ $offset = (60*60*get_option('gmt_offset'));
343
+
344
$sql = "SELECT category_name FROM " . MY_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".$event->event_category;
345
$category_name = $wpdb->get_row($sql);
346
$e = get_userdata($event->event_author);
371
$hcard .= "</div>\n</div>";
372
373
$map_string = $event->event_street.' '.$event->event_street2.' '.$event->event_city.' '.$event->event_state.' '.$event->event_postcode.' '.$event->event_country;
374
+ if ( strlen($map_string) > 0 ) {
375
$map_string = str_replace(" ","+",$map_string);
376
if ($event->event_label != "") {
377
$map_label = $event->event_label;
378
} else {
379
$map_label = $event->event_title;
380
}
381
+ $zoom = ($event->event_zoom != 0)?$event->event_zoom:'15';
382
+
383
+ if ($event->event_longitude != '0.000000' && $event->event_latitude != '0.000000') {
384
+ $map_string = "$event->event_longitude,$event->event_latitude";
385
+ }
386
+
387
+ $map = "<a href=\"http://maps.google.com/maps?f=q&z=$zoom&q=$map_string\">Map<span> to $map_label</span></a>";
388
} else {
389
$map = "";
390
}
402
$details['category'] = stripslashes($category_name->category_name);
403
$details['title'] = stripslashes($event->event_title);
404
if ($event->event_time == '00:00:00' ) {
405
+ $details['time'] = get_option( 'my_calendar_notime_text' );
406
} else {
407
$details['time'] = date(get_option('time_format'),strtotime($event->event_time));
408
}
409
+ if ($event->event_endtime == '00:00:00' ) {
410
+ $deatils['endtime'] = '';
411
+ } else {
412
+ $details['endtime'] = date( get_option('time_format'),strtotime($event->event_endtime));
413
+ }
414
$details['author'] = $e->display_name;
415
+ if ( $event->event_link_expires == 0 ) {
416
$details['link'] = $event->event_link;
417
+ } else {
418
+ if ( my_calendar_date_comp( $event->event_begin, date_i18n('Y-m-d',time() ) ) ) {
419
+ $details['link'] = '';
420
+ } else {
421
+ $details['link'] = $event->event_link;
422
+ }
423
+ }
424
$details['description'] = stripslashes($event->event_desc);
425
+ if ($details['link'] != '') {
426
$details['link_title'] = "<a href='".$event->event_link."'>".stripslashes($event->event_title)."</a>";
427
} else {
428
$details['link_title'] = stripslashes($event->event_title);
442
return $details;
443
}
444
445
?>
my-calendar.php CHANGED
@@ -1,2038 +1,1607 @@
1
- <?php
2
- /*
3
- Plugin Name: My Calendar
4
- Plugin URI: http://www.joedolson.com/articles/my-calendar/
5
- Description: Accessible WordPress event calendar plugin. Show events from multiple calendars on pages, in posts, or in widgets.
6
- Author: Joseph C Dolson
7
- Author URI: http://www.joedolson.com
8
- Version: 1.3.8
9
- */
10
- /* Copyright 2009 Joe Dolson (email : joe@joedolson.com)
11
-
12
- This program is free software; you can redistribute it and/or modify
13
- it under the terms of the GNU General Public License as published by
14
- the Free Software Foundation; either version 2 of the License, or
15
- (at your option) any later version.
16
-
17
- This program is distributed in the hope that it will be useful,
18
- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- GNU General Public License for more details.
21
-
22
- You should have received a copy of the GNU General Public License
23
- along with this program; if not, write to the Free Software
24
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
- */
26
-
27
- // Enable internationalisation
28
- $plugin_dir = basename(dirname(__FILE__));
29
- load_plugin_textdomain( 'my-calendar','wp-content/plugins/'.$plugin_dir, $plugin_dir);
30
- global $wpdb;
31
- // Define the tables used in My Calendar
32
- define('MY_CALENDAR_TABLE', $wpdb->prefix . 'my_calendar');
33
- define('MY_CALENDAR_CATEGORIES_TABLE', $wpdb->prefix . 'my_calendar_categories');
34
- define('MY_CALENDAR_LOCATIONS_TABLE', $wpdb->prefix . 'my_calendar_locations');
35
-
36
- // Create a master category for My Calendar and its sub-pages
37
- add_action('admin_menu', 'my_calendar_menu');
38
- // Add the function that puts style information in the header
39
- add_action('wp_head', 'my_calendar_wp_head');
40
- // Add the function that deals with deleted users
41
- add_action('delete_user', 'mc_deal_with_deleted_user');
42
- // Add the widgets if we are using version 2.8
43
- add_action('widgets_init', 'init_my_calendar_today');
44
- add_action('widgets_init', 'init_my_calendar_upcoming');
45
-
46
- function jd_calendar_plugin_action($links, $file) {
47
- if ($file == plugin_basename(dirname(__FILE__).'/my-calendar.php'))
48
- $links[] = "<a href='admin.php?page=my-calendar-config'>" . __('Settings', 'my-calendar') . "</a>";
49
- return $links;
50
- }
51
- add_filter('plugin_action_links', 'jd_calendar_plugin_action', -10, 2);
52
-
53
- include(dirname(__FILE__).'/my-calendar-settings.php' );
54
- include(dirname(__FILE__).'/my-calendar-categories.php' );
55
- include(dirname(__FILE__).'/my-calendar-locations.php' );
56
- include(dirname(__FILE__).'/my-calendar-help.php' );
57
- include(dirname(__FILE__).'/my-calendar-event-manager.php' );
58
- include(dirname(__FILE__).'/my-calendar-styles.php' );
59
- include(dirname(__FILE__).'/my-calendar-widgets.php' );
60
- include(dirname(__FILE__).'/date-utilities.php' );
61
-
62
-
63
- // Before we get on with the functions, we need to define the initial style used for My Calendar
64
-
65
- function jd_show_support_box() {
66
- ?>
67
- <div class="resources">
68
- <ul>
69
- <li><a href="http://www.joedolson.com/articles/my-calendar/"><?php _e("Get Support",'my-calendar'); ?></a></li>
70
- <li><a href="http://www.joedolson.com/donate.php"><?php _e("Make a Donation",'my-calendar'); ?></a></li>
71
- <li><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
72
- <div>
73
- <input type="hidden" name="cmd" value="_s-xclick" />
74
- <input type="hidden" name="hosted_button_id" value="8490399" />
75
- <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" name="submit" alt="Donate" />
76
- <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
77
- </div>
78
- </form></li>
79
- </ul>
80
-
81
- </div>
82
- <?php
83
- }
84
-
85
- // Function to deal with events posted by a user when that user is deleted
86
- function mc_deal_with_deleted_user($id) {
87
- global $wpdb;
88
- // This wouldn't work unless the database was up to date. Lets check.
89
- check_my_calendar();
90
- // Do the query
91
- $wpdb->get_results( "UPDATE ".MY_CALENDAR_TABLE." SET event_author=".$wpdb->get_var("SELECT MIN(ID) FROM ".$wpdb->prefix."users",0,0)." WHERE event_author=".$id );
92
- }
93
-
94
- // Function to add the calendar style into the header
95
- function my_calendar_wp_head() {
96
- global $wpdb, $wp_query;
97
- // If the calendar isn't installed or upgraded this won't work
98
- check_my_calendar();
99
- $styles = stripcslashes(get_option('my_calendar_style'));
100
- if ( get_option('my_calendar_use_styles') != 'true' ) {
101
-
102
- $this_post = $wp_query->get_queried_object();
103
- if (is_object($this_post)) {
104
- $id = $this_post->ID;
105
- }
106
- if ( get_option( 'my_calendar_show_css' ) != '' ) {
107
- $array = explode( ",",get_option( 'my_calendar_show_css' ) );
108
- if (!is_array($array)) {
109
- $array = array();
110
- }
111
- }
112
- if ( @in_array( $id, $array ) || get_option( 'my_calendar_show_css' ) == '' ) {
113
-
114
- echo "
115
- <style type=\"text/css\">
116
- <!--
117
- // Styles from My Calendar - Joseph C Dolson http://www.joedolson.com/
118
- $styles
119
- -->
120
- </style>";
121
-
122
- }
123
- }
124
- }
125
-
126
- // Function to deal with adding the calendar menus
127
- function my_calendar_menu() {
128
- global $wpdb;
129
- // We make use of the My Calendar tables so we must have installed My Calendar
130
- check_my_calendar();
131
- // Set admin as the only one who can use My Calendar for security
132
- $allowed_group = 'manage_options';
133
- // Use the database to *potentially* override the above if allowed
134
- $allowed_group = get_option('can_manage_events');
135
-
136
-
137
- // Add the admin panel pages for My Calendar. Use permissions pulled from above
138
- if (function_exists('add_menu_page')) {
139
- add_menu_page(__('My Calendar','my-calendar'), __('My Calendar','my-calendar'), $allowed_group, 'my-calendar', 'edit_my_calendar');
140
- }
141
- if (function_exists('add_submenu_page')) {
142
- add_submenu_page('my-calendar', __('Add/Edit Events','my-calendar'), __('Add/Edit Events','my-calendar'), $allowed_group, 'my-calendar', 'edit_my_calendar');
143
- add_action( "admin_head", 'my_calendar_write_js' );
144
- add_action( "admin_head", 'my_calendar_add_styles' );
145
- // Note only admin can change calendar options
146
- add_submenu_page('my-calendar', __('Manage Categories','my-calendar'), __('Manage Categories','my-calendar'), 'manage_options', 'my-calendar-categories', 'my_calendar_manage_categories');
147
- add_submenu_page('my-calendar', __('Manage Locations','my-calendar'), __('Manage Locations','my-calendar'), 'manage_options', 'my-calendar-locations', 'my_calendar_manage_locations');
148
- add_submenu_page('my-calendar', __('Settings','my-calendar'), __('Settings','my-calendar'), 'manage_options', 'my-calendar-config', 'edit_my_calendar_config');
149
- add_submenu_page('my-calendar', __('Style Editor','my-calendar'), __('Style Editor','my-calendar'), 'manage_options', 'my-calendar-styles', 'edit_my_calendar_styles');
150
- add_submenu_page('my-calendar', __('My Calendar Help','my-calendar'), __('Help','my-calendar'), 'manage_options', 'my-calendar-help', 'my_calendar_help');
151
- }
152
- }
153
- add_action( "admin_menu", 'my_calendar_add_javascript' );
154
-
155
- // Function to add the javascript to the admin header
156
- function my_calendar_add_javascript() {
157
- if ($_GET['page'] == 'my-calendar') {
158
- wp_enqueue_script('jquery-ui-datepicker',WP_PLUGIN_URL . '/my-calendar/js/ui.datepicker.js', array('jquery','jquery-ui-core') );
159
- }
160
- if ($_GET['page'] == 'my-calendar-categories') {
161
- wp_enqueue_script('jquery-colorpicker',WP_PLUGIN_URL . '/my-calendar/js/jquery-colorpicker.js', array('jquery') );
162
- }
163
- }
164
- function my_calendar_write_js() {
165
- if ($_GET['page']=='my-calendar') {
166
- echo '
167
- <script type="text/javascript">
168
- //<![CDATA[
169
- jQuery(document).ready(function($) {
170
- $("#event_begin").datepicker({
171
- numberOfMonths: 2,
172
- dateFormat: "yy-mm-dd"
173
- });
174
- $("#event_end").datepicker({
175
- numberOfMonths: 2,
176
- dateFormat: "yy-mm-dd"
177
- });
178
- });
179
- //]]>
180
- </script>
181
- ';
182
- }
183
- if ($_GET['page']=='my-calendar-categories') {
184
- /*
185
- <script type=\"text/javascript\">
186
- //<![CDATA[
187
- //jQuery(document).ready(function($) {
188
- //$('#category_color').colorpicker({ flat: true });
189
- //]]>
190
- */
191
- }
192
- }
193
- function my_calendar_add_display_javascript() {
194
- wp_enqueue_script('jquery');
195
- }
196
- add_action('init','my_calendar_add_display_javascript');
197
-
198
- function my_calendar_calendar_javascript() {
199
- $list_js = stripcslashes( get_option( 'my_calendar_listjs' ) );
200
- $cal_js = stripcslashes( get_option( 'my_calendar_caljs' ) );
201
-
202
- if ( get_option('calendar_javascript') != 1 || get_option('list_javascript') != 1 ) {
203
- //echo '<script type="text/javascript">
204
- //var $j = jQuery.noConflict();
205
- //$j(\'html\').addClass(\'js\');
206
- //</script>';
207
- }
208
-
209
- if ( get_option('calendar_javascript') != 1 ) {
210
- ?>
211
- <script type='text/javascript'>
212
- <?php echo $cal_js; ?>
213
- </script>
214
- <?php
215
- }
216
- if ( get_option('list_javascript') != 1 ) {
217
- ?>
218
- <script type='text/javascript'>
219
- <?php echo $list_js; ?>
220
- </script>
221
- <?php
222
- }
223
- }
224
- add_action('wp_head','my_calendar_calendar_javascript');
225
-
226
- function my_calendar_add_styles() {
227
- ?>
228
- <link type="text/css" rel="stylesheet" href="<?php echo WP_PLUGIN_URL; ?>/my-calendar/js/ui.datepicker.css" />
229
- <?php
230
- echo '
231
- <style type="text/css">
232
- <!--
233
- .jd-my-calendar {
234
- margin-right: 150px!important;
235
- }
236
- #my-calendar legend {
237
- font-weight: 700;
238
- font-size: 1em;
239
- }
240
- .resources {
241
- float: right;
242
- border: 1px solid #aaa;
243
- padding: 10px 10px 0;
244
- margin-left: 10px;
245
- -moz-border-radius: 5px;
246
- -webkit-border-radius: 5px;
247
- border-radius: 5px;
248
- background: #fff;
249
- text-align: center;
250
- }
251
- .resources form {
252
- margin: 0!important;
253
- }
254
- #category_icon option {
255
- padding: 5px 0 5px 24px;
256
- }
257
- #my-calendar-admin-table .delete {
258
- background: #a00;
259
- color: #fff;
260
- padding: 2px 8px;
261
- font-size: .8em;
262
- border: 1px solid #fff;
263
- -moz-border-radius: 8px;
264
- -webkit-border-radius: 8px;
265
- border-radius: 8px;
266
- text-decoration: none;
267
- }
268
- #my-calendar-admin-table .delete:hover, #my-calendar-admin-table .delete:focus {
269
- border: 1px solid #999;
270
- background: #b11;
271
- }
272
- .import {
273
- background: #ffa;
274
- padding: 5px 10px;
275
- border: 1px solid #aaa;
276
- -moz-border-radius: 5px;
277
- -webkit-border-radius: 5px;
278
- border-radius: 5px;
279
- margin: 15px 0;
280
- }
281
- .n4 {width: 32px;}
282
- .n5 {width: 32px;}
283
- .n6 {width: 64px;}
284
- .n7 {width: 128px;}
285
- .n8 {width: 256px;}
286
- .category-color {
287
- width: 1.2em;
288
- height: 1.2em;
289
- display: inline-block;
290
- -moz-border-radius: 3px;
291
- -webkit-border-radius: 3px;
292
- border-radius: 3px;
293
- border: 1px solid #000;
294
- }
295
- //-->
296
- </style>';
297
- }
298
-
299
- function my_calendar_insert($atts) {
300
- extract(shortcode_atts(array(
301
- 'name' => 'all',
302
- 'format' => 'calendar',
303
- 'category' => 'all',
304
- 'showkey' => 'yes',
305
- ), $atts));
306
- return my_calendar($name,$format,$category,$showkey);
307
- }
308
-
309
- function my_calendar_insert_upcoming($atts) {
310
- extract(shortcode_atts(array(
311
- 'before' => 'default',
312
- 'after' => 'default',
313
- 'type' => 'default',
314
- 'category' => 'default',
315
- 'template' => 'default'
316
- ), $atts));
317
- return my_calendar_upcoming_events($before, $after, $type, $category, $template);
318
- }
319
-
320
- function my_calendar_insert_today($atts) {
321
- extract(shortcode_atts(array(
322
- 'category' => 'default',
323
- 'template' => 'default'
324
- ), $atts));
325
- return my_calendar_todays_events($category, $template);
326
- }
327
-
328
-
329
- // add shortcode interpreter
330
- add_shortcode('my_calendar','my_calendar_insert');
331
- add_shortcode('my_calendar_upcoming','my_calendar_insert_upcoming');
332
- add_shortcode('my_calendar_today','my_calendar_insert_today');
333
-
334
- // Function to check what version of My Calendar is installed and install if needed
335
- function check_my_calendar() {
336
- // Checks to make sure My Calendar is installed, if not it adds the default
337
- // database tables and populates them with test data. If it is, then the
338
- // version is checked through various means and if it is not up to date
339
- // then it is upgraded. (Or will be, once there's a need.)
340
-
341
- // Lets see if this is first run and create a table if it is!
342
- global $wpdb, $initial_style, $initial_listjs, $initial_caljs;
343
-
344
- // defaults will go into the options table on a new install
345
- $initial_listjs = 'var $j = jQuery.noConflict();
346
-
347
- $j(document).ready(function() {
348
- $j("#calendar-list li").children().not(".event-date").hide();
349
- $j("#calendar-list li.current-day").children().show();
350
- $j(".event-date").toggle(
351
- function() {
352
- $j("#calendar-list li").children().not(".event-date").hide();
353
- $j(this).parent().children().not(".event-date").show("fast");
354
- },
355
- function() {
356
- $j("#calendar-list li").children().not(".event-date").hide("fast");
357
- }
358
- );
359
- });';
360
-
361
- $initial_caljs = 'var $j = jQuery.noConflict();
362
-
363
- $j(document).ready(function() {
364
- $j(".calendar-event").children().not("h3").hide();
365
- $j(".calendar-event h3").toggle(
366
- function() {
367
- $j(".calendar-event").children().not("h3").hide();
368
- $j(this).parent().children().not("h3").show("fast");
369
- },
370
- function() {
371
- $j(".calendar-event").children().not("h3").hide("fast");
372
- }
373
- );
374
- });';
375
-
376
- $initial_style = "
377
- #jd-calendar * {
378
- margin: 0;
379
- padding: 0;
380
- line-height: 1.5;
381
- color: #000;
382
- background: #fff;
383
- }
384
- #jd-calendar caption, #jd-calendar .my-calendar-date-switcher {
385
- background: #edf7ff;
386
- border: 1px solid #a9e3ff;
387
- margin: 2px 0;
388
- font-weight:700;
389
- padding:2px 0;
390
- }
391
-
392
- #jd-calendar table {
393
- width:100%;
394
- line-height:1.2;
395
- border-collapse:collapse;
396
- }
397
-
398
- #jd-calendar td {
399
- vertical-align:top;
400
- border:1px solid #eee;
401
- text-align:left;
402
- width:13%;
403
- height:70px;
404
- padding:2px!important;
405
- }
406
- #jd-calendar th {
407
- text-align: center;
408
- padding: 5px 0!important;
409
- letter-spacing: 1px;
410
- }
411
- #jd-calendar th abbr {
412
- border-bottom: none;
413
- }
414
- #jd-calendar h3 {
415
- font-size:.9em;
416
- font-family: Arial, Verdana, sans-serif;
417
- font-weight:700;
418
- margin:3px 0;
419
- padding:0;
420
- width: 100%;
421
- }
422
- #jd-calendar h3 img {
423
- vertical-align: bottom;
424
- margin: 0 3px 0 0!important;
425
- }
426
- #jd-calendar #calendar-list h3 img {
427
- vertical-align: middle;
428
- }
429
-
430
- #jd-calendar .list-event h3 {
431
- font-size:1.2em;
432
- margin:0;
433
- }
434
- #jd-calendar .calendar-event .details {
435
- position:absolute;
436
- width:50%;
437
- background: #edf7ff;
438
- color:#000;
439
- border:1px solid #9b5;
440
- -moz-border-radius:10px;
441
- -moz-box-shadow:3px 3px 6px #777;
442
- -webkit-box-shadow:3px 3px 6px #777;
443
- box-shadow:3px 3px 6px #777;
444
- padding:5px;
445
- z-index: 3;
446
- }
447
-
448
- #jd-calendar .list-event .details {
449
- background:#fafafa;
450
- border:1px solid #eee;
451
- -moz-border-radius:5px;
452
- -webkit-border-radius:5px;
453
- border-radius:5px;
454
- margin:5px 0;
455
- padding:5px 5px 0;
456
- color: #333;
457
- }
458
- #jd-calendar #calendar-list {
459
- margin: 0;
460
- padding: 0;
461
- }
462
- #jd-calendar #calendar-list li {
463
- padding:5px;
464
- list-style-type: none;
465
- margin: 0;
466
- }
467
-
468
- #jd-calendar #calendar-list .odd {
469
- background:#d3e3e3;
470
- }
471
-
472
- #jd-calendar .odd .list-event .details {
473
- background:#e3f3f3;
474
- border:1px solid #c3d3d3;
475
- }
476
-
477
- #jd-calendar .current-day {
478
- background:#ffb;
479
- }
480
- #jd-calendar .current-day span {
481
- color: #000;
482
- background: #eee;
483