Completed
Branch FET-9099-unit-test-factories (8a4437)
by
unknown
81:25 queued 71:40
created
core/libraries/rest_api/controllers/model/Read.php 3 patches
Braces   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		){
228 228
 			if( $relation instanceof \EE_Belongs_To_Relation ) {
229 229
 				$related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() );
230
-			}else{
230
+			} else{
231 231
 				$related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() );
232 232
 			}
233 233
 			return new \WP_Error(
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		}
281 281
 		if( $relation instanceof \EE_Belongs_To_Relation ){
282 282
 			return array_shift( $nice_results );
283
-		}else{
283
+		} else{
284 284
 			return $nice_results;
285 285
 		}
286 286
 	}
@@ -331,26 +331,26 @@  discard block
 block discarded – undo
331 331
 			$field_value = $field_obj->prepare_for_set_from_db( $raw_field_value );
332 332
 			if( $this->is_subclass_of_one(  $field_obj, $this->get_model_version_info()->fields_ignored() ) ){
333 333
 				unset( $result[ $field_name ] );
334
-			}elseif(
334
+			} elseif(
335 335
 				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() )
336 336
 			){
337 337
 				$result[ $field_name ] = array(
338 338
 					'raw' => $field_obj->prepare_for_get( $field_value ),
339 339
 					'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value )
340 340
 				);
341
-			}elseif(
341
+			} elseif(
342 342
 				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() )
343 343
 			){
344 344
 				$result[ $field_name ] = array(
345 345
 					'raw' => $field_obj->prepare_for_get( $field_value ),
346 346
 					'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value )
347 347
 				);
348
-			}elseif( $field_obj instanceof \EE_Datetime_Field ){
348
+			} elseif( $field_obj instanceof \EE_Datetime_Field ){
349 349
 				if( $raw_field_value instanceof \DateTime ) {
350 350
 					$raw_field_value = $raw_field_value->format( 'c' );
351 351
 				}
352 352
 				$result[ $field_name ] = mysql_to_rfc3339( $raw_field_value );
353
-			}else{
353
+			} else{
354 354
 				$value_prepared = $field_obj->prepare_for_get( $field_value );
355 355
 
356 356
 				$result[ $field_name ] = $value_prepared === INF ? EE_INF_IN_DB : $value_prepared;
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 	public static function get_related_entity_name( $relation_name, $relation_obj ){
480 480
 		if( $relation_obj instanceof \EE_Belongs_To_Relation ) {
481 481
 			return strtolower( $relation_name );
482
-		}else{
482
+		} else{
483 483
 			return \EEH_Inflector::pluralize_and_lower( $relation_name );
484 484
 		}
485 485
 	}
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 		$valid_contexts = \EEM_Base::valid_cap_contexts();
549 549
 		if( in_array( $context, $valid_contexts )  ){
550 550
 			return $context;
551
-		}else{
551
+		} else{
552 552
 			return \EEM_Base::caps_read;
553 553
 		}
554 554
 	}
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 			$order_by = $query_parameters[ 'order_by' ];
574 574
 		} elseif ( isset( $query_parameters[ 'orderby' ] ) ) {
575 575
 			$order_by = $query_parameters[ 'orderby' ];
576
-		}else{
576
+		} else{
577 577
 			$order_by = null;
578 578
 		}
579 579
 		if( $order_by !== null ){
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 			$group_by = $query_parameters[ 'group_by' ];
584 584
 		} elseif ( isset( $query_parameters[ 'groupby' ] ) ) {
585 585
 			$group_by = $query_parameters[ 'groupby' ];
586
-		}else{
586
+		} else{
587 587
 			$group_by = null;
588 588
 		}
589 589
 		if( $group_by !== null ){
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 			//limit should be either a string like '23' or '23,43', or an array with two items in it
607 607
 			if( is_string( $query_parameters[ 'limit' ] ) ) {
608 608
 				$limit_array = explode(',', $query_parameters['limit']);
609
-			}else {
609
+			} else {
610 610
 				$limit_array = $query_parameters[ 'limit' ];
611 611
 			}
612 612
 			$sanitized_limit = array();
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
 				$sanitized_limit[] = intval( $limit_part );
623 623
 			}
624 624
 			$model_query_params[ 'limit' ] = implode( ',', $sanitized_limit );
625
-		}else{
625
+		} else{
626 626
 			$model_query_params[ 'limit' ] = 50;
627 627
 		}
628 628
 		if( isset( $query_parameters[ 'caps' ] ) ) {
629 629
 			$model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] );
630
-		}else{
630
+		} else{
631 631
 			$model_query_params[ 'caps' ] = \EEM_Base::caps_read;
632 632
 		}
633 633
 		return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model );
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 		foreach( $query_params as $key => $value ) {
648 648
 			if( is_array( $value ) ) {
649 649
 				$model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value );
650
-			}else{
650
+			} else{
651 651
 				$model_ready_query_params[ $key ] = $value;
652 652
 			}
653 653
 		}
@@ -689,11 +689,11 @@  discard block
 block discarded – undo
689 689
 					//found the model name at the exact start
690 690
 					$field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include );
691 691
 					$extracted_fields_to_include[] = $field_sans_model_name;
692
-				}elseif( $field_to_include == $model_name ){
692
+				} elseif( $field_to_include == $model_name ){
693 693
 					$extracted_fields_to_include[] = '*';
694 694
 				}
695 695
 			}
696
-		}else{
696
+		} else{
697 697
 			//look for ones with no period
698 698
 			foreach( $includes as $field_to_include ) {
699 699
 				$field_to_include = trim( $field_to_include );
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -670,7 +670,7 @@
 block discarded – undo
670 670
 
671 671
 
672 672
 	/**
673
-	 * @param $model
673
+	 * @param \EEM_Base $model
674 674
 	 * @param $query_params
675 675
 	 * @return array
676 676
 	 */
Please login to merge, or discard this patch.
Spacing   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\libraries\rest_api\controllers\model;
3 3
 use EventEspresso\core\libraries\rest_api\Capabilities;
4
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 /**
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 	public function __construct() {
26 26
 		parent::__construct();
27
-		\EE_Registry::instance()->load_helper( 'Inflector' );
27
+		\EE_Registry::instance()->load_helper('Inflector');
28 28
 	}
29 29
 
30 30
 	/**
@@ -32,22 +32,22 @@  discard block
 block discarded – undo
32 32
 	 * @param \WP_REST_Request $request
33 33
 	 * @return \WP_REST_Response|\WP_Error
34 34
 	 */
35
-	public static function handle_request_get_all( \WP_REST_Request $request) {
35
+	public static function handle_request_get_all(\WP_REST_Request $request) {
36 36
 		$controller = new Read();
37
-		try{
37
+		try {
38 38
 			$matches = $controller->parse_route(
39 39
 				$request->get_route(),
40
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~',
41
-				array( 'version', 'model' )
40
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~',
41
+				array('version', 'model')
42 42
 			);
43
-			$controller->set_requested_version( $matches[ 'version' ] );
44
-			$model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
45
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) {
43
+			$controller->set_requested_version($matches['version']);
44
+			$model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
45
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) {
46 46
 				return $controller->send_response(
47 47
 					new \WP_Error(
48 48
 						'endpoint_parsing_error',
49 49
 						sprintf(
50
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
50
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
51 51
 							$model_name_singular
52 52
 						)
53 53
 					)
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 			}
56 56
 			return $controller->send_response(
57 57
 					$controller->get_entities_from_model(
58
-							$controller->get_model_version_info()->load_model( $model_name_singular ),
58
+							$controller->get_model_version_info()->load_model($model_name_singular),
59 59
 							$request
60 60
 					)
61 61
 			);
62
-		} catch( \Exception $e ) {
63
-			return $controller->send_response( $e );
62
+		} catch (\Exception $e) {
63
+			return $controller->send_response($e);
64 64
 		}
65 65
 	}
66 66
 
@@ -70,21 +70,21 @@  discard block
 block discarded – undo
70 70
 	 * @param \WP_Rest_Request $request
71 71
 	 * @return \WP_REST_Response|\WP_Error
72 72
 	 */
73
-	public static function handle_request_get_one( \WP_Rest_Request $request ) {
73
+	public static function handle_request_get_one(\WP_Rest_Request $request) {
74 74
 		$controller = new Read();
75
-		try{
75
+		try {
76 76
 			$matches = $controller->parse_route(
77 77
 				$request->get_route(),
78
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~',
79
-				array( 'version', 'model', 'id' ) );
80
-			$controller->set_requested_version( $matches[ 'version' ] );
81
-			$model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
82
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) {
78
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~',
79
+				array('version', 'model', 'id') );
80
+			$controller->set_requested_version($matches['version']);
81
+			$model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
82
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) {
83 83
 				return $controller->send_response(
84 84
 					new \WP_Error(
85 85
 						'endpoint_parsing_error',
86 86
 						sprintf(
87
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
87
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
88 88
 							$model_name_singular
89 89
 						)
90 90
 					)
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 			}
93 93
 			return $controller->send_response(
94 94
 					$controller->get_entity_from_model(
95
-							$controller->get_model_version_info()->load_model( $model_name_singular ),
95
+							$controller->get_model_version_info()->load_model($model_name_singular),
96 96
 							$request
97 97
 						)
98 98
 				);
99
-		} catch( \Exception $e ) {
100
-			return $controller->send_response( $e );
99
+		} catch (\Exception $e) {
100
+			return $controller->send_response($e);
101 101
 		}
102 102
 	}
103 103
 
@@ -109,40 +109,40 @@  discard block
 block discarded – undo
109 109
 	 * @param \WP_REST_Request $request
110 110
 	 * @return \WP_REST_Response|\WP_Error
111 111
 	 */
112
-	public static function handle_request_get_related( \WP_REST_Request $request ) {
112
+	public static function handle_request_get_related(\WP_REST_Request $request) {
113 113
 		$controller = new Read();
114
-		try{
114
+		try {
115 115
 			$matches = $controller->parse_route(
116 116
 				$request->get_route(),
117
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~',
118
-				array( 'version', 'model', 'id', 'related_model' )
117
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~',
118
+				array('version', 'model', 'id', 'related_model')
119 119
 			);
120
-			$controller->set_requested_version( $matches[ 'version' ] );
121
-			$main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
122
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) {
120
+			$controller->set_requested_version($matches['version']);
121
+			$main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
122
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) {
123 123
 				return $controller->send_response(
124 124
 					new \WP_Error(
125 125
 						'endpoint_parsing_error',
126 126
 						sprintf(
127
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
127
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
128 128
 							$main_model_name_singular
129 129
 						)
130 130
 					)
131 131
 				);
132 132
 			}
133
-			$main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular );
133
+			$main_model = $controller->get_model_version_info()->load_model($main_model_name_singular);
134 134
 			//assume the related model name is plural and try to find the model's name
135
-			$related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] );
136
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) {
135
+			$related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']);
136
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) {
137 137
 				//so the word didn't singularize well. Maybe that's just because it's a singular word?
138
-				$related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] );
138
+				$related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']);
139 139
 			}
140
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) {
140
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) {
141 141
 				return $controller->send_response(
142 142
 					new \WP_Error(
143 143
 						'endpoint_parsing_error',
144 144
 						sprintf(
145
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
145
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
146 146
 							$related_model_name_singular
147 147
 						)
148 148
 					)
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
 
152 152
 			return $controller->send_response(
153 153
 					$controller->get_entities_from_relation(
154
-						$request->get_param( 'id' ),
155
-						$main_model->related_settings_for( $related_model_name_singular ) ,
154
+						$request->get_param('id'),
155
+						$main_model->related_settings_for($related_model_name_singular),
156 156
 						$request
157 157
 					)
158 158
 				);
159
-		} catch( \Exception $e ) {
160
-			return $controller->send_response( $e );
159
+		} catch (\Exception $e) {
160
+			return $controller->send_response($e);
161 161
 		}
162 162
 	}
163 163
 
@@ -170,31 +170,31 @@  discard block
 block discarded – undo
170 170
 	 * @param \WP_REST_Request $request
171 171
 	 * @return array
172 172
 	 */
173
-	public function get_entities_from_model( $model, $request) {
174
-		$query_params = $this->create_model_query_params( $model, $request->get_params() );
175
-		if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) {
176
-			$model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() );
173
+	public function get_entities_from_model($model, $request) {
174
+		$query_params = $this->create_model_query_params($model, $request->get_params());
175
+		if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) {
176
+			$model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name());
177 177
 			return new \WP_Error(
178
-				sprintf( 'rest_%s_cannot_list', $model_name_plural ),
178
+				sprintf('rest_%s_cannot_list', $model_name_plural),
179 179
 				sprintf(
180
-					__( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ),
180
+					__('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'),
181 181
 					$model_name_plural,
182
-					Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] )
182
+					Capabilities::get_missing_permissions_string($model, $query_params['caps'])
183 183
 				),
184
-				array( 'status' => 403 )
184
+				array('status' => 403)
185 185
 			);
186 186
 		}
187 187
 
188
-		$this->_set_debug_info( 'model query params', $query_params );
188
+		$this->_set_debug_info('model query params', $query_params);
189 189
 		/** @type array $results */
190
-		$results = $model->get_all_wpdb_results( $query_params );
190
+		$results = $model->get_all_wpdb_results($query_params);
191 191
 		$nice_results = array( );
192
-		foreach ( $results as $result ) {
193
-			$nice_results[ ] = $this->create_entity_from_wpdb_result(
192
+		foreach ($results as $result) {
193
+			$nice_results[] = $this->create_entity_from_wpdb_result(
194 194
 					$model,
195 195
 					$result,
196
-					$request->get_param( 'include' ),
197
-					$query_params[ 'caps' ]
196
+					$request->get_param('include'),
197
+					$query_params['caps']
198 198
 				);
199 199
 		}
200 200
 		return $nice_results;
@@ -212,83 +212,83 @@  discard block
 block discarded – undo
212 212
 	 * @param \WP_REST_Request $request
213 213
 	 * @return array
214 214
 	 */
215
-	public function get_entities_from_relation( $id,  $relation, $request ) {
216
-		$context = $this->validate_context( $request->get_param( 'caps' ));
215
+	public function get_entities_from_relation($id, $relation, $request) {
216
+		$context = $this->validate_context($request->get_param('caps'));
217 217
 		$model = $relation->get_this_model();
218 218
 		$related_model = $relation->get_other_model();
219 219
 		//check if they can access the 1st model object
220
-		$query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 );
221
-		if( $model instanceof \EEM_Soft_Delete_Base ){
220
+		$query_params = array(array($model->primary_key_name() => $id), 'limit' => 1);
221
+		if ($model instanceof \EEM_Soft_Delete_Base) {
222 222
 			$query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params);
223 223
 		}
224 224
 		$restricted_query_params = $query_params;
225
-		$restricted_query_params[ 'caps' ] = $context;
226
-		$this->_set_debug_info( 'main model query params', $restricted_query_params );
227
-		$this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) );
225
+		$restricted_query_params['caps'] = $context;
226
+		$this->_set_debug_info('main model query params', $restricted_query_params);
227
+		$this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context));
228 228
 
229
-		if(
229
+		if (
230 230
 			! (
231
-				Capabilities::current_user_has_partial_access_to( $related_model, $context )
232
-				&& $model->exists( $restricted_query_params )
231
+				Capabilities::current_user_has_partial_access_to($related_model, $context)
232
+				&& $model->exists($restricted_query_params)
233 233
 			)
234
-		){
235
-			if( $relation instanceof \EE_Belongs_To_Relation ) {
236
-				$related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() );
237
-			}else{
238
-				$related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() );
234
+		) {
235
+			if ($relation instanceof \EE_Belongs_To_Relation) {
236
+				$related_model_name_maybe_plural = strtolower($related_model->get_this_model_name());
237
+			} else {
238
+				$related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name());
239 239
 			}
240 240
 			return new \WP_Error(
241
-				sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ),
241
+				sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural),
242 242
 				sprintf(
243
-					__(	'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ),
243
+					__('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'),
244 244
 					$related_model_name_maybe_plural,
245 245
 					$relation->get_this_model()->get_this_model_name(),
246 246
 					implode(
247 247
 						',',
248 248
 						array_keys(
249
-							Capabilities::get_missing_permissions( $related_model, $context )
249
+							Capabilities::get_missing_permissions($related_model, $context)
250 250
 						)
251 251
 					)
252 252
 				),
253
-				array( 'status' => 403 )
253
+				array('status' => 403)
254 254
 			);
255 255
 		}
256
-		$query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() );
257
-		$query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id;
258
-		$query_params[ 'default_where_conditions' ] = 'none';
259
-		$query_params[ 'caps' ] = $context;
260
-		$this->_set_debug_info( 'model query params', $query_params );
256
+		$query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params());
257
+		$query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id;
258
+		$query_params['default_where_conditions'] = 'none';
259
+		$query_params['caps'] = $context;
260
+		$this->_set_debug_info('model query params', $query_params);
261 261
 		/** @type array $results */
262
-		$results = $relation->get_other_model()->get_all_wpdb_results( $query_params );
262
+		$results = $relation->get_other_model()->get_all_wpdb_results($query_params);
263 263
 		$nice_results = array();
