Completed
Branch BUG-10458-sql-injection-via-sh... (c8fb1e)
by
unknown
129:18 queued 116:23
created
shortcodes/espresso_events/EES_Espresso_Events.shortcode.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
 		// grab attributes and merge with defaults, then extract
105 105
 		$attributes = array_merge( (array) $default_espresso_events_shortcode_atts, (array) $attributes );
106 106
 		$attributes = \EES_Shortcode::sanitize_attributes(
107
-		    $attributes,
108
-            // the following get sanitized/whitelisted in EEH_Event_Query
109
-            array(
110
-                'category_slug' => 'skip_sanitization',
111
-                'show_expired'  => 'skip_sanitization',
112
-                'order_by'      => 'skip_sanitization',
113
-                'month'         => 'skip_sanitization',
114
-                'sort'          => 'skip_sanitization',
115
-            )
116
-        );
107
+			$attributes,
108
+			// the following get sanitized/whitelisted in EEH_Event_Query
109
+			array(
110
+				'category_slug' => 'skip_sanitization',
111
+				'show_expired'  => 'skip_sanitization',
112
+				'order_by'      => 'skip_sanitization',
113
+				'month'         => 'skip_sanitization',
114
+				'sort'          => 'skip_sanitization',
115
+			)
116
+		);
117 117
 		// make sure we use the_excerpt()
118 118
 		add_filter( 'FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true' );
119 119
 		// apply query filters
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 
233 233
 
234 234
 	/**
235
-     * event_list_css
236
-     *
237
-     * @param string $event_list_css
235
+	 * event_list_css
236
+	 *
237
+	 * @param string $event_list_css
238 238
 	 * @return string
239 239
 	 */
