My Calendar - Version 2.5.10

Version Description

  • Bug fix: allow parsing of non-English strings through strtotime()
  • Bug fix: trim whitespace off array keys in location controller
  • Bug fix: Don't display 'Add Event' menu in adminbar if remote event database is enabled
  • Bug fix: All day events correctly exported in iCal files
  • Bug fix: Footer navigation not shown on single day view
  • Bug fix: Execute AJAX navigation from both header and footer containers
  • Bug fix: {icon_html} returned broken image if category had no assigned icon
  • Removed obsolete PHP 4 compatibility for clone keyword
  • Added hook to prevent activation if PHP version below 5.3.0.
  • New filter: define custom target calendar URL via 'mc_get_uri' filter
  • New action: 'mc_insert_recurring' run while creating event instances
  • New filter to customize default event length: 'mc_default_event_length'
  • New filter: 'mc_show_week_number' to turn on column indicating displayed week's number. (props Josef Fllman)
  • UI Change: Duplicate navigation and search on events list at bottom of list
  • Miscellaneous improvements to the My Calendar Filters shortcode: set target URL & change location search type, add as widget
  • New widget: My Calendar event filters
  • Added inverse color style declaration to category color template tag
Download this release

Release Info

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

Code changes from version 2.5.9 to 2.5.10

css/mc-styles.css CHANGED
@@ -63,6 +63,10 @@ ul.links li {
63
  line-height: 1.4;
64
  }
65
 
 
 
 
 
66
  #toggle {
67
  height: 2em
68
  }
@@ -681,6 +685,10 @@ tr.problem .error {
681
  clear: both;
682
  }
683
 
 
 
 
 
684
  @media (max-width: 1140px) {
685
  .mc-locations .locations-container input {
686
  max-width: 70%;
63
  line-height: 1.4;
64
  }
65
 
66
+ #my-calendar-admin-table {
67
+ margin-bottom: 1em;
68
+ }
69
+
70
  #toggle {
71
  height: 2em
72
  }
685
  clear: both;
686
  }
687
 