264
-		foreach( $results as $result ) {
264
+		foreach ($results as $result) {
265 265
 			$nice_result = $this->create_entity_from_wpdb_result(
266 266
 				$relation->get_other_model(),
267 267
 				$result,
268
-				$request->get_param( 'include' ),
269
-				$query_params[ 'caps' ]
268
+				$request->get_param('include'),
269
+				$query_params['caps']
270 270
 			);
271
-			if( $relation instanceof \EE_HABTM_Relation ) {
271
+			if ($relation instanceof \EE_HABTM_Relation) {
272 272
 				//put the unusual stuff (properties from the HABTM relation) first, and make sure
273 273
 				//if there are conflicts we prefer the properties from the main model
274 274
 				$join_model_result = $this->create_entity_from_wpdb_result(
275 275
 					$relation->get_join_model(),
276 276
 					$result,
277
-					$request->get_param( 'include' ),
278
-					$query_params[ 'caps' ]
277
+					$request->get_param('include'),
278
+					$query_params['caps']
279 279
 				);
280
-				$joined_result = array_merge( $nice_result, $join_model_result );
280
+				$joined_result = array_merge($nice_result, $join_model_result);
281 281
 				//but keep the meta stuff from the main model
282
-				if( isset( $nice_result['meta'] ) ){
282
+				if (isset($nice_result['meta'])) {
283 283
 					$joined_result['meta'] = $nice_result['meta'];
284 284
 				}
285 285
 				$nice_result = $joined_result;
286 286
 			}
287 287
 			$nice_results[] = $nice_result;
288 288
 		}
289
-		if( $relation instanceof \EE_Belongs_To_Relation ){
290
-			return array_shift( $nice_results );
291
-		}else{
289
+		if ($relation instanceof \EE_Belongs_To_Relation) {
290
+			return array_shift($nice_results);
291
+		} else {
292 292
 			return $nice_results;
293 293
 		}
294 294
 	}
@@ -325,110 +325,110 @@  discard block
 block discarded – undo
325 325
 	 * @param string $context one of the return values from EEM_Base::valid_cap_contexts()
326 326
 	 * @return array ready for being converted into json for sending to client
327 327
 	 */
328
-	public function create_entity_from_wpdb_result( $model, $db_row, $include, $context ) {
329
-		if( $include == null ) {
328
+	public function create_entity_from_wpdb_result($model, $db_row, $include, $context) {
329
+		if ($include == null) {
330 330
 			$include = '*';
331 331
 		}
332
-		if( $context == null ) {
332
+		if ($context == null) {
333 333
 			$context = \EEM_Base::caps_read;
334 334
 		}
335
-		$result = $model->deduce_fields_n_values_from_cols_n_values( $db_row );
336
-		$result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) );
337
-		foreach( $result as $field_name => $raw_field_value ) {
335
+		$result = $model->deduce_fields_n_values_from_cols_n_values($db_row);
336
+		$result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model));
337
+		foreach ($result as $field_name => $raw_field_value) {
338 338
 			$field_obj = $model->field_settings_for($field_name);
339
-			$field_value = $field_obj->prepare_for_set_from_db( $raw_field_value );
340
-			if( $this->is_subclass_of_one(  $field_obj, $this->get_model_version_info()->fields_ignored() ) ){
341
-				unset( $result[ $field_name ] );
342
-			}elseif(
343
-				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() )
344
-			){
345
-				$result[ $field_name ] = array(
346
-					'raw' => $field_obj->prepare_for_get( $field_value ),
347
-					'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value )
339
+			$field_value = $field_obj->prepare_for_set_from_db($raw_field_value);
340
+			if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) {
341
+				unset($result[$field_name]);
342
+			}elseif (
343
+				$this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format())
344
+			) {
345
+				$result[$field_name] = array(
346
+					'raw' => $field_obj->prepare_for_get($field_value),
347
+					'rendered' => $field_obj->prepare_for_pretty_echoing($field_value)
348 348
 				);
349
-			}elseif(
350
-				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() )
351
-			){
352
-				$result[ $field_name ] = array(
353
-					'raw' => $field_obj->prepare_for_get( $field_value ),
354
-					'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value )
349
+			}elseif (
350
+				$this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format())
351
+			) {
352
+				$result[$field_name] = array(
353
+					'raw' => $field_obj->prepare_for_get($field_value),
354
+					'pretty' => $field_obj->prepare_for_pretty_echoing($field_value)
355 355
 				);
356
-			}elseif( $field_obj instanceof \EE_Datetime_Field ){
357
-				if( $raw_field_value instanceof \DateTime ) {
358
-					$raw_field_value = $raw_field_value->format( 'c' );
356
+			}elseif ($field_obj instanceof \EE_Datetime_Field) {
357
+				if ($raw_field_value instanceof \DateTime) {
358
+					$raw_field_value = $raw_field_value->format('c');
359 359
 				}
360
-				$result[ $field_name ] = mysql_to_rfc3339( $raw_field_value );
361
-			}else{
362
-				$value_prepared = $field_obj->prepare_for_get( $field_value );
360
+				$result[$field_name] = mysql_to_rfc3339($raw_field_value);
361
+			} else {
362
+				$value_prepared = $field_obj->prepare_for_get($field_value);
363 363
 
364
-				$result[ $field_name ] = $value_prepared === INF ? EE_INF_IN_DB : $value_prepared;
364
+				$result[$field_name] = $value_prepared === INF ? EE_INF_IN_DB : $value_prepared;
365 365
 			}
366 366
 		}
367
-		if( $model instanceof \EEM_CPT_Base ) {
367
+		if ($model instanceof \EEM_CPT_Base) {
368 368
 			$attachment = wp_get_attachment_image_src(
369
-				get_post_thumbnail_id( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ),
369
+				get_post_thumbnail_id($db_row[$model->get_primary_key_field()->get_qualified_column()]),
370 370
 				'full'
371 371
 			);
372
-			$result[ 'featured_image_url' ] = !empty( $attachment ) ? $attachment[ 0 ] : null;
373
-			$result[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] );
372
+			$result['featured_image_url'] = ! empty($attachment) ? $attachment[0] : null;
373
+			$result['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]);
374 374
 		}
375 375
 		//add links to related data
376 376
 		$result['_links'] = array(
377 377
 			'self' => array(
378 378
 				array(
379 379
 					'href' => $this->get_versioned_link_to(
380
-						\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $result[ $model->primary_key_name() ]
380
+						\EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$result[$model->primary_key_name()]
381 381
 					)
382 382
 				)
383 383
 			),
384 384
 			'collection' => array(
385 385
 				array(
386 386
 					'href' => $this->get_versioned_link_to(
387
-						\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() )
387
+						\EEH_Inflector::pluralize_and_lower($model->get_this_model_name())
388 388
 					)
389 389
 				)
390 390
 			),
391 391
 		);
392 392
 		global $wp_rest_server;
393
-		if( $model instanceof \EEM_CPT_Base &&
393
+		if ($model instanceof \EEM_CPT_Base &&
394 394
 			$wp_rest_server instanceof \WP_REST_Server &&
395
-			$wp_rest_server->get_route_options( '/wp/v2/posts' ) ) {
396
-			$result[ '_links' ][ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array(
395
+			$wp_rest_server->get_route_options('/wp/v2/posts')) {
396
+			$result['_links'][\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array(
397 397
 				array(
398
-					'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ),
398
+					'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]),
399 399
 					'single' => true
400 400
 				)
401 401
 			);
402 402
 		}
403 403
 
404 404
 		//filter fields if specified
405
-		$includes_for_this_model = $this->extract_includes_for_this_model( $include );
406
-		if( ! empty( $includes_for_this_model ) ) {
407
-			if( $model->has_primary_key_field() ) {
405
+		$includes_for_this_model = $this->extract_includes_for_this_model($include);
406
+		if ( ! empty($includes_for_this_model)) {
407
+			if ($model->has_primary_key_field()) {
408 408
 				//always include the primary key
409 409
 				$includes_for_this_model[] = $model->primary_key_name();
410 410
 			}
411
-			$result = array_intersect_key( $result, array_flip( $includes_for_this_model ) );
411
+			$result = array_intersect_key($result, array_flip($includes_for_this_model));
412 412
 		}
413 413
 		//add meta links and possibly include related models
414 414
 		$relation_settings = apply_filters(
415 415
 			'FHEE__Read__create_entity_from_wpdb_result__related_models_to_include',
416 416
 			$model->relation_settings()
417 417
 		);
418
-		foreach( $relation_settings as $relation_name => $relation_obj ) {
419
-			$related_model_part = $this->get_related_entity_name( $relation_name, $relation_obj );
420
-			if( empty( $includes_for_this_model ) || isset( $includes_for_this_model['meta'] ) ) {
421
-				$result['_links'][ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part] = array(
418
+		foreach ($relation_settings as $relation_name => $relation_obj) {
419
+			$related_model_part = $this->get_related_entity_name($relation_name, $relation_obj);
420
+			if (empty($includes_for_this_model) || isset($includes_for_this_model['meta'])) {
421
+				$result['_links'][\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array(
422 422
 					array(
423 423
 						'href' => $this->get_versioned_link_to(
424
-							\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $result[ $model->primary_key_name() ] . '/' . $related_model_part
424
+							\EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$result[$model->primary_key_name()].'/'.$related_model_part
425 425
 						),
426 426
 						'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false
427 427
 					)
428 428
 				);
429 429
 			}
430
-			$related_fields_to_include = $this->extract_includes_for_this_model( $include, $relation_name );
431
-			if( $related_fields_to_include ) {
430
+			$related_fields_to_include = $this->extract_includes_for_this_model($include, $relation_name);
431
+			if ($related_fields_to_include) {
432 432
 				$pretend_related_request = new \WP_REST_Request();
433 433
 				$pretend_related_request->set_query_params(
434 434
 					array(
@@ -440,11 +440,11 @@  discard block
 block discarded – undo
440 440
 					)
441 441
 				);
442 442
 				$related_results = $this->get_entities_from_relation(
443
-					$result[ $model->primary_key_name() ],
443
+					$result[$model->primary_key_name()],
444 444
 					$relation_obj,
445 445
 					$pretend_related_request
446 446
 				);
447
-				$result[ $related_model_part ] = $related_results instanceof \WP_Error ? null : $related_results;
447
+				$result[$related_model_part] = $related_results instanceof \WP_Error ? null : $related_results;
448 448
 			}
449 449
 		}
450 450
 		$result = apply_filters(
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 		);
462 462
 		$this->_set_debug_info(
463 463
 			'inaccessible fields',
464
-			array_keys( array_diff_key( $result, $result_without_inaccessible_fields ) )
464
+			array_keys(array_diff_key($result, $result_without_inaccessible_fields))
465 465
 		);
466 466
 		return apply_filters(
467 467
 			'FHEE__Read__create_entity_from_wpdb_results__entity_return',
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
 	 * @param string $link_part_after_version_and_slash eg "events/10/datetimes"
477 477
 	 * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes"
478 478
 	 */
479
-	public function get_versioned_link_to( $link_part_after_version_and_slash ) {
480
-		return rest_url( \EED_Core_Rest_Api::ee_api_namespace . $this->get_model_version_info()->requested_version() . '/' . $link_part_after_version_and_slash );
479
+	public function get_versioned_link_to($link_part_after_version_and_slash) {
480
+		return rest_url(\EED_Core_Rest_Api::ee_api_namespace.$this->get_model_version_info()->requested_version().'/'.$link_part_after_version_and_slash);
481 481
 	}
482 482
 
483 483
 	/**
@@ -487,11 +487,11 @@  discard block
 block discarded – undo
487 487
 	 * @param \EE_Model_Relation_Base $relation_obj
488 488
 	 * @return string
489 489
 	 */
490
-	public static function get_related_entity_name( $relation_name, $relation_obj ){
491
-		if( $relation_obj instanceof \EE_Belongs_To_Relation ) {
492
-			return strtolower( $relation_name );
493
-		}else{
494
-			return \EEH_Inflector::pluralize_and_lower( $relation_name );
490
+	public static function get_related_entity_name($relation_name, $relation_obj) {
491
+		if ($relation_obj instanceof \EE_Belongs_To_Relation) {
492
+			return strtolower($relation_name);
493
+		} else {
494
+			return \EEH_Inflector::pluralize_and_lower($relation_name);
495 495
 		}
496 496
 	}
497 497
 
@@ -504,44 +504,44 @@  discard block
 block discarded – undo
504 504
 	 * @param \WP_REST_Request $request
505 505
 	 * @return array
506 506
 	 */
507
-	public function get_entity_from_model( $model, $request ) {
508
-		$query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1);
509
-		if( $model instanceof \EEM_Soft_Delete_Base ){
507
+	public function get_entity_from_model($model, $request) {
508
+		$query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1);
509
+		if ($model instanceof \EEM_Soft_Delete_Base) {
510 510
 			$query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params);
511 511
 		}
512 512
 		$restricted_query_params = $query_params;
513
-		$restricted_query_params[ 'caps' ] =  $this->validate_context(  $request->get_param( 'caps' ) );
514
-		$this->_set_debug_info( 'model query params', $restricted_query_params );
515
-		$model_rows = $model->get_all_wpdb_results( $restricted_query_params );
516
-		if ( ! empty ( $model_rows ) ) {
513
+		$restricted_query_params['caps'] = $this->validate_context($request->get_param('caps'));
514
+		$this->_set_debug_info('model query params', $restricted_query_params);
515
+		$model_rows = $model->get_all_wpdb_results($restricted_query_params);
516
+		if ( ! empty ($model_rows)) {
517 517
 			return $this->create_entity_from_wpdb_result(
518 518
 				$model,
519
-				array_shift( $model_rows ),
520
-				$request->get_param( 'include' ),
521
-				$this->validate_context( $request->get_param( 'caps' ) ) );
519
+				array_shift($model_rows),
520
+				$request->get_param('include'),
521
+				$this->validate_context($request->get_param('caps')) );
522 522
 		} else {
523 523
 			//ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities
524
-			$lowercase_model_name = strtolower( $model->get_this_model_name() );
525
-			$model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params );
526
-			if( ! empty( $model_rows_found_sans_restrictions ) ) {
524
+			$lowercase_model_name = strtolower($model->get_this_model_name());
525
+			$model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params);
526
+			if ( ! empty($model_rows_found_sans_restrictions)) {
527 527
 				//you got shafted- it existed but we didn't want to tell you!
528 528
 				return new \WP_Error(
529 529
 					'rest_user_cannot_read',
530 530
 					sprintf(
531
-						__( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ),
532
-						strtolower( $model->get_this_model_name() ),
531
+						__('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'),
532
+						strtolower($model->get_this_model_name()),
533 533
 						Capabilities::get_missing_permissions_string(
534 534
 							$model,
535
-							$this->validate_context( $request->get_param( 'caps' ) ) )
535
+							$this->validate_context($request->get_param('caps')) )
536 536
 					),
537
-					array( 'status' => 403 )
537
+					array('status' => 403)
538 538
 				);
539 539
 			} else {
540 540
 				//it's not you. It just doesn't exist
541 541
 				return new \WP_Error(
542
-					sprintf( 'rest_%s_invalid_id', $lowercase_model_name ),
543
-					sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ),
544
-					array( 'status' => 404 )
542
+					sprintf('rest_%s_invalid_id', $lowercase_model_name),
543
+					sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name),
544
+					array('status' => 404)
545 545
 				);
546 546
 			}
547 547
 		}
@@ -554,14 +554,14 @@  discard block
 block discarded – undo
554 554
 	 * @param string $context
555 555
 	 * @return string array key of EEM_Base::cap_contexts_to_cap_action_map()
556 556
 	 */
557
-	public function validate_context( $context ) {
558
-		if( ! $context ) {
557
+	public function validate_context($context) {
558
+		if ( ! $context) {
559 559
 			$context = \EEM_Base::caps_read;
560 560
 		}
561 561
 		$valid_contexts = \EEM_Base::valid_cap_contexts();
562
-		if( in_array( $context, $valid_contexts )  ){
562
+		if (in_array($context, $valid_contexts)) {
563 563
 			return $context;
564
-		}else{
564
+		} else {
565 565
 			return \EEM_Base::caps_read;
566 566
 		}
567 567
 	}
@@ -577,73 +577,73 @@  discard block
 block discarded – undo
577 577
 	 *                          that absolutely no results should be returned
578 578
 	 * @throws \EE_Error
579 579
 	 */
580
-	public function create_model_query_params( $model, $query_parameters ) {
580
+	public function create_model_query_params($model, $query_parameters) {
581 581
 		$model_query_params = array( );
582
-		if ( isset( $query_parameters[ 'where' ] ) ) {
583
-			$model_query_params[ 0 ] = $this->prepare_rest_query_params_key_for_models( $model, $query_parameters[ 'where' ] );
584
-		}
585
-		if ( isset( $query_parameters[ 'order_by' ] ) ) {
586
-			$order_by = $query_parameters[ 'order_by' ];
587
-		} elseif ( isset( $query_parameters[ 'orderby' ] ) ) {
588
-			$order_by = $query_parameters[ 'orderby' ];
589
-		}else{
582
+		if (isset($query_parameters['where'])) {
583
+			$model_query_params[0] = $this->prepare_rest_query_params_key_for_models($model, $query_parameters['where']);
584
+		}
585
+		if (isset($query_parameters['order_by'])) {
586
+			$order_by = $query_parameters['order_by'];
587
+		} elseif (isset($query_parameters['orderby'])) {
588
+			$order_by = $query_parameters['orderby'];
589
+		} else {
590 590
 			$order_by = null;
591 591
 		}
592
-		if( $order_by !== null ){
593
-			$model_query_params[ 'order_by' ] = $this->prepare_rest_query_params_key_for_models( $model, $order_by );
592
+		if ($order_by !== null) {
593
+			$model_query_params['order_by'] = $this->prepare_rest_query_params_key_for_models($model, $order_by);
594 594
 		}
595
-		if ( isset( $query_parameters[ 'group_by' ] ) ) {
596
-			$group_by = $query_parameters[ 'group_by' ];
597
-		} elseif ( isset( $query_parameters[ 'groupby' ] ) ) {
598
-			$group_by = $query_parameters[ 'groupby' ];
599
-		}else{
595
+		if (isset($query_parameters['group_by'])) {
596
+			$group_by = $query_parameters['group_by'];
597
+		} elseif (isset($query_parameters['groupby'])) {
598
+			$group_by = $query_parameters['groupby'];
599
+		} else {
600 600
 			$group_by = null;
601 601
 		}
602
-		if( $group_by !== null ){
603
-			if( is_array( $group_by ) ) {
604
-				$group_by = $this->prepare_rest_query_params_values_for_models( $model, $group_by );
602
+		if ($group_by !== null) {
603
+			if (is_array($group_by)) {
604
+				$group_by = $this->prepare_rest_query_params_values_for_models($model, $group_by);
605 605
 			}
606
-			$model_query_params[ 'group_by' ] = $group_by;
606
+			$model_query_params['group_by'] = $group_by;
607 607
 		}
608
-		if ( isset( $query_parameters[ 'having' ] ) ) {
608
+		if (isset($query_parameters['having'])) {
609 609
 			//@todo: no good for permissions
610
-			$model_query_params[ 'having' ] = $this->prepare_rest_query_params_key_for_models( $model, $query_parameters[ 'having' ] );
610
+			$model_query_params['having'] = $this->prepare_rest_query_params_key_for_models($model, $query_parameters['having']);
611 611
 		}
612
-		if ( isset( $query_parameters[ 'order' ] ) ) {
613
-			$model_query_params[ 'order' ] = $query_parameters[ 'order' ];
612
+		if (isset($query_parameters['order'])) {
613
+			$model_query_params['order'] = $query_parameters['order'];
614 614
 		}
615
-		if ( isset( $query_parameters[ 'mine' ] ) ){
616
-			$model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params );
615
+		if (isset($query_parameters['mine'])) {
616
+			$model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params);
617 617
 		}
618
-		if( isset( $query_parameters[ 'limit' ] ) ) {
618
+		if (isset($query_parameters['limit'])) {
619 619
 			//limit should be either a string like '23' or '23,43', or an array with two items in it
620
-			if( is_string( $query_parameters[ 'limit' ] ) ) {
620
+			if (is_string($query_parameters['limit'])) {
621 621
 				$limit_array = explode(',', $query_parameters['limit']);
622
-			}else {
623
-				$limit_array = $query_parameters[ 'limit' ];
622
+			} else {
623
+				$limit_array = $query_parameters['limit'];
624 624
 			}
625 625
 			$sanitized_limit = array();
626
-			foreach( $limit_array as $key => $limit_part ) {
627
-				if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) {
626
+			foreach ($limit_array as $key => $limit_part) {
627
+				if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) {
628 628
 					throw new \EE_Error(
629 629
 						sprintf(
630
-							__( 'An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso' ),
631
-							json_encode( $query_parameters[ 'limit' ] )
630
+							__('An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso'),
631
+							json_encode($query_parameters['limit'])
632 632
 						)
633 633
 					);
634 634
 				}
635
-				$sanitized_limit[] = intval( $limit_part );
635
+				$sanitized_limit[] = intval($limit_part);
636 636
 			}
637
-			$model_query_params[ 'limit' ] = implode( ',', $sanitized_limit );
638
-		}else{
639
-			$model_query_params[ 'limit' ] = 50;
637
+			$model_query_params['limit'] = implode(',', $sanitized_limit);
638
+		} else {
639
+			$model_query_params['limit'] = 50;
640 640
 		}
641
-		if( isset( $query_parameters[ 'caps' ] ) ) {
642
-			$model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] );
643
-		}else{
644
-			$model_query_params[ 'caps' ] = \EEM_Base::caps_read;
641
+		if (isset($query_parameters['caps'])) {
642
+			$model_query_params['caps'] = $this->validate_context($query_parameters['caps']);
643
+		} else {
644
+			$model_query_params['caps'] = \EEM_Base::caps_read;
645 645
 		}
646
-		return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model );
646
+		return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model);
647 647
 	}
648 648
 
649 649
 
@@ -655,13 +655,13 @@  discard block
 block discarded – undo
655 655
 	 * @param array     $query_params sub-array from @see EEM_Base::get_all()
656 656
 	 * @return array
657 657
 	 */
658
-	public function prepare_rest_query_params_key_for_models( $model,  $query_params ) {
658
+	public function prepare_rest_query_params_key_for_models($model, $query_params) {
659 659
 		$model_ready_query_params = array();
660
-		foreach( $query_params as $key => $value ) {
661
-			if( is_array( $value ) ) {
662
-				$model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value );
663
-			}else{
664
-				$model_ready_query_params[ $key ] = $value;
660
+		foreach ($query_params as $key => $value) {
661
+			if (is_array($value)) {
662
+				$model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value);
663
+			} else {
664
+				$model_ready_query_params[$key] = $value;
665 665
 			}
666 666
 		}
667 667
 		return $model_ready_query_params;
@@ -674,13 +674,13 @@  discard block
 block discarded – undo
674 674
 	 * @param $query_params
675 675
 	 * @return array
676 676
 	 */
677
-	public function prepare_rest_query_params_values_for_models( $model, $query_params ) {
677
+	public function prepare_rest_query_params_values_for_models($model, $query_params) {
678 678
 		$model_ready_query_params = array();
679
-		foreach( $query_params as $key => $value ) {
680
-			if( is_array( $value ) ) {
681
-				$model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value );
679
+		foreach ($query_params as $key => $value) {
680
+			if (is_array($value)) {
681
+				$model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value);
682 682
 			} else {
683
-				$model_ready_query_params[ $key ] = $value;
683
+				$model_ready_query_params[$key] = $value;
684 684
 			}
685 685
 		}
686 686
 		return $model_ready_query_params;
@@ -696,33 +696,33 @@  discard block
 block discarded – undo
696 696
 	 * @return array of fields for this model. If $model_name is provided, then
697 697
 	 * the fields for that model, with the model's name removed from each.
698 698
 	 */
699
-	public function extract_includes_for_this_model( $include_string, $model_name = null ) {
700
-		if( is_array( $include_string ) ) {
701
-			$include_string = implode( ',', $include_string );
699
+	public function extract_includes_for_this_model($include_string, $model_name = null) {
700
+		if (is_array($include_string)) {
701
+			$include_string = implode(',', $include_string);
702 702
 		}
703
-		if( $include_string === '*' ) {
703
+		if ($include_string === '*') {
704 704
 			return array();
705 705
 		}
706
-		$includes = explode( ',', $include_string );
706
+		$includes = explode(',', $include_string);
707 707
 		$extracted_fields_to_include = array();
708
-		if( $model_name ){
709
-			foreach( $includes as $field_to_include ) {
710
-				$field_to_include = trim( $field_to_include );
711
-				if( strpos( $field_to_include, $model_name . '.' ) === 0 ) {
708
+		if ($model_name) {
709
+			foreach ($includes as $field_to_include) {
710
+				$field_to_include = trim($field_to_include);
711
+				if (strpos($field_to_include, $model_name.'.') === 0) {
712 712
 					//found the model name at the exact start
713
-					$field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include );
713
+					$field_sans_model_name = str_replace($model_name.'.', '', $field_to_include);
714 714
 					$extracted_fields_to_include[] = $field_sans_model_name;
715
-				}elseif( $field_to_include == $model_name ){
715
+				}elseif ($field_to_include == $model_name) {
716 716
 					$extracted_fields_to_include[] = '*';
717 717
 				}
718 718
 			}
719
-		}else{
719
+		} else {
720 720
 			//look for ones with no period
721
-			foreach( $includes as $field_to_include ) {
722
-				$field_to_include = trim( $field_to_include );
721
+			foreach ($includes as $field_to_include) {
722
+				$field_to_include = trim($field_to_include);
723 723
 				if (
724
-					strpos( $field_to_include, '.' ) === false
725
-					&& ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include )
724
+					strpos($field_to_include, '.') === false
725
+					&& ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include)
726 726
 				) {
727 727
 					$extracted_fields_to_include[] = $field_to_include;
728 728
 				}
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_Page.core.php 1 patch
Spacing   +405 added lines, -405 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
 /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			'espresso_events' => 'edit'
68 68
 			);
69 69
 
70
-		add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) );
70
+		add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit'));
71 71
 	}
72 72
 
73 73
 	protected function _ajax_hooks() {
@@ -93,20 +93,20 @@  discard block
 block discarded – undo
93 93
 				'edit' => __('Update Event', 'event_espresso'),
94 94
 				'add_category' => __('Save New Category', 'event_espresso'),
95 95
 				'edit_category' => __('Update Category', 'event_espresso'),
96
-				'template_settings' => __( 'Update Settings', 'event_espresso' )
96
+				'template_settings' => __('Update Settings', 'event_espresso')
97 97
 				)
98 98
 		);
99 99
 	}
100 100
 
101 101
 	protected function _set_page_routes() {
102 102
 		//load formatter helper
103
-		EE_Registry::instance()->load_helper( 'Formatter' );
103
+		EE_Registry::instance()->load_helper('Formatter');
104 104
 		//load field generator helper
105
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
105
+		EE_Registry::instance()->load_helper('Form_Fields');
106 106
 
107 107
 		//is there a evt_id in the request?
108
-		$evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0;
109
-		$evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id;
108
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0;
109
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
110 110
 
111 111
 
112 112
 		$this->_page_routes = array(
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 				'help_tour' => array(
321 321
 					'Event_Editor_Help_Tour'
322 322
 					),
323
-				'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ),
323
+				'qtips' => array('EE_Event_Editor_Decaf_Tips'),
324 324
 				'require_nonce' => FALSE
325 325
 			),
326 326
 			'edit' => array(
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 				'help_tour' => array(
377 377
 					'Event_Edit_Help_Tour'
378 378
 				),
379
-				'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ),
379
+				'qtips' => array('EE_Event_Editor_Decaf_Tips'),
380 380
 				'require_nonce' => FALSE
381 381
 			),
382 382
 			'default_event_settings' => array(
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 						'filename' => 'events_default_settings_status'
399 399
 					)
400 400
 				),
401
-				'help_tour' => array( 'Event_Default_Settings_Help_Tour'),
401
+				'help_tour' => array('Event_Default_Settings_Help_Tour'),
402 402
 				'require_nonce' => FALSE
403 403
 			),
404 404
 			//template settings
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 						'filename' => 'general_settings_templates'
415 415
 					)
416 416
 				),
417
-				'help_tour' => array( 'Templates_Help_Tour' ),
417
+				'help_tour' => array('Templates_Help_Tour'),
418 418
 				'require_nonce' => FALSE
419 419
 			),
420 420
 			//event category stuff
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 					'label' => __('Edit Category', 'event_espresso'),
439 439
 					'order' => 15,
440 440
 					'persistent' => FALSE,
441
-					'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url
441
+					'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url
442 442
 					),
443 443
 				'help_tabs' => array(
444 444
 					'edit_category_help_tab' => array(
@@ -508,14 +508,14 @@  discard block
 block discarded – undo
508 508
 
509 509
 	public function load_scripts_styles() {
510 510
 
511
-		wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
512
-		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION );
511
+		wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
512
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
513 513
 		wp_enqueue_style('events-admin-css');
514 514
 		wp_enqueue_style('ee-cat-admin');
515 515
 		//todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
516 516
 		//registers for all views
517 517
 		//scripts
518
-		wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE);
518
+		wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE);
519 519
 	}
520 520
 
521 521
 	/**
@@ -533,11 +533,11 @@  discard block
 block discarded – undo
533 533
 	public function load_scripts_styles_edit() {
534 534
 		//styles
535 535
 		wp_enqueue_style('espresso-ui-theme');
536
-		wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
536
+		wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
537 537
 		wp_enqueue_style('event-editor-css');
538 538
 
539 539
 		//scripts
540
-		wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION );
540
+		wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION);
541 541
 		wp_enqueue_script('event-datetime-metabox');
542 542
 
543 543
 	}
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
 
574 574
 	public function admin_init() {
575
-		EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' );
575
+		EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso');
576 576
 	}
577 577
 
578 578
 
@@ -593,45 +593,45 @@  discard block
 block discarded – undo
593 593
 	 */
594 594
 	public function verify_event_edit($event = NULL) {
595 595
 		// no event?
596
-		if ( empty( $event )) {
596
+		if (empty($event)) {
597 597
 			// set event
598 598
 			$event = $this->_cpt_model_obj;
599 599
 		}
600 600
 		// STILL no event?
601
-		if ( empty ( $event )) {
601
+		if (empty ($event)) {
602 602
 			return;
603 603
 		}
604 604
 		// first check if event is active.
605
-		if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) {
605
+		if ($event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed) {
606 606
 			return;
607 607
 		}
608 608
 		$orig_status = $event->status();
609 609
 		//made it here so it IS active... next check that any of the tickets are sold.
610
-		if ( $event->is_sold_out( true ) ) {
611
-			if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out  ) {
610
+		if ($event->is_sold_out(true)) {
611
+			if ($event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out) {
612 612
 				EE_Error::add_attention(
613 613
 					sprintf(
614
-						__( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.', 'event_espresso' ),
615
-						EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' )
614
+						__('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.', 'event_espresso'),
615
+						EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence')
616 616
 					)
617 617
 				);
618 618
 			}
619 619
 			return;
620
-		} else if ( $orig_status === EEM_Event::sold_out ) {
620
+		} else if ($orig_status === EEM_Event::sold_out) {
621 621
 			EE_Error::add_attention(
622 622
 				sprintf(
623
-					__( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
624
-						'event_espresso' ),
625
-					EEH_Template::pretty_status( $event->status(), false, 'sentence' )
623
+					__('Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
624
+						'event_espresso'),
625
+					EEH_Template::pretty_status($event->status(), false, 'sentence')
626 626
 				)
627 627
 			);
628 628
 		}
629 629
 		//now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
630
-		if ( ! $event->tickets_on_sale() ) {
630
+		if ( ! $event->tickets_on_sale()) {
631 631
 			return;
632 632
 		}
633 633
 		//made it here so show warning
634
-		EE_Error::add_attention( $this->_edit_event_warning() );
634
+		EE_Error::add_attention($this->_edit_event_warning());
635 635
 	}
636 636
 
637 637
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 			),
672 672
 		);
673 673
 
674
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) {
674
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
675 675
 			$this->_views['trash'] = array(
676 676
 				'slug' => 'trash',
677 677
 				'label' => __('Trash', 'event_espresso'),
@@ -701,39 +701,39 @@  discard block
 block discarded – undo
701 701
 				'desc' => __('View Registrations for Event', 'event_espresso')
702 702
 			)
703 703
 		);
704
-		$items  = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items );
704
+		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
705 705
 		$statuses = array(
706 706
 			'sold_out_status' => array(
707
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
708
-				'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' )
707
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out,
708
+				'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence')
709 709
 			),
710 710
 			'active_status' => array(
711
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
712
-				'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' )
711
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active,
712
+				'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence')
713 713
 			),
714 714
 			'upcoming_status' => array(
715
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
716
-				'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' )
715
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming,
716
+				'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence')
717 717
 			),
718 718
 			'postponed_status' => array(
719
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
720
-				'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' )
719
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed,
720
+				'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence')
721 721
 			),
722 722
 			'cancelled_status' => array(
723
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
724
-				'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' )
723
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled,
724
+				'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence')
725 725
 			),
726 726
 			'expired_status' => array(
727
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
728
-				'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' )
727
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired,
728
+				'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence')
729 729
 			),
730 730
 			'inactive_status' => array(
731
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
732
-				'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' )
731
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive,
732
+				'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence')
733 733
 			)
734 734
 		);
735
-		$statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses );
736
-		return array_merge( $items, $statuses );
735
+		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
736
+		return array_merge($items, $statuses);
737 737
 	}
738 738
 
739 739
 
@@ -745,8 +745,8 @@  discard block
 block discarded – undo
745 745
 	 * @return EEM_Event
746 746
 	 */
747 747
 	private function _event_model() {
748
-		if ( ! $this->_event_model instanceof EEM_Event ) {
749
-			$this->_event_model = EE_Registry::instance()->load_model( 'Event' );
748
+		if ( ! $this->_event_model instanceof EEM_Event) {
749
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
750 750
 		}
751 751
 		return $this->_event_model;
752 752
 	}
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
 	 * @param  string $new_slug  what the slug is
766 766
 	 * @return string            The new html string for the permalink area
767 767
 	 */
768
-	public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) {
768
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) {
769 769
 		//make sure this is only when editing
770
-		if ( !empty( $id ) ) {
771
-			$post = get_post( $id );
772
-			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> ';
773
-			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\'' . $post->ID . '\']"">';
770
+		if ( ! empty($id)) {
771
+			$post = get_post($id);
772
+			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> ';
773
+			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\''.$post->ID.'\']"">';
774 774
 		}
775 775
 		return $return;
776 776
 	}
@@ -786,8 +786,8 @@  discard block
 block discarded – undo
786 786
 	 * @return string html for generated table
787 787
 	 */
788 788
 	protected function _events_overview_list_table() {
789
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
790
-		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) .
789
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
790
+		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button').
791 791
 		$this->_display_legend($this->_event_legend_items());
792 792
 		$this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2');
793 793
 		$this->display_admin_list_table_page_with_no_sidebar();
@@ -805,51 +805,51 @@  discard block
 block discarded – undo
805 805
 
806 806
 
807 807
 
808
-	protected function _insert_update_cpt_item( $post_id, $post ) {
808
+	protected function _insert_update_cpt_item($post_id, $post) {
809 809
 
810
-		if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) {
810
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
811 811
 			//getout we're not processing an event save.
812 812
 			return;
813 813
 		}
814 814
 
815 815
 		$event_values = array(
816
-			'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0,
817
-			'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0,
816
+			'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0,
817
+			'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
818 818
 			'EVT_additional_limit' => min(
819
-					apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ),
820
-					!empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ),
821
-			'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID,
822
-			'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0,
823
-			'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0,
824
-			'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL,
825
-			'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL,
826
-			'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL
819
+					apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
820
+					! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ),
821
+			'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID,
822
+			'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0,
823
+			'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
824
+			'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL,
825
+			'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL,
826
+			'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL
827 827
 			);
828 828
 
829 829
 		//update event
830
-		$success = $this->_event_model()->update_by_ID( $event_values, $post_id );
830
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
831 831
 
832 832
 
833 833
 		//get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
834
-		$get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status );
835
-		$event = $this->_event_model()->get_one( array($get_one_where) );
834
+		$get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status);
835
+		$event = $this->_event_model()->get_one(array($get_one_where));
836 836
 
837 837
 
838 838
 		//the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
839
-		$event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) );
839
+		$event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')));
840 840
 
841 841
 		$att_success = TRUE;
842 842
 
843
-		foreach ( $event_update_callbacks as $e_callback ) {
844
-			$_succ = call_user_func_array( $e_callback, array( $event,  $this->_req_data ) );
845
-			$att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message
843
+		foreach ($event_update_callbacks as $e_callback) {
844
+			$_succ = call_user_func_array($e_callback, array($event, $this->_req_data));
845
+			$att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message
846 846
 		}
847 847
 
848 848
 		//any errors?
849
-		if ( $success && FALSE === $att_success ) {
850
-			EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
851
-		} else if ( $success === FALSE ) {
852
-			EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
849
+		if ($success && FALSE === $att_success) {
850
+			EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
851
+		} else if ($success === FALSE) {
852
+			EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
853 853
 		}
854 854
 	}
855 855
 
@@ -859,14 +859,14 @@  discard block
 block discarded – undo
859 859
 	/**
860 860
 	 * @see parent::restore_item()
861 861
 	 */
862
-	protected function _restore_cpt_item( $post_id, $revision_id ) {
862
+	protected function _restore_cpt_item($post_id, $revision_id) {
863 863
 		//copy existing event meta to new post
864 864
 		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
865
-		if ( $post_evt instanceof EE_Event ) {
865
+		if ($post_evt instanceof EE_Event) {
866 866
 			//meta revision restore
867
-			$post_evt->restore_revision( $revision_id );
867
+			$post_evt->restore_revision($revision_id);
868 868
 			//related objs restore
869
-			$post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) );
869
+			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
870 870
 		}
871 871
 	}
872 872
 
@@ -879,52 +879,52 @@  discard block
 block discarded – undo
879 879
 	 * @param  array  $data   The request data from the form
880 880
 	 * @return bool           Success or fail.
881 881
 	 */
882
-	protected function _default_venue_update( $evtobj, $data ) {
883
-		require_once( EE_MODELS . 'EEM_Venue.model.php' );
882
+	protected function _default_venue_update($evtobj, $data) {
883
+		require_once(EE_MODELS.'EEM_Venue.model.php');
884 884
 		$venue_model = EE_Registry::instance()->load_model('Venue');
885 885
 		$rows_affected = NULL;
886
-		$venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL;
886
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL;
887 887
 
888 888
 		// very important.  If we don't have a venue name...
889 889
 		// then we'll get out because not necessary to create empty venue
890
-		if ( empty( $data['venue_title'] ) ) {
890
+		if (empty($data['venue_title'])) {
891 891
 			return false;
892 892
 		}
893 893
 
894 894
 		$venue_array = array(
895 895
 				'VNU_wp_user' => $evtobj->get('EVT_wp_user'),
896
-				'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL,
897
-				'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL,
898
-				'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL,
899
-				'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL,
900
-				'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL,
901
-				'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL,
902
-				'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL,
903
-				'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL,
904
-				'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL,
905
-				'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL,
906
-				'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL,
907
-				'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL,
908
-				'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL,
909
-				'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL,
910
-				'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL,
911
-				'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0,
896
+				'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL,
897
+				'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL,
898
+				'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL,
899
+				'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL,
900
+				'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL,
901
+				'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL,
902
+				'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL,
903
+				'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL,
904
+				'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL,
905
+				'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL,
906
+				'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL,
907
+				'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL,
908
+				'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL,
909
+				'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL,
910
+				'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL,
911
+				'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
912 912
 				'status' => 'publish'
913 913
 			);
914 914
 
915 915
 
916 916
 		//if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
917
-		if ( !empty( $venue_id ) ) {
918
-			$update_where = array( $venue_model->primary_key_name() => $venue_id );
919
-			$rows_affected = $venue_model->update( $venue_array, array( $update_where ) );
917
+		if ( ! empty($venue_id)) {
918
+			$update_where = array($venue_model->primary_key_name() => $venue_id);
919
+			$rows_affected = $venue_model->update($venue_array, array($update_where));
920 920
 			//we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
921
-			$evtobj->_add_relation_to( $venue_id, 'Venue' );
921
+			$evtobj->_add_relation_to($venue_id, 'Venue');
922 922
 			return $rows_affected > 0 ? TRUE : FALSE;
923 923
 		} else {
924 924
 			//we insert the venue
925
-			$venue_id = $venue_model->insert( $venue_array );
926
-			$evtobj->_add_relation_to( $venue_id, 'Venue' );
927
-			return !empty( $venue_id ) ? TRUE : FALSE;
925
+			$venue_id = $venue_model->insert($venue_array);
926
+			$evtobj->_add_relation_to($venue_id, 'Venue');
927
+			return ! empty($venue_id) ? TRUE : FALSE;
928 928
 		}
929 929
 		//when we have the ancestor come in it's already been handled by the revision save.
930 930
 	}
@@ -938,55 +938,55 @@  discard block
 block discarded – undo
938 938
 	 * @param  array    $data   The request data from the form
939 939
 	 * @return bool             success or fail
940 940
 	 */
941
-	protected function _default_tickets_update( EE_Event $evtobj, $data ) {
941
+	protected function _default_tickets_update(EE_Event $evtobj, $data) {
942 942
 		$success = true;
943 943
 		$saved_dtt = null;
944 944
 		$saved_tickets = array();
945
-		$incoming_date_formats = array( 'Y-m-d', 'h:i a' );
945
+		$incoming_date_formats = array('Y-m-d', 'h:i a');
946 946
 
947
-		foreach ( $data['edit_event_datetimes'] as $row => $dtt ) {
947
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
948 948
 			//trim all values to ensure any excess whitespace is removed.
949
-			$dtt =  array_map( 'trim', $dtt );
950
-			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
949
+			$dtt = array_map('trim', $dtt);
950
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
951 951
 			$datetime_values = array(
952
-				'DTT_ID' 		=> ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL,
952
+				'DTT_ID' 		=> ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL,
953 953
 				'DTT_EVT_start' => $dtt['DTT_EVT_start'],
954 954
 				'DTT_EVT_end' 	=> $dtt['DTT_EVT_end'],
955
-				'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'],
955
+				'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
956 956
 				'DTT_order' 	=> $row,
957 957
 			);
958 958
 
959 959
 			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
960 960
 
961
-			if ( !empty( $dtt['DTT_ID'] ) ) {
962
-				$DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] );
963
-				$DTM->set_date_format( $incoming_date_formats[0] );
964
-				$DTM->set_time_format( $incoming_date_formats[1] );
965
-				foreach ( $datetime_values as $field => $value ) {
966
-					$DTM->set( $field, $value );
961
+			if ( ! empty($dtt['DTT_ID'])) {
962
+				$DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']);
963
+				$DTM->set_date_format($incoming_date_formats[0]);
964
+				$DTM->set_time_format($incoming_date_formats[1]);
965
+				foreach ($datetime_values as $field => $value) {
966
+					$DTM->set($field, $value);
967 967
 				}
968 968
 
969 969
 				//make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
970 970
 				$saved_dtts[$DTM->ID()] = $DTM;
971 971
 			} else {
972
-				$DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE );
973
-				$DTM->set_date_format( $incoming_date_formats[0] );
974
-				$DTM->set_time_format( $incoming_date_formats[1] );
975
-				$DTM->set_timezone( $evtobj->get_timezone() );
976
-				foreach ( $datetime_values as $field => $value ) {
977
-					$DTM->set( $field, $value );
972
+				$DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE);
973
+				$DTM->set_date_format($incoming_date_formats[0]);
974
+				$DTM->set_time_format($incoming_date_formats[1]);
975
+				$DTM->set_timezone($evtobj->get_timezone());
976
+				foreach ($datetime_values as $field => $value) {
977
+					$DTM->set($field, $value);
978 978
 				}
979 979
 			}
980 980
 			$DTM->save();
981 981
 
982
-			$DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' );
982
+			$DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
983 983
 
984 984
 			//load DTT helper
985 985
 			EE_Registry::instance()->load_helper('DTT_Helper');
986 986
 
987 987
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
988
-			if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) {
989
-				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') );
988
+			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
989
+				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
990 990
 				$DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
991 991
 				$DTT->save();
992 992
 			}
@@ -994,45 +994,45 @@  discard block
 block discarded – undo
994 994
 			//now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
995 995
 			$saved_dtt = $DTT;
996 996
 
997
-			$success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now.
997
+			$success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now.
998 998
 		}
999 999
 
1000 1000
 		//no dtts get deleted so we don't do any of that logic here.
1001 1001
 		//update tickets next
1002
-		$old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array();
1003
-		foreach ( $data['edit_tickets'] as $row => $tkt ) {
1004
-			$incoming_date_formats = array( 'Y-m-d', 'h:i a' );
1002
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1003
+		foreach ($data['edit_tickets'] as $row => $tkt) {
1004
+			$incoming_date_formats = array('Y-m-d', 'h:i a');
1005 1005
 			$update_prices = false;
1006
-			$ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1006
+			$ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1007 1007
 
1008 1008
 			// trim inputs to ensure any excess whitespace is removed.
1009
-			$tkt = array_map( 'trim', $tkt );
1009
+			$tkt = array_map('trim', $tkt);
1010 1010
 
1011
-			if ( empty( $tkt['TKT_start_date'] ) ) {
1011
+			if (empty($tkt['TKT_start_date'])) {
1012 1012
 				//let's use now in the set timezone.
1013
-				$now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) );
1014
-				$tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] );
1013
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1014
+				$tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]);
1015 1015
 			}
1016 1016
 
1017
-			if ( empty( $tkt['TKT_end_date'] ) ) {
1017
+			if (empty($tkt['TKT_end_date'])) {
1018 1018
 				//use the start date of the first datetime
1019 1019
 				$dtt = $evtobj->first_datetime();
1020
-				$tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] );
1020
+				$tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]);
1021 1021
 			}
1022 1022
 
