Event List - Version 0.4.1

Version Description

(2013-05-31) =

  • fixed deleting of categories
  • fixed url to calendar icon in new/edit event form
  • fixed date format localization in new/edit event form
  • added some widget options
  • only show links in widget if all required info are available
  • small security improvements
Download this release

Release Info

Developer mibuthu
Plugin Icon 128x128 Event List
Version 0.4.1
Comparing to
See all releases

Code changes from version 0.4.0 to 0.4.1

admin/admin.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  require_once( EL_PATH.'includes/db.php' );
3
  require_once( EL_PATH.'includes/options.php' );
4
  require_once( EL_PATH.'includes/sc_event-list.php' );
@@ -11,7 +15,6 @@ class EL_Admin {
11
  private $options;
12
  private $shortcode;
13
  private $categories;
14
- private $dateformat;
15
  private $event_action = false;
16
  private $event_action_error = false;
17
 
@@ -20,8 +23,6 @@ class EL_Admin {
20
  $this->options = &EL_Options::get_instance();
21
  $this->shortcode = &SC_Event_List::get_instance();
22
  $this->categories = &EL_Categories::get_instance();
23
- $this->dateformat = __( 'Y/m/d' ); // similar date format than in list tables (e.g. post, pages, media)
24
- // $this->dateformat = 'd/m/Y'; // for debugging only
25
  $this->event_action = null;
26
  $this->event_action_error = null;
27
  }
@@ -49,7 +50,7 @@ class EL_Admin {
49
  $action = '';
50
  // is there POST data an event was edited must be updated
51
  if( !empty( $_POST ) ) {
52
- $this->event_action_error = !$this->db->update_event( $_POST, $this->dateformat );
53
  $this->event_action = isset( $_POST['id'] ) ? 'modified' : 'added';
54
  }
55
  // get action
@@ -121,7 +122,7 @@ class EL_Admin {
121
  $slug_array = explode(', ', $_GET['slug'] );
122
  $num_affected_events = $this->db->remove_category_in_events( $slug_array );
123
  require_once( EL_PATH.'admin/includes/category_table.php' );
124
- if( $this->categories->remove_category( $slug_array ) ) {
125
  $out .= '<div id="message" class="updated">
126
  <p><strong>'.sprintf( __( 'Category %s was deleted).<br />This Category was also removed in %d events.' ), $_GET['slug'], $num_affected_events ).'</strong></p>
127
  </div>';
@@ -238,7 +239,7 @@ class EL_Admin {
238
 
239
  // Add required data for javascript in a hidden field
240
  $json = json_encode( array( 'el_url' => EL_URL,
241
- 'el_date_format' => $this->datepicker_format( $this->dateformat ) ) );
242
  $out = '
243
  <form method="POST" action="?page=el_admin_main">';
244
  $out .= "
@@ -261,8 +262,8 @@ class EL_Admin {
261
  </tr>
262
  <tr>
263
  <th><label>Event Date (required)</label></th>
264
- <td><input type="text" class="text datepicker form-required" name="start_date" id="start_date" value="'.date_i18n( $this->dateformat, $start_date ).'" />
265
- <span id="end_date_area"> - <input type="text" class="text datepicker" name="end_date" id="end_date" value="'.date_i18n( $this->dateformat, $end_date ).'" /></span>
266
  <label><input type="checkbox" name="multiday" id="multiday" value="1" /> Multi-Day Event</label></td>
267
  </tr>
268
  <tr>
1
  <?php
2
+ if( !defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
  require_once( EL_PATH.'includes/db.php' );
7
  require_once( EL_PATH.'includes/options.php' );
8
  require_once( EL_PATH.'includes/sc_event-list.php' );
15
  private $options;
16
  private $shortcode;
17
  private $categories;
 
18
  private $event_action = false;
19
  private $event_action_error = false;
20
 
23
  $this->options = &EL_Options::get_instance();
24
  $this->shortcode = &SC_Event_List::get_instance();
25
  $this->categories = &EL_Categories::get_instance();
 
 
26
  $this->event_action = null;
27
  $this->event_action_error = null;
28
  }
50
  $action = '';
51
  // is there POST data an event was edited must be updated
52
  if( !empty( $_POST ) ) {
53
+ $this->event_action_error = !$this->db->update_event( $_POST, __( 'Y/m/d' ) );
54
  $this->event_action = isset( $_POST['id'] ) ? 'modified' : 'added';
55
  }
56
  // get action
122
  $slug_array = explode(', ', $_GET['slug'] );
123
  $num_affected_events = $this->db->remove_category_in_events( $slug_array );
124
  require_once( EL_PATH.'admin/includes/category_table.php' );
125
+ if( $this->categories->remove_categories( $slug_array ) ) {
126
  $out .= '<div id="message" class="updated">
127
  <p><strong>'.sprintf( __( 'Category %s was deleted).<br />This Category was also removed in %d events.' ), $_GET['slug'], $num_affected_events ).'</strong></p>
128
  </div>';
239
 
240
  // Add required data for javascript in a hidden field
241
  $json = json_encode( array( 'el_url' => EL_URL,
242
+ 'el_date_format' => $this->datepicker_format( __( 'Y/m/d' ) ) ) );
243
  $out = '
244
  <form method="POST" action="?page=el_admin_main">';
245
  $out .= "
262
  </tr>
263
  <tr>
264
  <th><label>Event Date (required)</label></th>
265
+ <td><input type="text" class="text datepicker form-required" name="start_date" id="start_date" value="'.date_i18n( __( 'Y/m/d' ), $start_date ).'" />
266
+ <span id="end_date_area"> - <input type="text" class="text datepicker" name="end_date" id="end_date" value="'.date_i18n( __( 'Y/m/d' ), $end_date ).'" /></span>
267
  <label><input type="checkbox" name="multiday" id="multiday" value="1" /> Multi-Day Event</label></td>
268
  </tr>
269
  <tr>
admin/includes/category_table.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  // load the base class (WP_List_Table class isn't automatically available)
3
  if(!class_exists('WP_List_Table')){
4
  require_once( ABSPATH.'wp-admin/includes/class-wp-list-table.php' );
1
  <?php
2
+ if( !defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
  // load the base class (WP_List_Table class isn't automatically available)
7
  if(!class_exists('WP_List_Table')){
8
  require_once( ABSPATH.'wp-admin/includes/class-wp-list-table.php' );
admin/includes/event_table.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  // load the base class (WP_List_Table class isn't automatically available)
3
  if(!class_exists('WP_List_Table')){
4
  require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
1
  <?php
2
+ if( !defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
  // load the base class (WP_List_Table class isn't automatically available)
7
  if(!class_exists('WP_List_Table')){
8
  require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
admin/js/admin_new.js CHANGED
@@ -22,13 +22,12 @@ jQuery(document).ready(function( $ ) {
22
  changeYear: true,
23
  numberOfMonths: 3,
24
  showOn: "both",
25
- buttonImage: conf.el_url + "images/calendar-icon.png",
26
  buttonImageOnly: true,
27
  constrainInput: true,
28
  onClose: function(selectedDate) {
29
- minDate = new Date(selectedDate);
30
- timestamp = minDate.getTime() + 1*24*60*60*1000;
31
- minDate.setTime(timestamp);
32
  $("#end_date").datepicker("option", "minDate", minDate);
33
  }
34
  });
@@ -39,7 +38,7 @@ jQuery(document).ready(function( $ ) {
39
  changeYear: true,
40
  numberOfMonths: 3,
41
  showOn: "both",
42
- buttonImage: conf.el_url + "images/calendar-icon.png",
43
  buttonImageOnly: true,
44
  constrainInput: true
45
  });
22
  changeYear: true,
23
  numberOfMonths: 3,
24
  showOn: "both",
25
+ buttonImage: conf.el_url + "admin/images/calendar-icon.png",
26
  buttonImageOnly: true,
27
  constrainInput: true,
28
  onClose: function(selectedDate) {
29
+ minDate = $.datepicker.parseDate( conf.el_date_format, selectedDate );
30
+ minDate.setDate(minDate.getDate()+1);
 
31
  $("#end_date").datepicker("option", "minDate", minDate);
32
  }
33
  });
38
  changeYear: true,
39
  numberOfMonths: 3,
40
  showOn: "both",
41
+ buttonImage: conf.el_url + "admin/images/calendar-icon.png",
42
  buttonImageOnly: true,
43
  constrainInput: true
44
  });
event-list.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Event List
4
  Plugin URI: http://wordpress.org/extend/plugins/event-list/
5
  Description: Manage your events and show them in a list view on your site.
6
- Version: 0.4.0
7
  Author: Michael Burtscher
8
  Author URI: http://wordpress.org/extend/plugins/event-list/
9
  License: GPLv2
@@ -25,6 +25,10 @@ You can view a copy of the HTML version of the GNU General Public
25
  License at http://www.gnu.org/copyleft/gpl.html
26
  */
27
 
 
 
 
 
28
  // GENERAL DEFINITIONS
29
  define( 'EL_URL', plugin_dir_url( __FILE__ ) );
30
  define( 'EL_PATH', plugin_dir_path( __FILE__ ) );
3
  Plugin Name: Event List
4
  Plugin URI: http://wordpress.org/extend/plugins/event-list/
5
  Description: Manage your events and show them in a list view on your site.
6
+ Version: 0.4.1
7
  Author: Michael Burtscher
8
  Author URI: http://wordpress.org/extend/plugins/event-list/
9
  License: GPLv2
25
  License at http://www.gnu.org/copyleft/gpl.html
26
  */
27
 
28
+ if( !defined( 'ABSPATH' ) ) {
29
+ exit;
30
+ }
31
+
32
  // GENERAL DEFINITIONS
33
  define( 'EL_URL', plugin_dir_url( __FILE__ ) );
34
  define( 'EL_PATH', plugin_dir_path( __FILE__ ) );
includes/categories.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  require_once( EL_PATH.'includes/options.php' );
3
 
4
  // Class to manage categories
1
  <?php
2
+ if( !defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
  require_once( EL_PATH.'includes/options.php' );
7
 
8
  // Class to manage categories
includes/db.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  require_once( EL_PATH.'includes/options.php' );
3
 
4
  // Class for database access via wordpress functions
1
  <?php
2
+ if( !defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
  require_once( EL_PATH.'includes/options.php' );
7
 
8
  // Class for database access via wordpress functions
includes/options.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  // This class handles all available options
4
  class EL_Options {
1
  <?php
2
+ if( !defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
 
6
  // This class handles all available options
7
  class EL_Options {
includes/sc_event-list.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  require_once( EL_PATH.'includes/db.php' );
3
  require_once( EL_PATH.'includes/options.php' );
4
  require_once( EL_PATH.'includes/categories.php' );
@@ -30,78 +34,99 @@ class SC_Event_List {
30
  // All available attributes
31
  $this->atts = array(
32
 
33
- 'initial_date' => array( 'val' => 'upcoming<br />year e.g. "2013"',
34
- 'std_val' => 'upcoming',
35
- 'visible' => true,
36
- 'desc' => 'This attribute specifies which events are initially shown. The standard is to show the upcoming events.<br />
37
- Specify a year e.g. "2013" to change this behavior.' ),
38
-
39
- 'cat_filter' => array( 'val' => 'none<br />category slug',
40
- 'std_val' => 'none',
41
- 'visible' => true,
42
- 'desc' => 'This attribute specifies events of which categories are shown. The standard is "none" to show all events.<br />
43
- Specify a category slug or a list of category slugs separated by a comma "," e.g. "tennis,hockey" to only show events of the specified categories.' ),
44
-
45
- 'num_events' => array( 'val' => 'number',
46
- 'std_val' => '0',
47
- 'visible' => true,
48
- 'desc' => 'This attribute specifies how many events should be displayed if upcoming events is selected.<br />
49
- 0 is the standard value which means that all events will be displayed.' ),
50
-
51
- 'show_nav' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
52
- 'std_val' => 'true',
53
- 'visible' => true,
54
- 'desc' => 'This attribute specifies if the calendar navigation should be displayed.<br />
55
- Choose "false" to always hide and "true" to always show the navigation.<br />
56
- With "event_list_only" the navigation is only visible in the event list and with "single_event_only" only for a single event'),
57
-
58
- 'show_location' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
59
- 'std_val' => 'true',
60
- 'visible' => true,
61
- 'desc' => 'This attribute specifies if the location is displayed in the event list.<br />
62
- Choose "false" to always hide and "true" to always show the location.<br />
63
- With "event_list_only" the location is only visible in the event list and with "single_event_only" only for a single event'),
64
-
65
- 'show_cat' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
66
- 'std_val' => 'false',
67
- 'visible' => true,
68
- 'desc' => 'This attribute specifies if the categories are displayed in the event list.<br />
69
- Choose "false" to always hide and "true" to always show the category.<br />
70
- With "event_list_only" the categories are only visible in the event list and with "single_event_only" only for a single event'),
71
-
72
- 'show_details' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
73
- 'std_val' => 'true',
74
- 'visible' => true,
75
- 'desc' => 'This attribute specifies if the details are displayed in the event list.<br />
76
- Choose "false" to always hide and "true" to always show the details.<br />
77
- With "event_list_only" the details are only visible in the event list and with "single_event_only" only for a single event'),
78
-
79
- 'details_length' => array( 'val' => 'number',
80
- 'std_val' => '0',
81
- 'visible' => true,
82
- 'desc' => 'This attribute specifies if the details should be truncate to the given number of character in the event list.<br />
83
- With the standard value 0 the full details are displayed.<br />
84
- This attribute has no influence if only a single event is shown.'),
85
-
86
- 'link_to_event' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
87
- 'std_val' => 'event_list_only',
88
- 'visible' => true,
89
- 'desc' => 'This attribute specifies if a link to the single event should be added onto the event name in the event list.<br />
90
- Choose "false" to never add and "true" to always add the link.<br />
91
- With "event_list_only" the link is only added in the event list and with "single_event_only" only for a single event'),
 
 
 
 
 
 
 
92
  // Invisible attributes ('visibe' = false): This attributes are required for the widget but will not be listed in the attributes table on the admin info page
93
- 'url_to_page' => array( 'val' => 'url',
94
- 'std_val' => '',
95
- 'visible' => false,
96
- 'desc' => 'This attribute specifies that the link should follow the given url.<br />
97
- The standard is to leave this attribute empty, then the url will be calculated automatically from the actual page or post url.<br />
98
- This is o.k. for the normal use of the shortcode. This attribute is normally only required for the event-list widget.' ),
99
-
100
- 'sc_id_for_url' => array( 'val' => 'number',
101
- 'std_val' => '',
102
- 'visible' => false,
103
- 'desc' => 'This attribute the specifies shortcode id of the used shortcode on the page specified with "url_to_page" attribute.<br />
104
- The empty standard value is o.k. for the normal use. This attribute is normally only required for the event-list widget.' )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  // Internal attributes: This parameters will be added by the script and are not available in the shortcode
106
  // 'sc_id'
107
  // 'ytd'
@@ -203,6 +228,7 @@ class SC_Event_List {
203
  }
204
 
205
  private function html_event( &$event, &$a, $single_day_only=false ) {
 
206
  $out = '
207
  <li class="event">';
208
  $out .= $this->html_fulldate( $event->start_date, $event->end_date, $single_day_only );
@@ -215,14 +241,16 @@ class SC_Event_List {
215
  $out .= ' multi-day';
216
  }
217
  $out .= '"><h3>';
 
 
218
  if( $this->is_visible( $a['link_to_event'] ) ) {
219
- $out .= '<a href="'.$this->get_url( $a ).'event_id_'.$a['sc_id_for_url'].'='.$event->id.'">'.$event->title.'</a>';
220
  }
221
  else {
222
- $out .= $event->title;
223
  }
224
  $out .= '</h3>';
225
- if( $event->time != '' ) {
226
  // set time format if a known format is available, else only show the text
227
  $date_array = date_parse( $event->time );
228
  if( empty( $date_array['errors']) && is_numeric( $date_array['hour'] ) && is_numeric( $date_array['minute'] ) ) {
@@ -231,19 +259,13 @@ class SC_Event_List {
231
  $out .= '<span class="event-time">'.$event->time.'</span>';
232
  }
233
  if( $this->is_visible( $a['show_location'] ) ) {
234
- $out .= '<span class="event-location">'.$event->location.'</span>';
235
  }
236
  if( $this->is_visible( $a['show_cat'] ) ) {
237
  $out .= '<div class="event-cat">'.$this->categories->get_category_string( $event->categories ).'</div>';
238
  }
239
  if( $this->is_visible( $a['show_details'] ) ) {
240
- if( is_numeric( $a['event_id'] ) || 0 >= $a['details_length'] ) {
241
- $details = $event->details;
242
- }
243
- else {
244
- $details = $this->db->truncate( $a['details_length'], $event->details );
245
- }
246
- $out .= '<div class="event-details">'.do_shortcode( $details ).'</div>';
247
  }
248
  $out .= '</div>
249
  </li>';
1
  <?php
2
+ if( !defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
  require_once( EL_PATH.'includes/db.php' );
7
  require_once( EL_PATH.'includes/options.php' );
8
  require_once( EL_PATH.'includes/categories.php' );
34
  // All available attributes
35
  $this->atts = array(
36
 
37
+ 'initial_date' => array( 'val' => 'upcoming<br />year e.g. "2013"',
38
+ 'std_val' => 'upcoming',
39
+ 'visible' => true,
40
+ 'desc' => 'This attribute specifies which events are initially shown. The standard is to show the upcoming events.<br />
41
+ Specify a year e.g. "2013" to change this behavior.' ),
42
+
43
+ 'cat_filter' => array( 'val' => 'none<br />category slug',
44
+ 'std_val' => 'none',
45
+ 'visible' => true,
46
+ 'desc' => 'This attribute specifies events of which categories are shown. The standard is "none" to show all events.<br />
47
+ Specify a category slug or a list of category slugs separated by a comma "," e.g. "tennis,hockey" to only show events of the specified categories.' ),
48
+
49
+ 'num_events' => array( 'val' => 'number',
50
+ 'std_val' => '0',
51
+ 'visible' => true,
52
+ 'desc' => 'This attribute specifies how many events should be displayed if upcoming events is selected.<br />
53
+ 0 is the standard value which means that all events will be displayed.' ),
54
+
55
+ 'show_nav' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
56
+ 'std_val' => 'true',
57
+ 'visible' => true,
58
+ 'desc' => 'This attribute specifies if the calendar navigation should be displayed.<br />
59
+ Choose "false" to always hide and "true" to always show the navigation.<br />
60
+ With "event_list_only" the navigation is only visible in the event list and with "single_event_only" only for a single event'),
61
+
62
+ 'show_starttime' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
63
+ 'std_val' => 'true',
64
+ 'visible' => true,
65
+ 'desc' => 'This attribute specifies if the starttime is displayed in the event list.<br />
66
+ Choose "false" to always hide and "true" to always show the starttime.<br />
67
+ With "event_list_only" the starttime is only visible in the event list and with "single_event_only" only for a single event'),
68
+
69
+ 'show_location' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
70
+ 'std_val' => 'true',
71
+ 'visible' => true,
72
+ 'desc' => 'This attribute specifies if the location is displayed in the event list.<br />
73
+ Choose "false" to always hide and "true" to always show the location.<br />
74
+ With "event_list_only" the location is only visible in the event list and with "single_event_only" only for a single event'),
75
+
76
+ 'show_cat' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
77
+ 'std_val' => 'false',
78
+ 'visible' => true,
79
+ 'desc' => 'This attribute specifies if the categories are displayed in the event list.<br />
80
+ Choose "false" to always hide and "true" to always show the category.<br />
81
+ With "event_list_only" the categories are only visible in the event list and with "single_event_only" only for a single event'),
82
+
83
+ 'show_details' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
84
+ 'std_val' => 'true',
85
+ 'visible' => true,
86
+ 'desc' => 'This attribute specifies if the details are displayed in the event list.<br />
87
+ Choose "false" to always hide and "true" to always show the details.<br />
88
+ With "event_list_only" the details are only visible in the event list and with "single_event_only" only for a single event'),
89
+
90
+ 'details_length' => array( 'val' => 'number',
91
+ 'std_val' => '0',
92
+ 'visible' => true,
93
+ 'desc' => 'This attribute specifies if the details should be truncate to the given number of character in the event list.<br />
94
+ With the standard value 0 the full details are displayed.<br />
95
+ This attribute has no influence if only a single event is shown.'),
96
+
97
+ 'link_to_event' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
98
+ 'std_val' => 'event_list_only',
99
+ 'visible' => true,
100
+ 'desc' => 'This attribute specifies if a link to the single event should be added onto the event name in the event list.<br />
101
+ Choose "false" to never add and "true" to always add the link.<br />
102
+ With "event_list_only" the link is only added in the event list and with "single_event_only" only for a single event'),
103
  // Invisible attributes ('visibe' = false): This attributes are required for the widget but will not be listed in the attributes table on the admin info page
104
+ 'title_length' => array( 'val' => 'number',
105
+ 'std_val' => '0',
106
+ 'visible' => false,
107
+ 'desc' => 'This attribute specifies if the title should be truncate to the given number of character in the event list.<br />
108
+ With the standard value 0 the full details are displayed.<br />
109
+ This attribute has no influence if only a single event is shown.'),
110
+
111
+ 'location_length' => array( 'val' => 'number',
112
+ 'std_val' => '0',
113
+ 'visible' => false,
114
+ 'desc' => 'This attribute specifies if the title should be truncate to the given number of character in the event list.<br />
115
+ With the standard value 0 the full details are displayed.<br />
116
+ This attribute has no influence if only a single event is shown.'),
117
+
118
+ 'url_to_page' => array( 'val' => 'url',
119
+ 'std_val' => '',
120
+ 'visible' => false,
121
+ 'desc' => 'This attribute specifies that the link should follow the given url.<br />
122
+ The standard is to leave this attribute empty, then the url will be calculated automatically from the actual page or post url.<br />
123
+ This is o.k. for the normal use of the shortcode. This attribute is normally only required for the event-list widget.' ),
124
+
125
+ 'sc_id_for_url' => array( 'val' => 'number',
126
+ 'std_val' => '',
127
+ 'visible' => false,
128
+ 'desc' => 'This attribute the specifies shortcode id of the used shortcode on the page specified with "url_to_page" attribute.<br />
129
+ The empty standard value is o.k. for the normal use. This attribute is normally only required for the event-list widget.' ),
130
  // Internal attributes: This parameters will be added by the script and are not available in the shortcode
131
  // 'sc_id'
132
  // 'ytd'
228
  }
229
 
230
  private function html_event( &$event, &$a, $single_day_only=false ) {
231
+ $max_length = is_numeric( $a['event_id'] ) ? 0 : 999999;
232
  $out = '
233
  <li class="event">';
234
  $out .= $this->html_fulldate( $event->start_date, $event->end_date, $single_day_only );
241
  $out .= ' multi-day';
242
  }
243
  $out .= '"><h3>';
244
+
245
+ $title = $this->db->truncate( min( $max_length, $a['title_length'] ), $event->title );
246
  if( $this->is_visible( $a['link_to_event'] ) ) {
247
+ $out .= '<a href="'.$this->get_url( $a ).'event_id_'.$a['sc_id_for_url'].'='.$event->id.'">'.$title.'</a>';
248
  }
249
  else {
250
+ $out .= $title;
251
  }
252
  $out .= '</h3>';
253
+ if( $event->time != '' && $this->is_visible( $a['show_starttime'] ) ) {
254
  // set time format if a known format is available, else only show the text
255
  $date_array = date_parse( $event->time );
256
  if( empty( $date_array['errors']) && is_numeric( $date_array['hour'] ) && is_numeric( $date_array['minute'] ) ) {
259
  $out .= '<span class="event-time">'.$event->time.'</span>';
260
  }
261
  if( $this->is_visible( $a['show_location'] ) ) {
262
+ $out .= '<span class="event-location">'.$this->db->truncate( min( $max_length, $a['location_length'] ), $event->location ).'</span>';
263
  }
264
  if( $this->is_visible( $a['show_cat'] ) ) {
265
  $out .= '<div class="event-cat">'.$this->categories->get_category_string( $event->categories ).'</div>';
266
  }
267
  if( $this->is_visible( $a['show_details'] ) ) {
268
+ $out .= '<div class="event-details">'.$this->db->truncate( min( $max_length, $a['details_length'] ), do_shortcode( $event->details ) ).'</div>';
 
 
 
 
 
 
269
  }
270
  $out .= '</div>
271
  </li>';
includes/widget.php CHANGED
@@ -1,9 +1,15 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Event List Widget
4
  */
5
  class EL_Widget extends WP_Widget {
6
 
 
 
7
  /**
8
  * Register widget with WordPress.
9
  */
@@ -13,6 +19,100 @@ class EL_Widget extends WP_Widget {
13
  'Event List', // Name
14
  array( 'description' => __( 'This widget displays a list of upcoming events. If you want to enable a link to the events or to the event page you have to insert a link to the event-list page or post.', 'text_domain' ), ) // Args
15
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  }
17
 
18
  /**
@@ -26,20 +126,32 @@ class EL_Widget extends WP_Widget {
26
  public function widget( $args, $instance ) {
27
  extract( $args );
28
  $title = apply_filters( 'widget_title', $instance['title'] );
29
-
30
  echo $before_widget;
31
  if ( ! empty( $title ) )
32
  {
33
  echo $before_title . $title . $after_title;
34
  }
35
- echo do_shortcode( '[event-list num_events="'.$instance['num_events'].'" '
36
- .'show_nav=false '
37
- .'show_details=false '
38
- .'show_location='.$instance['show_location'].' '
39
- .'link_to_event='.$instance['link_to_event'].' '
40
- .'url_to_page="'.$instance['url_to_page'].'" '
41
- .'sc_id_for_url="'.$instance['sc_id_for_url'].'"]' );
42
- if( 'true' === $instance['link_to_page'] ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  echo '<div style="clear:both"><a title="'.$instance['link_to_page_caption'].'" href="'.$instance[ 'url_to_page'].'">'.$instance['link_to_page_caption'].'</a></div>';
44
  }
45
  echo $after_widget;
@@ -57,14 +169,14 @@ class EL_Widget extends WP_Widget {
57
  */
58
  public function update( $new_instance, $old_instance ) {
59
  $instance = array();
60
- $instance['title'] = strip_tags( $new_instance['title'] );
61
- $instance['num_events'] = strip_tags( $new_instance['num_events'] );
62
- $instance['show_location'] = (isset( $new_instance['show_location'] ) && 1==$new_instance['show_location'] ) ? 'true' : 'false';
63
- $instance['url_to_page'] = strip_tags( $new_instance['url_to_page'] );
64
- $instance['sc_id_for_url'] = strip_tags( $new_instance['sc_id_for_url'] );
65
- $instance['link_to_event'] = (isset( $new_instance['link_to_event'] ) && 1==$new_instance['link_to_event'] ) ? 'true' : 'false';
66
- $instance['link_to_page'] = (isset( $new_instance['link_to_page'] ) && 1==$new_instance['link_to_page'] ) ? 'true' : 'false';
67
- $instance['link_to_page_caption'] = strip_tags( $new_instance['link_to_page_caption'] );
68
  return $instance;
69
  }
70
 
@@ -76,47 +188,29 @@ class EL_Widget extends WP_Widget {
76
  * @param array $instance Previously saved values from database.
77
  */
78
  public function form( $instance ) {
79
- $title = isset( $instance['title'] ) ? $instance['title'] : __( 'New title', 'text_domain' );
80
- $num_events = isset( $instance['num_events'] ) ? $instance['num_events'] : '3';
81
- $show_location = isset( $instance['show_location'] ) ? $instance['show_location'] : 'false';
82
- $url_to_page = isset( $instance['url_to_page'] ) ? $instance['url_to_page'] : '';
83
- $sc_id_for_url = isset( $instance['sc_id_for_url'] ) ? $instance['sc_id_for_url'] : '1';
84
- $link_to_event = isset( $instance['link_to_event'] ) ? $instance['link_to_event'] : 'false';
85
- $link_to_page = isset( $instance['link_to_page'] ) ? $instance['link_to_page'] : 'false';
86
- $link_to_page_caption = isset( $instance['link_to_page_caption'] ) ? $instance['link_to_page_caption'] : __( 'show event-list page', 'text_domain' );
87
- $show_location_checked = 'true'===$show_location || 1==$show_location ? 'checked = "checked" ' : '';
88
- $link_to_event_checked = 'true'===$link_to_event || 1==$link_to_event ? 'checked = "checked" ' : '';
89
- $link_to_page_checked = 'true'===$link_to_page || 1==$link_to_page ? 'checked = "checked" ' : '';
90
- $out = '
91
- <p>
92
- <label for="'.$this->get_field_id( 'title' ).'">'.__( 'Title:' ).'</label>
93
- <input class="widefat" id="'.$this->get_field_id( 'title' ).'" name="'.$this->get_field_name( 'title' ).'" type="text" value="'.esc_attr( $title ).'" />
94
- </p>
95
- <p>
96
- <label for="'.$this->get_field_id( 'num_events' ).'">'.__( 'Number of upcoming events:' ).'</label>
97
- <input style="width:30px" class="widefat" id="'.$this->get_field_id( 'num_events' ).'" name="'.$this->get_field_name( 'num_events' ).'" type="text" value="'.esc_attr( $num_events ).'" />
98
- </p>
99
- <p>
100
- <label><input class="widefat" id="'.$this->get_field_id( 'show_location' ).'" name="'.$this->get_field_name( 'show_location' ).'" type="checkbox" '.$show_location_checked.'value="1" /> '.__( 'Show location' ).'</label>
101
- </p>
102
- <p style="margin:0 0 0.4em 0">
103
- <label for="'.$this->get_field_id( 'url_to_page' ).'">'.__( 'URL to the linked eventlist page:' ).'</label>
104
- <input class="widefat" id="'.$this->get_field_id( 'url_to_page' ).'" name="'.$this->get_field_name( 'url_to_page' ).'" type="text" value="'.esc_attr( $url_to_page ).'" />
105
- </p>
106
- <p>
107
- <label for="'.$this->get_field_id( 'sc_id_for_url' ).'">'.__( 'Shortcode ID on linked page:' ).'</label>
108
- <input style="width:30px;" class="widefat" id="'.$this->get_field_id( 'sc_id_for_url' ).'" name="'.$this->get_field_name( 'sc_id_for_url' ).'" type="text" value="'.esc_attr( $sc_id_for_url ).'" />
109
- </p>
110
- <p style="margin-left:0.8em">
111
- <label><input class="widefat" id="'.$this->get_field_id( 'link_to_event' ).'" name="'.$this->get_field_name( 'link_to_event' ).'" type="checkbox" '.$link_to_event_checked.'value="1" /> '.__( 'Add links to the single events' ).'</label>
112
- </p>
113
- <p style="margin:0 0 0.2em 0.8em">
114
- <label><input class="widefat" id="'.$this->get_field_id( 'link_to_page' ).'" name="'.$this->get_field_name( 'link_to_page' ).'" type="checkbox" '.$link_to_page_checked.'value="1" /> '.__( 'Add a link to an event page' ).'</label>
115
- </p>
116
- <p style="margin:0 0 1em 2.5em">
117
- <label for="'.$this->get_field_id( 'link_to_page_caption' ).'">'.__( 'Caption for the link:' ).'</label>
118
- <input class="widefat" id="'.$this->get_field_id( 'link_to_page_caption' ).'" name="'.$this->get_field_name( 'link_to_page_caption' ).'" type="text" value="'.esc_attr( $link_to_page_caption ).'" />
119
- </p>';
120
  echo $out;
121
  }
122
 
1
  <?php
2
+ if( !defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
  /**
7
  * Event List Widget
8
  */
9
  class EL_Widget extends WP_Widget {
10
 
11
+ private $items;
12
+
13
  /**
14
  * Register widget with WordPress.
15
  */
19
  'Event List', // Name
20
  array( 'description' => __( 'This widget displays a list of upcoming events. If you want to enable a link to the events or to the event page you have to insert a link to the event-list page or post.', 'text_domain' ), ) // Args
21
  );
22
+
23
+ // define all available items
24
+ $this->items = array(
25
+ 'title' => array( 'type' => 'text',
26
+ 'std_value' => __( 'Upcoming events', 'text_domain' ),
27
+ 'caption' => __( 'Title:' ),
28
+ 'caption_after' => null,
29
+ 'form_style' => null,
30
+ 'form_width' => null ),
31
+
32
+ 'num_events' => array( 'type' => 'text',
33
+ 'std_value' => '3',
34
+ 'caption' => __( 'Number of upcoming events:' ),
35
+ 'caption_after' => null,
36
+ 'form_style' => null,
37
+ 'form_width' => 30 ),
38
+
39
+ 'title_length' => array( 'type' => 'text',
40
+ 'std_value' => '0',
41
+ 'caption' => __( 'Truncate event title to' ),
42
+ 'caption_after' => __( 'chars' ),
43
+ 'form_style' => null,
44
+ 'form_width' => 30 ),
45
+
46
+ 'show_starttime' => array( 'type' => 'checkbox',
47
+ 'std_value' => 'true',
48
+ 'caption' => __( 'Show event starttime' ),
49
+ 'caption_after' => null,
50
+ 'form_style' => null,
51
+ 'form_width' => null ),
52
+
53
+ 'show_location' => array( 'type' => 'checkbox',
54
+ 'std_value' => 'false',
55
+ 'caption' => __( 'Show event location' ),
56
+ 'caption_after' => null,
57
+ 'form_style' => 'margin:0 0 0.2em 0',
58
+ 'form_width' => null ),
59
+
60
+ 'location_length' => array( 'type' => 'text',
61
+ 'std_value' => '0',
62
+ 'caption' => __( 'Truncate location to' ),
63
+ 'caption_after' => __( 'chars' ),
64
+ 'form_style' => 'margin:0 0 0.6em 0.9em',
65
+ 'form_width' => 30 ),
66
+
67
+ 'show_details' => array( 'type' => 'checkbox',
68
+ 'std_value' => 'false',
69
+ 'caption' => __( 'Show event details' ),
70
+ 'caption_after' => null,
71
+ 'form_style' => 'margin:0 0 0.2em 0',
72
+ 'form_width' => null ),
73
+
74
+ 'details_length' => array( 'type' => 'text',
75
+ 'std_value' => '0',
76
+ 'caption' => __( 'Truncate details to' ),
77
+ 'caption_after' => __( 'characters' ),
78
+ 'form_style' => 'margin:0 0 0.6em 0.9em',
79
+ 'form_width' => 30 ),
80
+
81
+ 'url_to_page' => array( 'type' => 'text',
82
+ 'std_value' => '',
83
+ 'caption' => __( 'URL to the linked eventlist page:' ),
84
+ 'caption_after' => null,
85
+ 'form_style' => 'margin:0 0 0.4em 0',
86
+ 'form_width' => null ),
87
+
88
+ 'sc_id_for_url' => array( 'type' => 'text',
89
+ 'std_value' => '1',
90
+ 'caption' => __( 'Shortcode ID on linked page:' ),
91
+ 'caption_after' => null,
92
+ 'form_style' => null,
93
+ 'form_width' => 30 ),
94
+
95
+ 'link_to_event' => array( 'type' => 'checkbox',
96
+ 'std_value' => 'false',
97
+ 'caption' => __( 'Add links to the single events' ),
98
+ 'caption_after' => null,
99
+ 'form_style' => 'margin-left:0.8em',
100
+ 'form_width' => null ),
101
+
102
+ 'link_to_page' => array( 'type' => 'checkbox',
103
+ 'std_value' => 'false',
104
+ 'caption' => __( 'Add a link to an event page' ),
105
+ 'caption_after' => null,
106
+ 'form_style' => 'margin:0 0 0.2em 0.8em',
107
+ 'form_width' => null ),
108
+
109
+ 'link_to_page_caption' => array( 'type' => 'text',
110
+ 'std_value' => __( 'show event-list page', 'text_domain' ),
111
+ 'caption' => __( 'Caption for the link:' ),
112
+ 'caption_after' => null,
113
+ 'form_style' => 'margin:0 0 1em 2.5em',
114
+ 'form_width' => null ),
115
+ );
116
  }
117
 
118
  /**
126
  public function widget( $args, $instance ) {
127
  extract( $args );
128
  $title = apply_filters( 'widget_title', $instance['title'] );
 
129
  echo $before_widget;
130
  if ( ! empty( $title ) )
131
  {
132
  echo $before_title . $title . $after_title;
133
  }
134
+ $linked_page_is_set = 0 < strlen( $instance['url_to_page'] );
135
+ $linked_page_id_is_set = 0 < (int)$instance['sc_id_for_url'];
136
+ $shortcode = '[event-list show_nav=false';
137
+ $shortcode .= ' num_events="'.$instance['num_events'].'"';
138
+ $shortcode .= ' title_length='.$instance['title_length'];
139
+ $shortcode .= ' show_starttime='.$instance['show_starttime'];
140
+ $shortcode .= ' show_location='.$instance['show_location'];
141
+ $shortcode .= ' location_length='.$instance['location_length'];
142
+ $shortcode .= ' show_details='.$instance['show_details'];
143
+ $shortcode .= ' details_length='.$instance['details_length'];
144
+ if( $linked_page_is_set && $linked_page_id_is_set ) {
145
+ $shortcode .= ' link_to_event='.$instance['link_to_event'];
146
+ $shortcode .= ' url_to_page="'.$instance['url_to_page'];
147
+ $shortcode .= ' sc_id_for_url="'.$instance['sc_id_for_url'];
148
+ }
149
+ else {
150
+ $shortcode .= ' link_to_event=false';
151
+ }
152
+ $shortcode .= ']';
153
+ echo do_shortcode( $shortcode );
154
+ if( 'true' === $instance['link_to_page'] && $linked_page_is_set ) {
155
  echo '<div style="clear:both"><a title="'.$instance['link_to_page_caption'].'" href="'.$instance[ 'url_to_page'].'">'.$instance['link_to_page_caption'].'</a></div>';
156
  }
157
  echo $after_widget;
169
  */
170
  public function update( $new_instance, $old_instance ) {
171
  $instance = array();
172
+ foreach( $this->items as $itemname => $item ) {
173
+ if( 'checkbox' === $item['type'] ) {
174
+ $instance[$itemname] = ( isset( $new_instance[$itemname] ) && 1==$new_instance[$itemname] ) ? 'true' : 'false';
175
+ }
176
+ else { // 'text'
177
+ $instance[$itemname] = strip_tags( $new_instance[$itemname] );
178
+ }
179
+ }
180
  return $instance;
181
  }
182
 
188
  * @param array $instance Previously saved values from database.
189
  */
190
  public function form( $instance ) {
191
+ $out = '';
192
+ foreach( $this->items as $itemname => $item ) {
193
+ if( ! isset( $instance[$itemname] ) ) {
194
+ $instance[$itemname] = $item['std_value'];
195
+ }
196
+ $style_text = ( null===$item['form_style'] ) ? '' : ' style="'.$item['form_style'].'"';
197
+ if( 'checkbox' === $item['type'] ) {
198
+ $checked_text = ( 'true'===$instance[$itemname] || 1==$instance[$itemname] ) ? 'checked = "checked" ' : '';
199
+ $out .= '
200
+ <p'.$style_text.'>
201
+ <label><input class="widefat" id="'.$this->get_field_id( $itemname ).'" name="'.$this->get_field_name( $itemname ).'" type="checkbox" '.$checked_text.'value="1" /> '.$item['caption'].'</label>
202
+ </p>';
203
+ }
204
+ else { // 'text'
205
+ $width_text = ( null === $item['form_width'] ) ? '' : 'style="width:'.$item['form_width'].'px" ';
206
+ $caption_after_text = ( null === $item['caption_after'] ) ? '' : '<label>'.$item['caption_after'].'</label>';
207
+ $out .= '
208
+ <p'.$style_text.'>
209
+ <label for="'.$this->get_field_id( $itemname ).'">'.$item['caption'].' </label>
210
+ <input '.$width_text.'class="widefat" id="'.$this->get_field_id( $itemname ).'" name="'.$this->get_field_name( $itemname ).'" type="text" value="'.esc_attr( $instance[$itemname] ).'" />'.$caption_after_text.'
211
+ </p>';
212
+ }
213
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  echo $out;
215
  }
216
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: event, events, list, listview, calendar, schedule, shortcode, page, category, categories, admin, attribute, widget, sidebar
5
  Requires at least: 3.3
6
  Tested up to: 3.5.1
7
- Stable tag: 0.4.0
8
  Plugin URI: http://wordpress.org/extend/plugins/event-list
9
  Licence: GPLv2
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -66,6 +66,15 @@ Yes, you can create an instance of the "SC_Event_List" class which located in "p
66
 
67
  == Changelog ==
68
 
 
 
 
 
 
 
 
 
 
69
  = 0.4.0 (2013-05-04) =
70
 
71
  * added category support
4
  Tags: event, events, list, listview, calendar, schedule, shortcode, page, category, categories, admin, attribute, widget, sidebar
5
  Requires at least: 3.3
6
  Tested up to: 3.5.1
7
+ Stable tag: 0.4.1
8
  Plugin URI: http://wordpress.org/extend/plugins/event-list
9
  Licence: GPLv2
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
66
 
67
  == Changelog ==
68
 
69
+ = 0.4.1 (2013-05-31) =
70
+
71
+ * fixed deleting of categories
72
+ * fixed url to calendar icon in new/edit event form
73
+ * fixed date format localization in new/edit event form
74
+ * added some widget options
75
+ * only show links in widget if all required info are available
76
+ * small security improvements
77
+
78
  = 0.4.0 (2013-05-04) =
79
 
80
  * added category support