WP Events Manager - Version 2.1.7

Version Description

  • Update admin sortable events by date

=

Download this release

Release Info

Developer leehld
Plugin Icon 128x128 WP Events Manager
Version 2.1.7
Comparing to
See all releases

Code changes from version 2.1.6 to 2.1.7

inc/admin/upgrades/{upgrade-2.1.6.php → upgrade-2.1.7.php} RENAMED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit();
5
  }
6
 
7
- update_option( 'thimpress-event-version', '2.1.6' );
8
 
9
  /**
10
  * Update post meta
4
  exit();
5
  }
6
 
7
+ update_option( 'thimpress-event-version', '2.1.7' );
8
 
9
  /**
10
  * Update post meta
inc/class-wpems-install.php CHANGED
@@ -19,7 +19,7 @@ class WPEMS_Install {
19
  self::$db_upgrade = array(
20
  '2.0' => WPEMS_INC . 'admin/upgrades/upgrade-2.0.php',
21
  '2.0.8' => WPEMS_INC . 'admin/upgrades/upgrade-2.0.8.php',
22
- '2.1.6' => WPEMS_INC . 'admin/upgrades/upgrade-2.1.6.php'
23
  );
24
  }
25
 
@@ -89,7 +89,7 @@ class WPEMS_Install {
89
  /**
90
  * Upgrade options
91
  */
92
- self::upgrade_database();
93
  /**
94
  * Create Pages
95
  */
@@ -97,7 +97,7 @@ class WPEMS_Install {
97
  /**
98
  * Update current version
99
  */
100
- update_option( 'thimpress-event-version', WPEMS_VER );
101
  }
102
 
103
  /**
@@ -154,12 +154,10 @@ class WPEMS_Install {
154
  public static function upgrade_database() {
155
  $old_version = get_option( 'thimpress-event-version' );
156
 
157
- if ( $old_version ) {
158
- if ( $old_version != WPEMS_VER ) {
159
- foreach ( self::$db_upgrade as $ver => $file ) {
160
- if ( ! $old_version || version_compare( $old_version, $ver, '<' ) ) {
161
- require_once $file;
162
- }
163
  }
164
  }
165
  }
19
  self::$db_upgrade = array(
20
  '2.0' => WPEMS_INC . 'admin/upgrades/upgrade-2.0.php',
21
  '2.0.8' => WPEMS_INC . 'admin/upgrades/upgrade-2.0.8.php',
22
+ '2.1.7' => WPEMS_INC . 'admin/upgrades/upgrade-2.1.7.php'
23
  );
24
  }
25
 
89
  /**
90
  * Upgrade options
91
  */
92
+ // self::upgrade_database();
93
  /**
94
  * Create Pages
95
  */
97
  /**
98
  * Update current version
99
  */
100
+ // update_option( 'thimpress-event-version', WPEMS_VER );
101
  }
102
 
103
  /**
154
  public static function upgrade_database() {
155
  $old_version = get_option( 'thimpress-event-version' );
156
 
157
+ if ( ! $old_version || $old_version != WPEMS_VER ) {
158
+ foreach ( self::$db_upgrade as $ver => $file ) {
159
+ if ( ! $old_version || version_compare( $old_version, $ver, '<' ) ) {
160
+ require_once $file;
 
 
161
  }
162
  }
163
  }
inc/class-wpems-post-types.php CHANGED
@@ -23,7 +23,10 @@ class WPEMS_Custom_Post_Types {
23
  // custom event post type column
24
  add_filter( 'manage_tp_event_posts_columns', array( $this, 'event_columns' ) );
25
  add_action( 'manage_tp_event_posts_custom_column', array( $this, 'event_column_content' ), 10, 2 );
 
26
  add_filter( 'manage_edit-tp_event_sortable_columns', array( $this, 'sortable_columns' ) );
 
 
27
 
28
  add_filter( 'manage_edit-tp_event_category_columns', array( $this, 'event_category_columns' ) );
29
 
@@ -357,7 +360,66 @@ class WPEMS_Custom_Post_Types {
357
  * @return array
358
  */