1023 1023
 			$TKT_values = array(
1024
-				'TKT_ID' 			=> !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL,
1025
-				'TTM_ID' 			=> !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0,
1026
-				'TKT_name' 			=> !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '',
1027
-				'TKT_description' 	=> !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '',
1024
+				'TKT_ID' 			=> ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL,
1025
+				'TTM_ID' 			=> ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1026
+				'TKT_name' 			=> ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1027
+				'TKT_description' 	=> ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1028 1028
 				'TKT_start_date' 	=> $tkt['TKT_start_date'],
1029 1029
 				'TKT_end_date' 		=> $tkt['TKT_end_date'],
1030
-				'TKT_qty' 			=> ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'],
1031
-				'TKT_uses' 			=> ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ],
1032
-				'TKT_min' 			=> empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'],
1033
-				'TKT_max' 			=> empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'],
1030
+				'TKT_qty' 			=> ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1031
+				'TKT_uses' 			=> ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1032
+				'TKT_min' 			=> empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1033
+				'TKT_max' 			=> empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1034 1034
 				'TKT_row' 			=> $row,
1035
-				'TKT_order' 		=> isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row,
1035
+				'TKT_order' 		=> isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1036 1036
 				'TKT_price' 		=> $ticket_price
1037 1037
 			);
1038 1038
 
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 
1041 1041
 
1042 1042
 			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1043
-			if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) {
1043
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1044 1044
 				$TKT_values['TKT_ID'] = 0;
1045 1045
 				$TKT_values['TKT_is_default'] = 0;
1046 1046
 				$TKT_values['TKT_price'] = $ticket_price;
@@ -1051,58 +1051,58 @@  discard block
 block discarded – undo
1051 1051
 			//we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1052 1052
 			//keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1053 1053
 
1054
-			if ( !empty( $tkt['TKT_ID'] ) ) {
1055
-				$TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] );
1056
-				if ( $TKT instanceof EE_Ticket ) {
1057
-					$ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false;
1054
+			if ( ! empty($tkt['TKT_ID'])) {
1055
+				$TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']);
1056
+				if ($TKT instanceof EE_Ticket) {
1057
+					$ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false;
1058 1058
 					//let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1059
-					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false;
1060
-					$TKT->set_date_format( $incoming_date_formats[ 0 ] );
1061
-					$TKT->set_time_format( $incoming_date_formats[ 1 ] );
1059
+					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false;
1060
+					$TKT->set_date_format($incoming_date_formats[0]);
1061
+					$TKT->set_time_format($incoming_date_formats[1]);
1062 1062
 					//set new values
1063
-					foreach ( $TKT_values as $field => $value ) {
1064
-						if ( $field == 'TKT_qty' ) {
1065
-							$TKT->set_qty( $value );
1063
+					foreach ($TKT_values as $field => $value) {
1064
+						if ($field == 'TKT_qty') {
1065
+							$TKT->set_qty($value);
1066 1066
 						} else {
1067
-							$TKT->set( $field, $value );
1067
+							$TKT->set($field, $value);
1068 1068
 						}
1069 1069
 					}
1070 1070
 					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1071
-					if ( $create_new_TKT ) {
1071
+					if ($create_new_TKT) {
1072 1072
 						//archive the old ticket first
1073
-						$TKT->set( 'TKT_deleted', 1 );
1073
+						$TKT->set('TKT_deleted', 1);
1074 1074
 						$TKT->save();
1075 1075
 						//make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1076
-						$saved_tickets[ $TKT->ID() ] = $TKT;
1076
+						$saved_tickets[$TKT->ID()] = $TKT;
1077 1077
 						//create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1078 1078
 						$TKT = clone $TKT;
1079
-						$TKT->set( 'TKT_ID', 0 );
1080
-						$TKT->set( 'TKT_deleted', 0 );
1081
-						$TKT->set( 'TKT_price', $ticket_price );
1082
-						$TKT->set( 'TKT_sold', 0 );
1079
+						$TKT->set('TKT_ID', 0);
1080
+						$TKT->set('TKT_deleted', 0);
1081
+						$TKT->set('TKT_price', $ticket_price);
1082
+						$TKT->set('TKT_sold', 0);
1083 1083
 						//now we need to make sure that $new prices are created as well and attached to new ticket.
1084 1084
 						$update_prices = true;
1085 1085
 					}
1086 1086
 					//make sure price is set if it hasn't been already
1087
-					$TKT->set( 'TKT_price', $ticket_price );
1087
+					$TKT->set('TKT_price', $ticket_price);
1088 1088
 				}
1089 1089
 
1090 1090
 			} else {
1091 1091
 				//no TKT_id so a new TKT
1092 1092
 				$TKT_values['TKT_price'] = $ticket_price;
1093
-				$TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE );
1094
-				if ( $TKT instanceof EE_Ticket ) {
1093
+				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE);
1094
+				if ($TKT instanceof EE_Ticket) {
1095 1095
 					//need to reset values to properly account for the date formats
1096
-					$TKT->set_date_format( $incoming_date_formats[0] );
1097
-					$TKT->set_time_format( $incoming_date_formats[1] );
1098
-					$TKT->set_timezone( $evtobj->get_timezone() );
1096
+					$TKT->set_date_format($incoming_date_formats[0]);
1097
+					$TKT->set_time_format($incoming_date_formats[1]);
1098
+					$TKT->set_timezone($evtobj->get_timezone());
1099 1099
 
1100 1100
 					//set new values
1101
-					foreach ( $TKT_values as $field => $value ) {
1102
-						if ( $field == 'TKT_qty' ) {
1103
-							$TKT->set_qty( $value );
1101
+					foreach ($TKT_values as $field => $value) {
1102
+						if ($field == 'TKT_qty') {
1103
+							$TKT->set_qty($value);
1104 1104
 						} else {
1105
-							$TKT->set( $field, $value );
1105
+							$TKT->set($field, $value);
1106 1106
 						}
1107 1107
 					}
1108 1108
 
@@ -1110,32 +1110,32 @@  discard block
 block discarded – undo
1110 1110
 				}
1111 1111
 			}
1112 1112
 			// cap ticket qty by datetime reg limits
1113
-			$TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) );
1113
+			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1114 1114
 			//update ticket.
1115 1115
 			$TKT->save();
1116 1116
 
1117 1117
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1118
-			if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) {
1119
-				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date') );
1118
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1119
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1120 1120
 				EE_Registry::instance()->load_helper('DTT_Helper');
1121 1121
 				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1122 1122
 				$TKT->save();
1123 1123
 			}
1124 1124
 
1125 1125
 			//initially let's add the ticket to the dtt
1126
-			$saved_dtt->_add_relation_to( $TKT, 'Ticket' );
1126
+			$saved_dtt->_add_relation_to($TKT, 'Ticket');
1127 1127
 
1128 1128
 			$saved_tickets[$TKT->ID()] = $TKT;
1129 1129
 
1130 1130
 			//add prices to ticket
1131
-			$this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices );
1131
+			$this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1132 1132
 		}
1133 1133
 		//however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1134
-		$old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets;
1135
-		$tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) );
1134
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1135
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1136 1136
 
1137
-		foreach ( $tickets_removed as $id ) {
1138
-			$id = absint( $id );
1137
+		foreach ($tickets_removed as $id) {
1138
+			$id = absint($id);
1139 1139
 
1140 1140
 			//get the ticket for this id
1141 1141
 			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 			//need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1144 1144
 			$dtts = $tkt_to_remove->get_many_related('Datetime');
1145 1145
 
1146
-			foreach( $dtts as $dtt ) {
1146
+			foreach ($dtts as $dtt) {
1147 1147
 				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1148 1148
 			}
1149 1149
 
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 			//finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1155 1155
 			$tkt_to_remove->delete_permanently();
1156 1156
 		}
1157
-		return array( $saved_dtt, $saved_tickets );
1157
+		return array($saved_dtt, $saved_tickets);
1158 1158
 	}
1159 1159
 
1160 1160
 
@@ -1169,31 +1169,31 @@  discard block
 block discarded – undo
1169 1169
 	 * @param bool 		$new_prices Whether attach existing incoming prices or create new ones.
1170 1170
 	 * @return  void
1171 1171
 	 */
1172
-	private function  _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) {
1173
-		foreach ( $prices as $row => $prc ) {
1172
+	private function  _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) {
1173
+		foreach ($prices as $row => $prc) {
1174 1174
 			$PRC_values = array(
1175
-				'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL,
1176
-				'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL,
1177
-				'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0,
1178
-				'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '',
1179
-				'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '',
1175
+				'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL,
1176
+				'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL,
1177
+				'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1178
+				'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1179
+				'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1180 1180
 				'PRC_is_default' => 0, //make sure prices are NOT set as default from this context
1181 1181
 				'PRC_order' => $row
1182 1182
 			);
1183 1183
 
1184
-			if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) {
1184
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
1185 1185
 				$PRC_values['PRC_ID'] = 0;
1186
-				$PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE);
1186
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE);
1187 1187
 			} else {
1188
-				$PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] );
1188
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1189 1189
 				//update this price with new values
1190
-				foreach ( $PRC_values as $field => $newprc ) {
1191
-					$PRC->set( $field, $newprc );
1190
+				foreach ($PRC_values as $field => $newprc) {
1191
+					$PRC->set($field, $newprc);
1192 1192
 				}
1193 1193
 				$PRC->save();
1194 1194
 			}
1195 1195
 
1196
-			$ticket->_add_relation_to( $PRC, 'Price' );
1196
+			$ticket->_add_relation_to($PRC, 'Price');
1197 1197
 		}
1198 1198
 	}
1199 1199
 
@@ -1216,33 +1216,33 @@  discard block
 block discarded – undo
1216 1216
 
1217 1217
 		return; //TEMPORARILY EXITING CAUSE THIS IS A TODO
1218 1218
 
1219
-		$postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL;
1219
+		$postid = isset($this->_req_data['post_ID']) ? $this->_req_data['post_ID'] : NULL;
1220 1220
 
1221 1221
 
1222 1222
 		//if no postid then get out cause we need it for stuff in here
1223
-		if ( empty( $postid ) ) return;
1223
+		if (empty($postid)) return;
1224 1224
 
1225 1225
 
1226 1226
 		//handle datetime saves
1227 1227
 		$items = array();
1228 1228
 
1229
-		$get_one_where = array( $this->_event_model()->primary_key_name() => $postid );
1230
-		$event = $this->_event_model()->get_one( array($get_one_where) );
1229
+		$get_one_where = array($this->_event_model()->primary_key_name() => $postid);
1230
+		$event = $this->_event_model()->get_one(array($get_one_where));
1231 1231
 
1232 1232
 		//now let's get the attached datetimes from the most recent autosave
1233 1233
 		$dtts = $event->get_many_related('Datetime');
1234 1234
 
1235 1235
 		$dtt_ids = array();
1236
-		foreach( $dtts as $dtt ) {
1236
+		foreach ($dtts as $dtt) {
1237 1237
 			$dtt_ids[] = $dtt->ID();
1238 1238
 			$order = $dtt->order();
1239 1239
 			$this->_template_args['data']['items']['ID-'.$order] = $dtt->ID();
1240 1240
 		}
1241
-		$this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids );
1241
+		$this->_template_args['data']['items']['datetime_IDS'] = serialize($dtt_ids);
1242 1242
 
1243 1243
 		//handle DECAF venues
1244 1244
 		//we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event.
1245
-		if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) {
1245
+		if ($do_venue_autosaves = apply_filters('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE)) {
1246 1246
 			$venue = $event->get_first_related('Venue');
1247 1247
 			$this->_template_args['data']['items']['venue-id'] = $venue->ID();
1248 1248
 		}
@@ -1253,23 +1253,23 @@  discard block
 block discarded – undo
1253 1253
 
1254 1254
 		$ticket_ids = array();
1255 1255
 		$price_ids = array();
1256
-		foreach ( $tickets as $ticket ) {
1256
+		foreach ($tickets as $ticket) {
1257 1257
 			$ticket_ids[] = $price->ID();
1258 1258
 			$ticket_order = $price->get('TKT_order');
1259
-			$this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID();
1260
-			$this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID();
1259
+			$this->_template_args['data']['items']['edit-ticket-id-'.$ticket_order] = $ticket->ID();
1260
+			$this->_template_args['data']['items']['edit-ticket-event-id-'.$order] = $event->ID();
1261 1261
 
1262 1262
 			//now we have to make sure the prices are updated appropriately
1263 1263
 			$prices = $ticket->get_many_related('Prices');
1264 1264
 
1265
-			foreach ( $prices as $price ) {
1265
+			foreach ($prices as $price) {
1266 1266
 				$price_ids[] = $price->ID();
1267 1267
 				$price_order = $price->get('PRC_order');
1268
-				$this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID();
1269
-				$this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID();
1270
-				$this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default');
1268
+				$this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-'.$ticket_order.'-'.$price_order] = $price->ID();
1269
+				$this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-'.$ticket_row.'-'.$price_row] = $price->ID();
1270
+				$this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-'.$ticket_row.'-'.$price_row] = $price->get('PRC_is_default');
1271 1271
 			}
1272
-			$this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids);
1272
+			$this->_template_args['data']['items']['price-IDs-ticketrow-'.$ticket_row] = implode(',', $price_ids);
1273 1273
 		}
1274 1274
 		$this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids);
1275 1275
 	}
@@ -1287,12 +1287,12 @@  discard block
 block discarded – undo
1287 1287
 	private function _generate_publish_box_extra_content() {
1288 1288
 
1289 1289
 		//load formatter helper
1290
-  		EE_Registry::instance()->load_helper( 'Formatter' );
1290
+  		EE_Registry::instance()->load_helper('Formatter');
1291 1291
 
1292 1292
   		//args for getting related registrations
1293
-  		$approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) );
1294
-  		$not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) );
1295
-  		$pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) );
1293
+  		$approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved));
1294
+  		$not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved));
1295
+  		$pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment));
1296 1296
 
1297 1297
 
1298 1298
 		// publish box
@@ -1321,9 +1321,9 @@  discard block
 block discarded – undo
1321 1321
 				),
1322 1322
 				REG_ADMIN_URL
1323 1323
 			),
1324
-			'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ),
1325
-			'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ),
1326
-			'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ),
1324
+			'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args),
1325
+			'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args),
1326
+			'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args),
1327 1327
 			'misc_pub_section_class' => apply_filters(
1328 1328
 				'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1329 1329
 				'misc-pub-section'
@@ -1342,9 +1342,9 @@  discard block
 block discarded – undo
1342 1342
 			'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1343 1343
 			$this->_cpt_model_obj
1344 1344
 		);
1345
-		$publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean();
1345
+		$publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1346 1346
 		// load template
1347
-		EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args );
1347
+		EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args);
1348 1348
 	}
1349 1349
 
1350 1350
 
@@ -1376,16 +1376,16 @@  discard block
 block discarded – undo
1376 1376
 		$this->verify_cpt_object();
1377 1377
 		add_meta_box(
1378 1378
 			'espresso_event_editor_tickets',
1379
-			__( 'Event Datetime & Ticket', 'event_espresso' ),
1380
-			array( $this, 'ticket_metabox' ),
1379
+			__('Event Datetime & Ticket', 'event_espresso'),
1380
+			array($this, 'ticket_metabox'),
1381 1381
 			$this->page_slug,
1382 1382
 			'normal',
1383 1383
 			'high'
1384 1384
 		);
1385 1385
 		add_meta_box(
1386 1386
 			'espresso_event_editor_event_options',
1387
-			__( 'Event Registration Options', 'event_espresso' ),
1388
-			array( $this, 'registration_options_meta_box' ),
1387
+			__('Event Registration Options', 'event_espresso'),
1388
+			array($this, 'registration_options_meta_box'),
1389 1389
 			$this->page_slug,
1390 1390
 			'side',
1391 1391
 			'default'
@@ -1415,38 +1415,38 @@  discard block
 block discarded – undo
1415 1415
 			'disabled' => ''
1416 1416
 			);
1417 1417
 
1418
-		$event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL;
1418
+		$event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL;
1419 1419
 
1420
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1420
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1421 1421
 
1422 1422
 		/**
1423 1423
 		 * 1. Start with retrieving Datetimes
1424 1424
 		 * 2. Fore each datetime get related tickets
1425 1425
 		 * 3. For each ticket get related prices
1426 1426
 		 */
1427
-		$times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id );
1428
-		EE_Registry::instance()->load_helper('DTT_Helper' );
1427
+		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1428
+		EE_Registry::instance()->load_helper('DTT_Helper');
1429 1429
 		/** @type EE_Datetime $first_datetime */
1430
-		$first_datetime = array_slice( $times, 0, 1 );
1430
+		$first_datetime = array_slice($times, 0, 1);
1431 1431
 		//do we get related tickets?
1432
-		if ( $first_datetime[ 0 ]->get( 'DTT_ID' ) !== 0 ) {
1433
-			foreach ( $times as $time ) {
1434
-				if ( $time instanceof EE_Datetime ) {
1432
+		if ($first_datetime[0]->get('DTT_ID') !== 0) {
1433
+			foreach ($times as $time) {
1434
+				if ($time instanceof EE_Datetime) {
1435 1435
 					$existing_datetime_ids[] = $time->get('DTT_ID');
1436 1436
 					$template_args['time'] = $time;
1437 1437
 					$related_tickets = $time->tickets(
1438 1438
 						array(
1439
-							array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ),
1439
+							array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1440 1440
 							'default_where_conditions' => 'none'
1441 1441
 						)
1442 1442
 					);
1443 1443
 
1444
-					if ( !empty($related_tickets) ) {
1444
+					if ( ! empty($related_tickets)) {
1445 1445
 						$template_args['total_ticket_rows'] = count($related_tickets);
1446 1446
 						$row = 0;
1447
-						foreach ( $related_tickets as $ticket ) {
1447
+						foreach ($related_tickets as $ticket) {
1448 1448
 							$existing_ticket_ids[] = $ticket->get('TKT_ID');
1449
-							$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row );
1449
+							$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row);
1450 1450
 
1451 1451
 							$row++;
1452 1452
 						}
@@ -1454,7 +1454,7 @@  discard block
 block discarded – undo
1454 1454
 						$template_args['total_ticket_rows'] = 1;
1455 1455
 						/** @type EE_Ticket $ticket */
1456 1456
 						$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1457
-						$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket );
1457
+						$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1458 1458
 					}
1459 1459
 				}
1460 1460
 			}
@@ -1462,7 +1462,7 @@  discard block
 block discarded – undo
1462 1462
 			$template_args['time'] = $times[0];
1463 1463
 			/** @type EE_Ticket $ticket */
1464 1464
 			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1465
-			$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] );
1465
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1466 1466
 			// NOTE: we're just sending the first default row
1467 1467
 			// (decaf can't manage default tickets so this should be sufficient);
1468 1468
 		}
@@ -1471,8 +1471,8 @@  discard block
 block discarded – undo
1471 1471
 		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1472 1472
 		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1473 1473
 		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1474
-		$template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE );
1475
-		$template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' );
1474
+		$template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE);
1475
+		$template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php');
1476 1476
 		EEH_Template::display_template($template, $template_args);
1477 1477
 	}
1478 1478
 
@@ -1487,21 +1487,21 @@  discard block
 block discarded – undo
1487 1487
 	 * @param int        $row
1488 1488
 	 * @return string generated html for the ticket row.
1489 1489
 	 */
1490
-	private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) {
1490
+	private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) {
1491 1491
 		$template_args = array(
1492
-			'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(),
1493
-			'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '',
1492
+			'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(),
1493
+			'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '',
1494 1494
 			'ticketrow' => $skeleton ? 'TICKETNUM' : $row,
1495 1495
 			'TKT_ID' => $ticket->get('TKT_ID'),
1496 1496
 			'TKT_name' => $ticket->get('TKT_name'),
1497 1497
 			'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1498 1498
 			'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1499 1499
 			'TKT_is_default' => $ticket->get('TKT_is_default'),
1500
-			'TKT_qty' => $ticket->get_pretty('TKT_qty','input'),
1500
+			'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'),
1501 1501
 			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1502 1502
 			'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'),
1503
-			'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1504
-			'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled'
1503
+			'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1504
+			'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled'
1505 1505
 			);
1506 1506
 
1507 1507
 		$price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object();
@@ -1517,23 +1517,23 @@  discard block
 block discarded – undo
1517 1517
 
1518 1518
 		//make sure we have default start and end dates if skeleton
1519 1519
 		//handle rows that should NOT be empty
1520
-		if ( empty( $template_args['TKT_start_date'] ) ) {
1520
+		if (empty($template_args['TKT_start_date'])) {
1521 1521
 			//if empty then the start date will be now.
1522 1522
 			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1523 1523
 		}
1524 1524
 
1525
-		if ( empty( $template_args['TKT_end_date'] ) ) {
1525
+		if (empty($template_args['TKT_end_date'])) {
1526 1526
 			//get the earliest datetime (if present);
1527
-			$earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL;
1527
+			$earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL;
1528 1528
 
1529
-			if ( !empty( $earliest_dtt ) )
1529
+			if ( ! empty($earliest_dtt))
1530 1530
 				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1531 1531
 			else
1532
-				$template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) );
1532
+				$template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")));
1533 1533
 		}
1534 1534
 
1535
-		$template_args = array_merge( $template_args, $price_args );
1536
-		$template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket);
1535
+		$template_args = array_merge($template_args, $price_args);
1536
+		$template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket);
1537 1537
 		return EEH_Template::display_template($template, $template_args, TRUE);
1538 1538
 	}
1539 1539
 
@@ -1562,8 +1562,8 @@  discard block
 block discarded – undo
1562 1562
 		$template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status());
1563 1563
 		$template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description());
1564 1564
 		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false);
1565
-		$template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values );
1566
-		$templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php';
1565
+		$template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values);
1566
+		$templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php';
1567 1567
 		EEH_Template::display_template($templatepath, $template_args);
1568 1568
 	}
1569 1569
 
@@ -1591,21 +1591,21 @@  discard block
 block discarded – undo
1591 1591
 		$EEME = $this->_event_model();
1592 1592
 
1593 1593
 		$offset = ($current_page - 1) * $per_page;
1594
-		$limit = $count ? NULL : $offset . ',' . $per_page;
1594
+		$limit = $count ? NULL : $offset.','.$per_page;
1595 1595
 		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1596 1596
 		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1597 1597
 
1598 1598
 		if (isset($this->_req_data['month_range'])) {
1599 1599
 			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1600
-			$month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1601
-			$year_r = !empty($pieces[1]) ? $pieces[1] : '';
1600
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1601
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1602 1602
 		}
1603 1603
 
1604 1604
 		$where = array();
1605 1605
 
1606
-		$status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL;
1606
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL;
1607 1607
 		//determine what post_status our condition will have for the query.
1608
-		switch ( $status ) {
1608
+		switch ($status) {
1609 1609
 			case 'month' :
1610 1610
 			case 'today' :
1611 1611
 			case NULL :
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 				break;
1614 1614
 
1615 1615
 			case 'draft' :
1616
-				$where['status'] = array( 'IN', array('draft', 'auto-draft') );
1616
+				$where['status'] = array('IN', array('draft', 'auto-draft'));
1617 1617
 				break;
1618 1618
 
1619 1619
 			default :
@@ -1621,43 +1621,43 @@  discard block
 block discarded – undo
1621 1621
 		}
1622 1622
 
1623 1623
 		//categories?
1624
-		$category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL;
1624
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL;
1625 1625
 
1626
-		if ( !empty ( $category ) ) {
1626
+		if ( ! empty ($category)) {
1627 1627
 			$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1628 1628
 			$where['Term_Taxonomy.term_id'] = $category;
1629 1629
 		}
1630 1630
 
1631 1631
 		//date where conditions
1632
-		$start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' );
1632
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1633 1633
 		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1634
-			$DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) );
1635
-			$start = $DateTime->format( implode( ' ', $start_formats  ) );
1636
-			$end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) );
1637
-			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) );
1634
+			$DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone()));
1635
+			$start = $DateTime->format(implode(' ', $start_formats));
1636
+			$end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1637
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1638 1638
 		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1639
-			$DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1640
-			$start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) );
1641
-			$end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) );
1642
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1643
-		} else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) {
1644
-			$now = date( 'Y-m-01' );
1645
-			$DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1646
-			$start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) );
1647
-			$end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) );
1648
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1639
+			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1640
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1641
+			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1642
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1643
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1644
+			$now = date('Y-m-01');
1645
+			$DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1646
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1647
+			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1648
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1649 1649
 		}
1650 1650
 
1651 1651
 
1652
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
1653
-			$where['EVT_wp_user'] =  get_current_user_id();
1652
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1653
+			$where['EVT_wp_user'] = get_current_user_id();
1654 1654
 		} else {
1655
-			if ( ! isset( $where['status'] ) ) {
1656
-				if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) {
1655
+			if ( ! isset($where['status'])) {
1656
+				if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1657 1657
 					$where['OR'] = array(
1658
-						'status*restrict_private' => array( '!=', 'private' ),
1658
+						'status*restrict_private' => array('!=', 'private'),
1659 1659
 						'AND' => array(
1660
-							'status*inclusive' => array( '=', 'private' ),
1660
+							'status*inclusive' => array('=', 'private'),
1661 1661
 							'EVT_wp_user' => get_current_user_id()
1662 1662
 						)
1663 1663
 					);
@@ -1665,16 +1665,16 @@  discard block
 block discarded – undo
1665 1665
 			}
1666 1666
 		}
1667 1667
 
1668
-		if ( isset( $this->_req_data['EVT_wp_user'] ) ) {
1669
-			if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
1668
+		if (isset($this->_req_data['EVT_wp_user'])) {
1669
+			if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1670 1670
 				$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1671 1671
 			}
1672 1672
 		}
1673 1673
 
1674 1674
 
1675 1675
 		//search query handling
1676
-		if ( isset( $this->_req_data['s'] ) ) {
1677
-			$search_string = '%' . $this->_req_data['s'] . '%';
1676
+		if (isset($this->_req_data['s'])) {
1677
+			$search_string = '%'.$this->_req_data['s'].'%';
1678 1678
 			$where['OR'] = array(
1679 1679
 				'EVT_name' => array('LIKE', $search_string),
1680 1680
 				'EVT_desc' => array('LIKE', $search_string),
@@ -1683,32 +1683,32 @@  discard block
 block discarded – undo
1683 1683
 		}
1684 1684
 
1685 1685
 
1686
-		$where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data );
1687
-		$query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data );
1686
+		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1687
+		$query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data);
1688 1688
 
1689 1689
 
1690 1690
 		//let's first check if we have special requests coming in.
1691
-		if ( isset( $this->_req_data['active_status'] ) ) {
1692
-			switch ( $this->_req_data['active_status'] ) {
1691
+		if (isset($this->_req_data['active_status'])) {
1692
+			switch ($this->_req_data['active_status']) {
1693 1693
 				case 'upcoming' :
1694
-					return $EEME->get_upcoming_events( $query_params, $count );
1694
+					return $EEME->get_upcoming_events($query_params, $count);
1695 1695
 					break;
1696 1696
 
1697 1697
 				case 'expired' :
1698
-					return $EEME->get_expired_events( $query_params, $count );
1698
+					return $EEME->get_expired_events($query_params, $count);
1699 1699
 					break;
1700 1700
 
1701 1701
 				case 'active' :
1702
-					return $EEME->get_active_events( $query_params, $count );
1702
+					return $EEME->get_active_events($query_params, $count);
1703 1703
 					break;
1704 1704
 
1705 1705
 				case 'inactive' :
1706
-					return $EEME->get_inactive_events( $query_params, $count );
1706
+					return $EEME->get_inactive_events($query_params, $count);
1707 1707
 					break;
1708 1708
 			}
1709 1709
 		}
1710 1710
 
1711
-		$events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params );
1711
+		$events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1712 1712
 
1713 1713
 		return $events;
1714 1714
 	}
@@ -1717,23 +1717,23 @@  discard block
 block discarded – undo
1717 1717
 
1718 1718
 
1719 1719
 	//handling for WordPress CPT actions (trash, restore, delete)
