Completed
Branch BUG-9464-payment-methods-myste... (62c1ef)
by
unknown
357:53 queued 343:58
created
core/helpers/EEH_Event_Query.helper.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -2,19 +2,19 @@
 block discarded – undo
2 2
 	exit( 'No direct script access allowed' );
3 3
 }
4 4
 /**
5
- * Event Espresso
6
- *
7
- * Event Registration and Ticketing Management Plugin for WordPress
8
- *
9
- * @ package            Event Espresso
10
- * @ author                Event Espresso
11
- * @ copyright        (c) 2008-2014 Event Espresso  All Rights Reserved.
12
- * @ license            http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
13
- * @ link                    http://www.eventespresso.com
14
- * @ version            $VID:$
15
- *
16
- * ------------------------------------------------------------------------
17
- */
5
+	 * Event Espresso
6
+	 *
7
+	 * Event Registration and Ticketing Management Plugin for WordPress
8
+	 *
9
+	 * @ package            Event Espresso
10
+	 * @ author                Event Espresso
11
+	 * @ copyright        (c) 2008-2014 Event Espresso  All Rights Reserved.
12
+	 * @ license            http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
13
+	 * @ link                    http://www.eventespresso.com
14
+	 * @ version            $VID:$
15
+	 *
16
+	 * ------------------------------------------------------------------------
17
+	 */
18 18
 
19 19
 
20 20
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@
 block discarded – undo
229 229
 	 *
230 230
 	 * @access    public
231 231
 	 * @param string $event_list_css
232
-	 * @return    array
232
+	 * @return    string
233 233
 	 */
234 234
 	public function event_list_css( $event_list_css = '' ) {
235 235
 		$event_list_css .=  ! empty( $event_list_css ) ? ' ' : '';
Please login to merge, or discard this 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,13 +527,13 @@  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
 			// event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
534
-			$SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start <= "' . gmdate( 'Y-m-t 23:59:59', strtotime( $month ) ) . '"';
534
+			$SQL = ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_start <= "'.gmdate('Y-m-t 23:59:59', strtotime($month)).'"';
535 535
 			// event end date is GREATER than the start of the month ( so nothing that ended before this month )
536
-			$SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end >= "' . gmdate( 'Y-m-01 0:0:00', strtotime( $month ) ) . '" ';
536
+			$SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end >= "'.gmdate('Y-m-01 0:0:00', strtotime($month)).'" ';
537 537
 		}
538 538
 		return $SQL;
539 539
 	}
@@ -548,9 +548,9 @@  discard block
 block discarded – undo
548 548
 	 * @param WP_Query $wp_query
549 549
 	 * @return    string
550 550
 	 */
551
-	public static function posts_orderby( $SQL = '', WP_Query $wp_query ) {
552
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
553
-			$SQL = EEH_Event_Query::posts_orderby_sql( EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort );
551
+	public static function posts_orderby($SQL = '', WP_Query $wp_query) {
552
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
553
+			$SQL = EEH_Event_Query::posts_orderby_sql(EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort);
554 554
 		}
555 555
 		return $SQL;
556 556
 	}
@@ -581,63 +581,63 @@  discard block
 block discarded – undo
581 581
 	 * @param string     $sort
582 582
 	 * @return string
583 583
 	 */
584
-	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
584
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') {
585 585
 		global $wpdb;
586 586
 		$SQL = '';
587 587
 		$counter = 0;
588 588
 		//make sure 'orderby' is set in query params