688
+ .event-actions {
689
+ clear: both;
690
+ }
691
+
692
  @media (max-width: 1140px) {
693
  .mc-locations .locations-container input {
694
  max-width: 70%;
js/jquery.public.js DELETED
@@ -1,19 +0,0 @@
1
- (function ($) {
2
- $(function () {
3
- // Delete single instances of recurring events.
4
- $( '.mc_response' ).hide();
5
- $('button.delete_occurrence').on( 'click', function () {
6
- var value = $(this).attr( 'data-value' );
7
- var data = {
8
- 'action': mc_data.action,
9
- 'occur_id': value,
10
- 'security': mc_data.security
11
- };
12
- $.post( ajaxurl, data, function (response) {
13
- if ( response.success == 1 ) {
14
- $( "button[data-value='"+value+"']" ).parent( 'li' ).hide();
15
- }
16
- $('.mc_response').text( response.response ).show( 300 );
17
- }, "json" );
18
- });
19
- }(jQuery));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/mc-ajax.js CHANGED
@@ -1,7 +1,7 @@
1
  (function ($) {
2
  'use strict';
3
  $(function () {
4
- $(document).on('click', '.my-calendar-header a.mcajax', function (e) {
5
  var calendar = $( this ).closest( '.mc-main' );
6
  var ref = calendar.attr('id');
7
  e.preventDefault();
1
  (function ($) {
2
  'use strict';
3
  $(function () {
4
+ $(document).on('click', ".my-calendar-header a.mcajax, .my-calendar-footer a.mcajax", function (e) {
5
  var calendar = $( this ).closest( '.mc-main' );
6
  var ref = calendar.attr('id');
7
  e.preventDefault();
my-calendar-core.php CHANGED
@@ -25,12 +25,12 @@ if ( ! function_exists( 'is_ssl' ) ) {
25
  }
26
  }
27
 
28
- function my_calendar_getUsers() {
29
- return mc_get_users();
30
  }
31
 
32
  // mod from Mike T
33
- function mc_get_users() {
34
  global $blog_id;
35
  $count = count_users( 'time' );
36
  $args = array(
@@ -38,15 +38,15 @@ function mc_get_users() {
38
  'orderby' => 'display_name',
39
  'fields' => array( 'ID', 'user_nicename', 'display_name' )
40
  );
41
- $args = apply_filters( 'mc_filter_user_arguments', $args, $count );
42
  $users = new WP_User_Query( $args );
43
 
44
  return $users->get_results();
45
  }
46
 
47
- function mc_selected_users( $selected ) {
48
  $selected = explode( ',', $selected );
49
- $users = mc_get_users();
50
  $options = '';
51
  foreach ( $users as $u ) {
52
  if ( in_array( $u->ID, $selected ) ) {
@@ -427,7 +427,7 @@ function mc_get_current_url() {
427
  $current_url = home_url( add_query_arg( $args, $wp->request ) );
428
 
429
  if ( $wp_rewrite->using_index_permalinks() && strpos( $current_url, 'index.php' ) === false ) {
430
- $current_url = str_replace( home_url(), home_url( '/' ) . 'index.php', $home );
431
  }
432
  if ( $wp_rewrite->using_permalinks() ) {
433
  $current_url = trailingslashit( $current_url );
@@ -1005,19 +1005,10 @@ function jd_option_selected( $field, $value, $type = 'checkbox' ) {
1005
  return $output;
1006
  }
1007
 
1008
- // compatibility of clone keyword between PHP 5 and 4
1009
- if ( version_compare( phpversion(), '5.0' ) < 0 ) {
1010
- eval( '
1011
- function clone($object) {
1012
- return $object;
1013
- }
1014
- ' );
1015
- }
1016
-
1017
  add_action( 'admin_bar_menu', 'my_calendar_admin_bar', 200 );
1018
  function my_calendar_admin_bar() {
1019
  global $wp_admin_bar;
1020
- if ( current_user_can( 'mc_add_events' ) ) {
1021
  $url = apply_filters( 'mc_add_events_url', admin_url( 'admin.php?page=my-calendar' ) );
1022
  $args = array( 'id' => 'mc-add-event', 'title' => __( 'Add Event', 'my-calendar' ), 'href' => $url );
1023
  $wp_admin_bar->add_node( $args );
@@ -1709,7 +1700,10 @@ function mc_increment_event( $id, $post = array(), $test = false ) {
1709
  $return[] = $data;
1710
  }
1711
  if ( ! $test ) {
1712
- $wpdb->insert( my_calendar_event_table(), $data, $format );
 
 
 
1713
  }
1714
  } else {
1715
  $numforward ++;
@@ -1733,7 +1727,10 @@ function mc_increment_event( $id, $post = array(), $test = false ) {
1733
  $return[] = $data;
1734
  }
1735
  if ( ! $test ) {
1736
- $sql = $wpdb->insert( my_calendar_event_table(), $data, $format );
 
 
 
1737
  }
1738
  }
1739
  break;
@@ -1754,7 +1751,10 @@ function mc_increment_event( $id, $post = array(), $test = false ) {
1754
  $return[] = $data;
1755
  }
1756
  if ( ! $test ) {
1757
- $wpdb->insert( my_calendar_event_table(), $data, $format );
 
 
 
1758
  }
1759
  }
1760
  break;
@@ -1775,7 +1775,10 @@ function mc_increment_event( $id, $post = array(), $test = false ) {
1775
  $return[] = $data;
1776
  }
1777
  if ( ! $test ) {
1778
- $wpdb->insert( my_calendar_event_table(), $data, $format );
 
 
 
1779
  }
1780
  }
1781
  break;
@@ -1793,7 +1796,10 @@ function mc_increment_event( $id, $post = array(), $test = false ) {
1793
  );
1794
 
1795
  if ( ! $test ) {
1796
- $wpdb->insert( my_calendar_event_table(), $data, $format );
 
 
 
1797
  }
1798
  $numforward = $numforward - 1;
1799
  for ( $i = 0; $i <= $numforward; $i ++ ) {
@@ -1822,7 +1828,10 @@ function mc_increment_event( $id, $post = array(), $test = false ) {
1822
  return $data;
1823
  }
1824
  if ( ! $test ) {
1825
- $wpdb->insert( my_calendar_event_table(), $data, $format );
 
 
 
1826
  }
1827
  $newbegin = my_calendar_add_date( date( 'Y-m-d H:i:s', $newbegin ), 28, 0, 0 );
1828
  $newend = my_calendar_add_date( date( 'Y-m-d H:i:s', $newend ), 28, 0, 0 );
@@ -1845,7 +1854,10 @@ function mc_increment_event( $id, $post = array(), $test = false ) {
1845
  $return[] = $data;
1846
  }
1847
  if ( ! $test ) {
1848
- $wpdb->insert( my_calendar_event_table(), $data, $format );
 
 
 
1849
  }
1850
  }
1851
  break;
@@ -1861,7 +1873,10 @@ function mc_increment_event( $id, $post = array(), $test = false ) {
1861
  'occur_group_id' => $group_id
1862
  );
1863
  if ( ! $test ) {
1864
- $wpdb->insert( my_calendar_event_table(), $data, $format );
 
 
 
1865
  }
1866
  }
1867
 
@@ -1872,39 +1887,6 @@ function mc_increment_event( $id, $post = array(), $test = false ) {
1872
  return $data;
1873
  }
1874
 
1875
- function mc_get_details_link( $event ) {
1876
- if ( is_numeric( $event ) ) {
1877
- $event = mc_get_event( $event );
1878
- }
1879
- // if available, and not querying remotely, use permalink.
1880
- $permalinks = apply_filters( 'mc_use_permalinks', get_option( 'mc_use_permalinks' ) );
1881
- $permalinks = ( $permalinks === 1 || $permalinks === true || $permalinks === 'true' ) ? true : false;
1882
- $details_link = mc_event_link( $event );
1883
- if ( $event->event_post != 0 && get_option( 'mc_remote' ) != 'true' && $permalinks ) {
1884
- $details_link = add_query_arg( 'mc_id', $event->occur_id, get_permalink( $event->event_post ) );
1885
- } else {
1886
- if ( get_option( 'mc_uri' ) != '' && _mc_is_url( get_option( 'mc_uri' ) ) ) {
1887
- $details_link = mc_build_url( array( 'mc_id' => $event->occur_id ), array(
1888
- 'month',
1889
- 'dy',
1890
- 'yr',
1891
- 'ltype',
1892
- 'loc',
1893
- 'mcat',
1894
- 'format',
1895
- 'feed',
1896
- 'page_id',
1897
- 'p',
1898
- 'mcs',
1899
- 'time',
1900
- 'page'
1901
- ), get_option( 'mc_uri' ) );
1902
- }
1903
- }
1904
-
1905
- return apply_filters( 'mc_customize_details_link', $details_link, $event );
1906
- }
1907
-
1908
  // Actions -- these are action hooks attached to My Calendar events, usable to add additional actions during those events.
1909
  add_action( 'init', 'mc_register_actions' );
1910
  function mc_register_actions() {
25
  }
26
  }
27
 
28
+ function my_calendar_getUsers( $group = 'authors' ) {
29
+ return mc_get_users( $group );
30
  }
31
 
32
  // mod from Mike T
33
+ function mc_get_users( $group = 'authors' ) {
34
  global $blog_id;
35
  $count = count_users( 'time' );
36
  $args = array(
38
  'orderby' => 'display_name',
39
  'fields' => array( 'ID', 'user_nicename', 'display_name' )
40
  );
41
+ $args = apply_filters( 'mc_filter_user_arguments', $args, $count, $group );
42
  $users = new WP_User_Query( $args );
43
 
44
  return $users->get_results();
45
  }
46
 
47
+ function mc_selected_users( $selected = '', $group = 'authors' ) {
48
  $selected = explode( ',', $selected );
49
+ $users = mc_get_users( $group );
50
  $options = '';
51
  foreach ( $users as $u ) {
52
  if ( in_array( $u->ID, $selected ) ) {
427
  $current_url = home_url( add_query_arg( $args, $wp->request ) );
428
 
429
  if ( $wp_rewrite->using_index_permalinks() && strpos( $current_url, 'index.php' ) === false ) {
430
+ $current_url = str_replace( home_url(), home_url( '/' ) . 'index.php', $current_url );
431
  }
432
  if ( $wp_rewrite->using_permalinks() ) {
433
  $current_url = trailingslashit( $current_url );
1005
  return $output;
1006
  }
1007
 
 
 
 
 
 
 
 
 
 
1008
  add_action( 'admin_bar_menu', 'my_calendar_admin_bar', 200 );
1009
  function my_calendar_admin_bar() {
1010
  global $wp_admin_bar;
1011
+ if ( current_user_can( 'mc_add_events' ) && get_option( 'mc_remote' ) != 'true' ) {
1012
  $url = apply_filters( 'mc_add_events_url', admin_url( 'admin.php?page=my-calendar' ) );
1013
  $args = array( 'id' => 'mc-add-event', 'title' => __( 'Add Event', 'my-calendar' ), 'href' => $url );
1014
  $wp_admin_bar->add_node( $args );
1700
  $return[] = $data;
1701
  }
1702
  if ( ! $test ) {
1703
+ $insert = apply_filters( 'mc_insert_recurring', false, $data, $format, $id, 'daily' );
1704
+ if ( ! $insert ) {
1705
+ $wpdb->insert( my_calendar_event_table(), $data, $format );
1706
+ }
1707
  }
1708
  } else {
1709
  $numforward ++;
1727
  $return[] = $data;
1728
  }
1729
  if ( ! $test ) {
1730
+ $insert = apply_filters( 'mc_insert_recurring', false, $data, $format, $id, 'weekly' );
1731
+ if ( ! $insert ) {
1732
+ $sql = $wpdb->insert( my_calendar_event_table(), $data, $format );
1733
+ }
1734
  }
1735
  }
1736
  break;
1751
  $return[] = $data;
1752
  }
1753
  if ( ! $test ) {
1754
+ $insert = apply_filters( 'mc_insert_recurring', false, $data, $format, $id, 'biweekly' );
1755
+ if ( ! $insert ) {
1756
+ $wpdb->insert( my_calendar_event_table(), $data, $format );
1757
+ }
1758
  }
1759
  }
1760
  break;
1775
  $return[] = $data;
1776
  }
1777
  if ( ! $test ) {
1778
+ $insert = apply_filters( 'mc_insert_recurring', false, $data, $format, $id, 'monthly' );
1779
+ if ( ! $insert ) {
1780
+ $wpdb->insert( my_calendar_event_table(), $data, $format );
1781
+ }
1782
  }
1783
  }
1784
  break;
1796
  );
1797
 
1798
  if ( ! $test ) {
1799
+ $insert = apply_filters( 'mc_insert_recurring', false, $data, $format, $id, 'month-by-day' );
1800
+ if ( ! $insert ) {
1801
+ $wpdb->insert( my_calendar_event_table(), $data, $format );
1802
+ }
1803
  }
1804
  $numforward = $numforward - 1;
1805
  for ( $i = 0; $i <= $numforward; $i ++ ) {
1828
  return $data;
1829
  }
1830
  if ( ! $test ) {
1831
+ $insert = apply_filters( 'mc_insert_recurring', false, $data, $format, $id, 'month-by-day' );
1832
+ if ( ! $insert ) {
1833
+ $wpdb->insert( my_calendar_event_table(), $data, $format );
1834
+ }
1835
  }
1836
  $newbegin = my_calendar_add_date( date( 'Y-m-d H:i:s', $newbegin ), 28, 0, 0 );
1837
  $newend = my_calendar_add_date( date( 'Y-m-d H:i:s', $newend ), 28, 0, 0 );
1854
  $return[] = $data;
1855
  }
1856
  if ( ! $test ) {
1857
+ $insert = apply_filters( 'mc_insert_recurring', false, $data, $format, $id, 'annual' );
1858
+ if ( ! $insert ) {
1859
+ $wpdb->insert( my_calendar_event_table(), $data, $format );
1860
+ }
1861
  }
1862
  }
1863
  break;
1873
  'occur_group_id' => $group_id
1874
  );
1875
  if ( ! $test ) {
1876
+ $insert = apply_filters( 'mc_insert_recurring', false, $data, $format, $id, 'single' );
1877
+ if ( ! $insert ) {
1878
+ $wpdb->insert( my_calendar_event_table(), $data, $format );
1879
+ }
1880
  }
1881
  }
1882
 
1887
  return $data;
1888
  }
1889
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1890
  // Actions -- these are action hooks attached to My Calendar events, usable to add additional actions during those events.
1891
  add_action( 'init', 'mc_register_actions' );
1892
  function mc_register_actions() {
my-calendar-event-manager.php CHANGED
@@ -162,7 +162,7 @@ function manage_my_calendar() {
162
  $event_instance = (int) $_GET['date'];
163
  $sql = "SELECT occur_begin FROM " . my_calendar_event_table() . " WHERE occur_id=" . $event_instance;
164
  $inst = $mcdb->get_var( $sql );
165
- $instance_date = '(' . date( 'Y-m-d', strtotime( $inst ) ) . ')';
166
  } else {
167
  $instance_date = '';
168
  } ?>
@@ -577,12 +577,16 @@ function my_calendar_save( $action, $output, $event_id = false ) {
577
  if ( mc_can_edit_event( $event_id ) ) {
578
  $update = $output[2];
579
  $update = apply_filters( 'mc_before_save_update', $update, $event_id );
580
- $endtime = date( "H:i:00", strtotime( $update['event_endtime'] ) );
 
 
 
 
581
  $date_changed = (
582
- $update['event_begin'] != $_POST['prev_event_begin'] ||
583
- date( "H:i:00", strtotime( $update['event_time'] ) ) != $_POST['prev_event_time'] ||
584
- $update['event_end'] != $_POST['prev_event_end'] ||
585
- ( $endtime != $_POST['prev_event_endtime'] && ( $_POST['prev_event_endtime'] != '' && $endtime != '23:59:59' ) ) )
586
  ? true : false;
587
  if ( isset( $_POST['event_instance'] ) ) {
588
  // compares the information sent to the information saved for a given event.
@@ -621,11 +625,13 @@ function my_calendar_save( $action, $output, $event_id = false ) {
621
  $update,
622
  array( 'event_id' => $event_id ),
623
  $formats,
624
- '%d' );
 
625
  $recur_changed = ( $update['event_repeats'] != $_POST['prev_event_repeats'] || $update['event_recur'] != $_POST['prev_event_recur'] ) ? true : false;
626
  if ( $date_changed || $recur_changed ) {
627
  // TODO: if date or recur changed, do generation of new instances, then iterate over existing occurrences
628
  // to update & delete remaining
 
629
  mc_delete_instances( $event_id );
630
  mc_increment_event( $event_id );
631
  mc_delete_cache();
@@ -793,19 +799,8 @@ function mc_show_block( $field, $has_data, $data, $echo = true, $default = '' )
793
  switch ( $field ) {
794
  case 'event_host' :
795
  if ( $show_block ) {
796
- $users = mc_get_users();
797
- $select = '';
798
- foreach ( $users as $u ) {
799
- $display_name = ( $u->display_name == '' ) ? $u->user_nicename : $u->display_name;
800
- if ( is_object( $data ) && $data->event_host == $u->ID ) {
801
- $selected = ' selected="selected"';
802
- } else if ( is_object( $u ) && $u->ID == $user_ID && empty( $data->event_host ) ) {
803
- $selected = ' selected="selected"';
804
- } else {
805
- $selected = '';
806
- }
807
- $select .= "<option value='$u->ID'$selected>$display_name</option>\n";
808
- }
809
  $return = '
810
  <p>
811
  <label for="e_host">' . __( 'Host', 'my-calendar' ) . '</label>
@@ -817,12 +812,8 @@ function mc_show_block( $field, $has_data, $data, $echo = true, $default = '' )
817
  break;
818
  case 'event_author' :
819
  if ( $show_block && is_object( $data ) && $data->event_author === '0' ) {
820
- $users = mc_get_users();
821
- $select = '';
822
- foreach ( $users as $u ) {
823
- $display_name = ( $u->display_name == '' ) ? $u->user_nicename : $u->display_name;
824
- $select .= "<option value='$u->ID'>$display_name</option>\n";
825
- }
826
  $return = '
827
  <p>
828
  <label for="e_author">' . __( 'Author', 'my-calendar' ) . '</label>
@@ -1171,7 +1162,7 @@ function mc_form_fields( $data, $mode, $event_id ) {
1171
  <?php
1172
  if ( ! empty( $_GET['date'] ) && $data->event_recur != 'S' ) {
1173
  $event = mc_get_event( $instance );
1174
- $date = date_i18n( get_option( 'mc_date_format' ), strtotime( $event->occur_begin ) );
1175
  $message = __( "You are editing the <strong>$date</strong> instance of this event. Other instances of this event will not be changed.", 'my-calendar' );
1176
  echo "<div class='message updated'><p>$message</p></div>";
1177
  } else if ( isset( $_GET['date'] ) && empty( $_GET['date'] ) ) {
@@ -1658,6 +1649,7 @@ function mc_list_events() {
1658
 
1659
  $found_rows = $wpdb->get_col( "SELECT FOUND_ROWS();" );
1660
  $items = $found_rows[0];
 
1661
  if ( ( function_exists( 'akismet_http_post' ) || function_exists( 'bs_checker' ) ) && $allow_filters ) {
1662
  ?>
1663
  <ul class="links">
@@ -1859,13 +1851,13 @@ function mc_list_events() {
1859
  <?php if ( $event->event_label != '' ) { ?><a class='mc_filter' href='<?php $elabel = urlencode( $event->event_label ); echo admin_url( "admin.php?page=my-calendar-manage&amp;filter=$elabel&amp;restrict=where" ); ?>' title="<?php _e( 'Filter by location', 'my-calendar' ); ?>"><span class="screen-reader-text"><?php _e( 'Show only: ', 'my-calendar' ); ?></span><?php echo strip_tags( stripslashes( $event->event_label ) ); ?></a><?php } ?>
1860
  </td>
1861
  <?php if ( $event->event_endtime != "23:59:59" ) {
1862
- $eventTime = date_i18n( get_option( 'mc_time_format' ), strtotime( $event->event_time ) );
1863
  } else {
1864
  $eventTime = mc_notime_label( $event );
1865
  } ?>
1866
  <td><?php
1867
  $date_format = ( get_option( 'mc_date_format' ) == '' ) ? get_option( 'date_format' ) : get_option( 'mc_date_format' );
1868
- $begin = date_i18n( $date_format, strtotime( $event->event_begin ) );
1869
  echo "$begin, $eventTime"; ?>
1870
  <div class="recurs">
1871
  <strong><?php _e( 'Recurs', 'my-calendar' ); ?></strong>
@@ -1942,7 +1934,70 @@ function mc_list_events() {
1942
  }
1943
  ?>
1944
  </table>
1945
- <p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1946
  <input type="submit" class="button-secondary delete" name="mass_delete" value="<?php _e( 'Delete events', 'my-calendar' ); ?>"/>
1947
  <?php if ( current_user_can( 'mc_approve_events' ) ) { ?>
1948
  <input type="submit" class="button-secondary mc-approve" name="mass_approve" value="<?php _e( 'Approve events', 'my-calendar' ); ?>"/>
@@ -1992,15 +2047,15 @@ function mc_check_data( $action, $post, $i ) {
1992
  // ...AND there's no reason to allow it, since weekday events will NEVER happen on the weekend.
1993
  $begin = trim( $post['event_begin'][ $i ] );
1994
  $end = ( ! empty( $post['event_end'] ) ) ? trim( $post['event_end'][ $i ] ) : $post['event_begin'][ $i ];
1995
- if ( $recur == 'E' && ( date( 'w', strtotime( $begin ) ) == 0 || date( 'w', strtotime( $begin ) ) == 6 ) ) {
1996
- if ( date( 'w', strtotime( $begin ) ) == 0 ) {
1997
  $newbegin = my_calendar_add_date( $begin, 1 );
1998
  if ( ! empty( $post['event_end'][ $i ] ) ) {
1999
  $newend = my_calendar_add_date( $end, 1 );
2000
  } else {
2001
  $newend = $newbegin;
2002
  }
2003
- } else if ( date( 'w', strtotime( $begin ) ) == 6 ) {
2004
  $newbegin = my_calendar_add_date( $begin, 2 );
2005
  if ( ! empty( $post['event_end'][ $i ] ) ) {
2006
  $newend = my_calendar_add_date( $end, 2 );
@@ -2015,10 +2070,11 @@ function mc_check_data( $action, $post, $i ) {
2015
  $end = ! empty( $post['event_end'][ $i ] ) ? trim( $post['event_end'][ $i ] ) : $begin;
2016
  }
2017
 
2018
- $begin = date( 'Y-m-d', strtotime( $begin ) );// regardless of entry format, convert.
2019
  $time = ! empty( $post['event_time'][ $i ] ) ? trim( $post['event_time'][ $i ] ) : '';
2020
  if ( $time != '' ) {
2021
- $endtime = ! empty( $post['event_endtime'][ $i ] ) ? trim( $post['event_endtime'][ $i ] ) : date( 'H:i:s', strtotime( $time . ' +1 hour' ) );
 
2022
  } else {
2023
  $endtime = ! empty( $post['event_endtime'][ $i ] ) ? trim( $post['event_endtime'][ $i ] ) : '';
2024
  }
@@ -2026,18 +2082,18 @@ function mc_check_data( $action, $post, $i ) {
2026
  $endtime = ( $endtime == '' && $time == '00:00:00' ) ? '23:59:59' : $endtime; // set at end of night if np
2027
 
2028
  // prevent setting enddate to incorrect value on copy.
2029
- if ( strtotime( $end ) < strtotime( $begin ) && $action == 'copy' ) {
2030
- $end = date( 'Y-m-d', ( strtotime( $begin ) + ( strtotime( $post['prev_event_end'] ) - strtotime( $post['prev_event_begin'] ) ) ) );
2031
  }
2032
  if ( isset( $post['event_allday'] ) && (int) $post['event_allday'] !== 0 ) {
2033
  $time = '00:00:00'; $endtime = '23:59:59';
2034
  }
2035
 
2036
  // verify formats
2037
- $time = date( 'H:i:s', strtotime( $time ) );
2038
- $endtime = date( 'H:i:s', strtotime( $endtime ) );
2039
 
2040
- $end = date( 'Y-m-d', strtotime( $end ) ); // regardless of entry format, convert.
2041
  $repeats = ( isset( $post['event_repeats'] ) ) ? trim( $post['event_repeats'] ) : 0;
2042
  $host = ! empty( $post['event_host'] ) ? $post['event_host'] : $current_user->ID;
2043
 
@@ -2141,7 +2197,7 @@ function mc_check_data( $action, $post, $i ) {
2141
  // Perform validation on the submitted dates - checks for valid years and months
2142
  if ( mc_checkdate( $begin ) && mc_checkdate( $end ) ) {
2143
  // Make sure dates are equal or end date is later than start date
2144
- if ( strtotime( "$end $endtime" ) < strtotime( "$begin $time" ) ) {
2145
  $errors .= "<div class='error'><p><strong>" . __( 'Error', 'my-calendar' ) . ":</strong> " . __( 'Your event end date must be either after or the same as your event begin date', 'my-calendar' ) . "</p></div>";
2146
  }
2147
  } else {
@@ -2149,7 +2205,7 @@ function mc_check_data( $action, $post, $i ) {
2149
  }
2150
 
2151
  // We check for a valid time, or an empty one
2152
- $time = ( $time == '' ) ? '23:59:59' : date( 'H:i:00', strtotime( $time ) );
2153
  $time_format_one = '/^([0-1][0-9]):([0-5][0-9]):([0-5][0-9])$/';
2154
  $time_format_two = '/^([2][0-3]):([0-5][0-9]):([0-5][0-9])$/';
2155
  if ( preg_match( $time_format_one, $time ) || preg_match( $time_format_two, $time ) || $time == '' ) {
@@ -2413,7 +2469,7 @@ function mc_instance_list( $id, $occur = false, $template = '<h3>{title}</h3>{de
2413
  $results = $wpdb->get_results( $sql );
2414
  if ( is_array( $results ) && is_admin() ) {
2415
  foreach ( $results as $result ) {
2416
- $begin = "<span id='occur_date_$result->occur_id'>" . date_i18n( get_option( 'mc_date_format' ), strtotime( $result->occur_begin ) ) . ', ' . date( get_option( 'mc_time_format' ), strtotime( $result->occur_begin ) ) . "</span>";
2417
  if ( $result->occur_id == $occur ) {
2418
  $control = '';
2419
  $edit = "<em>" . __( 'Editing Now', 'my-calendar' ) . "</em>";
@@ -2480,14 +2536,14 @@ function mc_standard_datetime_input( $form, $has_data, $data, $instance, $contex
2480
  $event_end = esc_attr( $data->event_end );
2481
  if ( isset( $_GET['date'] ) ) {
2482
  $event = mc_get_event( (int) $_GET['date'] );
2483
- $event_begin = date( 'Y-m-d', strtotime( $event->occur_begin ) );
2484
- $event_end = date( 'Y-m-d', strtotime( $event->occur_end ) );
2485
  if ( $event_begin == $event_end ) {
2486
  $event_end = '';
2487
  };
2488
  }
2489
- $starttime = ( mc_is_all_day( $data ) ) ? '' : date( "h:i A", strtotime( $data->event_time ) );
2490
- $endtime = ( mc_is_all_day( $data ) ) ? '' : date( "h:i A", strtotime( $data->event_endtime ) );
2491
  } else {
2492
  $event_begin = date( "Y-m-d" );
2493
  $event_end = $starttime = $endtime = '';
@@ -2585,3 +2641,64 @@ function mc_post_update_event( $id ) {
2585
  mc_update_data( $event_id, 'event_image', $featured_image, '%s' );
2586
  }
2587
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  $event_instance = (int) $_GET['date'];
163
  $sql = "SELECT occur_begin FROM " . my_calendar_event_table() . " WHERE occur_id=" . $event_instance;
164
  $inst = $mcdb->get_var( $sql );
165
+ $instance_date = '(' . date( 'Y-m-d', mc_strtotime( $inst ) ) . ')';
166
  } else {
167
  $instance_date = '';
168
  } ?>
577
  if ( mc_can_edit_event( $event_id ) ) {
578
  $update = $output[2];
579
  $update = apply_filters( 'mc_before_save_update', $update, $event_id );
580
+ $endtime = date( "H:i:00", mc_strtotime( $update['event_endtime'] ) );
581
+ $prev_eb = ( isset( $_POST['prev_event_begin'] ) ) ? $_POST['prev_event_begin'] : '';
582
+ $prev_et = ( isset( $_POST['prev_event_time'] ) ) ? $_POST['prev_event_time'] : '';
583
+ $prev_ee = ( isset( $_POST['prev_event_end'] ) ) ? $_POST['prev_event_end'] : '';
584
+ $prev_eet = ( isset( $_POST['prev_event_endtime'] ) ) ? $_POST['prev_event_endtime'] : '';
585
  $date_changed = (
586
+ $update['event_begin'] != $prev_eb ||
587
+ date( "H:i:00", mc_strtotime( $update['event_time'] ) ) != $prev_et ||
588
+ $update['event_end'] != $prev_ee ||
589
+ ( $endtime != $prev_eet && ( $prev_eet != '' && $endtime != '23:59:59' ) ) )
590
  ? true : false;
591
  if ( isset( $_POST['event_instance'] ) ) {
592
  // compares the information sent to the information saved for a given event.
625
  $update,
626
  array( 'event_id' => $event_id ),
627
  $formats,
628
+ '%d' );
629
+
630
  $recur_changed = ( $update['event_repeats'] != $_POST['prev_event_repeats'] || $update['event_recur'] != $_POST['prev_event_recur'] ) ? true : false;
631
  if ( $date_changed || $recur_changed ) {
632
  // TODO: if date or recur changed, do generation of new instances, then iterate over existing occurrences
633
  // to update & delete remaining
634
+ // ISSUE: this results in all new event IDs, which breaks links. Need to resolve. TODO
635
  mc_delete_instances( $event_id );
636
  mc_increment_event( $event_id );
637
  mc_delete_cache();
799
  switch ( $field ) {
800
  case 'event_host' :
801
  if ( $show_block ) {
802
+ $host = ( empty( $data->event_host ) ) ? $user_ID : $data->event_host;
803
+ $select = mc_selected_users( $host, 'hosts' );
 
 
 
 
 
 
 
 
 
 
 
804
  $return = '
805
  <p>
806
  <label for="e_host">' . __( 'Host', 'my-calendar' ) . '</label>
812
  break;
813
  case 'event_author' :
814
  if ( $show_block && is_object( $data ) && $data->event_author === '0' ) {
815
+ $author = ( empty( $data->event_author ) ) ? $user_ID : $data->event_author;
816
+ $select = mc_selected_users( $author, 'authors' );
 
 
 
 
817
  $return = '
818
  <p>
819
  <label for="e_author">' . __( 'Author', 'my-calendar' ) . '</label>
1162
  <?php
1163
  if ( ! empty( $_GET['date'] ) && $data->event_recur != 'S' ) {
1164
  $event = mc_get_event( $instance );
1165
+ $date = date_i18n( get_option( 'mc_date_format' ), mc_strtotime( $event->occur_begin ) );
1166
  $message = __( "You are editing the <strong>$date</strong> instance of this event. Other instances of this event will not be changed.", 'my-calendar' );
1167
  echo "<div class='message updated'><p>$message</p></div>";
1168
  } else if ( isset( $_GET['date'] ) && empty( $_GET['date'] ) ) {
1649
 
1650
  $found_rows = $wpdb->get_col( "SELECT FOUND_ROWS();" );
1651
  $items = $found_rows[0];
1652
+ // Navigation
1653
  if ( ( function_exists( 'akismet_http_post' ) || function_exists( 'bs_checker' ) ) && $allow_filters ) {
1654
  ?>
1655
  <ul class="links">
1851
  <?php if ( $event->event_label != '' ) { ?><a class='mc_filter' href='<?php $elabel = urlencode( $event->event_label ); echo admin_url( "admin.php?page=my-calendar-manage&amp;filter=$elabel&amp;restrict=where" ); ?>' title="<?php _e( 'Filter by location', 'my-calendar' ); ?>"><span class="screen-reader-text"><?php _e( 'Show only: ', 'my-calendar' ); ?></span><?php echo strip_tags( stripslashes( $event->event_label ) ); ?></a><?php } ?>
1852
  </td>
1853
  <?php if ( $event->event_endtime != "23:59:59" ) {
1854
+ $eventTime = date_i18n( get_option( 'mc_time_format' ), mc_strtotime( $event->event_time ) );
1855
  } else {
1856
  $eventTime = mc_notime_label( $event );
1857
  } ?>
1858
  <td><?php
1859
  $date_format = ( get_option( 'mc_date_format' ) == '' ) ? get_option( 'date_format' ) : get_option( 'mc_date_format' );
1860
+ $begin = date_i18n( $date_format, mc_strtotime( $event->event_begin ) );
1861
  echo "$begin, $eventTime"; ?>
1862
  <div class="recurs">
1863
  <strong><?php _e( 'Recurs', 'my-calendar' ); ?></strong>
1934
  }
1935
  ?>
1936
  </table>
1937
+ <?php
1938
+ // navigation
1939
+ if ( ( function_exists( 'akismet_http_post' ) || function_exists( 'bs_checker' ) ) && $allow_filters ) {
1940
+ ?>
1941
+ <ul class="links">
1942
+ <li>
1943
+ <a <?php echo ( isset( $_GET['restrict'] ) && $_GET['restrict'] == 'flagged' ) ? 'class="active-link"' : ''; ?>
1944
+ href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;restrict=flagged&amp;filter=1' ); ?>"><?php _e( 'Spam', 'my-calendar' ); ?></a>
1945
+ </li>
1946
+ </ul><?php
1947
+ }
1948
+ ?>
1949
+ <div class='mc-search'>
1950
+ <form action="<?php echo esc_url( add_query_arg( $_GET, admin_url( 'admin.php' ) ) ); ?>" method="post">
1951
+ <div><input type="hidden" name="_wpnonce"
1952
+ value="<?php echo wp_create_nonce( 'my-calendar-nonce' ); ?>"/>
1953
+ </div>
1954
+ <div>
1955
+ <label for="mc_search_footer" class='screen-reader-text'><?php _e( 'Search', 'my-calendar' ); ?></label>
1956
+ <input type='text' role='search' name='mcs' id='mc_search_footer'
1957
+ value='<?php if ( isset( $_POST['mcs'] ) ) {
1958
+ esc_attr_e( $_POST['mcs'] );
1959
+ } ?>'/> <input type='submit' value='<?php _e( 'Search Events', 'my-calendar' ); ?>' class='button-secondary'/>
1960
+ </div>
1961
+ </form>
1962
+ </div>
1963
+ <?php
1964
+ if ( get_option( 'mc_event_approve' ) == 'true' ) {
1965
+ ?>
1966
+ <ul class="links">
1967
+ <li>
1968
+ <a <?php echo ( isset( $_GET['limit'] ) && $_GET['limit'] == 'published' ) ? 'class="active-link"' : ''; ?>
1969
+ href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=published' ); ?>"><?php _e( 'Published', 'my-calendar' ); ?></a>
1970
+ </li>
1971
+ <li>
1972
+ <a <?php echo ( isset( $_GET['limit'] ) && $_GET['limit'] == 'reserved' ) ? 'class="active-link"' : ''; ?>
1973
+ href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=reserved' ); ?>"><?php _e( 'Reserved', 'my-calendar' ); ?></a>
1974
+ </li>
1975
+ <li>
1976
+ <a <?php echo ( isset( $_GET['limit'] ) && $_GET['limit'] == 'all' || ! isset( $_GET['limit'] ) ) ? 'class="active-link"' : ''; ?>
1977
+ href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;restrict=archived' ); ?>"><?php _e( 'Archived', 'my-calendar' ); ?></a>
1978
+ </li>
1979
+ <li>
1980
+ <a <?php echo ( isset( $_GET['limit'] ) && $_GET['limit'] == 'all' || ! isset( $_GET['limit'] ) ) ? 'class="active-link"' : ''; ?>
1981
+ href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=all' ); ?>"><?php _e( 'All', 'my-calendar' ); ?></a>
1982
+ </li>
1983
+ </ul><?php
1984
+ }
1985
+ echo $filtered;
1986
+ $num_pages = ceil( $items / $items_per_page );
1987
+ if ( $num_pages > 1 ) {
1988
+ $page_links = paginate_links( array(
1989
+ 'base' => add_query_arg( 'paged', '%#%' ),
1990
+ 'format' => '',
1991
+ 'prev_text' => __( '&laquo; Previous<span class="screen-reader-text"> Events</span>', 'my-calendar' ),
1992
+ 'next_text' => __( 'Next<span class="screen-reader-text"> Events</span> &raquo;', 'my-calendar' ),
1993
+ 'total' => $num_pages,
1994
+ 'current' => $current,
1995
+ 'mid_size' => 1
1996
+ ) );
1997
+ printf( "<div class='tablenav'><div class='tablenav-pages'>%s</div></div>", $page_links );
1998
+ }
1999
+ ?>
2000
+ <p class="event-actions">
2001
  <input type="submit" class="button-secondary delete" name="mass_delete" value="<?php _e( 'Delete events', 'my-calendar' ); ?>"/>
2002
  <?php if ( current_user_can( 'mc_approve_events' ) ) { ?>
2003
  <input type="submit" class="button-secondary mc-approve" name="mass_approve" value="<?php _e( 'Approve events', 'my-calendar' ); ?>"/>
2047
  // ...AND there's no reason to allow it, since weekday events will NEVER happen on the weekend.
2048
  $begin = trim( $post['event_begin'][ $i ] );
2049
  $end = ( ! empty( $post['event_end'] ) ) ? trim( $post['event_end'][ $i ] ) : $post['event_begin'][ $i ];
2050
+ if ( $recur == 'E' && ( date( 'w', mc_strtotime( $begin ) ) == 0 || date( 'w', mc_strtotime( $begin ) ) == 6 ) ) {
2051
+ if ( date( 'w', mc_strtotime( $begin ) ) == 0 ) {
2052
  $newbegin = my_calendar_add_date( $begin, 1 );
2053
  if ( ! empty( $post['event_end'][ $i ] ) ) {
2054
  $newend = my_calendar_add_date( $end, 1 );
2055
  } else {
2056
  $newend = $newbegin;
2057
  }
2058
+ } else if ( date( 'w', mc_strtotime( $begin ) ) == 6 ) {
2059
  $newbegin = my_calendar_add_date( $begin, 2 );
2060
  if ( ! empty( $post['event_end'][ $i ] ) ) {
2061
  $newend = my_calendar_add_date( $end, 2 );
2070
  $end = ! empty( $post['event_end'][ $i ] ) ? trim( $post['event_end'][ $i ] ) : $begin;
2071
  }
2072
 
2073
+ $begin = date( 'Y-m-d', mc_strtotime( $begin ) );// regardless of entry format, convert.
2074
  $time = ! empty( $post['event_time'][ $i ] ) ? trim( $post['event_time'][ $i ] ) : '';
2075
  if ( $time != '' ) {
2076
+ $default_modifier = apply_filters( 'mc_default_event_length', '1 hour' );
2077
+ $endtime = ! empty( $post['event_endtime'][ $i ] ) ? trim( $post['event_endtime'][ $i ] ) : date( 'H:i:s', mc_strtotime( $time . ' +' . $default_modifier ) );
2078
  } else {
2079
  $endtime = ! empty( $post['event_endtime'][ $i ] ) ? trim( $post['event_endtime'][ $i ] ) : '';
2080
  }
2082
  $endtime = ( $endtime == '' && $time == '00:00:00' ) ? '23:59:59' : $endtime; // set at end of night if np
2083
 
2084
  // prevent setting enddate to incorrect value on copy.
2085
+ if ( mc_strtotime( $end ) < mc_strtotime( $begin ) && $action == 'copy' ) {
2086
+ $end = date( 'Y-m-d', ( mc_strtotime( $begin ) + ( mc_strtotime( $post['prev_event_end'] ) - mc_strtotime( $post['prev_event_begin'] ) ) ) );
2087
  }
2088
  if ( isset( $post['event_allday'] ) && (int) $post['event_allday'] !== 0 ) {
2089
  $time = '00:00:00'; $endtime = '23:59:59';
2090
  }
2091
 
2092
  // verify formats
2093
+ $time = date( 'H:i:s', mc_strtotime( $time ) );
2094
+ $endtime = date( 'H:i:s', mc_strtotime( $endtime ) );
2095
 
2096
+ $end = date( 'Y-m-d', mc_strtotime( $end ) ); // regardless of entry format, convert.
2097
  $repeats = ( isset( $post['event_repeats'] ) ) ? trim( $post['event_repeats'] ) : 0;
2098
  $host = ! empty( $post['event_host'] ) ? $post['event_host'] : $current_user->ID;
2099
 
2197
  // Perform validation on the submitted dates - checks for valid years and months
2198
  if ( mc_checkdate( $begin ) && mc_checkdate( $end ) ) {
2199
  // Make sure dates are equal or end date is later than start date
2200
+ if ( mc_strtotime( "$end $endtime" ) < mc_strtotime( "$begin $time" ) ) {
2201
  $errors .= "<div class='error'><p><strong>" . __( 'Error', 'my-calendar' ) . ":</strong> " . __( 'Your event end date must be either after or the same as your event begin date', 'my-calendar' ) . "</p></div>";
2202
  }
2203
  } else {
2205
  }
2206
 
2207
  // We check for a valid time, or an empty one
2208
+ $time = ( $time == '' ) ? '23:59:59' : date( 'H:i:00', mc_strtotime( $time ) );
2209
  $time_format_one = '/^([0-1][0-9]):([0-5][0-9]):([0-5][0-9])$/';
2210
  $time_format_two = '/^([2][0-3]):([0-5][0-9]):([0-5][0-9])$/';
2211
  if ( preg_match( $time_format_one, $time ) || preg_match( $time_format_two, $time ) || $time == '' ) {
2469
  $results = $wpdb->get_results( $sql );
2470
  if ( is_array( $results ) && is_admin() ) {
2471
  foreach ( $results as $result ) {
2472
+ $begin = "<span id='occur_date_$result->occur_id'>" . date_i18n( get_option( 'mc_date_format' ), mc_strtotime( $result->occur_begin ) ) . ', ' . date( get_option( 'mc_time_format' ), mc_strtotime( $result->occur_begin ) ) . "</span>";
2473
  if ( $result->occur_id == $occur ) {
2474
  $control = '';
2475
  $edit = "<em>" . __( 'Editing Now', 'my-calendar' ) . "</em>";
2536
  $event_end = esc_attr( $data->event_end );
2537
  if ( isset( $_GET['date'] ) ) {
2538
  $event = mc_get_event( (int) $_GET['date'] );
2539
+ $event_begin = date( 'Y-m-d', mc_strtotime( $event->occur_begin ) );
2540
+ $event_end = date( 'Y-m-d', mc_strtotime( $event->occur_end ) );
2541
  if ( $event_begin == $event_end ) {
2542
  $event_end = '';
2543
  };
2544
  }
2545
+ $starttime = ( mc_is_all_day( $data ) ) ? '' : date( "h:i A", mc_strtotime( $data->event_time ) );
2546
+ $endtime = ( mc_is_all_day( $data ) ) ? '' : date( "h:i A", mc_strtotime( $data->event_endtime ) );
2547
  } else {
2548
  $event_begin = date( "Y-m-d" );
2549
  $event_end = $starttime = $endtime = '';
2641
  mc_update_data( $event_id, 'event_image', $featured_image, '%s' );
2642
  }
2643
  }
2644
+
2645
+ /**
2646
+ * Parse a string and replace internationalized months with English so strtotime() will parse correctly
2647
+ */
2648
+ function mc_strtotime( $string ) {
2649
+ $months = array(
2650
+ date_i18n( 'F', strtotime( 'January 1' ) ),
2651
+ date_i18n( 'F', strtotime( 'February 1' ) ),
2652
+ date_i18n( 'F', strtotime( 'March 1' ) ),
2653
+ date_i18n( 'F', strtotime( 'April 1' ) ),
2654
+ date_i18n( 'F', strtotime( 'May 1' ) ),
2655
+ date_i18n( 'F', strtotime( 'June 1' ) ),
2656
+ date_i18n( 'F', strtotime( 'July 1' ) ),
2657
+ date_i18n( 'F', strtotime( 'August 1' ) ),
2658
+ date_i18n( 'F', strtotime( 'September 1' ) ),
2659
+ date_i18n( 'F', strtotime( 'October 1' ) ),
2660
+ date_i18n( 'F', strtotime( 'November 1' ) ),
2661
+ date_i18n( 'F', strtotime( 'December 1' ) ),
2662
+ date_i18n( 'M', strtotime( 'January 1' ) ),
2663
+ date_i18n( 'M', strtotime( 'February 1' ) ),
2664
+ date_i18n( 'M', strtotime( 'March 1' ) ),
2665
+ date_i18n( 'M', strtotime( 'April 1' ) ),
2666
+ date_i18n( 'M', strtotime( 'May 1' ) ),
2667
+ date_i18n( 'M', strtotime( 'June 1' ) ),
2668
+ date_i18n( 'M', strtotime( 'July 1' ) ),
2669
+ date_i18n( 'M', strtotime( 'August 1' ) ),
2670
+ date_i18n( 'M', strtotime( 'September 1' ) ),
2671
+ date_i18n( 'M', strtotime( 'October 1' ) ),
2672
+ date_i18n( 'M', strtotime( 'November 1' ) ),
2673
+ date_i18n( 'M', strtotime( 'December 1' ) )
2674
+ );
2675
+ $english = array(
2676
+ 'January',
2677
+ 'February',
2678
+ 'March',
2679
+ 'April',
2680
+ 'May',
2681
+ 'June',
2682
+ 'July',
2683
+ 'August',
2684
+ 'September',
2685
+ 'October',
2686
+ 'November',
2687
+ 'December',
2688
+ 'January',
2689
+ 'February',
2690
+ 'March',
2691
+ 'April',
2692
+ 'May',
2693
+ 'June',
2694
+ 'July',
2695
+ 'August',
2696
+ 'September',
2697
+ 'October',
2698
+ 'November',
2699
+ 'December'
2700
+ );
2701
+
2702
+ return strtotime( str_replace( $months, $english, $string ) );
2703
+
2704
+ }
my-calendar-generator.php CHANGED
@@ -80,8 +80,8 @@ function mc_generator( $type ) {
80
  <?php _e( '<strong>Note:</strong> If you provide a location filter value, it must be an exact match for that information as saved with your events. (e.g. "Saint Paul" is not equivalent to "saint paul" or "St. Paul")', 'my-calendar' ); ?>
81
  </p>
82
  <?php
83
- // Grab users and list them
84
- $users = mc_get_users();
85
  $options = '';
86
  foreach ( $users as $u ) {
87
  $options .= '<option value="' . $u->ID . '">' . esc_html( $u->display_name ) . "</option>\n";
@@ -94,6 +94,13 @@ function mc_generator( $type ) {
94
  <?php echo $options; ?>
95
  </select>
96
  </p>
 
 
 
 
 
 
 
97
  <p>
98
  <label for="host"><?php _e( 'Limit by Host', 'my-calendar' ); ?></label>
99
  <select name="host[]" id="host" multiple="multiple">
80
  <?php _e( '<strong>Note:</strong> If you provide a location filter value, it must be an exact match for that information as saved with your events. (e.g. "Saint Paul" is not equivalent to "saint paul" or "St. Paul")', 'my-calendar' ); ?>
81
  </p>
82
  <?php
83
+ // Grab authors and list them
84
+ $users = mc_get_users( 'authors' );
85
  $options = '';
86
  foreach ( $users as $u ) {
87
  $options .= '<option value="' . $u->ID . '">' . esc_html( $u->display_name ) . "</option>\n";
94
  <?php echo $options; ?>
95
  </select>
96
  </p>
97
+ <?php
98
+ // Grab authors and list them
99
+ $users = mc_get_users( 'hosts' );
100
+ $options = '';
101
+ foreach ( $users as $u ) {
102
+ $options .= '<option value="' . $u->ID . '">' . esc_html( $u->display_name ) . "</option>\n";
103
+ } ?>
104
  <p>
105
  <label for="host"><?php _e( 'Limit by Host', 'my-calendar' ); ?></label>
106
  <select name="host[]" id="host" multiple="multiple">
my-calendar-group-manager.php CHANGED
@@ -428,8 +428,8 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
428
  } ?></label>
429
  <select id="e_host" name="event_host">
430
  <?php
431
- // Grab all the categories and list them
432
- $userList = mc_get_users();
433
  foreach ( $userList as $u ) {
434
  echo '<option value="' . $u->ID . '"';
435
  if ( is_object( $data ) && $data->event_host == $u->ID ) {
428
  } ?></label>
429
  <select id="e_host" name="event_host">
430
  <?php
431
+ // Grab hosts and list them
432
+ $userList = mc_get_users( 'hosts' );
433
  foreach ( $userList as $u ) {
434
  echo '<option value="' . $u->ID . '"';
435
  if ( is_object( $data ) && $data->event_host == $u->ID ) {
my-calendar-help.php CHANGED
@@ -150,10 +150,10 @@ function my_calendar_help() {
150
 
151
  <h4><?php _e( 'Calendar Filter Shortcodes', 'my-calendar' ); ?></h4>
152
 
153
- <textarea readonly='readonly' class="large-text readonly">[mc_filters show="categories,locations"]</textarea>
154
 
155
  <p>
156
- <?php _e( 'Displays all available filters as a single form. The <code>show</code> attribute takes three keywords: categories, locations, and access, to indicate which filters to show and in what order.', 'my-calendar' ); ?>
157
  </p>
158
 
159
  <textarea readonly='readonly' class="large-text readonly">[my_calendar_locations show="list" type="saved" datatype="name"]</textarea>
150
 
151
  <h4><?php _e( 'Calendar Filter Shortcodes', 'my-calendar' ); ?></h4>
152
 
153
+ <textarea readonly='readonly' class="large-text readonly">[mc_filters show="categories,locations" target_url='' ltype='name']</textarea>
154
 
155
  <p>
156
+ <?php _e( 'Displays all available filters as a single form. The <code>show</code> attribute takes three keywords: categories, locations, and access, to indicate which filters to show and in what order.', 'my-calendar' ); ?> <?php _e( 'Use "target_url" to pass the URL for a page where results should be shown. The target page should use the "[my_calendar]" shortcode.', 'my-calendar' ); ?> <?php _e( 'Use "ltype" to change the type of data being searched.', 'my-calendar' ); ?>
157
  </p>
158
 
159
  <textarea readonly='readonly' class="large-text readonly">[my_calendar_locations show="list" type="saved" datatype="name"]</textarea>
my-calendar-limits.php CHANGED
@@ -254,8 +254,8 @@ function mc_limit_string( $type = '', $ltype = '', $lvalue = '' ) {
254
  $current_location = $lvalue;
255
  }
256
  } else {
257
- $location = urldecode( $_GET['ltype'] );
258
- $current_location = urldecode( $_GET['loc'] );
259
  }
260
  switch ( $location ) {
261
  case "name" :
254
  $current_location = $lvalue;
255
  }
256
  } else {
257
+ $location = isset( $_GET['ltype'] ) ? urldecode( $_GET['ltype'] ) : $location;
258
+ $current_location = isset( $_GET['loc'] ) ? urldecode( $_GET['loc'] ) : $current_location;
259
  }
260
  switch ( $location ) {
261
  case "name" :
my-calendar-locations.php CHANGED
@@ -262,6 +262,13 @@ function mc_show_location_form( $view = 'add', $curID = '' ) {
262
  <?php
263
  }
264
 
 
 
 
 
 
 
 
265
  function mc_controlled_field( $this_field ) {
266
  $this_field = trim( $this_field );
267
  $controls = get_option( 'mc_location_controls' );
@@ -276,13 +283,22 @@ function mc_controlled_field( $this_field ) {
276
  }
277
  }
278
 
 
 
 
 
 
 
 
 
 
279
  function mc_location_controller( $fieldname, $selected, $context = 'location' ) {
280
  $field = ( $context == 'location' ) ? 'location_' . $fieldname : 'event_' . $fieldname;
281
  $selected = esc_attr( trim( $selected ) );
282
  $options = get_option( 'mc_location_controls' );
283
  $regions = $options[ 'event_' . $fieldname ];
284
  $form = "<select name='$field' id='e_$fieldname'>";
285
- if ( $selected == '' || in_array( $selected, array_keys( $regions ) ) ) {
286
  $form .= "<option value=''>". __( 'None', 'my-calendar' )."</option>\n";
287
  } else {
288
  $form .= "<option value='$selected'>$selected " . __( '(Not a controlled value)', 'my-calendar' ) . "</option>\n";
262
  <?php
263
  }
264
 
265
+ /**
266
+ * Check whether this location field has pre-entered controls on input
267
+ *
268
+ * @param string $this_field field name
269
+ *
270
+ * @return boolean true if location field is controlled
271
+ */
272
  function mc_controlled_field( $this_field ) {
273
  $this_field = trim( $this_field );
274
  $controls = get_option( 'mc_location_controls' );
283
  }
284
  }
285
 
286
+ /**
287
+ * Return select element with the controlled values for a location field
288
+ *
289
+ * @param string $fieldname Name of field
290
+ * @param string $selected currently selected value
291
+ * @param string $context current context: entering new location or new event
292
+ *
293
+ * @return string HTML select element with values
294
+ */
295
  function mc_location_controller( $fieldname, $selected, $context = 'location' ) {
296
  $field = ( $context == 'location' ) ? 'location_' . $fieldname : 'event_' . $fieldname;
297
  $selected = esc_attr( trim( $selected ) );
298
  $options = get_option( 'mc_location_controls' );
299
  $regions = $options[ 'event_' . $fieldname ];
300
  $form = "<select name='$field' id='e_$fieldname'>";
301
+ if ( $selected == '' || in_array( $selected, array_map( 'trim', array_keys( $regions ) ) ) ) {
302
  $form .= "<option value=''>". __( 'None', 'my-calendar' )."</option>\n";
303
  } else {
304
  $form .= "<option value='$selected'>$selected " . __( '(Not a controlled value)', 'my-calendar' ) . "</option>\n";
my-calendar-output.php CHANGED
@@ -189,6 +189,7 @@ function my_calendar_draw_event( $event, $type = "calendar", $process_date, $tim
189
  if ( $event->category_private == 1 && ! is_user_logged_in() ) {
190
  return '';
191
  }
 
192
  // assign empty values to template sections
193
  $header = $address = $more = $author = $list_title = $title = $output = $container = $short = $description = $link = $vcal = $gcal = '';
194
  $date_format = ( get_option( 'mc_date_format' ) != '' ) ? get_option( 'mc_date_format' ) : get_option( 'date_format' );
@@ -234,6 +235,7 @@ function my_calendar_draw_event( $event, $type = "calendar", $process_date, $tim
234
  }
235
  }
236
  }
 
237
  $mc_display_author = get_option( 'mc_display_author' );
238
  $display_map = get_option( 'mc_show_map' );
239
  $display_address = get_option( 'mc_show_address' );
@@ -252,7 +254,7 @@ function my_calendar_draw_event( $event, $type = "calendar", $process_date, $tim
252
  case 'single' : $title_template = ( mc_get_template( 'title_solo' ) == '' ) ? '{title}' : mc_get_template( 'title_solo' ); break;
253
  default: $title_template = ( mc_get_template( 'title' ) == '' ) ? '{title}' : mc_get_template( 'title' );
254
  }
255
-
256
  $event_title = jd_draw_template( $data, $title_template );
257
  $event_title = ( $event_title == '' ) ? jd_draw_template( $data, '{title}' ) : mc_kses_post( $event_title ); //prevent empty titles
258
 
@@ -268,18 +270,19 @@ function my_calendar_draw_event( $event, $type = "calendar", $process_date, $tim
268
  } else {
269
  $wrap = $balance = '';
270
  }
 
271
  $current_date = date_i18n( apply_filters( 'mc_date_format', $date_format, 'details' ), strtotime( $process_date ) );
272
  $group_class = ( $event->event_span == 1 ) ? ' multidate group' . $event->event_group_id : '';
273
  $heading_level = apply_filters( 'mc_heading_level_table', 'h3', $type, $time, $template );
274
  $inner_heading = apply_filters( 'mc_heading_inner_title', $wrap . $image . trim( $event_title ) . $balance, $event_title, $event );
275
- $header .= ( $type != 'single' && $type != 'list' ) ? "<$heading_level class='event-title summary$group_class' id='$uid-$day_id-$type-title'>$inner_heading</$heading_level>\n" : '';
276
- $event_title = ( $type == 'single' ) ? apply_filters( 'mc_single_event_title', $event_title, $event ) : $event_title;
277
- $title = ( $type == 'single' && ! is_singular( 'mc-events' ) ) ? "<h2 class='event-title summary'>$image $event_title</h2>\n" : '<span class="summary screen-reader-text">' . $event_title . '</span>';
278
- $title = apply_filters( 'mc_event_title', $title, $event, $event_title, $image );
279
- $header .= '<span class="summary">' . $title . '</span>';
280
- $close_image = apply_filters( 'mc_close_button', "<img src=\"" . plugin_dir_url( __FILE__ ) . "images/event-close.png\" alt='" . __( 'Close', 'my-calendar' ) . "' />" );
281
- $close_button = "<button type='button' aria-controls='$uid-$day_id-$type-details' class='mc-toggle close'>$close_image</button>";
282
-
283
  if ( mc_show_details( $time, $type ) ) {
284
  $close = ( $type == 'calendar' || $type == 'mini' ) ? $close_button : '';
285
 
@@ -334,7 +337,8 @@ function my_calendar_draw_event( $event, $type = "calendar", $process_date, $tim
334
  $atts = apply_filters( 'mc_post_thumbnail_atts', array( 'class' => 'mc-image photo' ) );
335
  $image = get_the_post_thumbnail( $event->event_post, $default_size, $atts );
336
  } else {
337
- $image = ( $event->event_image != '' ) ? "<img src='$event->event_image' alt='' class='mc-image photo' />" : '';
 
338
  }
339
 
340
  if ( get_option( 'mc_desc' ) == 'true' || $type == 'single' ) {
@@ -367,7 +371,7 @@ function my_calendar_draw_event( $event, $type = "calendar", $process_date, $tim
367
 
368
  $status = ( $status != '' ) ? "<p>$status</p>" : '';
369
  $status = apply_filters( 'mc_registration_state', $status, $event );
370
- $return_url = apply_filters( 'mc_return_uri', get_option( 'mc_uri' ) );
371
  $return = ( $type == 'single' ) ? "<p class='view-full'><a href='$return_url'>" . __( 'View full calendar', 'my-calendar' ) . "</a></p>" : '';
372
 
373
  if ( ! mc_show_details( $time, $type ) ) {
@@ -1355,7 +1359,7 @@ function my_calendar( $name, $format, $category, $time = 'month', $ltype = '', $
1355
  }
1356
  }
1357
  if ( $mc_bottomnav != '' ) {
1358
- $mc_bottomnav = "<div class='mc_bottomnav'>$mc_bottomnav</div>";
1359
  }
1360
 
1361
  if ( $time == 'day' ) {
@@ -1442,6 +1446,9 @@ function my_calendar( $name, $format, $category, $time = 'month', $ltype = '', $
1442
  } else {
1443
  $my_calendar_body .= ( $tr == 'tr' ) ? "<thead>\n" : '<div class="mc-table-body">';
1444
  $my_calendar_body .= "<$tr class='mc-row'>\n";
 
 
 
1445
  for ( $i = 0; $i <= 6; $i ++ ) {
1446
  if ( $start_of_week == 0 ) {
1447
  $class = ( $i < 6 && $i > 0 ) ? 'day-heading' : 'weekend-heading';
@@ -1490,6 +1497,21 @@ function my_calendar( $name, $format, $category, $time = 'month', $ltype = '', $
1490
  $is_anchor = $is_close_anchor = "";
1491
  }
1492
  $td = apply_filters( 'mc_grid_day_wrapper', 'td', $format );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1493
  if ( ! empty( $events ) ) {
1494
  $hide_nextmonth = apply_filters( 'mc_hide_nextmonth', false );
1495
  if ( $hide_nextmonth == true && $monthclass == 'nextmonth' ) {
@@ -1521,8 +1543,9 @@ function my_calendar( $name, $format, $category, $time = 'month', $ltype = '', $
1521
  'mcat',
1522
  'cid',
1523
  'mc_id'
1524
- ), apply_filters( 'mc_modify_day_uri', get_option( 'mc_uri' ) ) );
1525
- $link = ( get_option( 'mc_uri' ) != '' && ! is_numeric( get_option( 'mc_uri' ) ) ) ? $day_url : '#';
 
1526
  } else {
1527
  $atype = str_replace( 'anchor', '', get_option( 'mc_open_day_uri' ) );
1528
  $ad = str_pad( date( 'j', $start ), 2, '0', STR_PAD_LEFT ); // need to match format in ID
@@ -1618,8 +1641,8 @@ function my_calendar( $name, $format, $category, $time = 'month', $ltype = '', $
1618
  }
1619
  }
1620
  }
1621
- $my_calendar_body .= $mc_bottomnav;
1622
  }
 
1623
  }
1624
  // The actual printing is done by the shortcode function.
1625
  $my_calendar_body .= apply_filters( 'mc_after_calendar', '', $args );
@@ -1836,10 +1859,17 @@ function my_calendar_prev_link( $cur_year, $cur_month, $cur_day, $format, $time
1836
  return $output;
1837
  }
1838
 
1839
- function mc_filters( $args ) {
1840
- $fields = explode( ',', $args );
 
 
 
 
 
 
 
1841
  $return = false;
1842
- $current_url = mc_get_current_url();
1843
  $form = "
1844
  <div id='mc_filters'>
1845
  <form action='" . $current_url . "' method='get'>\n";
@@ -1853,7 +1883,7 @@ function mc_filters( $args ) {
1853
  foreach ( $qsa as $name => $argument ) {
1854
  $name = esc_attr( strip_tags( $name ) );
1855
  $argument = esc_attr( strip_tags( $argument ) );
1856
- if ( $name == 'access' || $name == 'mcat' || $name == 'ltype' || $name == 'lvalue' && in_array( $name, $args ) ) {
1857
  } else {
1858
  $form .= ' <input type="hidden" name="' . $name . '" value="' . $argument . '" />' . "\n";
1859
  }
@@ -1866,7 +1896,7 @@ function mc_filters( $args ) {
1866
  $return = true;
1867
  break;
1868
  case 'locations':
1869
- $form .= my_calendar_locations_list( 'form', 'saved', 'name', 'group' );
1870
  $return = true;
1871
  break;
1872
  case 'access':
@@ -2138,7 +2168,7 @@ function my_calendar_searchform( $type, $url ) {
2138
  $query = ( isset( $_GET['mcs'] ) ) ? $_GET['mcs'] : '';
2139
  if ( $type == 'simple' ) {
2140
  if ( !$url || $url == '' ) {
2141
- $url = ( get_option( 'mc_uri' ) != '' ) ? get_option( 'mc_uri' ) : home_url();
2142
  }
2143
  return '
2144
  <div class="mc-search-container" role="search">
189
  if ( $event->category_private == 1 && ! is_user_logged_in() ) {
190
  return '';
191
  }
192
+
193
  // assign empty values to template sections
194
  $header = $address = $more = $author = $list_title = $title = $output = $container = $short = $description = $link = $vcal = $gcal = '';
195
  $date_format = ( get_option( 'mc_date_format' ) != '' ) ? get_option( 'mc_date_format' ) : get_option( 'date_format' );
235
  }
236
  }
237
  }
238
+
239
  $mc_display_author = get_option( 'mc_display_author' );
240
  $display_map = get_option( 'mc_show_map' );
241
  $display_address = get_option( 'mc_show_address' );
254
  case 'single' : $title_template = ( mc_get_template( 'title_solo' ) == '' ) ? '{title}' : mc_get_template( 'title_solo' ); break;
255
  default: $title_template = ( mc_get_template( 'title' ) == '' ) ? '{title}' : mc_get_template( 'title' );
256
  }
257
+
258
  $event_title = jd_draw_template( $data, $title_template );
259
  $event_title = ( $event_title == '' ) ? jd_draw_template( $data, '{title}' ) : mc_kses_post( $event_title ); //prevent empty titles
260
 
270
  } else {
271
  $wrap = $balance = '';
272
  }
273
+
274
  $current_date = date_i18n( apply_filters( 'mc_date_format', $date_format, 'details' ), strtotime( $process_date ) );
275
  $group_class = ( $event->event_span == 1 ) ? ' multidate group' . $event->event_group_id : '';
276
  $heading_level = apply_filters( 'mc_heading_level_table', 'h3', $type, $time, $template );
277
  $inner_heading = apply_filters( 'mc_heading_inner_title', $wrap . $image . trim( $event_title ) . $balance, $event_title, $event );
278
+ $header .= ( $type != 'single' && $type != 'list' ) ? "<$heading_level class='event-title summary$group_class' id='$uid-$day_id-$type-title'>$inner_heading</$heading_level>\n" : '';
279
+ $event_title = ( $type == 'single' ) ? apply_filters( 'mc_single_event_title', $event_title, $event ) : $event_title;
280
+ $title = ( $type == 'single' && ! is_singular( 'mc-events' ) ) ? "<h2 class='event-title summary'>$image $event_title</h2>\n" : '<span class="summary screen-reader-text">' . $event_title . '</span>';
281
+ $title = apply_filters( 'mc_event_title', $title, $event, $event_title, $image );
282
+ $header .= '<span class="summary">' . $title . '</span>';
283
+ $close_image = apply_filters( 'mc_close_button', "<img src=\"" . plugin_dir_url( __FILE__ ) . "images/event-close.png\" alt='" . __( 'Close', 'my-calendar' ) . "' />" );
284
+ $close_button = "<button type='button' aria-controls='$uid-$day_id-$type-details' class='mc-toggle close'>$close_image</button>";
285
+
286
  if ( mc_show_details( $time, $type ) ) {
287
  $close = ( $type == 'calendar' || $type == 'mini' ) ? $close_button : '';
288
 
337
  $atts = apply_filters( 'mc_post_thumbnail_atts', array( 'class' => 'mc-image photo' ) );
338
  $image = get_the_post_thumbnail( $event->event_post, $default_size, $atts );
339
  } else {
340
+ $alt = esc_attr( apply_filters( 'mc_event_image_alt', '', $event ) );
341
+ $image = ( $event->event_image != '' ) ? "<img src='$event->event_image' alt='$alt' class='mc-image photo' />" : '';
342
  }
343
 
344
  if ( get_option( 'mc_desc' ) == 'true' || $type == 'single' ) {
371
 
372
  $status = ( $status != '' ) ? "<p>$status</p>" : '';
373
  $status = apply_filters( 'mc_registration_state', $status, $event );
374
+ $return_url = apply_filters( 'mc_return_uri', mc_get_uri( $event ) );
375
  $return = ( $type == 'single' ) ? "<p class='view-full'><a href='$return_url'>" . __( 'View full calendar', 'my-calendar' ) . "</a></p>" : '';
376
 
377
  if ( ! mc_show_details( $time, $type ) ) {
1359
  }
1360
  }
1361
  if ( $mc_bottomnav != '' ) {
1362
+ $mc_bottomnav = "<div class='mc_bottomnav my-calendar-footer'>$mc_bottomnav</div>";
1363
  }
1364
 
1365
  if ( $time == 'day' ) {
1446
  } else {
1447
  $my_calendar_body .= ( $tr == 'tr' ) ? "<thead>\n" : '<div class="mc-table-body">';
1448
  $my_calendar_body .= "<$tr class='mc-row'>\n";
1449
+ if ( apply_filters( 'mc_show_week_number', false, $args ) ) {
1450
+ $my_calendar_body .= "<th class='mc-week-number'>" . __( 'Week', 'my-calendar' ) . "</th>";
1451
+ }
1452
  for ( $i = 0; $i <= 6; $i ++ ) {
1453
  if ( $start_of_week == 0 ) {
1454
  $class = ( $i < 6 && $i > 0 ) ? 'day-heading' : 'weekend-heading';
1497
  $is_anchor = $is_close_anchor = "";
1498
  }
1499
  $td = apply_filters( 'mc_grid_day_wrapper', 'td', $format );
1500
+ if ( apply_filters( 'mc_show_week_number', false, $args ) ) {
1501
+ if ( ( date( 'N', $start ) == $start_of_week || $start == strtotime( $from ) || !$week_number_shown ) ) {
1502
+ $week_number_shown = false;
1503
+ if ( $format != "list" ) {
1504
+ $weeknumber = date( 'W', $start);
1505
+ $my_calendar_body .= "<td class='week_number'>$weeknumber</td>";
1506
+ $week_number_shown = true;
1507
+ }
1508
+ if ( $format == "list" && !empty( $events ) && !$week_number_shown ) {
1509
+ $weeknumber = date( 'W', $start);
1510
+ $my_calendar_body .= "<li class='mc-week-number'><span class='week-number-text'>" . __( 'Week', 'my-calendar' ) . "</span> <span class='week-number-number'>$weeknumber</span></li>";
1511
+ $week_number_shown = true;
1512
+ }
1513
+ }
1514
+ }
1515
  if ( ! empty( $events ) ) {
1516
  $hide_nextmonth = apply_filters( 'mc_hide_nextmonth', false );
1517
  if ( $hide_nextmonth == true && $monthclass == 'nextmonth' ) {
1543
  'mcat',
1544
  'cid',
1545
  'mc_id'
1546
+ ), apply_filters( 'mc_modify_day_uri', mc_get_uri( $events[0], $args ) )
1547
+ );
1548
+ $link = ( $day_url != '' ) ? $day_url : '#';
1549
  } else {
1550
  $atype = str_replace( 'anchor', '', get_option( 'mc_open_day_uri' ) );
1551
  $ad = str_pad( date( 'j', $start ), 2, '0', STR_PAD_LEFT ); // need to match format in ID
1641
  }
1642
  }
1643
  }
 
1644
  }
1645
+ $my_calendar_body .= $mc_bottomnav;
1646
  }
1647
  // The actual printing is done by the shortcode function.
1648
  $my_calendar_body .= apply_filters( 'mc_after_calendar', '', $args );
1859
  return $output;
1860
  }
1861
 
1862
+ function mc_filters( $args, $target_url, $ltype ) {
1863
+ if ( !is_array( $args ) ) {
1864
+ $fields = explode( ',', $args );
1865
+ } else {
1866
+ $fields = $args;
1867
+ }
1868
+ if ( empty( $fields ) ) {
1869
+ return;
1870
+ }
1871
  $return = false;
1872
+ $current_url = ( $target_url != '' && _mc_is_url( $target_url ) ) ? $target_url : mc_get_current_url();
1873
  $form = "
1874
  <div id='mc_filters'>
1875
  <form action='" . $current_url . "' method='get'>\n";
1883
  foreach ( $qsa as $name => $argument ) {
1884
  $name = esc_attr( strip_tags( $name ) );
1885
  $argument = esc_attr( strip_tags( $argument ) );
1886
+ if ( ( $name == 'access' || $name == 'mcat' || $name == 'loc' || $name == 'ltype' ) ) {
1887
  } else {
1888
  $form .= ' <input type="hidden" name="' . $name . '" value="' . $argument . '" />' . "\n";
1889
  }
1896
  $return = true;
1897
  break;
1898
  case 'locations':
1899
+ $form .= my_calendar_locations_list( 'form', 'saved', $ltype, 'group' );
1900
  $return = true;
1901
  break;
1902
  case 'access':
2168
  $query = ( isset( $_GET['mcs'] ) ) ? $_GET['mcs'] : '';
2169
  if ( $type == 'simple' ) {
2170
  if ( !$url || $url == '' ) {
2171
+ $url = ( get_option( 'mc_uri' ) != '' ) ? mc_get_uri( false, array( 'type' => $type ) ) : home_url();
2172
  }
2173
  return '
2174
  <div class="mc-search-container" role="search">
my-calendar-print.php CHANGED
@@ -41,8 +41,15 @@ function my_calendar_print() {
41
  </head>
42
  <body>';
43
  echo $head;
 
 
 
 
 
 
 
44
  echo my_calendar( 'print', 'calendar', $category, $time, $ltype, $lvalue, 'mc-print-view', '', '', null, null, 'none', 'none' );
45
- $return_url = ( get_option( 'mc_uri' ) != '' && ! is_numeric( get_option( 'mc_uri' ) ) ) ? get_option( 'mc_uri' ) : home_url();
46
  $return_url = apply_filters( 'mc_print_return_url', $return_url, $category, $time, $ltype, $lvalue );
47
 
48
  if ( isset( $_GET['href'] ) ) {
41
  </head>
42
  <body>';
43
  echo $head;
44
+ $args = array(
45
+ 'type' => 'print',
46
+ 'category' => $category,
47
+ 'time' => $time,
48
+ 'ltype' => $ltype,
49
+ 'lvalue' => $lvalue
50
+ );
51
  echo my_calendar( 'print', 'calendar', $category, $time, $ltype, $lvalue, 'mc-print-view', '', '', null, null, 'none', 'none' );
52
+ $return_url = ( get_option( 'mc_uri' ) != '' && ! is_numeric( get_option( 'mc_uri' ) ) ) ? mc_get_uri( false, $args ) : home_url();
53
  $return_url = apply_filters( 'mc_print_return_url', $return_url, $category, $time, $ltype, $lvalue );
54
 
55
  if ( isset( $_GET['href'] ) ) {
my-calendar-shortcodes.php CHANGED
@@ -127,10 +127,12 @@ function my_calendar_access( $atts ) {
127
 
128
  function my_calendar_filters( $atts ) {
129
  extract( shortcode_atts( array(
130
- 'show' => 'categories,locations'
 
 
131
  ), $atts, 'my_calendar_filters' ) );
132
 
133
- return mc_filters( $show );
134
  }
135
 
136
 
127
 
128
  function my_calendar_filters( $atts ) {
129
  extract( shortcode_atts( array(
130
+ 'show' => 'categories,locations',
131
+ 'target_url' => '',
132
+ 'ltype' => 'name'
133
  ), $atts, 'my_calendar_filters' ) );
134
 
135
+ return mc_filters( $show, $target_url, $ltype );
136
  }
137
 
138
 
my-calendar-templates.php CHANGED
@@ -6,6 +6,7 @@ if ( ! defined( 'ABSPATH' ) ) {
6
  // draw array of information into a template with {$key} formatted tags
7
  function jd_draw_template( $array, $template, $type = 'list' ) {
8
  $template = stripcslashes( $template );
 
9
  foreach ( $array as $key => $value ) {
10
  // disallow anything not allowed in posts
11
  // fields where mc_kses_posts shouldn't run
@@ -18,7 +19,7 @@ function jd_draw_template( $array, $template, $type = 'list' ) {
18
  if ( strpos( $template, "{" . $key ) !== false ) {
19
  if ( $type != 'list' ) {
20
  if ( $key == 'link' && $value == '' ) {
21
- $value = ( get_option( 'mc_uri' ) != '' && ! is_numeric( get_option( 'mc_uri' ) ) ) ? get_option( 'mc_uri' ) : home_url();
22
  }
23
  if ( $key != 'guid' ) {
24
  $value = htmlentities( $value );
@@ -49,12 +50,12 @@ function jd_draw_template( $array, $template, $type = 'list' ) {
49
  // secondary search for RSS output
50
  $rss_search = "{rss_$key}";
51
  if ( strpos( $template, $rss_search ) !== false ) {
52
- $value = ent2ncr( $value ); // WP native function.
53
  $template = stripcslashes( str_replace( $rss_search, $value, $template ) );
54
  }
55
  }
56
  }
57
-
58
  return stripslashes( trim( $template ) );
59
  }
60
 
@@ -262,8 +263,8 @@ function mc_create_tags( $event, $context = 'filters' ) {
262
  $endtime = ( $event->event_end == '23:59:59' ) ? '00:00:00' : date( 'H:i:s', strtotime( $real_end_date ) );
263
  $e['endtime'] = ( $real_end_date == $real_begin_date || $event->event_hide_end == 1 || date( 'H:i:s', strtotime( $real_end_date ) ) == '23:59:59' ) ? '' : date_i18n( get_option( 'mc_time_format' ), strtotime( $endtime ) );
264
  $e['runtime'] = mc_runtime( $event->ts_occur_begin, $event->ts_occur_end, $event );
265
- $e['dtstart'] = date( 'Y-m-d\TH:i:s', strtotime( $real_begin_date ) );// hcal formatted
266
- $e['dtend'] = date( 'Y-m-d\TH:i:s', strtotime( $real_end_date ) ); //hcal formatted end
267
  $e['rssdate'] = date( 'D, d M Y H:i:s +0000', strtotime( $event->event_added ) );
268
  $date = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_begin' ), strtotime( $real_begin_date ) );
269
  $date_end = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_end' ), strtotime( $real_end_date ) );
@@ -290,9 +291,12 @@ function mc_create_tags( $event, $context = 'filters' ) {
290
  $e['category'] = stripslashes( $event->category_name );
291
  $e['term'] = intval( $event->category_term );
292
  $e['icon'] = mc_category_icon( $event, 'img' );
293
- $e['icon_html'] = "<img src='$e[icon]' class='mc-category-icon' alt='" . __( 'Category', 'my-calendar' ) . ": " . esc_attr( $event->category_name ) . "' />";
294
  $e['color'] = $event->category_color;
295
- $e['color_css'] = "<span style='background-color: $event->category_color'>"; // this is because widgets now strip out style attributes.
 
 
 
296
  $e['close_color_css'] = "</span>";
297
 
298
  // special
@@ -344,10 +348,10 @@ function mc_create_tags( $event, $context = 'filters' ) {
344
  $e['linking_title'] = ( $e['linking'] != '' ) ? "<a href='" . $e['linking'] . "'>" . $e['title'] . "</a>" : $e['title'];
345
 
346
  if ( $context != 'related' && ( is_singular( 'mc-events' ) || isset( $_GET['mc_id'] ) ) ) {
347
- $related_template = apply_filters( 'mc_related_template', "{date}, {time}", $event );
348
- $e['related'] = '<ul class="related-events">' . mc_list_related( $event->event_group_id, $event->event_id, $related_template ) . '</ul>';
349
  } else {
350
- $e['related'] = '';
351
  }
352
 
353
  // location fields
@@ -386,7 +390,7 @@ function mc_create_tags( $event, $context = 'filters' ) {
386
  $e['ical_description'] = str_replace( "\r", "=0D=0A=", $event->event_desc );
387
  $e['ical_desc'] = $strip_desc;
388
  $e['ical_start'] = $dtstart;
389
- $e['ical_end'] = $dtend;
390
  $ical_link = mc_build_url( array( 'vcal' => $event->occur_id ), array(
391
  'month',
392
  'dy',
@@ -395,7 +399,7 @@ function mc_create_tags( $event, $context = 'filters' ) {
395
  'loc',
396
  'mcat',
397
  'format'
398
- ), get_option( 'mc_uri' ) );
399
  $e['ical'] = $ical_link;
400
  $e['ical_html'] = "<a class='ical' rel='nofollow' href='$ical_link'>" . __( 'iCal', 'my-calendar' ) . "</a>";
401
  $e = apply_filters( 'mc_filter_shortcodes', $e, $event );
@@ -414,6 +418,59 @@ function mc_notime_label( $event ) {
414
  return apply_filters( 'mc_notime_label', $notime, $event );
415
  }
416
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
  function mc_get_details_label( $event, $e ) {
418
  $templates = get_option( 'mc_templates' );
419
  $e_template = ( ! empty( $templates['label'] ) ) ? stripcslashes( $templates['label'] ) : sprintf( __( 'Event Details %s', 'my-calendar' ), '<span class="screen-reader-text">about {title}</span> &raquo;' );
@@ -435,23 +492,25 @@ function old_mc_format_timestamp( $os ) {
435
 
436
  function mc_format_timestamp( $os ) {
437
  if ( get_option( 'mc_ical_utc' ) == 'true' ) {
438
- $timezone_string = get_option( 'timezone_string' );
439
- if ( ! $timezone_string ) {
440
- // multiply gmt_offset by -1 because POSIX has it reversed:
441
- // http://stackoverflow.com/questions/20228224/php-timezone-issue
442
- $timezone_string = sprintf("Etc/GMT%+d", -1 * get_option('$gmt_offset') );
443
- }
444
-
445
- $timezone_object = timezone_open( $timezone_string );
446
- $date_object = date_create( null, $timezone_object );
447
- $date_object->setTime( date( 'H', $os ), date( 'i', $os ) );
448
- $date_object->setDate( date( 'Y', $os ), date( 'm', $os ), date( 'd', $os ) );
449
- $timestamp = $date_object->getTimestamp( );
450
- $time = gmdate( "Ymd\THi00", $timestamp ) . "Z";
 
 
451
 
452
  } else {
453
- $os_time = mktime( date( 'H', $os ), date( 'i', $os ), date( 's', $os ), date( 'm', $os ), date( 'd', $os ), date( 'Y', $os ) );
454
- $time = date( "Ymd\THi00", $os_time );
455
  }
456
 
457
  return $time;
6
  // draw array of information into a template with {$key} formatted tags
7
  function jd_draw_template( $array, $template, $type = 'list' ) {
8
  $template = stripcslashes( $template );
9
+
10
  foreach ( $array as $key => $value ) {
11
  // disallow anything not allowed in posts
12
  // fields where mc_kses_posts shouldn't run
19
  if ( strpos( $template, "{" . $key ) !== false ) {
20
  if ( $type != 'list' ) {
21
  if ( $key == 'link' && $value == '' ) {
22
+ $value = ( get_option( 'mc_uri' ) != '' && ! is_numeric( get_option( 'mc_uri' ) ) ) ? mc_get_uri( false, $array ) : home_url();
23
  }
24
  if ( $key != 'guid' ) {
25
  $value = htmlentities( $value );
50
  // secondary search for RSS output
51
  $rss_search = "{rss_$key}";
52
  if ( strpos( $template, $rss_search ) !== false ) {
53
+ $value = ent2ncr( $value ); // WP core function.
54
  $template = stripcslashes( str_replace( $rss_search, $value, $template ) );
55
  }
56
  }
57
  }
58
+
59
  return stripslashes( trim( $template ) );
60
  }
61
 
263
  $endtime = ( $event->event_end == '23:59:59' ) ? '00:00:00' : date( 'H:i:s', strtotime( $real_end_date ) );
264
  $e['endtime'] = ( $real_end_date == $real_begin_date || $event->event_hide_end == 1 || date( 'H:i:s', strtotime( $real_end_date ) ) == '23:59:59' ) ? '' : date_i18n( get_option( 'mc_time_format' ), strtotime( $endtime ) );
265
  $e['runtime'] = mc_runtime( $event->ts_occur_begin, $event->ts_occur_end, $event );
266
+ $e['dtstart'] = date( 'Y-m-d\TH:i:s', strtotime( $real_begin_date ) ); // hcal formatted
267
+ $e['dtend'] = date( 'Y-m-d\TH:i:s', strtotime( $real_end_date ) ); // hcal formatted end
268
  $e['rssdate'] = date( 'D, d M Y H:i:s +0000', strtotime( $event->event_added ) );
269
  $date = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_begin' ), strtotime( $real_begin_date ) );
270
  $date_end = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_end' ), strtotime( $real_end_date ) );
291
  $e['category'] = stripslashes( $event->category_name );
292
  $e['term'] = intval( $event->category_term );
293
  $e['icon'] = mc_category_icon( $event, 'img' );
294
+ $e['icon_html'] = ( $e['icon'] != '' ) ? "<img src='$e[icon]' class='mc-category-icon' alt='" . __( 'Category', 'my-calendar' ) . ": " . esc_attr( $event->category_name ) . "' />" : '';
295
  $e['color'] = $event->category_color;
296
+ $hex = ( strpos( $event->category_color, '#' ) !== 0 ) ? '#' : '';
297
+ $color = $hex . $event->category_color;
298
+ $inverse = mc_inverse_color( $color );
299
+ $e['color_css'] = "<span style='background-color: $event->category_color; color: $inverse'>"; // this is because widgets now strip out style attributes.
300
  $e['close_color_css'] = "</span>";
301
 
302
  // special
348
  $e['linking_title'] = ( $e['linking'] != '' ) ? "<a href='" . $e['linking'] . "'>" . $e['title'] . "</a>" : $e['title'];
349
 
350
  if ( $context != 'related' && ( is_singular( 'mc-events' ) || isset( $_GET['mc_id'] ) ) ) {
351
+ $related_template = apply_filters( 'mc_related_template', "{date}, {time}", $event );
352
+ $e['related'] = '<ul class="related-events">' . mc_list_related( $event->event_group_id, $event->event_id, $related_template ) . '</ul>';
353
  } else {
354
+ $e['related'] = '';
355
  }
356
 
357
  // location fields
390
  $e['ical_description'] = str_replace( "\r", "=0D=0A=", $event->event_desc );
391
  $e['ical_desc'] = $strip_desc;
392
  $e['ical_start'] = $dtstart;
393
+ $e['ical_end'] = ( mc_is_all_day( $event ) ) ? date( 'Ymd\THi00', strtotime( $dtend ) + 60 ) : $dtend;
394
  $ical_link = mc_build_url( array( 'vcal' => $event->occur_id ), array(
395
  'month',
396
  'dy',
399
  'loc',
400
  'mcat',
401
  'format'
402
+ ), mc_get_uri( $event ) );
403
  $e['ical'] = $ical_link;
404
  $e['ical_html'] = "<a class='ical' rel='nofollow' href='$ical_link'>" . __( 'iCal', 'my-calendar' ) . "</a>";
405
  $e = apply_filters( 'mc_filter_shortcodes', $e, $event );
418
  return apply_filters( 'mc_notime_label', $notime, $event );
419
  }
420
 
421
+
422
+ function mc_get_details_link( $event ) {
423
+ if ( is_numeric( $event ) ) {
424
+ $event = mc_get_event( $event );
425
+ }
426
+ $uri = mc_get_uri( $event );
427
+
428
+ // if available, and not querying remotely, use permalink.
429
+ $permalinks = apply_filters( 'mc_use_permalinks', get_option( 'mc_use_permalinks' ) );
430
+ $permalinks = ( $permalinks === 1 || $permalinks === true || $permalinks === 'true' ) ? true : false;
431
+ $details_link = mc_event_link( $event );
432
+ if ( $event->event_post != 0 && get_option( 'mc_remote' ) != 'true' && $permalinks ) {
433
+ $details_link = add_query_arg( 'mc_id', $event->occur_id, get_permalink( $event->event_post ) );
434
+ } else {
435
+ if ( get_option( 'mc_uri' ) != '' && _mc_is_url( get_option( 'mc_uri' ) ) ) {
436
+ $details_link = mc_build_url( array( 'mc_id' => $event->occur_id ), array(
437
+ 'month',
438
+ 'dy',
439
+ 'yr',
440
+ 'ltype',
441
+ 'loc',
442
+ 'mcat',
443
+ 'format',
444
+ 'feed',
445
+ 'page_id',
446
+ 'p',
447
+ 'mcs',
448
+ 'time',
449
+ 'page'
450
+ ), $uri );
451
+ }
452
+ }
453
+
454
+ return apply_filters( 'mc_customize_details_link', $details_link, $event );
455
+ }
456
+
457
+ /**
458
+ * Get URI from settings
459
+ *
460
+ * @param object $event Event object
461
+ * @param array $args Any arguments passed
462
+ *
463
+ * @uses filter 'mc_get_uri'
464
+ *
465
+ * @return string URL
466
+ */
467
+ function mc_get_uri( $event = false, $args = array() ) {
468
+ // for a brief period of time, mc_uri was a post ID.
469
+ $uri = ( is_numeric( get_option( 'mc_uri' ) ) ) ? get_permalink( get_option( 'mc_uri' ) ) : get_option( 'mc_uri' );
470
+
471
+ return apply_filters( 'mc_get_uri', $uri, $event, $args );
472
+ }
473
+
474
  function mc_get_details_label( $event, $e ) {
475
  $templates = get_option( 'mc_templates' );
476
  $e_template = ( ! empty( $templates['label'] ) ) ? stripcslashes( $templates['label'] ) : sprintf( __( 'Event Details %s', 'my-calendar' ), '<span class="screen-reader-text">about {title}</span> &raquo;' );
492
 
493
  function mc_format_timestamp( $os ) {
494
  if ( get_option( 'mc_ical_utc' ) == 'true' ) {
495
+ $timezone_string = get_option( 'timezone_string' );
496
+ if ( ! $timezone_string ) {
497
+ // multiply gmt_offset by -1 because POSIX has it reversed:
498
+ // http://stackoverflow.com/questions/20228224/php-timezone-issue
499
+ $timezone_string = sprintf("Etc/GMT%+d", -1 * get_option('$gmt_offset') );
500
+ }
501
+
502
+ $timezone_object = timezone_open( $timezone_string );
503
+ $date_object = date_create( null, $timezone_object );
504
+
505
+ $date_object->setTime( date( 'H', $os ), date( 'i', $os ) );
506
+ $date_object->setDate( date( 'Y', $os ), date( 'm', $os ), date( 'd', $os ) );
507
+
508
+ $timestamp = $date_object->getTimestamp( );
509
+ $time = gmdate( "Ymd\THi00", $timestamp ) . "Z";
510
 
511
  } else {
512
+ $os_time = mktime( date( 'H', $os ), date( 'i', $os ), date( 's', $os ), date( 'm', $os ), date( 'd', $os ), date( 'Y', $os ) );
513
+ $time = date( "Ymd\THi00", $os_time );
514
  }
515
 
516
  return $time;
my-calendar-widgets.php CHANGED
@@ -52,6 +52,98 @@ class my_calendar_simple_search extends WP_Widget {
52
  }
53
  }
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  class my_calendar_today_widget extends WP_Widget {
56
 
57
  function __construct() {
@@ -66,7 +158,7 @@ class my_calendar_today_widget extends WP_Widget {
66
  $the_category = ( $instance['my_calendar_today_category'] == '' ) ? 'default' : esc_attr( $instance['my_calendar_today_category'] );
67
  $author = ( ! isset( $instance['my_calendar_today_author'] ) || $instance['my_calendar_today_author'] == '' ) ? 'all' : esc_attr( $instance['my_calendar_today_author'] );
68
  $host = ( ! isset( $instance['mc_host'] ) || $instance['mc_host'] == '' ) ? 'all' : esc_attr( $instance['mc_host'] );
69
- $default_link = ( is_numeric( get_option( 'mc_uri' ) ) ) ? get_permalink( get_option( 'mc_uri' ) ) : get_option( 'mc_uri' );
70
  $widget_link = ( ! empty( $instance['my_calendar_today_linked'] ) && $instance['my_calendar_today_linked'] == 'yes' ) ? $default_link : '';
71
  $widget_link = ( ! empty( $instance['mc_link'] ) ) ? esc_url( $instance['mc_link'] ) : $widget_link;
72
  $widget_title = empty( $the_title ) ? '' : $the_title;
@@ -99,7 +191,7 @@ class my_calendar_today_widget extends WP_Widget {
99
  $widget_linked = ( isset( $instance['my_calendar_today_linked'] ) ) ? esc_attr( $instance['my_calendar_today_linked'] ) : '';
100
  $date = ( isset( $instance['mc_date'] ) ) ? esc_attr( $instance['mc_date'] ) : '';
101
  if ( $widget_linked == 'yes' ) {
102
- $default_link = ( is_numeric( get_option( 'mc_uri' ) ) ) ? get_permalink( get_option( 'mc_uri' ) ) : get_option( 'mc_uri' );
103
  } else {
104
  $default_link = '';
105
  }
@@ -208,7 +300,7 @@ class my_calendar_upcoming_widget extends WP_Widget {
208
  $the_category = ( $instance['my_calendar_upcoming_category'] == '' ) ? 'default' : esc_attr( $instance['my_calendar_upcoming_category'] );
209
  $author = ( ! isset( $instance['my_calendar_upcoming_author'] ) || $instance['my_calendar_upcoming_author'] == '' ) ? 'default' : esc_attr( $instance['my_calendar_upcoming_author'] );
210
  $host = ( ! isset( $instance['mc_host'] ) || $instance['mc_host'] == '' ) ? 'default' : esc_attr( $instance['mc_host'] );
211
- $widget_link = ( isset( $instance['my_calendar_upcoming_linked'] ) && $instance['my_calendar_upcoming_linked'] == 'yes' ) ? get_option( 'mc_uri' ) : '';
212
  $widget_link = ( ! empty( $instance['mc_link'] ) ) ? esc_url( $instance['mc_link'] ) : $widget_link;
213
  $widget_title = empty( $the_title ) ? '' : $the_title;
214
  $widget_title = ( $widget_link == '' ) ? $widget_title : "<a href='$widget_link'>$widget_title</a>";
@@ -250,7 +342,7 @@ class my_calendar_upcoming_widget extends WP_Widget {
250
  $site = ( isset( $instance['mc_site'] ) ) ? esc_attr( $instance['mc_site'] ) : '';
251
 
252
  if ( $linked == 'yes' ) {
253
- $default_link = ( is_numeric( get_option( 'mc_uri' ) ) ) ? get_permalink( get_option( 'mc_uri' ) ) : get_option( 'mc_uri' );
254
  } else {
255
  $default_link = '';
256
  }
52
  }
53
  }
54
 
55
+
56
+ class my_calendar_filters extends WP_Widget {
57
+ function __construct() {
58
+ parent::__construct(
59
+ false,
60
+ $name = __( 'My Calendar: Event Filters', 'my-calendar' ),
61
+ array( 'customize_selective_refresh' => true )
62
+ );
63
+ }
64
+
65
+ function widget( $args, $instance ) {
66
+ extract( $args );
67
+ $widget_title = apply_filters( 'widget_title', $instance['title'], $instance, $args );
68
+ $widget_title = ( $widget_title != '' ) ? $before_title . $widget_title . $after_title : '';
69
+ $widget_url = ( isset( $instance['url'] ) ) ? $instance['url'] : mc_get_uri();
70
+ $ltype = ( isset( $instance['ltype'] ) ) ? $instance['ltype'] : false;
71
+ $show = ( isset( $instance['show'] ) ) ? $instance['show'] : array();
72
+ $show = implode( $show, ',' );
73
+
74
+ echo $before_widget;
75
+ echo ( $instance['title'] != '' ) ? $widget_title : '';
76
+
77
+ echo mc_filters( $show, $widget_url, $ltype );
78
+ echo $after_widget;
79
+ }
80
+
81
+ function form( $instance ) {
82
+ $widget_title = ( isset( $instance['title'] ) ) ? $instance['title'] : '';
83
+ $widget_url = ( isset( $instance['url'] ) ) ? $instance['url'] : mc_get_uri();
84
+ $ltype = ( isset( $instance['ltype'] ) ) ? $instance['ltype'] : false;
85
+ $show = ( isset( $instance['show'] ) ) ? $instance['show'] : array();
86
+
87
+ ?>
88
+ <p>
89
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'my-calendar' ); ?>
90
+ :</label><br/>
91
+ <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'title' ); ?>"
92
+ name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $widget_title ); ?>"/>
93
+ </p>
94
+ <p>
95
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Target Calendar Page', 'my-calendar' ); ?>
96
+ :</label><br/>
97
+ <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'url' ); ?>"
98
+ name="<?php echo $this->get_field_name( 'url' ); ?>" value="<?php echo esc_url( $widget_url ); ?>"/>
99
+ </p>
100
+ <ul>
101
+ <?php $locations = in_array( 'locations', $show ) ? 'checked="checked"' : ''; ?>
102
+ <li>
103
+ <input type="checkbox" id="<?php echo $this->get_field_id( 'show' ); ?>_locations" name="<?php echo $this->get_field_name( 'show' ); ?>[]" value="locations" <?php echo $locations; ?> /> <label for="<?php echo $this->get_field_id( 'show' ); ?>_locations"><?php _e( "Locations", 'my-calendar' ); ?></label>
104
+ </li>
105
+ <?php $categories = in_array( 'categories', $show ) ? 'checked="checked"' : ''; ?>
106
+ <li>
107
+ <input type="checkbox" id="<?php echo $this->get_field_id( 'show' ); ?>_categories" name="<?php echo $this->get_field_name( 'show' ); ?>[]" value="categories" <?php echo $categories; ?> /> <label for="<?php echo $this->get_field_id( 'show' ); ?>_categories"><?php _e( "Categories", 'my-calendar' ); ?></label>
108
+ </li>
109
+ <?php $access = in_array( 'access', $show ) ? 'checked="checked"' : ''; ?>
110
+ <li>
111
+ <input type="checkbox" id="<?php echo $this->get_field_id( 'show' ); ?>_access" name="<?php echo $this->get_field_name( 'show' ); ?>[]" value="access" <?php echo $access; ?> /> <label for="<?php echo $this->get_field_id( 'show' ); ?>_access"><?php _e( "Accessibility Features", 'my-calendar' ); ?></label>
112
+ </li>
113
+ </ul>
114
+ <p>
115
+ <label
116
+ for="<?php echo $this->get_field_id( 'ltype' ); ?>"><?php _e( 'Filter locations by', 'my-calendar' ); ?></label>
117
+ <select id="<?php echo $this->get_field_id( 'ltype' ); ?>"
118
+ name="<?php echo $this->get_field_name( 'ltype' ); ?>">
119
+ <option
120
+ value="name" <?php selected( $ltype, 'name' ); ?>><?php _e( 'Location Name', 'my-calendar' ) ?></option>
121
+ <option
122
+ value="state" <?php selected( $ltype, 'state' ); ?>><?php _e( 'State/Province', 'my-calendar' ) ?></option>
123
+ <option
124
+ value="city" <?php selected( $ltype, 'city' ); ?>><?php _e( 'City', 'my-calendar' ) ?></option>
125
+ <option
126
+ value="region" <?php selected( $ltype, 'region' ); ?>><?php _e( 'Region', 'my-calendar' ) ?></option>
127
+ <option
128
+ value="zip" <?php selected( $ltype, 'zip' ); ?>><?php _e( 'Postal Code', 'my-calendar' ) ?></option>
129
+ <option
130
+ value="country" <?php selected( $ltype, 'country' ); ?>><?php _e( 'Country', 'my-calendar' ) ?></option>
131
+ </select>
132
+ </p>
133
+ <?php
134
+ }
135
+
136
+ function update( $new, $old ) {
137
+ $instance = $old;
138
+ $instance['title'] = mc_kses_post( $new['title'] );
139
+ $instance['url'] = esc_url_raw( $new['url'] );
140
+ $instance['ltype'] = sanitize_title( $new['ltype'] );
141
+ $instance['show'] = array_map( 'sanitize_title', $new['show'] );
142
+
143
+ return $instance;
144
+ }
145
+ }
146
+
147
  class my_calendar_today_widget extends WP_Widget {
148
 
149
  function __construct() {
158
  $the_category = ( $instance['my_calendar_today_category'] == '' ) ? 'default' : esc_attr( $instance['my_calendar_today_category'] );
159
  $author = ( ! isset( $instance['my_calendar_today_author'] ) || $instance['my_calendar_today_author'] == '' ) ? 'all' : esc_attr( $instance['my_calendar_today_author'] );
160
  $host = ( ! isset( $instance['mc_host'] ) || $instance['mc_host'] == '' ) ? 'all' : esc_attr( $instance['mc_host'] );
161
+ $default_link = mc_get_uri( false, $args );
162
  $widget_link = ( ! empty( $instance['my_calendar_today_linked'] ) && $instance['my_calendar_today_linked'] == 'yes' ) ? $default_link : '';
163
  $widget_link = ( ! empty( $instance['mc_link'] ) ) ? esc_url( $instance['mc_link'] ) : $widget_link;
164
  $widget_title = empty( $the_title ) ? '' : $the_title;
191
  $widget_linked = ( isset( $instance['my_calendar_today_linked'] ) ) ? esc_attr( $instance['my_calendar_today_linked'] ) : '';
192
  $date = ( isset( $instance['mc_date'] ) ) ? esc_attr( $instance['mc_date'] ) : '';
193
  if ( $widget_linked == 'yes' ) {
194
+ $default_link = mc_get_uri( false, $instance );
195
  } else {
196
  $default_link = '';
197
  }
300
  $the_category = ( $instance['my_calendar_upcoming_category'] == '' ) ? 'default' : esc_attr( $instance['my_calendar_upcoming_category'] );
301
  $author = ( ! isset( $instance['my_calendar_upcoming_author'] ) || $instance['my_calendar_upcoming_author'] == '' ) ? 'default' : esc_attr( $instance['my_calendar_upcoming_author'] );
302
  $host = ( ! isset( $instance['mc_host'] ) || $instance['mc_host'] == '' ) ? 'default' : esc_attr( $instance['mc_host'] );
303
+ $widget_link = ( isset( $instance['my_calendar_upcoming_linked'] ) && $instance['my_calendar_upcoming_linked'] == 'yes' ) ? mc_get_uri( false, $instance ) : '';
304
  $widget_link = ( ! empty( $instance['mc_link'] ) ) ? esc_url( $instance['mc_link'] ) : $widget_link;
305
  $widget_title = empty( $the_title ) ? '' : $the_title;
306
  $widget_title = ( $widget_link == '' ) ? $widget_title : "<a href='$widget_link'>$widget_title</a>";
342
  $site = ( isset( $instance['mc_site'] ) ) ? esc_attr( $instance['mc_site'] ) : '';
343
 
344
  if ( $linked == 'yes' ) {
345
+ $default_link = mc_get_uri( false, $instance );
346
  } else {
347
  $default_link = '';
348
  }
my-calendar.php CHANGED
@@ -7,7 +7,7 @@ Author: Joseph C Dolson
7
  Author URI: http://www.joedolson.com
8
  Text Domain: my-calendar
9
  Domain Path: lang
10
- Version: 2.5.9
11
  */
12
  /* Copyright 2009-2017 Joe Dolson (email : joe@joedolson.com)
13
 
@@ -30,7 +30,7 @@ if ( ! defined( 'ABSPATH' ) ) {
30
  } // Exit if accessed directly
31
 
32
  global $mc_version, $wpdb;
33
- $mc_version = '2.5.9';
34
 
35
  register_activation_hook( __FILE__, 'mc_plugin_activated' );
36
  register_deactivation_hook( __FILE__, 'mc_plugin_deactivated' );
@@ -42,6 +42,18 @@ function mc_plugin_activated() {
42
  check_my_calendar();
43
  }
44
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  function mc_plugin_deactivated() {
46
  flush_rewrite_rules();
47
  }
@@ -87,6 +99,7 @@ add_action( 'widgets_init', create_function( '', 'return register_widget("my_cal
87
  add_action( 'widgets_init', create_function( '', 'return register_widget("my_calendar_upcoming_widget");' ) );
88
  add_action( 'widgets_init', create_function( '', 'return register_widget("my_calendar_mini_widget");' ) );
89
  add_action( 'widgets_init', create_function( '', 'return register_widget("my_calendar_simple_search");' ) );
 
90
  add_action( 'init', 'my_calendar_add_feed' );
91
  add_action( 'admin_menu', 'my_calendar_admin_js' );
92
  add_action( 'wp_footer', 'mc_footer_js' );
7
  Author URI: http://www.joedolson.com
8
  Text Domain: my-calendar
9
  Domain Path: lang
10
+ Version: 2.5.10
11
  */
12
  /* Copyright 2009-2017 Joe Dolson (email : joe@joedolson.com)
13
 
30
  } // Exit if accessed directly
31
 
32
  global $mc_version, $wpdb;
33
+ $mc_version = '2.5.10';
34
 
35
  register_activation_hook( __FILE__, 'mc_plugin_activated' );
36
  register_deactivation_hook( __FILE__, 'mc_plugin_deactivated' );
42
  check_my_calendar();
43
  }
44
 
45
+ register_activation_hook(__FILE__, 'mc_activation_hook');
46
+ function mc_activation_hook() {
47
+ $required_php_version = '5.3.0';
48
+
49
+ if ( version_compare( PHP_VERSION, $required_php_version, '<' ) ) {
50
+ $plugin_data = get_plugin_data(__FILE__, false);
51
+ $message = sprintf( __( '%s requires PHP version %s or higher. Your current PHP version is %s', 'my-calendar' ), $plugin_data['Name'], $required_php_version, phpversion() );
52
+ echo "<p>{$message}</p>";
53
+ exit;
54
+ }
55
+ }
56
+
57
  function mc_plugin_deactivated() {
58
  flush_rewrite_rules();
59
  }
99
  add_action( 'widgets_init', create_function( '', 'return register_widget("my_calendar_upcoming_widget");' ) );
100
  add_action( 'widgets_init', create_function( '', 'return register_widget("my_calendar_mini_widget");' ) );
101
  add_action( 'widgets_init', create_function( '', 'return register_widget("my_calendar_simple_search");' ) );
102
+ add_action( 'widgets_init', create_function( '', 'return register_widget("my_calendar_filters");' ) );
103
  add_action( 'init', 'my_calendar_add_feed' );
104
  add_action( 'admin_menu', 'my_calendar_admin_js' );
105
  add_action( 'wp_footer', 'mc_footer_js' );
readme.txt CHANGED
@@ -16,9 +16,9 @@ My Calendar does WordPress event management with richly customizable ways to dis
16
 
17
  Easy to use for anybody, My Calendar provides enormous flexibility for designers and developers needing a custom calendar.
18
 
19
- * [Buy the User's Guide](http://www.joedolson.com/my-calendar/users-guide/) for extensive help with set up and use.
20
  * [Buy My Calendar Pro](https://www.joedolson.com/my-calendar/pro/), the premium extension for My Calendar
21
- * [Use My Tickets](https://wordpress.org/plugins/my-tickets/) and sell tickets to your My Calendar events
 
22
 
23
  = Features: =
24
 
@@ -83,6 +83,26 @@ Translating my plug-ins is always appreciated. Visit <a href="https://translate.
83
 
84
  == Changelog ==
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  = 2.5.9 =
87
 
88
  * Bug fix: class .mc-main appeared twice in day view
@@ -824,7 +844,7 @@ Because the majority of users end up on my web site asking for help anyway -- an
824
 
825
  = This plug-in is really complicated. Why can't you personally help me figure out how to use it? =
826
 
827
- I can! Just not in person. I've written a User's Guide for My Calendar, which you can [purchase at my web site](https://www.joedolson.com/my-calendar/users-guide/) for $25. This helps defray the thousands of hours I've spent developing the plug-in and providing support. Please, consider buying the User's Guide or [making a donation](https://www.joedolson.com/donate.php) before asking for support!
828
 
829
  = Can my visitors or members submit events? =
830
 
16
 
17
  Easy to use for anybody, My Calendar provides enormous flexibility for designers and developers needing a custom calendar.
18
 
 
19
  * [Buy My Calendar Pro](https://www.joedolson.com/my-calendar/pro/), the premium extension for My Calendar
20
+ * [Use My Tickets](https://wordpress.org/plugins/my-tickets/) and sell tickets for My Calendar events
21
+ * [Buy the User's Guide](http://www.joedolson.com/my-calendar/users-guide/) for extensive help with set up and use.
22
 
23
  = Features: =
24
 
83
 
84
  == Changelog ==
85
 
86
+ = 2.5.10 =
87
+
88
+ * Bug fix: allow parsing of non-English strings through strtotime()
89
+ * Bug fix: trim whitespace off array keys in location controller
90
+ * Bug fix: Don't display 'Add Event' menu in adminbar if remote event database is enabled
91
+ * Bug fix: All day events correctly exported in iCal files
92
+ * Bug fix: Footer navigation not shown on single day view
93
+ * Bug fix: Execute AJAX navigation from both header and footer containers
94
+ * Bug fix: {icon_html} returned broken image if category had no assigned icon
95
+ * Removed obsolete PHP 4 compatibility for clone keyword
96
+ * Added hook to prevent activation if PHP version below 5.3.0.
97
+ * New filter: define custom target calendar URL via 'mc_get_uri' filter
98
+ * New action: 'mc_insert_recurring' run while creating event instances
99
+ * New filter to customize default event length: 'mc_default_event_length'
100
+ * New filter: 'mc_show_week_number' to turn on column indicating displayed week's number. (props Josef Fällman)
101
+ * UI Change: Duplicate navigation and search on events list at bottom of list
102
+ * Miscellaneous improvements to the My Calendar Filters shortcode: set target URL & change location search type, add as widget
103
+ * New widget: My Calendar event filters
104
+ * Added inverse color style declaration to category color template tag
105
+
106
  = 2.5.9 =
107
 
108
  * Bug fix: class .mc-main appeared twice in day view
844
 
845
  = This plug-in is really complicated. Why can't you personally help me figure out how to use it? =
846
 
847
+ I can! But not in person. I've written a User's Guide for My Calendar, which you can [purchase at my web site](https://www.joedolson.com/my-calendar/users-guide/) for $25. This helps defray the thousands of hours I've spent developing the plug-in and providing support. Please, consider buying the User's Guide or [making a donation](https://www.joedolson.com/donate.php) before asking for support!
848
 
849
  = Can my visitors or members submit events? =
850