1720
-	public function trash_cpt_item( $post_id ) {
1720
+	public function trash_cpt_item($post_id) {
1721 1721
 		$this->_req_data['EVT_ID'] = $post_id;
1722
-		$this->_trash_or_restore_event( 'trash', FALSE );
1722
+		$this->_trash_or_restore_event('trash', FALSE);
1723 1723
 	}
1724 1724
 
1725 1725
 
1726 1726
 
1727 1727
 
1728
-	public function restore_cpt_item( $post_id ) {
1728
+	public function restore_cpt_item($post_id) {
1729 1729
 		$this->_req_data['EVT_ID'] = $post_id;
1730
-		$this->_trash_or_restore_event( 'draft', FALSE );
1730
+		$this->_trash_or_restore_event('draft', FALSE);
1731 1731
 	}
1732 1732
 
1733 1733
 
1734
-	public function delete_cpt_item( $post_id ) {
1734
+	public function delete_cpt_item($post_id) {
1735 1735
 		$this->_req_data['EVT_ID'] = $post_id;
1736
-		$this->_delete_event( FALSE );
1736
+		$this->_delete_event(FALSE);
1737 1737
 	}
1738 1738
 
1739 1739
 
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 	 * @param  string $event_status
1746 1746
 	 * @return void
1747 1747
 	 */
1748
-	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) {
1748
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) {
1749 1749
 		//determine the event id and set to array.
1750 1750
 		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE;
1751 1751
 		// loop thru events
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 			// clean status
1754 1754
 			$event_status = sanitize_key($event_status);
1755 1755
 			// grab status
1756
-			if (!empty($event_status)) {
1756
+			if ( ! empty($event_status)) {
1757 1757
 				$success = $this->_change_event_status($EVT_ID, $event_status);
1758 1758
 			} else {
1759 1759
 				$success = FALSE;
@@ -1767,7 +1767,7 @@  discard block
 block discarded – undo
1767 1767
 		}
1768 1768
 		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1769 1769
 
1770
-		if ( $redirect_after )
1770
+		if ($redirect_after)
1771 1771
 			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1772 1772
 	}
1773 1773
 
@@ -1782,7 +1782,7 @@  discard block
 block discarded – undo
1782 1782
 		// clean status
1783 1783
 		$event_status = sanitize_key($event_status);
1784 1784
 		// grab status
1785
-		if (!empty($event_status)) {
1785
+		if ( ! empty($event_status)) {
1786 1786
 			$success = TRUE;
1787 1787
 			//determine the event id and set to array.
1788 1788
 			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
@@ -1817,15 +1817,15 @@  discard block
 block discarded – undo
1817 1817
 	 * @param  string $event_status
1818 1818
 	 * @return bool
1819 1819
 	 */
1820
-	private function _change_event_status( $EVT_ID = 0, $event_status = '') {
1820
+	private function _change_event_status($EVT_ID = 0, $event_status = '') {
1821 1821
 		// grab event id
1822
-		if (!$EVT_ID) {
1822
+		if ( ! $EVT_ID) {
1823 1823
 			$msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso');
1824 1824
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1825 1825
 			return FALSE;
1826 1826
 		}
1827 1827
 
1828
-		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
1828
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1829 1829
 
1830 1830
 		// clean status
1831 1831
 		$event_status = sanitize_key($event_status);
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
 				$hook = FALSE;
1852 1852
 		}
1853 1853
 		//use class to change status
1854
-		$this->_cpt_model_obj->set_status( $event_status );
1854
+		$this->_cpt_model_obj->set_status($event_status);
1855 1855
 		$success = $this->_cpt_model_obj->save();
1856 1856
 
1857 1857
 		if ($success === FALSE) {
@@ -1873,15 +1873,15 @@  discard block
 block discarded – undo
1873 1873
 	 * @access protected
1874 1874
 	 * @param bool $redirect_after
1875 1875
 	 */
1876
-	protected function _delete_event( $redirect_after = TRUE ) {
1876
+	protected function _delete_event($redirect_after = TRUE) {
1877 1877
 		//determine the event id and set to array.
1878 1878
 		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL;
1879
-		$EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID;
1879
+		$EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
1880 1880
 
1881 1881
 
1882 1882
 		// loop thru events
1883 1883
 		if ($EVT_ID) {
1884
-			$success = $this->_permanently_delete_event( $EVT_ID );
1884
+			$success = $this->_permanently_delete_event($EVT_ID);
1885 1885
 			// get list of events with no prices
1886 1886
 			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
1887 1887
 			// remove this event from the list of events with no prices
@@ -1895,7 +1895,7 @@  discard block
 block discarded – undo
1895 1895
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1896 1896
 		}
1897 1897
 
1898
-		if ( $redirect_after )
1898
+		if ($redirect_after)
1899 1899
 			$this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash'));
1900 1900
 	}
1901 1901
 
@@ -1913,12 +1913,12 @@  discard block
 block discarded – undo
1913 1913
 		$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1914 1914
 		// loop thru events
1915 1915
 		foreach ($EVT_IDs as $EVT_ID) {
1916
-			$EVT_ID = absint( $EVT_ID );
1917
-			if ( $EVT_ID ) {
1918
-				$results = $this->_permanently_delete_event( $EVT_ID );
1916
+			$EVT_ID = absint($EVT_ID);
1917
+			if ($EVT_ID) {
1918
+				$results = $this->_permanently_delete_event($EVT_ID);
1919 1919
 				$success = $results !== FALSE ? $success : FALSE;
1920 1920
 				// remove this event from the list of events with no prices
1921
-				unset( $espresso_no_ticket_prices[ $EVT_ID ] );
1921
+				unset($espresso_no_ticket_prices[$EVT_ID]);
1922 1922
 			} else {
1923 1923
 				$success = FALSE;
1924 1924
 				$msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso');
@@ -1938,21 +1938,21 @@  discard block
 block discarded – undo
1938 1938
 	 * @param  int $EVT_ID
1939 1939
 	 * @return bool
1940 1940
 	 */
1941
-	private function _permanently_delete_event( $EVT_ID = 0 ) {
1941
+	private function _permanently_delete_event($EVT_ID = 0) {
1942 1942
 		// grab event id
1943
-		if ( ! $EVT_ID ) {
1943
+		if ( ! $EVT_ID) {
1944 1944
 			$msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso');
1945 1945
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1946 1946
 			return FALSE;
1947 1947
 		}
1948
-		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
1948
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1949 1949
 
1950 1950
 		//need to delete related tickets and prices first.
1951 1951
 		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
1952
-		foreach ( $datetimes as $datetime ) {
1952
+		foreach ($datetimes as $datetime) {
1953 1953
 			$this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
1954 1954
 			$tickets = $datetime->get_many_related('Ticket');
1955
-			foreach ( $tickets as $ticket ) {
1955
+			foreach ($tickets as $ticket) {
1956 1956
 				$ticket->_remove_relation_to($datetime, 'Datetime');
1957 1957
 				$ticket->delete_related_permanently('Price');
1958 1958
 				$ticket->delete_permanently();
@@ -1962,14 +1962,14 @@  discard block
 block discarded – undo
1962 1962
 
1963 1963
 		//what about related venues or terms?
1964 1964
 		$venues = $this->_cpt_model_obj->get_many_related('Venue');
1965
-		foreach ( $venues as $venue ) {
1965
+		foreach ($venues as $venue) {
1966 1966
 			$this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
1967 1967
 		}
1968 1968
 
1969 1969
 		//any attached question groups?
1970 1970
 		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
1971
-		if ( !empty( $question_groups ) ) {
1972
-			foreach ( $question_groups as $question_group ) {
1971
+		if ( ! empty($question_groups)) {
1972
+			foreach ($question_groups as $question_group) {
1973 1973
 				$this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
1974 1974
 			}
1975 1975
 		}
@@ -1978,12 +1978,12 @@  discard block
 block discarded – undo
1978 1978
 
1979 1979
 
1980 1980
 		//Message Template Groups
1981
-		$this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' );
1981
+		$this->_cpt_model_obj->_remove_relations('Message_Template_Group');
1982 1982
 
1983 1983
 		/** @type EE_Term_Taxonomy[] $term_taxonomies */
1984 1984
 		$term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
1985 1985
 
1986
-		foreach ( $term_taxonomies as $term_taxonomy ) {
1986
+		foreach ($term_taxonomies as $term_taxonomy) {
1987 1987
 			$this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
1988 1988
 		}
1989 1989
 
@@ -1997,7 +1997,7 @@  discard block
 block discarded – undo
1997 1997
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1998 1998
 			return FALSE;
1999 1999
 		}
2000
-		do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID );
2000
+		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2001 2001
 		return TRUE;
2002 2002
 	}
2003 2003
 
@@ -2014,7 +2014,7 @@  discard block
 block discarded – undo
2014 2014
 	 */
2015 2015
 	public function total_events() {
2016 2016
 
2017
-		$count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true );
2017
+		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2018 2018
 		return $count;
2019 2019
 	}
2020 2020
 
@@ -2029,10 +2029,10 @@  discard block
 block discarded – undo
2029 2029
 	 */
2030 2030
 	public function total_events_draft() {
2031 2031
 		$where = array(
2032
-			'status' => array( 'IN', array('draft', 'auto-draft' ) )
2032
+			'status' => array('IN', array('draft', 'auto-draft'))
2033 2033
 			);
2034 2034
 
2035
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
2035
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2036 2036
 		return $count;
2037 2037
 	}
2038 2038
 
@@ -2051,7 +2051,7 @@  discard block
 block discarded – undo
2051 2051
 			'status' => 'trash'
2052 2052
 			);
2053 2053
 
2054
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
2054
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2055 2055
 		return $count;
2056 2056
 	}
2057 2057
 
@@ -2079,11 +2079,11 @@  discard block
 block discarded – undo
2079 2079
 			// translated
2080 2080
 			TRUE
2081 2081
 		);
2082
-		$this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment;
2082
+		$this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment;
2083 2083
 
2084 2084
 		$this->_set_add_edit_form_tags('update_default_event_settings');
2085 2085
 		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
2086
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE);
2086
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE);
2087 2087
 		$this->display_admin_page_with_sidebar();
2088 2088
 	}
2089 2089
 
@@ -2109,9 +2109,9 @@  discard block
 block discarded – undo
2109 2109
 
2110 2110
 	protected function _template_settings() {
2111 2111
 		$this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso');
2112
-		$this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />';
2113
-		$this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>';
2114
-		$this->display_admin_caf_preview_page( 'template_settings_tab' );
2112
+		$this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />';
2113
+		$this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>';
2114
+		$this->display_admin_caf_preview_page('template_settings_tab');
2115 2115
 	}
2116 2116
 
2117 2117
 
@@ -2124,22 +2124,22 @@  discard block
 block discarded – undo
2124 2124
 	 * @return void
2125 2125
 	 */
2126 2126
 	private function _set_category_object() {
2127
-		if ( isset( $this->_category->id ) && !empty( $this->_category->id ) )
2127
+		if (isset($this->_category->id) && ! empty($this->_category->id))
2128 2128
 			return; //already have the category object so get out.
2129 2129
 
2130 2130
 		//set default category object
2131 2131
 		$this->_set_empty_category_object();
2132 2132
 
2133 2133
 		//only set if we've got an id
2134
-		if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) {
2134
+		if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2135 2135
 			return;
2136 2136
 		}
2137 2137
 
2138 2138
 		$category_id = absint($this->_req_data['EVT_CAT_ID']);
2139 2139
 
2140
-		$term = get_term( $category_id, 'espresso_event_categories' );
2140
+		$term = get_term($category_id, 'espresso_event_categories');
2141 2141
 
2142
-		if ( !empty( $term ) ) {
2142
+		if ( ! empty($term)) {
2143 2143
 			$this->_category->category_name = $term->name;
2144 2144
 			$this->_category->category_identifier = $term->slug;
2145 2145
 			$this->_category->category_desc = $term->description;
@@ -2153,13 +2153,13 @@  discard block
 block discarded – undo
2153 2153
 
2154 2154
 	private function _set_empty_category_object() {
2155 2155
 		$this->_category = new stdClass();
2156
-		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc  = '';
2156
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2157 2157
 		$this->_category->id = $this->_category->parent = 0;
2158 2158
 	}
2159 2159
 
2160 2160
 
2161 2161
 	protected function _category_list_table() {
2162
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2162
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2163 2163
 		$this->_search_btn_label = __('Categories', 'event_espresso');
2164 2164
 		$this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2');
2165 2165
 		$this->display_admin_list_table_page_with_sidebar();
@@ -2169,22 +2169,22 @@  discard block
 block discarded – undo
2169 2169
 	protected function _category_details($view) {
2170 2170
 
2171 2171
 		//load formatter helper
2172
-		EE_Registry::instance()->load_helper( 'Formatter' );
2172
+		EE_Registry::instance()->load_helper('Formatter');
2173 2173
 		//load field generator helper
2174
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
2174
+		EE_Registry::instance()->load_helper('Form_Fields');
2175 2175
 
2176 2176
 		$route = $view == 'edit' ? 'update_category' : 'insert_category';
2177 2177
 		$this->_set_add_edit_form_tags($route);
2178 2178
 
2179 2179
 		$this->_set_category_object();
2180
-		$id = !empty($this->_category->id) ? $this->_category->id : '';
2180
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
2181 2181
 
2182 2182
 		$delete_action = 'delete_category';
2183 2183
 
2184 2184
 		//custom redirect
2185
-		$redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url );
2185
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url);
2186 2186
 
2187
-		$this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect );
2187
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2188 2188
 
2189 2189
 		//take care of contents
2190 2190
 		$this->_template_args['admin_page_content'] = $this->_category_details_content();
@@ -2198,25 +2198,25 @@  discard block
 block discarded – undo
2198 2198
 			'type' => 'wp_editor',
2199 2199
 			'value' => EEH_Formatter::admin_format_content($this->_category->category_desc),
2200 2200
 			'class' => 'my_editor_custom',
2201
-			'wpeditor_args' => array('media_buttons' => FALSE )
2201
+			'wpeditor_args' => array('media_buttons' => FALSE)
2202 2202
 		);
2203
-		$_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' );
2203
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2204 2204
 
2205
-		$all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) );
2205
+		$all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id)));
2206 2206
 
2207 2207
 		//setup category select for term parents.
2208 2208
 		$category_select_values[] = array(
2209 2209
 			'text' => __('No Parent', 'event_espresso'),
2210 2210
 			'id' => 0
2211 2211
 			);
2212
-		foreach ( $all_terms as $term ) {
2212
+		foreach ($all_terms as $term) {
2213 2213
 			$category_select_values[] = array(
2214 2214
 				'text' => $term->name,
2215 2215
 				'id' => $term->term_id
2216 2216
 				);
2217 2217
 		}
2218 2218
 
2219
-		$category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent );
2219
+		$category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent);
2220 2220
 
2221 2221
 		$template_args = array(
2222 2222
 			'category' => $this->_category,
@@ -2226,15 +2226,15 @@  discard block
 block discarded – undo
2226 2226
 			'disable' => '',
2227 2227
 			'disabled_message' => FALSE
2228 2228
 			);
2229
-		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2230
-		return EEH_Template::display_template($template, $template_args, TRUE );
2229
+		$template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php';
2230
+		return EEH_Template::display_template($template, $template_args, TRUE);
2231 2231
 	}
2232 2232
 
2233 2233
 
2234 2234
 	protected function _delete_categories() {
2235
-		$cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id'];
2235
+		$cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id'];
2236 2236
 
2237
-		foreach ( $cat_ids as $cat_id ) {
2237
+		foreach ($cat_ids as $cat_id) {
2238 2238
 			$this->_delete_category($cat_id);
2239 2239
 		}
2240 2240
 
@@ -2242,7 +2242,7 @@  discard block
 block discarded – undo
2242 2242
 		$query_args = array(
2243 2243
 			'action' => 'category_list'
2244 2244
 			);
2245
-		$this->_redirect_after_action(0,'','',$query_args);
2245
+		$this->_redirect_after_action(0, '', '', $query_args);
2246 2246
 
2247 2247
 	}
2248 2248
 
@@ -2252,61 +2252,61 @@  discard block
 block discarded – undo
2252 2252
 
2253 2253
 	protected function _delete_category($cat_id) {
2254 2254
 		global $wpdb;
2255
-		$cat_id = absint( $cat_id );
2256
-		wp_delete_term( $cat_id, 'espresso_event_categories' );
2255
+		$cat_id = absint($cat_id);
2256
+		wp_delete_term($cat_id, 'espresso_event_categories');
2257 2257
 	}
2258 2258
 
2259 2259
 
2260 2260
 
2261 2261
 	protected function _insert_or_update_category($new_category) {
2262 2262
 
2263
-		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE );
2263
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE);
2264 2264
 		$success = 0; //we already have a success message so lets not send another.
2265 2265
 
2266
-		if ( $cat_id ) {
2266
+		if ($cat_id) {
2267 2267
 			$query_args = array(
2268 2268
 				'action'     => 'edit_category',
2269 2269
 				'EVT_CAT_ID' => $cat_id
2270 2270
 			);
2271 2271
 		} else {
2272
-			$query_args = array( 'action' => 'add_category' );
2272
+			$query_args = array('action' => 'add_category');
2273 2273
 		}
2274
-		$this->_redirect_after_action( $success, '','', $query_args, TRUE );
2274
+		$this->_redirect_after_action($success, '', '', $query_args, TRUE);
2275 2275
 
2276 2276
 	}
2277 2277
 
2278 2278
 
2279 2279
 
2280
-	private function _insert_category( $update = FALSE ) {
2280
+	private function _insert_category($update = FALSE) {
2281 2281
 		$cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2282
-		$category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : '';
2283
-		$category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : '';
2284
-		$category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0;
2282
+		$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2283
+		$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2284
+		$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2285 2285
 
2286
-		if ( empty( $category_name ) ) {
2287
-			$msg = __( 'You must add a name for the category.', 'event_espresso' );
2288
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2286
+		if (empty($category_name)) {
2287
+			$msg = __('You must add a name for the category.', 'event_espresso');
2288
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2289 2289
 			return false;
2290 2290
 		}
2291 2291
 
2292
-		$term_args=array(
2292
+		$term_args = array(
2293 2293
 			'name'=>$category_name,
2294 2294
 			'description'=>$category_desc,
2295 2295
 			'parent'=>$category_parent
2296 2296
 		);
2297 2297
 		//was the category_identifier input disabled?
2298
-		if(isset($this->_req_data['category_identifier'])){
2298
+		if (isset($this->_req_data['category_identifier'])) {
2299 2299
 			$term_args['slug'] = $this->_req_data['category_identifier'];
2300 2300
 		}
2301
-		$insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args );
2301
+		$insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args);
2302 2302
 
2303
-		if ( !is_array( $insert_ids ) ) {
2304
-			$msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' );
2305
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2303
+		if ( ! is_array($insert_ids)) {
2304
+			$msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso');
2305
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2306 2306
 		} else {
2307 2307
 			$cat_id = $insert_ids['term_id'];
2308
-			$msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name );
2309
-			EE_Error::add_success( $msg );
2308
+			$msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name);
2309
+			EE_Error::add_success($msg);
2310 2310
 		}
2311 2311
 
2312 2312
 		return $cat_id;
@@ -2315,32 +2315,32 @@  discard block
 block discarded – undo
2315 2315
 
2316 2316
 
2317 2317
 
2318
-	public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) {
2318
+	public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) {
2319 2319
 		global $wpdb;
2320 2320
 
2321 2321
 		//testing term stuff
2322
-		$orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id';
2323
-		$order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC';
2324
-		$limit = ($current_page-1)*$per_page;
2322
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2323
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2324
+		$limit = ($current_page - 1) * $per_page;
2325 2325
 
2326
-		$where = array( 'taxonomy' => 'espresso_event_categories' );
2326
+		$where = array('taxonomy' => 'espresso_event_categories');
2327 2327
 
2328
-		if ( isset( $this->_req_data['s'] ) ) {
2329
-			$sstr = '%' . $this->_req_data['s'] . '%';
2328
+		if (isset($this->_req_data['s'])) {
2329
+			$sstr = '%'.$this->_req_data['s'].'%';
2330 2330
 			$where['OR'] = array(
2331
-				'Term.name' => array( 'LIKE', $sstr),
2332
-				'description' => array( 'LIKE', $sstr )
2331
+				'Term.name' => array('LIKE', $sstr),
2332
+				'description' => array('LIKE', $sstr)
2333 2333
 				);
2334 2334
 		}
2335 2335
 
2336 2336
 		$query_params = array(
2337
-			$where ,
2338
-			'order_by' => array( $orderby => $order ),
2339
-			'limit' => $limit . ',' . $per_page,
2337
+			$where,
2338
+			'order_by' => array($orderby => $order),
2339
+			'limit' => $limit.','.$per_page,
2340 2340
 			'force_join' => array('Term')
2341 2341
 			);
2342 2342
 
2343
-		$categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params );
2343
+		$categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params);
2344 2344
 
2345 2345
 		return $categories;
2346 2346
 	}
Please login to merge, or discard this patch.
admin_pages/payments/Payments_Admin_Page.core.php 1 patch
Spacing   +168 added lines, -168 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
 /**
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
45 45
 	 * @return \Payments_Admin_Page
46 46
 	 */
47
-	public function __construct( $routing = TRUE ) {
48
-		parent::__construct( $routing );
47
+	public function __construct($routing = TRUE) {
48
+		parent::__construct($routing);
49 49
 	}
50 50
 
51 51
 
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
 	protected function _set_page_config() {
131 131
 		$payment_method_list_config = array(
132 132
 			'nav'           => array(
133
-				'label' => __( 'Payment Methods', 'event_espresso' ),
133
+				'label' => __('Payment Methods', 'event_espresso'),
134 134
 				'order' => 10
135 135
 			),
136 136
 			'metaboxes'     => $this->_default_espresso_metaboxes,
137 137
 			'help_tabs'     => array_merge(
138 138
 				array(
139 139
 					'payment_methods_overview_help_tab' => array(
140
-						'title'    => __( 'Payment Methods Overview', 'event_espresso' ),
140
+						'title'    => __('Payment Methods Overview', 'event_espresso'),
141 141
 						'filename' => 'payment_methods_overview'
142 142
 					)
143 143
 				),
144 144
 				$this->_add_payment_method_help_tabs() ),
145
-			'help_tour'     => array( 'Payment_Methods_Selection_Help_Tour' ),
145
+			'help_tour'     => array('Payment_Methods_Selection_Help_Tour'),
146 146
 			'require_nonce' => false
147 147
 		);
148 148
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 					)
161 161
 				),
162 162
 				//'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ),
163
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
163
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
164 164
 				'require_nonce' => FALSE
165 165
 			),
166 166
 			'payment_log'=>array(
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 	/**
180 180
 	 * @return array
181 181
 	 */
182
-	protected function _add_payment_method_help_tabs(){
182
+	protected function _add_payment_method_help_tabs() {
183 183
 		EE_Registry::instance()->load_lib('Payment_Method_Manager');
184 184
 		$payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
185 185
 		$all_pmt_help_tabs_config = array();
186
-		foreach( $payment_method_types as $payment_method_type ){
187
-			if ( ! EE_Registry::instance()->CAP->current_user_can( $payment_method_type->cap_name(), 'specific_payment_method_type_access' ) ) {
186
+		foreach ($payment_method_types as $payment_method_type) {
187
+			if ( ! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(), 'specific_payment_method_type_access')) {
188 188
 				continue;
189 189
 			}
190
-			foreach( $payment_method_type->help_tabs_config() as $help_tab_name => $config ){
191
-				$template_args = isset( $config[ 'template_args' ] ) ? $config[ 'template_args' ] : array();
192
-				$template_args[ 'admin_page_obj' ] = $this;
190
+			foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
191
+				$template_args = isset($config['template_args']) ? $config['template_args'] : array();
192
+				$template_args['admin_page_obj'] = $this;
193 193
 				$all_pmt_help_tabs_config[$help_tab_name] = array(
194 194
 					'title'=>$config['title'],
195 195
 					'content'=>EEH_Template::display_template( 
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 
217 217
 
218 218
 	public function load_scripts_styles() {
219
-		wp_enqueue_script( 'ee_admin_js' );
220
-		wp_enqueue_script( 'ee-text-links' );
221
-		wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE );
219
+		wp_enqueue_script('ee_admin_js');
220
+		wp_enqueue_script('ee-text-links');
221
+		wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE);
222 222
 	}
223 223
 
224 224
 
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 
228 228
 	public function load_scripts_styles_default() {
229 229
 		//styles
230
-		wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION );
231
-		wp_enqueue_style( 'espresso_payments' );
232
-		wp_enqueue_style( 'ee-text-links' );
230
+		wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION);
231
+		wp_enqueue_style('espresso_payments');
232
+		wp_enqueue_style('ee-text-links');
233 233
 		//scripts
234 234
 	}
235 235
 
@@ -243,46 +243,46 @@  discard block
 block discarded – undo
243 243
 		 * to the loading process.  However, people MUST setup the details for the payment method so its safe to do a
244 244
 		 * recheck here.
245 245
 		 */
246
-		EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
246
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
247 247
 		EEM_Payment_Method::instance()->verify_button_urls();
248
-		EE_Registry::instance()->load_helper( 'Tabbed_Content' );
249
-		EE_Registry::instance()->load_helper( 'HTML' );
248
+		EE_Registry::instance()->load_helper('Tabbed_Content');
249
+		EE_Registry::instance()->load_helper('HTML');
250 250
 		//setup tabs, one for each payment method type
251 251
 		$tabs = array();
252 252
 		$payment_methods = array();
253
-		foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) {
253
+		foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
254 254
 			// we don't want to show admin-only PMTs for now
255
-			if ( $pmt_obj instanceof EE_PMT_Admin_Only ) {
255
+			if ($pmt_obj instanceof EE_PMT_Admin_Only) {
256 256
 				continue;
257 257
 			}
258 258
 			//check access
259
-			if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) {
259
+			if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) {
260 260
 				continue;
261 261
 			}
262 262
 			//check for any active pms of that type
263
-			$payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() );
264
-			if ( ! $payment_method instanceof EE_Payment_Method ) {
263
+			$payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
264
+			if ( ! $payment_method instanceof EE_Payment_Method) {
265 265
 				$payment_method = EE_Payment_Method::new_instance(
266 266
 					array(
267
-						'PMD_slug'					=>sanitize_key( $pmt_obj->system_name() ),
267
+						'PMD_slug'					=>sanitize_key($pmt_obj->system_name()),
268 268
 						'PMD_type'					=>$pmt_obj->system_name(),
269 269
 						'PMD_name'				=>$pmt_obj->pretty_name(),
270 270
 						'PMD_admin_name'	=>$pmt_obj->pretty_name()
271 271
 					)
272 272
 				);
273 273
 			}
274
-			$payment_methods[ $payment_method->slug() ] = $payment_method;
274
+			$payment_methods[$payment_method->slug()] = $payment_method;
275 275
 		}
276
-		$payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods );
277
-		foreach( $payment_methods as $payment_method ) {
278
-			if ( $payment_method instanceof EE_Payment_Method ) {
276
+		$payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods);
277
+		foreach ($payment_methods as $payment_method) {
278
+			if ($payment_method instanceof EE_Payment_Method) {
279 279
 				add_meta_box(
280 280
 					//html id
281
-					'espresso_' . $payment_method->slug() . '_payment_settings',
281
+					'espresso_'.$payment_method->slug().'_payment_settings',
282 282
 					//title
283
-					sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ),
283
+					sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
284 284
 					//callback
285
-					array( $this, 'payment_method_settings_meta_box' ),
285
+					array($this, 'payment_method_settings_meta_box'),
286 286
 					//post type
287 287
 					null,
288 288
 					//context
@@ -290,19 +290,19 @@  discard block
 block discarded – undo
290 290
 					//priority
291 291
 					'default',
292 292
 					//callback args
293
-					array( 'payment_method' => $payment_method )
293
+					array('payment_method' => $payment_method)
294 294
 				);
295 295
 				//setup for tabbed content
296
-				$tabs[ $payment_method->slug() ] = array(
296
+				$tabs[$payment_method->slug()] = array(
297 297
 					'label' => $payment_method->admin_name(),
298 298
 					'class' => $payment_method->active() ? 'gateway-active' : '',
299
-					'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
300
-					'title' => __( 'Modify this Payment Method', 'event_espresso' ),
299
+					'href'  => 'espresso_'.$payment_method->slug().'_payment_settings',
300
+					'title' => __('Modify this Payment Method', 'event_espresso'),
301 301
 					'slug'  => $payment_method->slug()
302 302
 				);
303 303
 			}
304 304
 		}
305
-		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() );
305
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug());
306 306
 		$this->display_admin_page_with_sidebar();
307 307
 
308 308
 	}
@@ -313,20 +313,20 @@  discard block
 block discarded – undo
313 313
 	 *   _get_active_payment_method_slug
314 314
 	 * 	@return string
315 315
 	 */
316
-	protected function _get_active_payment_method_slug(){
316
+	protected function _get_active_payment_method_slug() {
317 317
 		$payment_method_slug = FALSE;
318 318
 		//decide which payment method tab to open first, as dictated by the request's 'payment_method'
319
-		if ( isset( $this->_req_data['payment_method'] )) {
319
+		if (isset($this->_req_data['payment_method'])) {
320 320
 			// if they provided the current payment method, use it
321
-			$payment_method_slug = sanitize_key( $this->_req_data['payment_method'] );
321
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
322 322
 		}
323
-		$payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug )));
323
+		$payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
324 324
 		// if that didn't work or wasn't provided, find another way to select the current pm
325
-		if ( ! $this->_verify_payment_method( $payment_method )) {
325
+		if ( ! $this->_verify_payment_method($payment_method)) {
326 326
 			// like, looking for an active one
327
-			$payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' );
327
+			$payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
328 328
 			// test that one as well
329
-			if ( $this->_verify_payment_method( $payment_method )) {
329
+			if ($this->_verify_payment_method($payment_method)) {
330 330
 				$payment_method_slug = $payment_method->slug();
331 331
 			} else {
332 332
 				$payment_method_slug = 'paypal_standard';
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 	 * @param \EE_Payment_Method $payment_method
345 345
 	 * @return boolean
346 346
 	 */
347
-	protected function _verify_payment_method( $payment_method ){
347
+	protected function _verify_payment_method($payment_method) {
348 348
 		if (
349 349
 			$payment_method instanceof EE_Payment_Method &&
350 350
 			$payment_method->type_obj() instanceof EE_PMT_Base &&
351
-			EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' )
351
+			EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access')
352 352
 		) {
353 353
 			return TRUE;
354 354
 		}
@@ -365,21 +365,21 @@  discard block
 block discarded – undo
365 365
 	 * @return string
366 366
 	 * @throws EE_Error
367 367
 	 */
368
-	public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){
369
-		$payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL;
370
-		if ( ! $payment_method instanceof EE_Payment_Method ){
371
-			throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' )));
368
+	public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) {
369
+		$payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL;
370
+		if ( ! $payment_method instanceof EE_Payment_Method) {
371
+			throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso')));
372 372
 		}
373 373
 		$payment_method_scopes = $payment_method->active();
374 374
 		// if the payment method really exists show its form, otherwise the activation template
375
-		if ( $payment_method->ID() && ! empty( $payment_method_scopes )) {
376
-				$form = $this->_generate_payment_method_settings_form( $payment_method );
377
-				if ( $form->form_data_present_in( $this->_req_data )) {
378
-					$form->receive_form_submission( $this->_req_data );
375
+		if ($payment_method->ID() && ! empty($payment_method_scopes)) {
376
+				$form = $this->_generate_payment_method_settings_form($payment_method);
377
+				if ($form->form_data_present_in($this->_req_data)) {
378
+					$form->receive_form_submission($this->_req_data);
379 379
 				}
380
-				echo $form->form_open() . $form->get_html_and_js() . $form->form_close();
380
+				echo $form->form_open().$form->get_html_and_js().$form->form_close();
381 381
 		} else {
382
-			echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js();
382
+			echo $this->_activate_payment_method_button($payment_method)->get_html_and_js();
383 383
 		}
384 384
 	}
385 385
 
@@ -392,14 +392,14 @@  discard block
 block discarded – undo
392 392
 	 * @param \EE_Payment_Method $payment_method
393 393
 	 * @return \EE_Form_Section_Proper
394 394
 	 */
395
-	protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) {
396
-		if ( ! $payment_method instanceof EE_Payment_Method ){
395
+	protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) {
396
+		if ( ! $payment_method instanceof EE_Payment_Method) {
397 397
 			return new EE_Form_Section_Proper();
398 398
 		}
399 399
 		return new EE_Form_Section_Proper(
400 400
 			array(
401
-				'name' 	=> $payment_method->slug() . '_settings_form',
402
-				'html_id' 	=> $payment_method->slug() . '_settings_form',
401
+				'name' 	=> $payment_method->slug().'_settings_form',
402
+				'html_id' 	=> $payment_method->slug().'_settings_form',
403 403
 				'action' 	=> EE_Admin_Page::add_query_args_and_nonce(
404 404
 					array(
405 405
 						'action' 						=> 'update_payment_method',
@@ -411,12 +411,12 @@  discard block
 block discarded – undo
411 411
 				'subsections' 			=> apply_filters(
412 412
 					'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
413 413
 					array(
414
-						'pci_dss_compliance_' . $payment_method->slug() 				=> $this->_pci_dss_compliance( $payment_method ),
415
-						'currency_support_' . $payment_method->slug()					=> $this->_currency_support( $payment_method ),
416
-						'payment_method_settings_' . $payment_method->slug() 	=> $this->_payment_method_settings( $payment_method ),
417
-						'update_' . $payment_method->slug()										=> $this->_update_payment_method_button( $payment_method ),
418
-						'deactivate_' . $payment_method->slug()								=> $this->_deactivate_payment_method_button( $payment_method ),
419
-						'fine_print_' . $payment_method->slug()									=> $this->_fine_print()
414
+						'pci_dss_compliance_'.$payment_method->slug() 				=> $this->_pci_dss_compliance($payment_method),
415
+						'currency_support_'.$payment_method->slug()					=> $this->_currency_support($payment_method),
416
+						'payment_method_settings_'.$payment_method->slug() 	=> $this->_payment_method_settings($payment_method),
417
+						'update_'.$payment_method->slug()										=> $this->_update_payment_method_button($payment_method),
418
+						'deactivate_'.$payment_method->slug()								=> $this->_deactivate_payment_method_button($payment_method),
419
+						'fine_print_'.$payment_method->slug()									=> $this->_fine_print()
420 420
 					),
421 421
 					$payment_method
422 422
 				)
@@ -433,19 +433,19 @@  discard block
 block discarded – undo
433 433
 	 * @param \EE_Payment_Method $payment_method
434 434
 	 * @return \EE_Form_Section_Proper
435 435
 	 */
436
-	protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) {
437
-		if ( $payment_method->type_obj()->requires_https() ) {
436
+	protected function _pci_dss_compliance(EE_Payment_Method $payment_method) {
437
+		if ($payment_method->type_obj()->requires_https()) {
438 438
 			return new EE_Form_Section_HTML(
439 439
 				EEH_HTML::tr(
440 440
 					EEH_HTML::th(
441 441
 						EEH_HTML::label(
442
-							EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' )
442
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
443 443
 						)
444
-					) .
444
+					).
445 445
 					EEH_HTML::td(
446
-						EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) .
447
-						EEH_HTML::br() .
448
-						__( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' ))
446
+						EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')).
447
+						EEH_HTML::br().
448
+						__('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso'))
449 449
 					)
450 450
 				)
451 451
 			);
@@ -463,19 +463,19 @@  discard block
 block discarded – undo
463 463
 	 * @param \EE_Payment_Method $payment_method
464 464
 	 * @return \EE_Form_Section_Proper
465 465
 	 */
466
-	protected function _currency_support( EE_Payment_Method $payment_method ) {
467
-		if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) {
466
+	protected function _currency_support(EE_Payment_Method $payment_method) {
467
+		if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
468 468
 			return new EE_Form_Section_HTML(
469 469
 				EEH_HTML::tr(
470 470
 					EEH_HTML::th(
471 471
 						EEH_HTML::label(
472
-							EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' )
472
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
473 473
 						)
474
-					) .
474
+					).
475 475
 					EEH_HTML::td(
476 476
 						EEH_HTML::strong(
477 477
 							sprintf(
478
-								__( 'This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'),
478
+								__('This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'),
479 479
 								EE_Config::instance()->currency->code
480 480
 							)
481 481
 						)
@@ -495,9 +495,9 @@  discard block
 block discarded – undo
495 495
 	 * @param \EE_Payment_Method $payment_method
496 496
 	 * @return \EE_Form_Section_HTML
497 497
 	 */
498
-	protected function _payment_method_settings( EE_Payment_Method $payment_method ) {
498
+	protected function _payment_method_settings(EE_Payment_Method $payment_method) {
499 499
 		//modify the form so we only have/show fields that will be implemented for this version
500
-		return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() );
500
+		return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
501 501
 	}
502 502
 
503 503
 
@@ -510,8 +510,8 @@  discard block
 block discarded – undo
510 510
 	 * @return \EE_Payment_Method_Form
511 511
 	 * @throws \EE_Error
512 512
 	 */
513
-	protected function _simplify_form( $form_section, $payment_method_name = '' ){
514
-		if ( $form_section instanceof EE_Payment_Method_Form ) {
513
+	protected function _simplify_form($form_section, $payment_method_name = '') {
514
+		if ($form_section instanceof EE_Payment_Method_Form) {
515 515
 			$form_section->exclude(
516 516
 				array(
517 517
 					'PMD_type', //dont want them changing the type
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 			);
523 523
 			return $form_section;
524 524
 		} else {
525
-			throw new EE_Error( sprintf( __( 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso' ), $payment_method_name ));
525
+			throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name));
526 526
 		}
527 527
 	}
528 528
 
@@ -535,18 +535,18 @@  discard block
 block discarded – undo
535 535
 	 * @param \EE_Payment_Method $payment_method
536 536
 	 * @return \EE_Form_Section_HTML
537 537
 	 */
538
-	protected function _update_payment_method_button( EE_Payment_Method $payment_method ) {
538
+	protected function _update_payment_method_button(EE_Payment_Method $payment_method) {
539 539
 		$update_button = new EE_Submit_Input(
540 540
 			array(
541
-				'html_id' 		=> 'save_' . $payment_method->slug() . '_settings',
542
-				'default' 		=> sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ),
541
+				'html_id' 		=> 'save_'.$payment_method->slug().'_settings',
542
+				'default' 		=> sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()),
543 543
 				'html_label' => EEH_HTML::nbsp()
544 544
 			)
545 545
 		);
546 546
 		return new EE_Form_Section_HTML(
547
-			EEH_HTML::no_row( EEH_HTML::br(2) ) .
547
+			EEH_HTML::no_row(EEH_HTML::br(2)).
548 548
 			EEH_HTML::tr(
549
-				EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) .
549
+				EEH_HTML::th(__('Update Settings', 'event_espresso')).
550 550
 				EEH_HTML::td(
551 551
 					$update_button->get_html_for_input()
552 552
 				)
@@ -563,11 +563,11 @@  discard block
 block discarded – undo
563 563
 	 * @param \EE_Payment_Method $payment_method
564 564
 	 * @return \EE_Form_Section_Proper
565 565
 	 */
566
-	protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) {
567
-		$link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() );
566
+	protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) {
567
+		$link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name());
568 568
 		return new EE_Form_Section_HTML(
569 569
 			EEH_HTML::tr(
570
-				EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) .
570
+				EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')).
571 571
 				EEH_HTML::td(
572 572
 					EEH_HTML::link(
573 573
 						EE_Admin_Page::add_query_args_and_nonce(
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 						),
580 580
 						$link_text_and_title,
581 581
 						$link_text_and_title,
582
-						'deactivate_' . $payment_method->slug(),
582
+						'deactivate_'.$payment_method->slug(),
583 583
 						'espresso-button button-secondary'
584 584
 					)
585 585
 				)
@@ -595,12 +595,12 @@  discard block
 block discarded – undo
595 595
 	 * @param \EE_Payment_Method $payment_method
596 596
 	 * @return \EE_Form_Section_Proper
597 597
 	 */
598
-	protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) {
599
-		$link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() );
598
+	protected function _activate_payment_method_button(EE_Payment_Method $payment_method) {
599
+		$link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name());
600 600
 		return new EE_Form_Section_Proper(
601 601
 			array(
602
-				'name' 	=> 'activate_' . $payment_method->slug() . '_settings_form',
603
-				'html_id' 	=> 'activate_' . $payment_method->slug() . '_settings_form',
602
+				'name' 	=> 'activate_'.$payment_method->slug().'_settings_form',
603
+				'html_id' 	=> 'activate_'.$payment_method->slug().'_settings_form',
604 604
 				'action' 	=> '#',
605 605
 				'layout_strategy'		=> new EE_Admin_Two_Column_Layout(),
606 606
 				'subsections' 			=> apply_filters(
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
 						new EE_Form_Section_HTML(
610 610
 							EEH_HTML::tr(
611 611
 								EEH_HTML::th(
612
-									EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' ))
613
-								) .
612
+									EEH_HTML::label(__('Click to Activate ', 'event_espresso'))
613
+								).
614 614
 								EEH_HTML::td(
615 615
 									EEH_HTML::link(
616 616
 										EE_Admin_Page::add_query_args_and_nonce(
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 										),
623 623
 										$link_text_and_title,
624 624
 										$link_text_and_title,
625
-										'activate_' . $payment_method->slug(),
625
+										'activate_'.$payment_method->slug(),
626 626
 										'espresso-button-green button-primary'
627 627
 									)
628 628
 								)
@@ -644,9 +644,9 @@  discard block
 block discarded – undo
644 644
 	protected function _fine_print() {
645 645
 		return new EE_Form_Section_HTML(
646 646
 			EEH_HTML::tr(
647
-				EEH_HTML::th() .
647
+				EEH_HTML::th().
648 648
 				EEH_HTML::td(
649
-					EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' )
649
+					EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
650 650
 				)
651 651
 			)
652 652
 		);
@@ -658,15 +658,15 @@  discard block
 block discarded – undo
658 658
 	 * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
659 659
 	 * @global WP_User $current_user
660 660
 	 */
661
-	protected function _activate_payment_method(){
662
-		if(isset($this->_req_data['payment_method_type'])){
661
+	protected function _activate_payment_method() {
662
+		if (isset($this->_req_data['payment_method_type'])) {
663 663
 			$payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
664 664
 			//see if one exists
665
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
666
-			$payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type );
665
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
666
+			$payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type);
667 667
 
668
-			$this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug()));
669
-		}else{
668
+			$this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug()));
669
+		} else {
670 670
 			$this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default'));
671 671
 		}
672 672
 	}
@@ -674,14 +674,14 @@  discard block
 block discarded – undo
674 674
 	/**
675 675
 	 * Deactivates the payment method with the specified slug, and redirects.
676 676
 	 */
677
-	protected function _deactivate_payment_method(){
678
-		if(isset($this->_req_data['payment_method'])){
677
+	protected function _deactivate_payment_method() {
678
+		if (isset($this->_req_data['payment_method'])) {
679 679
 			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
680 680
 			//deactivate it
681 681
 			EE_Registry::instance()->load_lib('Payment_Method_Manager');
682
-			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug );
683
-			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug));
684
-		}else{
682
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
683
+			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug));
684
+		} else {
685 685
 			$this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default'));
686 686
 		}
687 687
 	}
@@ -695,39 +695,39 @@  discard block
 block discarded – undo
695 695
 	 * subsequently called 'headers_sent_func' which is _payment_methods_list)
696 696
 	 * @return void
697 697
 	 */
698
-	protected function _update_payment_method(){
699
-		if( $_SERVER['REQUEST_METHOD'] == 'POST'){
698
+	protected function _update_payment_method() {
699
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
700 700
 			//ok let's find which gateway form to use based on the form input
701 701
 			EE_Registry::instance()->load_lib('Payment_Method_Manager');
702 702
 			/** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
703 703
 			$correct_pmt_form_to_use = NULL;
704 704
 			$pmt_obj = NULL;
705
-			foreach(EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj){
705
+			foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
706 706
 				/** @var $pmt_obj EE_PMT_Base */
707 707
 				//get the form and simplify it, like what we do when we display it
708 708
 				$pmt_form = $pmt_obj->settings_form();
709 709
 				$this->_simplify_form($pmt_form);
710
-				if($pmt_form->form_data_present_in($this->_req_data)){
710
+				if ($pmt_form->form_data_present_in($this->_req_data)) {
711 711
 					$correct_pmt_form_to_use = $pmt_form;
712 712
 					break;
713 713
 				}
714 714
 			}
715 715
 			//if we couldn't find the correct payment method type...
716
-			if( ! $correct_pmt_form_to_use ){
716
+			if ( ! $correct_pmt_form_to_use) {
717 717
 				EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support", 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
718 718
 				$this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default'));
719 719
 			}
720 720
 			$correct_pmt_form_to_use->receive_form_submission($this->_req_data);
721
-			if($correct_pmt_form_to_use->is_valid()){
721
+			if ($correct_pmt_form_to_use->is_valid()) {
722 722
 				$correct_pmt_form_to_use->save();
723 723
 				$pm = $correct_pmt_form_to_use->get_model_object();
724 724
 				/** @var $pm EE_Payment_Method */
725
-				$this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$pm->slug()));
726
-			}else{
725
+				$this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$pm->slug()));
726
+			} else {
727 727
 				EE_Error::add_error(
728 728
 					sprintf(
729 729
 						__('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'),
730
-						$pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __( '"(unknown)"', 'event_espresso' )
730
+						$pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __('"(unknown)"', 'event_espresso')
731 731
 					),
732 732
 					__FILE__,
733 733
 					__FUNCTION__,
@@ -744,11 +744,11 @@  discard block
 block discarded – undo
744 744
 	protected function _payment_settings() {
745 745
 
746 746
 		$this->_template_args['values'] = $this->_yes_no_values;
747
-		$this->_template_args['show_pending_payment_options'] = isset( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) ? absint( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) : FALSE;
747
+		$this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : FALSE;
748 748
 
749
-		$this->_set_add_edit_form_tags( 'update_payment_settings' );
750
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
751
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE );
749
+		$this->_set_add_edit_form_tags('update_payment_settings');
750
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
751
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE);
752 752
 		$this->display_admin_page_with_sidebar();
753 753
 
754 754
 	}
@@ -762,13 +762,13 @@  discard block
 block discarded – undo
762 762
 	*		@return array
763 763
 	*/
764 764
 	protected function _update_payment_settings() {
765
-		EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset( $this->_req_data['show_pending_payment_options'] ) ? $this->_req_data['show_pending_payment_options'] : FALSE;
766
-		EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG );
765
+		EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options']) ? $this->_req_data['show_pending_payment_options'] : FALSE;
766
+		EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG);
767 767
 
768 768
 
769
-		$what = __('Payment Settings','event_espresso');
770
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ );
771
-		$this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) );
769
+		$what = __('Payment Settings', 'event_espresso');
770
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__);
771
+		$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings'));
772 772
 
773 773
 	}
774 774
 	protected function _payment_log_overview_list_table() {
@@ -794,18 +794,18 @@  discard block
 block discarded – undo
794 794
 	 * @param bool $count
795 795
 	 * @return array
796 796
 	 */
797
-	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){
798
-		EE_Registry::instance()->load_model( 'Change_Log' );
797
+	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) {
798
+		EE_Registry::instance()->load_model('Change_Log');
799 799
 		//we may need to do multiple queries (joining differently), so we actually wan tan array of query params
800
-		$query_params =  array(array('LOG_type'=>  EEM_Change_Log::type_gateway));
800
+		$query_params = array(array('LOG_type'=>  EEM_Change_Log::type_gateway));
801 801
 		//check if they've selected a specific payment method
802
-		if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){
802
+		if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
803 803
 			$query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'],
804 804
 				'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']);
805 805
 		}
806 806
 		//take into account search
807
-		if(isset($this->_req_data['s']) && $this->_req_data['s']){
808
-			$similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%');
807
+		if (isset($this->_req_data['s']) && $this->_req_data['s']) {
808
+			$similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%');
809 809
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
810 810
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
811 811
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
@@ -820,48 +820,48 @@  discard block
 block discarded – undo
820 820
 			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
821 821
 
822 822
 		}
823
-		if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){
823
+		if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) {
824 824
 			//add date
825
-			$start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] );
826
-			$end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] );
825
+			$start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
826
+			$end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
827 827
 			//make sure our timestamps start and end right at the boundaries for each day
828
-			$start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
829
-			$end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
828
+			$start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
829
+			$end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
830 830
 
831 831
 			//convert to timestamps
832
-			$start_date = strtotime( $start_date );
833
-			$end_date = strtotime( $end_date );
832
+			$start_date = strtotime($start_date);
833
+			$end_date = strtotime($end_date);
834 834
 
835 835
 			//makes sure start date is the lowest value and vice versa
836
-			$start_date = min( $start_date, $end_date );
837
-			$end_date = max( $start_date, $end_date );
836
+			$start_date = min($start_date, $end_date);
837
+			$end_date = max($start_date, $end_date);
838 838
 
839 839
 			//convert for query
840
-			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' );
841
-			$end_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' );
840
+			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s');
841
+			$end_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s');
842 842
 
843
-			$query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date));
843
+			$query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
844 844
 
845 845
 		}
846
-		if($count){
846
+		if ($count) {
847 847
 			return EEM_Change_Log::instance()->count($query_params);
848 848
 		}
849
-		if(isset($this->_req_data['order'])){
850
-			$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
849
+		if (isset($this->_req_data['order'])) {
850
+			$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
851 851
 			$query_params['order_by'] = array('LOG_time' => $sort);
852
-		}else{
852
+		} else {
853 853
 				$query_params['order_by'] = array('LOG_time' => 'DESC');
854 854
 		}
855
-		$offset = ($current_page-1)*$per_page;
855
+		$offset = ($current_page - 1) * $per_page;
856 856
 
857
-		if( ! isset($this->_req_data['download_results'])){
858
-			$query_params['limit'] = array( $offset, $per_page );
857
+		if ( ! isset($this->_req_data['download_results'])) {
858
+			$query_params['limit'] = array($offset, $per_page);
859 859
 		}
860 860
 
861 861
 
862 862
 
863 863
 		//now they've requested to instead just download the file instead of viewing it.
864
-		if(isset($this->_req_data['download_results'])){
864
+		if (isset($this->_req_data['download_results'])) {
865 865
 			$wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
866 866
 			header('Content-Disposition: attachment');
867 867
 			header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url()));
@@ -883,36 +883,36 @@  discard block
 block discarded – undo
883 883
 	 * @param EE_Change_Log $logB
884 884
 	 * @return int
885 885
 	 */
886
-	protected function _sort_logs_again($logA,$logB){
886
+	protected function _sort_logs_again($logA, $logB) {
887 887
 		$timeA = $logA->get_raw('LOG_time');
888 888
 		$timeB = $logB->get_raw('LOG_time');
889
-		if($timeA == $timeB){
889
+		if ($timeA == $timeB) {
890 890
 			return 0;
891 891
 		}
892 892
 		$comparison = $timeA < $timeB ? -1 : 1;
893
-		if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){
893
+		if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
894 894
 			return $comparison * -1;
895
-		}else{
895
+		} else {
896 896
 			return $comparison;
897 897
 		}
898 898
 	}
899 899
 
900 900
 	protected function _payment_log_details() {
901
-		EE_Registry::instance()->load_model( 'Change_Log' );
901
+		EE_Registry::instance()->load_model('Change_Log');
902 902
 		/** @var $payment_log EE_Change_Log */
903 903
 		$payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
904 904
 		$payment_method = NULL;
905 905
 		$transaction = NULL;
906
-		if( $payment_log instanceof EE_Change_Log ){
907
-			if( $payment_log->object() instanceof EE_Payment ){
906
+		if ($payment_log instanceof EE_Change_Log) {
907
+			if ($payment_log->object() instanceof EE_Payment) {
908 908
 				$payment_method = $payment_log->object()->payment_method();
909 909
 				$transaction = $payment_log->object()->transaction();
910
-			}elseif($payment_log->object() instanceof EE_Payment_Method){
910
+			}elseif ($payment_log->object() instanceof EE_Payment_Method) {
911 911
 				$payment_method = $payment_log->object();
912 912
 			}
913 913
 		}
914 914
 		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
915
-			EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
915
+			EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php',
916 916
 			array(
917 917
 				'payment_log'=>$payment_log,
918 918
 				'payment_method'=>$payment_method,
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/Prices_List_Table.class.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	protected $_price_types = array();
38 38
 
39
-	public function __construct( $admin_page ) {
39
+	public function __construct($admin_page) {
40 40
 		parent::__construct($admin_page);
41
-		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
41
+		require_once(EE_MODELS.'EEM_Price_Type.model.php');
42 42
 		$this->_PRT = EEM_Price_Type::instance();
43 43
 		$this->_price_types = $this->_PRT->get_all_deleted_and_undeleted();
44 44
 	}
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 
49 49
 	protected function _setup_data() {
50 50
 		$trashed = $this->_admin_page->get_view() == 'trashed' ? true : false;
51
-		$this->_data = $this->_admin_page->get_prices_overview_data( $this->_per_page, false, $trashed );
52
-		$this->_all_data_count = $this->_admin_page->get_prices_overview_data( $this->_per_page, true, false );
53
-		$this->_trashed_count = $this->_admin_page->get_prices_overview_data( $this->_per_page, true, true );
51
+		$this->_data = $this->_admin_page->get_prices_overview_data($this->_per_page, false, $trashed);
52
+		$this->_all_data_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, false);
53
+		$this->_trashed_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, true);
54 54
 	}
55 55
 
56 56
 
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 
75 75
 			$this->_sortable_columns = array(
76 76
 						// true means its already sorted
77
-						'name' => array( 'name' => false ),
78
-						'type' => array( 'type' => false ),
79
-						'amount' => array( 'amount' => false )
77
+						'name' => array('name' => false),
78
+						'type' => array('type' => false),
79
+						'amount' => array('amount' => false)
80 80
 			);
81 81
 
82 82
         $this->_hidden_columns = array(
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
 	protected function _add_view_counts() {
100 100
 		$this->_views['all']['count'] = $this->_all_data_count;
101
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_default_prices', 'pricing_trash_price') ) {
101
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) {
102 102
 			$this->_views['trashed']['count'] = $this->_trashed_count;
103 103
 		}
104 104
 	}
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
 	 * @param  object $item the current item
113 113
 	 * @return string
114 114
 	 */
115
-	protected function _get_row_class( $item ) {
115
+	protected function _get_row_class($item) {
116 116
 		static $row_class = '';
117
-		$row_class = ( $row_class == '' ? 'alternate' : '' );
117
+		$row_class = ($row_class == '' ? 'alternate' : '');
118 118
 
119 119
 		$new_row = $row_class;
120 120
 
121
-		if ( $item->type_obj()->base_type() !== 1 && $item->type_obj()->base_type() !== 4 )
121
+		if ($item->type_obj()->base_type() !== 1 && $item->type_obj()->base_type() !== 4)
122 122
 			$new_row .= ' rowsortable';
123 123
 
124
-		return ' class="' . $new_row . '"';
124
+		return ' class="'.$new_row.'"';
125 125
 	}
126 126
 
127 127
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 
132 132
 
133 133
 	function column_cb($item) {
134
-		if ( $item->type_obj()->base_type() !== 1 )
135
-			return sprintf( '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', /* $1%s */ $item->ID() );
134
+		if ($item->type_obj()->base_type() !== 1)
135
+			return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', /* $1%s */ $item->ID());
136 136
 		return '';
137 137
 	}
138 138
 
@@ -145,31 +145,31 @@  discard block
 block discarded – undo
145 145
 		//Build row actions
146 146
 		$actions = array();
147 147
 		// edit price link
148
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_default_price', 'pricing_edit_price', $item->ID() ) ) {
149
-			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_price', 'id'=>$item->ID() ), PRICING_ADMIN_URL );
150
-			$actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Price', 'event_espresso' ) . '">' . __( 'Edit', 'event_espresso' ) . '</a>';
148
+		if (EE_Registry::instance()->CAP->current_user_can('ee_edit_default_price', 'pricing_edit_price', $item->ID())) {
149
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_price', 'id'=>$item->ID()), PRICING_ADMIN_URL);
150
+			$actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Price', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>';
151 151
 		}
152 152
 
153
-		$name_link = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_default_price', 'edit_price', $item->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Price', 'event_espresso' ) . '">' . stripslashes( $item->name() ) . '</a>' : $item->name();
153
+		$name_link = EE_Registry::instance()->CAP->current_user_can('ee_edit_default_price', 'edit_price', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Price', 'event_espresso').'">'.stripslashes($item->name()).'</a>' : $item->name();
154 154
 
155
-		if ( $item->type_obj()->base_type() !== 1 ) {
155
+		if ($item->type_obj()->base_type() !== 1) {
156 156
 			if ($this->_view == 'all') {
157 157
 				// trash price link
158
-				if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_default_price', 'pricing_trash_price', $item->ID() ) ) {
159
-					$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'trash_price', 'id'=>$item->ID(), 'noheader' => true ), PRICING_ADMIN_URL );
160
-					$actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' . esc_attr__( 'Move Price to Trash', 'event_espresso' ) . '">' . __( 'Move to Trash', 'event_espresso' ) . '</a>';
158
+				if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_price', 'pricing_trash_price', $item->ID())) {
159
+					$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'trash_price', 'id'=>$item->ID(), 'noheader' => true), PRICING_ADMIN_URL);
160
+					$actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Move Price to Trash', 'event_espresso').'">'.__('Move to Trash', 'event_espresso').'</a>';
161 161
 				}
162 162
 			} else {
163
-				if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_default_price', 'pricing_restore_price', $item->ID() ) ) {
163
+				if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_price', 'pricing_restore_price', $item->ID())) {
164 164
 					// restore price link
165
-					$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'restore_price', 'id'=>$item->ID(), 'noheader' => true ), PRICING_ADMIN_URL );
166
-					$actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' . esc_attr__( 'Restore Price', 'event_espresso' ) . '">' . __( 'Restore', 'event_espresso' ) . '</a>';
165
+					$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'restore_price', 'id'=>$item->ID(), 'noheader' => true), PRICING_ADMIN_URL);
166
+					$actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Price', 'event_espresso').'">'.__('Restore', 'event_espresso').'</a>';
167 167
 				}
168 168
 
169 169
 				// delete price link
170
-				if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_default_price', 'pricing_delete_price', $item->ID() ) ) {
171
-					$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'delete_price', 'id'=>$item->ID(), 'noheader' => true ), PRICING_ADMIN_URL );
172
-					$actions['delete'] = '<a href="'.$delete_lnk_url.'" title="' . esc_attr__( 'Delete Price Permanently', 'event_espresso' ) . '">' . __( 'Delete Permanently', 'event_espresso' ) . '</a>';
170
+				if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_price', 'pricing_delete_price', $item->ID())) {
171
+					$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'delete_price', 'id'=>$item->ID(), 'noheader' => true), PRICING_ADMIN_URL);
172
+					$actions['delete'] = '<a href="'.$delete_lnk_url.'" title="'.esc_attr__('Delete Price Permanently', 'event_espresso').'">'.__('Delete Permanently', 'event_espresso').'</a>';
173 173
 				}
174 174
 			}
175 175
 		}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		return sprintf('%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
179 179
 										/* $1%s */ $name_link,
180 180
 										/* $2%s */ $item->ID(),
181
-										/* $3%s */ $this->row_actions( $actions )
181
+										/* $3%s */ $this->row_actions($actions)
182 182
 		);
183 183
 	}
184 184
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
 
197 197
 	function column_description($item) {
198
-		return stripslashes( $item->desc() );
198
+		return stripslashes($item->desc());
199 199
 	}
200 200
 
201 201
 
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 
205 205
 	function column_amount($item) {
206 206
 		if ($this->_price_types[$item->type()]->is_percent()) {
207
-			return '<div class="pad-amnt-rght">' . number_format($item->amount(), 1) . '%</div>';
207
+			return '<div class="pad-amnt-rght">'.number_format($item->amount(), 1).'%</div>';
208 208
 		} else {
209
-			return '<div class="pad-amnt-rght">' . EEH_Template::format_currency( $item->amount() ) . '</div>';
209
+			return '<div class="pad-amnt-rght">'.EEH_Template::format_currency($item->amount()).'</div>';
210 210
 		}
211 211
 	}
212 212
 
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,10 +79,10 @@
 block discarded – undo
79 79
 						'amount' => array( 'amount' => false )
80 80
 			);
81 81
 
82
-        $this->_hidden_columns = array(
82
+		$this->_hidden_columns = array(
83 83
 			);
84 84
 
85
-        $this->_ajax_sorting_callback = 'update_prices_order';
85
+		$this->_ajax_sorting_callback = 'update_prices_order';
86 86
 
87 87
 	}
88 88
 
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/Pricing_Admin_Page.core.php 2 patches
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 * @param bool $routing
32 32
 	 * @return Pricing_Admin_Page
33 33
 	 */
34
-	public function __construct( $routing = TRUE ) {
35
-		parent::__construct( $routing );
34
+	public function __construct($routing = TRUE) {
35
+		parent::__construct($routing);
36 36
 	}
37 37
 
38 38
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 
51 51
 	protected function _ajax_hooks() {
52
-		add_action('wp_ajax_espresso_update_prices_order', array( $this, 'update_price_order' ));
52
+		add_action('wp_ajax_espresso_update_prices_order', array($this, 'update_price_order'));
53 53
 	}
54 54
 
55 55
 
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 	*		@return void
83 83
 	*/
84 84
 	protected function _set_page_routes() {
85
-		$prc_id = ! empty( $this->_req_data['PRC_ID'] ) && ! is_array( $this->_req_data['PRC_ID'] ) ? $this->_req_data['PRC_ID'] : 0;
86
-		$prt_id =  ! empty( $this->_req_data['PRT_ID'] ) && ! is_array( $this->_req_data['PRT_ID'] ) ? $this->_req_data['PRT_ID'] : 0;
85
+		$prc_id = ! empty($this->_req_data['PRC_ID']) && ! is_array($this->_req_data['PRC_ID']) ? $this->_req_data['PRC_ID'] : 0;
86
+		$prt_id = ! empty($this->_req_data['PRT_ID']) && ! is_array($this->_req_data['PRT_ID']) ? $this->_req_data['PRT_ID'] : 0;
87 87
 		$this->_page_routes = array(
88 88
 			'default' => array(
89 89
 					'func' => '_price_overview_list_table',
@@ -91,38 +91,38 @@  discard block
 block discarded – undo
91 91
 				),
92 92
 			'add_new_price'	=> array(
93 93
 					'func' => '_edit_price_details',
94
-					'args' => array( 'new_price' => TRUE ),
94
+					'args' => array('new_price' => TRUE),
95 95
 					'capability' => 'ee_edit_default_prices'
96 96
 				),
97 97
 			'edit_price'	=> array(
98 98
 					'func' => '_edit_price_details',
99
-					'args' => array( 'new_price' => FALSE ),
99
+					'args' => array('new_price' => FALSE),
100 100
 					'capability' => 'ee_edit_default_price',
101 101
 					'obj_id' => $prc_id
102 102
 				),
103 103
 			'insert_price'	=> array(
104 104
 					'func' => '_insert_or_update_price',
105
-					'args' => array( 'new_price' => TRUE ),
105
+					'args' => array('new_price' => TRUE),
106 106
 					'noheader' => TRUE,
107 107
 					'capability' => 'ee_edit_default_prices',
108 108
 				),
109 109
 			'update_price'	=> array(
110 110
 					'func' => '_insert_or_update_price',
111
-					'args' => array( 'new_price' => FALSE ),
111
+					'args' => array('new_price' => FALSE),
112 112
 					'noheader' => TRUE,
113 113
 					'capability' => 'ee_edit_default_price',
114 114
 					'obj_id' => $prc_id
115 115
 				),
116 116
 			'trash_price'	=> array(
117 117
 					'func' => '_trash_or_restore_price',
118
-					'args' => array( 'trash' => TRUE ),
118
+					'args' => array('trash' => TRUE),
119 119
 					'noheader' => TRUE,
120 120
 					'capability' => 'ee_delete_default_price',
121 121
 					'obj_id' => $prc_id
122 122
 				),
123 123
 			'restore_price'	=> array(
124 124
 					'func' => '_trash_or_restore_price',
125
-					'args' => array( 'trash' => FALSE ),
125
+					'args' => array('trash' => FALSE),
126 126
 					'noheader' => TRUE,
127 127
 					'capability' => 'ee_delete_default_price',
128 128
 					'obj_id' => $prc_id
@@ -154,27 +154,27 @@  discard block
 block discarded – undo
154 154
 				),
155 155
 			'insert_price_type'	=> array(
156 156
 					'func' => '_insert_or_update_price_type',
157
-					'args' => array( 'new_price_type' => TRUE ),
157
+					'args' => array('new_price_type' => TRUE),
158 158
 					'noheader' => TRUE,
159 159
 					'capability' => 'ee_edit_default_price_types'
160 160
 				),
161 161
 			'update_price_type' => array(
162 162
 					'func' => '_insert_or_update_price_type',
163
-					'args' => array( 'new_price_type' => FALSE ),
163
+					'args' => array('new_price_type' => FALSE),
164 164
 					'noheader' => TRUE,
165 165
 					'capability' => 'ee_edit_default_price_type',
166 166
 					'obj_id' => $prt_id
167 167
 				),
168 168
 			'trash_price_type'	=> array(
169 169
 					'func' => '_trash_or_restore_price_type',
170
-					'args' => array( 'trash' => TRUE ),
170
+					'args' => array('trash' => TRUE),
171 171
 					'noheader' => TRUE,
172 172
 					'capability' => 'ee_delete_default_price_type',
173 173
 					'obj_id' => $prt_id
174 174
 				),
175 175
 			'restore_price_type'	=> array(
176 176
 					'func' => '_trash_or_restore_price_type',
177
-					'args' => array( 'trash' => FALSE ),
177
+					'args' => array('trash' => FALSE),
178 178
 					'noheader' => TRUE,
179 179
 					'capability' => 'ee_delete_default_price_type',
180 180
 					'obj_id' => $prt_id
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 							'filename' => 'pricing_default_pricing_views_bulk_actions_search'
215 215
 							)
216 216
 						),
217
-					'help_tour' => array( 'Pricing_Default_Prices_Help_Tour'),
217
+					'help_tour' => array('Pricing_Default_Prices_Help_Tour'),
218 218
 					'require_nonce' => FALSE
219 219
 				),
220 220
 			'add_new_price' => array(
@@ -230,24 +230,24 @@  discard block
 block discarded – undo
230 230
 							)
231 231
 						),
232 232
                     'help_tour' => array('Pricing_Add_New_Default_Price_Help_Tour'),
233
-					'metaboxes' => array( '_publish_post_box', '_espresso_news_post_box', '_price_details_meta_boxes' ),
233
+					'metaboxes' => array('_publish_post_box', '_espresso_news_post_box', '_price_details_meta_boxes'),
234 234
 					'require_nonce' => FALSE
235 235
 				),
236 236
 			'edit_price' => array(
237 237
 					'nav' => array(
238 238
 							'label' => __('Edit Default Price', 'event_espresso'),
239 239
 							'order' => 20,
240
-							'url' => isset($this->_req_data['id']) ? add_query_arg(array('id' => $this->_req_data['id'] ), $this->_current_page_view_url )  : $this->_admin_base_url,
240
+							'url' => isset($this->_req_data['id']) ? add_query_arg(array('id' => $this->_req_data['id']), $this->_current_page_view_url) : $this->_admin_base_url,
241 241
 							'persistent' => FALSE
242 242
 						),
243
-					'metaboxes' => array( '_publish_post_box', '_espresso_news_post_box', '_price_details_meta_boxes' ),
243
+					'metaboxes' => array('_publish_post_box', '_espresso_news_post_box', '_price_details_meta_boxes'),
244 244
                     'help_tabs' => array(
245 245
 						'edit_default_price_help_tab' => array(
246 246
 							'title' => __('Edit Default Price', 'event_espresso'),
247 247
 							'filename' => 'pricing_edit_default_price'
248 248
 							)
249 249
 						),
250
-					'help_tour' => array( 'Pricing_Edit_Default_Price_Help_Tour' ),
250
+					'help_tour' => array('Pricing_Edit_Default_Price_Help_Tour'),
251 251
 					'require_nonce' => FALSE
252 252
 				),
253 253
 			'price_types' => array(
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 							'filename' => 'pricing_price_types_views_bulk_actions_search'
271 271
 							),
272 272
 						),
