Completed
Branch BUG-10144-query-quotes (92f63e)
by
unknown
57:41 queued 43:15
created
core/CPTs/EE_CPT_Event_Strategy.core.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 	 * @param WP_Query $wp_query
40 40
 	 * @param array $CPT
41 41
 	 */
42
-	public function __construct( $wp_query, $CPT = array() ) {
43
-		if ( $wp_query instanceof WP_Query ) {
42
+	public function __construct($wp_query, $CPT = array()) {
43
+		if ($wp_query instanceof WP_Query) {
44 44
 			$WP_Query = $wp_query;
45 45
 			$this->CPT = $CPT;
46 46
 		} else {
47
-			$WP_Query = isset( $wp_query[ 'WP_Query' ] ) ? $wp_query[ 'WP_Query' ] : null;
48
-			$this->CPT = isset( $wp_query[ 'CPT' ] ) ? $wp_query[ 'CPT' ] : null;
47
+			$WP_Query = isset($wp_query['WP_Query']) ? $wp_query['WP_Query'] : null;
48
+			$this->CPT = isset($wp_query['CPT']) ? $wp_query['CPT'] : null;
49 49
 		}
50 50
 		// !!!!!!!!!!  IMPORTANT !!!!!!!!!!!!
51 51
 		// here's the list of available filters in the WP_Query object
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 		// 'posts_fields'
60 60
 		// 'posts_join'
61 61
 		$this->_add_filters();
62
-		if ( $WP_Query instanceof WP_Query ) {
63
-			$WP_Query->is_espresso_event_single = is_singular() && isset( $WP_Query->query->post_type ) && $WP_Query->query->post_type == 'espresso_events' ? TRUE : FALSE;
62
+		if ($WP_Query instanceof WP_Query) {
63
+			$WP_Query->is_espresso_event_single = is_singular() && isset($WP_Query->query->post_type) && $WP_Query->query->post_type == 'espresso_events' ? TRUE : FALSE;
64 64
 			$WP_Query->is_espresso_event_archive = is_post_type_archive('espresso_events') ? TRUE : FALSE;
65
-			$WP_Query->is_espresso_event_taxonomy = is_tax( 'espresso_event_categories' ) ? TRUE : FALSE;
65
+			$WP_Query->is_espresso_event_taxonomy = is_tax('espresso_event_categories') ? TRUE : FALSE;
66 66
 		}
67 67
 
68 68
 	}
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 	 * (which will get removed in case the next call to get_posts ISN'T
75 75
 	 * for event CPTs)
76 76
 	 */
77
-	protected function _add_filters(){
78
-		add_filter( 'posts_fields', array( $this, 'posts_fields' ), 1, 2 );
79
-		add_filter( 'posts_join', array( $this, 'posts_join' ), 1, 2 );
80
-		add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 2 );
77
+	protected function _add_filters() {
78
+		add_filter('posts_fields', array($this, 'posts_fields'), 1, 2);
79
+		add_filter('posts_join', array($this, 'posts_join'), 1, 2);
80
+		add_filter('posts_where', array($this, 'posts_where'), 10, 2);
81 81
 		// add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 );
82
-		add_filter( 'posts_orderby', array( $this, 'posts_orderby' ), 1, 2 );
83
-		add_filter( 'posts_groupby', array( $this, 'posts_groupby' ), 1, 2 );
82
+		add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2);
83
+		add_filter('posts_groupby', array($this, 'posts_groupby'), 1, 2);
84 84
 	}
85 85
 
86 86
 
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
 	 * This is to avoid applying this CPT strategy for other posts or CPTs (eg,
91 91
 	 * we don't want to join to the datetime table when querying for venues, do we!?)
92 92
 	 */
93
-	protected function _remove_filters(){
94
-		remove_filter( 'posts_fields', array( $this, 'posts_fields' ), 1 );
95
-		remove_filter( 'posts_join', array( $this, 'posts_join' ), 1 );
96
-		remove_filter( 'posts_where', array( $this, 'posts_where' ), 10 );
93
+	protected function _remove_filters() {
94
+		remove_filter('posts_fields', array($this, 'posts_fields'), 1);
95
+		remove_filter('posts_join', array($this, 'posts_join'), 1);
96
+		remove_filter('posts_where', array($this, 'posts_where'), 10);
97 97
 		// remove_filter( 'the_posts', array( $this, 'the_posts' ), 1 );
98
-		remove_filter( 'posts_orderby', array( $this, 'posts_orderby' ), 1 );
99
-		remove_filter( 'posts_groupby', array( $this, 'posts_groupby' ), 1 );
98
+		remove_filter('posts_orderby', array($this, 'posts_orderby'), 1);
99
+		remove_filter('posts_groupby', array($this, 'posts_groupby'), 1);
100 100
 	}
101 101
 
102 102
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @param WP_Query $wp_query
110 110
 	 * @return    string
111 111
 	 */
112
-	public function posts_fields( $SQL, WP_Query $wp_query ) {
112
+	public function posts_fields($SQL, WP_Query $wp_query) {
113 113
 		if (
114 114
 			$wp_query instanceof WP_Query
115 115
 			&&
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 			)
121 121
 		) {
122 122
 			// adds something like ", wp_esp_datetime.* " to WP Query SELECT statement
123
-			$SQL .= ', ' . EEM_Datetime::instance()->table() . '.* ' ;
124
-			if ( $wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy ) {
123
+			$SQL .= ', '.EEM_Datetime::instance()->table().'.* ';
124
+			if ($wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy) {
125 125
 				// because we only want to retrieve the next upcoming datetime for each event:
126 126
 				// add something like ", MIN( wp_esp_datetime.DTT_EVT_start ) as event_start_date " to WP Query SELECT statement
127
-				$SQL .= ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ' ;
127
+				$SQL .= ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date ';
128 128
 			}
129 129
 		}
130 130
 		return $SQL;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @internal  param \WP_Query $WP_Query
142 142
 	 * @return    string
143 143
 	 */
144
-	public function posts_join( $SQL, WP_Query $wp_query ) {
144
+	public function posts_join($SQL, WP_Query $wp_query) {
145 145
 		if (
146 146
 			$wp_query instanceof WP_Query
147 147
 			&&
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 			)
153 153
 		) {
154 154
 			// adds something like " LEFT JOIN wp_esp_datetime ON ( wp_esp_datetime.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement
155
-			$SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name() . ' ) ';
155
+			$SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name().' ) ';
156 156
 		}
157 157
 		return $SQL;
158 158
 	}
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @param WP_Query $wp_query
168 168
 	 * @return    string
169 169
 	 */
170
-	public function posts_where( $SQL, WP_Query $wp_query ) {
170
+	public function posts_where($SQL, WP_Query $wp_query) {
171 171
 //		global $wpdb;
172 172
 		if (
173 173
 			$wp_query instanceof WP_Query
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 				|| $wp_query->is_espresso_event_taxonomy
178 178
 			)
179 179
 		) {
180
-			if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive ) || ! isset( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events ) || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events ) {
181
-				$SQL .=  ' AND ' . EEM_Datetime::instance()->table() . ".DTT_EVT_end > '" . current_time( 'mysql', true ) . "' ";
180
+			if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive) || ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events) || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events) {
181
+				$SQL .= ' AND '.EEM_Datetime::instance()->table().".DTT_EVT_end > '".current_time('mysql', true)."' ";
182 182
 			}
183 183
 		}
184 184
 		return $SQL;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * @param 	WP_Query $wp_query
195 195
 	 * @return 	string
196 196
 	 */
197
-	public function posts_orderby( $SQL, WP_Query $wp_query ) {
197
+	public function posts_orderby($SQL, WP_Query $wp_query) {
198 198
 		if (
199 199
 			$wp_query instanceof WP_Query
200 200
 			&&
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @param WP_Query $wp_query
219 219
 	 * @return    string
220 220
 	 */
221
-	public function posts_groupby( $SQL, WP_Query $wp_query ) {
221
+	public function posts_groupby($SQL, WP_Query $wp_query) {
222 222
 		if (
223 223
 			$wp_query instanceof WP_Query
224 224
 			&&
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 			// we're joining to the datetimes table, where there can be MANY datetimes for a single event, but we want to only show each event only once
232 232
 			// (whereas if we didn't group them by the post's ID, then we would end up with many repeats)
233 233
 			global $wpdb;
234
-			$SQL = $wpdb->posts . '.ID ';
234
+			$SQL = $wpdb->posts.'.ID ';
235 235
 		}
236 236
 		return $SQL;
237 237
 	}
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	 * @param WP_Query $wp_query
247 247
 	 * @return    array
248 248
 	 */
249
-	public function the_posts( $posts, WP_Query $wp_query ) {
249
+	public function the_posts($posts, WP_Query $wp_query) {
250 250
 		return $posts;
251 251
 	}
252 252
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @param      $single
263 263
 	 * @return    string
264 264
 	 */
265
-	public function get_EE_post_type_metadata( $meta_value = NULL, $post_id, $meta_key, $single ) {
265
+	public function get_EE_post_type_metadata($meta_value = NULL, $post_id, $meta_key, $single) {
266 266
 		return $meta_value;
267 267
 	}
268 268
 
Please login to merge, or discard this patch.
core/db_models/EEM_Registration.model.php 1 patch
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -106,32 +106,32 @@  discard block
 block discarded – undo
106 106
 	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).
107 107
 	 *    Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
108 108
 	 */
109
-	protected function __construct( $timezone = null ) {
110
-		$this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true );
111
-		$this->singular_item = __('Registration','event_espresso');
112
-		$this->plural_item = __('Registrations','event_espresso');
109
+	protected function __construct($timezone = null) {
110
+		$this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
111
+		$this->singular_item = __('Registration', 'event_espresso');
112
+		$this->plural_item = __('Registrations', 'event_espresso');
113 113
 
114 114
 		$this->_tables = array(
115
-			'Registration'=>new EE_Primary_Table('esp_registration','REG_ID')
115
+			'Registration'=>new EE_Primary_Table('esp_registration', 'REG_ID')
116 116
 		);
117 117
 		$this->_fields = array(
118 118
 			'Registration'=>array(
119
-				'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID','event_espresso')),
120
-				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'),
121
-				'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID','event_espresso'), false, 0, 'Attendee'),
122
-				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'),
123
-				'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso'), false, 0, 'Ticket'),
124
-				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'),
125
-				'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred','event_espresso'), false, EE_Datetime_Field::now, $timezone ),
126
-				'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total','event_espresso'), false, 0),
127
-				'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration','event_espresso'), false, 0),
128
-				'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration','event_espresso'), false, ''),
129
-				'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration','event_espresso'), false, ''),
130
-				'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration','event_espresso'), false, ''),
131
-				'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ','event_espresso'), true, 1),
132
-				'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group','event_espresso'), false, 1),
133
-				'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending','event_espresso'), false, false),
134
-				'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false )
119
+				'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')),
120
+				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'),
121
+				'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'),
122
+				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'),
123
+				'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, 0, 'Ticket'),
124
+				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'),
125
+				'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone),
126
+				'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total', 'event_espresso'), false, 0),
127
+				'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration', 'event_espresso'), false, 0),
128
+				'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration', 'event_espresso'), false, ''),
129
+				'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration', 'event_espresso'), false, ''),
130
+				'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration', 'event_espresso'), false, ''),
131
+				'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ', 'event_espresso'), true, 1),
132
+				'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group', 'event_espresso'), false, 1),
133
+				'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false),
134
+				'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false)
135 135
 			)