359
  public function sortable_columns( $columns ) {
360
- return wp_parse_args( $columns, array( 'start' => 'start', 'end' => 'end' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  }
362
 
363
  /**
23
  // custom event post type column
24
  add_filter( 'manage_tp_event_posts_columns', array( $this, 'event_columns' ) );
25
  add_action( 'manage_tp_event_posts_custom_column', array( $this, 'event_column_content' ), 10, 2 );
26
+
27
  add_filter( 'manage_edit-tp_event_sortable_columns', array( $this, 'sortable_columns' ) );
28
+ add_filter( 'posts_join_paged', array( $this, 'posts_join_paged' ) );
29
+ add_filter( 'posts_orderby', array( $this, 'posts_orderby' ) );
30
 
31
  add_filter( 'manage_edit-tp_event_category_columns', array( $this, 'event_category_columns' ) );
32
 
360
  * @return array
361
  */
362
  public function sortable_columns( $columns ) {
363
+ return wp_parse_args( $columns, array( 'start' => 'event_start_date', 'end' => 'event_end_date' ) );
364
+ }
365
+
366
+ /**
367
+ * @return bool
368
+ */
369
+ private function _is_admin_sort() {
370
+ if ( ! ( is_admin() && isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] == 'tp_event' ) ) {
371
+ return false;
372
+ }
373
+
374
+ if ( ! isset( $_REQUEST['orderby'] ) || ! in_array( $_REQUEST['orderby'], array(
375
+ 'event_start_date',
376
+ 'event_end_date'
377
+ ) ) ) {
378
+ return false;
379
+ }
380
+
381
+ return true;
382
+ }
383
+
384
+ /**
385
+ * @param $join
386
+ *
387
+ * @return string
388
+ */
389
+ public function posts_join_paged( $join ) {
390
+ if ( ! $this->_is_admin_sort() ) {
391
+ return $join;
392
+ }
393
+
394
+ global $wpdb;
395
+
396
+ $order_by = $_REQUEST['orderby'];
397
+
398
+ if ( $order_by == 'event_start_date' ) {
399
+ $join .= " INNER JOIN {$wpdb->prefix}postmeta AS event_date ON event_date.post_id = {$wpdb->prefix}posts.ID AND event_date.meta_key = 'tp_event_date_start' ";
400
+ }
401
+
402
+ if ( $order_by == 'event_end_date' ) {
403
+ $join .= " INNER JOIN {$wpdb->prefix}postmeta AS event_date ON event_date.post_id = {$wpdb->prefix}posts.ID AND event_date.meta_key = 'tp_event_date_end' ";
404
+ }
405
+
406
+ return $join;
407
+ }
408
+
409
+ /**
410
+ * @param $order_by
411
+ *
412
+ * @return string
413
+ */
414
+ public function posts_orderby( $order_by ) {
415
+ if ( ! $this->_is_admin_sort() ) {
416
+ return $order_by;
417
+ }
418
+
419
+ $order = isset( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc';
420
+
421
+ return "event_date.meta_value {$order}";
422
+
423
  }
424
 
425
  /**
inc/class-wpems-user-process.php CHANGED
@@ -25,9 +25,9 @@ class WPEMS_User_Process {
25
  add_action( 'init', array( __CLASS__, 'process_login' ), 50 );
26
  add_action( 'init', array( __CLASS__, 'process_lost_password' ), 50 );
27
  add_action( 'init', array( __CLASS__, 'process_reset_password' ), 50 );
28
-
29
  // process
30
  add_action( 'wp_logout', array( __CLASS__, 'wp_logout' ) );
 
31
  }
32
 
33
  public static function user_process_init() {
@@ -46,8 +46,10 @@ class WPEMS_User_Process {
46
  // redirect logout
47
  public static function wp_logout() {
48
  wpems_add_notice( 'success', sprintf( '%s', __( 'You have been sign out!', 'wp-events-manager' ) ) );
49
- wp_safe_redirect( self::$login_url );
50
- exit();
 
 
51
  }
52
 
53
  /**
@@ -223,4 +225,4 @@ class WPEMS_User_Process {
223
 
224
  }
225
 
226
- WPEMS_User_Process::init();
25
  add_action( 'init', array( __CLASS__, 'process_login' ), 50 );
26
  add_action( 'init', array( __CLASS__, 'process_lost_password' ), 50 );
27
  add_action( 'init', array( __CLASS__, 'process_reset_password' ), 50 );
 
28
  // process
29
  add_action( 'wp_logout', array( __CLASS__, 'wp_logout' ) );
30
+ add_filter( 'logout_redirect', array( __CLASS__, 'logout_redirect' ), 10,3 );
31
  }
32
 
33
  public static function user_process_init() {
46
  // redirect logout
47
  public static function wp_logout() {
48
  wpems_add_notice( 'success', sprintf( '%s', __( 'You have been sign out!', 'wp-events-manager' ) ) );
49
+ }
50
+
51
+ public static function logout_redirect( $redirect_to, $requested_redirect_to, $user){
52
+ return self::$login_url;
53
  }
54
 
55
  /**
225
 
226
  }
227
 
228
+ WPEMS_User_Process::init();
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: thimpress, leehld
3
  Donate link: https://thimpress.com/
4
  Tags: event, event management, events, registration, bookings, tickets, locations, google maps
5
  Requires at least: 4.6
6
- Tested up to: 4.9.4
7
- Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -136,6 +136,8 @@ To stay in touch and update about FundPress's future releases and features, you
136
  - Update booking completed status when book free event
137
  - Add booking mail for admin
138
 
 
 
139
 
140
  == Upgrade Notice ==
141
 
3
  Donate link: https://thimpress.com/
4
  Tags: event, event management, events, registration, bookings, tickets, locations, google maps
5
  Requires at least: 4.6
6
+ Tested up to: 4.9.5
7
+ Stable tag: 2.1.7
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
136
  - Update booking completed status when book free event
137
  - Add booking mail for admin
138
 
139
+ = 2.1.7 =
140
+ + Update admin sortable events by date
141
 
142
  == Upgrade Notice ==
143
 
wp-events-manager.php CHANGED
@@ -5,7 +5,7 @@
5
  Plugin URI: http://thimpress.com/
6
  Description: A complete plugin for Events management and online booking system
7
  Author: ThimPress
8
- Version: 2.1.6
9
  Author URI: http://thimpress.com
10
  */
11
 
@@ -43,7 +43,7 @@ if ( ! class_exists( 'WPEMS' ) ) {
43
  $this->set_define( 'WPEMS_INC_URI', WPEMS_URI . 'inc/' );
44
  $this->set_define( 'WPEMS_ASSETS_URI', WPEMS_URI . 'assets/' );
45
  $this->set_define( 'WPEMS_LIB_URI', WPEMS_INC_URI . 'libraries/' );
46
- $this->set_define( 'WPEMS_VER', '2.1.6' );
47
  $this->set_define( 'WPEMS_MAIN_FILE', __FILE__ );
48
  }
49
 
5
  Plugin URI: http://thimpress.com/
6
  Description: A complete plugin for Events management and online booking system
7
  Author: ThimPress
8
+ Version: 2.1.7
9
  Author URI: http://thimpress.com
10
  */
11
 
43
  $this->set_define( 'WPEMS_INC_URI', WPEMS_URI . 'inc/' );
44
  $this->set_define( 'WPEMS_ASSETS_URI', WPEMS_URI . 'assets/' );
45
  $this->set_define( 'WPEMS_LIB_URI', WPEMS_INC_URI . 'libraries/' );
46
+ $this->set_define( 'WPEMS_VER', '2.1.7' );
47
  $this->set_define( 'WPEMS_MAIN_FILE', __FILE__ );
48
  }
49