273
-					'help_tour' => array( 'Pricing_Price_Types_Default_Help_Tour' ),
273
+					'help_tour' => array('Pricing_Price_Types_Default_Help_Tour'),
274 274
 					'metaboxes' => array('_espresso_news_post_box', '_espresso_links_post_box'),
275 275
 					'require_nonce' => FALSE
276 276
 				),
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
 							'filename' => 'pricing_add_new_price_type'
287 287
 							)
288 288
 						),
289
-                    'help_tour' => array( 'Pricing_Add_New_Price_Type_Help_Tour' ),
290
-					'metaboxes' => array( '_publish_post_box', '_espresso_news_post_box', '_price_type_details_meta_boxes' ),
289
+                    'help_tour' => array('Pricing_Add_New_Price_Type_Help_Tour'),
290
+					'metaboxes' => array('_publish_post_box', '_espresso_news_post_box', '_price_type_details_meta_boxes'),
291 291
 					'require_nonce' => FALSE
292 292
 				),
293 293
 			'edit_price_type' => array(
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 							'filename' => 'pricing_edit_price_type'
303 303
 							)
304 304
 						),
305
-                    'help_tour' => array( 'Pricing_Edit_Price_Type_Help_Tour' ),
306
-					'metaboxes' => array( '_publish_post_box', '_espresso_news_post_box', '_price_type_details_meta_boxes' ),
305
+                    'help_tour' => array('Pricing_Edit_Price_Type_Help_Tour'),
306
+					'metaboxes' => array('_publish_post_box', '_espresso_news_post_box', '_price_type_details_meta_boxes'),
307 307
 