136 136
 		);
137 137
 		$this->_model_relations = array(
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
 			'Answer'=>new EE_Has_Many_Relation(),
144 144
 			'Checkin'=>new EE_Has_Many_Relation(),
145 145
 			'Registration_Payment' => new EE_Has_Many_Relation(),
146
-			'Payment'=>new EE_HABTM_Relation( 'Registration_Payment' ),
147
-			'Message' => new EE_Has_Many_Any_Relation( false ) //allow deletes even if there are messages in the queue related
146
+			'Payment'=>new EE_HABTM_Relation('Registration_Payment'),
147
+			'Message' => new EE_Has_Many_Any_Relation(false) //allow deletes even if there are messages in the queue related
148 148
 		);
149 149
 		$this->_model_chain_to_wp_user = 'Event';
150 150
 
151
-		parent::__construct( $timezone );
151
+		parent::__construct($timezone);
152 152
 	}
153 153
 
154 154
 
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
 	 *		@param bool  $translated If true will return the values as singular localized strings
244 244
 	 *		@return array
245 245
 	 */
246
-	public static function reg_status_array( $exclude = array(), $translated = FALSE ) {
247
-		EEM_Registration::instance()->_get_registration_status_array( $exclude );
248
-		return $translated ? EEM_Status::instance()->localized_status( self::$_reg_status, FALSE, 'sentence') : self::$_reg_status;
246
+	public static function reg_status_array($exclude = array(), $translated = FALSE) {
247
+		EEM_Registration::instance()->_get_registration_status_array($exclude);
248
+		return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, FALSE, 'sentence') : self::$_reg_status;
249 249
 	}
250 250
 
251 251
 
@@ -256,18 +256,18 @@  discard block
 block discarded – undo
256 256
 	 * @param array $exclude
257 257
 	 * @return array
258 258
 	 */