589
-		if ( ! isset( self::$_query_params['orderby'] )) {
589
+		if ( ! isset(self::$_query_params['orderby'])) {
590 590
 			self::$_query_params['orderby'] = array();
591 591
 		}
592 592
 		// loop thru $orderby_params (type cast as array)
593
-		foreach ( (array)$orderby_params as $orderby ) {
593
+		foreach ((array) $orderby_params as $orderby) {
594 594
 			// check if we have already added this param
595
-			if ( isset( self::$_query_params['orderby'][ $orderby ] )) {
595
+			if (isset(self::$_query_params['orderby'][$orderby])) {
596 596
 				// if so then remove from the $orderby_params so that the count() method below is accurate
597
-				unset( $orderby_params[ $orderby ] );
597
+				unset($orderby_params[$orderby]);
598 598
 				// then bump ahead to the next param
599 599
 				continue;
600 600
 			}
601 601
 			// this will ad a comma depending on whether this is the first or last param
602
-			$glue = $counter == 0 || $counter == count( $orderby_params ) ? ' ' : ', ';
602
+			$glue = $counter == 0 || $counter == count($orderby_params) ? ' ' : ', ';
603 603
 			// ok what's we dealing with?
604
-			switch ( $orderby ) {
604
+			switch ($orderby) {
605 605
 				case 'id' :
606 606
 				case 'ID' :
607
-					$SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
607
+					$SQL .= $glue.$wpdb->posts.'.ID '.$sort;
608 608
 					break;
609 609
 				case 'end_date' :
610
-					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
610
+					$SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort;
611 611
 					break;
612 612
 				case 'event_name' :
613
-					$SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
613
+					$SQL .= $glue.$wpdb->posts.'.post_title '.$sort;
614 614
 					break;
615 615
 				case 'category_slug' :
616
-					$SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
616
+					$SQL .= $glue.$wpdb->terms.'.slug '.$sort;
617 617
 					break;
618 618
 				case 'ticket_start' :
619
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
619
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort;
620 620
 					break;
621 621
 				case 'ticket_end' :
622
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
622
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort;
623 623
 					break;
624 624
 				case 'venue_title' :
625
-					$SQL .= $glue . 'venue_title ' . $sort;
625
+					$SQL .= $glue.'venue_title '.$sort;
626 626
 					break;
627 627
 				case 'city' :
628
-					$SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
628
+					$SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort;
629 629
 					break;
630 630
 				case 'state' :
631
-					$SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
631
+					$SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort;
632 632
 					break;
633 633
 				case 'start_date' :
634 634
 				default :
635
-					$SQL .= $glue . ' event_start_date ' . $sort;
635
+					$SQL .= $glue.' event_start_date '.$sort;
636 636
 					break;
637 637
 			}
638 638
 			// add to array of orderby params that have been added
639
-			self::$_query_params['orderby'][ $orderby ] = TRUE;
640
-			$counter ++;
639
+			self::$_query_params['orderby'][$orderby] = TRUE;
640
+			$counter++;
641 641
 		}
642 642
 		return $SQL;
643 643
 	}
Please login to merge, or discard this patch.
core/helpers/EEH_Formatter.helper.php 4 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 
298 298
 
299 299
 	/**
300
-	* 	_get_formatter - obtain the requester formatter class
301
-	*
302
-	* 	@access private
303
-	* 	@param string $type how the address is formatted. for example: 'multiline' or 'inline'
304
-	* 	@return EEI_Address_Formatter
305
-	*/
300
+	 * 	_get_formatter - obtain the requester formatter class
301
+	 *
302
+	 * 	@access private
303
+	 * 	@param string $type how the address is formatted. for example: 'multiline' or 'inline'
304
+	 * 	@return EEI_Address_Formatter
305
+	 */
306 306
 	private static function _get_formatter( $type ) {
307 307
 		switch( $type ) {
308 308
 
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 
349 349
 
350 350
 	/**
351
-	* 	_schema_formatting
352
-	* 	adds schema.org formatting to an address
353
-	*
354
-	* 	@access private
355
-	* 	@param object EEI_Address_Formatter $formatter
356
-	* 	@param object EEI_Address $obj_with_address
357
-	* 	@return string
358
-	*/
351
+	 * 	_schema_formatting
352
+	 * 	adds schema.org formatting to an address
353
+	 *
354
+	 * 	@access private
355
+	 * 	@param object EEI_Address_Formatter $formatter
356
+	 * 	@param object EEI_Address $obj_with_address
357
+	 * 	@return string
358
+	 */
359 359
 	private static function _schema_formatting( EEI_Address_Formatter $formatter, EEI_Address $obj_with_address ){
360 360
 		$formatted_address = '<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
361 361
 		$formatted_address .= $formatter->format(
@@ -396,50 +396,50 @@  discard block
 block discarded – undo
396 396
 
397 397
 
398 398
 	/**
399
-	* 	location
400
-	* 	The location of the event, organization or action.
401
-	* 	Should include the Venue name AND schema formatted address info
402
-	*
403
-	* 	@access public
404
-	* 	@param string $location
405
-	* 	@return string
406
-	*/
399
+	 * 	location
400
+	 * 	The location of the event, organization or action.
401
+	 * 	Should include the Venue name AND schema formatted address info
402
+	 *
403
+	 * 	@access public
404
+	 * 	@param string $location
405
+	 * 	@return string
406
+	 */
407 407
 	public static function location ( $location = NULL ) {
408 408
 		return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' . $location . '</div>' : '';
409 409
 	}
410 410
 
411 411
 	/**
412
-	* 	name
413
-	* 	The name of the Event or Venue.
414
-	*
415
-	* 	@access public
416
-	* 	@param string $name
417
-	* 	@return string
418
-	*/
412
+	 * 	name
413
+	 * 	The name of the Event or Venue.
414
+	 *
415
+	 * 	@access public
416
+	 * 	@param string $name
417
+	 * 	@return string
418
+	 */
419 419
 	public static function name ( $name = NULL ) {
420 420
 		return ! empty( $name ) ? '<span itemprop="name">' . $name . '</span>' : '';
421 421
 	}
422 422
 
423 423
 	/**
424
-	* 	streetAddress
425
-	* 	The street address. For example, 1600 Amphitheatre Pkwy.
426
-	*
427
-	* 	@access public
428
-	* 	@param EEI_Address $obj_with_address
429
-	* 	@return string
430
-	*/
424
+	 * 	streetAddress
425
+	 * 	The street address. For example, 1600 Amphitheatre Pkwy.
426
+	 *
427
+	 * 	@access public
428
+	 * 	@param EEI_Address $obj_with_address
429
+	 * 	@return string
430
+	 */
431 431
 	public static function streetAddress ( EEI_Address $obj_with_address = NULL ) {
432 432
 		return $obj_with_address->address() !== NULL && $obj_with_address->address() !== '' ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';
433 433
 	}
434 434
 
435 435
 	/**
436
-	* 	postOfficeBoxNumber
437
-	* 	The post office box number for PO box addresses.
438
-	*
439
-	* 	@access public
440
-	* 	@param EEI_Address $obj_with_address
441
-	* 	@return string
442
-	*/
436
+	 * 	postOfficeBoxNumber
437
+	 * 	The post office box number for PO box addresses.
438
+	 *
439
+	 * 	@access public
440
+	 * 	@param EEI_Address $obj_with_address
441
+	 * 	@return string
442
+	 */
443 443
 	public static function postOfficeBoxNumber ( EEI_Address $obj_with_address = NULL ) {
444 444
 		// regex check for some form of PO Box or P.O. Box, etc, etc, etc
445 445
 		if ( preg_match("/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", $obj_with_address->address2() )) {
@@ -450,25 +450,25 @@  discard block
 block discarded – undo
450 450
 	}
451 451
 
452 452
 	/**
453
-	* 	addressLocality
454
-	* 	The locality (city, town, etc). For example, Mountain View.
455
-	*
456
-	* 	@access public
457
-	* 	@param EEI_Address $obj_with_address
458
-	* 	@return string
459
-	*/
453
+	 * 	addressLocality
454
+	 * 	The locality (city, town, etc). For example, Mountain View.
455
+	 *
456
+	 * 	@access public
457
+	 * 	@param EEI_Address $obj_with_address
458
+	 * 	@return string
459
+	 */
460 460
 	public static function addressLocality ( EEI_Address $obj_with_address = NULL ) {
461 461
 		return $obj_with_address->city() !== NULL && $obj_with_address->city() !== '' ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';
462 462
 	}
463 463
 
464 464
 	/**
465
-	* 	addressRegion
466
-	* 	The region (state, province, etc). For example, CA.
467
-	*
468
-	* 	@access public
469
-	* 	@param EEI_Address $obj_with_address
470
-	* 	@return string
471
-	*/
465
+	 * 	addressRegion
466
+	 * 	The region (state, province, etc). For example, CA.
467
+	 *
468
+	 * 	@access public
469
+	 * 	@param EEI_Address $obj_with_address
470
+	 * 	@return string
471
+	 */
472 472
 	public static function addressRegion ( EEI_Address $obj_with_address = NULL ) {
473 473
 		$state = $obj_with_address->state();
474 474
 		if ( ! empty( $state ) ) {
@@ -479,13 +479,13 @@  discard block
 block discarded – undo
479 479
 	}
480 480
 
481 481
 	/**
482
-	* 	addressCountry
483
-	* 	The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code.
484
-	*
485
-	* 	@access public
486
-	* 	@param EEI_Address $obj_with_address
487
-	* 	@return string
488
-	*/
482
+	 * 	addressCountry
483
+	 * 	The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code.
484
+	 *
485
+	 * 	@access public
486
+	 * 	@param EEI_Address $obj_with_address
487
+	 * 	@return string
488
+	 */
489 489
 	public static function addressCountry ( EEI_Address $obj_with_address = NULL ) {
490 490
 		$country = $obj_with_address->country();
491 491
 		if ( ! empty( $country ) ) {
@@ -496,39 +496,39 @@  discard block
 block discarded – undo
496 496
 	}
497 497
 
498 498
 	/**
499
-	* 	postalCode
500
-	* 	The postal code. For example, 94043.
501
-	*
502
-	* 	@access public
503
-	* 	@param EEI_Address $obj_with_address
504
-	* 	@return string
505
-	*/
499
+	 * 	postalCode
500
+	 * 	The postal code. For example, 94043.
501
+	 *
502
+	 * 	@access public
503
+	 * 	@param EEI_Address $obj_with_address
504
+	 * 	@return string
505
+	 */
506 506
 	public static function postalCode ( EEI_Address $obj_with_address = NULL ) {
507 507
 		return $obj_with_address->zip() !== NULL && $obj_with_address->zip() !== ''  ? '<span itemprop="postalCode">' . $obj_with_address->zip() . '</span>' : '';
508 508
 	}
509 509
 
510 510
 	/**
511
-	* 	telephone
512
-	* 	The telephone number.
513
-	*
514
-	* 	@access public
515
-	* 	@param string $phone_nmbr
516
-	* 	@return string
517
-	*/
511
+	 * 	telephone
512
+	 * 	The telephone number.
513
+	 *
514
+	 * 	@access public
515
+	 * 	@param string $phone_nmbr
516
+	 * 	@return string
517
+	 */
518 518
 	public static function telephone ( $phone_nmbr = NULL ) {
519 519
 		return $phone_nmbr !== NULL && $phone_nmbr !== ''  ? '<span itemprop="telephone">' . $phone_nmbr . '</span>' : '';
520 520
 	}
521 521
 
522 522
 	/**
523
-	* 	URL
524
-	* 	URL of the item as a clickable link
525
-	*
526
-	* 	@access public
527
-	* 	@param string $url - the URL that the link will resolve to
528
-	* 	@param string $text - the text that will be used for the visible link
529
-	* 	@param array $attributes - array of additional link attributes in  attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )
530
-	* 	@return string (link)
531
-	*/
523
+	 * 	URL
524
+	 * 	URL of the item as a clickable link
525
+	 *
526
+	 * 	@access public
527
+	 * 	@param string $url - the URL that the link will resolve to
528
+	 * 	@param string $text - the text that will be used for the visible link
529
+	 * 	@param array $attributes - array of additional link attributes in  attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )
530
+	 * 	@return string (link)
531
+	 */
532 532
 	public static function url ( $url = NULL, $text = NULL, $attributes = array() ) {
533 533
 		$atts = '';
534 534
 		foreach ( $attributes as $attribute => $value ) {
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,8 +6,9 @@
 block discarded – undo
6 6
  * @package Event Espresso
7 7
  * @subpackage messages
8 8
  */
9
-if (!defined('EVENT_ESPRESSO_VERSION') )
9
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
10 10
 	exit('NO direct script access allowed');
11
+}
11 12
 
12 13
 /**
13 14
  *
Please login to merge, or discard this patch.
Doc Comments   +14 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,6 +88,7 @@  discard block
 block discarded – undo
88 88
 	/**
89 89
 	 * [ee_tep_not_null description]
90 90
 	 * @param  string | array $value [description]
91
+	 * @param string $value
91 92
 	 * @return bool       [description]
92 93
 	 */
93 94
 	static public function ee_tep_not_null($value) {
@@ -152,6 +153,15 @@  discard block
 block discarded – undo
152 153
  */
153 154
 class EE_Address_Formatter {
154 155
 
156
+	/**
157
+	 * @param string $address
158
+	 * @param string $address2
159
+	 * @param string $city
160
+	 * @param string $state
161
+	 * @param string $zip
162
+	 * @param string $country
163
+	 * @param string $sub
164
+	 */
155 165
 	protected function parse_formatted_address( $address, $address2, $city, $state, $zip, $country, $formatted_address, $sub ) {
156 166
 		// swap address part placeholders for the real text
157 167
 		$formatted_address = str_replace(
@@ -629,6 +639,8 @@  discard block
 block discarded – undo
629 639
 	 * @param EE_State | string $state
630 640
 	 * @param string $zip
631 641
 	 * @param EE_Country | string $country
642
+	 * @param integer $state
643
+	 * @param string $country
632 644
 	 * @return EE_Generic_Address
633 645
 	 */
634 646
 	public function __construct( $address, $address2, $city, $state, $zip, $country ) {
@@ -716,7 +728,7 @@  discard block
 block discarded – undo
716 728
 
717 729
 
718 730
 	/**
719
-	 * @return \EE_State
731
+	 * @return string
720 732
 	 */
721 733
 	public function state_obj() {
722 734
 		return $this->_state_obj;
@@ -765,7 +777,7 @@  discard block
 block discarded – undo
765 777
 
766 778
 
767 779
 	/**
768
-	 * @return \EE_Country
780
+	 * @return string
769 781
 	 */
770 782
 	public function country_obj() {
771 783
 		return $this->_country_obj;
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param  string $content content to format
40 40
 	 * @return string          formatted content
41 41
 	 */
42
-	static public function admin_format_content($content='') {
42
+	static public function admin_format_content($content = '') {
43 43
 		return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8")));
44 44
 	}
45 45
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * @return string
80 80
 	 */
81 81
 	static public	function ee_tep_parse_input_field_data($data, $parse) {
82
-		return strtr( trim($data), $parse);
82
+		return strtr(trim($data), $parse);
83 83
 	}
84 84
 
85 85
 
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 	 * @return string
119 119
 	 * @deprecated v4.6.21
120 120
 	 */
121
-	static public function event_date_display( $date, $format = '' ) {
121
+	static public function event_date_display($date, $format = '') {
122 122
 		EE_Error::doing_it_wrong(
123 123
 			__METHOD__,
124
-			__( 'This method is deprecated as of EE 4.6.12.  Currently it does not reformat as with prior behaviour but just returns the incoming string.  Please use the EE_Datetime helpers for Datetime on the event to display as desired.', 'event_espresso' ),
124
+			__('This method is deprecated as of EE 4.6.12.  Currently it does not reformat as with prior behaviour but just returns the incoming string.  Please use the EE_Datetime helpers for Datetime on the event to display as desired.', 'event_espresso'),
125 125
 			'4.6.21'
126 126
 		);
127 127
 
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
  */
153 153
 class EE_Address_Formatter {
154 154
 
155
-	protected function parse_formatted_address( $address, $address2, $city, $state, $zip, $country, $formatted_address, $sub ) {
155
+	protected function parse_formatted_address($address, $address2, $city, $state, $zip, $country, $formatted_address, $sub) {
156 156
 		// swap address part placeholders for the real text
157 157
 		$formatted_address = str_replace(
158 158
 			// find
159
-			array( '{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}' ),
159
+			array('{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}'),
160 160
 			// replace
161
-			array( $address, $address2, $city, $state, $zip, $country ),
161
+			array($address, $address2, $city, $state, $zip, $country),
162 162
 			// string
163 163
 			$formatted_address
164 164
 		);
165 165
 		// remove placeholder from start and end, reduce repeating placeholders to singles, then replace with HTML line breaks
166
-		return preg_replace( '/%+/', $sub, trim( $formatted_address, '%' ) );
166
+		return preg_replace('/%+/', $sub, trim($formatted_address, '%'));
167 167
 	}
168 168
 
169 169
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 * @param string $CNT_ISO
200 200
 	 * @return string
201 201
 	 */
202
-	public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) {
202
+	public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) {
203 203
 
204 204
 		$address_formats = apply_filters(
205 205
 			'FHEE__EE_MultiLine_Address_Formatter__address_formats',
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
 			)
212 212
 		);
213 213
 		// if the incoming country has a set format, use that, else use the default
214
-		$formatted_address = isset( $address_formats[ $CNT_ISO ] ) ? $address_formats[ $CNT_ISO ] : $address_formats[ 'ZZ' ];
215
-		return $this->parse_formatted_address( $address, $address2, $city, $state, $zip, $country, $formatted_address, '<br />' );
214
+		$formatted_address = isset($address_formats[$CNT_ISO]) ? $address_formats[$CNT_ISO] : $address_formats['ZZ'];
215
+		return $this->parse_formatted_address($address, $address2, $city, $state, $zip, $country, $formatted_address, '<br />');
216 216
 	}
217 217
 }
218 218
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @param string $CNT_ISO
246 246
 	 * @return string
247 247
 	 */
248
-	public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) {
248
+	public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) {
249 249
 		$address_formats = apply_filters(
250 250
 			'FHEE__EE_Inline_Address_Formatter__address_formats',
251 251
 			array(
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 			)
257 257
 		);
258 258
 		// if the incoming country has a set format, use that, else use the default
259
-		$formatted_address = isset( $address_formats[ $CNT_ISO ] ) ? $address_formats[ $CNT_ISO ] : $address_formats[ 'ZZZ' ];
260
-		return $this->parse_formatted_address( $address, $address2, $city, $state, $zip, $country, $formatted_address, ', ' );
259
+		$formatted_address = isset($address_formats[$CNT_ISO]) ? $address_formats[$CNT_ISO] : $address_formats['ZZZ'];
260
+		return $this->parse_formatted_address($address, $address2, $city, $state, $zip, $country, $formatted_address, ', ');
261 261
 
262 262
 	}
263 263
 }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 * @param string $CNT_ISO
293 293
 	 * @return string
294 294
 	 */
295
-	public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) {
295
+	public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) {
296 296
 		return NULL;
297 297
 	}
298 298
 }
@@ -328,20 +328,20 @@  discard block
 block discarded – undo
328 328
 	 * @param bool    $add_wrapper
329 329
 	 * @return string
330 330
 	 */
331
-	public static function format ( $obj_with_address = null, $type = 'multiline', $use_schema = true, $add_wrapper = true ) {
331
+	public static function format($obj_with_address = null, $type = 'multiline', $use_schema = true, $add_wrapper = true) {
332 332
 		// check that incoming object implements the EEI_Address interface
333
-		if ( ! $obj_with_address instanceof EEI_Address ) {
334
-			$msg = __( 'The address could not be formatted.', 'event_espresso' );
335
-			$dev_msg = __( 'The EE_Address_Formatter requires passed objects to implement the EEI_Address interface.', 'event_espresso' );
336
-			EE_Error::add_error( $msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
333
+		if ( ! $obj_with_address instanceof EEI_Address) {
334
+			$msg = __('The address could not be formatted.', 'event_espresso');
335
+			$dev_msg = __('The EE_Address_Formatter requires passed objects to implement the EEI_Address interface.', 'event_espresso');
336
+			EE_Error::add_error($msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
337 337
 			return null;
338 338
 		}
339 339
 		// obtain an address formatter
340
-		$formatter = EEH_Address::_get_formatter( $type );
340
+		$formatter = EEH_Address::_get_formatter($type);
341 341
 		// apply schema.org formatting ?
342 342
 		$use_schema = ! is_admin() ? $use_schema : false;
343
-		$formatted_address = $use_schema ? EEH_Address::_schema_formatting( $formatter, $obj_with_address ) : EEH_Address::_regular_formatting( $formatter, $obj_with_address, $add_wrapper ) ;
344
-		$formatted_address = $add_wrapper && ! $use_schema ? '<div class="espresso-address-dv">' . $formatted_address . '</div>' : $formatted_address;
343
+		$formatted_address = $use_schema ? EEH_Address::_schema_formatting($formatter, $obj_with_address) : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper);
344
+		$formatted_address = $add_wrapper && ! $use_schema ? '<div class="espresso-address-dv">'.$formatted_address.'</div>' : $formatted_address;
345 345
 		// return the formatted address
346 346
 		return $formatted_address;
347 347
 	}
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 	* 	@param string $type how the address is formatted. for example: 'multiline' or 'inline'
356 356
 	* 	@return EEI_Address_Formatter
357 357
 	*/
358
-	private static function _get_formatter( $type ) {
359
-		switch( $type ) {
358
+	private static function _get_formatter($type) {
359
+		switch ($type) {
360 360
 
361 361
 			case 'multiline' :
362 362
 				return new EE_MultiLine_Address_Formatter();
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 	 * @param bool $add_wrapper
383 383
 	 * @return string
384 384
 	 */
385
-	private static function _regular_formatting( EEI_Address_Formatter $formatter, EEI_Address $obj_with_address, $add_wrapper = TRUE ){
385
+	private static function _regular_formatting(EEI_Address_Formatter $formatter, EEI_Address $obj_with_address, $add_wrapper = TRUE) {
386 386
 		$formatted_address = $add_wrapper ? '<div>' : '';
387 387
 		$formatted_address .= $formatter->format(
388 388
 			$obj_with_address->address(),
@@ -409,15 +409,15 @@  discard block
 block discarded – undo
409 409
 	* 	@param object EEI_Address $obj_with_address
410 410
 	* 	@return string
411 411
 	*/
412
-	private static function _schema_formatting( EEI_Address_Formatter $formatter, EEI_Address $obj_with_address ){
412
+	private static function _schema_formatting(EEI_Address_Formatter $formatter, EEI_Address $obj_with_address) {
413 413
 		$formatted_address = '<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
414 414
 		$formatted_address .= $formatter->format(
415
-			EEH_Schema::streetAddress( $obj_with_address ),
416
-			EEH_Schema::postOfficeBoxNumber( $obj_with_address ),
417
-			EEH_Schema::addressLocality( $obj_with_address ),
418
-			EEH_Schema::addressRegion( $obj_with_address ),
419
-			EEH_Schema::postalCode( $obj_with_address ),
420
-			EEH_Schema::addressCountry( $obj_with_address ),
415
+			EEH_Schema::streetAddress($obj_with_address),
416
+			EEH_Schema::postOfficeBoxNumber($obj_with_address),
417
+			EEH_Schema::addressLocality($obj_with_address),
418
+			EEH_Schema::addressRegion($obj_with_address),
419
+			EEH_Schema::postalCode($obj_with_address),
420
+			EEH_Schema::addressCountry($obj_with_address),
421 421
 			$obj_with_address->country_ID()
422 422
 		);
423 423
 		$formatted_address .= '</div>';
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
 	* 	@param string $location
461 461
 	* 	@return string
462 462
 	*/
463
-	public static function location ( $location = NULL ) {
464
-		return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' . $location . '</div>' : '';
463
+	public static function location($location = NULL) {
464
+		return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'.$location.'</div>' : '';
465 465
 	}
466 466
 
467 467
 	/**
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	* 	@param string $name
473 473
 	* 	@return string
474 474
 	*/
475
-	public static function name ( $name = NULL ) {
476
-		return ! empty( $name ) ? '<span itemprop="name">' . $name . '</span>' : '';
475
+	public static function name($name = NULL) {
476
+		return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : '';
477 477
 	}
478 478
 
479 479
 	/**
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 	* 	@param EEI_Address $obj_with_address
485 485
 	* 	@return string
486 486
 	*/
487
-	public static function streetAddress ( EEI_Address $obj_with_address = NULL ) {
488
-		return $obj_with_address->address() !== NULL && $obj_with_address->address() !== '' ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';
487
+	public static function streetAddress(EEI_Address $obj_with_address = NULL) {
488
+		return $obj_with_address->address() !== NULL && $obj_with_address->address() !== '' ? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : '';
489 489
 	}
490 490
 
491 491
 	/**
@@ -496,10 +496,10 @@  discard block
 block discarded – undo
496 496
 	* 	@param EEI_Address $obj_with_address
497 497
 	* 	@return string
498 498
 	*/
499
-	public static function postOfficeBoxNumber ( EEI_Address $obj_with_address = NULL ) {
499
+	public static function postOfficeBoxNumber(EEI_Address $obj_with_address = NULL) {
500 500
 		// regex check for some form of PO Box or P.O. Box, etc, etc, etc
501
-		if ( preg_match("/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", $obj_with_address->address2() )) {
502
-			return $obj_with_address->address2() !== NULL && $obj_with_address->address2() !== '' ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';
501
+		if (preg_match("/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", $obj_with_address->address2())) {
502
+			return $obj_with_address->address2() !== NULL && $obj_with_address->address2() !== '' ? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : '';
503 503
 		} else {
504 504
 			return $obj_with_address->address2();
505 505
 		}
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
 	* 	@param EEI_Address $obj_with_address
514 514
 	* 	@return string
515 515
 	*/
516
-	public static function addressLocality ( EEI_Address $obj_with_address = NULL ) {
517
-		return $obj_with_address->city() !== NULL && $obj_with_address->city() !== '' ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';
516
+	public static function addressLocality(EEI_Address $obj_with_address = NULL) {
517
+		return $obj_with_address->city() !== NULL && $obj_with_address->city() !== '' ? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : '';
518 518
 	}
519 519
 
520 520
 	/**
@@ -525,10 +525,10 @@  discard block
 block discarded – undo
525 525
 	* 	@param EEI_Address $obj_with_address
526 526
 	* 	@return string
527 527
 	*/
528
-	public static function addressRegion ( EEI_Address $obj_with_address = NULL ) {
528
+	public static function addressRegion(EEI_Address $obj_with_address = NULL) {
529 529
 		$state = $obj_with_address->state_name();
530
-		if ( ! empty( $state ) ) {
531
-			return '<span itemprop="addressRegion">' . $state . '</span>';
530
+		if ( ! empty($state)) {
531
+			return '<span itemprop="addressRegion">'.$state.'</span>';
532 532
 		} else {
533 533
 			return '';
534 534
 		}
@@ -542,10 +542,10 @@  discard block
 block discarded – undo
542 542
 	* 	@param EEI_Address $obj_with_address
543 543
 	* 	@return string
544 544
 	*/
545
-	public static function addressCountry ( EEI_Address $obj_with_address = NULL ) {
545
+	public static function addressCountry(EEI_Address $obj_with_address = NULL) {
546 546
 		$country = $obj_with_address->country_name();
547
-		if ( ! empty( $country ) ) {
548
-			return '<span itemprop="addressCountry">' . $country . '</span>';
547
+		if ( ! empty($country)) {
548
+			return '<span itemprop="addressCountry">'.$country.'</span>';
549 549
 		} else {
550 550
 			return '';
551 551
 		}
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 	* 	@param EEI_Address $obj_with_address
560 560
 	* 	@return string
561 561
 	*/
562
-	public static function postalCode ( EEI_Address $obj_with_address = NULL ) {
563
-		return $obj_with_address->zip() !== NULL && $obj_with_address->zip() !== ''  ? '<span itemprop="postalCode">' . $obj_with_address->zip() . '</span>' : '';
562
+	public static function postalCode(EEI_Address $obj_with_address = NULL) {
563
+		return $obj_with_address->zip() !== NULL && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'.$obj_with_address->zip().'</span>' : '';
564 564
 	}
565 565
 
566 566
 	/**
@@ -571,8 +571,8 @@  discard block
 block discarded – undo
571 571
 	* 	@param string $phone_nmbr
572 572
 	* 	@return string
573 573
 	*/
574
-	public static function telephone ( $phone_nmbr = NULL ) {
575
-		return $phone_nmbr !== NULL && $phone_nmbr !== ''  ? '<span itemprop="telephone">' . $phone_nmbr . '</span>' : '';
574
+	public static function telephone($phone_nmbr = NULL) {
575
+		return $phone_nmbr !== NULL && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>' : '';
576 576
 	}
577 577
 
578 578
 	/**
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
 	* 	@param array $attributes - array of additional link attributes in  attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )
586 586
 	* 	@return string (link)
587 587
 	*/
588
-	public static function url ( $url = NULL, $text = NULL, $attributes = array() ) {
588
+	public static function url($url = NULL, $text = NULL, $attributes = array()) {
589 589
 		$atts = '';
590
-		foreach ( $attributes as $attribute => $value ) {
591
-			$atts .= ' ' . $attribute . '="' . $value . '"';
590
+		foreach ($attributes as $attribute => $value) {
591
+			$atts .= ' '.$attribute.'="'.$value.'"';
592 592
 		}
593 593
 		$text = $text !== NULL && $text !== '' ? $text : $url;
594
-		return $url !== NULL && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>' : '';
594
+		return $url !== NULL && $url !== '' ? '<a itemprop="url" href="'.$url.'"'.$atts.'>'.$text.'</a>' : '';
595 595
 	}
596 596
 
597 597
 
@@ -631,18 +631,18 @@  discard block
 block discarded – undo
631 631
 	 * @param EE_Country | string $country
632 632
 	 * @return EE_Generic_Address
633 633
 	 */
634
-	public function __construct( $address, $address2, $city, $state, $zip, $country ) {
634
+	public function __construct($address, $address2, $city, $state, $zip, $country) {
635 635
 		$this->_address = $address;
636 636
 		$this->_address2 = $address2;
637 637
 		$this->_city = $city;
638
-		if ( $state instanceof EE_State ) {
638
+		if ($state instanceof EE_State) {
639 639
 			$this->_state_obj = $state;
640 640
 		} else {
641 641
 			$this->_state_ID = $state;
642 642
 			$this->_state_obj = $this->_get_state_obj();
643 643
 		}
644 644
 		$this->_zip = $zip;
645
-		if ( $country instanceof EE_Country ) {
645
+		if ($country instanceof EE_Country) {
646 646
 			$this->_country_obj = $country;
647 647
 		} else {
648 648
 			$this->_country_ID = $country;
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 	 * @return \EE_State
684 684
 	 */
685 685
 	private function _get_state_obj() {
686
-		return $this->_state_obj instanceof EE_State ? $this->_state_obj : EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $this->_state_ID );
686
+		return $this->_state_obj instanceof EE_State ? $this->_state_obj : EE_Registry::instance()->load_model('State')->get_one_by_ID($this->_state_ID);
687 687
 	}
688 688
 
689 689
 
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 	 * @return string
702 702
 	 */
703 703
 	public function state_abbrev() {
704
-		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : __( 'Unknown', 'event_espresso' );
704
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : __('Unknown', 'event_espresso');
705 705
 	}
706 706
 
707 707
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 	 * @return string
711 711
 	 */
712 712
 	public function state_name() {
713
-		return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() :  __( 'Unknown', 'event_espresso' );
713
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : __('Unknown', 'event_espresso');
714 714
 	}
715 715
 
716 716
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 	 * @return string
729 729
 	 */
730 730
 	public function state() {
731
-		if ( apply_filters( 'FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj() ) ) {
731
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
732 732
 			return $this->state_obj()->abbrev();
733 733
 		} else {
734 734
 			return $this->state_name();
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 	 * @return EE_Country
742 742
 	 */
743 743
 	private function _get_country_obj() {
744
-		return $this->_country_obj instanceof EE_Country ? $this->_country_obj : EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $this->_country_ID );
744
+		return $this->_country_obj instanceof EE_Country ? $this->_country_obj : EE_Registry::instance()->load_model('Country')->get_one_by_ID($this->_country_ID);
745 745
 	}
746 746
 
747 747
 
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 	 * @return string
760 760
 	 */
761 761
 	public function country_name() {
762
-		return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() :  __( 'Unknown', 'event_espresso' );
762
+		return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : __('Unknown', 'event_espresso');
763 763
 	}
764 764
 
765 765
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 	 * @return string
778 778
 	 */
779 779
 	public function country() {
780
-		if ( apply_filters( 'FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj() ) ) {
780
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
781 781
 			return $this->country_ID();
782 782
 		} else {
783 783
 			return $this->country_name();
Please login to merge, or discard this patch.
core/helpers/EEH_HTML.helper.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EEH_HTML
5
- *
3
+  *
4
+  * Class EEH_HTML
5
+  *
6 6
   * Sometimes when writing PHP you need to generate some standard HTML,
7 7
   * but either not enough to warrant creating a template file,
8 8
   * or the amount of PHP conditionals and/or loops peppered throughout the HTML
9 9
   * just make it really ugly and difficult to read.
10 10
   * This class simply adds a bunch of methods for generating basic HTML tags.
11 11
   * Most of the methods have the same name as the HTML tag they generate, and most have the same set of parameters.
12
- *
13
- * @package         Event Espresso
14
- * @subpackage    core
15
- * @author				Brent Christensen
16
- * @since		 	   $VID:$
17
- *
18
- */
12
+  *
13
+  * @package         Event Espresso
14
+  * @subpackage    core
15
+  * @author				Brent Christensen
16
+  * @since		 	   $VID:$
17
+  *
18
+  */
19 19
 
20 20
 class EEH_HTML {
21 21
 
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public static function instance() {
43 43
 		// check if class object is instantiated, and instantiated properly
44
-		if ( ! self::$_instance instanceof EEH_HTML ) {
44
+		if ( ! self::$_instance instanceof EEH_HTML) {
45 45
 			self::$_instance = new EEH_HTML();
46 46
 		}
47 47
 		return self::$_instance;
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 	 * @param bool   $force_close
94 94
 	 * @return string
95 95
 	 */
96
-	protected static function _open_tag( $tag = 'div', $content = '', $id = '', $class = '', $style = '', $other_attributes = '', $force_close = FALSE ) {
97
-		$attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : '';
98
-		$attributes .= ! empty( $class ) ? ' class="' . $class . '"' : '';
99
-		$attributes .= ! empty( $style ) ? ' style="' . $style . '"' : '';
100
-		$attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : '';
101
-		$html = EEH_HTML::nl( 0, $tag ) . '<' . $tag . $attributes . '>';
102
-		$html .= ! empty( $content ) ? EEH_HTML::nl( 1, $tag  ) . $content : '';
103
-		$indent = ! empty( $content ) || $force_close ? TRUE : FALSE;
104
-		$html .= ! empty( $content ) || $force_close ? EEH_HTML::_close_tag( $tag, $id, $class, $indent ) : '';
96
+	protected static function _open_tag($tag = 'div', $content = '', $id = '', $class = '', $style = '', $other_attributes = '', $force_close = FALSE) {
97
+		$attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : '';
98
+		$attributes .= ! empty($class) ? ' class="'.$class.'"' : '';
99
+		$attributes .= ! empty($style) ? ' style="'.$style.'"' : '';
100
+		$attributes .= ! empty($other_attributes) ? ' '.$other_attributes : '';
101
+		$html = EEH_HTML::nl(0, $tag).'<'.$tag.$attributes.'>';
102
+		$html .= ! empty($content) ? EEH_HTML::nl(1, $tag).$content : '';
103
+		$indent = ! empty($content) || $force_close ? TRUE : FALSE;
104
+		$html .= ! empty($content) || $force_close ? EEH_HTML::_close_tag($tag, $id, $class, $indent) : '';
105 105
 		return $html;
106 106
 	}
107 107
 
@@ -117,16 +117,16 @@  discard block
 block discarded – undo
117 117
 	 * @param bool   $indent
118 118
 	 * @return string
119 119
 	 */
120
-	protected static function _close_tag( $tag = 'div', $id = '', $class = '', $indent = TRUE ) {
121
-		if ( $id ) {
122
-			$comment = EEH_HTML::comment( 'close ' . $id ) . EEH_HTML::nl( 0, $tag );
123
-		} else if ( $class ) {
124
-			$comment = EEH_HTML::comment( 'close ' . $class ) . EEH_HTML::nl( 0, $tag );
120
+	protected static function _close_tag($tag = 'div', $id = '', $class = '', $indent = TRUE) {
121
+		if ($id) {
122
+			$comment = EEH_HTML::comment('close '.$id).EEH_HTML::nl(0, $tag);
123
+		} else if ($class) {
124
+			$comment = EEH_HTML::comment('close '.$class).EEH_HTML::nl(0, $tag);
125 125
 		} else {
126 126
 			$comment = '';
127 127
 		}
128 128
 		$html = $indent ? EEH_HTML::nl( -1, $tag ) : '';
129
-		$html .= '</' . $tag . '>' . $comment;
129
+		$html .= '</'.$tag.'>'.$comment;
130 130
 		return $html;
131 131
 	}
132 132
 
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
146 146
 	 * @return string
147 147
 	 */
148
-	public static function div( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
149
-		return EEH_HTML::_open_tag( 'div', $content, $id, $class, $style, $other_attributes );
148
+	public static function div($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
149
+		return EEH_HTML::_open_tag('div', $content, $id, $class, $style, $other_attributes);
150 150
 	}
151 151
 
152 152
 
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 * @param string $class - html class attribute
160 160
 	 * @return string
161 161
 	 */
162
-	public static function divx( $id = '', $class = '' ) {
163
-		return EEH_HTML::_close_tag( 'div', $id, $class );
162
+	public static function divx($id = '', $class = '') {
163
+		return EEH_HTML::_close_tag('div', $id, $class);
164 164
 	}
165 165
 
166 166
 
@@ -176,23 +176,23 @@  discard block
 block discarded – undo
176 176
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
177 177
 	 * @return string
178 178
 	 */
179
-	public static function h1( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
180
-		return EEH_HTML::_open_tag( 'h1', $content, $id, $class, $style, $other_attributes, TRUE );
179
+	public static function h1($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
180
+		return EEH_HTML::_open_tag('h1', $content, $id, $class, $style, $other_attributes, TRUE);
181 181
 	}
182
-	public static function h2( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
183
-		return EEH_HTML::_open_tag( 'h2', $content, $id, $class, $style, $other_attributes, TRUE );
182
+	public static function h2($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
183
+		return EEH_HTML::_open_tag('h2', $content, $id, $class, $style, $other_attributes, TRUE);
184 184
 	}
185
-	public static function h3( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
186
-		return EEH_HTML::_open_tag( 'h3', $content, $id, $class, $style, $other_attributes, TRUE );
185
+	public static function h3($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
186
+		return EEH_HTML::_open_tag('h3', $content, $id, $class, $style, $other_attributes, TRUE);
187 187
 	}
188
-	public static function h4( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
189
-		return EEH_HTML::_open_tag( 'h4', $content, $id, $class, $style, $other_attributes, TRUE );
188
+	public static function h4($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
189
+		return EEH_HTML::_open_tag('h4', $content, $id, $class, $style, $other_attributes, TRUE);
190 190
 	}
191
-	public static function h5( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
192
-		return EEH_HTML::_open_tag( 'h5', $content, $id, $class, $style, $other_attributes, TRUE );
191
+	public static function h5($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
192
+		return EEH_HTML::_open_tag('h5', $content, $id, $class, $style, $other_attributes, TRUE);
193 193
 	}
194
-	public static function h6( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
195
-		return EEH_HTML::_open_tag( 'h6', $content, $id, $class, $style, $other_attributes, TRUE );
194
+	public static function h6($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
195
+		return EEH_HTML::_open_tag('h6', $content, $id, $class, $style, $other_attributes, TRUE);
196 196
 	}
197 197
 
198 198
 
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
209 209
 	 * @return string
210 210
 	 */
211
-	public static function p( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
212
-		return EEH_HTML::_open_tag( 'p', $content, $id, $class, $style, $other_attributes, TRUE );
211
+	public static function p($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
212
+		return EEH_HTML::_open_tag('p', $content, $id, $class, $style, $other_attributes, TRUE);
213 213
 	}
214 214
 
215 215
 
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
225 225
 	 * @return string
226 226
 	 */
227
-	public static function ul( $id = '', $class = '', $style = '', $other_attributes = '' ) {
228
-		return EEH_HTML::_open_tag( 'ul', '', $id, $class, $style, $other_attributes );
227
+	public static function ul($id = '', $class = '', $style = '', $other_attributes = '') {
228
+		return EEH_HTML::_open_tag('ul', '', $id, $class, $style, $other_attributes);
229 229
 	}
230 230
 
231 231
 
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 	 * @param string $class - html class attribute
239 239
 	 * @return string
240 240
 	 */
241
-	public static function ulx( $id = '', $class = '' ) {
242
-		return EEH_HTML::_close_tag( 'ul', $id, $class );
241
+	public static function ulx($id = '', $class = '') {
242
+		return EEH_HTML::_close_tag('ul', $id, $class);
243 243
 	}
244 244
 
245 245
 
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
257 257
 	 * @return string
258 258
 	 */
259
-	public static function li( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
260
-		return EEH_HTML::_open_tag( 'li', $content, $id, $class, $style, $other_attributes );
259
+	public static function li($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
260
+		return EEH_HTML::_open_tag('li', $content, $id, $class, $style, $other_attributes);
261 261
 	}
262 262
 
263 263
 
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 * @param string $class - html class attribute
271 271
 	 * @return string
272 272
 	 */
273
-	public static function lix( $id = '', $class = '' ) {
274
-		return EEH_HTML::_close_tag( 'li', $id, $class );
273
+	public static function lix($id = '', $class = '') {
274
+		return EEH_HTML::_close_tag('li', $id, $class);
275 275
 	}
276 276
 
277 277
 
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
288 288
 	 * @return string
289 289
 	 */
290
-	public static function table( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
291
-		return EEH_HTML::_open_tag( 'table', $content, $id, $class, $style, $other_attributes );
290
+	public static function table($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
291
+		return EEH_HTML::_open_tag('table', $content, $id, $class, $style, $other_attributes);
292 292
 	}
293 293
 
294 294
 
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 	 * @param string $class - html class attribute
301 301
 	 * @return string
302 302
 	 */
303
-	public static function tablex( $id = '', $class = '' ) {
304
-		return EEH_HTML::_close_tag( 'table', $id, $class );
303
+	public static function tablex($id = '', $class = '') {
304
+		return EEH_HTML::_close_tag('table', $id, $class);
305 305
 	}
306 306
 
307 307
 
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
318 318
 	 * @return string
319 319
 	 */
320
-	public static function thead( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
321
-		return EEH_HTML::_open_tag( 'thead', $content, $id, $class, $style, $other_attributes );
320
+	public static function thead($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
321
+		return EEH_HTML::_open_tag('thead', $content, $id, $class, $style, $other_attributes);
322 322
 	}
323 323
 
324 324
 
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
 	 * @param string $class - html class attribute
331 331
 	 * @return string
332 332
 	 */
333
-	public static function theadx( $id = '', $class = '' ) {
334
-		return EEH_HTML::_close_tag( 'thead', $id, $class );
333
+	public static function theadx($id = '', $class = '') {
334
+		return EEH_HTML::_close_tag('thead', $id, $class);
335 335
 	}
336 336
 
337 337
 
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
348 348
 	 * @return string
349 349
 	 */
350
-	public static function tbody( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
351
-		return EEH_HTML::_open_tag( 'tbody', $content, $id, $class, $style, $other_attributes );
350
+	public static function tbody($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
351
+		return EEH_HTML::_open_tag('tbody', $content, $id, $class, $style, $other_attributes);
352 352
 	}
353 353
 
354 354
 
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
 	 * @param string $class - html class attribute
361 361
 	 * @return string
362 362
 	 */
363
-	public static function tbodyx( $id = '', $class = '' ) {
364
-		return EEH_HTML::_close_tag( 'tbody', $id, $class );
363
+	public static function tbodyx($id = '', $class = '') {
364
+		return EEH_HTML::_close_tag('tbody', $id, $class);
365 365
 	}
366 366
 
367 367
 
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
378 378
 	 * @return string
379 379
 	 */
380
-	public static function tr( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
381
-		return EEH_HTML::_open_tag( 'tr', $content, $id, $class, $style, $other_attributes );
380
+	public static function tr($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
381
+		return EEH_HTML::_open_tag('tr', $content, $id, $class, $style, $other_attributes);
382 382
 	}
383 383
 
384 384
 
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
 	 * @param string $class - html class attribute
391 391
 	 * @return string
392 392
 	 */
393
-	public static function trx( $id = '', $class = '' ) {
394
-		return EEH_HTML::_close_tag( 'tr', $id, $class );
393
+	public static function trx($id = '', $class = '') {
394
+		return EEH_HTML::_close_tag('tr', $id, $class);
395 395
 	}
396 396
 
397 397
 
@@ -407,8 +407,8 @@  discard block
 block discarded – undo
407 407
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
408 408
 	 * @return string
409 409
 	 */
410
-	public static function th( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
411
-		return EEH_HTML::_open_tag( 'th', $content, $id, $class, $style, $other_attributes );
410
+	public static function th($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
411
+		return EEH_HTML::_open_tag('th', $content, $id, $class, $style, $other_attributes);
412 412
 	}
413 413
 
414 414
 
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param string $class - html class attribute
421 421
 	 * @return string
422 422
 	 */
423
-	public static function thx( $id = '', $class = '' ) {
424
-		return EEH_HTML::_close_tag( 'th', $id, $class );
423
+	public static function thx($id = '', $class = '') {
424
+		return EEH_HTML::_close_tag('th', $id, $class);
425 425
 	}
426 426
 
427 427
 
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
438 438
 	 * @return string
439 439
 	 */
440
-	public static function td( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
441
-		return EEH_HTML::_open_tag( 'td', $content, $id, $class, $style, $other_attributes );
440
+	public static function td($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
441
+		return EEH_HTML::_open_tag('td', $content, $id, $class, $style, $other_attributes);
442 442
 	}
443 443
 
444 444
 
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
 	 * @param string $class - html class attribute
451 451
 	 * @return string
452 452
 	 */
453
-	public static function tdx( $id = '', $class = '' ) {
454
-		return EEH_HTML::_close_tag( 'td', $id, $class );
453
+	public static function tdx($id = '', $class = '') {
454
+		return EEH_HTML::_close_tag('td', $id, $class);
455 455
 	}
456 456
 
457 457
 
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
 	 * @param int    $colspan
466 466
 	 * @return string
467 467
 	 */
468
-	public static function no_row( $content = '', $colspan = 2 ) {
468
+	public static function no_row($content = '', $colspan = 2) {
469 469
 		return EEH_HTML::tr(
470
-			EEH_HTML::td( $content, '', '',  'padding:0; border:none;', 'colspan="' . $colspan . '"' ),
471
-			'', '',  'padding:0; border:none;'
470
+			EEH_HTML::td($content, '', '', 'padding:0; border:none;', 'colspan="'.$colspan.'"'),
471
+			'', '', 'padding:0; border:none;'
472 472
 		);
473 473
 	}
474 474
 
@@ -488,14 +488,14 @@  discard block
 block discarded – undo
488 488
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
489 489
 	 * @return string
490 490
 	 */
491
-	public static function link( $href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
492
-		$link_text = ! empty( $link_text ) ? $link_text : $href;
493
-		$attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : '';
494
-		$attributes .= ! empty( $class ) ? ' class="' . $class . '"' : '';
495
-		$attributes .= ! empty( $style ) ? ' style="' . $style . '"' : '';
496
-		$attributes .= ! empty( $title ) ? ' title="' . esc_attr( $title ) . '"' : '';
497
-		$attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : '';
498
-		return '<a href="' . $href . '" ' . $attributes . '>'  . $link_text  . '</a>';
491
+	public static function link($href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '') {
492
+		$link_text = ! empty($link_text) ? $link_text : $href;
493
+		$attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : '';
494
+		$attributes .= ! empty($class) ? ' class="'.$class.'"' : '';
495
+		$attributes .= ! empty($style) ? ' style="'.$style.'"' : '';
496
+		$attributes .= ! empty($title) ? ' title="'.esc_attr($title).'"' : '';
497
+		$attributes .= ! empty($other_attributes) ? ' '.$other_attributes : '';
498
+		return '<a href="'.$href.'" '.$attributes.'>'.$link_text.'</a>';
499 499
 	}
500 500
 
501 501
 
@@ -512,14 +512,14 @@  discard block
 block discarded – undo
512 512
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
513 513
 	 * @return string
514 514
 	 */
515
-	public static function img( $src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
516
-		$attributes = ! empty( $src ) ? ' src="' . esc_url_raw( $src ) . '"' : '';
517
-		$attributes .= ! empty( $alt ) ? ' alt="' . esc_attr( $alt ) . '"' : '';
518
-		$attributes .= ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : '';
519
-		$attributes .= ! empty( $class ) ? ' class="' . $class . '"' : '';
520
-		$attributes .= ! empty( $style ) ? ' style="' . $style . '"' : '';
521
-		$attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : '';
522
-		return '<img' . $attributes  . '/>';
515
+	public static function img($src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '') {
516
+		$attributes = ! empty($src) ? ' src="'.esc_url_raw($src).'"' : '';
517
+		$attributes .= ! empty($alt) ? ' alt="'.esc_attr($alt).'"' : '';
518
+		$attributes .= ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : '';
519
+		$attributes .= ! empty($class) ? ' class="'.$class.'"' : '';
520
+		$attributes .= ! empty($style) ? ' style="'.$style.'"' : '';
521
+		$attributes .= ! empty($other_attributes) ? ' '.$other_attributes : '';
522
+		return '<img'.$attributes.'/>';
523 523
 	}
524 524
 
525 525
 
@@ -537,12 +537,12 @@  discard block
 block discarded – undo
537 537
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
538 538
 	 * @return string
539 539
 	 */
540
-	protected static function _inline_tag( $tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
541
-		$attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : '';
542
-		$attributes .= ! empty( $class ) ? ' class="' . $class . '"' : '';
543
-		$attributes .= ! empty( $style ) ? ' style="' . $style . '"' : '';
544
-		$attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : '';
545
-		return '<' . $tag . ' ' . $attributes . '>'  . $content  . '</' . $tag . '>';
540
+	protected static function _inline_tag($tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
541
+		$attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : '';
542
+		$attributes .= ! empty($class) ? ' class="'.$class.'"' : '';
543
+		$attributes .= ! empty($style) ? ' style="'.$style.'"' : '';
544
+		$attributes .= ! empty($other_attributes) ? ' '.$other_attributes : '';
545
+		return '<'.$tag.' '.$attributes.'>'.$content.'</'.$tag.'>';
546 546
 	}
547 547
 
548 548
 
@@ -558,8 +558,8 @@  discard block
 block discarded – undo
558 558
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
559 559
 	 * @return string
560 560
 	 */
561
-	public static function label( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
562
-		return EEH_HTML::_inline_tag( 'label', $content, $id, $class, $style, $other_attributes );
561
+	public static function label($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
562
+		return EEH_HTML::_inline_tag('label', $content, $id, $class, $style, $other_attributes);
563 563
 	}
564 564
 
565 565
 
@@ -575,8 +575,8 @@  discard block
 block discarded – undo
575 575
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
576 576
 	 * @return string
577 577
 	 */
578
-	public static function span( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
579
-		return EEH_HTML::_inline_tag( 'span', $content, $id, $class, $style, $other_attributes );
578
+	public static function span($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
579
+		return EEH_HTML::_inline_tag('span', $content, $id, $class, $style, $other_attributes);
580 580
 	}
581 581
 
582 582
 
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
593 593
 	 * @return string
594 594
 	 */
595
-	public static function strong( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
596
-		return EEH_HTML::_inline_tag( 'strong', $content, $id, $class, $style, $other_attributes );
595
+	public static function strong($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
596
+		return EEH_HTML::_inline_tag('strong', $content, $id, $class, $style, $other_attributes);
597 597
 	}
598 598
 
599 599
 
@@ -605,8 +605,8 @@  discard block
 block discarded – undo
605 605
 	 * @param string $comment
606 606
 	 * @return string
607 607
 	 */
608
-	public static function comment( $comment = '' ) {
609
-		return ! empty( $comment ) ? EEH_HTML::nl() . '<!-- ' . $comment . ' -->' : '';
608
+	public static function comment($comment = '') {
609
+		return ! empty($comment) ? EEH_HTML::nl().'<!-- '.$comment.' -->' : '';
610 610
 	}
611 611
 
612 612
 
@@ -617,8 +617,8 @@  discard block
 block discarded – undo
617 617
 	 * @param int $nmbr - the number of line breaks to return
618 618
 	 * @return string
619 619
 	 */
620
-	public static function br( $nmbr = 1 ) {
621
-		return str_repeat( '<br />', $nmbr );
620
+	public static function br($nmbr = 1) {
621
+		return str_repeat('<br />', $nmbr);
622 622
 	}
623 623
 
624 624
 
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
 	 * @param int $nmbr - the number of non-breaking spaces to return
630 630
 	 * @return string
631 631
 	 */
632
-	public static function nbsp( $nmbr = 1 ) {
633
-		return str_repeat( '&nbsp;', $nmbr );
632
+	public static function nbsp($nmbr = 1) {
633
+		return str_repeat('&nbsp;', $nmbr);
634 634
 	}
635 635
 
636 636
 
@@ -644,9 +644,9 @@  discard block
 block discarded – undo
644 644
 	 * @param string $id
645 645
 	 * @return string
646 646
 	 */
647
-	public static function sanitize_id( $id = '' ) {
648
-		$key = str_replace( ' ', '-', trim( $id ) );
649
-		return preg_replace( '/[^a-zA-Z0-9_\-]/', '', $key );
647
+	public static function sanitize_id($id = '') {
648
+		$key = str_replace(' ', '-', trim($id));
649
+		return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key);
650 650
 	}
651 651
 
652 652
 
@@ -658,10 +658,10 @@  discard block
 block discarded – undo
658 658
 	 * @param string $tag
659 659
 	 * @return string - newline character plus # of indents passed (can be + or -)
660 660
 	 */
661
-	public static function nl( $indent = 0, $tag = 'none' ) {
661
+	public static function nl($indent = 0, $tag = 'none') {
662 662
 		$html = "\n";
663
-		EEH_HTML::indent( $indent, $tag );
664
-		for ( $x = 0; $x < EEH_HTML::$_indent[ $tag ]; $x++ ) {
663
+		EEH_HTML::indent($indent, $tag);
664
+		for ($x = 0; $x < EEH_HTML::$_indent[$tag]; $x++) {
665 665
 			$html .= "\t";
666 666
 		}
667 667
 		return $html;
@@ -676,17 +676,17 @@  discard block
 block discarded – undo
676 676
 	 * @param int    $indent can be negative to decrease the indentation level
677 677
 	 * @param string $tag
678 678
 	 */
679
-	public static function indent( $indent, $tag = 'none' ){
679
+	public static function indent($indent, $tag = 'none') {
680 680
 		static $default_indentation = FALSE;
681
-		if ( ! $default_indentation ) {
681
+		if ( ! $default_indentation) {
682 682
 			EEH_HTML::_set_default_indentation();
683 683
 			$default_indentation = TRUE;
684 684
 		}
685
-		if ( ! isset( EEH_HTML::$_indent[ $tag ] )) {
686
-			EEH_HTML::$_indent[ $tag ] = 0;
685
+		if ( ! isset(EEH_HTML::$_indent[$tag])) {
686
+			EEH_HTML::$_indent[$tag] = 0;
687 687
 		}
688
-		EEH_HTML::$_indent[ $tag ] += intval( $indent );
689
-		EEH_HTML::$_indent[ $tag ] = EEH_HTML::$_indent[ $tag ] >= 0 ? EEH_HTML::$_indent[ $tag ] : 0;
688
+		EEH_HTML::$_indent[$tag] += intval($indent);
689
+		EEH_HTML::$_indent[$tag] = EEH_HTML::$_indent[$tag] >= 0 ? EEH_HTML::$_indent[$tag] : 0;
690 690
 	}
691 691
 
692 692
 
Please login to merge, or discard this patch.
core/helpers/EEH_Inflector.helper.php 3 patches
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
  * @version $Revision 0.1 $
36 36
  */
37 37
 class EEH_Inflector{
38
-    // ------ CLASS METHODS ------ //
39
-    // ---- Public methods ---- //
40
-    // {{{ pluralize()
38
+	// ------ CLASS METHODS ------ //
39
+	// ---- Public methods ---- //
40
+	// {{{ pluralize()
41 41
 
42 42
 	/**
43 43
 	 * Just calls self::pluralize and strtolower on $word and returns it
@@ -51,319 +51,319 @@  discard block
 block discarded – undo
51 51
 	static function singularize_and_upper( $word ) {
52 52
 		return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) );
53 53
 	}
54
-    /**
55
-     * Pluralizes English nouns.
56
-     *
57
-     * @access public
58
-     * @static
59
-     * @param    string    $word    English noun to pluralize
60
-     * @return string Plural noun
61
-     */
62
-    static function pluralize($word){
63
-        $plural = array(
64
-            '/(quiz)$/i'               => '\1zes',
65
-            '/^(ox)$/i'                => '\1en',
66
-            '/([m|l])ouse$/i'          => '\1ice',
67
-            '/(matr|vert|ind)ix|ex$/i' => '\1ices',
68
-            '/(x|ch|ss|sh)$/i'         => '\1es',
69
-            '/([^aeiouy]|qu)ies$/i'    => '\1y',
70
-            '/([^aeiouy]|qu)y$/i'      => '\1ies',
71
-            '/(hive)$/i'               => '\1s',
72
-            '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
73
-            '/sis$/i'                  => 'ses',
74
-            '/([ti])um$/i'             => '\1a',
75
-            '/(buffal|tomat)o$/i'      => '\1oes',
76
-            '/(bu)s$/i'                => '\1ses',
77
-            '/(alias|status)/i'        => '\1es',
78
-            '/(octop|vir)us$/i'        => '\1i',
79
-            '/(ax|test)is$/i'          => '\1es',
80
-            '/s$/i'                    => 's',
81
-            '/$/'                      => 's');
82
-
83
-        $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
84
-
85
-        $irregular = array(
86
-            'person' => 'people',
87
-            'man'    => 'men',
88
-            'child'  => 'children',
89
-            'sex'    => 'sexes',
90
-            'move'   => 'moves');
91
-
92
-        $lowercased_word = strtolower($word);
93
-
94
-        foreach($uncountable as $_uncountable){
95
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
54
+	/**
55
+	 * Pluralizes English nouns.
56
+	 *
57
+	 * @access public
58
+	 * @static
59
+	 * @param    string    $word    English noun to pluralize
60
+	 * @return string Plural noun
61
+	 */
62
+	static function pluralize($word){
63
+		$plural = array(
64
+			'/(quiz)$/i'               => '\1zes',
65
+			'/^(ox)$/i'                => '\1en',
66
+			'/([m|l])ouse$/i'          => '\1ice',
67
+			'/(matr|vert|ind)ix|ex$/i' => '\1ices',
68
+			'/(x|ch|ss|sh)$/i'         => '\1es',
69
+			'/([^aeiouy]|qu)ies$/i'    => '\1y',
70
+			'/([^aeiouy]|qu)y$/i'      => '\1ies',
71
+			'/(hive)$/i'               => '\1s',
72
+			'/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
73
+			'/sis$/i'                  => 'ses',
74
+			'/([ti])um$/i'             => '\1a',
75
+			'/(buffal|tomat)o$/i'      => '\1oes',
76
+			'/(bu)s$/i'                => '\1ses',
77
+			'/(alias|status)/i'        => '\1es',
78
+			'/(octop|vir)us$/i'        => '\1i',
79
+			'/(ax|test)is$/i'          => '\1es',
80
+			'/s$/i'                    => 's',
81
+			'/$/'                      => 's');
82
+
83
+		$uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
84
+
85
+		$irregular = array(
86
+			'person' => 'people',
87
+			'man'    => 'men',
88
+			'child'  => 'children',
89
+			'sex'    => 'sexes',
90
+			'move'   => 'moves');
91
+
92
+		$lowercased_word = strtolower($word);
93
+
94
+		foreach($uncountable as $_uncountable){
95
+			if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
96 96
 					! ctype_alpha( $lowercased_word[ strlen( $lowercased_word ) - strlen($_uncountable) ] ) ){
97
-                return $word;
98
-            }
99
-        }
100
-
101
-        foreach($irregular as $_plural => $_singular){
102
-            if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){
103
-                return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
104
-            }
105
-        }
106
-
107
-        foreach($plural as $rule => $replacement){
108
-            if(preg_match($rule, $word)){
109
-                return preg_replace($rule, $replacement, $word);
110
-            }
111
-        }
112
-        return false;
113
-    }
114
-
115
-    // }}}
116
-    // {{{ singularize()
117
-
118
-    /**
119
-     * Singularizes English nouns.
120
-     *
121
-     * @access public
122
-     * @static
123
-     * @param    string    $word    English noun to singularize
124
-     * @return string Singular noun.
125
-     */
126
-    static function singularize($word){
127
-        $singular = array(
128
-            '/(quiz)zes$/i'                                                    => '\1',
129
-            '/(matr)ices$/i'                                                   => '\1ix',
130
-            '/(vert|ind)ices$/i'                                               => '\1ex',
131
-            '/^(ox)en/i'                                                       => '\1',
132
-            '/(alias|status)es$/i'                                             => '\1',
133
-            '/([octop|vir])i$/i'                                               => '\1us',
134
-            '/(cris|ax|test)es$/i'                                             => '\1is',
135
-            '/(shoe)s$/i'                                                      => '\1',
136
-            '/(o)es$/i'                                                        => '\1',
137
-            '/(bus)es$/i'                                                      => '\1',
138
-            '/([m|l])ice$/i'                                                   => '\1ouse',
139
-            '/(x|ch|ss|sh)es$/i'                                               => '\1',
140
-            '/(m)ovies$/i'                                                     => '\1ovie',
141
-            '/(s)eries$/i'                                                     => '\1eries',
142
-            '/([^aeiouy]|qu)ies$/i'                                            => '\1y',
143
-            '/([lr])ves$/i'                                                    => '\1f',
144
-            '/(tive)s$/i'                                                      => '\1',
145
-            '/(hive)s$/i'                                                      => '\1',
146
-            '/([^f])ves$/i'                                                    => '\1fe',
147
-            '/(^analy)ses$/i'                                                  => '\1sis',
148
-            '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
149
-            '/([ti])a$/i'                                                      => '\1um',
150
-            '/(n)ews$/i'                                                       => '\1ews',
151
-            '/s$/i'                                                            => '',
152
-        );
153
-
154
-        $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
155
-
156
-        $irregular = array(
157
-            'person' => 'people',
158
-            'man'    => 'men',
159
-            'child'  => 'children',
160
-            'sex'    => 'sexes',
161
-            'move'   => 'moves');
162
-
163
-        $lowercased_word = strtolower($word);
164
-        foreach($uncountable as $_uncountable){
165
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){
166
-                return $word;
167
-            }
168
-        }
169
-
170
-        foreach($irregular as $_plural => $_singular){
171
-            if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){
172
-                return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
173
-            }
174
-        }
175
-
176
-        foreach($singular as $rule => $replacement){
177
-            if(preg_match($rule, $word)){
178
-                return preg_replace($rule, $replacement, $word);
179
-            }
180
-        }
181
-
182
-        return $word;
183
-    }
184
-
185
-    // }}}
186
-    // {{{ titleize()
187
-
188
-    /**
189
-     * Converts an underscored or CamelCase word into a English
190
-     * sentence.
191
-     *
192
-     * The titleize static function converts text like "WelcomePage",
193
-     * "welcome_page" or  "welcome page" to this "Welcome
194
-     * Page".
195
-     * If second parameter is set to 'first' it will only
196
-     * capitalize the first character of the title.
197
-     *
198
-     * @access public
199
-     * @static
200
-     * @param    string    $word    Word to format as tile
201
-     * @param    string    $uppercase    If set to 'first' it will only uppercase the
202
-     * first character. Otherwise it will uppercase all
203
-     * the words in the title.
204
-     * @return string Text formatted as title
205
-     */
206
-    static function titleize($word, $uppercase = ''){
207
-        $uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords';
208
-        return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word)));
209
-    }
210
-
211
-    // }}}
212
-    // {{{ camelize()
213
-
214
-    /**
215
-     * Returns given word as CamelCased
216
-     *
217
-     * Converts a word like "send_email" to "SendEmail". It
218
-     * will remove non alphanumeric character from the word, so
219
-     * "who's online" will be converted to "WhoSOnline"
220
-     *
221
-     * @access public
222
-     * @static
223
-     * @see variablize
224
-     * @param    string    $word    Word to convert to camel case
225
-     * @return string UpperCamelCasedWord
226
-     */
227
-    static function camelize($word){
228
-        return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
229
-    }
230
-
231
-    // }}}
232
-    // {{{ underscore()
233
-
234
-    /**
235
-     * Converts a word "into_it_s_underscored_version"
236
-     *
237
-     * Convert any "CamelCased" or "ordinary Word" into an
238
-     * "underscored_word".
239
-     *
240
-     * This can be really useful for creating friendly URLs.
241
-     *
242
-     * @access public
243
-     * @static
244
-     * @param    string    $word    Word to underscore
245
-     * @return string Underscored word
246
-     */
247
-    static function underscore($word){
248
-        return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word))));
249
-    }
250
-
251
-    // }}}
252
-    // {{{ humanize()
253
-
254
-    /**
255
-     * Returns a human-readable string from $word
256
-     *
257
-     * Returns a human-readable string from $word, by replacing
258
-     * underscores with a space, and by upper-casing the initial
259
-     * character by default.
260
-     *
261
-     * If you need to uppercase all the words you just have to
262
-     * pass 'all' as a second parameter.
263
-     *
264
-     * @access public
265
-     * @static
266
-     * @param    string    $word    String to "humanize"
267
-     * @param    string    $uppercase    If set to 'all' it will uppercase all the words
268
-     * instead of just the first one.
269
-     * @return string Human-readable word
270
-     */
271
-    static function humanize($word, $uppercase = ''){
97
+				return $word;
98
+			}
99
+		}
100
+
101
+		foreach($irregular as $_plural => $_singular){
102
+			if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){
103
+				return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
104
+			}
105
+		}
106
+
107
+		foreach($plural as $rule => $replacement){
108
+			if(preg_match($rule, $word)){
109
+				return preg_replace($rule, $replacement, $word);
110
+			}
111
+		}
112
+		return false;
113
+	}
114
+
115
+	// }}}
116
+	// {{{ singularize()
117
+
118
+	/**
119
+	 * Singularizes English nouns.
120
+	 *
121
+	 * @access public
122
+	 * @static
123
+	 * @param    string    $word    English noun to singularize
124
+	 * @return string Singular noun.
125
+	 */
126
+	static function singularize($word){
127
+		$singular = array(
128
+			'/(quiz)zes$/i'                                                    => '\1',
129
+			'/(matr)ices$/i'                                                   => '\1ix',
130
+			'/(vert|ind)ices$/i'                                               => '\1ex',
131
+			'/^(ox)en/i'                                                       => '\1',
132
+			'/(alias|status)es$/i'                                             => '\1',
133
+			'/([octop|vir])i$/i'                                               => '\1us',
134
+			'/(cris|ax|test)es$/i'                                             => '\1is',
135
+			'/(shoe)s$/i'                                                      => '\1',
136
+			'/(o)es$/i'                                                        => '\1',
137
+			'/(bus)es$/i'                                                      => '\1',
138
+			'/([m|l])ice$/i'                                                   => '\1ouse',
139
+			'/(x|ch|ss|sh)es$/i'                                               => '\1',
140
+			'/(m)ovies$/i'                                                     => '\1ovie',
141
+			'/(s)eries$/i'                                                     => '\1eries',
142
+			'/([^aeiouy]|qu)ies$/i'                                            => '\1y',
143
+			'/([lr])ves$/i'                                                    => '\1f',
144
+			'/(tive)s$/i'                                                      => '\1',
145
+			'/(hive)s$/i'                                                      => '\1',
146
+			'/([^f])ves$/i'                                                    => '\1fe',
147
+			'/(^analy)ses$/i'                                                  => '\1sis',
148
+			'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
149
+			'/([ti])a$/i'                                                      => '\1um',
150
+			'/(n)ews$/i'                                                       => '\1ews',
151
+			'/s$/i'                                                            => '',
152
+		);
153
+
154
+		$uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
155
+
156
+		$irregular = array(
157
+			'person' => 'people',
158
+			'man'    => 'men',
159
+			'child'  => 'children',
160
+			'sex'    => 'sexes',
161
+			'move'   => 'moves');
162
+
163
+		$lowercased_word = strtolower($word);
164
+		foreach($uncountable as $_uncountable){
165
+			if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){
166
+				return $word;
167
+			}
168
+		}
169
+
170
+		foreach($irregular as $_plural => $_singular){
171
+			if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){
172
+				return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
173
+			}
174
+		}
175
+
176
+		foreach($singular as $rule => $replacement){
177
+			if(preg_match($rule, $word)){
178
+				return preg_replace($rule, $replacement, $word);
179
+			}
180
+		}
181
+
182
+		return $word;
183
+	}
184
+
185
+	// }}}
186
+	// {{{ titleize()
187
+
188
+	/**
189
+	 * Converts an underscored or CamelCase word into a English
190
+	 * sentence.
191
+	 *
192
+	 * The titleize static function converts text like "WelcomePage",
193
+	 * "welcome_page" or  "welcome page" to this "Welcome
194
+	 * Page".
195
+	 * If second parameter is set to 'first' it will only
196
+	 * capitalize the first character of the title.
197
+	 *
198
+	 * @access public
199
+	 * @static
200
+	 * @param    string    $word    Word to format as tile
201
+	 * @param    string    $uppercase    If set to 'first' it will only uppercase the
202
+	 * first character. Otherwise it will uppercase all
203
+	 * the words in the title.
204
+	 * @return string Text formatted as title
205
+	 */
206
+	static function titleize($word, $uppercase = ''){
207
+		$uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords';
208
+		return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word)));
209
+	}
210
+
211
+	// }}}
212
+	// {{{ camelize()
213
+
214
+	/**
215
+	 * Returns given word as CamelCased
216
+	 *
217
+	 * Converts a word like "send_email" to "SendEmail". It
218
+	 * will remove non alphanumeric character from the word, so
219
+	 * "who's online" will be converted to "WhoSOnline"
220
+	 *
221
+	 * @access public
222
+	 * @static
223
+	 * @see variablize
224
+	 * @param    string    $word    Word to convert to camel case
225
+	 * @return string UpperCamelCasedWord
226
+	 */
227
+	static function camelize($word){
228
+		return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
229
+	}
230
+
231
+	// }}}
232
+	// {{{ underscore()
233
+
234
+	/**
235
+	 * Converts a word "into_it_s_underscored_version"
236
+	 *
237
+	 * Convert any "CamelCased" or "ordinary Word" into an
238
+	 * "underscored_word".
239
+	 *
240
+	 * This can be really useful for creating friendly URLs.
241
+	 *
242
+	 * @access public
243
+	 * @static
244
+	 * @param    string    $word    Word to underscore
245
+	 * @return string Underscored word
246
+	 */
247
+	static function underscore($word){
248
+		return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word))));
249
+	}
250
+
251
+	// }}}
252
+	// {{{ humanize()
253
+
254
+	/**
255
+	 * Returns a human-readable string from $word
256
+	 *
257
+	 * Returns a human-readable string from $word, by replacing
258
+	 * underscores with a space, and by upper-casing the initial
259
+	 * character by default.
260
+	 *
261
+	 * If you need to uppercase all the words you just have to
262
+	 * pass 'all' as a second parameter.
263
+	 *
264
+	 * @access public
265
+	 * @static
266
+	 * @param    string    $word    String to "humanize"
267
+	 * @param    string    $uppercase    If set to 'all' it will uppercase all the words
268
+	 * instead of just the first one.
269
+	 * @return string Human-readable word
270
+	 */
271
+	static function humanize($word, $uppercase = ''){
272 272
 		//make special exceptions for acronyms
273 273
 		$word = str_replace('wp_', 'WP_', $word );
274
-        $uppercase = $uppercase == 'all' ? 'ucwords' : 'ucfirst';
275
-        return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
276
-    }
277
-
278
-    // }}}
279
-    // {{{ variablize()
280
-
281
-    /**
282
-     * Same as camelize but first char is underscored
283
-     *
284
-     * Converts a word like "send_email" to "sendEmail". It
285
-     * will remove non alphanumeric character from the word, so
286
-     * "who's online" will be converted to "whoSOnline"
287
-     *
288
-     * @access public
289
-     * @static
290
-     * @see camelize
291
-     * @param    string    $word    Word to lowerCamelCase
292
-     * @return string Returns a lowerCamelCasedWord
293
-     */
294
-    static function variablize($word){
295
-        $word = EEH_Inflector::camelize($word);
296
-        return strtolower($word[0]) . substr($word, 1);
297
-    }
298
-
299
-    // }}}
300
-    // {{{ tableize()
301
-
302
-    /**
303
-     * Converts a class name to its table name according to rails
304
-     * naming conventions.
305
-     *
306
-     * Converts "Person" to "people"
307
-     *
308
-     * @access public
309
-     * @static
310
-     * @see classify
311
-     * @param    string    $class_name    Class name for getting related table_name.
312
-     * @return string plural_table_name
313
-     */
314
-    static function tableize($class_name){
315
-        return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name));
316
-    }
317
-
318
-    // }}}
319
-    // {{{ classify()
320
-
321
-    /**
322
-     * Converts a table name to its class name according to rails
323
-     * naming conventions.
324
-     *
325
-     * Converts "people" to "Person"
326
-     *
327
-     * @access public
328
-     * @static
329
-     * @see tableize
330
-     * @param    string    $table_name    Table name for getting related ClassName.
331
-     * @return string SingularClassName
332
-     */
333
-    static function classify($table_name){
334
-        return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name));
335
-    }
336
-
337
-    // }}}
338
-    // {{{ ordinalize()
339
-
340
-    /**
341
-     * Converts number to its ordinal English form.
342
-     *
343
-     * This method converts 13 to 13th, 2 to 2nd ...
344
-     *
345
-     * @access public
346
-     * @static
347
-     * @param    integer    $number    Number to get its ordinal value
348
-     * @return string Ordinal representation of given string.
349
-     */
350
-    static function ordinalize($number){
351
-        if(in_array(($number % 100), range(11, 13))){
352
-            return $number . 'th';
353
-        }else{
354
-            switch(($number % 10)){
355
-                case 1:
356
-                    return $number . 'st';
357
-                    break;
358
-                case 2:
359
-                    return $number . 'nd';
360
-                    break;
361
-                case 3:
362
-                    return $number . 'rd';
363
-                default:
364
-                    return $number . 'th';
365
-                    break;
366
-            }
367
-        }
368
-    }
274
+		$uppercase = $uppercase == 'all' ? 'ucwords' : 'ucfirst';
275
+		return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
276
+	}
277
+
278
+	// }}}
279
+	// {{{ variablize()
280
+
281
+	/**
282
+	 * Same as camelize but first char is underscored
283
+	 *
284
+	 * Converts a word like "send_email" to "sendEmail". It
285
+	 * will remove non alphanumeric character from the word, so
286
+	 * "who's online" will be converted to "whoSOnline"
287
+	 *
288
+	 * @access public
289
+	 * @static
290
+	 * @see camelize
291
+	 * @param    string    $word    Word to lowerCamelCase
292
+	 * @return string Returns a lowerCamelCasedWord
293
+	 */
294
+	static function variablize($word){
295
+		$word = EEH_Inflector::camelize($word);
296
+		return strtolower($word[0]) . substr($word, 1);
297
+	}
298
+
299
+	// }}}
300
+	// {{{ tableize()
301
+
302
+	/**
303
+	 * Converts a class name to its table name according to rails
304
+	 * naming conventions.
305
+	 *
306
+	 * Converts "Person" to "people"
307
+	 *
308
+	 * @access public
309
+	 * @static
310
+	 * @see classify
311
+	 * @param    string    $class_name    Class name for getting related table_name.
312
+	 * @return string plural_table_name
313
+	 */
314
+	static function tableize($class_name){
315
+		return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name));
316
+	}
317
+
318
+	// }}}
319
+	// {{{ classify()
320
+
321
+	/**
322
+	 * Converts a table name to its class name according to rails
323
+	 * naming conventions.
324
+	 *
325
+	 * Converts "people" to "Person"
326
+	 *
327
+	 * @access public
328
+	 * @static
329
+	 * @see tableize
330
+	 * @param    string    $table_name    Table name for getting related ClassName.
331
+	 * @return string SingularClassName
332
+	 */
333
+	static function classify($table_name){
334
+		return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name));
335
+	}
336
+
337
+	// }}}
338
+	// {{{ ordinalize()
339
+
340
+	/**
341
+	 * Converts number to its ordinal English form.
342
+	 *
343
+	 * This method converts 13 to 13th, 2 to 2nd ...
344
+	 *
345
+	 * @access public
346
+	 * @static
347
+	 * @param    integer    $number    Number to get its ordinal value
348
+	 * @return string Ordinal representation of given string.
349
+	 */
350
+	static function ordinalize($number){
351
+		if(in_array(($number % 100), range(11, 13))){
352
+			return $number . 'th';
353
+		}else{
354
+			switch(($number % 10)){
355
+				case 1:
356
+					return $number . 'st';
357
+					break;
358
+				case 2:
359
+					return $number . 'nd';
360
+					break;
361
+				case 3:
362
+					return $number . 'rd';
363
+				default:
364
+					return $number . 'th';
365
+					break;
366
+			}
367
+		}
368
+	}
369 369
 }
370 370
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 // +----------------------------------------------------------------------+
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @since 0.1
35 35
  * @version $Revision 0.1 $
36 36
  */
37
-class EEH_Inflector{
37
+class EEH_Inflector {
38 38
     // ------ CLASS METHODS ------ //
39 39
     // ---- Public methods ---- //
40 40
     // {{{ pluralize()
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 	 * @param string $word
45 45
 	 * @return string
46 46
 	 */
47
-	static function pluralize_and_lower( $word ){
48
-		return strtolower( self::pluralize( $word ) );
47
+	static function pluralize_and_lower($word) {
48
+		return strtolower(self::pluralize($word));
49 49
 	}
50 50
 
51
-	static function singularize_and_upper( $word ) {
52
-		return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) );
51
+	static function singularize_and_upper($word) {
52
+		return str_replace(' ', '_', self::humanize(self::singularize($word), 'all'));
53 53
 	}
54 54
     /**
55 55
      * Pluralizes English nouns.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * @param    string    $word    English noun to pluralize
60 60
      * @return string Plural noun
61 61
      */
62
-    static function pluralize($word){
62
+    static function pluralize($word) {
63 63
         $plural = array(
64 64
             '/(quiz)$/i'               => '\1zes',
65 65
             '/^(ox)$/i'                => '\1en',
@@ -91,21 +91,21 @@  discard block
 block discarded – undo
91 91
 
92 92
         $lowercased_word = strtolower($word);
93 93
 
94
-        foreach($uncountable as $_uncountable){
95
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
96
-					! ctype_alpha( $lowercased_word[ strlen( $lowercased_word ) - strlen($_uncountable) ] ) ){
94
+        foreach ($uncountable as $_uncountable) {
95
+            if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
96
+					! ctype_alpha($lowercased_word[strlen($lowercased_word) - strlen($_uncountable)])) {
97 97
                 return $word;
98 98
             }
99 99
         }
100 100
 
101
-        foreach($irregular as $_plural => $_singular){
102
-            if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){
103
-                return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
101
+        foreach ($irregular as $_plural => $_singular) {
102
+            if (preg_match('/('.$_plural.')$/i', $word, $arr)) {
103
+                return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1).substr($_singular, 1), $word);
104 104
             }
105 105
         }
106 106
 
107
-        foreach($plural as $rule => $replacement){
108
-            if(preg_match($rule, $word)){
107
+        foreach ($plural as $rule => $replacement) {
108
+            if (preg_match($rule, $word)) {
109 109
                 return preg_replace($rule, $replacement, $word);
110 110
             }
111 111
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      * @param    string    $word    English noun to singularize
124 124
      * @return string Singular noun.
125 125
      */
126
-    static function singularize($word){
126
+    static function singularize($word) {
127 127
         $singular = array(
128 128
             '/(quiz)zes$/i'                                                    => '\1',
129 129
             '/(matr)ices$/i'                                                   => '\1ix',
@@ -161,20 +161,20 @@  discard block
 block discarded – undo
161 161
             'move'   => 'moves');
162 162
 
163 163
         $lowercased_word = strtolower($word);
164
-        foreach($uncountable as $_uncountable){
165
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){
164
+        foreach ($uncountable as $_uncountable) {
165
+            if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable) {
166 166
                 return $word;
167 167
             }
168 168
         }
169 169
 
170
-        foreach($irregular as $_plural => $_singular){
171
-            if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){
172
-                return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
170
+        foreach ($irregular as $_plural => $_singular) {
171
+            if (preg_match('/('.$_singular.')$/i', $word, $arr)) {
172
+                return preg_replace('/('.$_singular.')$/i', substr($arr[0], 0, 1).substr($_plural, 1), $word);
173 173
             }
174 174
         }
175 175
 
176
-        foreach($singular as $rule => $replacement){
177
-            if(preg_match($rule, $word)){
176
+        foreach ($singular as $rule => $replacement) {
177
+            if (preg_match($rule, $word)) {
178 178
                 return preg_replace($rule, $replacement, $word);
179 179
             }
180 180
         }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      * the words in the title.
204 204
      * @return string Text formatted as title
205 205
      */
206
-    static function titleize($word, $uppercase = ''){
206
+    static function titleize($word, $uppercase = '') {
207 207
         $uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords';
208 208
         return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word)));
209 209
     }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      * @param    string    $word    Word to convert to camel case
225 225
      * @return string UpperCamelCasedWord
226 226
      */
227
-    static function camelize($word){
227
+    static function camelize($word) {
228 228
         return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
229 229
     }
230 230
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      * @param    string    $word    Word to underscore
245 245
      * @return string Underscored word
246 246
      */
247
-    static function underscore($word){
247
+    static function underscore($word) {
248 248
         return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word))));
249 249
     }
250 250
 
@@ -268,9 +268,9 @@  discard block
 block discarded – undo
268 268
      * instead of just the first one.
269 269
      * @return string Human-readable word
270 270
      */
271
-    static function humanize($word, $uppercase = ''){
271
+    static function humanize($word, $uppercase = '') {
272 272
 		//make special exceptions for acronyms
273
-		$word = str_replace('wp_', 'WP_', $word );
273
+		$word = str_replace('wp_', 'WP_', $word);
274 274
         $uppercase = $uppercase == 'all' ? 'ucwords' : 'ucfirst';
275 275
         return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
276 276
     }
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
      * @param    string    $word    Word to lowerCamelCase
292 292
      * @return string Returns a lowerCamelCasedWord
293 293
      */
294
-    static function variablize($word){
294
+    static function variablize($word) {
295 295
         $word = EEH_Inflector::camelize($word);
296
-        return strtolower($word[0]) . substr($word, 1);
296
+        return strtolower($word[0]).substr($word, 1);
297 297
     }
298 298
 
299 299
     // }}}
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
      * @param    string    $class_name    Class name for getting related table_name.
312 312
      * @return string plural_table_name
313 313
      */
314
-    static function tableize($class_name){
314
+    static function tableize($class_name) {
315 315
         return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name));
316 316
     }
317 317
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
      * @param    string    $table_name    Table name for getting related ClassName.
331 331
      * @return string SingularClassName
332 332
      */
333
-    static function classify($table_name){
333
+    static function classify($table_name) {
334 334
         return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name));
335 335
     }
336 336
 
@@ -347,21 +347,21 @@  discard block
 block discarded – undo
347 347
      * @param    integer    $number    Number to get its ordinal value
348 348
      * @return string Ordinal representation of given string.
349 349
      */
350
-    static function ordinalize($number){
351
-        if(in_array(($number % 100), range(11, 13))){
352
-            return $number . 'th';
353
-        }else{
354
-            switch(($number % 10)){
350
+    static function ordinalize($number) {
351
+        if (in_array(($number % 100), range(11, 13))) {
352
+            return $number.'th';
353
+        } else {
354
+            switch (($number % 10)) {
355 355
                 case 1:
356
-                    return $number . 'st';
356
+                    return $number.'st';
357 357
                     break;
358 358
                 case 2:
359
-                    return $number . 'nd';
359
+                    return $number.'nd';
360 360
                     break;
361 361
                 case 3:
362
-                    return $number . 'rd';
362
+                    return $number.'rd';
363 363
                 default:
364
-                    return $number . 'th';
364
+                    return $number.'th';
365 365
                     break;
366 366
             }
367 367
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -350,7 +350,7 @@
 block discarded – undo
350 350
     static function ordinalize($number){
351 351
         if(in_array(($number % 100), range(11, 13))){
352 352
             return $number . 'th';
353
-        }else{
353
+        } else{
354 354
             switch(($number % 10)){
355 355
                 case 1:
356 356
                     return $number . 'st';
Please login to merge, or discard this patch.
core/helpers/EEH_MSG_Template.helper.php 2 patches
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
 	 * @throws \EE_Error
47 47
 	 * @return array|bool array of data required for the redirect to the correct edit page or FALSE if encountering problems.
48 48
 	 */
49
-	public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0,  $global = FALSE) {
49
+	public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = FALSE) {
50 50
 
51 51
 		//make sure message_type is an array.
52 52
 		$message_types = (array) $message_types;
53 53
 		$templates = array();
54 54
 		$success = TRUE;
55 55
 
56
-		if ( empty($messenger) ) {
57
-			throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') );
56
+		if (empty($messenger)) {
57
+			throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso'));
58 58
 		}
59 59
 
60 60
 		//if we STILL have empty $message_types then we need to generate an error message b/c we NEED message types to do the template files.
61
-		if ( empty($message_types) ) {
62
-			throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') );
61
+		if (empty($message_types)) {
62
+			throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso'));
63 63
 		}
64 64
 
65 65
 		self::_set_autoloader();
@@ -67,25 +67,25 @@  discard block
 block discarded – undo
67 67
 
68 68
 		$MSG = new EE_messages();
69 69
 
70
-		foreach ( $message_types as $message_type ) {
70
+		foreach ($message_types as $message_type) {
71 71
 			//if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty.
72
-			if ( $global && empty( $GRP_ID ) ) {
73
-				$GRP_ID = EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE ) ) );
72
+			if ($global && empty($GRP_ID)) {
73
+				$GRP_ID = EEM_Message_Template_Group::instance()->get_one(array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE)));
74 74
 				$GRP_ID = $GRP_ID instanceof EE_Message_Template_Group ? $GRP_ID->ID() : 0;
75 75
 			}
76 76
 			//if this is global template generation. First let's determine if we already HAVE global templates for this messenger and message_type combination.  If we do then NO generation!!
77
-			if ( $global && self::already_generated($messenger, $message_type, $GRP_ID  ) ) {
77
+			if ($global && self::already_generated($messenger, $message_type, $GRP_ID)) {
78 78
 				$templates = TRUE;
79 79
 				continue; //get out we've already got generated templates for this.
80 80
 			}
81 81
 
82 82
 			$new_message_template_group = $MSG->create_new_templates($messenger, $message_type, $GRP_ID, $global);
83 83
 
84
-			if ( !$new_message_template_group ) {
84
+			if ( ! $new_message_template_group) {
85 85
 				$success = FALSE;
86 86
 				continue;
87 87
 			}
88
-			if ( $templates === TRUE ) $templates = array();
88
+			if ($templates === TRUE) $templates = array();
89 89
 			$templates[] = $new_message_template_group;
90 90
 		}
91 91
 
@@ -101,18 +101,18 @@  discard block
 block discarded – undo
101 101
 	 * @param  bool  $update_to_active if true then we also toggle the template to active.
102 102
 	 * @return bool                true = generated, false = hasn't been generated.
103 103
 	 */
104
-	public static function already_generated( $messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE ) {
104
+	public static function already_generated($messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE) {
105 105
 		self::_set_autoloader();
106 106
 		$MTP = EEM_Message_Template::instance();
107 107
 
108 108
 		//what method we use depends on whether we have an GRP_ID or not
109
-		$count = empty( $GRP_ID ) ? EEM_Message_Template::instance()->count( array( array( 'Message_Template_Group.MTP_messenger' => $messenger, 'Message_Template_Group.MTP_message_type' => $message_type, 'Message_Template_Group.MTP_is_global' => TRUE ) ) ) :  $MTP->count( array( array( 'GRP_ID' => $GRP_ID ) ) );
109
+		$count = empty($GRP_ID) ? EEM_Message_Template::instance()->count(array(array('Message_Template_Group.MTP_messenger' => $messenger, 'Message_Template_Group.MTP_message_type' => $message_type, 'Message_Template_Group.MTP_is_global' => TRUE))) : $MTP->count(array(array('GRP_ID' => $GRP_ID)));
110 110
 
111
-		if ( $update_to_active ) {
112
-			self::update_to_active( $messenger, $message_type );
111
+		if ($update_to_active) {
112
+			self::update_to_active($messenger, $message_type);
113 113
 		}
114 114
 
115
-		return ( $count > 0 ) ? TRUE : FALSE;
115
+		return ($count > 0) ? TRUE : FALSE;
116 116
 	}
117 117
 
118 118
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 * @static
127 127
 	 * @return  int 						count of updated records.
128 128
 	 */
129
-	public static function update_to_active( $messenger, $message_type ) {
130
-		return EEM_Message_Template_Group::instance()->update( array('MTP_is_active' => 1), array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type )) );
129
+	public static function update_to_active($messenger, $message_type) {
130
+		return EEM_Message_Template_Group::instance()->update(array('MTP_is_active' => 1), array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type)));
131 131
 	}
132 132
 
133 133
 
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @return int  count of updated records.
142 142
 	 */
143
-	public static function update_to_inactive( $messenger = '', $message_type = '' ) {
143
+	public static function update_to_inactive($messenger = '', $message_type = '') {
144 144
 		$query_args = array();
145
-		if ( empty( $messenger ) && empty( $message_type ) )
145
+		if (empty($messenger) && empty($message_type))
146 146
 			return 0;
147
-		if ( ! empty( $messenger ) ) {
147
+		if ( ! empty($messenger)) {
148 148
 			$query_args[0]['MTP_messenger'] = $messenger;
149 149
 		}
150 150
 
151
-		if ( ! empty( $message_type ) ) {
151
+		if ( ! empty($message_type)) {
152 152
 			$query_args[0]['MTP_message_type'] = $message_type;
153 153
 		}
154
-		return EEM_Message_Template_Group::instance()->update( array( 'MTP_is_active' => FALSE ), $query_args );
154
+		return EEM_Message_Template_Group::instance()->update(array('MTP_is_active' => FALSE), $query_args);
155 155
 	}
156 156
 
157 157
 
@@ -189,39 +189,39 @@  discard block
 block discarded – undo
189 189
 	 *												OR
190 190
 	 * 												FALSE if no shortcodes found.
191 191
 	 */
192
-	public static function get_shortcodes( $message_type, $messenger, $fields = array(), $context = 'admin', $merged = FALSE ) {
192
+	public static function get_shortcodes($message_type, $messenger, $fields = array(), $context = 'admin', $merged = FALSE) {
193 193
 
194
-		$messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) );
195
-		$mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) );
194
+		$messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger)));
195
+		$mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type)));
196 196
 
197 197
 		//convert slug to object
198
-		$messenger = self::messenger_obj( $messenger );
198
+		$messenger = self::messenger_obj($messenger);
199 199
 
200 200
 		//validate class for getting our list of shortcodes
201
-		$classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator';
202
-		if ( !class_exists( $classname ) ) {
203
-			$msg[] = __( 'The Validator class was unable to load', 'event_espresso');
204
-			$msg[] = sprintf( __('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'), $classname );
205
-			throw new EE_Error( implode( '||', $msg ) );
201
+		$classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator';
202
+		if ( ! class_exists($classname)) {
203
+			$msg[] = __('The Validator class was unable to load', 'event_espresso');
204
+			$msg[] = sprintf(__('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'), $classname);
205
+			throw new EE_Error(implode('||', $msg));
206 206
 		}
207 207
 
208
-		$a = new ReflectionClass( $classname );
209
-		$_VLD = $a->newInstance( array(), $context );
208
+		$a = new ReflectionClass($classname);
209
+		$_VLD = $a->newInstance(array(), $context);
210 210
 		$valid_shortcodes = $_VLD->get_validators();
211 211
 
212 212
 		//let's make sure we're only getting the shortcode part of the validators
213 213
 		$shortcodes = array();
214
-		foreach( $valid_shortcodes as $field => $validators ) {
214
+		foreach ($valid_shortcodes as $field => $validators) {
215 215
 			$shortcodes[$field] = $validators['shortcodes'];
216 216
 			$fields[] = $field;
217 217
 		}
218 218
 		$valid_shortcodes = $shortcodes;
219 219
 
220 220
 		//if not all fields let's make sure we ONLY include the shortcodes for the specified fields.
221
-		if ( ! empty( $fields ) ) {
221
+		if ( ! empty($fields)) {
222 222
 			$specified_shortcodes = array();
223
-			foreach ( $fields as $field ) {
224
-				if ( isset( $valid_shortcodes[$field] ) )
223
+			foreach ($fields as $field) {
224
+				if (isset($valid_shortcodes[$field]))
225 225
 					$specified_shortcodes[$field] = $valid_shortcodes[$field];
226 226
 			}
227 227
 			$valid_shortcodes = $specified_shortcodes;
@@ -229,16 +229,16 @@  discard block
 block discarded – undo
229 229
 
230 230
 
231 231
 		//if not merged then let's replace the fields with the localized fields
232
-		if ( ! $merged ) {
232
+		if ( ! $merged) {
233 233
 			//let's get all the fields for the set messenger so that we can get the localized label and use that in the returned array.
234 234
 			$field_settings = $messenger->get_template_fields();
235 235
 			$localized = array();
236
-			foreach ( $valid_shortcodes as $field => $shortcodes ) {
236
+			foreach ($valid_shortcodes as $field => $shortcodes) {
237 237
 				//get localized field label
238
-				if ( isset( $field_settings[$field] ) ) {
238
+				if (isset($field_settings[$field])) {
239 239
 					//possible that this is used as a main field.
240
-					if ( empty( $field_settings[$field] ) ) {
241
-						if ( isset( $field_settings['extra'][$field] ) ) {
240
+					if (empty($field_settings[$field])) {
241
+						if (isset($field_settings['extra'][$field])) {
242 242
 							$_field = $field_settings['extra'][$field]['main']['label'];
243 243
 						} else {
244 244
 							$_field = $field;
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
 					} else {
247 247
 						$_field = $field_settings[$field]['label'];
248 248
 					}
249
-				} else if ( isset( $field_settings['extra'] ) ) {
249
+				} else if (isset($field_settings['extra'])) {
250 250
 					//loop through extra "main fields" and see if any of their children have our field
251
-					foreach ( $field_settings['extra'] as $main_field => $fields ) {
252
-						if ( isset( $fields[$field] ) )
251
+					foreach ($field_settings['extra'] as $main_field => $fields) {
252
+						if (isset($fields[$field]))
253 253
 							$_field = $fields[$field]['label'];
254 254
 						else
255 255
 							$_field = $field;
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 				} else {
258 258
 					$_field = $field;
259 259
 				}
260
-				if ( isset( $_field )) {
261
-					$localized[ $_field ] = $shortcodes;
260
+				if (isset($_field)) {
261
+					$localized[$_field] = $shortcodes;
262 262
 				}
263 263
 			}
264 264
 			$valid_shortcodes = $localized;
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 
267 267
 
268 268
 		//if $merged then let's merge all the shortcodes into one list NOT indexed by field.
269
-		if ( $merged ) {
269
+		if ($merged) {
270 270
 			$merged_codes = array();
271
-			foreach ( $valid_shortcodes as $field => $shortcode ) {
272
-				foreach ( $shortcode as $code => $label ) {
273
-					if ( isset( $merged_codes[$code] ) )
271
+			foreach ($valid_shortcodes as $field => $shortcode) {
272
+				foreach ($shortcode as $code => $label) {
273
+					if (isset($merged_codes[$code]))
274 274
 						continue;
275 275
 					else
276 276
 						$merged_codes[$code] = $label;
@@ -292,15 +292,15 @@  discard block
 block discarded – undo
292 292
 	 * @throws \EE_Error
293 293
 	 * @return EE_messenger
294 294
 	 */
295
-	public static function messenger_obj( $messenger ) {
296
-		$ref = ucwords( str_replace( '_', ' ', $messenger ) );
297
-		$ref = str_replace( ' ', '_', $ref );
298
-		$classname = 'EE_' . $ref . '_messenger';
295
+	public static function messenger_obj($messenger) {
296
+		$ref = ucwords(str_replace('_', ' ', $messenger));
297
+		$ref = str_replace(' ', '_', $ref);
298
+		$classname = 'EE_'.$ref.'_messenger';
299 299
 
300
-		if ( !class_exists($classname) ) {
300
+		if ( ! class_exists($classname)) {
301 301
 			$msg[] = __('Messenger class loading fail.', 'event_espresso');
302
-			$msg[] = sprintf( __('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate messenger file name (minus the extension) in the "/core/messages/messenger/" directory', 'event_espresso'), $classname );
303
-			throw new EE_Error( implode( '||', $msg ) );
302
+			$msg[] = sprintf(__('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate messenger file name (minus the extension) in the "/core/messages/messenger/" directory', 'event_espresso'), $classname);
303
+			throw new EE_Error(implode('||', $msg));
304 304
 		}
305 305
 
306 306
 		//made it here so let's instantiate the object and return it.
@@ -318,15 +318,15 @@  discard block
 block discarded – undo
318 318
 	 * @throws \EE_Error
319 319
 	 * @return EE_message_type
320 320
 	 */
321
-	public static function message_type_obj( $message_type ) {
322
-		$ref = ucwords( str_replace( '_', ' ', $message_type ) );
323
-		$ref = str_replace( ' ', '_', $ref );
324
-		$classname = 'EE_' . $ref . '_message_type';
321
+	public static function message_type_obj($message_type) {
322
+		$ref = ucwords(str_replace('_', ' ', $message_type));
323
+		$ref = str_replace(' ', '_', $ref);
324
+		$classname = 'EE_'.$ref.'_message_type';
325 325
 
326
-		if ( !class_exists($classname) ) {
326
+		if ( ! class_exists($classname)) {
327 327
 			$msg[] = __('Message Type class loading fail.', 'event_espresso');
328
-			$msg[] = sprintf( __('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate message type file name (minus the extension) in the "/core/messages/message_type/" directory', 'event_espresso'), $classname );
329
-			throw new EE_Error( implode( '||', $msg ) );
328
+			$msg[] = sprintf(__('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate message type file name (minus the extension) in the "/core/messages/message_type/" directory', 'event_espresso'), $classname);
329
+			throw new EE_Error(implode('||', $msg));
330 330
 		}
331 331
 
332 332
 		//made it here so let's instantiate the object and return it.
@@ -345,10 +345,10 @@  discard block
 block discarded – undo
345 345
 	 * @param  string   $message_type message type to check for.
346 346
 	 * @return boolean
347 347
 	 */
348
-	public static function is_mt_active( $message_type ) {
348
+	public static function is_mt_active($message_type) {
349 349
 		self::_set_autoloader();
350
-		$active_mts = EE_Registry::instance()->load_lib( 'messages' )->get_active_message_types();
351
-		return in_array( $message_type, $active_mts );
350
+		$active_mts = EE_Registry::instance()->load_lib('messages')->get_active_message_types();
351
+		return in_array($message_type, $active_mts);
352 352
 	}
353 353
 
354 354
 
@@ -361,10 +361,10 @@  discard block
 block discarded – undo
361 361
 	 * @param  string  $messenger slug for messenger to check.
362 362
 	 * @return boolean
363 363
 	 */
364
-	public static function is_messenger_active( $messenger ) {
364
+	public static function is_messenger_active($messenger) {
365 365
 		self::_set_autoloader();
366 366
 		$active_messengers = EE_Registry::instance()->load_lib('messages')->get_active_messengers();
367
-		return isset( $active_messengers[ $messenger ] );
367
+		return isset($active_messengers[$messenger]);
368 368
 	}
369 369
 
370 370
 
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	 * @return array
379 379
 	 */
380 380
 	public static function get_active_messengers_in_db() {
381
-		return apply_filters( 'FHEE__EEH_MSG_Template__get_active_messengers_in_db', get_option( 'ee_active_messengers', array() ) );
381
+		return apply_filters('FHEE__EEH_MSG_Template__get_active_messengers_in_db', get_option('ee_active_messengers', array()));
382 382
 	}
383 383
 
384 384
 
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 *
394 394
 	 * @return bool FALSE if not updated, TRUE if updated.
395 395
 	 */
396
-	public static function update_active_messengers_in_db( $data_to_save ) {
397
-		return update_option( 'ee_active_messengers', $data_to_save );
396
+	public static function update_active_messengers_in_db($data_to_save) {
397
+		return update_option('ee_active_messengers', $data_to_save);
398 398
 	}
399 399
 
400 400
 
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 	 *
414 414
 	 * @return string          The generated url.
415 415
 	 */
416
-	public static function generate_url_trigger( $sending_messenger, $generating_messenger, $context, $message_type, EE_Registration $registration, $message_template_group, $data_id ) {
416
+	public static function generate_url_trigger($sending_messenger, $generating_messenger, $context, $message_type, EE_Registration $registration, $message_template_group, $data_id) {
417 417
 		$query_args = array(
418 418
 			'ee' => 'msg_url_trigger',
419 419
 			'snd_msgr' => $sending_messenger,
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 			'GRP_ID' => $message_template_group,
425 425
 			'id' => $data_id
426 426
 			);
427
-		$url = add_query_arg( $query_args, get_site_url() );
427
+		$url = add_query_arg($query_args, get_site_url());
428 428
 
429 429
 		//made it here so now we can just get the url and filter it.  Filtered globally and by message type.
430
-		$url = apply_filters( 'FHEE__EEH_MSG_Template__generate_url_trigger', $url, $sending_messenger, $generating_messenger, $context, $message_type, $registration, $message_template_group, $data_id );
430
+		$url = apply_filters('FHEE__EEH_MSG_Template__generate_url_trigger', $url, $sending_messenger, $generating_messenger, $context, $message_type, $registration, $message_template_group, $data_id);
431 431
 
432 432
 		return $url;
433 433
 	}
Please login to merge, or discard this patch.
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
4 4
 	exit('NO direct script access allowed');
5
+}
5 6
 
6 7
 /**
7 8
  * Event Espresso
@@ -85,7 +86,9 @@  discard block
 block discarded – undo
85 86
 				$success = FALSE;
86 87
 				continue;
87 88
 			}
88
-			if ( $templates === TRUE ) $templates = array();
89
+			if ( $templates === TRUE ) {
90
+				$templates = array();
91
+			}
89 92
 			$templates[] = $new_message_template_group;
90 93
 		}
91 94
 
@@ -142,8 +145,9 @@  discard block
 block discarded – undo
142 145
 	 */
143 146
 	public static function update_to_inactive( $messenger = '', $message_type = '' ) {
144 147
 		$query_args = array();
145
-		if ( empty( $messenger ) && empty( $message_type ) )
146
-			return 0;
148
+		if ( empty( $messenger ) && empty( $message_type ) ) {
149
+					return 0;
150
+		}
147 151
 		if ( ! empty( $messenger ) ) {
148 152
 			$query_args[0]['MTP_messenger'] = $messenger;
149 153
 		}
@@ -221,8 +225,9 @@  discard block
 block discarded – undo
221 225
 		if ( ! empty( $fields ) ) {
222 226
 			$specified_shortcodes = array();
223 227
 			foreach ( $fields as $field ) {
224
-				if ( isset( $valid_shortcodes[$field] ) )
225
-					$specified_shortcodes[$field] = $valid_shortcodes[$field];
228
+				if ( isset( $valid_shortcodes[$field] ) ) {
229
+									$specified_shortcodes[$field] = $valid_shortcodes[$field];
230
+				}
226 231
 			}
227 232
 			$valid_shortcodes = $specified_shortcodes;
228 233
 		}
@@ -249,10 +254,11 @@  discard block
 block discarded – undo
249 254
 				} else if ( isset( $field_settings['extra'] ) ) {
250 255
 					//loop through extra "main fields" and see if any of their children have our field
251 256
 					foreach ( $field_settings['extra'] as $main_field => $fields ) {
252
-						if ( isset( $fields[$field] ) )
253
-							$_field = $fields[$field]['label'];
254
-						else
255
-							$_field = $field;
257
+						if ( isset( $fields[$field] ) ) {
258
+													$_field = $fields[$field]['label'];
259
+						} else {
260
+													$_field = $field;
261
+						}
256 262
 					}
257 263
 				} else {
258 264
 					$_field = $field;
@@ -270,10 +276,11 @@  discard block
 block discarded – undo
270 276
 			$merged_codes = array();
271 277
 			foreach ( $valid_shortcodes as $field => $shortcode ) {
272 278
 				foreach ( $shortcode as $code => $label ) {
273
-					if ( isset( $merged_codes[$code] ) )
274
-						continue;
275
-					else
276
-						$merged_codes[$code] = $label;
279
+					if ( isset( $merged_codes[$code] ) ) {
280
+											continue;
281
+					} else {
282
+											$merged_codes[$code] = $label;
283
+					}
277 284
 				}
278 285
 			}
279 286
 			$valid_shortcodes = $merged_codes;
Please login to merge, or discard this patch.
core/helpers/EEH_Money.helper.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
  */
9 9
 if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
10 10
  /**
11
- *
12
- * Money helper class.
13
- * This class has helper methods that help with money related conversions and calculations.
14
- *
15
- * @since %VER%
16
- *
17
- * @package		Event Espresso
18
- * @subpackage	helpers
19
- * @author		Darren Ethier
20
- *
21
- * ------------------------------------------------------------------------
22
- */
11
+  *
12
+  * Money helper class.
13
+  * This class has helper methods that help with money related conversions and calculations.
14
+  *
15
+  * @since %VER%
16
+  *
17
+  * @package		Event Espresso
18
+  * @subpackage	helpers
19
+  * @author		Darren Ethier
20
+  *
21
+  * ------------------------------------------------------------------------
22
+  */
23 23
 class EEH_Money extends EEH_Base  {
24 24
 
25 25
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  * @subpackage plugin api, messages
6 6
  * @since           4.5.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister a new message template pack variation for the EE messages system.
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  *
21 21
  * ------------------------------------------------------------------------
22 22
  */
23
-class EEH_Money extends EEH_Base  {
23
+class EEH_Money extends EEH_Base {
24 24
 
25 25
 
26 26
 	/**
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	 * @param int|string $incoming_value
30 30
 	 * @return float
31 31
 	 */
32
-	public static function convert_to_float_from_localized_money( $incoming_value ) {
32
+	public static function convert_to_float_from_localized_money($incoming_value) {
33 33
 		//remove thousands separator
34
-		$money_value = str_replace( EE_Registry::instance()->CFG->currency->thsnds, '', $incoming_value );
34
+		$money_value = str_replace(EE_Registry::instance()->CFG->currency->thsnds, '', $incoming_value);
35 35
 
36 36
 		//replace decimal place with standard decimal.
37
-		$money_value = str_replace( EE_Registry::instance()->CFG->currency->dec_mrk, '.', $money_value );
37
+		$money_value = str_replace(EE_Registry::instance()->CFG->currency->dec_mrk, '.', $money_value);
38 38
 
39 39
 		//float it! and round to three decimal places
40
-		$money_value = round ( (float) $money_value, 3 );
40
+		$money_value = round((float) $money_value, 3);
41 41
 		return $money_value;
42 42
 	}
43 43
 
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 	 * @throws \EE_Error
58 58
 	 */
59 59
 
60
-	public static function compare_floats( $float1, $float2, $operator='=' ) {
60
+	public static function compare_floats($float1, $float2, $operator = '=') {
61 61
 		// Check numbers to 5 digits of precision
62 62
 		$epsilon = 0.00001;
63 63
 
64
-		$float1 = (float)$float1;
65
-		$float2 = (float)$float2;
64
+		$float1 = (float) $float1;
65
+		$float2 = (float) $float2;
66 66
 
67 67
 		switch ($operator) {
68 68
 			// equal
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 				}
117 117
 				break;
118 118
 			default:
119
-				throw new EE_Error(__( "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", 'event_espresso' ) );
119
+				throw new EE_Error(__("Unknown operator '".$operator."' in EEH_Money::compare_floats()", 'event_espresso'));
120 120
 		}
121 121
 
122 122
 		return false;
@@ -131,21 +131,21 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return string
133 133
 	 */
134
-	public static function get_format_for_jqplot( $CNT_ISO = '') {
134
+	public static function get_format_for_jqplot($CNT_ISO = '') {
135 135
 		//default format
136 136
 		$format = 'f';
137 137
 		//if CNT_ISO passed lets try to get currency settings for it.
138
-		$currency_config = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : null;
138
+		$currency_config = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
139 139
 		//default currency settings for site if not set
140
-		if ( ! $currency_config instanceof EE_Currency_Config ) {
140
+		if ( ! $currency_config instanceof EE_Currency_Config) {
141 141
 			$currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config();
142 142
 		}
143 143
 
144 144
 		//first get the decimal place and number of places
145
-		$format = "%'." . $currency_config->dec_plc . $format;
145
+		$format = "%'.".$currency_config->dec_plc.$format;
146 146
 
147 147
 		//currency symbol on right side.
148
-		$format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
148
+		$format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign;
149 149
 		return $format;
150 150
 	}
151 151
 
@@ -160,27 +160,27 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @return string
162 162
 	 */
163
-	public static function get_format_for_google_charts( $CNT_ISO = '' ) {
163
+	public static function get_format_for_google_charts($CNT_ISO = '') {
164 164
 		//if CNT_ISO passed lets try to get currency settings for it.
165
-		$currency_config = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : null;
165
+		$currency_config = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
166 166
 		//default currency settings for site if not set
167
-		if ( ! $currency_config instanceof EE_Currency_Config ) {
167
+		if ( ! $currency_config instanceof EE_Currency_Config) {
168 168
 			$currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config();
169 169
 		}
170 170
 
171
-		$decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' );
171
+		$decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0');
172 172
 
173 173
 		//first get the decimal place and number of places
174
-		$format = '#,##0.' . $decimal_places_placeholder;
174
+		$format = '#,##0.'.$decimal_places_placeholder;
175 175
 
176 176
 		//currency symbol on right side.
177
-		$format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
177
+		$format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign;
178 178
 		$formatterObject = array(
179 179
 			'decimalSymbol' => $currency_config->dec_mrk,
180 180
 			'groupingSymbol' => $currency_config->thsnds,
181 181
 			'fractionDigits' => $currency_config->dec_plc,
182 182
 		);
183
-		if ( $currency_config->sign_b4 ) {
183
+		if ($currency_config->sign_b4) {
184 184
 			$formatterObject['prefix'] = $currency_config->sign;
185 185
 		} else {
186 186
 			$formatterObject['suffix'] = $currency_config->sign;
Please login to merge, or discard this patch.
core/helpers/EEH_Parse_Shortcodes.helper.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param INT 					 $GRP_ID 	       The message template grp_id for the specific template being parsed.
84 84
 	 * @return string                   The parsed template string
85 85
 	 */
86
-	public function parse_message_template( $template, EE_Messages_Addressee $data, $valid_shortcodes, EE_message_type $message_type, EE_messenger $messenger, $context, $GRP_ID ) {
86
+	public function parse_message_template($template, EE_Messages_Addressee $data, $valid_shortcodes, EE_message_type $message_type, EE_messenger $messenger, $context, $GRP_ID) {
87 87
 		$extra_data = array(
88 88
 			'messenger' => $messenger,
89 89
 			'message_type' => $message_type,
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			'GRP_ID' => $GRP_ID
92 92
 			);
93 93
 
94
-		$this->_init_data( $template, $data, $valid_shortcodes, $extra_data );
94
+		$this->_init_data($template, $data, $valid_shortcodes, $extra_data);
95 95
 
96 96
 
97 97
 		$this->_template = is_array($template) ? $template['main'] : $template;
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 	}
103 103
 
104 104
 
105
-	public function parse_attendee_list_template( $template, EE_Registration $registration, $valid_shortcodes, $extra_data = array() ) {
105
+	public function parse_attendee_list_template($template, EE_Registration $registration, $valid_shortcodes, $extra_data = array()) {
106 106
 
107
-		$this->_init_data( $template, $registration, $valid_shortcodes, $extra_data );
107
+		$this->_init_data($template, $registration, $valid_shortcodes, $extra_data);
108 108
 
109 109
 		$this->_template = is_array($template) ? $template['attendee_list'] : $template;
110 110
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 		return $parsed;
113 113
 	}
114 114
 
115
-	public function parse_event_list_template( $template, EE_Event $event, $valid_shortcodes, $extra_data = array() ) {
116
-		$this->_init_data( $template, $event, $valid_shortcodes, $extra_data );
115
+	public function parse_event_list_template($template, EE_Event $event, $valid_shortcodes, $extra_data = array()) {
116
+		$this->_init_data($template, $event, $valid_shortcodes, $extra_data);
117 117
 
118 118
 		$this->_template = is_array($template) ? $template['event_list'] : $template;
119 119
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	}
123 123
 
124 124
 
125
-	public function parse_ticket_list_template( $template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array() ) {
126
-		$this->_init_data( $template, $ticket, $valid_shortcodes, $extra_data );
125
+	public function parse_ticket_list_template($template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array()) {
126
+		$this->_init_data($template, $ticket, $valid_shortcodes, $extra_data);
127 127
 
128 128
 		$this->_template = is_array($template) ? $template['ticket_list'] : $template;
129 129
 
@@ -133,26 +133,26 @@  discard block
 block discarded – undo
133 133
 
134 134
 
135 135
 
136
-	public function parse_line_item_list_template( $template, EE_Line_Item $line_item, $valid_shortcodes, $extra_data = array() ) {
137
-		$this->_init_data( $template, $line_item, $valid_shortcodes, $extra_data );
138
-		$this->_template = is_array( $template ) ? $template['ticket_line_item_no_pms'] : $template;
136
+	public function parse_line_item_list_template($template, EE_Line_Item $line_item, $valid_shortcodes, $extra_data = array()) {
137
+		$this->_init_data($template, $line_item, $valid_shortcodes, $extra_data);
138
+		$this->_template = is_array($template) ? $template['ticket_line_item_no_pms'] : $template;
139 139
 
140 140
 		$parsed = $this->_parse_message_template();
141 141
 		return $parsed;
142 142
 	}
143 143
 
144 144
 
145
-	public function parse_payment_list_template( $template, EE_Payment $payment_item, $valid_shortcodes, $extra_data = array() ) {
146
-		$this->_init_data( $template, $payment_item, $valid_shortcodes, $extra_data );
147
-		$this->_template = is_array( $template ) ? $template['payment_list'] : $template;
145
+	public function parse_payment_list_template($template, EE_Payment $payment_item, $valid_shortcodes, $extra_data = array()) {
146
+		$this->_init_data($template, $payment_item, $valid_shortcodes, $extra_data);
147
+		$this->_template = is_array($template) ? $template['payment_list'] : $template;
148 148
 
149 149
 		$parsed = $this->_parse_message_template();
150 150
 		return $parsed;
151 151
 	}
152 152
 
153 153
 
154
-	public function parse_datetime_list_template( $template, EE_Datetime $datetime, $valid_shortcodes, $extra_data = array() ) {
155
-		$this->_init_data( $template, $datetime, $valid_shortcodes, $extra_data );
154
+	public function parse_datetime_list_template($template, EE_Datetime $datetime, $valid_shortcodes, $extra_data = array()) {
155
+		$this->_init_data($template, $datetime, $valid_shortcodes, $extra_data);
156 156
 
157 157
 		$this->_template = is_array($template) ? $template['datetime_list'] : $template;
158 158
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	}
162 162
 
163 163
 
164
-	public function parse_question_list_template( $template, EE_Answer $answer, $valid_shortcodes, $extra_data = array() ) {
165
-		$this->_init_data( $template, $answer, $valid_shortcodes, $extra_data );
164
+	public function parse_question_list_template($template, EE_Answer $answer, $valid_shortcodes, $extra_data = array()) {
165
+		$this->_init_data($template, $answer, $valid_shortcodes, $extra_data);
166 166
 
167 167
 		$this->_template = is_array($template) ? $template['question_list'] : $template;
168 168
 
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 	}
172 172
 
173 173
 
174
-	private function _init_data( $template, $data, $valid_shortcodes, $extra_data = array() ) {
174
+	private function _init_data($template, $data, $valid_shortcodes, $extra_data = array()) {
175 175
 		$this->_reset_props();
176 176
 		$this->_data['template'] = $template;
177 177
 		$this->_data['data'] = $data;
178 178
 		$this->_data['extra_data'] = $extra_data;
179 179
 
180
-		$this->_set_shortcodes( $valid_shortcodes );
180
+		$this->_set_shortcodes($valid_shortcodes);
181 181
 	}
182 182
 
183 183
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
 
198 198
 		//now let's get a list of shortcodes that are found in the given template
199
-		$possible_shortcodes = preg_match_all( '/(\[.+?\])/', $this->_template, $matches );
199
+		$possible_shortcodes = preg_match_all('/(\[.+?\])/', $this->_template, $matches);
200 200
 		$shortcodes = (array) $matches[0]; //this should be an array of shortcodes in the template string.
201 201
 
202 202
 		$matched_code = array();
@@ -221,31 +221,31 @@  discard block
 block discarded – undo
221 221
 			'[PAYMENT_LIST_*]'
222 222
 			);
223 223
 
224
-		$list_type_shortcodes = apply_filters( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', $list_type_shortcodes );
224
+		$list_type_shortcodes = apply_filters('FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', $list_type_shortcodes);
225 225
 
226 226
 		//now lets go ahead and loop through our parsers for each shortcode and setup the values
227
-		foreach ( $shortcodes as $shortcode ) {
227
+		foreach ($shortcodes as $shortcode) {
228 228
 
229
-			foreach ( $this->_shortcode_objs as $sc_obj ) {
229
+			foreach ($this->_shortcode_objs as $sc_obj) {
230 230
 				$data_send = '';
231 231
 
232 232
 				//we need to setup any dynamic shortcodes so that they work with the array_key_exists
233
-				$sc = preg_match_all( '/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches );
234
-				$sc_to_verify = !empty($matches[0] ) ? $matches[0][0] . ']' : $shortcode;
233
+				$sc = preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches);
234
+				$sc_to_verify = ! empty($matches[0]) ? $matches[0][0].']' : $shortcode;
235 235
 
236
-				if ( !array_key_exists( $sc_to_verify, $sc_obj->get_shortcodes() ) ) {
236
+				if ( ! array_key_exists($sc_to_verify, $sc_obj->get_shortcodes())) {
237 237
 					continue; //the given shortcode isn't in this object
238 238
 				}
239 239
 
240 240
 				//if this isn't  a "list" type shortcode then we'll send along the data vanilla instead of in an array.
241
-				if ( ! in_array( $sc_to_verify, $list_type_shortcodes ) ) {
242
-					$data_send = !is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data;
241
+				if ( ! in_array($sc_to_verify, $list_type_shortcodes)) {
242
+					$data_send = ! is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data;
243 243
 				} else {
244 244
 					$data_send = $this->_data;
245 245
 				}
246 246
 
247 247
 
248
-				$parsed = $sc_obj->parser( $shortcode, $data_send, $this->_data['extra_data'] );
248
+				$parsed = $sc_obj->parser($shortcode, $data_send, $this->_data['extra_data']);
249 249
 
250 250
 				$matched_code[] = $shortcode;
251 251
 				$sc_values[] = $parsed;
@@ -267,13 +267,13 @@  discard block
 block discarded – undo
267 267
 	 * @param array $valid_shortcodes an array of strings corresponding to EE_Shortcode Library objects
268 268
 	 * @return void
269 269
 	 */
270
-	private function _set_shortcodes( $valid_shortcodes ) {
271
-		foreach ( $valid_shortcodes as $shortcode_ref ) {
272
-			$ref = ucwords( str_replace('_', ' ', $shortcode_ref ) );
273
-			$ref = str_replace( ' ', '_', $ref );
274
-			$classname = 'EE_' . $ref . '_Shortcodes';
275
-			if ( class_exists( $classname ) ) {
276
-				$a = new ReflectionClass( $classname );
270
+	private function _set_shortcodes($valid_shortcodes) {
271
+		foreach ($valid_shortcodes as $shortcode_ref) {
272
+			$ref = ucwords(str_replace('_', ' ', $shortcode_ref));
273
+			$ref = str_replace(' ', '_', $ref);
274
+			$classname = 'EE_'.$ref.'_Shortcodes';
275
+			if (class_exists($classname)) {
276
+				$a = new ReflectionClass($classname);
277 277
 				$this->_shortcode_objs[] = $a->newInstance();
278 278
 			}
279 279
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,8 +6,9 @@
 block discarded – undo
6 6
  * @package Event Espresso
7 7
  * @subpackage messages
8 8
  */
9
-if (!defined('EVENT_ESPRESSO_VERSION') )
9
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
10 10
 	exit('NO direct script access allowed');
11
+}
11 12
 
12 13
 /**
13 14
  *
Please login to merge, or discard this patch.
core/helpers/EEH_Sideloader.helper.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 
30 30
 
31
-require_once( EE_HELPERS . 'EEH_Base.helper.php' );
31
+require_once(EE_HELPERS.'EEH_Base.helper.php');
32 32
 class EEH_Sideloader extends EEH_Base {
33 33
 
34 34
 	private $_upload_to;
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 * @access public
44 44
 	 * @param array $init array fo initializing the sideloader if keys match the properties.
45 45
 	 */
46
-	public function __construct( $init = array() ) {
47
-		$this->_init( $init );
46
+	public function __construct($init = array()) {
47
+		$this->_init($init);
48 48
 	}
49 49
 
50 50
 
@@ -55,24 +55,24 @@  discard block
 block discarded – undo
55 55
 	 * @param  array  $init array on init (keys match properties others ignored)
56 56
 	 * @return void
57 57
 	 */
58
-	private function _init( $init ) {
58
+	private function _init($init) {
59 59
 		$defaults = array(
60 60
 			'_upload_to' => $this->_get_wp_uploads_dir(),
61 61
 			'_upload_from' => '',
62 62
 			'_permissions' => 0644,
63
-			'_new_file_name' => 'EE_Sideloader_' . uniqid() . '.default'
63
+			'_new_file_name' => 'EE_Sideloader_'.uniqid().'.default'
64 64
 			);
65 65
 
66
-		$props = array_merge( $defaults, $init );
66
+		$props = array_merge($defaults, $init);
67 67
 
68
-		foreach ( $props as $key => $val ) {
69
-			if ( EEH_Class_Tools::has_property( $this, $key ) ) {
68
+		foreach ($props as $key => $val) {
69
+			if (EEH_Class_Tools::has_property($this, $key)) {
70 70
 				$this->$key = $val;
71 71
 			}
72 72
 		}
73 73
 
74 74
 		//make sure we include the required wp file for needed functions
75
-		require_once( ABSPATH . 'wp-admin/includes/file.php' );
75
+		require_once(ABSPATH.'wp-admin/includes/file.php');
76 76
 	}
77 77
 
78 78
 
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
 	private function _get_wp_uploads_dir() {}
81 81
 
82 82
 	//setters
83
-	public function set_upload_to( $upload_to_folder ) {
83
+	public function set_upload_to($upload_to_folder) {
84 84
 		$this->_upload_to = $upload_to_folder;
85 85
 	}
86
-	public function set_upload_from( $upload_from_folder ) {
86
+	public function set_upload_from($upload_from_folder) {
87 87
 		$this->_upload_from_folder = $upload_from_folder;
88 88
 	}
89
-	public function set_permissions( $permissions ) {
89
+	public function set_permissions($permissions) {
90 90
 		$this->_permissions = $permissions;
91 91
 	}
92
-	public function set_new_file_name( $new_file_name ) {
92
+	public function set_new_file_name($new_file_name) {
93 93
 		$this->_new_file_name = $new_file_name;
94 94
 	}
95 95
 
@@ -111,34 +111,34 @@  discard block
 block discarded – undo
111 111
 	//upload methods
112 112
 	public function sideload() {
113 113
 		//setup temp dir
114
-		$temp_file = wp_tempnam( $this->_upload_from );
114
+		$temp_file = wp_tempnam($this->_upload_from);
115 115
 
116
-		if ( !$temp_file ) {
117
-			EE_Error::add_error( __('Something went wrong with the upload.  Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
116
+		if ( ! $temp_file) {
117
+			EE_Error::add_error(__('Something went wrong with the upload.  Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
118 118
 			return false;
119 119
 		}
120 120
 
121
-		do_action( 'AHEE__EEH_Sideloader__sideload__before', $this, $temp_file );
121
+		do_action('AHEE__EEH_Sideloader__sideload__before', $this, $temp_file);
122 122
 
123
-		$wp_remote_args = apply_filters( 'FHEE__EEH_Sideloader__sideload__wp_remote_args', array( 'timeout' => 500, 'stream' => true, 'filename' => $temp_file ), $this, $temp_file );
123
+		$wp_remote_args = apply_filters('FHEE__EEH_Sideloader__sideload__wp_remote_args', array('timeout' => 500, 'stream' => true, 'filename' => $temp_file), $this, $temp_file);
124 124
 
125
-		$response = wp_safe_remote_get( $this->_upload_from, $wp_remote_args );
125
+		$response = wp_safe_remote_get($this->_upload_from, $wp_remote_args);
126 126
 
127
-		if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
128
-			unlink( $temp_file );
129
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
130
-				EE_Error::add_error( sprintf( __('Unable to upload the file.  Either the path given to upload from is incorrect, or something else happened.  Here is the response returned:<br />%s<br />Here is the path given: %s', 'event_espresso'), var_export( $response, true ), $this->_upload_from ), __FILE__, __FUNCTION__, __LINE__ );
127
+		if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) {
128
+			unlink($temp_file);
129
+			if (defined('WP_DEBUG') && WP_DEBUG) {
130
+				EE_Error::add_error(sprintf(__('Unable to upload the file.  Either the path given to upload from is incorrect, or something else happened.  Here is the response returned:<br />%s<br />Here is the path given: %s', 'event_espresso'), var_export($response, true), $this->_upload_from), __FILE__, __FUNCTION__, __LINE__);
131 131
 			}
132 132
 			return false;
133 133
 		}
134 134
 
135 135
 		//possible md5 check
136
-		$content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
137
-		if ( $content_md5 ) {
138
-			$md5_check = verify_file_md5( $temp_file, $content_md5 );
139
-			if ( is_wp_error( $md5_check ) ) {
140
-				unlink( $temp_file );
141
-				EE_Error::add_error( $md5_check->get_error_message(), __FILE__, __FUNCTION__, __LINE__ );
136
+		$content_md5 = wp_remote_retrieve_header($response, 'content-md5');
137
+		if ($content_md5) {
138
+			$md5_check = verify_file_md5($temp_file, $content_md5);
139
+			if (is_wp_error($md5_check)) {
140
+				unlink($temp_file);
141
+				EE_Error::add_error($md5_check->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
142 142
 				return false;
143 143
 			}
144 144
 		}
@@ -146,24 +146,24 @@  discard block
 block discarded – undo
146 146
 		$file = $temp_file;
147 147
 
148 148
 		//now we have the file, let's get it in the right directory with the right name.
149
-		$path = apply_filters( 'FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to . $this->_new_file_name, $this );
149
+		$path = apply_filters('FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to.$this->_new_file_name, $this);
150 150
 
151 151
 		//move file in
152
-		if ( false === @ rename( $file, $path ) ) {
153
-			unlink( $temp_file );
154
-			EE_Error::add_error(  sprintf( __('Unable to move the file to new location (possible permissions errors). This is the path the class attempted to move the file to: %s', 'event_espresso' ), $path ), __FILE__, __FUNCTION__, __LINE__ );
152
+		if (false === @ rename($file, $path)) {
153
+			unlink($temp_file);
154
+			EE_Error::add_error(sprintf(__('Unable to move the file to new location (possible permissions errors). This is the path the class attempted to move the file to: %s', 'event_espresso'), $path), __FILE__, __FUNCTION__, __LINE__);
155 155
 			return false;
156 156
 		}
157 157
 
158 158
 		//set permissions
159
-		$permissions = apply_filters( 'FHEE__EEH_Sideloader__sideload__permissions_applied', $this->_permissions, $this );
160
-		chmod( $path, $permissions );
159
+		$permissions = apply_filters('FHEE__EEH_Sideloader__sideload__permissions_applied', $this->_permissions, $this);
160
+		chmod($path, $permissions);
161 161
 
162 162
 		//that's it.  let's allow for actions after file uploaded.
163
-		do_action( 'AHEE__EE_Sideloader__sideload_after', $this, $path );
163
+		do_action('AHEE__EE_Sideloader__sideload_after', $this, $path);
164 164
 
165 165
 		//unlink tempfile
166
-		@unlink( $temp_file );
166
+		@unlink($temp_file);
167 167
 		return true;
168 168
 	}
169 169
 
Please login to merge, or discard this patch.
core/helpers/EEH_Tabbed_Content.helper.php 2 patches
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
3 3
 	exit('NO direct script access allowed');
4
+}
4 5
 
5 6
 /**
6 7
  * Event Espresso
@@ -98,8 +99,9 @@  discard block
 block discarded – undo
98 99
 	 * @param array $nav_tabs tab array for nav tabs
99 100
 	 */
100 101
 	public static function display_admin_nav_tabs($nav_tabs = array()) {
101
-		if ( empty($nav_tabs) )
102
-			throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) );
102
+		if ( empty($nav_tabs) ) {
103
+					throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) );
104
+		}
103 105
 
104 106
 		$all_tabs = '<h2 class="nav-tab-wrapper">' . "\n";
105 107
 		foreach ( $nav_tabs as $slug => $tab ) {
@@ -165,8 +167,10 @@  discard block
 block discarded – undo
165 167
 	 * @return string                  a html snippet of of all the formatted link elements.
166 168
 	 */
167 169
 	public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) {
168
-		if ( !is_array($item_array) || empty( $item_array ) )
169
-			return false; //get out we don't have even the basic thing we need!
170
+		if ( !is_array($item_array) || empty( $item_array ) ) {
171
+					return false;
172
+		}
173
+		//get out we don't have even the basic thing we need!
170 174
 
171 175
 
172 176
 		$defaults = array(
@@ -184,8 +188,9 @@  discard block
 block discarded – undo
184 188
 			$item = wp_parse_args( $item, $defaults );
185 189
 			$item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class'];
186 190
 			$list .= self::_text_link_item($item);
187
-			if ( !empty($sep) && $ci != count($item_array) )
188
-				$list .= self::_text_link_item($sep);
191
+			if ( !empty($sep) && $ci != count($item_array) ) {
192
+							$list .= self::_text_link_item($sep);
193
+			}
189 194
 			$ci++;
190 195
 		}
191 196
 
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -46,22 +46,22 @@  discard block
 block discarded – undo
46 46
 	 * @return string the assembled html string containing the tabbed content for display.
47 47
 	 * @throws \EE_Error
48 48
 	 */
49
-	public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE ) {
49
+	public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE) {
50 50
 
51 51
 		//first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston
52
-		if ( !empty( $tabs_names) && ( count( (array) $tabs_names) != count( (array) $tabs_content) ) ) {
53
-			throw new EE_Error( __('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') );
52
+		if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) {
53
+			throw new EE_Error(__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso'));
54 54
 		}
55 55
 
56 56
 		//make sure we've got incoming data setup properly
57
-		$tabs = !empty( $tabs_names ) ? (array) $tabs_names : array_keys( (array) $tabs_contents );
58
-		$tabs_content = !empty( $tabs_names ) ? array_combine( (array) $tabs_names, (array) $tabs_content ) : $tabs_contents;
57
+		$tabs = ! empty($tabs_names) ? (array) $tabs_names : array_keys((array) $tabs_contents);
58
+		$tabs_content = ! empty($tabs_names) ? array_combine((array) $tabs_names, (array) $tabs_content) : $tabs_contents;
59 59
 
60
-		$all_tabs = '<h2 class="nav-tab-wrapper">' . "\n";
60
+		$all_tabs = '<h2 class="nav-tab-wrapper">'."\n";
61 61
 		$all_tabs_content = '';
62 62
 
63 63
 		$index = 0;
64
-		foreach ( $tabs as $tab ) {
64
+		foreach ($tabs as $tab) {
65 65
 			$active = $index === 0 ? true : false;
66 66
 			$all_tabs .= self::tab($tab, $active);
67 67
 			$all_tabs_content .= self::tab_content($tab, $tabs_content[$tab], $active);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		$tab_container_class = $small_tabs ? 'ee-nav-tabs ee-nav-tabs-small' : 'ee-nav-tabs';
80 80
 
81
-		return '<div class="'. $tab_container_class . '">' . "\n\t" . $all_tabs . $all_tabs_content . "\n" . '</div>';
81
+		return '<div class="'.$tab_container_class.'">'."\n\t".$all_tabs.$all_tabs_content."\n".'</div>';
82 82
 	}
83 83
 
84 84
 
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 	 * @throws \EE_Error
103 103
 	 */
104 104
 	public static function display_admin_nav_tabs($nav_tabs = array()) {
105
-		if ( empty($nav_tabs) )
106
-			throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) );
105
+		if (empty($nav_tabs))
106
+			throw new EE_Error(__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso'));
107 107
 
108
-		$all_tabs = '<h2 class="nav-tab-wrapper">' . "\n";
109
-		foreach ( $nav_tabs as $slug => $tab ) {
108
+		$all_tabs = '<h2 class="nav-tab-wrapper">'."\n";
109
+		foreach ($nav_tabs as $slug => $tab) {
110 110
 			$all_tabs .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']);
111 111
 		}
112 112
 		$all_tabs .= '</h2>';
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
 	 * @param bool|string $css If string given then the generated tab will include that as the class.
123 123
 	 * @return string          html for tab
124 124
 	 */
125
-	private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE ) {
125
+	private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE) {
126 126
 		$name = str_replace(' ', '-', $name);
127 127
 		$class = $active ? 'nav-tab nav-tab-active' : 'nav-tab';
128
-		$class = $css ? $class . ' ' . $css : $class;
129
-		$nice_name = $nice_name ? $nice_name : ucwords( preg_replace('/(-|_)/', ' ', $name) );
130
-		$url = $url ? $url : '#' . $name;
131
-		$tab = '<a class="' . $class . '" rel="ee-tab-' . $name . '" href="' . $url . '">' . $nice_name . '</a>' . "\n\t";
128
+		$class = $css ? $class.' '.$css : $class;
129
+		$nice_name = $nice_name ? $nice_name : ucwords(preg_replace('/(-|_)/', ' ', $name));
130
+		$url = $url ? $url : '#'.$name;
131
+		$tab = '<a class="'.$class.'" rel="ee-tab-'.$name.'" href="'.$url.'">'.$nice_name.'</a>'."\n\t";
132 132
 		return $tab;
133 133
 	}
134 134
 
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	private static function tab_content($name, $tab_content, $active = false) {
146 146
 		$class = $active ? 'nav-tab-content' : 'nav-tab-content hidden';
147
-		$name = str_replace( ' ', '-', $name);
148
-		$content = "\t" . '<div class="'. $class . '" id="ee-tab-' . $name . '">' . "\n";
149
-		$content .= "\t" . $tab_content . "\n";
147
+		$name = str_replace(' ', '-', $name);
148
+		$content = "\t".'<div class="'.$class.'" id="ee-tab-'.$name.'">'."\n";
149
+		$content .= "\t".$tab_content."\n";
150 150
 		$content .= '<div style="clear:both"></div></div>';
151 151
 		return $content;
152 152
 	}
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 	 * @param string $default 			You can include a string for the item that will receive the "item_display" class for the js.
173 173
 	 * @return string                  a html snippet of of all the formatted link elements.
174 174
 	 */
175
-	public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) {
176
-		$item_array = apply_filters( 'FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class );
177
-		if ( !is_array($item_array) || empty( $item_array ) )
175
+	public static function tab_text_links($item_array, $container_class = '', $sep = '|', $default = '') {
176
+		$item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class);
177
+		if ( ! is_array($item_array) || empty($item_array))
178 178
 			return false; //get out we don't have even the basic thing we need!
179 179
 
180 180
 
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 			'title' => esc_attr__('Link for Item', 'event_espresso'),
186 186
 			'slug' => 'item_slug'
187 187
 		);
188
-		$container_class = !empty($container_class) ? 'ee-text-links ' . $container_class : 'ee-text-links';
189
-		$list = '<ul class="' . $container_class . '">';
188
+		$container_class = ! empty($container_class) ? 'ee-text-links '.$container_class : 'ee-text-links';
189
+		$list = '<ul class="'.$container_class.'">';
190 190
 
191 191
 		$ci = 1;
192
-		foreach ( $item_array as $item ) {
193
-			$item = wp_parse_args( $item, $defaults );
194
-			$item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class'];
192
+		foreach ($item_array as $item) {
193
+			$item = wp_parse_args($item, $defaults);
194
+			$item['class'] = ! empty($default) && $default == $item['slug'] ? 'item_display '.$item['class'] : $item['class'];
195 195
 			$list .= self::_text_link_item($item);
196
-			if ( !empty($sep) && $ci != count($item_array) )
196
+			if ( ! empty($sep) && $ci != count($item_array))
197 197
 				$list .= self::_text_link_item($sep);
198 198
 			$ci++;
199 199
 		}
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 
205 205
 
206 206
 
207
-	private static function _text_link_item( $item ) {
207
+	private static function _text_link_item($item) {
208 208
 		//if this isn't an array then we're doing a separator
209
-		if ( !is_array( $item ) ) {
209
+		if ( ! is_array($item)) {
210 210
 			$label = $item;
211 211
 			$class = 'ee-text-link-sep';
212 212
 			$href = '';
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 			extract($item);
216 216
 		}
217 217
 
218
-		$class = $class != 'ee-text-link-sep'  ? 'class="ee-text-link-li ' . $class . '"' : 'class="ee-text-link-sep"';
218
+		$class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li '.$class.'"' : 'class="ee-text-link-sep"';
219 219
 
220
-		$content = '<li ' . $class . '>';
221
-		$content .= !empty($href) ? '<a class="ee-text-link" href="#' . $href . '" title="' . $title . '">' : '';
220
+		$content = '<li '.$class.'>';
221
+		$content .= ! empty($href) ? '<a class="ee-text-link" href="#'.$href.'" title="'.$title.'">' : '';
222 222
 		$content .= $label;
223
-		$content .= !empty($href) ? '</a>' : '';
223
+		$content .= ! empty($href) ? '</a>' : '';
224 224
 		$content .= '</li>';
225 225
 		return $content;
226 226
 	}
Please login to merge, or discard this patch.