308 308
 					'require_nonce' => FALSE
309 309
 				)
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	public function load_scripts_styles() {
341 341
 		//styles
342 342
 		wp_enqueue_style('espresso-ui-theme');
343
-		wp_register_style( 'espresso_PRICING', PRICING_ASSETS_URL . 'espresso_pricing_admin.css', array(), EVENT_ESPRESSO_VERSION );
343
+		wp_register_style('espresso_PRICING', PRICING_ASSETS_URL.'espresso_pricing_admin.css', array(), EVENT_ESPRESSO_VERSION);
344 344
 		wp_enqueue_style('espresso_PRICING');
345 345
 
346 346
 		//scripts
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
 		//wp_enqueue_script('jquery-ui-dialog');
351 351
 		//wp_enqueue_script('jquery-ui-draggable');
352 352
 		//wp_enqueue_script('jquery-ui-datepicker');
353
-		wp_register_script( 'espresso_PRICING', PRICING_ASSETS_URL . 'espresso_pricing_admin.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE );
354
-		wp_enqueue_script( 'espresso_PRICING' );
353
+		wp_register_script('espresso_PRICING', PRICING_ASSETS_URL.'espresso_pricing_admin.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
354
+		wp_enqueue_script('espresso_PRICING');
355 355
 	}
356 356
 
357 357
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 
360 360
 
361 361
 	public function load_scripts_styles_default() {
362
-		wp_enqueue_script( 'espresso_ajax_table_sorting' );
362
+		wp_enqueue_script('espresso_ajax_table_sorting');
363 363
 	}
364 364
 
365 365
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 				)
388 388
 		);
389 389
 
390
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_default_prices', 'pricing_trash_price' ) ) {
390
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) {
391 391
 			$this->_views['trashed'] = array(
392 392
 					'slug' => 'trashed',
393 393
 					'label' => __('Trash', 'event_espresso'),
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 				)
418 418
 		);
419 419
 