259
-	private function _get_registration_status_array( $exclude = array() ) {
259
+	private function _get_registration_status_array($exclude = array()) {
260 260
 		//in the very rare circumstance that we are deleting a model's table's data
261 261
 		//and the table hasn't actually been created, this could have an error
262 262
 		/** @type WPDB $wpdb */
263 263
 		global $wpdb;
264
-		if( $this->_get_table_analysis()->tableExists( $wpdb->prefix . 'esp_status' ) ){
264
+		if ($this->_get_table_analysis()->tableExists($wpdb->prefix.'esp_status')) {
265 265
 			$SQL = "SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration' ";
266
-			$results = $wpdb->get_results( $SQL );
266
+			$results = $wpdb->get_results($SQL);
267 267
 			self::$_reg_status = array();
268
-			foreach ( $results as $status ) {
269
-				if ( ! in_array( $status->STS_ID, $exclude )) {
270
-					self::$_reg_status[ $status->STS_ID ] = $status->STS_code;
268
+			foreach ($results as $status) {
269
+				if ( ! in_array($status->STS_ID, $exclude)) {
270
+					self::$_reg_status[$status->STS_ID] = $status->STS_code;
271 271
 				}
272 272
 			}
273 273
 		}
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
 	 * @throws \EE_Error
281 281
 	 */
282 282
 	protected function _get_table_analysis() {
283
-		if( $this->_table_analysis instanceof TableAnalysis ) {
283
+		if ($this->_table_analysis instanceof TableAnalysis) {
284 284
 			return $this->_table_analysis;
285 285
 		} else {
286 286
 			throw new \EE_Error(
287 287
 				sprintf(
288
-					__( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'),
289
-					get_class( $this )
288
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
289
+					get_class($this)
290 290
 				)
291 291
 			);
292 292
 		}
@@ -301,15 +301,15 @@  discard block
 block discarded – undo
301 301
 	 * @return array
302 302
 	 * @throws \EE_Error
303 303
 	 */
304
-	public function get_reg_months_and_years( $where_params ) {
304
+	public function get_reg_months_and_years($where_params) {
305 305
 		$query_params[0] = $where_params;
306 306
 		$query_params['group_by'] = array('reg_year', 'reg_month');
307
-		$query_params['order_by'] = array( 'REG_date' => 'DESC' );
307
+		$query_params['order_by'] = array('REG_date' => 'DESC');
308 308
 		$columns_to_select = array(
309 309
 			'reg_year' => array('YEAR(REG_date)', '%s'),
310 310
 			'reg_month' => array('MONTHNAME(REG_date)', '%s')
311 311
 			);
312
-		return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select );
312
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
313 313
 	}
314 314
 
315 315
 
@@ -321,11 +321,11 @@  discard block
 block discarded – undo
321 321
 	* 		@param		int		$ATT_ID
322 322
 	*		@return 	EE_Registration[]
323 323
 	*/
324
-	public function get_all_registrations_for_attendee( $ATT_ID = 0 ) {
325
-		if ( ! $ATT_ID ) {
324
+	public function get_all_registrations_for_attendee($ATT_ID = 0) {
325
+		if ( ! $ATT_ID) {
326 326
 			return FALSE;
327 327
 		}
328
-		return $this->get_all( array( array( 'ATT_ID' => $ATT_ID )));
328
+		return $this->get_all(array(array('ATT_ID' => $ATT_ID)));
329 329
 	}
330 330
 
331 331
 
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	 * @param string $REG_url_link
337 337
 	 * @return EE_Registration
338 338
 	 */
339
-	public function get_registration_for_reg_url_link($REG_url_link){
340
-		if(!$REG_url_link){
339
+	public function get_registration_for_reg_url_link($REG_url_link) {
340
+		if ( ! $REG_url_link) {
341 341
 			return false;
342 342
 		}
343 343
 		return $this->get_one(array(array('REG_url_link'=>$REG_url_link)));
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
 	* 		@param    int		$att_nmbr 	in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required
356 356
 	*		@return 		mixed		array on success, FALSE on fail
357 357
 	*/
358
-	public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) {
358
+	public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) {
359 359
 		return $this->get_one(array(
360 360
 			array(
361 361
 				'TXN_ID'=>$TXN_ID,
362 362
 				'ATT_ID'=>$ATT_ID
363 363
 			),
364
-			'limit'=>array( min( ( $att_nmbr-1 ), 0 ), 1 )
364
+			'limit'=>array(min(($att_nmbr - 1), 0), 1)
365 365
 		));
366 366
 	}
367 367
 
@@ -373,16 +373,16 @@  discard block
 block discarded – undo
373 373
 	 *		@param $period string which can be passed to php's strtotime function (eg "-1 month")
374 374
 	 *		@return stdClass[] with properties regDate and total
375 375
 	*/
376
-	public function get_registrations_per_day_report( $period = '-1 month' ) {
376
+	public function get_registrations_per_day_report($period = '-1 month') {
377 377
 
378
-		$sql_date = $this->convert_datetime_for_query( 'REG_date', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' );
379
-		$where = array( 'REG_date' => array( '>=', $sql_date ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) );
378
+		$sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC');
379
+		$where = array('REG_date' => array('>=', $sql_date), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete));
380 380
 
381
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_day_report' ) ) {
381
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) {
382 382
 			$where['Event.EVT_wp_user'] = get_current_user_id();
383 383
 		}
384 384
 
385
-		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'REG_date' );
385
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date');
386 386
 
387 387
 		$results = $this->_get_all_wpdb_results(
388 388
 				array(
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 				),
393 393
 				OBJECT,
394 394
 				array(
395
-					'regDate'=>array( 'DATE(' . $query_interval . ')','%s'),
396
-					'total'=>array('count(REG_ID)','%d')
395
+					'regDate'=>array('DATE('.$query_interval.')', '%s'),
396
+					'total'=>array('count(REG_ID)', '%d')
397 397
 				));
398 398
 		return $results;
399 399
 	}
@@ -408,22 +408,22 @@  discard block
 block discarded – undo
408 408
 	 * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID
409 409
 	 *                    (i.e. RAP)
410 410
 	 */
411
-	public function get_registrations_per_day_and_per_status_report( $period = '-1 month' ) {
411
+	public function get_registrations_per_day_and_per_status_report($period = '-1 month') {
412 412
 		global $wpdb;
413
-		$registration_table = $wpdb->prefix . 'esp_registration';
413
+		$registration_table = $wpdb->prefix.'esp_registration';
414 414
 		$event_table = $wpdb->posts;
415
-		$sql_date = date("Y-m-d H:i:s", strtotime($period) );
415
+		$sql_date = date("Y-m-d H:i:s", strtotime($period));
416 416
 
417 417
 		//prepare the query interval for displaying offset
418
-		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'dates.REG_date' );
418
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date');
419 419
 
420 420
 		//inner date query
421 421
 		$inner_date_query = "SELECT DISTINCT REG_date from $registration_table ";
422 422
 		$inner_where = " WHERE";
423 423
 		//exclude events not authored by user if permissions in effect
424
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) {
424
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
425 425
 			$inner_date_query .= "LEFT JOIN {$event_table} ON ID = EVT_ID";
426
-			$inner_where .= " post_author = " . get_current_user_id() . " AND";
426
+			$inner_where .= " post_author = ".get_current_user_id()." AND";
427 427
 		}
428 428
 		$inner_where .= " REG_date >= '{$sql_date}'";
429 429
 		$inner_date_query .= $inner_where;
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 		$select_parts = array();
436 436
 
437 437
 		//loop through registration stati to do parts for each status.
438
-		foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) {
439
-			if ( $STS_ID === EEM_Registration::status_id_incomplete ) {
438
+		foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
439
+			if ($STS_ID === EEM_Registration::status_id_incomplete) {
440 440
 				continue;
441 441
 			}
442 442
 			$select_parts[] = "COUNT({$STS_code}.REG_ID) as {$STS_ID}";
@@ -444,14 +444,14 @@  discard block
 block discarded – undo
444 444
 		}
445 445
 
446 446
 		//setup the selects
447
-		$select .= implode(', ', $select_parts );
447
+		$select .= implode(', ', $select_parts);
448 448
 		$select .= " FROM ({$inner_date_query}) AS dates LEFT JOIN ";
449 449
 
450 450
 		//setup the joins
451
-		$join .= implode( " LEFT JOIN ", $join_parts );
451
+		$join .= implode(" LEFT JOIN ", $join_parts);
452 452
 
453 453
 		//now let's put it all together
454
-		$query = $select . $join . ' GROUP BY Registration_REG_date';
454
+		$query = $select.$join.' GROUP BY Registration_REG_date';
455 455
 
456 456
 		//and execute it
457 457
 		$results = $wpdb->get_results(
@@ -472,23 +472,23 @@  discard block
 block discarded – undo
472 472
 	 * @param $period string which can be passed to php's strtotime function (eg "-1 month")
473 473
 	 *		@return stdClass[] each with properties event_name, reg_limit, and total
474 474
 	*/
475
-	public function get_registrations_per_event_report( $period = '-1 month' ) {
475
+	public function get_registrations_per_event_report($period = '-1 month') {
476 476
 
477
-		$date_sql = $this->convert_datetime_for_query( 'REG_date', date( "Y-m-d H:i:s", strtotime( $period )), 'Y-m-d H:i:s', 'UTC' );
478
-		$where = array( 'REG_date' => array( '>=', $date_sql ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) );
477
+		$date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC');
478
+		$where = array('REG_date' => array('>=', $date_sql), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete));
479 479
 
480
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) {
480
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
481 481
 			$where['Event.EVT_wp_user'] = get_current_user_id();
482 482
 		}
483 483
 		$results = $this->_get_all_wpdb_results(array(
484 484
 			$where,
485 485
 			'group_by'=>'Event.EVT_name',
486 486
 			'order_by'=>'Event.EVT_name',
487
-			'limit'=>array(0,24)),
487
+			'limit'=>array(0, 24)),
488 488
 			OBJECT,
489 489
 			array(
490
-				'event_name'=>array('Event_CPT.post_title','%s'),
491
-				'total'=>array('COUNT(REG_ID)','%s')
490
+				'event_name'=>array('Event_CPT.post_title', '%s'),
491
+				'total'=>array('COUNT(REG_ID)', '%s')
492 492
 			)
493 493
 		);
494 494
 
@@ -506,19 +506,19 @@  discard block
 block discarded – undo
506 506
 	 * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID
507 507
 	 *                    (i.e. RAP)
508 508
 	 */
509
-	public function get_registrations_per_event_and_per_status_report( $period = '-1 month' ) {
509
+	public function get_registrations_per_event_and_per_status_report($period = '-1 month') {
510 510
 		global $wpdb;
511
-		$registration_table = $wpdb->prefix . 'esp_registration';
511
+		$registration_table = $wpdb->prefix.'esp_registration';
512 512
 		$event_table = $wpdb->posts;
513
-		$sql_date = date("Y-m-d H:i:s", strtotime($period) );
513
+		$sql_date = date("Y-m-d H:i:s", strtotime($period));
514 514
 
515 515
 		//inner date query
516 516
 		$inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from {$registration_table} ";
517 517
 		$inner_where = " WHERE";
518 518
 		//exclude events not authored by user if permissions in effect
519
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) {
519
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
520 520
 			$inner_date_query .= "LEFT JOIN {$event_table} ON ID = EVT_ID";
521
-			$inner_where .= " post_author = " . get_current_user_id() . " AND";
521
+			$inner_where .= " post_author = ".get_current_user_id()." AND";
522 522
 		}
523 523
 		$inner_where .= " REG_date >= '{$sql_date}'";
524 524
 		$inner_date_query .= $inner_where;
@@ -530,8 +530,8 @@  discard block
 block discarded – undo
530 530
 		$select_parts = array();
531 531
 
532 532
 		//loop through registration stati to do parts for each status.
533
-		foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) {
534
-			if ( $STS_ID === EEM_Registration::status_id_incomplete ) {
533
+		foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
534
+			if ($STS_ID === EEM_Registration::status_id_incomplete) {
535 535
 				continue;
536 536
 			}
537 537
 			$select_parts[] = "COUNT({$STS_code}.REG_ID) as {$STS_ID}";
@@ -539,14 +539,14 @@  discard block
 block discarded – undo
539 539
 		}
540 540
 
541 541
 		//setup the selects
542
-		$select .= implode( ', ', $select_parts );
542
+		$select .= implode(', ', $select_parts);
543 543
 		$select .= " FROM ({$inner_date_query}) AS dates LEFT JOIN {$event_table} as Event ON Event.ID = dates.EVT_ID LEFT JOIN ";
544 544
 
545 545
 		//setup remaining joins
546
-		$join .= implode( " LEFT JOIN ", $join_parts );
546
+		$join .= implode(" LEFT JOIN ", $join_parts);
547 547
 
548 548
 		//now put it all together
549
-		$query = $select . $join . ' GROUP BY Registration_Event';
549
+		$query = $select.$join.' GROUP BY Registration_Event';
550 550
 
551 551
 		//and execute
552 552
 		$results = $wpdb->get_results(
@@ -562,11 +562,11 @@  discard block
 block discarded – undo
562 562
 	 * @param int $TXN_ID
563 563
 	 * @return EE_Registration
564 564
 	 */
565
-	public function get_primary_registration_for_transaction_ID( $TXN_ID = 0){
566
-		if( ! $TXN_ID ){
565
+	public function get_primary_registration_for_transaction_ID($TXN_ID = 0) {
566
+		if ( ! $TXN_ID) {
567 567
 			return false;
568 568
 		}
569
-		return $this->get_one(array(array('TXN_ID'=>$TXN_ID,'REG_count'=>  EEM_Registration::PRIMARY_REGISTRANT_COUNT)));
569
+		return $this->get_one(array(array('TXN_ID'=>$TXN_ID, 'REG_count'=>  EEM_Registration::PRIMARY_REGISTRANT_COUNT)));
570 570
 	}
571 571
 
572 572
 
@@ -578,11 +578,11 @@  discard block
 block discarded – undo
578 578
 	 *		@param boolean $for_incomplete_payments
579 579
 	 *		@return int
580 580
 	 */
581
-	public function get_event_registration_count ( $EVT_ID, $for_incomplete_payments = FALSE ) {
581
+	public function get_event_registration_count($EVT_ID, $for_incomplete_payments = FALSE) {
582 582
 		// we only count approved registrations towards registration limits
583
-		$query_params = array( array( 'EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved ) );
584
-		if( $for_incomplete_payments ){
585
-			$query_params[0]['Transaction.STS_ID']=array('!=',  EEM_Transaction::complete_status_code);
583
+		$query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved));
584
+		if ($for_incomplete_payments) {
585
+			$query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code);
586 586
 		}
587 587
 
588 588
 		return $this->count($query_params);
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 		/** @type WPDB $wpdb */
599 599
 		global $wpdb;
600 600
 		return $wpdb->query(
601
-				'DELETE r FROM ' . $this->table() . ' r LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' );
601
+				'DELETE r FROM '.$this->table().' r LEFT JOIN '.EEM_Transaction::instance()->table().' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' );
602 602
 	}
603 603
 
604 604
 	/**
@@ -608,17 +608,17 @@  discard block
 block discarded – undo
608 608
 	 * @param boolean $checked_in whether to count registrations checked IN or OUT
609 609
 	 * @return int
610 610
 	 */
611
-	public function count_registrations_checked_into_datetime( $DTT_ID, $checked_in = true) {
611
+	public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) {
612 612
 		global $wpdb;
613 613
 		//subquery to get latest checkin
614 614
 		$query = $wpdb->prepare(
615 615
 			'SELECT '
616 616
 				. 'COUNT( DISTINCT checkins.REG_ID ) '
617
-			. 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN'
617
+			. 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN'
618 618
 				. '( SELECT '
619 619
 					. 'max( CHK_timestamp ) AS latest_checkin, '
620 620
 					. 'REG_ID AS REG_ID '
621
-				. 'FROM ' . EEM_Checkin::instance()->table() . ' '
621
+				. 'FROM '.EEM_Checkin::instance()->table().' '
622 622
 				. 'WHERE DTT_ID=%d '
623 623
 				. 'GROUP BY REG_ID'
624 624
 			. ') AS most_recent_checkin_per_reg '
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 			$DTT_ID,
630 630
 			$checked_in
631 631
 		);
632
-		return (int)$wpdb->get_var( $query );
632
+		return (int) $wpdb->get_var($query);
633 633
 	}
634 634
 
635 635
 	/**
@@ -639,18 +639,18 @@  discard block
 block discarded – undo
639 639
 	 * @param boolean $checked_in whether to count registrations checked IN or OUT
640 640
 	 * @return int
641 641
 	 */
642
-	public function count_registrations_checked_into_event( $EVT_ID, $checked_in = true ) {
642
+	public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) {
643 643
 		global $wpdb;
644 644
 		//subquery to get latest checkin
645 645
 		$query = $wpdb->prepare(
646 646
 			'SELECT '
647 647
 				. 'COUNT( DISTINCT checkins.REG_ID ) '
648
-			. 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN'
648
+			. 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN'
649 649
 				. '( SELECT '
650 650
 					. 'max( CHK_timestamp ) AS latest_checkin, '
651 651
 					. 'REG_ID AS REG_ID '
652
-				. 'FROM ' . EEM_Checkin::instance()->table() . ' AS c '
653
-				. 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d '
652
+				. 'FROM '.EEM_Checkin::instance()->table().' AS c '
653
+				. 'INNER JOIN '.EEM_Datetime::instance()->table().' AS d '
654 654
 				. 'ON c.DTT_ID=d.DTT_ID '
655 655
 				. 'WHERE d.EVT_ID=%d '
656 656
 				. 'GROUP BY REG_ID'
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 			$EVT_ID,
663 663
 			$checked_in
664 664
 		);
665
-		return (int)$wpdb->get_var( $query );
665
+		return (int) $wpdb->get_var($query);
666 666
 	}
667 667
 
668 668
 
@@ -677,15 +677,15 @@  discard block
 block discarded – undo
677 677
 	 * @param array $attendee_ids
678 678
 	 * @return EE_Registration[]
679 679
 	 */
680
-	public function get_latest_registration_for_each_of_given_contacts( $attendee_ids = array() ) {
680
+	public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) {
681 681
 		//first do a native wp_query to get the latest REG_ID's matching these attendees.
682 682
 		global $wpdb;
683
-		$registration_table = $wpdb->prefix . 'esp_registration';
683
+		$registration_table = $wpdb->prefix.'esp_registration';
684 684
 		$attendee_table = $wpdb->posts;
685
-		$attendee_ids = is_array( $attendee_ids )
686
-			? array_map( 'absint', $attendee_ids )
687
-			: array( (int) $attendee_ids );
688
-		$attendee_ids = implode( ',', $attendee_ids );
685
+		$attendee_ids = is_array($attendee_ids)
686
+			? array_map('absint', $attendee_ids)
687
+			: array((int) $attendee_ids);
688
+		$attendee_ids = implode(',', $attendee_ids);
689 689
 
690 690
 
691 691
 		//first we do a query to get the registration ids
@@ -710,24 +710,24 @@  discard block
 block discarded – undo
710 710
 			ARRAY_A
711 711
 		);
712 712
 
713
-		if ( empty( $registration_ids ) ) {
713
+		if (empty($registration_ids)) {
714 714
 			return array();
715 715
 		}
716 716
 
717 717
 		$ids_for_model_query = array();
718 718
 		//let's flatten the ids so they can be used in the model query.
719
-		foreach ( $registration_ids as $registration_id ) {
720
-			if ( isset( $registration_id['registration_id'] ) ) {
719
+		foreach ($registration_ids as $registration_id) {
720
+			if (isset($registration_id['registration_id'])) {
721 721
 				$ids_for_model_query[] = $registration_id['registration_id'];
722 722
 			}
723 723
 		}
724 724
 
725 725
 		//construct query
726 726
 		$_where = array(
727
-			'REG_ID' => array( 'IN', $ids_for_model_query )
727
+			'REG_ID' => array('IN', $ids_for_model_query)
728 728
 		);
729 729
 
730
-		return $this->get_all( array( $_where ) );
730
+		return $this->get_all(array($_where));
731 731
 	}
732 732
 
733 733
 
Please login to merge, or discard this patch.
core/helpers/EEH_Event_Query.helper.php 1 patch
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public static function add_query_filters() {
87 87
 		//add query filters
88
-		add_action( 'pre_get_posts', array( 'EEH_Event_Query', 'filter_query_parts' ), 10, 1 );
88
+		add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1);
89 89
 	}
90 90
 
91 91
 
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	 * @param \WP_Query $WP_Query
98 98
 	 * @return bool
99 99
 	 */
100
-	public static function apply_query_filters( WP_Query $WP_Query ) {
101
-		return ( isset( $WP_Query->query, $WP_Query->query['post_type'] ) && $WP_Query->query['post_type'] == 'espresso_events' ) ||  apply_filters( 'FHEE__EEH_Event_Query__apply_query_filters', false ) ? true : false;
100
+	public static function apply_query_filters(WP_Query $WP_Query) {
101
+		return (isset($WP_Query->query, $WP_Query->query['post_type']) && $WP_Query->query['post_type'] == 'espresso_events') || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false) ? true : false;
102 102
 	}
103 103
 
104 104
 
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 	 * @access    public
109 109
 	 * @param \WP_Query $WP_Query
110 110
 	 */
111
-	public static function filter_query_parts( WP_Query $WP_Query ) {
111
+	public static function filter_query_parts(WP_Query $WP_Query) {
112 112
 		//ONLY add our filters if this isn't the main wp_query, because if this is the main wp_query we already have our cpt strategies take care of adding things in.
113
-		if ( $WP_Query instanceof WP_Query && ! $WP_Query->is_main_query() ) {
113
+		if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) {
114 114
 			// build event list query
115
-			add_filter( 'posts_fields', array( 'EEH_Event_Query', 'posts_fields' ), 10, 2 );
116
-			add_filter( 'posts_join', array( 'EEH_Event_Query', 'posts_join' ), 10, 2 );
117
-			add_filter( 'posts_where', array( 'EEH_Event_Query', 'posts_where' ), 10, 2 );
118
-			add_filter( 'posts_orderby', array( 'EEH_Event_Query', 'posts_orderby' ), 10, 2 );
119
-			add_filter( 'posts_clauses_request', array( 'EEH_Event_Query', 'posts_clauses' ), 10, 2 );
115
+			add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2);
116
+			add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2);
117
+			add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2);
118
+			add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2);
119
+			add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2);
120 120
 		}
121 121
 	}
122 122
 
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 	 * @param string $orderby
132 132
 	 * @param string $sort
133 133
 	 */
134
-	public static function set_query_params( $month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC' ) {
134
+	public static function set_query_params($month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC') {
135 135
 		self::$_query_params = array();
136
-		EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month( $month );
137
-		EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug( $category );
138
-		EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired( $show_expired );
139
-		EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby( $orderby );
140
-		EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort( $sort );
136
+		EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month);
137
+		EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category);
138
+		EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired);
139
+		EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby);
140
+		EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort);
141 141
 	}
142 142
 
143 143
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 * @param string $month
150 150
 	 * @return    string
151 151
 	 */
152
-	private static function _display_month( $month = '' ) {
153
-		return EE_Registry::instance()->REQ->is_set( 'event_query_month' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_month' ) ) : $month;
152
+	private static function _display_month($month = '') {
153
+		return EE_Registry::instance()->REQ->is_set('event_query_month') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month')) : $month;
154 154
 	}
155 155
 
156 156
 
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 	 * @param string $category
163 163
 	 * @return    string
164 164
 	 */
165
-	private static function _event_category_slug( $category = '' ) {
166
-		return EE_Registry::instance()->REQ->is_set( 'event_query_category' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_category' ) ) : $category;
165
+	private static function _event_category_slug($category = '') {
166
+		return EE_Registry::instance()->REQ->is_set('event_query_category') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_category')) : $category;
167 167
 	}
168 168
 
169 169
 
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 	 * @param bool $show_expired
176 176
 	 * @return    boolean
177 177
 	 */
178
-	private static function _show_expired( $show_expired = FALSE ) {
178
+	private static function _show_expired($show_expired = FALSE) {
179 179
 		// override default expired option if set via filter
180
-		$_event_query_show_expired =EE_Registry::instance()->REQ->is_set( 'event_query_show_expired' ) ? EE_Registry::instance()->REQ->get( 'event_query_show_expired' ) : $show_expired;
181
-		return filter_var( $_event_query_show_expired, FILTER_VALIDATE_BOOLEAN );
180
+		$_event_query_show_expired = EE_Registry::instance()->REQ->is_set('event_query_show_expired') ? EE_Registry::instance()->REQ->get('event_query_show_expired') : $show_expired;
181
+		return filter_var($_event_query_show_expired, FILTER_VALIDATE_BOOLEAN);
182 182
 	}
183 183
 
184 184
 
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
 	 * @param    string $orderby
191 191
 	 * @return    array
192 192
 	 */
193
-	private static function _orderby( $orderby = 'start_date' ) {
194
-		$event_query_orderby = EE_Registry::instance()->REQ->is_set( 'event_query_orderby' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_orderby' ) ) : $orderby;
195
-		$event_query_orderby = is_array( $event_query_orderby ) ? $event_query_orderby : explode( ',', $event_query_orderby );
196
-		$event_query_orderby = array_map( 'trim', $event_query_orderby );
193
+	private static function _orderby($orderby = 'start_date') {
194
+		$event_query_orderby = EE_Registry::instance()->REQ->is_set('event_query_orderby') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_orderby')) : $orderby;
195
+		$event_query_orderby = is_array($event_query_orderby) ? $event_query_orderby : explode(',', $event_query_orderby);
196
+		$event_query_orderby = array_map('trim', $event_query_orderby);
197 197
 		return $event_query_orderby;
198 198
 	}
199 199
 
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	 * @param string $sort
207 207
 	 * @return    array
208 208
 	 */
209
-	private static function _sort( $sort = 'ASC' ) {
210
-		$sort = EE_Registry::instance()->REQ->is_set( 'event_query_sort' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_sort' ) ) : $sort;
211
-		return in_array( $sort, array( 'ASC', 'asc', 'DESC', 'desc' )) ? strtoupper( $sort ) : 'ASC';
209
+	private static function _sort($sort = 'ASC') {
210
+		$sort = EE_Registry::instance()->REQ->is_set('event_query_sort') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_sort')) : $sort;
211
+		return in_array($sort, array('ASC', 'asc', 'DESC', 'desc')) ? strtoupper($sort) : 'ASC';
212 212
 	}
213 213
 
214 214
 
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @return array   array of clauses
223 223
 	 */
224
-	public static function posts_clauses( $clauses, WP_Query $wp_query ) {
225
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
224
+	public static function posts_clauses($clauses, WP_Query $wp_query) {
225
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
226 226
 			global $wpdb;
227
-			$clauses['groupby'] = $wpdb->posts . '.ID ';
227
+			$clauses['groupby'] = $wpdb->posts.'.ID ';
228 228
 		}
229 229
 		return $clauses;
230 230
 	}
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	 * @param WP_Query $wp_query
240 240
 	 * @return    string
241 241
 	 */
242
-	public static function posts_fields( $SQL, WP_Query $wp_query ) {
243
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
242
+	public static function posts_fields($SQL, WP_Query $wp_query) {
243
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
244 244
 			// adds something like ", wp_esp_datetime.* " to WP Query SELECT statement
245
-			$SQL .= EEH_Event_Query::posts_fields_sql_for_orderby( EEH_Event_Query::$_event_query_orderby );
245
+			$SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby);
246 246
 		}
247 247
 		return $SQL;
248 248
 	}
@@ -257,29 +257,29 @@  discard block
 block discarded – undo
257 257
 	 * @internal  param bool|string $mixed $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet
258 258
 	 * @return    string
259 259
 	 */
260
-	public static function posts_fields_sql_for_orderby( $orderby_params = array() ) {
261
-		$SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ' ;
262
-		foreach( (array)$orderby_params as $orderby ) {
263
-			switch ( $orderby ) {
260
+	public static function posts_fields_sql_for_orderby($orderby_params = array()) {
261
+		$SQL = ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date ';
262
+		foreach ((array) $orderby_params as $orderby) {
263
+			switch ($orderby) {
264 264
 
265 265
 				case 'ticket_start' :
266
-					$SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date' ;
266
+					$SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_start_date';
267 267
 					break;
268 268
 
269 269
 				case 'ticket_end' :
270
-					$SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date' ;
270
+					$SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_end_date';
271 271
 					break;
272 272
 
273 273
 				case 'venue_title' :
274
-					$SQL .= ', Venue.post_title AS venue_title' ;
274
+					$SQL .= ', Venue.post_title AS venue_title';
275 275
 					break;
276 276
 
277 277
 				case 'city' :
278
-					$SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city' ;
278
+					$SQL .= ', '.EEM_Venue::instance()->second_table().'.VNU_city';
279 279
 					break;
280 280
 
281 281
 				case 'state' :
282
-					$SQL .= ', ' . EEM_State::instance()->table() . '.STA_name' ;
282
+					$SQL .= ', '.EEM_State::instance()->table().'.STA_name';
283 283
 					break;
284 284
 
285 285
 			}
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 	 * @param WP_Query $wp_query
298 298
 	 * @return    string
299 299
 	 */
300
-	public static function posts_join( $SQL = '', WP_Query $wp_query ) {
301
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
300
+	public static function posts_join($SQL = '', WP_Query $wp_query) {
301
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
302 302
 			// Category
303
-			$SQL = EEH_Event_Query::posts_join_sql_for_show_expired( $SQL, EEH_Event_Query::$_event_query_show_expired );
304
-			$SQL = EEH_Event_Query::posts_join_sql_for_terms( $SQL, EEH_Event_Query::$_event_query_category );
305
-			$SQL = EEH_Event_Query::posts_join_for_orderby( $SQL, EEH_Event_Query::$_event_query_orderby );
303
+			$SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired);
304
+			$SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category);
305
+			$SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby);
306 306
 		}
307 307
 		return $SQL;
308 308
 	}
@@ -317,11 +317,11 @@  discard block
 block discarded – undo
317 317
 	 * @param    boolean $show_expired if TRUE, then displayed past events
318 318
 	 * @return string
319 319
 	 */
320
-	public static function posts_join_sql_for_show_expired( $SQL = '', $show_expired = FALSE ) {
321
-		if ( ! $show_expired ) {
322
-			$join = EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name();
323
-			if ( strpos( $SQL, $join ) === FALSE ) {
324
-				$SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) ';
320
+	public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = FALSE) {
321
+		if ( ! $show_expired) {
322
+			$join = EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name();
323
+			if (strpos($SQL, $join) === FALSE) {
324
+				$SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' ) ';
325 325
 			}
326 326
 		}
327 327
 		return $SQL;
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 	 * @param 	string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet
338 338
 	 * @return 	string
339 339
 	 */
340
-	public static function posts_join_sql_for_terms( $SQL = '', $join_terms = '' ) {
341
-		if ( ! empty( $join_terms ) ) {
340
+	public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') {
341
+		if ( ! empty($join_terms)) {
342 342
 			global $wpdb;
343 343
 			$SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
344 344
 			$SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
@@ -358,25 +358,25 @@  discard block
 block discarded – undo
358 358
 	 * @param 	array $orderby_params
359 359
 	 * @return 	string
360 360
 	 */
361
-	public static function posts_join_for_orderby( $SQL = '', $orderby_params = array() ) {
362
-		foreach ( (array)$orderby_params as $orderby ) {
363
-			switch ( $orderby ) {
361
+	public static function posts_join_for_orderby($SQL = '', $orderby_params = array()) {
362
+		foreach ((array) $orderby_params as $orderby) {
363
+			switch ($orderby) {
364 364
 				case 'ticket_start' :
365 365
 				case 'ticket_end' :
366
-					$SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() );
367
-					$SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' . EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' = ' . EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' )';
366
+					$SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Datetime_Ticket::instance()->table().'.'.EEM_Datetime::instance()->primary_key_name());
367
+					$SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON ('.EEM_Datetime_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' = '.EEM_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' )';
368 368
 					break;
369 369
 				case 'venue_title' :
370 370
 				case 'city' :
371
-					$SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL );
371
+					$SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL);
372 372
 					break;
373 373
 				case 'state' :
374
-					$SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL );
375
-					$SQL .= EEH_Event_Query::_posts_join_for_venue_state( $SQL );
374
+					$SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL);
375
+					$SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL);
376 376
 					break;
377 377
 				case 'start_date' :
378 378
 				default :
379
-					$SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Event::instance()->table() . '.ID' );
379
+					$SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table().'.ID');
380 380
 					break;
381 381
 
382 382
 			}
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
 	 * @param string $join
395 395
 	 * @return string
396 396
 	 */
397
-	protected static function _posts_join_for_datetime( $SQL = '', $join = '' ) {
398
-		if ( ! empty( $join )) {
399
-			$join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name();
400
-			if ( strpos( $SQL, $join ) === FALSE ) {
401
-				return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )';
397
+	protected static function _posts_join_for_datetime($SQL = '', $join = '') {
398
+		if ( ! empty($join)) {
399
+			$join .= ' = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name();
400
+			if (strpos($SQL, $join) === FALSE) {
401
+				return ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' )';
402 402
 			}
403 403
 		}
404 404
 		return '';
@@ -413,13 +413,13 @@  discard block
 block discarded – undo
413 413
 	 * @param string $SQL
414 414
 	 * @return string
415 415
 	 */
416
-	protected static function _posts_join_for_event_venue( $SQL = '' ) {
416
+	protected static function _posts_join_for_event_venue($SQL = '') {
417 417
 		// Event Venue table name
418 418
 		$event_venue_table = EEM_Event_Venue::instance()->table();
419 419
 		// generate conditions for:  Event <=> Event Venue  JOIN clause
420
-		$event_to_event_venue_join = EEM_Event::instance()->table() . '.ID = ' . $event_venue_table . '.' . EEM_Event::instance()->primary_key_name();
420
+		$event_to_event_venue_join = EEM_Event::instance()->table().'.ID = '.$event_venue_table.'.'.EEM_Event::instance()->primary_key_name();
421 421
 		// don't add joins if they have already been added
422
-		if ( strpos( $SQL, $event_to_event_venue_join ) === FALSE ) {
422
+		if (strpos($SQL, $event_to_event_venue_join) === FALSE) {
423 423
 			// Venue table name
424 424
 			$venue_table = EEM_Venue::instance()->table();
425 425
 			// Venue table pk
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
 			$venue_SQL .= " LEFT JOIN $venue_table as Venue ON ( $event_venue_table.$venue_table_pk = Venue.ID )";
433 433
 			// generate JOIN clause for: Venue <=> Venue Meta
434 434
 			$venue_SQL .= " LEFT JOIN $venue_meta_table ON ( Venue.ID = $venue_meta_table.$venue_table_pk )";
435
-			unset( $event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table );
435
+			unset($event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table);
436 436
 			return $venue_SQL;
437 437
 		}
438
-		unset( $event_venue_table, $event_to_event_venue_join );
438
+		unset($event_venue_table, $event_to_event_venue_join);
439 439
 		return '';
440 440
 	}
441 441
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	 * @param string $SQL
449 449
 	 * @return string
450 450
 	 */
451
-	protected static function _posts_join_for_venue_state( $SQL = '' ) {
451
+	protected static function _posts_join_for_venue_state($SQL = '') {
452 452
 		// Venue Meta table name
453 453
 		$venue_meta_table = EEM_Venue::instance()->second_table();
454 454
 		// State table name
@@ -456,16 +456,16 @@  discard block
 block discarded – undo
456 456
 		// State table pk
457 457
 		$state_table_pk = EEM_State::instance()->primary_key_name();
458 458
 		// verify vars
459
-		if ( $venue_meta_table && $state_table && $state_table_pk ) {
459
+		if ($venue_meta_table && $state_table && $state_table_pk) {
460 460
 			// like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID
461 461
 			$join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk";
462 462
 			// don't add join if it has already been added
463
-			if ( strpos( $SQL, $join ) === FALSE ) {
464
-				unset( $state_table_pk, $venue_meta_table, $venue_table_pk );
463
+			if (strpos($SQL, $join) === FALSE) {
464
+				unset($state_table_pk, $venue_meta_table, $venue_table_pk);
465 465
 				return " LEFT JOIN $state_table ON ( $join )";
466 466
 			}
467 467
 		}
468
-		unset( $join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk );
468
+		unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk);
469 469
 		return '';
470 470
 	}
471 471
 
@@ -479,14 +479,14 @@  discard block
 block discarded – undo
479 479
 	 * @param WP_Query $wp_query
480 480
 	 * @return    string
481 481
 	 */
482
-	public static function posts_where( $SQL = '', WP_Query $wp_query ) {
483
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
482
+	public static function posts_where($SQL = '', WP_Query $wp_query) {
483
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
484 484
 			// Show Expired ?
485
-			$SQL .= EEH_Event_Query::posts_where_sql_for_show_expired( EEH_Event_Query::$_event_query_show_expired  );
485
+			$SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired);
486 486
 			// Category
487
-			$SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug( EEH_Event_Query::$_event_query_category  );
487
+			$SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category);
488 488
 			// Start Date
489
-			$SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month( EEH_Event_Query::$_event_query_month );
489
+			$SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month);
490 490
 		}
491 491
 		return $SQL;
492 492
 	}
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	 * @param    boolean $show_expired if TRUE, then displayed past events
501 501
 	 * @return    string
502 502
 	 */
503
-	public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) {
504
-		return ! $show_expired ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > \'' . current_time( 'mysql', TRUE ) . '\' ' : '';
503
+	public static function posts_where_sql_for_show_expired($show_expired = FALSE) {
504
+		return ! $show_expired ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > \''.current_time('mysql', TRUE).'\' ' : '';
505 505
 	}
506 506
 
507 507
 
@@ -513,9 +513,9 @@  discard block
 block discarded – undo
513 513
 	 * @param    boolean $event_category_slug
514 514
 	 * @return    string
515 515
 	 */
516
-	public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) {
516
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) {
517 517
 		global $wpdb;
518
-		return ! empty( $event_category_slug ) ? " AND {$wpdb->terms}.slug = '{$event_category_slug}' " : '';
518
+		return ! empty($event_category_slug) ? " AND {$wpdb->terms}.slug = '{$event_category_slug}' " : '';
519 519
 	}
520 520
 
521 521
 
@@ -527,14 +527,14 @@  discard block
 block discarded – undo
527 527
 	 * @param    boolean $month
528 528
 	 * @return    string
529 529
 	 */
530
-	public static function posts_where_sql_for_event_list_month( $month = NULL ) {
530
+	public static function posts_where_sql_for_event_list_month($month = NULL) {
531 531
 		$SQL = '';
532
-		if ( ! empty( $month ) ) {
532
+		if ( ! empty($month)) {
533 533
 			$datetime_table = EEM_Datetime::instance()->table();
534 534
 			// event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
535
-			$SQL = " AND {$datetime_table}.DTT_EVT_start <= '" . gmdate( 'Y-m-t 23:59:59', strtotime( $month ) ) . "'";
535
+			$SQL = " AND {$datetime_table}.DTT_EVT_start <= '".gmdate('Y-m-t 23:59:59', strtotime($month))."'";
536 536
 			// event end date is GREATER than the start of the month ( so nothing that ended before this month )
537
-			$SQL .= " AND {$datetime_table}.DTT_EVT_end >= '" . gmdate( 'Y-m-01 0:0:00', strtotime( $month ) ) . "' ";
537
+			$SQL .= " AND {$datetime_table}.DTT_EVT_end >= '".gmdate('Y-m-01 0:0:00', strtotime($month))."' ";
538 538
 		}
539 539
 		return $SQL;
540 540
 	}
@@ -549,9 +549,9 @@  discard block
 block discarded – undo
549 549
 	 * @param WP_Query $wp_query
550 550
 	 * @return    string
551 551
 	 */
552
-	public static function posts_orderby( $SQL = '', WP_Query $wp_query ) {
553
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
554
-			$SQL = EEH_Event_Query::posts_orderby_sql( EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort );
552
+	public static function posts_orderby($SQL = '', WP_Query $wp_query) {
553
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
554
+			$SQL = EEH_Event_Query::posts_orderby_sql(EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort);
555 555
 		}
556 556
 		return $SQL;
557 557
 	}
@@ -582,63 +582,63 @@  discard block
 block discarded – undo
582 582
 	 * @param string     $sort
583 583
 	 * @return string
584 584
 	 */
585
-	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
585
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') {
586 586
 		global $wpdb;
587 587
 		$SQL = '';
588 588
 		$counter = 0;
589 589
 		//make sure 'orderby' is set in query params
590
-		if ( ! isset( self::$_query_params['orderby'] )) {
590
+		if ( ! isset(self::$_query_params['orderby'])) {
591 591
 			self::$_query_params['orderby'] = array();
592 592
 		}
593 593
 		// loop thru $orderby_params (type cast as array)
594
-		foreach ( (array)$orderby_params as $orderby ) {
594
+		foreach ((array) $orderby_params as $orderby) {
595 595
 			// check if we have already added this param
596
-			if ( isset( self::$_query_params['orderby'][ $orderby ] )) {
596
+			if (isset(self::$_query_params['orderby'][$orderby])) {
597 597
 				// if so then remove from the $orderby_params so that the count() method below is accurate
598
-				unset( $orderby_params[ $orderby ] );
598
+				unset($orderby_params[$orderby]);
599 599
 				// then bump ahead to the next param
600 600
 				continue;
601 601
 			}
602 602
 			// this will ad a comma depending on whether this is the first or last param
603
-			$glue = $counter == 0 || $counter == count( $orderby_params ) ? ' ' : ', ';
603
+			$glue = $counter == 0 || $counter == count($orderby_params) ? ' ' : ', ';
604 604
 			// ok what's we dealing with?
605
-			switch ( $orderby ) {
605
+			switch ($orderby) {
606 606
 				case 'id' :
607 607
 				case 'ID' :
608
-					$SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
608
+					$SQL .= $glue.$wpdb->posts.'.ID '.$sort;
609 609
 					break;
610 610
 				case 'end_date' :
611
-					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
611
+					$SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort;
612 612
 					break;
613 613
 				case 'event_name' :
614
-					$SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
614
+					$SQL .= $glue.$wpdb->posts.'.post_title '.$sort;
615 615
 					break;
616 616
 				case 'category_slug' :
617
-					$SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
617
+					$SQL .= $glue.$wpdb->terms.'.slug '.$sort;
618 618
 					break;
619 619
 				case 'ticket_start' :
620
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
620
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort;
621 621
 					break;
622 622
 				case 'ticket_end' :
623
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
623
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort;
624 624
 					break;
625 625
 				case 'venue_title' :
626
-					$SQL .= $glue . 'venue_title ' . $sort;
626
+					$SQL .= $glue.'venue_title '.$sort;
627 627
 					break;
628 628
 				case 'city' :
629
-					$SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
629
+					$SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort;
630 630
 					break;
631 631
 				case 'state' :
632
-					$SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
632
+					$SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort;
633 633
 					break;
634 634
 				case 'start_date' :
635 635
 				default :
636
-					$SQL .= $glue . ' event_start_date ' . $sort;
636
+					$SQL .= $glue.' event_start_date '.$sort;
637 637
 					break;
638 638
 			}
639 639
 			// add to array of orderby params that have been added
640
-			self::$_query_params['orderby'][ $orderby ] = TRUE;
641
-			$counter ++;
640
+			self::$_query_params['orderby'][$orderby] = TRUE;
641
+			$counter++;
642 642
 		}
643 643
 		return $SQL;
644 644
 	}
Please login to merge, or discard this patch.