240 240
 	public function event_list_css( $event_list_css = '' ) {
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 	 * @param WP $WP
51 51
 	 * @return    void
52 52
 	 */
53
-	public function run( WP $WP ) {
54
-		if ( did_action( 'pre_get_posts' ) && did_action( 'send_headers' ) ) {
53
+	public function run(WP $WP) {
54
+		if (did_action('pre_get_posts') && did_action('send_headers')) {
55 55
 			EED_Events_Archive::instance()->event_list();
56 56
 		} else {
57 57
 			// this will trigger the EED_Events_Archive module's event_list() method during the pre_get_posts hook point,
58 58
 			// this allows us to initialize things, enqueue assets, etc,
59 59
 			// as well, this saves an instantiation of the module in an array using 'espresso_events' as the key, so that we can retrieve it
60
-			add_action( 'pre_get_posts', array( EED_Events_Archive::instance(), 'event_list' ) );
60
+			add_action('pre_get_posts', array(EED_Events_Archive::instance(), 'event_list'));
61 61
 		}
62 62
 	}
63 63
 
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	 *  @param 	array 	$attributes
80 80
 	 *  @return 	string
81 81
 	 */
82
-	public function process_shortcode( $attributes = array() ) {
82
+	public function process_shortcode($attributes = array()) {
83 83
 		// make sure EED_Events_Archive is setup properly
84
-		if ( apply_filters( 'FHEE__fallback_shortcode_processor__EES_Espresso_Events', FALSE )) {
84
+		if (apply_filters('FHEE__fallback_shortcode_processor__EES_Espresso_Events', FALSE)) {
85 85
 			EED_Events_Archive::instance()->event_list();
86 86
 		}
87 87
 		//set default attributes
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 			$default_espresso_events_shortcode_atts
103 103
 		);
104 104
 		// grab attributes and merge with defaults, then extract
105
-		$attributes = array_merge( (array) $default_espresso_events_shortcode_atts, (array) $attributes );
105
+		$attributes = array_merge((array) $default_espresso_events_shortcode_atts, (array) $attributes);
106 106
 		$attributes = \EES_Shortcode::sanitize_attributes(
107 107
 		    $attributes,
108 108
             // the following get sanitized/whitelisted in EEH_Event_Query
@@ -115,22 +115,22 @@  discard block
 block discarded – undo
115 115
             )
116 116
         );
117 117
 		// make sure we use the_excerpt()
118
-		add_filter( 'FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true' );
118
+		add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true');
119 119
 		// apply query filters
120
-		add_filter( 'FHEE__EEH_Event_Query__apply_query_filters', '__return_true' );
120
+		add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
121 121
 		// run the query
122 122
 		global $wp_query;
123
-		$wp_query = new EE_Event_List_Query( $attributes );
123
+		$wp_query = new EE_Event_List_Query($attributes);
124 124
 		// check what template is loaded and load filters accordingly
125
-		EED_Events_Archive::instance()->template_include( 'loop-espresso_events.php' );
125
+		EED_Events_Archive::instance()->template_include('loop-espresso_events.php');
126 126
 		// load our template
127
-		$event_list = EEH_Template::locate_template( 'loop-espresso_events.php', array(), TRUE, TRUE );
127
+		$event_list = EEH_Template::locate_template('loop-espresso_events.php', array(), TRUE, TRUE);
128 128
 		// now reset the query and postdata
129 129
 		wp_reset_query();
130 130
 		wp_reset_postdata();
131 131
 		EED_Events_Archive::remove_all_events_archive_filters();
132 132
 		// remove query filters
133
-		remove_filter( 'FHEE__EEH_Event_Query__apply_query_filters', '__return_true' );
133
+		remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
134 134
 		// pull our content from the output buffer and return it
135 135
 		return $event_list;
136 136
 	}
@@ -174,43 +174,43 @@  discard block
 block discarded – undo
174 174
 	 *
175 175
 	 * @param array $args
176 176
 	 */
177
-	public function __construct( $args = array() ) {
177
+	public function __construct($args = array()) {
178 178
 		// incoming args could be a mix of WP query args + EE shortcode args
179
-		foreach ( $args as $key =>$value ) {
180
-			$property = '_' . $key;
179
+		foreach ($args as $key =>$value) {
180
+			$property = '_'.$key;
181 181
 			// if the arg is a property of this class, then it's an EE shortcode arg
182
-			if ( property_exists( $this, $property )) {
182
+			if (property_exists($this, $property)) {
183 183
 				// set the property value
184 184
 				$this->{$property} = $value;
185 185
 				// then remove it from the array of args that will later be passed to WP_Query()
186
-				unset( $args[ $key ] );
186
+				unset($args[$key]);
187 187
 			}
188 188
 		}
189 189
 		//add query filters
190 190
 		EEH_Event_Query::add_query_filters();
191 191
 		// set params that will get used by the filters
192
-		EEH_Event_Query::set_query_params( $this->_month, $this->_category_slug, $this->_show_expired, $this->_order_by, $this->_sort );
192
+		EEH_Event_Query::set_query_params($this->_month, $this->_category_slug, $this->_show_expired, $this->_order_by, $this->_sort);
193 193
 		// first off, let's remove any filters from previous queries
194
-		remove_filter( 'FHEE__archive_espresso_events_template__upcoming_events_h1', array( $this, 'event_list_title' ));
195
-		remove_all_filters( 'FHEE__content_espresso_events__event_class' );
194
+		remove_filter('FHEE__archive_espresso_events_template__upcoming_events_h1', array($this, 'event_list_title'));
195
+		remove_all_filters('FHEE__content_espresso_events__event_class');
196 196
 		// Event List Title ?
197
-		add_filter( 'FHEE__archive_espresso_events_template__upcoming_events_h1', array( $this, 'event_list_title' ), 10, 1 );
197
+		add_filter('FHEE__archive_espresso_events_template__upcoming_events_h1', array($this, 'event_list_title'), 10, 1);
198 198
 		// add the css class
199
-		add_filter( 'FHEE__content_espresso_events__event_class', array( $this, 'event_list_css' ), 10, 1 );
199
+		add_filter('FHEE__content_espresso_events__event_class', array($this, 'event_list_css'), 10, 1);
200 200
 		// the current "page" we are viewing
201
-		$paged = max( 1, get_query_var( 'paged' ));
201
+		$paged = max(1, get_query_var('paged'));
202 202
 		// Force these args
203
-		$args = array_merge( $args, array(
203
+		$args = array_merge($args, array(
204 204
 			'post_type' => 'espresso_events',
205 205
 			'posts_per_page' => $this->_limit,
206 206
 			'update_post_term_cache' => FALSE,
207 207
 			'update_post_meta_cache' => FALSE,
208 208
 			'paged' => $paged,
209
-			'offset' => ( $paged - 1 ) * $this->_limit
209
+			'offset' => ($paged - 1) * $this->_limit
210 210
 		));
211 211
 
212 212
 		// run the query
213
-		parent::__construct( $args );
213
+		parent::__construct($args);
214 214
 	}
215 215
 
216 216
 
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	 * @param string $event_list_title
223 223
 	 * @return string
224 224
 	 */
225
-	public function event_list_title( $event_list_title = '' ) {
226
-		if ( ! empty( $this->_title )) {
225
+	public function event_list_title($event_list_title = '') {
226
+		if ( ! empty($this->_title)) {
227 227
 			return $this->_title;
228 228
 		}
229 229
 		return $event_list_title;
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
      * @param string $event_list_css
238 238
 	 * @return string
239 239
 	 */
240
-	public function event_list_css( $event_list_css = '' ) {
241
-		$event_list_css .=  ! empty( $event_list_css ) ? ' ' : '';
242
-		$event_list_css .=  ! empty( $this->_css_class ) ? $this->_css_class : '';
243
-		$event_list_css .=  ! empty( $event_list_css ) ? ' ' : '';
244
-		$event_list_css .=  ! empty( $this->_category_slug ) ? $this->_category_slug : '';
240
+	public function event_list_css($event_list_css = '') {
241
+		$event_list_css .= ! empty($event_list_css) ? ' ' : '';
242
+		$event_list_css .= ! empty($this->_css_class) ? $this->_css_class : '';
243
+		$event_list_css .= ! empty($event_list_css) ? ' ' : '';
244
+		$event_list_css .= ! empty($this->_category_slug) ? $this->_category_slug : '';
245 245
 		return $event_list_css;
246 246
 	}
247 247
 
Please login to merge, or discard this patch.
core/helpers/EEH_Event_Query.helper.php 2 patches
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public static function apply_query_filters( WP_Query $WP_Query ) {
93 93
 		return (
94
-		    isset( $WP_Query->query, $WP_Query->query['post_type'] )
95
-            && $WP_Query->query['post_type'] === 'espresso_events'
96
-        ) ||  apply_filters( 'FHEE__EEH_Event_Query__apply_query_filters', false ) ;
94
+			isset( $WP_Query->query, $WP_Query->query['post_type'] )
95
+			&& $WP_Query->query['post_type'] === 'espresso_events'
96
+		) ||  apply_filters( 'FHEE__EEH_Event_Query__apply_query_filters', false ) ;
97 97
 	}
98 98
 
99 99
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public static function filter_query_parts( WP_Query $WP_Query ) {
106 106
 		// ONLY add our filters if this isn't the main wp_query,
107
-        // because if this is the main wp_query we already have
108
-        // our cpt strategies take care of adding things in.
107
+		// because if this is the main wp_query we already have
108
+		// our cpt strategies take care of adding things in.
109 109
 		if ( $WP_Query instanceof WP_Query && ! $WP_Query->is_main_query() ) {
110 110
 			// build event list query
111 111
 			add_filter( 'posts_fields', array( 'EEH_Event_Query', 'posts_fields' ), 10, 2 );
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
 	 * @param string $orderby
128 128
 	 * @param string $sort
129 129
 	 */
130
-    public static function set_query_params(
131
-        $month = '',
132
-        $category = '',
133
-        $show_expired = false,
134
-        $orderby = 'start_date',
135
-        $sort = 'ASC'
136
-    ) {
130
+	public static function set_query_params(
131
+		$month = '',
132
+		$category = '',
133
+		$show_expired = false,
134
+		$orderby = 'start_date',
135
+		$sort = 'ASC'
136
+	) {
137 137
 		self::$_query_params = array();
138 138
 		EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month( $month );
139 139
 		EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug( $category );
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	 * @return    string
152 152
 	 */
153 153
 	private static function _display_month( $month = '' ) {
154
-        return sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month', $month));
155
-    }
154
+		return sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month', $month));
155
+	}
156 156
 
157 157
 
158 158
 
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 	private static function _show_expired( $show_expired = false ) {
178 178
 		// override default expired option if set via filter
179 179
 		return filter_var(
180
-		    EE_Registry::instance()->REQ->get('event_query_show_expired', $show_expired),
181
-            FILTER_VALIDATE_BOOLEAN
182
-        );
180
+			EE_Registry::instance()->REQ->get('event_query_show_expired', $show_expired),
181
+			FILTER_VALIDATE_BOOLEAN
182
+		);
183 183
 	}
184 184
 
185 185
 
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
 	private static function _orderby( $orderby = 'start_date' ) {
194 194
 		$event_query_orderby = EE_Registry::instance()->REQ->get('event_query_orderby', $orderby);
195 195
 		$event_query_orderby = is_array( $event_query_orderby )
196
-            ? $event_query_orderby
197
-            : explode( ',', $event_query_orderby );
196
+			? $event_query_orderby
197
+			: explode( ',', $event_query_orderby );
198 198
 		$event_query_orderby = array_map( 'trim', $event_query_orderby );
199 199
 		$event_query_orderby = array_map( 'sanitize_text_field', $event_query_orderby );
200 200
 		return $event_query_orderby;
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
 	private static function _sort( $sort = 'ASC' ) {
212 212
 		$sort = EE_Registry::instance()->REQ->get('event_query_sort', $sort);
213 213
 		return in_array( $sort, array( 'ASC', 'asc', 'DESC', 'desc' ), true)
214
-            ? strtoupper( $sort )
215
-            : 'ASC';
214
+			? strtoupper( $sort )
215
+			: 'ASC';
216 216
 	}
217 217
 
218 218
 
@@ -235,14 +235,14 @@  discard block
 block discarded – undo
235 235
 
236 236
 
237 237
 
238
-    /**
239
-     *    posts_fields
240
-     *
241
-     * @param          $SQL
242
-     * @param WP_Query $wp_query
243
-     * @return    string
244
-     * @throws \EE_Error
245
-     */
238
+	/**
239
+	 *    posts_fields
240
+	 *
241
+	 * @param          $SQL
242
+	 * @param WP_Query $wp_query
243
+	 * @return    string
244
+	 * @throws \EE_Error
245
+	 */
246 246
 	public static function posts_fields( $SQL, WP_Query $wp_query ) {
247 247
 		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
248 248
 			// adds something like ", wp_esp_datetime.* " to WP Query SELECT statement
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
 
254 254
 
255 255
 
256
-    /**
257
-     *    posts_join_sql_for_terms
258
-     *
259
-     * @param array $orderby_params
260
-     * @return    string
261
-     * @throws \EE_Error
262
-     */
256
+	/**
257
+	 *    posts_join_sql_for_terms
258
+	 *
259
+	 * @param array $orderby_params
260
+	 * @return    string
261
+	 * @throws \EE_Error
262
+	 */
263 263
 	public static function posts_fields_sql_for_orderby( $orderby_params = array() ) {
264 264
 		$SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ' ;
265 265
 		foreach( (array)$orderby_params as $orderby ) {
@@ -292,14 +292,14 @@  discard block
 block discarded – undo
292 292
 
293 293
 
294 294
 
295
-    /**
296
-     *    posts_join
297
-     *
298
-     * @param string   $SQL
299
-     * @param WP_Query $wp_query
300
-     * @return    string
301
-     * @throws \EE_Error
302
-     */
295
+	/**
296
+	 *    posts_join
297
+	 *
298
+	 * @param string   $SQL
299
+	 * @param WP_Query $wp_query
300
+	 * @return    string
301
+	 * @throws \EE_Error
302
+	 */
303 303
 	public static function posts_join( $SQL = '', WP_Query $wp_query ) {
304 304
 		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
305 305
 			// Category
@@ -312,14 +312,14 @@  discard block
 block discarded – undo
312 312
 
313 313
 
314 314
 
315
-    /**
316
-     *    posts_join_sql_for_terms
317
-     *
318
-     * @param string     $SQL
319
-     * @param    boolean $show_expired if TRUE, then displayed past events
320
-     * @return string
321
-     * @throws \EE_Error
322
-     */
315
+	/**
316
+	 *    posts_join_sql_for_terms
317
+	 *
318
+	 * @param string     $SQL
319
+	 * @param    boolean $show_expired if TRUE, then displayed past events
320
+	 * @return string
321
+	 * @throws \EE_Error
322
+	 */
323 323
 	public static function posts_join_sql_for_show_expired( $SQL = '', $show_expired = FALSE ) {
324 324
 		if ( ! $show_expired ) {
325 325
 			$join = EEM_Event::instance()->table() . '.ID = ';
@@ -353,24 +353,24 @@  discard block
 block discarded – undo
353 353
 
354 354
 
355 355
 
356
-    /**
357
-     *    posts_join_for_orderby
358
-     *    usage:  $SQL .= EEH_Event_Query::posts_join_for_orderby( $orderby_params );
359
-     *
360
-     * @param    string $SQL
361
-     * @param    array  $orderby_params
362
-     * @return    string
363
-     * @throws \EE_Error
364
-     */
356
+	/**
357
+	 *    posts_join_for_orderby
358
+	 *    usage:  $SQL .= EEH_Event_Query::posts_join_for_orderby( $orderby_params );
359
+	 *
360
+	 * @param    string $SQL
361
+	 * @param    array  $orderby_params
362
+	 * @return    string
363
+	 * @throws \EE_Error
364
+	 */
365 365
 	public static function posts_join_for_orderby( $SQL = '', $orderby_params = array() ) {
366 366
 		foreach ( (array)$orderby_params as $orderby ) {
367 367
 			switch ( $orderby ) {
368 368
 				case 'ticket_start' :
369 369
 				case 'ticket_end' :
370 370
 					$SQL .= EEH_Event_Query::_posts_join_for_datetime(
371
-					    $SQL,
372
-                        EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name()
373
-                    );
371
+						$SQL,
372
+						EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name()
373
+					);
374 374
 					$SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table();
375 375
 					$SQL .= ' ON (';
376 376
 					$SQL .= EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name();
@@ -398,14 +398,14 @@  discard block
 block discarded – undo
398 398
 
399 399
 
400 400
 
401
-    /**
402
-     *    _posts_join_for_datetime
403
-     *
404
-     * @param string $SQL
405
-     * @param string $join
406
-     * @return string
407
-     * @throws \EE_Error
408
-     */
401
+	/**
402
+	 *    _posts_join_for_datetime
403
+	 *
404
+	 * @param string $SQL
405
+	 * @param string $join
406
+	 * @return string
407
+	 * @throws \EE_Error
408
+	 */
409 409
 	protected static function _posts_join_for_datetime( $SQL = '', $join = '' ) {
410 410
 		if ( ! empty( $join )) {
411 411
 			$join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name();
@@ -418,13 +418,13 @@  discard block
 block discarded – undo
418 418
 
419 419
 
420 420
 
421
-    /**
422
-     *    _posts_join_for_event_venue
423
-     *
424
-     * @param string $SQL
425
-     * @return string
426
-     * @throws \EE_Error
427
-     */
421
+	/**
422
+	 *    _posts_join_for_event_venue
423
+	 *
424
+	 * @param string $SQL
425
+	 * @return string
426
+	 * @throws \EE_Error
427
+	 */
428 428
 	protected static function _posts_join_for_event_venue( $SQL = '' ) {
429 429
 		// Event Venue table name
430 430
 		$event_venue_table = EEM_Event_Venue::instance()->table();
@@ -454,13 +454,13 @@  discard block
 block discarded – undo
454 454
 
455 455
 
456 456
 
457
-    /**
458
-     *    _posts_join_for_venue_state
459
-     *
460
-     * @param string $SQL
461
-     * @return string
462
-     * @throws \EE_Error
463
-     */
457
+	/**
458
+	 *    _posts_join_for_venue_state
459
+	 *
460
+	 * @param string $SQL
461
+	 * @return string
462
+	 * @throws \EE_Error
463
+	 */
464 464
 	protected static function _posts_join_for_venue_state( $SQL = '' ) {
465 465
 		// Venue Meta table name
466 466
 		$venue_meta_table = EEM_Venue::instance()->second_table();
@@ -484,14 +484,14 @@  discard block
 block discarded – undo
484 484
 
485 485
 
486 486
 
487
-    /**
488
-     *    posts_where
489
-     *
490
-     * @param string   $SQL
491
-     * @param WP_Query $wp_query
492
-     * @return    string
493
-     * @throws \EE_Error
494
-     */
487
+	/**
488
+	 *    posts_where
489
+	 *
490
+	 * @param string   $SQL
491
+	 * @param WP_Query $wp_query
492
+	 * @return    string
493
+	 * @throws \EE_Error
494
+	 */
495 495
 	public static function posts_where( $SQL = '', WP_Query $wp_query ) {
496 496
 		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
497 497
 			// Show Expired ?
@@ -506,17 +506,17 @@  discard block
 block discarded – undo
506 506
 
507 507
 
508 508
 
509
-    /**
510
-     *    posts_where_sql_for_show_expired
511
-     *
512
-     * @param    boolean $show_expired if TRUE, then displayed past events
513
-     * @return    string
514
-     * @throws \EE_Error
515
-     */
509
+	/**
510
+	 *    posts_where_sql_for_show_expired
511
+	 *
512
+	 * @param    boolean $show_expired if TRUE, then displayed past events
513
+	 * @return    string
514
+	 * @throws \EE_Error
515
+	 */
516 516
 	public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) {
517 517
 		return ! $show_expired
518
-            ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > \'' . current_time( 'mysql', TRUE ) . '\' '
519
-            : '';
518
+			? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > \'' . current_time( 'mysql', TRUE ) . '\' '
519
+			: '';
520 520
 	}
521 521
 
522 522
 
@@ -531,19 +531,19 @@  discard block
 block discarded – undo
531 531
 		global $wpdb;
532 532
 		$event_category_slug = esc_sql($event_category_slug);
533 533
 		return ! empty( $event_category_slug )
534
-            ? " AND {$wpdb->terms}.slug = '{$event_category_slug}' "
535
-            : '';
534
+			? " AND {$wpdb->terms}.slug = '{$event_category_slug}' "
535
+			: '';
536 536
 	}
537 537
 
538 538
 
539 539
 
540
-    /**
541
-     *    posts_where_sql_for_event_list_month
542
-     *
543
-     * @param    boolean $month
544
-     * @return    string
545
-     * @throws \EE_Error
546
-     */
540
+	/**
541
+	 *    posts_where_sql_for_event_list_month
542
+	 *
543
+	 * @param    boolean $month
544
+	 * @return    string
545
+	 * @throws \EE_Error
546
+	 */
547 547
 	public static function posts_where_sql_for_event_list_month( $month = NULL ) {
548 548
 		$SQL = '';
549 549
 		if ( ! empty( $month ) ) {
@@ -558,55 +558,55 @@  discard block
 block discarded – undo
558 558
 
559 559
 
560 560
 
561
-    /**
562
-     *    posts_orderby
563
-     *
564
-     * @param string   $SQL
565
-     * @param WP_Query $wp_query
566
-     * @return    string
567
-     * @throws \EE_Error
568
-     */
561
+	/**
562
+	 *    posts_orderby
563
+	 *
564
+	 * @param string   $SQL
565
+	 * @param WP_Query $wp_query
566
+	 * @return    string
567
+	 * @throws \EE_Error
568
+	 */
569 569
 	public static function posts_orderby( $SQL = '', WP_Query $wp_query ) {
570 570
 		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
571 571
 			$SQL = EEH_Event_Query::posts_orderby_sql(
572
-			    EEH_Event_Query::$_event_query_orderby,
573
-                EEH_Event_Query::$_event_query_sort
574
-            );
572
+				EEH_Event_Query::$_event_query_orderby,
573
+				EEH_Event_Query::$_event_query_sort
574
+			);
575 575
 		}
576 576
 		return $SQL;
577 577
 	}
578 578
 
579 579
 
580 580
 
581
-    /**
582
-     *    posts_orderby_sql
583
-     *    possible parameters:
584
-     *    ID
585
-     *    start_date
586
-     *    end_date
587
-     *    event_name
588
-     *    category_slug
589
-     *    ticket_start
590
-     *    ticket_end
591
-     *    venue_title
592
-     *    city
593
-     *    state
594
-     *    **IMPORTANT**
595
-     *    make sure to also send the $orderby_params array to the posts_join_for_orderby() method
596
-     *    or else some of the table references below will result in MySQL errors
597
-     *
598
-     * @param array|bool $orderby_params
599
-     * @param string     $sort
600
-     * @return string
601
-     * @throws \EE_Error
602
-     */
581
+	/**
582
+	 *    posts_orderby_sql
583
+	 *    possible parameters:
584
+	 *    ID
585
+	 *    start_date
586
+	 *    end_date
587
+	 *    event_name
588
+	 *    category_slug
589
+	 *    ticket_start
590
+	 *    ticket_end
591
+	 *    venue_title
592
+	 *    city
593
+	 *    state
594
+	 *    **IMPORTANT**
595
+	 *    make sure to also send the $orderby_params array to the posts_join_for_orderby() method
596
+	 *    or else some of the table references below will result in MySQL errors
597
+	 *
598
+	 * @param array|bool $orderby_params
599
+	 * @param string     $sort
600
+	 * @return string
601
+	 * @throws \EE_Error
602
+	 */
603 603
 	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
604 604
 		global $wpdb;
605 605
 		$SQL = '';
606 606
 		$counter = 0;
607 607
 		$sort = in_array($sort, array('ASC', 'asc', 'DESC', 'desc'), true)
608
-            ? strtoupper($sort)
609
-            : 'ASC';
608
+			? strtoupper($sort)
609
+			: 'ASC';
610 610
 		//make sure 'orderby' is set in query params
611 611
 		if ( ! isset( self::$_query_params['orderby'] )) {
612 612
 			self::$_query_params['orderby'] = array();
Please login to merge, or discard this patch.
Spacing   +119 added lines, -119 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
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public static function add_query_filters() {
80 80
 		//add query filters
81
-		add_action( 'pre_get_posts', array( 'EEH_Event_Query', 'filter_query_parts' ), 10, 1 );
81
+		add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1);
82 82
 	}
83 83
 
84 84
 
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 	 * @param \WP_Query $WP_Query
90 90
 	 * @return bool
91 91
 	 */
92
-	public static function apply_query_filters( WP_Query $WP_Query ) {
92
+	public static function apply_query_filters(WP_Query $WP_Query) {
93 93
 		return (
94
-		    isset( $WP_Query->query, $WP_Query->query['post_type'] )
94
+		    isset($WP_Query->query, $WP_Query->query['post_type'])
95 95
             && $WP_Query->query['post_type'] === 'espresso_events'
96
-        ) ||  apply_filters( 'FHEE__EEH_Event_Query__apply_query_filters', false ) ;
96
+        ) || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false);
97 97
 	}
98 98
 
99 99
 
@@ -102,17 +102,17 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @param \WP_Query $WP_Query
104 104
 	 */
105
-	public static function filter_query_parts( WP_Query $WP_Query ) {
105
+	public static function filter_query_parts(WP_Query $WP_Query) {
106 106
 		// ONLY add our filters if this isn't the main wp_query,
107 107
         // because if this is the main wp_query we already have
108 108
         // our cpt strategies take care of adding things in.
109
-		if ( $WP_Query instanceof WP_Query && ! $WP_Query->is_main_query() ) {
109
+		if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) {
110 110
 			// build event list query
111
-			add_filter( 'posts_fields', array( 'EEH_Event_Query', 'posts_fields' ), 10, 2 );
112
-			add_filter( 'posts_join', array( 'EEH_Event_Query', 'posts_join' ), 10, 2 );
113
-			add_filter( 'posts_where', array( 'EEH_Event_Query', 'posts_where' ), 10, 2 );
114
-			add_filter( 'posts_orderby', array( 'EEH_Event_Query', 'posts_orderby' ), 10, 2 );
115
-			add_filter( 'posts_clauses_request', array( 'EEH_Event_Query', 'posts_clauses' ), 10, 2 );
111
+			add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2);
112
+			add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2);
113
+			add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2);
114
+			add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2);
115
+			add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2);
116 116
 		}
117 117
 	}
118 118
 
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
         $sort = 'ASC'
136 136
     ) {
137 137
 		self::$_query_params = array();
138
-		EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month( $month );
139
-		EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug( $category );
140
-		EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired( $show_expired );
141
-		EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby( $orderby );
142
-		EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort( $sort );
138
+		EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month);
139
+		EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category);
140
+		EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired);
141
+		EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby);
142
+		EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort);
143 143
 	}
144 144
 
145 145
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @param string $month
151 151
 	 * @return    string
152 152
 	 */
153
-	private static function _display_month( $month = '' ) {
153
+	private static function _display_month($month = '') {
154 154
         return sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month', $month));
155 155
     }
156 156
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * @param string $category
163 163
 	 * @return    string
164 164
 	 */
165
-	private static function _event_category_slug( $category = '' ) {
165
+	private static function _event_category_slug($category = '') {
166 166
 		return sanitize_title_with_dashes(EE_Registry::instance()->REQ->get('event_query_category', $category));
167 167
 	}
168 168
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @param bool $show_expired
175 175
 	 * @return    boolean
176 176
 	 */
177
-	private static function _show_expired( $show_expired = false ) {
177
+	private static function _show_expired($show_expired = false) {
178 178
 		// override default expired option if set via filter
179 179
 		return filter_var(
180 180
 		    EE_Registry::instance()->REQ->get('event_query_show_expired', $show_expired),
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
 	 * @param    string $orderby
191 191
 	 * @return    array
192 192
 	 */
193
-	private static function _orderby( $orderby = 'start_date' ) {
193
+	private static function _orderby($orderby = 'start_date') {
194 194
 		$event_query_orderby = EE_Registry::instance()->REQ->get('event_query_orderby', $orderby);
195
-		$event_query_orderby = is_array( $event_query_orderby )
195
+		$event_query_orderby = is_array($event_query_orderby)
196 196
             ? $event_query_orderby
197
-            : explode( ',', $event_query_orderby );
198
-		$event_query_orderby = array_map( 'trim', $event_query_orderby );
199
-		$event_query_orderby = array_map( 'sanitize_text_field', $event_query_orderby );
197
+            : explode(',', $event_query_orderby);
198
+		$event_query_orderby = array_map('trim', $event_query_orderby);
199
+		$event_query_orderby = array_map('sanitize_text_field', $event_query_orderby);
200 200
 		return $event_query_orderby;
201 201
 	}
202 202
 
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
 	 * @param string $sort
209 209
 	 * @return string
210 210
 	 */
211
-	private static function _sort( $sort = 'ASC' ) {
211
+	private static function _sort($sort = 'ASC') {
212 212
 		$sort = EE_Registry::instance()->REQ->get('event_query_sort', $sort);
213
-		return in_array( $sort, array( 'ASC', 'asc', 'DESC', 'desc' ), true)
214
-            ? strtoupper( $sort )
213
+		return in_array($sort, array('ASC', 'asc', 'DESC', 'desc'), true)
214
+            ? strtoupper($sort)
215 215
             : 'ASC';
216 216
 	}
217 217
 
@@ -225,10 +225,10 @@  discard block
 block discarded – undo
225 225
 	 *
226 226
 	 * @return array   array of clauses
227 227
 	 */
228
-	public static function posts_clauses( $clauses, WP_Query $wp_query ) {
229
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
228
+	public static function posts_clauses($clauses, WP_Query $wp_query) {
229
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
230 230
 			global $wpdb;
231
-			$clauses['groupby'] = $wpdb->posts . '.ID ';
231
+			$clauses['groupby'] = $wpdb->posts.'.ID ';
232 232
 		}
233 233
 		return $clauses;
234 234
 	}
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
      * @return    string
244 244
      * @throws \EE_Error
245 245
      */
246
-	public static function posts_fields( $SQL, WP_Query $wp_query ) {
247
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
246
+	public static function posts_fields($SQL, WP_Query $wp_query) {
247
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
248 248
 			// adds something like ", wp_esp_datetime.* " to WP Query SELECT statement
249
-			$SQL .= EEH_Event_Query::posts_fields_sql_for_orderby( EEH_Event_Query::$_event_query_orderby );
249
+			$SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby);
250 250
 		}
251 251
 		return $SQL;
252 252
 	}
@@ -260,29 +260,29 @@  discard block
 block discarded – undo
260 260
      * @return    string
261 261
      * @throws \EE_Error
262 262
      */
263
-	public static function posts_fields_sql_for_orderby( $orderby_params = array() ) {
264
-		$SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ' ;
265
-		foreach( (array)$orderby_params as $orderby ) {
266
-			switch ( $orderby ) {
263
+	public static function posts_fields_sql_for_orderby($orderby_params = array()) {
264
+		$SQL = ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date ';
265
+		foreach ((array) $orderby_params as $orderby) {
266
+			switch ($orderby) {
267 267
 
268 268
 				case 'ticket_start' :
269
-					$SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date' ;
269
+					$SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_start_date';
270 270
 					break;
271 271
 
272 272
 				case 'ticket_end' :
273
-					$SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date' ;
273
+					$SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_end_date';
274 274
 					break;
275 275
 
276 276
 				case 'venue_title' :
277
-					$SQL .= ', Venue.post_title AS venue_title' ;
277
+					$SQL .= ', Venue.post_title AS venue_title';
278 278
 					break;
279 279
 
280 280
 				case 'city' :
281
-					$SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city' ;
281
+					$SQL .= ', '.EEM_Venue::instance()->second_table().'.VNU_city';
282 282
 					break;
283 283
 
284 284
 				case 'state' :
285
-					$SQL .= ', ' . EEM_State::instance()->table() . '.STA_name' ;
285
+					$SQL .= ', '.EEM_State::instance()->table().'.STA_name';
286 286
 					break;
287 287
 
288 288
 			}
@@ -300,12 +300,12 @@  discard block
 block discarded – undo
300 300
      * @return    string
301 301
      * @throws \EE_Error
302 302
      */
303
-	public static function posts_join( $SQL = '', WP_Query $wp_query ) {
304
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
303
+	public static function posts_join($SQL = '', WP_Query $wp_query) {
304
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
305 305
 			// Category
306
-			$SQL = EEH_Event_Query::posts_join_sql_for_show_expired( $SQL, EEH_Event_Query::$_event_query_show_expired );
307
-			$SQL = EEH_Event_Query::posts_join_sql_for_terms( $SQL, EEH_Event_Query::$_event_query_category );
308
-			$SQL = EEH_Event_Query::posts_join_for_orderby( $SQL, EEH_Event_Query::$_event_query_orderby );
306
+			$SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired);
307
+			$SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category);
308
+			$SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby);
309 309
 		}
310 310
 		return $SQL;
311 311
 	}
@@ -320,13 +320,13 @@  discard block
 block discarded – undo
320 320
      * @return string
321 321
      * @throws \EE_Error
322 322
      */
323
-	public static function posts_join_sql_for_show_expired( $SQL = '', $show_expired = FALSE ) {
324
-		if ( ! $show_expired ) {
325
-			$join = EEM_Event::instance()->table() . '.ID = ';
326
-			$join .= EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name();
323
+	public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = FALSE) {
324
+		if ( ! $show_expired) {
325
+			$join = EEM_Event::instance()->table().'.ID = ';
326
+			$join .= EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name();
327 327
 			// don't add if this is already in the SQL
328
-			if ( strpos( $SQL, $join ) === FALSE ) {
329
-				$SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) ';
328
+			if (strpos($SQL, $join) === FALSE) {
329
+				$SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' ) ';
330 330
 			}
331 331
 		}
332 332
 		return $SQL;
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 	 * @param 	string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet
342 342
 	 * @return 	string
343 343
 	 */
344
-	public static function posts_join_sql_for_terms( $SQL = '', $join_terms = '' ) {
345
-		if ( ! empty( $join_terms ) ) {
344
+	public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') {
345
+		if ( ! empty($join_terms)) {
346 346
 			global $wpdb;
347 347
 			$SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
348 348
 			$SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
@@ -362,33 +362,33 @@  discard block
 block discarded – undo
362 362
      * @return    string
363 363
      * @throws \EE_Error
364 364
      */
365
-	public static function posts_join_for_orderby( $SQL = '', $orderby_params = array() ) {
366
-		foreach ( (array)$orderby_params as $orderby ) {
367
-			switch ( $orderby ) {
365
+	public static function posts_join_for_orderby($SQL = '', $orderby_params = array()) {
366
+		foreach ((array) $orderby_params as $orderby) {
367
+			switch ($orderby) {
368 368
 				case 'ticket_start' :
369 369
 				case 'ticket_end' :
370 370
 					$SQL .= EEH_Event_Query::_posts_join_for_datetime(
371 371
 					    $SQL,
372
-                        EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name()
372
+                        EEM_Datetime_Ticket::instance()->table().'.'.EEM_Datetime::instance()->primary_key_name()
373 373
                     );
374
-					$SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table();
374
+					$SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table();
375 375
 					$SQL .= ' ON (';
376
-					$SQL .= EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name();
376
+					$SQL .= EEM_Datetime_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name();
377 377
 					$SQL .= ' = ';
378
-					$SQL .= EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name();
379
-					$SQL .=  ' )';
378
+					$SQL .= EEM_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name();
379
+					$SQL .= ' )';
380 380
 					break;
381 381
 				case 'venue_title' :
382 382
 				case 'city' :
383
-					$SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL );
383
+					$SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL);
384 384
 					break;
385 385
 				case 'state' :
386
-					$SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL );
387
-					$SQL .= EEH_Event_Query::_posts_join_for_venue_state( $SQL );
386
+					$SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL);
387
+					$SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL);
388 388
 					break;
389 389
 				case 'start_date' :
390 390
 				default :
391
-					$SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Event::instance()->table() . '.ID' );
391
+					$SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table().'.ID');
392 392
 					break;
393 393
 
394 394
 			}
@@ -406,11 +406,11 @@  discard block
 block discarded – undo
406 406
      * @return string
407 407
      * @throws \EE_Error
408 408
      */
409
-	protected static function _posts_join_for_datetime( $SQL = '', $join = '' ) {
410
-		if ( ! empty( $join )) {
411
-			$join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name();
412
-			if ( strpos( $SQL, $join ) === FALSE ) {
413
-				return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )';
409
+	protected static function _posts_join_for_datetime($SQL = '', $join = '') {
410
+		if ( ! empty($join)) {
411
+			$join .= ' = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name();
412
+			if (strpos($SQL, $join) === FALSE) {
413
+				return ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' )';
414 414
 			}
415 415
 		}
416 416
 		return '';
@@ -425,14 +425,14 @@  discard block
 block discarded – undo
425 425
      * @return string
426 426
      * @throws \EE_Error
427 427
      */
428
-	protected static function _posts_join_for_event_venue( $SQL = '' ) {
428
+	protected static function _posts_join_for_event_venue($SQL = '') {
429 429
 		// Event Venue table name
430 430
 		$event_venue_table = EEM_Event_Venue::instance()->table();
431 431
 		// generate conditions for:  Event <=> Event Venue  JOIN clause
432
-		$event_to_event_venue_join = EEM_Event::instance()->table() . '.ID = ';
433
-		$event_to_event_venue_join .= $event_venue_table . '.' . EEM_Event::instance()->primary_key_name();
432
+		$event_to_event_venue_join = EEM_Event::instance()->table().'.ID = ';
433
+		$event_to_event_venue_join .= $event_venue_table.'.'.EEM_Event::instance()->primary_key_name();
434 434
 		// don't add joins if they have already been added
435
-		if ( strpos( $SQL, $event_to_event_venue_join ) === FALSE ) {
435
+		if (strpos($SQL, $event_to_event_venue_join) === FALSE) {
436 436
 			// Venue table name
437 437
 			$venue_table = EEM_Venue::instance()->table();
438 438
 			// Venue table pk
@@ -445,10 +445,10 @@  discard block
 block discarded – undo
445 445
 			$venue_SQL .= " LEFT JOIN $venue_table as Venue ON ( $event_venue_table.$venue_table_pk = Venue.ID )";
446 446
 			// generate JOIN clause for: Venue <=> Venue Meta
447 447
 			$venue_SQL .= " LEFT JOIN $venue_meta_table ON ( Venue.ID = $venue_meta_table.$venue_table_pk )";
448
-			unset( $event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table );
448
+			unset($event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table);
449 449
 			return $venue_SQL;
450 450
 		}
451
-		unset( $event_venue_table, $event_to_event_venue_join );
451
+		unset($event_venue_table, $event_to_event_venue_join);
452 452
 		return '';
453 453
 	}
454 454
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
      * @return string
462 462
      * @throws \EE_Error
463 463
      */
464
-	protected static function _posts_join_for_venue_state( $SQL = '' ) {
464
+	protected static function _posts_join_for_venue_state($SQL = '') {
465 465
 		// Venue Meta table name
466 466
 		$venue_meta_table = EEM_Venue::instance()->second_table();
467 467
 		// State table name
@@ -469,16 +469,16 @@  discard block
 block discarded – undo
469 469
 		// State table pk
470 470
 		$state_table_pk = EEM_State::instance()->primary_key_name();
471 471
 		// verify vars
472
-		if ( $venue_meta_table && $state_table && $state_table_pk ) {
472
+		if ($venue_meta_table && $state_table && $state_table_pk) {
473 473
 			// like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID
474 474
 			$join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk";
475 475
 			// don't add join if it has already been added
476
-			if ( strpos( $SQL, $join ) === FALSE ) {
477
-				unset( $state_table_pk, $venue_meta_table, $venue_table_pk );
476
+			if (strpos($SQL, $join) === FALSE) {
477
+				unset($state_table_pk, $venue_meta_table, $venue_table_pk);
478 478
 				return " LEFT JOIN $state_table ON ( $join )";
479 479
 			}
480 480
 		}
481
-		unset( $join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk );
481
+		unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk);
482 482
 		return '';
483 483
 	}
484 484
 
@@ -492,14 +492,14 @@  discard block
 block discarded – undo
492 492
      * @return    string
493 493
      * @throws \EE_Error
494 494
      */
495
-	public static function posts_where( $SQL = '', WP_Query $wp_query ) {
496
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
495
+	public static function posts_where($SQL = '', WP_Query $wp_query) {
496
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
497 497
 			// Show Expired ?
498
-			$SQL .= EEH_Event_Query::posts_where_sql_for_show_expired( EEH_Event_Query::$_event_query_show_expired );
498
+			$SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired);
499 499
 			// Category
500
-			$SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug( EEH_Event_Query::$_event_query_category );
500
+			$SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category);
501 501
 			// Start Date
502
-			$SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month( EEH_Event_Query::$_event_query_month );
502
+			$SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month);
503 503
 		}
504 504
 		return $SQL;
505 505
 	}
@@ -513,9 +513,9 @@  discard block
 block discarded – undo
513 513
      * @return    string
514 514
      * @throws \EE_Error
515 515
      */
516
-	public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) {
516
+	public static function posts_where_sql_for_show_expired($show_expired = FALSE) {
517 517
 		return ! $show_expired
518
-            ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > \'' . current_time( 'mysql', TRUE ) . '\' '
518
+            ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > \''.current_time('mysql', TRUE).'\' '
519 519
             : '';
520 520
 	}
521 521
 
@@ -527,10 +527,10 @@  discard block
 block discarded – undo
527 527
 	 * @param    boolean $event_category_slug
528 528
 	 * @return    string
529 529
 	 */
530
-	public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) {
530
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) {
531 531
 		global $wpdb;
532 532
 		$event_category_slug = esc_sql($event_category_slug);
533
-		return ! empty( $event_category_slug )
533
+		return ! empty($event_category_slug)
534 534
             ? " AND {$wpdb->terms}.slug = '{$event_category_slug}' "
535 535
             : '';
536 536
 	}
@@ -544,14 +544,14 @@  discard block
 block discarded – undo
544 544
      * @return    string
545 545
      * @throws \EE_Error
546 546
      */
547
-	public static function posts_where_sql_for_event_list_month( $month = NULL ) {
547
+	public static function posts_where_sql_for_event_list_month($month = NULL) {
548 548
 		$SQL = '';
549
-		if ( ! empty( $month ) ) {
549
+		if ( ! empty($month)) {
550 550
 			$datetime_table = EEM_Datetime::instance()->table();
551 551
 			// event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
552
-			$SQL = " AND {$datetime_table}.DTT_EVT_start <= '" . date( 'Y-m-t 23:59:59', strtotime( $month . ' 1') ) . "'";
552
+			$SQL = " AND {$datetime_table}.DTT_EVT_start <= '".date('Y-m-t 23:59:59', strtotime($month.' 1'))."'";
553 553
 			// event end date is GREATER than the start of the month ( so nothing that ended before this month )
554
-			$SQL .= " AND {$datetime_table}.DTT_EVT_end >= '" . date( 'Y-m-01 0:0:00', strtotime( $month . ' 1') ) . "' ";
554
+			$SQL .= " AND {$datetime_table}.DTT_EVT_end >= '".date('Y-m-01 0:0:00', strtotime($month.' 1'))."' ";
555 555
 		}
556 556
 		return $SQL;
557 557
 	}
@@ -566,8 +566,8 @@  discard block
 block discarded – undo
566 566
      * @return    string
567 567
      * @throws \EE_Error
568 568
      */
569
-	public static function posts_orderby( $SQL = '', WP_Query $wp_query ) {
570
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
569
+	public static function posts_orderby($SQL = '', WP_Query $wp_query) {
570
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
571 571
 			$SQL = EEH_Event_Query::posts_orderby_sql(
572 572
 			    EEH_Event_Query::$_event_query_orderby,
573 573
                 EEH_Event_Query::$_event_query_sort
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
      * @return string
601 601
      * @throws \EE_Error
602 602
      */
603
-	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
603
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') {
604 604
 		global $wpdb;
605 605
 		$SQL = '';
606 606
 		$counter = 0;
@@ -608,58 +608,58 @@  discard block
 block discarded – undo
608 608
             ? strtoupper($sort)
609 609
             : 'ASC';
610 610
 		//make sure 'orderby' is set in query params
611
-		if ( ! isset( self::$_query_params['orderby'] )) {
611
+		if ( ! isset(self::$_query_params['orderby'])) {
612 612
 			self::$_query_params['orderby'] = array();
613 613
 		}
614 614
 		// loop thru $orderby_params (type cast as array)
615
-		foreach ( (array)$orderby_params as $orderby ) {
615
+		foreach ((array) $orderby_params as $orderby) {
616 616
 			// check if we have already added this param
617
-			if ( isset( self::$_query_params['orderby'][ $orderby ] )) {
617
+			if (isset(self::$_query_params['orderby'][$orderby])) {
618 618
 				// if so then remove from the $orderby_params so that the count() method below is accurate
619
-				unset( $orderby_params[ $orderby ] );
619
+				unset($orderby_params[$orderby]);
620 620
 				// then bump ahead to the next param
621 621
 				continue;
622 622
 			}
623 623
 			// this will ad a comma depending on whether this is the first or last param
624
-			$glue = $counter === 0 || $counter === count( $orderby_params ) ? ' ' : ', ';
624
+			$glue = $counter === 0 || $counter === count($orderby_params) ? ' ' : ', ';
625 625
 			// ok what's we dealing with?
626
-			switch ( $orderby ) {
626
+			switch ($orderby) {
627 627
 				case 'id' :
628 628
 				case 'ID' :
629
-					$SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
629
+					$SQL .= $glue.$wpdb->posts.'.ID '.$sort;
630 630
 					break;
631 631
 				case 'end_date' :
632
-					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
632
+					$SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort;
633 633
 					break;
634 634
 				case 'event_name' :
635
-					$SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
635
+					$SQL .= $glue.$wpdb->posts.'.post_title '.$sort;
636 636
 					break;
637 637
 				case 'category_slug' :
638
-					$SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
638
+					$SQL .= $glue.$wpdb->terms.'.slug '.$sort;
639 639
 					break;
640 640
 				case 'ticket_start' :
641
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
641
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort;
642 642
 					break;
643 643
 				case 'ticket_end' :
644
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
644
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort;
645 645
 					break;
646 646
 				case 'venue_title' :
647
-					$SQL .= $glue . 'venue_title ' . $sort;
647
+					$SQL .= $glue.'venue_title '.$sort;
648 648
 					break;
649 649
 				case 'city' :
650
-					$SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
650
+					$SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort;
651 651
 					break;
652 652
 				case 'state' :
653
-					$SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
653
+					$SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort;
654 654
 					break;
655 655
 				case 'start_date' :
656 656
 				default :
657
-					$SQL .= $glue . ' event_start_date ' . $sort;
657
+					$SQL .= $glue.' event_start_date '.$sort;
658 658
 					break;
659 659
 			}
660 660
 			// add to array of orderby params that have been added
661
-			self::$_query_params['orderby'][ $orderby ] = TRUE;
662
-			$counter ++;
661
+			self::$_query_params['orderby'][$orderby] = TRUE;
662
+			$counter++;
663 663
 		}
664 664
 		return $SQL;
665 665
 	}
Please login to merge, or discard this patch.
core/EES_Shortcode.shortcode.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 		}
73 73
 		$shortcode = str_replace( 'EES_', '', strtoupper( $shortcode_class ));
74 74
 		$shortcode_obj = isset( EE_Registry::instance()->shortcodes->{$shortcode} )
75
-            ? EE_Registry::instance()->shortcodes->{$shortcode}
76
-            : null;
75
+			? EE_Registry::instance()->shortcodes->{$shortcode}
76
+			: null;
77 77
 		return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self'
78
-            ? $shortcode_obj
79
-            : new $shortcode_class();
78
+			? $shortcode_obj
79
+			: new $shortcode_class();
80 80
 	}
81 81
 
82 82
 
@@ -142,47 +142,47 @@  discard block
 block discarded – undo
142 142
 
143 143
 
144 144
 
145
-    /**
146
-     * @param array $attributes
147
-     * @param array $custom_sanitization
148
-     * @return array
149
-     */
150
-    public static function sanitize_attributes(array $attributes, $custom_sanitization = array())
151
-    {
152
-        foreach ($attributes as $key => $value) {
153
-            // is a custom sanitization callback specified ?
154
-            if ( isset($custom_sanitization[$key])) {
155
-                $callback = $custom_sanitization[$key];
156
-                if ($callback === 'skip_sanitization') {
157
-                    $attributes[$key] = $value;
158
-                    continue;
159
-                } else if (function_exists($callback)){
160
-                    $attributes[$key] = $callback($value);
161
-                    continue;
162
-                }
163
-            }
164
-            switch (true) {
165
-                case $value === null :
166
-                case is_int($value) :
167
-                case is_float($value) :
168
-                    // typical booleans
169
-                case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) :
170
-                    $attributes[$key] = $value;
171
-                    break;
172
-                case is_string($value) :
173
-                    $attributes[$key] = sanitize_text_field($value);
174
-                    break;
175
-                case is_array($value) :
176
-                    $attributes[$key] = \EES_Shortcode::sanitize_attributes($value);
177
-                    break;
178
-                default :
179
-                    // only remaining data types are Object and Resource
180
-                    // which are not allowed as shortcode attributes
181
-                    $attributes[$key] = null;
182
-                    break;
183
-            }
184
-        }
185
-        return $attributes;
145
+	/**
146
+	 * @param array $attributes
147
+	 * @param array $custom_sanitization
148
+	 * @return array
149
+	 */
150
+	public static function sanitize_attributes(array $attributes, $custom_sanitization = array())
151
+	{
152
+		foreach ($attributes as $key => $value) {
153
+			// is a custom sanitization callback specified ?
154
+			if ( isset($custom_sanitization[$key])) {
155
+				$callback = $custom_sanitization[$key];
156
+				if ($callback === 'skip_sanitization') {
157
+					$attributes[$key] = $value;
158
+					continue;
159
+				} else if (function_exists($callback)){
160
+					$attributes[$key] = $callback($value);
161
+					continue;
162
+				}
163
+			}
164
+			switch (true) {
165
+				case $value === null :
166
+				case is_int($value) :
167
+				case is_float($value) :
168
+					// typical booleans
169
+				case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) :
170
+					$attributes[$key] = $value;
171
+					break;
172
+				case is_string($value) :
173
+					$attributes[$key] = sanitize_text_field($value);
174
+					break;
175
+				case is_array($value) :
176
+					$attributes[$key] = \EES_Shortcode::sanitize_attributes($value);
177
+					break;
178
+				default :
179
+					// only remaining data types are Object and Resource
180
+					// which are not allowed as shortcode attributes
181
+					$attributes[$key] = null;
182
+					break;
183
+			}
184
+		}
185
+		return $attributes;
186 186
 	}
187 187
 
188 188
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 * @param WP $WP
43 43
 	 * @return    void
44 44
 	 */
45
-	public abstract function run( WP $WP );
45
+	public abstract function run(WP $WP);
46 46
 
47 47
 
48 48
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 *  @param		array 	$attributes
55 55
 	 *  @return 	mixed
56 56
 	 */
57
-	public abstract function process_shortcode( $attributes = array() );
57
+	public abstract function process_shortcode($attributes = array());
58 58
 
59 59
 
60 60
 
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 	 * @param 	string $shortcode_class
66 66
 	 * @return 	\EES_Shortcode
67 67
 	 */
68
-	final public static function instance( $shortcode_class = null ) {
69
-		$shortcode_class = ! empty( $shortcode_class ) ? $shortcode_class : get_called_class();
70
-		if ( $shortcode_class === 'EES_Shortcode' || empty( $shortcode_class )) {
68
+	final public static function instance($shortcode_class = null) {
69
+		$shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class();
70
+		if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) {
71 71
 			return null;
72 72
 		}
73
-		$shortcode = str_replace( 'EES_', '', strtoupper( $shortcode_class ));
74
-		$shortcode_obj = isset( EE_Registry::instance()->shortcodes->{$shortcode} )
73
+		$shortcode = str_replace('EES_', '', strtoupper($shortcode_class));
74
+		$shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode} )
75 75
             ? EE_Registry::instance()->shortcodes->{$shortcode}
76 76
             : null;
77 77
 		return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self'
@@ -90,23 +90,23 @@  discard block
 block discarded – undo
90 90
 	 * @param 	$attributes
91 91
 	 * @return 	mixed
92 92
 	 */
93
-	final public static function fallback_shortcode_processor( $attributes ) {
94
-		if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) {
93
+	final public static function fallback_shortcode_processor($attributes) {
94
+		if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) {
95 95
 			return null;
96 96
 		}
97 97
 		// what shortcode was actually parsed ?
98 98
 		$shortcode_class = get_called_class();
99 99
 		// notify rest of system that fallback processor was triggered
100
-		add_filter( 'FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true' );
100
+		add_filter('FHEE__fallback_shortcode_processor__'.$shortcode_class, '__return_true');
101 101
 		// get instance of actual shortcode
102
-		$shortcode_obj = self::instance( $shortcode_class );
102
+		$shortcode_obj = self::instance($shortcode_class);
103 103
 		// verify class
104
-		if ( $shortcode_obj instanceof EES_Shortcode ) {
104
+		if ($shortcode_obj instanceof EES_Shortcode) {
105 105
 			global $wp;
106
-			$shortcode_obj->run( $wp );
106
+			$shortcode_obj->run($wp);
107 107
 			// set attributes and run the shortcode
108
-			$shortcode_obj->_attributes = (array)$attributes;
109
-			return $shortcode_obj->process_shortcode( $shortcode_obj->_attributes );
108
+			$shortcode_obj->_attributes = (array) $attributes;
109
+			return $shortcode_obj->process_shortcode($shortcode_obj->_attributes);
110 110
 		} else {
111 111
 			return null;
112 112
 		}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * @param 	$attributes
123 123
 	 * @return 	string
124 124
 	 */
125
-	final public static function invalid_shortcode_processor( $attributes ) {
125
+	final public static function invalid_shortcode_processor($attributes) {
126 126
 		return '';
127 127
 	}
128 128
 
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	final public function __construct() {
135 135
 		// get classname, remove EES_prefix, and convert to UPPERCASE
136
-		$shortcode = strtoupper( str_replace( 'EES_', '', get_class( $this )));
136
+		$shortcode = strtoupper(str_replace('EES_', '', get_class($this)));
137 137
 		// assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier
138
-		add_shortcode( $shortcode, array( $this, 'process_shortcode' ));
138
+		add_shortcode($shortcode, array($this, 'process_shortcode'));
139 139
 		// make sure system knows this is an EE page
140
-		EE_Registry::instance()->REQ->set_espresso_page( TRUE );
140
+		EE_Registry::instance()->REQ->set_espresso_page(TRUE);
141 141
 	}
142 142
 
143 143
 
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
     {
152 152
         foreach ($attributes as $key => $value) {
153 153
             // is a custom sanitization callback specified ?
154
-            if ( isset($custom_sanitization[$key])) {
154
+            if (isset($custom_sanitization[$key])) {
155 155
                 $callback = $custom_sanitization[$key];
156 156
                 if ($callback === 'skip_sanitization') {
157 157
                     $attributes[$key] = $value;
158 158
                     continue;
159
-                } else if (function_exists($callback)){
159
+                } else if (function_exists($callback)) {
160 160
                     $attributes[$key] = $callback($value);
161 161
                     continue;
162 162
                 }
Please login to merge, or discard this patch.