420
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_default_price_types', 'pricing_trash_price_type' ) ) {
420
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_price_types', 'pricing_trash_price_type')) {
421 421
 			 $this->_views['trashed'] = array(
422 422
 					'slug' => 'trashed',
423 423
 					'label' => __('Trash', 'event_espresso'),
@@ -456,18 +456,18 @@  discard block
 block discarded – undo
456 456
 	* 	@param  boolean $trashed   whether the current view is of the trash can - eww yuck!
457 457
 	* 	@return mixed (int|array)  int = count || array of price objects
458 458
 	*/
459
-	public function get_prices_overview_data( $per_page = 10, $count = FALSE, $trashed = FALSE ) {
459
+	public function get_prices_overview_data($per_page = 10, $count = FALSE, $trashed = FALSE) {
460 460
 
461
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
461
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
462 462
 		// start with an empty array
463 463
 		$event_pricing = array();
464 464
 
465
-		require_once( PRICING_ADMIN . 'Prices_List_Table.class.php' );
466
-		require_once(EE_MODELS . 'EEM_Price.model.php');
465
+		require_once(PRICING_ADMIN.'Prices_List_Table.class.php');
466
+		require_once(EE_MODELS.'EEM_Price.model.php');
467 467
 		//$PRC = EEM_Price::instance();
468 468
 
469 469
 		$this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? '' : $this->_req_data['orderby'];
470
-		$order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC';
470
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
471 471
 
472 472
 		switch ($this->_req_data['orderby']) {
473 473
 			case 'name':
@@ -480,27 +480,27 @@  discard block
 block discarded – undo
480 480
 				$orderby = array('PRC_amount'=>$order);
481 481
 				break;
482 482
 			default:
483
-				$orderby = array( 'PRC_order'=>$order, 'Price_Type.PRT_order'=>$order, 'PRC_ID'=>$order);
483
+				$orderby = array('PRC_order'=>$order, 'Price_Type.PRT_order'=>$order, 'PRC_ID'=>$order);
484 484
 		}
485 485
 
486
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
487
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
486
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
487
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
488 488
 
489 489
 		$_where = array(
490 490
 				'PRC_is_default' => 1,
491 491
 				'PRC_deleted' => $trashed
492 492
 				);
493 493
 
494
-		$offset = ($current_page-1)*$per_page;
495
-		$limit = array( $offset, $per_page );
494
+		$offset = ($current_page - 1) * $per_page;
495
+		$limit = array($offset, $per_page);
496 496
 
497
-		if ( isset( $this->_req_data['s'] ) ) {
498
-			$sstr = '%' . $this->_req_data['s'] . '%';
497
+		if (isset($this->_req_data['s'])) {
498
+			$sstr = '%'.$this->_req_data['s'].'%';
499 499
 			$_where['OR'] = array(
500
-				'PRC_name' => array('LIKE',$sstr ),
501
-				'PRC_desc' => array('LIKE',$sstr ),
502
-				'PRC_amount' => array( 'LIKE',$sstr ),
503
-				'Price_Type.PRT_name' => array( 'LIKE', $sstr )
500
+				'PRC_name' => array('LIKE', $sstr),
501
+				'PRC_desc' => array('LIKE', $sstr),
502
+				'PRC_amount' => array('LIKE', $sstr),
503
+				'Price_Type.PRT_name' => array('LIKE', $sstr)
504 504
 				);
505 505
 		}
506 506
 
@@ -511,9 +511,9 @@  discard block
 block discarded – undo
511 511
 			'group_by'=>'PRC_ID'
512 512
 			);
513 513
 
514
-		if($count){
515
-			return $trashed ? EEM_Price::instance()->count( array( $_where ) ) : EEM_Price::instance()->count_deleted_and_undeleted(array($_where));
516
-		}else{
514
+		if ($count) {
515
+			return $trashed ? EEM_Price::instance()->count(array($_where)) : EEM_Price::instance()->count_deleted_and_undeleted(array($_where));
516
+		} else {
517 517
 			return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params);
518 518
 		}
519 519
 	}
@@ -529,40 +529,40 @@  discard block
 block discarded – undo
529 529
 	*		@return void
530 530
 	*/
531 531
 	protected function _edit_price_details() {
532
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
532
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
533 533
 		// grab price ID
534
-		$PRC_ID = isset( $this->_req_data['id'] ) && ! empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : FALSE;
534
+		$PRC_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : FALSE;
535 535
 		// change page title based on request action
536
-		$this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action ));
536
+		$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
537 537
 		// add PRC_ID to title if editing
538
-		$this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
538
+		$this->_admin_page_title = $PRC_ID ? $this->_admin_page_title.' # '.$PRC_ID : $this->_admin_page_title;
539 539
 
540 540
 		// get prices
541
-		require_once(EE_MODELS . 'EEM_Price.model.php');
541
+		require_once(EE_MODELS.'EEM_Price.model.php');
542 542
 		$PRC = EEM_Price::instance();
543 543
 
544
-		if ( $PRC_ID ) {
545
-			$price = $PRC->get_one_by_ID( $PRC_ID );
544
+		if ($PRC_ID) {
545
+			$price = $PRC->get_one_by_ID($PRC_ID);
546 546
 			$additional_hidden_fields = array(
547
-					'PRC_ID' => array( 'type' => 'hidden', 'value' => $PRC_ID )
547
+					'PRC_ID' => array('type' => 'hidden', 'value' => $PRC_ID)
548 548
 				);
549
-			$this->_set_add_edit_form_tags( 'update_price', $additional_hidden_fields );
549
+			$this->_set_add_edit_form_tags('update_price', $additional_hidden_fields);
550 550
 		} else {
551 551
 			$price = $PRC->get_new_price();
552
-			$this->_set_add_edit_form_tags( 'insert_price' );
552
+			$this->_set_add_edit_form_tags('insert_price');
553 553
 		}
554 554
 
555 555
 		$this->_template_args['PRC_ID'] = $PRC_ID;
556 556
 		$this->_template_args['price'] = $price;
557 557
 
558 558
 		// get price types
559
-		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
559
+		require_once(EE_MODELS.'EEM_Price_Type.model.php');
560 560
 		$PRT = EEM_Price_Type::instance();
561
-		$price_types = $PRT->get_all( array( array('PBT_ID' => array('!=', 1 ) ) ) );
561
+		$price_types = $PRT->get_all(array(array('PBT_ID' => array('!=', 1))));
562 562
 		$price_type_names = array();
563 563
 		if (empty($price_types)) {
564
-			$msg = __( 'You have no price types defined. Please add a price type before adding a price.', 'event_espresso' );
565
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
564
+			$msg = __('You have no price types defined. Please add a price type before adding a price.', 'event_espresso');
565
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
566 566
 			exit();
567 567
 		} else {
568 568
 			foreach ($price_types as $type) {
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 		$this->_template_args['price_types'] = $price_type_names;
576 576
 		$this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
577 577
 
578
-		$this->_set_publish_post_box_vars( 'id', $PRC_ID );
578
+		$this->_set_publish_post_box_vars('id', $PRC_ID);
579 579
 		// the details template wrapper
580 580
 		$this->display_admin_page_with_sidebar();
581 581
 	}
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 	*		@return void
592 592
 	*/
593 593
 	protected function _price_details_meta_boxes() {
594
-		add_meta_box( 'edit-price-details-mbox', __( 'Default Price Details', 'event_espresso' ), array( $this, '_edit_price_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
594
+		add_meta_box('edit-price-details-mbox', __('Default Price Details', 'event_espresso'), array($this, '_edit_price_details_meta_box'), $this->wp_page_slug, 'normal', 'high');
595 595
 	}
596 596
 
597 597
 
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 	*		@return void
606 606
 	*/
607 607
 	public function _edit_price_details_meta_box() {
608
-		echo EEH_Template::display_template( PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php', $this->_template_args, TRUE );
608
+		echo EEH_Template::display_template(PRICING_TEMPLATE_PATH.'pricing_details_main_meta_box.template.php', $this->_template_args, TRUE);
609 609
 	}
610 610
 
611 611
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	*/
620 620
 	protected function set_price_column_values() {
621 621
 
622
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
622
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
623 623
 
624 624
 		$set_column_values = array(
625 625
 				'PRT_ID' => absint($this->_req_data['PRT_ID']),
@@ -647,12 +647,12 @@  discard block
 block discarded – undo
647 647
 	*		@access protected
648 648
 	*		@return void
649 649
 	*/
650
-	protected function _insert_or_update_price( $insert = FALSE ) {
650
+	protected function _insert_or_update_price($insert = FALSE) {
651 651
 
652 652
 		//echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
653
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
653
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
654 654
 
655
-		require_once(EE_MODELS . 'EEM_Price.model.php');
655
+		require_once(EE_MODELS.'EEM_Price.model.php');
656 656
 		$PRC = EEM_Price::instance();
657 657
 
658 658
 		// why be so pessimistic ???  : (
@@ -660,14 +660,14 @@  discard block
 block discarded – undo
660 660
 
661 661
 		$set_column_values = $this->set_price_column_values();
662 662
 		// is this a new Price ?
663
-		if ( $insert ) {
663
+		if ($insert) {
664 664
 			// run the insert
665
-			if ( $PRC_ID = $PRC->insert( $set_column_values )) {
665
+			if ($PRC_ID = $PRC->insert($set_column_values)) {
666 666
 				//make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type
667 667
 				$PR = EEM_price::instance()->get_one_by_ID($PRC_ID);
668
-				if ( $PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax ) {
668
+				if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
669 669
 					$ticket = EEM_Ticket::instance()->get_one_by_ID(1);
670
-					$ticket->_add_relation_to( $PR, 'Price' );
670
+					$ticket->_add_relation_to($PR, 'Price');
671 671
 					$ticket->save();
672 672
 				}
673 673
 				$success = 1;
@@ -677,29 +677,29 @@  discard block
 block discarded – undo
677 677
 			}
678 678
 			$action_desc = 'created';
679 679
 		} else {
680
-			$PRC_ID = absint( $this->_req_data['PRC_ID'] );
680
+			$PRC_ID = absint($this->_req_data['PRC_ID']);
681 681
 			// run the update
682
-			$where_cols_n_values = array( 'PRC_ID' => $PRC_ID );
683
-			if ( $PRC->update( $set_column_values, array($where_cols_n_values))) {
682
+			$where_cols_n_values = array('PRC_ID' => $PRC_ID);
683
+			if ($PRC->update($set_column_values, array($where_cols_n_values))) {
684 684
 				$success = 1;
685 685
 			}
686 686
 
687 687
 			$PR = EEM_Price::instance()->get_one_by_ID($PRC_ID);
688
-			if ( $PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax ) {
688
+			if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
689 689
 
690 690
 				//if this is $PRC_ID == 1, then we need to update the default ticket attached to this price so the TKT_price value is updated.
691
-				if ( $PRC_ID === 1 ) {
691
+				if ($PRC_ID === 1) {
692 692
 					$ticket = $PR->get_first_related('Ticket');
693
-					if ( $ticket ) {
694
-						$ticket->set('TKT_price', $PR->get('PRC_amount') );
695
-						$ticket->set('TKT_name', $PR->get('PRC_name') );
693
+					if ($ticket) {
694
+						$ticket->set('TKT_price', $PR->get('PRC_amount'));
695
+						$ticket->set('TKT_name', $PR->get('PRC_name'));
696 696
 						$ticket->set('TKT_description', $PR->get('PRC_desc'));
697 697
 						$ticket->save();
698 698
 					}
699 699
 				} else {
700 700
 					//we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type.
701 701
 					$ticket = EEM_Ticket::instance()->get_one_by_ID(1);
702
-					$ticket->_add_relation_to( $PRC_ID, 'Price' );
702
+					$ticket->_add_relation_to($PRC_ID, 'Price');
703 703
 					$ticket->save();
704 704
 				}
705 705
 			}
@@ -707,9 +707,9 @@  discard block
 block discarded – undo
707 707
 			$action_desc = 'updated';
708 708
 		}
709 709
 
710
-		$query_args = array( 'action' => 'edit_price', 'id' => $PRC_ID );
710
+		$query_args = array('action' => 'edit_price', 'id' => $PRC_ID);
711 711
 
712
-		$this->_redirect_after_action( $success, 'Prices', $action_desc, $query_args );
712
+		$this->_redirect_after_action($success, 'Prices', $action_desc, $query_args);
713 713
 
714 714
 	}
715 715
 
@@ -723,12 +723,12 @@  discard block
 block discarded – undo
723 723
 	*		@access protected
724 724
 	*		@return void
725 725
 	*/
726
-	protected function _trash_or_restore_price( $trash = TRUE ) {
726
+	protected function _trash_or_restore_price($trash = TRUE) {
727 727
 
728 728
 		//echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
729
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
729
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
730 730
 
731
-		require_once(EE_MODELS . 'EEM_Price.model.php');
731
+		require_once(EE_MODELS.'EEM_Price.model.php');
732 732
 		$PRC = EEM_Price::instance();
733 733
 
734 734
 		$success = 1;
@@ -737,18 +737,18 @@  discard block
 block discarded – undo
737 737
 		//get base ticket for updating
738 738
 		$ticket = EEM_Ticket::instance()->get_one_by_ID(1);
739 739
 		//Checkboxes
740
-		if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
740
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
741 741
 			// if array has more than one element than success message should be plural
742
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
742
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
743 743
 			// cycle thru checkboxes
744
-			while (list( $PRC_ID, $value ) = each($this->_req_data['checkbox'])) {
745
-				if ( ! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), absint($PRC_ID) ) ) {
744
+			while (list($PRC_ID, $value) = each($this->_req_data['checkbox'])) {
745
+				if ( ! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), absint($PRC_ID))) {
746 746
 					$success = 0;
747 747
 				} else {
748 748
 					$PR = EEM_Price::instance()->get_one_by_ID($PRC_ID);
749
-					if ( $PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax ) {
749
+					if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
750 750
 						//if trashing then remove relations to base default ticket.  If restoring then add back to base default ticket
751
-						if ( $PRC_deleted ) {
751
+						if ($PRC_deleted) {
752 752
 							$ticket->_remove_relation_to($PRC_ID, 'Price');
753 753
 						} else {
754 754
 							$ticket->_add_relation_to($PRC_ID, 'Price');
@@ -760,14 +760,14 @@  discard block
 block discarded – undo
760 760
 
761 761
 		} else {
762 762
 			// grab single id and delete
763
-			$PRC_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0;
764
-			if ( empty( $PRC_ID ) || ! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), $PRC_ID) ) {
763
+			$PRC_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
764
+			if (empty($PRC_ID) || ! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), $PRC_ID)) {
765 765
 				$success = 0;
766 766
 			} else {
767 767
 				$PR = EEM_Price::instance()->get_one_by_ID($PRC_ID);
768
-				if ( $PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax ) {
768
+				if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
769 769
 					//if trashing then remove relations to base default ticket.  If restoring then add back to base default ticket
770
-					if ( $PRC_deleted ) {
770
+					if ($PRC_deleted) {
771 771
 						$ticket->_remove_relation_to($PRC_ID, 'Price');
772 772
 					} else {
773 773
 						$ticket->_add_relation_to($PRC_ID, 'Price');
@@ -781,17 +781,17 @@  discard block
 block discarded – undo
781 781
 			'action' => 'default'
782 782
 			);
783 783
 
784
-		if ( $success ) {
785
-			if ( $trash ) {
784
+		if ($success) {
785
+			if ($trash) {
786 786
 				$msg = $success == 2 ? __('The Prices have been trashed.', 'event_espresso') : __('The Price has been trashed.', 'event_espresso');
787 787
 			} else {
788 788
 				$msg = $success == 2 ? __('The Prices have been restored.', 'event_espresso') : __('The Price has been restored.', 'event_espresso');
789 789
 			}
790 790
 
791
-			EE_Error::add_success( $msg );
791
+			EE_Error::add_success($msg);
792 792
 		}
793 793
 
794
-		$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
794
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
795 795
 
796 796
 	}
797 797
 
@@ -808,19 +808,19 @@  discard block
 block discarded – undo
808 808
 	protected function _delete_price() {
809 809
 
810 810
 		//echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
811
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
811
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
812 812
 
813
-		require_once(EE_MODELS . 'EEM_Price.model.php');
813
+		require_once(EE_MODELS.'EEM_Price.model.php');
814 814
 		$PRC = EEM_Price::instance();
815 815
 
816 816
 		$success = 1;
817 817
 		//Checkboxes
818
-		if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
818
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
819 819
 			// if array has more than one element than success message should be plural
820
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
820
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
821 821
 			// cycle thru bulk action checkboxes
822
-			while (list( $PRC_ID, $value ) = each($this->_req_data['checkbox'])) {
823
-				if (!$PRC->delete_permanently_by_ID(absint($PRC_ID))) {
822
+			while (list($PRC_ID, $value) = each($this->_req_data['checkbox'])) {
823
+				if ( ! $PRC->delete_permanently_by_ID(absint($PRC_ID))) {
824 824
 					$success = 0;
825 825
 				}
826 826
 			}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 
835 835
 		}
836 836
 
837
-		$this->_redirect_after_action( $success, 'Prices', 'deleted', array() );
837
+		$this->_redirect_after_action($success, 'Prices', 'deleted', array());
838 838
 
839 839
 	}
840 840
 
@@ -842,16 +842,16 @@  discard block
 block discarded – undo
842 842
 
843 843
 
844 844
 	public function update_price_order() {
845
-		$success = __( 'Price order was updated successfully.', 'event_espresso' );
845
+		$success = __('Price order was updated successfully.', 'event_espresso');
846 846
 
847 847
 		// grab our row IDs
848
-		$row_ids = isset( $this->_req_data['row_ids'] ) && ! empty( $this->_req_data['row_ids'] ) ? explode( ',', rtrim( $this->_req_data['row_ids'], ',' )) : FALSE;
848
+		$row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) ? explode(',', rtrim($this->_req_data['row_ids'], ',')) : FALSE;
849 849
 
850
-		if ( is_array( $row_ids )) {
851
-			for ( $i = 0; $i < count( $row_ids ); $i++ ) {
850
+		if (is_array($row_ids)) {
851
+			for ($i = 0; $i < count($row_ids); $i++) {
852 852
 				//Update the prices when re-ordering
853 853
 				$id = absint($row_ids[$i]);
854
-				if ( EEM_Price::instance()->update ( array( 'PRC_order' => $i+1 ), array(array( 'PRC_ID' => $id ) )) === FALSE ) {
854
+				if (EEM_Price::instance()->update(array('PRC_order' => $i + 1), array(array('PRC_ID' => $id))) === FALSE) {
855 855
 					$success = FALSE;
856 856
 				}
857 857
 			}
@@ -859,9 +859,9 @@  discard block
 block discarded – undo
859 859
 			$success = FALSE;
860 860
 		}
861 861
 
862
-		$errors = ! $success ? __( 'An error occurred. The price order was not updated.', 'event_espresso' ) : FALSE;
862
+		$errors = ! $success ? __('An error occurred. The price order was not updated.', 'event_espresso') : FALSE;
863 863
 
864
-		echo json_encode( array( 'return_data' => FALSE, 'success' => $success, 'errors' => $errors ));
864
+		echo json_encode(array('return_data' => FALSE, 'success' => $success, 'errors' => $errors));
865 865
 		die();
866 866
 	}
867 867
 
@@ -904,46 +904,46 @@  discard block
 block discarded – undo
904 904
 	* 	@param  boolean $trashed   whether the current view is of the trash can - eww yuck!
905 905
 	* 	@return mixed (int|array)  int = count || array of price objects
906 906
 	*/
907
-	public function get_price_types_overview_data( $per_page = 10, $count = FALSE, $trashed = FALSE ) {
907
+	public function get_price_types_overview_data($per_page = 10, $count = FALSE, $trashed = FALSE) {
908 908
 
909
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
909
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
910 910
 		// start with an empty array
911 911
 
912
-		require_once( PRICING_ADMIN . 'Price_Types_List_Table.class.php' );
913
-		require_once( EE_MODELS . 'EEM_Price_Type.model.php' );
912
+		require_once(PRICING_ADMIN.'Price_Types_List_Table.class.php');
913
+		require_once(EE_MODELS.'EEM_Price_Type.model.php');
914 914
 
915 915
 		$this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? '' : $this->_req_data['orderby'];
916
-		$order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC';
916
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
917 917
 		switch ($this->_req_data['orderby']) {
918 918
 			case 'name':
919
-				$orderby = array( 'PRT_name' => $order);
919
+				$orderby = array('PRT_name' => $order);
920 920
 				break;
921 921
 			default:
922
-				$orderby = array( 'PRT_order' => $order);
922
+				$orderby = array('PRT_order' => $order);
923 923
 		}
924 924
 
925 925
 
926
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
927
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
926
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
927
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
928 928
 
929
-		$offset = ($current_page-1)*$per_page;
930
-		$limit = array( $offset, $per_page );
929
+		$offset = ($current_page - 1) * $per_page;
930
+		$limit = array($offset, $per_page);
931 931
 
932
-		$_where = array('PRT_deleted'=>$trashed, 'PBT_ID' => array('!=', 1 ) );
932
+		$_where = array('PRT_deleted'=>$trashed, 'PBT_ID' => array('!=', 1));
933 933
 
934
-		if ( isset( $this->_req_data['s'] ) ) {
935
-			$sstr = '%' . $this->_req_data['s'] . '%';
934
+		if (isset($this->_req_data['s'])) {
935
+			$sstr = '%'.$this->_req_data['s'].'%';
936 936
 			$_where['OR'] = array(
937
-				'PRT_name' => array( 'LIKE', $sstr )
937
+				'PRT_name' => array('LIKE', $sstr)
938 938
 				);
939 939
 		}
940 940
 		$query_params = array(
941 941
 			$_where,
942 942
 			'order_by'=>$orderby,
943 943
 			'limit'=>$limit);
944
-		if($count){
944
+		if ($count) {
945 945
 			return EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params);
946
-		}else{
946
+		} else {
947 947
 			return EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params);
948 948
 		}
949 949
 
@@ -963,25 +963,25 @@  discard block
 block discarded – undo
963 963
 	*/
964 964
 	protected function _edit_price_type_details() {
965 965
 
966
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
966
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
967 967
 
968 968
 
969 969
 		// grab price type ID
970
-		$PRT_ID = isset( $this->_req_data['id'] ) && ! empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : FALSE;
970
+		$PRT_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : FALSE;
971 971
 		// change page title based on request action
972
-		$this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action ));
972
+		$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
973 973
 		// add PRT_ID to title if editing
974
-		$this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
974
+		$this->_admin_page_title = $PRT_ID ? $this->_admin_page_title.' # '.$PRT_ID : $this->_admin_page_title;
975 975
 
976 976
 //		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
977 977
 
978
-		if ( $PRT_ID ) {
979
-			$price_type = EEM_Price_Type::instance()->get_one_by_ID( $PRT_ID );
980
-			$additional_hidden_fields = array( 'PRT_ID' => array( 'type' => 'hidden', 'value' => $PRT_ID ));
981
-			$this->_set_add_edit_form_tags( 'update_price_type', $additional_hidden_fields );
978
+		if ($PRT_ID) {
979
+			$price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
980
+			$additional_hidden_fields = array('PRT_ID' => array('type' => 'hidden', 'value' => $PRT_ID));
981
+			$this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields);
982 982
 		} else {
983 983
 			$price_type = EEM_Price_Type::instance()->get_new_price_type();
984
-			$this->_set_add_edit_form_tags( 'insert_price_type' );
984
+			$this->_set_add_edit_form_tags('insert_price_type');
985 985
 		}
986 986
 
987 987
 		$this->_template_args['PRT_ID'] = $PRT_ID;
@@ -990,19 +990,19 @@  discard block
 block discarded – undo
990 990
 
991 991
 		$base_types = EEM_Price_Type::instance()->get_base_types();
992 992
 		$select_values = array();
993
-		foreach ( $base_types as $ref => $text ) {
994
-			if ( $ref == EEM_Price_Type::base_type_base_price ) {
993
+		foreach ($base_types as $ref => $text) {
994
+			if ($ref == EEM_Price_Type::base_type_base_price) {
995 995
 				//do not allow creation of base_type_base_prices because that's a system only base type.
996 996
 				continue;
997 997
 			}
998
-			$values[] = array( 'id' => $ref, 'text' => $text );
998
+			$values[] = array('id' => $ref, 'text' => $text);
999 999
 		}
1000 1000
 
1001 1001
 
1002 1002
 		$this->_template_args['base_type_select'] = EEH_Form_Fields::select_input('base_type', $values, $price_type->base_type(), 'id="price-type-base-type-slct"');
1003 1003
 		$this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
1004
-		$redirect_URL = add_query_arg( array( 'action' => 'price_types'), $this->_admin_base_url );
1005
-		$this->_set_publish_post_box_vars( 'id', $PRT_ID, FALSE, $redirect_URL );
1004
+		$redirect_URL = add_query_arg(array('action' => 'price_types'), $this->_admin_base_url);
1005
+		$this->_set_publish_post_box_vars('id', $PRT_ID, FALSE, $redirect_URL);
1006 1006
 		// the details template wrapper
1007 1007
 		$this->display_admin_page_with_sidebar();
1008 1008
 
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 	*		@return void
1020 1020
 	*/
1021 1021
 	protected function _price_type_details_meta_boxes() {
1022
-		add_meta_box( 'edit-price-details-mbox', __( 'Price Type Details', 'event_espresso' ), array( $this, '_edit_price_type_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1022
+		add_meta_box('edit-price-details-mbox', __('Price Type Details', 'event_espresso'), array($this, '_edit_price_type_details_meta_box'), $this->wp_page_slug, 'normal', 'high');
1023 1023
 	}
1024 1024
 
1025 1025
 
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 	*		@return void
1033 1033
 	*/
1034 1034
 	public function _edit_price_type_details_meta_box() {
1035
-		echo EEH_Template::display_template( PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php', $this->_template_args, TRUE );
1035
+		echo EEH_Template::display_template(PRICING_TEMPLATE_PATH.'pricing_type_details_main_meta_box.template.php', $this->_template_args, TRUE);
1036 1036
 	}
1037 1037
 
1038 1038
 
@@ -1045,9 +1045,9 @@  discard block
 block discarded – undo
1045 1045
 	*/
1046 1046
 	protected function set_price_type_column_values() {
1047 1047
 
1048
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1048
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1049 1049
 
1050
-		$base_type = !empty( $this->_req_data['base_type'] ) ? $this->_req_data['base_type'] : EEM_Price_Type::base_type_base_price;
1050
+		$base_type = ! empty($this->_req_data['base_type']) ? $this->_req_data['base_type'] : EEM_Price_Type::base_type_base_price;
1051 1051
 
1052 1052
 		switch ($base_type) {
1053 1053
 
@@ -1094,12 +1094,12 @@  discard block
 block discarded – undo
1094 1094
 	*		@access protected
1095 1095
 	*		@return void
1096 1096
 	*/
1097
-	protected function _insert_or_update_price_type( $new_price_type = FALSE ) {
1097
+	protected function _insert_or_update_price_type($new_price_type = FALSE) {
1098 1098
 
1099 1099
 //		echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
1100
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1100
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1101 1101
 
1102
-		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
1102
+		require_once(EE_MODELS.'EEM_Price_Type.model.php');
1103 1103
 		$PRT = EEM_Price_Type::instance();
1104 1104
 
1105 1105
 		// why be so pessimistic ???  : (
@@ -1107,24 +1107,24 @@  discard block
 block discarded – undo
1107 1107
 
1108 1108
 		$set_column_values = $this->set_price_type_column_values();
1109 1109
 		// is this a new Price ?
1110
-		if ( $new_price_type ) {
1110
+		if ($new_price_type) {
1111 1111
 			// run the insert
1112
-			if ( $PRT_ID = $PRT->insert( $set_column_values )) {
1112
+			if ($PRT_ID = $PRT->insert($set_column_values)) {
1113 1113
 				$success = 1;
1114 1114
 			}
1115 1115
 			$action_desc = 'created';
1116 1116
 		} else {
1117 1117
 			$PRT_ID = absint($this->_req_data['PRT_ID']);
1118 1118
 			// run the update
1119
-			$where_cols_n_values = array('PRT_ID' => $PRT_ID );
1120
-			if ( $PRT->update( $set_column_values, array( $where_cols_n_values ))) {
1119
+			$where_cols_n_values = array('PRT_ID' => $PRT_ID);
1120
+			if ($PRT->update($set_column_values, array($where_cols_n_values))) {
1121 1121
 				$success = 1;
1122 1122
 			}
1123 1123
 			$action_desc = 'updated';
1124 1124
 		}
1125 1125
 
1126
-		$query_args = array( 'action'=> 'edit_price_type', 'id' => $PRT_ID );
1127
-		$this->_redirect_after_action( $success, 'Price Type', $action_desc, $query_args );
1126
+		$query_args = array('action'=> 'edit_price_type', 'id' => $PRT_ID);
1127
+		$this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args);
1128 1128
 
1129 1129
 	}
1130 1130
 
@@ -1138,49 +1138,49 @@  discard block
 block discarded – undo
1138 1138
 	*		@access protected
1139 1139
 	*		@return void
1140 1140
 	*/
1141
-	protected function _trash_or_restore_price_type( $trash = TRUE ) {
1141
+	protected function _trash_or_restore_price_type($trash = TRUE) {
1142 1142
 
1143 1143
 		//echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
1144
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1144
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1145 1145
 
1146
-		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
1146
+		require_once(EE_MODELS.'EEM_Price_Type.model.php');
1147 1147
 		$PRT = EEM_Price_Type::instance();
1148 1148
 
1149 1149
 		$success = 1;
1150 1150
 		$PRT_deleted = $trash ? TRUE : FALSE;
1151 1151
 		//Checkboxes
1152
-		if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1152
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1153 1153
 			// if array has more than one element than success message should be plural
1154
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
1155
-			$what = count( $this->_req_data['checkbox'] ) > 1 ? 'Price Types' : 'Price Type';
1154
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1155
+			$what = count($this->_req_data['checkbox']) > 1 ? 'Price Types' : 'Price Type';
1156 1156
 			// cycle thru checkboxes
1157
-			while (list( $PRT_ID, $value ) = each($this->_req_data['checkbox'])) {
1158
-				if ( ! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID ) ) {
1157
+			while (list($PRT_ID, $value) = each($this->_req_data['checkbox'])) {
1158
+				if ( ! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID)) {
1159 1159
 					$success = 0;
1160 1160
 				}
1161 1161
 			}
1162 1162
 
1163 1163
 		} else {
1164 1164
 			// grab single id and delete
1165
-			$PRT_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0;
1166
-			if ( empty( $PRT_ID ) || ! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID )) {
1165
+			$PRT_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
1166
+			if (empty($PRT_ID) || ! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID)) {
1167 1167
 				$success = 0;
1168 1168
 			}
1169 1169
 			$what = 'Price Type';
1170 1170
 
1171 1171
 		}
1172 1172
 
1173
-		$query_args = array( 'action' => 'price_types' );
1174
-		if ( $success ) {
1175
-			if ( $trash ) {
1173
+		$query_args = array('action' => 'price_types');
1174
+		if ($success) {
1175
+			if ($trash) {
1176 1176
 				$msg = $success > 1 ? __('The Price Types have been trashed.', 'event_espresso') : __('The Price Type has been trashed.', 'event_espresso');
1177 1177
 			} else {
1178 1178
 				$msg = $success > 1 ? __('The Price Types have been restored.', 'event_espresso') : __('The Price Type has been restored.', 'event_espresso');
1179 1179
 			}
1180
-			EE_Error::add_success( $msg );
1180
+			EE_Error::add_success($msg);
1181 1181
 		}
1182 1182
 
1183
-		$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
1183
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
1184 1184
 
1185 1185
 	}
1186 1186
 
@@ -1197,19 +1197,19 @@  discard block
 block discarded – undo
1197 1197
 	protected function _delete_price_type() {
1198 1198
 
1199 1199
 		//echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
1200
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1200
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1201 1201
 
1202 1202
 		$PRT = EEM_Price_Type::instance();
1203 1203
 
1204 1204
 		$success = 1;
1205 1205
 		//Checkboxes
1206
-		if (!empty($this->_req_data['checkbox'])) {
1206
+		if ( ! empty($this->_req_data['checkbox'])) {
1207 1207
 			// if array has more than one element than success message should be plural
1208
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
1208
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1209 1209
 			$what = $PRT->item_name($success);
1210 1210
 			// cycle thru bulk action checkboxes
1211
-			while (list( $PRT_ID, $value ) = each($this->_req_data['checkbox'])) {
1212
-				if (!$PRT->delete_permanently_by_ID($PRT_ID) ) {
1211
+			while (list($PRT_ID, $value) = each($this->_req_data['checkbox'])) {
1212
+				if ( ! $PRT->delete_permanently_by_ID($PRT_ID)) {
1213 1213
 					$success = 0;
1214 1214
 				}
1215 1215
 			}
@@ -1217,8 +1217,8 @@  discard block
 block discarded – undo
1217 1217
 		}
1218 1218
 
1219 1219
 
1220
-		$query_args = array( 'action'=> 'price_types' );
1221
-		$this->_redirect_after_action( $success, $what, 'deleted', $query_args );
1220
+		$query_args = array('action'=> 'price_types');
1221
+		$this->_redirect_after_action($success, $what, 'deleted', $query_args);
1222 1222
 
1223 1223
 	}
1224 1224
 
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
 	*		@return string
1235 1235
 	*/
1236 1236
 	protected function _learn_more_about_pricing_link() {
1237
-		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how pricing works', 'event_espresso') . '</a>';
1237
+		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how pricing works', 'event_espresso').'</a>';
1238 1238
 	}
1239 1239
 
1240 1240
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
@@ -545,7 +547,7 @@  discard block
 block discarded – undo
545 547
 
546 548
 		if($count){
547 549
 			return $trashed ? EEM_Price::instance()->count( array( $_where ) ) : EEM_Price::instance()->count_deleted_and_undeleted(array($_where));
548
-		}else{
550
+		} else{
549 551
 			return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params);
550 552
 		}
551 553
 	}
@@ -989,7 +991,7 @@  discard block
 block discarded – undo
989 991
 			'limit'=>$limit);
990 992
 		if($count){
991 993
 			return EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params);
992
-		}else{
994
+		} else{
993 995
 			return EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params);
994 996
 		}
995 997
 
Please login to merge, or discard this patch.
admin/extend/registration_form/Extend_Registration_Form_Admin_Page.core.php 3 patches
Spacing   +163 added lines, -163 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
 /**
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 
31 31
 
32 32
 
33
-	public function __construct( $routing = TRUE ) {
34
-		define( 'REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS );
35
-		define( 'REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS );
36
-		define( 'REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/' );
37
-		define( 'REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS );
38
-		define( 'REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/' );
39
-		parent::__construct( $routing );
33
+	public function __construct($routing = TRUE) {
34
+		define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form'.DS);
35
+		define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets'.DS);
36
+		define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/');
37
+		define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates'.DS);
38
+		define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/');
39
+		parent::__construct($routing);
40 40
 	}
41 41
 
42 42
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 
47 47
 	protected function _extend_page_config() {
48 48
 		$this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
49
-		$qst_id = ! empty( $this->_req_data['QST_ID'] ) && ! is_array( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0;
50
-		$qsg_id = ! empty( $this->_req_data['QSG_ID'] ) && ! is_array( $this->_req_data['QSG_ID'] ) ? $this->_req_data['QSG_ID'] : 0;
49
+		$qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
50
+		$qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0;
51 51
 
52 52
 		$new_page_routes = array(
53 53
 			'question_groups' => array(
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 				'func' => '_trash_or_restore_questions',
81 81
 				'capability' => 'ee_delete_question',
82 82
 				'obj_id' => $qst_id,
83
-				'args' => array( 'trash' => FALSE ),
83
+				'args' => array('trash' => FALSE),
84 84
 				'noheader' => TRUE
85 85
 				),
86 86
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
 			'trash_question_group' => array(
141 141
 				'func' => '_trash_or_restore_question_groups',
142
-				'args' => array( 'trash' => TRUE ),
142
+				'args' => array('trash' => TRUE),
143 143
 				'capability' => 'ee_delete_question_group',
144 144
 				'obj_id' => $qsg_id,
145 145
 				'noheader' => TRUE
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
 			'restore_question_group' => array(
149 149
 				'func' => '_trash_or_restore_question_groups',
150
-				'args' => array( 'trash' => FALSE ),
150
+				'args' => array('trash' => FALSE),
151 151
 				'capability' => 'ee_delete_question_group',
152 152
 				'obj_id' => $qsg_id,
153 153
 				'noheader' => TRUE
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
 			'update_question_group' => array(
164 164
 				'func' => '_insert_or_update_question_group',
165
-				'args' => array('new_question_group' => FALSE ),
165
+				'args' => array('new_question_group' => FALSE),
166 166
 				'capability' => 'ee_edit_question_group',
167 167
 				'obj_id' => $qsg_id,
168 168
 				'noheader' => TRUE,
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 					'noheader' => TRUE
201 201
 				),
202 202
 			);
203
-		$this->_page_routes = array_merge( $this->_page_routes, $new_page_routes );
203
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
204 204
 
205 205
 		$new_page_config = array(
206 206
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 						'filename' => 'registration_form_question_groups_views_bulk_actions_search'
225 225
 						),
226 226
 					),
227
-				'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'),
227
+				'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'),
228 228
 				'metaboxes' => $this->_default_espresso_metaboxes,
229 229
 				'require_nonce' => FALSE,
230 230
 				'qtips' => array(
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 					'order' => 5,
239 239
 					'persistent' => FALSE
240 240
 					),
241
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
241
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
242 242
                 'help_tabs' => array(
243 243
 					'registration_form_add_question_help_tab' => array(
244 244
 						'title' => __('Add Question', 'event_espresso'),
245 245
 						'filename' => 'registration_form_add_question'
246 246
 						),
247 247
 					),
248
-                'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'),
248
+                'help_tour' => array('Registration_Form_Add_Question_Help_Tour'),
249 249
 				'require_nonce' => FALSE
250 250
 				),
251 251
 
@@ -255,14 +255,14 @@  discard block
 block discarded – undo
255 255
 					'order' => 5,
256 256
 					'persistent' => FALSE
257 257
 					),
258
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
258
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
259 259
 				'help_tabs' => array(
260 260
 					'registration_form_add_question_group_help_tab' => array(
261 261
 						'title' => __('Add Question Group', 'event_espresso'),
262 262
 						'filename' => 'registration_form_add_question_group'
263 263
 						),
264 264
 					),
265
-                'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'),
265
+                'help_tour' => array('Registration_Form_Add_Question_Group_Help_Tour'),
266 266
 				'require_nonce' => FALSE
267 267
 				),
268 268
 
@@ -271,16 +271,16 @@  discard block
 block discarded – undo
271 271
 					'label' => __('Edit Question Group', 'event_espresso'),
272 272
 					'order' => 5,
273 273
 					'persistent' => FALSE,
274
-					'url' => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id'] ), $this->_current_page_view_url )  : $this->_admin_base_url
274
+					'url' => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id']), $this->_current_page_view_url) : $this->_admin_base_url
275 275
 					),
276
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
276
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
277 277
 				'help_tabs' => array(
278 278
 					'registration_form_edit_question_group_help_tab' => array(
279 279
 						'title' => __('Edit Question Group', 'event_espresso'),
280 280
 						'filename' => 'registration_form_edit_question_group'
281 281
 						),
282 282
 					),
283
-                'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'),
283
+                'help_tour' => array('Registration_Form_Edit_Question_Group_Help_Tour'),
284 284
 				'require_nonce' => FALSE
285 285
 				),
286 286
 
@@ -292,19 +292,19 @@  discard block
 block discarded – undo
292 292
 				'labels' => array(
293 293
 					'publishbox' => __('Update Settings', 'event_espresso')
294 294
 					),
295
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
295
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
296 296
 				'help_tabs' => array(
297 297
 					'registration_form_reg_form_settings_help_tab' => array(
298 298
 						'title' => __('Registration Form Settings', 'event_espresso'),
299 299
 						'filename' => 'registration_form_reg_form_settings'
300 300
 						),
301 301
 					),
302
-                'help_tour' => array( 'Registration_Form_Settings_Help_Tour'),
302
+                'help_tour' => array('Registration_Form_Settings_Help_Tour'),
303 303
 				'require_nonce' => FALSE
304 304
 				)
305 305
 
306 306
 			);
307
-		$this->_page_config = array_merge( $this->_page_config, $new_page_config );
307
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
308 308
 
309 309
 		//change the list table we're going to use so it's the NEW list table!
310 310
 		$this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 			'edit_question_group' => __('Edit Question Group', 'event_espresso'),
319 319
 			'delete_question_group' => __('Delete Question Group', 'event_espresso'),
320 320
 			);
321
-		$this->_labels['buttons'] = array_merge( $this->_labels['buttons'], $new_labels );
321
+		$this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
322 322
 
323 323
 	}
324 324
 
@@ -327,14 +327,14 @@  discard block
 block discarded – undo
327 327
 
328 328
 
329 329
 	protected function _ajax_hooks() {
330
-		add_action('wp_ajax_espresso_update_question_group_order', array( $this, 'update_question_group_order' ));
330
+		add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
331 331
 	}
332 332
 
333 333
 
334 334
 
335 335
 
336 336
 	public function load_scripts_styles_question_groups() {
337
-		wp_enqueue_script( 'espresso_ajax_table_sorting' );
337
+		wp_enqueue_script('espresso_ajax_table_sorting');
338 338
 	}
339 339
 
340 340
 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 * @return void
356 356
 	 */
357 357
 	public function load_sortable_question_script() {
358
-		wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
358
+		wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
359 359
 		wp_enqueue_script('ee-question-sortable');
360 360
 	}
361 361
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 				)
375 375
 		);
376 376
 
377
-		if ( EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) {
377
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) {
378 378
 			$this->_views['trash'] = array(
379 379
 				'slug' => 'trash',
380 380
 				'label' => __('Trash', 'event_espresso'),
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 				)
405 405
 		);
406 406
 
407
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_question_groups', 'espresso_registration_form_trash_question_groups' ) ) {
407
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups', 'espresso_registration_form_trash_question_groups')) {
408 408
 			$this->_views['trash'] = array(
409 409
 				'slug' => 'trash',
410 410
 				'label' => __('Trash', 'event_espresso'),
@@ -440,24 +440,24 @@  discard block
 block discarded – undo
440 440
 
441 441
 
442 442
 
443
-	protected function _delete_question(){
444
-		$success = $this->_delete_items( $this->_question_model );
443
+	protected function _delete_question() {
444
+		$success = $this->_delete_items($this->_question_model);
445 445
 		$this->_redirect_after_action(
446 446
 			$success,
447
-			$this->_question_model->item_name( $success ),
447
+			$this->_question_model->item_name($success),
448 448
 			'deleted',
449
-			array( 'action' => 'default', 'status' => 'all' )
449
+			array('action' => 'default', 'status' => 'all')
450 450
 		);
451 451
 	}
452 452
 
453 453
 
454 454
 	protected function _delete_questions() {
455
-		$success = $this->_delete_items( $this->_question_model );
455
+		$success = $this->_delete_items($this->_question_model);
456 456
 		$this->_redirect_after_action(
457 457
 			$success,
458
-			$this->_question_model->item_name( $success ),
458
+			$this->_question_model->item_name($success),
459 459
 			'deleted permanently',
460
-			array( 'action' => 'default', 'status' => 'trash' )
460
+			array('action' => 'default', 'status' => 'trash')
461 461
 		);
462 462
 	}
463 463
 
@@ -468,26 +468,26 @@  discard block
 block discarded – undo
468 468
  * @param EEM_Soft_Delete_Base $model
469 469
  * @return int number of items deleted permanently
470 470
  */
471
-	private function _delete_items(EEM_Soft_Delete_Base $model){
471
+	private function _delete_items(EEM_Soft_Delete_Base $model) {
472 472
 		$success = 0;
473
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
474
-		if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
473
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
474
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
475 475
 			// if array has more than one element than success message should be plural
476
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
476
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
477 477
 			// cycle thru bulk action checkboxes
478
-			while (list( $ID, $value ) = each($this->_req_data['checkbox'])) {
479
-				if ( ! $this->_delete_item( $ID, $model ) ) {
478
+			while (list($ID, $value) = each($this->_req_data['checkbox'])) {
479
+				if ( ! $this->_delete_item($ID, $model)) {
480 480
 					$success = 0;
481 481
 				}
482 482
 			}
483 483
 
484
-		}elseif( !empty($this->_req_data['QSG_ID'])){
485
-			$success = $this->_delete_item( $this->_req_data['QSG_ID'], $model );
484
+		}elseif ( ! empty($this->_req_data['QSG_ID'])) {
485
+			$success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
486 486
 
487
-		}elseif( !empty($this->_req_data['QST_ID'])){
488
-			$success = $this->_delete_item( $this->_req_data['QST_ID'], $model );
489
-		}else{
490
-			EE_Error::add_error( sprintf(__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__ );
487
+		}elseif ( ! empty($this->_req_data['QST_ID'])) {
488
+			$success = $this->_delete_item($this->_req_data['QST_ID'], $model);
489
+		} else {
490
+			EE_Error::add_error(sprintf(__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__);
491 491
 		}
492 492
 		return $success;
493 493
 	}
@@ -498,11 +498,11 @@  discard block
 block discarded – undo
498 498
 	 * @param EEM_Soft_Delete_Base $model
499 499
 	 * @return boolean
500 500
 	 */
501
-	protected function _delete_item( $id, $model ) {
502
-		if( $model instanceof EEM_Question ) {
503
-			EEM_Question_Option::instance()->delete_permanently( array( array( 'QST_ID' => absint( $id ) ) ) );
501
+	protected function _delete_item($id, $model) {
502
+		if ($model instanceof EEM_Question) {
503
+			EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
504 504
 		}
505
-		return $model->delete_permanently_by_ID( absint( $id ) );
505
+		return $model->delete_permanently_by_ID(absint($id));
506 506
 	}
507 507
 
508 508
 
@@ -514,29 +514,29 @@  discard block
 block discarded – undo
514 514
 
515 515
 
516 516
 
517
-	protected function _edit_question_group( $type = 'add' ) {
518
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
519
-		$ID=isset( $this->_req_data['QSG_ID'] ) && ! empty( $this->_req_data['QSG_ID'] ) ? absint( $this->_req_data['QSG_ID'] ) : FALSE;
520
-		$this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action ));
517
+	protected function _edit_question_group($type = 'add') {
518
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
519
+		$ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) ? absint($this->_req_data['QSG_ID']) : FALSE;
520
+		$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
521 521
 		// add ID to title if editing
522
-		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
523
-		if($ID){
524
-			$questionGroup=$this->_question_group_model->get_one_by_ID($ID);
525
-			$additional_hidden_fields=array('QSG_ID'=>array('type'=>'hidden','value'=>$ID));
522
+		$this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title;
523
+		if ($ID) {
524
+			$questionGroup = $this->_question_group_model->get_one_by_ID($ID);
525
+			$additional_hidden_fields = array('QSG_ID'=>array('type'=>'hidden', 'value'=>$ID));
526 526
 			$this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
527
-		}else{
527
+		} else {
528 528
 			$questionGroup = EEM_Question_Group::instance()->create_default_object();
529 529
 			$questionGroup->set_order_to_latest();
530 530
 			$this->_set_add_edit_form_tags('insert_question_group');
531 531
 		}
532 532
 		$this->_template_args['values'] = $this->_yes_no_values;
533
-		$this->_template_args['all_questions']=$questionGroup->questions_in_and_not_in_group();
534
-		$this->_template_args['QSG_ID']=$ID ? $ID : TRUE;
535
-		$this->_template_args['question_group']=$questionGroup;
533
+		$this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
534
+		$this->_template_args['QSG_ID'] = $ID ? $ID : TRUE;
535
+		$this->_template_args['question_group'] = $questionGroup;
536 536
 
537
-		$redirect_URL = add_query_arg( array( 'action' => 'question_groups'), $this->_admin_base_url );
538
-		$this->_set_publish_post_box_vars( 'id', $ID, FALSE, $redirect_URL  );
539
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', $this->_template_args, TRUE );
537
+		$redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
538
+		$this->_set_publish_post_box_vars('id', $ID, FALSE, $redirect_URL);
539
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php', $this->_template_args, TRUE);
540 540
 
541 541
 		// the details template wrapper
542 542
 		$this->display_admin_page_with_sidebar();
@@ -547,76 +547,76 @@  discard block
 block discarded – undo
547 547
 
548 548
 	protected function _delete_question_groups() {
549 549
 		$success = $this->_delete_items($this->_question_group_model);
550
-		$this->_redirect_after_action( $success, $this->_question_group_model->item_name($success), 'deleted permanently', array( 'action'=>'question_groups', 'status'=>'trash' ));
550
+		$this->_redirect_after_action($success, $this->_question_group_model->item_name($success), 'deleted permanently', array('action'=>'question_groups', 'status'=>'trash'));
551 551
 	}
552 552
 
553 553
 
554 554
 
555
-	protected function _insert_or_update_question_group( $new_question_group = TRUE) {
556
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
557
-		$set_column_values=$this->_set_column_values_for($this->_question_group_model);
558
-		if ( $new_question_group ){
555
+	protected function _insert_or_update_question_group($new_question_group = TRUE) {
556
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
557
+		$set_column_values = $this->_set_column_values_for($this->_question_group_model);
558
+		if ($new_question_group) {
559 559
 			$QSG_ID = $this->_question_group_model->insert($set_column_values);
560 560
 			$success = $QSG_ID ? 1 : 0;
561 561
 		} else {
562 562
 			$QSG_ID = absint($this->_req_data['QSG_ID']);
563
-			unset( $set_column_values[ 'QSG_ID' ] );
564
-			$success= $this->_question_group_model->update( $set_column_values, array( array( 'QSG_ID' => $QSG_ID )));
563
+			unset($set_column_values['QSG_ID']);
564
+			$success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
565 565
 		}
566
-		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( EEM_Attendee::system_question_phone );
566
+		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone);
567 567
 		// update the existing related questions
568 568
 		// BUT FIRST...  delete the phone question from the Question_Group_Question if it is being added to this question group (therefore removed from the existing group)
569
-		if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ] )) {
569
+		if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) {
570 570
 			// delete where QST ID = system phone question ID and Question Group ID is NOT this group
571
-			EEM_Question_Group_Question::instance()->delete( array( array( 'QST_ID' => $phone_question_id, 'QSG_ID' => array( '!=', $QSG_ID ))));
571
+			EEM_Question_Group_Question::instance()->delete(array(array('QST_ID' => $phone_question_id, 'QSG_ID' => array('!=', $QSG_ID))));
572 572
 		}
573 573
 		/** @type EE_Question_Group $question_group */
574
-		$question_group=$this->_question_group_model->get_one_by_ID( $QSG_ID );
574
+		$question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
575 575
 		$questions = $question_group->questions();
576 576
 		// make sure system phone question is added to list of questions for this group
577
-		if ( ! isset( $questions[$phone_question_id ] )) {
578
-			$questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID( $phone_question_id );
577
+		if ( ! isset($questions[$phone_question_id])) {
578
+			$questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
579 579
 		}
580 580
 
581
-		foreach( $questions as $question_ID => $question ){
581
+		foreach ($questions as $question_ID => $question) {
582 582
 			// first we always check for order.
583
-			if ( ! empty( $this->_req_data['question_orders'][ $question_ID ] ) ){
583
+			if ( ! empty($this->_req_data['question_orders'][$question_ID])) {
584 584
 				//update question order
585
-				$question_group->update_question_order( $question_ID, $this->_req_data['question_orders'][ $question_ID ] );
585
+				$question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]);
586 586
 			}
587 587
 
588 588
 			// then we always check if adding or removing.
589
-			if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ] )) {
590
-				$question_group->add_question( $question_ID );
589
+			if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) {
590
+				$question_group->add_question($question_ID);
591 591
 			} else {
592 592
 				// not found, remove it (but only if not a system question for the personal group with the exception of lname system question - we allow removal of it)
593 593
 				if (
594 594
 					in_array(
595 595
 						$question->system_ID(),
596
-						EEM_Question::instance()->required_system_questions_in_system_question_group( $question_group->system_group() )
596
+						EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group())
597 597
 					)
598 598
 				) {
599 599
 					continue;
600 600
 				} else {
601
-					$question_group->remove_question( $question_ID );
601
+					$question_group->remove_question($question_ID);
602 602
 				}
603 603
 			}
604 604
 		}
605 605
 		// save new related questions
606
-		if ( isset( $this->_req_data['questions'] )) {
607
-			foreach( $this->_req_data['questions'] as $QST_ID ){
608
-				$question_group->add_question( $QST_ID );
609
-				if ( isset( $this->_req_data['question_orders'][ $QST_ID ] )) {
610
-					$question_group->update_question_order( $QST_ID, $this->_req_data['question_orders'][ $QST_ID ] );
606
+		if (isset($this->_req_data['questions'])) {
607
+			foreach ($this->_req_data['questions'] as $QST_ID) {
608
+				$question_group->add_question($QST_ID);
609
+				if (isset($this->_req_data['question_orders'][$QST_ID])) {
610
+					$question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]);
611 611
 				}
612 612
 			}
613 613
 		}
614 614
 
615
-		if ( $success !== FALSE ) {
616
-			$msg = $new_question_group ? sprintf( __('The %s has been created', 'event_espresso'), $this->_question_group_model->item_name() ) : sprintf( __('The %s has been updated', 'event_espresso' ), $this->_question_group_model->item_name() );
617
-			EE_Error::add_success( $msg );
615
+		if ($success !== FALSE) {
616
+			$msg = $new_question_group ? sprintf(__('The %s has been created', 'event_espresso'), $this->_question_group_model->item_name()) : sprintf(__('The %s has been updated', 'event_espresso'), $this->_question_group_model->item_name());
617
+			EE_Error::add_success($msg);
618 618
 		}
619
-		$this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group','QSG_ID'=>$QSG_ID), TRUE);
619
+		$this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group', 'QSG_ID'=>$QSG_ID), TRUE);
620 620
 
621 621
 	}
622 622
 
@@ -624,39 +624,39 @@  discard block
 block discarded – undo
624 624
 	 * duplicates a question and all its question options and redirects to the new question.
625 625
 	 */
626 626
 	public function _duplicate_question() {
627
-		$question_ID = intval( $this->_req_data[ 'QST_ID' ] );
628
-		$question = EEM_Question::instance()->get_one_by_ID( $question_ID );
629
-		if( $question instanceof EE_Question ) {
627
+		$question_ID = intval($this->_req_data['QST_ID']);
628
+		$question = EEM_Question::instance()->get_one_by_ID($question_ID);
629
+		if ($question instanceof EE_Question) {
630 630
 			$new_question = $question->duplicate();
631
-			if( $new_question instanceof EE_Question ) {
632
-				$this->_redirect_after_action( true, __( 'Question', 'event_espresso' ), __( 'Duplicated', 'event_espresso' ), array('action'=>'edit_question', 'QST_ID' => $new_question->ID() ), TRUE);
631
+			if ($new_question instanceof EE_Question) {
632
+				$this->_redirect_after_action(true, __('Question', 'event_espresso'), __('Duplicated', 'event_espresso'), array('action'=>'edit_question', 'QST_ID' => $new_question->ID()), TRUE);
633 633
 			} else {
634 634
 				global $wpdb;
635
-				EE_Error::add_error( sprintf( __( 'Could not duplicate question with ID %1$d because: %2$s', 'event_espresso' ), $question_ID, $wpdb->last_error ), __FILE__, __FUNCTION__, __LINE__ );
636
-			$this->_redirect_after_action(false, '', '', array('action'=>'default'), false );
635
+				EE_Error::add_error(sprintf(__('Could not duplicate question with ID %1$d because: %2$s', 'event_espresso'), $question_ID, $wpdb->last_error), __FILE__, __FUNCTION__, __LINE__);
636
+			$this->_redirect_after_action(false, '', '', array('action'=>'default'), false);
637 637
 			}
638 638
 		} else {
639
-			EE_Error::add_error( sprintf( __( 'Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso' ), $question_ID ), __FILE__, __FUNCTION__, __LINE__ );
640
-			$this->_redirect_after_action( false, '', '', array( 'action' => 'default' ), false );
639
+			EE_Error::add_error(sprintf(__('Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__);
640
+			$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
641 641
 		}
642 642
 	}
643 643
 
644 644
 
645 645
 
646 646
 	protected function _trash_or_restore_question_groups($trash = TRUE) {
647
-		return $this->_trash_or_restore_items( $this->_question_group_model, $trash );
647
+		return $this->_trash_or_restore_items($this->_question_group_model, $trash);
648 648
 	}
649 649
 
650
-	protected function _trash_question(){
651
-		$success=$this->_question_model->delete_by_ID(intval($this->_req_data['QST_ID']));
652
-		$query_args=array('action'=>'default','status'=>'all');
650
+	protected function _trash_question() {
651
+		$success = $this->_question_model->delete_by_ID(intval($this->_req_data['QST_ID']));
652
+		$query_args = array('action'=>'default', 'status'=>'all');
653 653
 		$this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
654 654
 	}
655 655
 
656 656
 
657 657
 
658
-	protected function _trash_or_restore_questions($trash=TRUE){
659
-		$this->_trash_or_restore_items( $this->_question_model, $trash );
658
+	protected function _trash_or_restore_questions($trash = TRUE) {
659
+		$this->_trash_or_restore_items($this->_question_model, $trash);
660 660
 	}
661 661
 
662 662
 
@@ -667,21 +667,21 @@  discard block
 block discarded – undo
667 667
 	 * @param EEM_Base $model
668 668
 	 * @param boolean $trash wehter to trash or restore
669 669
 	 */
670
-	private function _trash_or_restore_items( EEM_Base $model, $trash = TRUE ) {
670
+	private function _trash_or_restore_items(EEM_Base $model, $trash = TRUE) {
671 671
 
672
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
672
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
673 673
 
674 674
 		$success = 1;
675 675
 		//Checkboxes
676 676
 		//echo "trash $trash";
677 677
 		//var_dump($this->_req_data['checkbox']);die;
678
-		if ( isset( $this->_req_data['checkbox'] )) {
679
-			if ( isset( $this->_req_data['checkbox'] ) && ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] )) {
678
+		if (isset($this->_req_data['checkbox'])) {
679
+			if (isset($this->_req_data['checkbox']) && ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
680 680
 				// if array has more than one element than success message should be plural
681
-				$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
681
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
682 682
 				// cycle thru bulk action checkboxes
683
-				while (list( $ID, $value ) = each($this->_req_data['checkbox'])) {
684
-					if ( ! $model->delete_or_restore_by_ID($trash,absint($ID))) {
683
+				while (list($ID, $value) = each($this->_req_data['checkbox'])) {
684
+					if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) {
685 685
 						$success = 0;
686 686
 					}
687 687
 				}
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 			} else {
690 690
 				// grab single id and delete
691 691
 				$ID = absint($this->_req_data['checkbox']);
692
-				if ( ! $model->delete_or_restore_by_ID($trash,$ID)) {
692
+				if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
693 693
 					$success = 0;
694 694
 				}
695 695
 			}
@@ -697,53 +697,53 @@  discard block
 block discarded – undo
697 697
 		} else {
698 698
 			// delete via trash link
699 699
 			// grab single id and delete
700
-			$ID = absint($this->_req_data[ $model->primary_key_name() ]);
701
-			if ( ! $model->delete_or_restore_by_ID($trash,$ID)) {
700
+			$ID = absint($this->_req_data[$model->primary_key_name()]);
701
+			if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
702 702
 				$success = 0;
703 703
 			}
704 704
 
705 705
 		}
706 706
 
707 707
 
708
-		$action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) );
708
+		$action = $model instanceof EEM_Question ? 'default' : 'question_groups'; //strtolower( $model->item_name(2) );
709 709
 		//echo "action :$action";
710 710
 		//$action = 'questions' ? 'default' : $action;
711
-		if($trash){
711
+		if ($trash) {
712 712
 			$action_desc = 'trashed';
713 713
 			$status = 'trash';
714
-		}else{
714
+		} else {
715 715
 			$action_desc = 'restored';
716 716
 			$status = 'all';
717 717
 		}
718
-		$this->_redirect_after_action( $success, $model->item_name($success), $action_desc, array( 'action' => $action, 'status'=>$status ) );
718
+		$this->_redirect_after_action($success, $model->item_name($success), $action_desc, array('action' => $action, 'status'=>$status));
719 719
 	}
720 720
 
721 721
 
722 722
 
723 723
 
724
-	public function get_trashed_questions( $per_page,$current_page = 1, $count = FALSE ) {
724
+	public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) {
725 725
 		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
726 726
 
727
-		if( $count ){
727
+		if ($count) {
728 728
 			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
729
-			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
730
-			$results=$this->_question_model->count_deleted($where);
731
-		}else{
729
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
730
+			$results = $this->_question_model->count_deleted($where);
731
+		} else {
732 732
 			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
733
-			$results=$this->_question_model->get_all_deleted($query_params);
733
+			$results = $this->_question_model->get_all_deleted($query_params);
734 734
 		}
735 735
 		return $results;
736 736
 	}
737 737
 
738 738
 
739 739
 
740
-	public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) {
741
-		$questionGroupModel=EEM_Question_Group::instance();
742
-		$query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page);
743
-		if ($count){
744
-			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
740
+	public function get_question_groups($per_page, $current_page = 1, $count = FALSE) {
741
+		$questionGroupModel = EEM_Question_Group::instance();
742
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
743
+		if ($count) {
744
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
745 745
 			$results = $questionGroupModel->count($where);
746
-		}else{
746
+		} else {
747 747
 			$results = $questionGroupModel->get_all($query_params);
748 748
 		}
749 749
 		return $results;
@@ -751,14 +751,14 @@  discard block
 block discarded – undo
751 751
 
752 752
 
753 753
 
754
-	public function get_trashed_question_groups( $per_page,$current_page = 1, $count = FALSE ) {
755
-		$questionGroupModel=EEM_Question_Group::instance();
756
-		$query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page);
757
-		if($count){
758
-			$where = isset( $query_params[0] ) ? array($query_params[0]) : array();
754
+	public function get_trashed_question_groups($per_page, $current_page = 1, $count = FALSE) {
755
+		$questionGroupModel = EEM_Question_Group::instance();
756
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
757
+		if ($count) {
758
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
759 759
 			$query_params['limit'] = NULL;
760 760
 			$results = $questionGroupModel->count_deleted($where);
761
-		}else{
761
+		} else {
762 762
 			$results = $questionGroupModel->get_all_deleted($query_params);
763 763
 		}
764 764
 		return $results;
@@ -771,22 +771,22 @@  discard block
 block discarded – undo
771 771
 	 */
772 772
 	public function update_question_group_order() {
773 773
 
774
-		$success = __( 'Question group order was updated successfully.', 'event_espresso' );
774
+		$success = __('Question group order was updated successfully.', 'event_espresso');
775 775
 
776 776
 		// grab our row IDs
777
-		$row_ids = isset( $this->_req_data['row_ids'] ) && ! empty( $this->_req_data['row_ids'] ) ? explode( ',', rtrim( $this->_req_data['row_ids'], ',' )) : FALSE;
777
+		$row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) ? explode(',', rtrim($this->_req_data['row_ids'], ',')) : FALSE;
778 778
 
779
-		$perpage = !empty( $this->_req_data['perpage'] ) ? (int) $this->_req_data['perpage'] : NULL;
780
-		$curpage = !empty( $this->_req_data['curpage'] ) ? (int) $this->_req_data['curpage'] : NULL;
779
+		$perpage = ! empty($this->_req_data['perpage']) ? (int) $this->_req_data['perpage'] : NULL;
780
+		$curpage = ! empty($this->_req_data['curpage']) ? (int) $this->_req_data['curpage'] : NULL;
781 781
 
782
-		if ( is_array( $row_ids )) {
782
+		if (is_array($row_ids)) {
783 783
 			//figure out where we start the row_id count at for the current page.
784
-			$qsgcount = empty( $curpage ) ? 0 : ($curpage - 1 ) * $perpage;
784
+			$qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
785 785
 
786 786
 			global $wpdb;
787
-			for ( $i = 0; $i < count($row_ids); $i++ ) {
787
+			for ($i = 0; $i < count($row_ids); $i++) {
788 788
 				//Update the questions when re-ordering
789
-				if ( EEM_Question_Group::instance()->update ( array( 'QSG_order' => $qsgcount ), array(array( 'QSG_ID' => $row_ids[$i] ))) === FALSE ) {
789
+				if (EEM_Question_Group::instance()->update(array('QSG_order' => $qsgcount), array(array('QSG_ID' => $row_ids[$i]))) === FALSE) {
790 790
 					$success = FALSE;
791 791
 				}
792 792
 				$qsgcount++;
@@ -795,9 +795,9 @@  discard block
 block discarded – undo
795 795
 			$success = FALSE;
796 796
 		}
797 797
 
798
-		$errors = ! $success ? __( 'An error occurred. The question group order was not updated.', 'event_espresso' ) : FALSE;
798
+		$errors = ! $success ? __('An error occurred. The question group order was not updated.', 'event_espresso') : FALSE;
799 799
 
800
-		echo json_encode( array( 'return_data' => FALSE, 'success' => $success, 'errors' => $errors ));
800
+		echo json_encode(array('return_data' => FALSE, 'success' => $success, 'errors' => $errors));
801 801
 		die();
802 802
 
803 803
 	}
@@ -814,10 +814,10 @@  discard block
 block discarded – undo
814 814
 
815 815
 	protected function _reg_form_settings() {
816 816
 		$this->_template_args['values'] = $this->_yes_no_values;
817
-		$this->_template_args = apply_filters( 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', $this->_template_args );
818
-		$this->_set_add_edit_form_tags( 'update_reg_form_settings' );
819
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
820
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', $this->_template_args, TRUE );
817
+		$this->_template_args = apply_filters('FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', $this->_template_args);
818
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
819
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
820
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php', $this->_template_args, TRUE);
821 821
 		$this->display_admin_page_with_sidebar();
822 822
 	}
823 823
 
@@ -825,9 +825,9 @@  discard block
 block discarded – undo
825 825
 
826 826
 
827 827
 	protected function _update_reg_form_settings() {
828
-		EE_Registry::instance()->CFG->registration = apply_filters( 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', EE_Registry::instance()->CFG->registration );
829
-		$success = $this->_update_espresso_configuration( __('Registration Form Options', 'event_espresso'), EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ );
830
-		$this->_redirect_after_action( $success, __('Registration Form Options', 'event_espresso'), 'updated', array( 'action' => 'view_reg_form_settings' ) );
828
+		EE_Registry::instance()->CFG->registration = apply_filters('FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', EE_Registry::instance()->CFG->registration);
829
+		$success = $this->_update_espresso_configuration(__('Registration Form Options', 'event_espresso'), EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__);
830
+		$this->_redirect_after_action($success, __('Registration Form Options', 'event_espresso'), 'updated', array('action' => 'view_reg_form_settings'));
831 831
 	}
832 832
 
833 833
 }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -512,7 +512,7 @@
 block discarded – undo
512 512
 	 * Deletes the specified question (and its associated question options) or question group
513 513
 	 * @param int $id
514 514
 	 * @param EEM_Soft_Delete_Base $model
515
-	 * @return boolean
515
+	 * @return integer
516 516
 	 */
517 517
 	protected function _delete_item( $id, $model ) {
518 518
 		if( $model instanceof EEM_Question ) {
Please login to merge, or discard this patch.
Braces   +10 added lines, -9 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
@@ -481,12 +482,12 @@  discard block
 block discarded – undo
481 482
 				}
482 483
 			}
483 484
 
484
-		}elseif( !empty($this->_req_data['QSG_ID'])){
485
+		} elseif( !empty($this->_req_data['QSG_ID'])){
485 486
 			$success = $this->_delete_item( $this->_req_data['QSG_ID'], $model );
486 487
 
487
-		}elseif( !empty($this->_req_data['QST_ID'])){
488
+		} elseif( !empty($this->_req_data['QST_ID'])){
488 489
 			$success = $this->_delete_item( $this->_req_data['QST_ID'], $model );
489
-		}else{
490
+		} else{
490 491
 			EE_Error::add_error( sprintf(__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__ );
491 492
 		}
492 493
 		return $success;
@@ -524,7 +525,7 @@  discard block
 block discarded – undo
524 525
 			$questionGroup=$this->_question_group_model->get_one_by_ID($ID);
525 526
 			$additional_hidden_fields=array('QSG_ID'=>array('type'=>'hidden','value'=>$ID));
526 527
 			$this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
527
-		}else{
528
+		} else{
528 529
 			$questionGroup = EEM_Question_Group::instance()->create_default_object();
529 530
 			$questionGroup->set_order_to_latest();
530 531
 			$this->_set_add_edit_form_tags('insert_question_group');
@@ -711,7 +712,7 @@  discard block
 block discarded – undo
711 712
 		if($trash){
712 713
 			$action_desc = 'trashed';
713 714
 			$status = 'trash';
714
-		}else{
715
+		} else{
715 716
 			$action_desc = 'restored';
716 717
 			$status = 'all';
717 718
 		}
@@ -728,7 +729,7 @@  discard block
 block discarded – undo
728 729
 			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
729 730
 			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
730 731
 			$results=$this->_question_model->count_deleted($where);
731
-		}else{
732
+		} else{
732 733
 			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
733 734
 			$results=$this->_question_model->get_all_deleted($query_params);
734 735
 		}
@@ -743,7 +744,7 @@  discard block
 block discarded – undo
743 744
 		if ($count){
744 745
 			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
745 746
 			$results = $questionGroupModel->count($where);
746
-		}else{
747
+		} else{
747 748
 			$results = $questionGroupModel->get_all($query_params);
748 749
 		}
749 750
 		return $results;
@@ -758,7 +759,7 @@  discard block
 block discarded – undo
758 759
 			$where = isset( $query_params[0] ) ? array($query_params[0]) : array();
759 760
 			$query_params['limit'] = NULL;
760 761
 			$results = $questionGroupModel->count_deleted($where);
761
-		}else{
762
+		} else{
762 763
 			$results = $questionGroupModel->get_all_deleted($query_params);
763 764
 		}
764 765
 		return $results;
Please login to merge, or discard this patch.
caffeinated/payment_methods/Paypal_Pro/EEG_Paypal_Pro.gateway.php 1 patch
Spacing   +51 added lines, -51 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
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEG_Paypal_Pro extends EE_Onsite_Gateway{
28
+class EEG_Paypal_Pro extends EE_Onsite_Gateway {
29 29
 	/**
30 30
 	 *
31 31
 	 * @var $_paypal_api_username string
@@ -88,21 +88,21 @@  discard block
 block discarded – undo
88 88
 	 * } @see parent::do_direct_payment for more info
89 89
 	 * @return \EE_Payment|\EEI_Payment
90 90
 	 */
91
-	public function do_direct_payment($payment,$billing_info = null){
91
+	public function do_direct_payment($payment, $billing_info = null) {
92 92
 		$transaction = $payment->transaction();
93 93
 		$primary_registrant = $transaction->primary_registration();
94
-		$order_description  = sprintf(__("Event Registrations from %s", "event_espresso"),get_bloginfo('name'));
94
+		$order_description  = sprintf(__("Event Registrations from %s", "event_espresso"), get_bloginfo('name'));
95 95
 		//charge for the full amount. Show itemized list
96
-		if( $this->_can_easily_itemize_transaction_for( $payment ) ){
96
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
97 97
 			$item_num = 1;
98 98
 			$total_line_item = $transaction->total_line_item();
99 99
 			$order_items = array();
100 100
 			foreach ($total_line_item->get_items() as $line_item) {
101 101
 				$item = array(
102 102
 						// Item Name.  127 char max.
103
-						'l_name' => substr($line_item->name(),0,127),
103
+						'l_name' => substr($line_item->name(), 0, 127),
104 104
 						// Item description.  127 char max.
105
-						'l_desc' => substr($line_item->desc(),0,127),
105
+						'l_desc' => substr($line_item->desc(), 0, 127),
106 106
 						// Cost of individual item.
107 107
 						'l_amt' => $line_item->unit_price(),
108 108
 						// Item Number.  127 char max.
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 			}
124 124
 			$item_amount = $total_line_item->get_items_total();
125 125
 			$tax_amount = $total_line_item->get_total_tax();
126
-		}else{
126
+		} else {
127 127
 			$order_items = array();
128 128
 			$item_amount = $payment->amount();
129
-			$single_item_desc = sprintf(__("Partial payment of %s for %s", "event_espresso"),$payment->amount(),$primary_registrant->reg_code());
129
+			$single_item_desc = sprintf(__("Partial payment of %s for %s", "event_espresso"), $payment->amount(), $primary_registrant->reg_code());
130 130
 			$tax_amount = 0;
131
-			array_push($order_items,array(
131
+			array_push($order_items, array(
132 132
 				// Item Name.  127 char max.
133
-				'l_name' => sprintf(__("Partial payment for registration: %s", 'event_espresso'),$primary_registrant->reg_code()),
133
+				'l_name' => sprintf(__("Partial payment for registration: %s", 'event_espresso'), $primary_registrant->reg_code()),
134 134
 				// Item description.  127 char max.
135 135
 				'l_desc' => $single_item_desc,
136 136
 				// Cost of individual item.
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 			// Payer's salutation.  20 char max.
178 178
 			'salutation' => '',
179 179
 			// Payer's first name.  25 char max.
180
-			'firstname' => substr($billing_info['first_name'],0,25),
180
+			'firstname' => substr($billing_info['first_name'], 0, 25),
181 181
 			// Payer's middle name.  25 char max.
182 182
 			'middlename' => '',
183 183
 			// Payer's last name.  25 char max.
184
-			'lastname' => substr($billing_info['last_name'],0,25),
184
+			'lastname' => substr($billing_info['last_name'], 0, 25),
185 185
 			// Payer's suffix.  12 char max.
186 186
 			'suffix' => ''
187 187
 		);
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
 			// Required.  Name of City.
195 195
 			'city' => $billing_info['city'],
196 196
 			// Required. Name of State or Province.
197
-			'state' => substr( $billing_info['state'], 0, 40 ),
197
+			'state' => substr($billing_info['state'], 0, 40),
198 198
 			// Required.  Country code.
199 199
 			'countrycode' => $billing_info['country'],
200 200
 			// Required.  Postal code of payer.
201 201
 			'zip' => $billing_info['zip'],
202 202
 			// Phone Number of payer.  20 char max.
203
-			'shiptophonenum' => substr($billing_info['phone'],0,20)
203
+			'shiptophonenum' => substr($billing_info['phone'], 0, 20)
204 204
 		);
205 205
 
206 206
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			// Required.  Three-letter currency code.  Default is USD.
211 211
 			'currencycode' => $payment->currency_code(),
212 212
 			// Required if you include itemized cart details. (L_AMTn, etc.)  Subtotal of items not including S&H, or tax.
213
-			'itemamt' => $this->format_currency($item_amount),//
213
+			'itemamt' => $this->format_currency($item_amount), //
214 214
 			// Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
215 215
 			'shippingamt' => '',
216 216
 			// Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
 			// Free-form field for your own use.  256 char max.
223 223
 			'custom' => $primary_registrant ? $primary_registrant->ID() : '',
224 224
 			// Your own invoice or tracking number
225
-			'invnum' => wp_generate_password(12,false),//$transaction->ID(),
225
+			'invnum' => wp_generate_password(12, false), //$transaction->ID(),
226 226
 			// URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
227 227
 			'notifyurl' => '',
228
-			'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
228
+			'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this
229 229
 		);
230 230
 		// Wrap all data arrays into a single, "master" array which will be passed into the class function.
231 231
 		$PayPalRequestData = array(
@@ -238,32 +238,32 @@  discard block
 block discarded – undo
238 238
 				'OrderItems' => $order_items,
239 239
 		);
240 240
 		$this->_log_clean_request($PayPalRequestData, $payment);
241
-		try{
241
+		try {
242 242
 			$PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
243 243
 			//remove PCI-sensitive data so it doesn't get stored
244
-			$PayPalResult = $this->_log_clean_response($PayPalResult,$payment);
244
+			$PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
245 245
 
246 246
 			$message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK'];
247
-			if( empty($PayPalResult[ 'RAWRESPONSE' ] ) ) {
248
-				$payment->set_status( $this->_pay_model->failed_status() ) ;
249
-				$payment->set_gateway_response( __( 'No response received from Paypal Pro', 'event_espresso' ) );
247
+			if (empty($PayPalResult['RAWRESPONSE'])) {
248
+				$payment->set_status($this->_pay_model->failed_status());
249
+				$payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso'));
250 250
 				$payment->set_details($PayPalResult);
251
-			}else{
252
-				if($this->_APICallSuccessful($PayPalResult)){
251
+			} else {
252
+				if ($this->_APICallSuccessful($PayPalResult)) {
253 253
 					$payment->set_status($this->_pay_model->approved_status());
254
-				}else{
254
+				} else {
255 255
 					$payment->set_status($this->_pay_model->declined_status());
256 256
 				}
257 257
 				//make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
258
-				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval( $PayPalResult['AMT'] ) : 0);
258
+				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
259 259
 				$payment->set_gateway_response($message);
260
-				$payment->set_txn_id_chq_nmbr(isset( $PayPalResult['TRANSACTIONID'] )? $PayPalResult['TRANSACTIONID'] : null);
260
+				$payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null);
261 261
 
262 262
 				$primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : '';
263 263
 				$payment->set_extra_accntng($primary_registration_code);
264 264
 				$payment->set_details($PayPalResult);
265 265
 			}
266
-		}catch(Exception $e){
266
+		} catch (Exception $e) {
267 267
 			$payment->set_status($this->_pay_model->failed_status());
268 268
 			$payment->set_gateway_response($e->getMessage());
269 269
 		}
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 * @param EEI_Payment $payment
281 281
 	 * @return array
282 282
 	 */
283
-	private function _log_clean_request($request,$payment){
283
+	private function _log_clean_request($request, $payment) {
284 284
 		$cleaned_request_data = $request;
285 285
 		unset($cleaned_request_data['CCDetails']['acct']);
286 286
 		unset($cleaned_request_data['CCDetails']['cvv2']);
@@ -296,13 +296,13 @@  discard block
 block discarded – undo
296 296
 	 * @param EEI_Payment $payment
297 297
 	 * @return array cleaned
298 298
 	 */
299
-	private function _log_clean_response($response,$payment){
299
+	private function _log_clean_response($response, $payment) {
300 300
 		unset($response['REQUESTDATA']['CREDITCARDTYPE']);
301 301
 		unset($response['REQUESTDATA']['ACCT']);
302 302
 		unset($response['REQUESTDATA']['EXPDATE']);
303 303
 		unset($response['REQUESTDATA']['CVV2']);
304 304
 		unset($response['RAWREQUEST']);
305
-		$this->log(array('Paypal Response'=>$response),$payment);
305
+		$this->log(array('Paypal Response'=>$response), $payment);
306 306
 		return $response;
307 307
 	}
308 308
 
@@ -327,32 +327,32 @@  discard block
 block discarded – undo
327 327
 		// DP Fields
328 328
 		$DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
329 329
 		foreach ($DPFields as $DPFieldsVar => $DPFieldsVal)
330
-			$DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
330
+			$DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal);
331 331
 
332 332
 		// CC Details Fields
333 333
 		$CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
334 334
 		foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal)
335
-			$CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
335
+			$CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal);
336 336
 
337 337
 		// PayerInfo Type Fields
338 338
 		$PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
339 339
 		foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal)
340
-			$PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
340
+			$PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal);
341 341
 
342 342
 		// Payer Name Fields
343 343
 		$PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
344 344
 		foreach ($PayerName as $PayerNameVar => $PayerNameVal)
345
-			$PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
345
+			$PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal);
346 346
 
347 347
 		// Address Fields (Billing)
348 348
 		$BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
349 349
 		foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal)
350
-			$BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
350
+			$BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal);
351 351
 
352 352
 		// Payment Details Type Fields
353 353
 		$PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
354 354
 		foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal)
355
-			$PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
355
+			$PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal);
356 356
 
357 357
 		// Payment Details Item Type Fields
358 358
 		$OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
@@ -360,22 +360,22 @@  discard block
 block discarded – undo
360 360
 		foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
361 361
 			$CurrentItem = $OrderItems[$OrderItemsVar];
362 362
 			foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal)
363
-				$OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
363
+				$OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal);
364 364
 			$n++;
365 365
 		}
366 366
 
367 367
 		// Ship To Address Fields
368 368
 		$ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
369 369
 		foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal)
370
-			$ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
370
+			$ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal);
371 371
 
372 372
 		// 3D Secure Fields
373 373
 		$Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
374 374
 		foreach ($Secure3D as $Secure3DVar => $Secure3DVal)
375
-			$Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
375
+			$Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal);
376 376
 
377 377
 		// Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
378
-		$NVPRequest = 'USER=' . $this->_username . '&PWD=' . $this->_password . '&VERSION=64.0' . '&SIGNATURE=' . $this->_signature . $DPFieldsNVP . $CCDetailsNVP . $PayerInfoNVP . $PayerNameNVP . $BillingAddressNVP . $PaymentDetailsNVP . $OrderItemsNVP . $ShippingAddressNVP . $Secure3DNVP;
378
+		$NVPRequest = 'USER='.$this->_username.'&PWD='.$this->_password.'&VERSION=64.0'.'&SIGNATURE='.$this->_signature.$DPFieldsNVP.$CCDetailsNVP.$PayerInfoNVP.$PayerNameNVP.$BillingAddressNVP.$PaymentDetailsNVP.$OrderItemsNVP.$ShippingAddressNVP.$Secure3DNVP;
379 379
 		$NVPResponse = $this->_CURLRequest($NVPRequest);
380 380
 		$NVPRequestArray = $this->_NVPToArray($NVPRequest);
381 381
 		$NVPResponseArray = $this->_NVPToArray($NVPResponse);
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 	private function _CURLRequest($Request) {
400 400
 		$EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
401 401
 		$curl = curl_init();
402
-		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE ) );
402
+		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE));
403 403
 		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
404 404
 		curl_setopt($curl, CURLOPT_TIMEOUT, 60);
405 405
 		curl_setopt($curl, CURLOPT_URL, $EndPointURL);
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 	private function _APICallSuccessful($PayPalResult) {
450 450
 		$approved = false;
451 451
 		// check main response message from PayPal
452
-		if (isset($PayPalResult['ACK']) && !empty($PayPalResult['ACK'])) {
452
+		if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
453 453
 			$ack = strtoupper($PayPalResult['ACK']);
454
-			$approved = ( $ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS' ) ? true : false;
454
+			$approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
455 455
 		}
456 456
 
457 457
 		return $approved;
@@ -467,11 +467,11 @@  discard block
 block discarded – undo
467 467
 
468 468
 		$Errors = array();
469 469
 		$n = 0;
470
-		while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
471
-			$LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
472
-			$LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : '';
473
-			$LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : '';
474
-			$LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : '';
470
+		while (isset($DataArray['L_ERRORCODE'.$n.''])) {
471
+			$LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : '';
472
+			$LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) ? $DataArray['L_SHORTMESSAGE'.$n.''] : '';
473
+			$LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) ? $DataArray['L_LONGMESSAGE'.$n.''] : '';
474
+			$LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) ? $DataArray['L_SEVERITYCODE'.$n.''] : '';
475 475
 
476 476
 			$CurrentItem = array(
477 477
 					'L_ERRORCODE' => $LErrorCode,
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 				elseif ($CurrentErrorVar == 'L_SEVERITYCODE')
512 512
 					$CurrentVarName = 'Severity Code';
513 513
 
514
-				$error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
514
+				$error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal;
515 515
 			}
516 516
 		}
517 517
 		return $error;
Please login to merge, or discard this patch.
core/db_models/fields/EE_Post_Content_Field.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,18 +3,18 @@
 block discarded – undo
3 3
  * Field to only allow tags that are normally allowed on post_content:
4 4
  * address,a,abbr,acronym,area,article,aside,b,big,blockquote,br,button,caption,cite,code,col,del,dd,dfn,details,div,dl,dt,em,fieldset,figure,figcaption,font,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,img,ins,kbd,label,legend,li,map,mark,menu,nav,p,pre,q,s,samp,span,section,small,strike,strong,sub,summary,sup,table,tbody,td,textarea,tfoot,th,thead,title,tr,tt,u,ul,ol,var
5 5
  */
6
-class EE_Post_Content_Field extends EE_Full_HTML_Field{
6
+class EE_Post_Content_Field extends EE_Full_HTML_Field {
7 7
 	/**
8 8
 	 * removes all tags which a WP Post wouldn't allow in its content normally
9 9
 	 * @param string $value_inputted_for_field_on_model_object
10 10
 	 * @return string
11 11
 	 */
12 12
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
13
-		$value_with_select_tags =  wp_kses("$value_inputted_for_field_on_model_object",wp_kses_allowed_html( 'post' ));
13
+		$value_with_select_tags = wp_kses("$value_inputted_for_field_on_model_object", wp_kses_allowed_html('post'));
14 14
 		return parent::prepare_for_set($value_with_select_tags);
15 15
 	}
16 16
 	
17
-	function prepare_for_set_from_db($value_found_in_db_for_model_object){
17
+	function prepare_for_set_from_db($value_found_in_db_for_model_object) {
18 18
 		return $value_found_in_db_for_model_object;
19 19
 	}
20 20
 }
21 21
\ No newline at end of file
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlerBaseClasses/JobHandlerFile.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 
17 17
 use EventEspressoBatchRequest\Helpers\BatchRequestException;
18 18
 
19
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
20
-	exit( 'No direct script access allowed' );
19
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
20
+	exit('No direct script access allowed');
21 21
 }
22 22
 
23 23
 
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @param \EEHI_File|null $file_helper
41 41
 	 */
42
-	public function __construct( \EEHI_File $file_helper = null ) {
43
-		if( ! $file_helper ) {
42
+	public function __construct(\EEHI_File $file_helper = null) {
43
+		if ( ! $file_helper) {
44 44
 			$this->_file_helper = new \EEH_File();
45 45
 		}
46 46
 	}
@@ -56,39 +56,39 @@  discard block
 block discarded – undo
56 56
 	 * @return string
57 57
 	 * @throws \EventEspressoBatchRequest\Helpers\BatchRequestException
58 58
 	 */
59
-	public function create_file_from_job_with_name( $job_id, $filename, $filetype = 'application/ms-excel' ) {
59
+	public function create_file_from_job_with_name($job_id, $filename, $filetype = 'application/ms-excel') {
60 60
 		$filepath = '';
61
-		try{
61
+		try {
62 62
 			$success = $this->_file_helper->ensure_folder_exists_and_is_writable(
63
-				EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name
63
+				EVENT_ESPRESSO_UPLOAD_DIR.JobHandlerFile::temp_folder_name
64 64
 			);
65
-			if ( $success ) {
65
+			if ($success) {
66 66
 				$success = $this->_file_helper->ensure_folder_exists_and_is_writable(
67
-					EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name . DS . $job_id
67
+					EVENT_ESPRESSO_UPLOAD_DIR.JobHandlerFile::temp_folder_name.DS.$job_id
68 68
 				);
69 69
 			}
70
-			if( $success ) {
71
-				$filepath = EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name . DS . $job_id . DS. $filename;
72
-				$success = $this->_file_helper->ensure_file_exists_and_is_writable( $filepath );
70
+			if ($success) {
71
+				$filepath = EVENT_ESPRESSO_UPLOAD_DIR.JobHandlerFile::temp_folder_name.DS.$job_id.DS.$filename;
72
+				$success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath);
73 73
 			}
74 74
 			//let's add the .htaccess file so safari will open the file properly
75
-			if( $success ) {
76
-				$extension = \EEH_File::get_file_extension( $filepath );
75
+			if ($success) {
76
+				$extension = \EEH_File::get_file_extension($filepath);
77 77
 				\EEH_File::write_to_file(
78
-					EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name . DS . $job_id . DS . '.htaccess',
79
-					'AddType ' . $filetype . ' ' . $extension,
78
+					EVENT_ESPRESSO_UPLOAD_DIR.JobHandlerFile::temp_folder_name.DS.$job_id.DS.'.htaccess',
79
+					'AddType '.$filetype.' '.$extension,
80 80
 					'.htaccess'
81 81
 				);
82 82
 			}
83 83
 			//those methods normally fail with an exception, but if not, let's do it
84
-			if( ! $success ) {
85
-				throw new \EE_Error( 'could_not_create_temp_file',
86
-				__( 'An unknown error occurred', 'event_espresso' ));
84
+			if ( ! $success) {
85
+				throw new \EE_Error('could_not_create_temp_file',
86
+				__('An unknown error occurred', 'event_espresso'));
87 87
 			}
88
-		} catch( \EE_Error $e ) {
88
+		} catch (\EE_Error $e) {
89 89
 			throw new BatchRequestException(
90 90
 				sprintf(
91
-					__( 'Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso' ),
91
+					__('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'),
92 92
 					$job_id,
93 93
 					$e->getMessage()
94 94
 				),
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @param string $filepath
105 105
 	 * @return string url to file
106 106
 	 */
107
-	public function get_url_to_file( $filepath ) {
108
-		return str_replace( EVENT_ESPRESSO_UPLOAD_DIR, EVENT_ESPRESSO_UPLOAD_URL, $filepath );
107
+	public function get_url_to_file($filepath) {
108
+		return str_replace(EVENT_ESPRESSO_UPLOAD_DIR, EVENT_ESPRESSO_UPLOAD_URL, $filepath);
109 109
 	}
110 110
 }
111 111
 
Please login to merge, or discard this patch.