@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
7 | 7 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
8 | 8 | |
9 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | * @param \WP_REST_Request $request |
47 | 47 | * @return \WP_REST_Response|\WP_Error |
48 | 48 | */ |
49 | - public static function handle_request_get_all( \WP_REST_Request $request) { |
|
49 | + public static function handle_request_get_all(\WP_REST_Request $request) { |
|
50 | 50 | $controller = new Read(); |
51 | - try{ |
|
51 | + try { |
|
52 | 52 | $matches = $controller->parse_route( |
53 | 53 | $request->get_route(), |
54 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~', |
|
55 | - array( 'version', 'model' ) |
|
54 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~', |
|
55 | + array('version', 'model') |
|
56 | 56 | ); |
57 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
58 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
59 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
57 | + $controller->set_requested_version($matches['version']); |
|
58 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
59 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
60 | 60 | return $controller->send_response( |
61 | 61 | new \WP_Error( |
62 | 62 | 'endpoint_parsing_error', |
63 | 63 | sprintf( |
64 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
64 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
65 | 65 | $model_name_singular |
66 | 66 | ) |
67 | 67 | ) |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | } |
70 | 70 | return $controller->send_response( |
71 | 71 | $controller->get_entities_from_model( |
72 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
72 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
73 | 73 | $request |
74 | 74 | ) |
75 | 75 | ); |
76 | - } catch( \Exception $e ) { |
|
77 | - return $controller->send_response( $e ); |
|
76 | + } catch (\Exception $e) { |
|
77 | + return $controller->send_response($e); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -84,21 +84,21 @@ discard block |
||
84 | 84 | * @param \WP_REST_Request $request |
85 | 85 | * @return \WP_REST_Response|\WP_Error |
86 | 86 | */ |
87 | - public static function handle_request_get_one( \WP_REST_Request $request ) { |
|
87 | + public static function handle_request_get_one(\WP_REST_Request $request) { |
|
88 | 88 | $controller = new Read(); |
89 | - try{ |
|
89 | + try { |
|
90 | 90 | $matches = $controller->parse_route( |
91 | 91 | $request->get_route(), |
92 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~', |
|
93 | - array( 'version', 'model', 'id' ) ); |
|
94 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
95 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
96 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
92 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~', |
|
93 | + array('version', 'model', 'id') ); |
|
94 | + $controller->set_requested_version($matches['version']); |
|
95 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
96 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
97 | 97 | return $controller->send_response( |
98 | 98 | new \WP_Error( |
99 | 99 | 'endpoint_parsing_error', |
100 | 100 | sprintf( |
101 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
101 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
102 | 102 | $model_name_singular |
103 | 103 | ) |
104 | 104 | ) |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | } |
107 | 107 | return $controller->send_response( |
108 | 108 | $controller->get_entity_from_model( |
109 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
109 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
110 | 110 | $request |
111 | 111 | ) |
112 | 112 | ); |
113 | - } catch( \Exception $e ) { |
|
114 | - return $controller->send_response( $e ); |
|
113 | + } catch (\Exception $e) { |
|
114 | + return $controller->send_response($e); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -123,40 +123,40 @@ discard block |
||
123 | 123 | * @param \WP_REST_Request $request |
124 | 124 | * @return \WP_REST_Response|\WP_Error |
125 | 125 | */ |
126 | - public static function handle_request_get_related( \WP_REST_Request $request ) { |
|
126 | + public static function handle_request_get_related(\WP_REST_Request $request) { |
|
127 | 127 | $controller = new Read(); |
128 | - try{ |
|
128 | + try { |
|
129 | 129 | $matches = $controller->parse_route( |
130 | 130 | $request->get_route(), |
131 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~', |
|
132 | - array( 'version', 'model', 'id', 'related_model' ) |
|
131 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~', |
|
132 | + array('version', 'model', 'id', 'related_model') |
|
133 | 133 | ); |
134 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
135 | - $main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
136 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) { |
|
134 | + $controller->set_requested_version($matches['version']); |
|
135 | + $main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
136 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) { |
|
137 | 137 | return $controller->send_response( |
138 | 138 | new \WP_Error( |
139 | 139 | 'endpoint_parsing_error', |
140 | 140 | sprintf( |
141 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
141 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
142 | 142 | $main_model_name_singular |
143 | 143 | ) |
144 | 144 | ) |
145 | 145 | ); |
146 | 146 | } |
147 | - $main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular ); |
|
147 | + $main_model = $controller->get_model_version_info()->load_model($main_model_name_singular); |
|
148 | 148 | //assume the related model name is plural and try to find the model's name |
149 | - $related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] ); |
|
150 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
149 | + $related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']); |
|
150 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
151 | 151 | //so the word didn't singularize well. Maybe that's just because it's a singular word? |
152 | - $related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] ); |
|
152 | + $related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']); |
|
153 | 153 | } |
154 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
154 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
155 | 155 | return $controller->send_response( |
156 | 156 | new \WP_Error( |
157 | 157 | 'endpoint_parsing_error', |
158 | 158 | sprintf( |
159 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
159 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
160 | 160 | $related_model_name_singular |
161 | 161 | ) |
162 | 162 | ) |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | |
166 | 166 | return $controller->send_response( |
167 | 167 | $controller->get_entities_from_relation( |
168 | - $request->get_param( 'id' ), |
|
169 | - $main_model->related_settings_for( $related_model_name_singular ) , |
|
168 | + $request->get_param('id'), |
|
169 | + $main_model->related_settings_for($related_model_name_singular), |
|
170 | 170 | $request |
171 | 171 | ) |
172 | 172 | ); |
173 | - } catch( \Exception $e ) { |
|
174 | - return $controller->send_response( $e ); |
|
173 | + } catch (\Exception $e) { |
|
174 | + return $controller->send_response($e); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
@@ -184,28 +184,28 @@ discard block |
||
184 | 184 | * @param \WP_REST_Request $request |
185 | 185 | * @return array|\WP_Error |
186 | 186 | */ |
187 | - public function get_entities_from_model( $model, $request) { |
|
188 | - $query_params = $this->create_model_query_params( $model, $request->get_params() ); |
|
189 | - if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) { |
|
190 | - $model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ); |
|
187 | + public function get_entities_from_model($model, $request) { |
|
188 | + $query_params = $this->create_model_query_params($model, $request->get_params()); |
|
189 | + if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) { |
|
190 | + $model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()); |
|
191 | 191 | return new \WP_Error( |
192 | - sprintf( 'rest_%s_cannot_list', $model_name_plural ), |
|
192 | + sprintf('rest_%s_cannot_list', $model_name_plural), |
|
193 | 193 | sprintf( |
194 | - __( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ), |
|
194 | + __('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'), |
|
195 | 195 | $model_name_plural, |
196 | - Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) |
|
196 | + Capabilities::get_missing_permissions_string($model, $query_params['caps']) |
|
197 | 197 | ), |
198 | - array( 'status' => 403 ) |
|
198 | + array('status' => 403) |
|
199 | 199 | ); |
200 | 200 | } |
201 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
202 | - $this->_set_headers_from_query_params( $model, $query_params ); |
|
201 | + if ( ! $request->get_header('no_rest_headers')) { |
|
202 | + $this->_set_headers_from_query_params($model, $query_params); |
|
203 | 203 | } |
204 | 204 | /** @type array $results */ |
205 | - $results = $model->get_all_wpdb_results( $query_params ); |
|
205 | + $results = $model->get_all_wpdb_results($query_params); |
|
206 | 206 | $nice_results = array( ); |
207 | - foreach ( $results as $result ) { |
|
208 | - $nice_results[ ] = $this->create_entity_from_wpdb_result( |
|
207 | + foreach ($results as $result) { |
|
208 | + $nice_results[] = $this->create_entity_from_wpdb_result( |
|
209 | 209 | $model, |
210 | 210 | $result, |
211 | 211 | $request |
@@ -225,64 +225,64 @@ discard block |
||
225 | 225 | * @param \WP_REST_Request $request |
226 | 226 | * @return array|\WP_Error |
227 | 227 | */ |
228 | - public function get_entities_from_relation( $id, $relation, $request ) { |
|
229 | - $context = $this->validate_context( $request->get_param( 'caps' )); |
|
228 | + public function get_entities_from_relation($id, $relation, $request) { |
|
229 | + $context = $this->validate_context($request->get_param('caps')); |
|
230 | 230 | $model = $relation->get_this_model(); |
231 | 231 | $related_model = $relation->get_other_model(); |
232 | 232 | //check if they can access the 1st model object |
233 | - $query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 ); |
|
234 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
233 | + $query_params = array(array($model->primary_key_name() => $id), 'limit' => 1); |
|
234 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
235 | 235 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
236 | 236 | } |
237 | 237 | $restricted_query_params = $query_params; |
238 | - $restricted_query_params[ 'caps' ] = $context; |
|
239 | - $this->_set_debug_info( 'main model query params', $restricted_query_params ); |
|
240 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) ); |
|
238 | + $restricted_query_params['caps'] = $context; |
|
239 | + $this->_set_debug_info('main model query params', $restricted_query_params); |
|
240 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context)); |
|
241 | 241 | |
242 | - if( |
|
242 | + if ( |
|
243 | 243 | ! ( |
244 | - Capabilities::current_user_has_partial_access_to( $related_model, $context ) |
|
245 | - && $model->exists( $restricted_query_params ) |
|
244 | + Capabilities::current_user_has_partial_access_to($related_model, $context) |
|
245 | + && $model->exists($restricted_query_params) |
|
246 | 246 | ) |
247 | - ){ |
|
248 | - if( $relation instanceof \EE_Belongs_To_Relation ) { |
|
249 | - $related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() ); |
|
250 | - }else{ |
|
251 | - $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() ); |
|
247 | + ) { |
|
248 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
249 | + $related_model_name_maybe_plural = strtolower($related_model->get_this_model_name()); |
|
250 | + } else { |
|
251 | + $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name()); |
|
252 | 252 | } |
253 | 253 | return new \WP_Error( |
254 | - sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ), |
|
254 | + sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural), |
|
255 | 255 | sprintf( |
256 | - __( 'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ), |
|
256 | + __('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'), |
|
257 | 257 | $related_model_name_maybe_plural, |
258 | 258 | $relation->get_this_model()->get_this_model_name(), |
259 | 259 | implode( |
260 | 260 | ',', |
261 | 261 | array_keys( |
262 | - Capabilities::get_missing_permissions( $related_model, $context ) |
|
262 | + Capabilities::get_missing_permissions($related_model, $context) |
|
263 | 263 | ) |
264 | 264 | ) |
265 | 265 | ), |
266 | - array( 'status' => 403 ) |
|
266 | + array('status' => 403) |
|
267 | 267 | ); |
268 | 268 | } |
269 | - $query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() ); |
|
270 | - $query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id; |
|
271 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
272 | - $query_params[ 'caps' ] = $context; |
|
273 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
274 | - $this->_set_headers_from_query_params( $relation->get_other_model(), $query_params ); |
|
269 | + $query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params()); |
|
270 | + $query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id; |
|
271 | + $query_params['default_where_conditions'] = 'none'; |
|
272 | + $query_params['caps'] = $context; |
|
273 | + if ( ! $request->get_header('no_rest_headers')) { |
|
274 | + $this->_set_headers_from_query_params($relation->get_other_model(), $query_params); |
|
275 | 275 | } |
276 | 276 | /** @type array $results */ |
277 | - $results = $relation->get_other_model()->get_all_wpdb_results( $query_params ); |
|
277 | + $results = $relation->get_other_model()->get_all_wpdb_results($query_params); |
|
278 | 278 | $nice_results = array(); |
279 | - foreach( $results as $result ) { |
|
279 | + foreach ($results as $result) { |
|
280 | 280 | $nice_result = $this->create_entity_from_wpdb_result( |
281 | 281 | $relation->get_other_model(), |
282 | 282 | $result, |
283 | 283 | $request |
284 | 284 | ); |
285 | - if( $relation instanceof \EE_HABTM_Relation ) { |
|
285 | + if ($relation instanceof \EE_HABTM_Relation) { |
|
286 | 286 | //put the unusual stuff (properties from the HABTM relation) first, and make sure |
287 | 287 | //if there are conflicts we prefer the properties from the main model |
288 | 288 | $join_model_result = $this->create_entity_from_wpdb_result( |
@@ -290,18 +290,18 @@ discard block |
||
290 | 290 | $result, |
291 | 291 | $request |
292 | 292 | ); |
293 | - $joined_result = array_merge( $nice_result, $join_model_result ); |
|
293 | + $joined_result = array_merge($nice_result, $join_model_result); |
|
294 | 294 | //but keep the meta stuff from the main model |
295 | - if( isset( $nice_result['meta'] ) ){ |
|
295 | + if (isset($nice_result['meta'])) { |
|
296 | 296 | $joined_result['meta'] = $nice_result['meta']; |
297 | 297 | } |
298 | 298 | $nice_result = $joined_result; |
299 | 299 | } |
300 | 300 | $nice_results[] = $nice_result; |
301 | 301 | } |
302 | - if( $relation instanceof \EE_Belongs_To_Relation ){ |
|
303 | - return array_shift( $nice_results ); |
|
304 | - }else{ |
|
302 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
303 | + return array_shift($nice_results); |
|
304 | + } else { |
|
305 | 305 | return $nice_results; |
306 | 306 | } |
307 | 307 | } |
@@ -314,30 +314,30 @@ discard block |
||
314 | 314 | * @param array $query_params |
315 | 315 | * @return void |
316 | 316 | */ |
317 | - protected function _set_headers_from_query_params( $model, $query_params ) { |
|
318 | - $this->_set_debug_info( 'model query params', $query_params ); |
|
319 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) ); |
|
317 | + protected function _set_headers_from_query_params($model, $query_params) { |
|
318 | + $this->_set_debug_info('model query params', $query_params); |
|
319 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($model, $query_params['caps'])); |
|
320 | 320 | //normally the limit to a 2-part array, where the 2nd item is the limit |
321 | - if( ! isset( $query_params[ 'limit' ] ) ) { |
|
322 | - $query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
321 | + if ( ! isset($query_params['limit'])) { |
|
322 | + $query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
323 | 323 | } |
324 | - if( is_array( $query_params[ 'limit' ] ) ) { |
|
325 | - $limit_parts = $query_params[ 'limit' ]; |
|
324 | + if (is_array($query_params['limit'])) { |
|
325 | + $limit_parts = $query_params['limit']; |
|
326 | 326 | } else { |
327 | - $limit_parts = explode(',', $query_params[ 'limit' ] ); |
|
328 | - if( count( $limit_parts ) == 1 ){ |
|
329 | - $limit_parts = array(0, $limit_parts[ 0 ] ); |
|
327 | + $limit_parts = explode(',', $query_params['limit']); |
|
328 | + if (count($limit_parts) == 1) { |
|
329 | + $limit_parts = array(0, $limit_parts[0]); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | //remove the group by and having parts of the query, as those will |
333 | 333 | //make the sql query return an array of values, instead of just a single value |
334 | - unset( $query_params[ 'group_by' ], $query_params[ 'having' ], $query_params[ 'limit' ] ); |
|
335 | - $count = $model->count( $query_params, null, true ); |
|
334 | + unset($query_params['group_by'], $query_params['having'], $query_params['limit']); |
|
335 | + $count = $model->count($query_params, null, true); |
|
336 | 336 | |
337 | - $pages = $count / $limit_parts[ 1 ]; |
|
338 | - $this->_set_response_header( 'Total', $count, false ); |
|
339 | - $this->_set_response_header( 'PageSize', $limit_parts[ 1 ], false ); |
|
340 | - $this->_set_response_header( 'TotalPages', ceil( $pages ), false ); |
|
337 | + $pages = $count / $limit_parts[1]; |
|
338 | + $this->_set_response_header('Total', $count, false); |
|
339 | + $this->_set_response_header('PageSize', $limit_parts[1], false); |
|
340 | + $this->_set_response_header('TotalPages', ceil($pages), false); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | |
@@ -350,47 +350,47 @@ discard block |
||
350 | 350 | * @param string $deprecated no longer used |
351 | 351 | * @return array ready for being converted into json for sending to client |
352 | 352 | */ |
353 | - public function create_entity_from_wpdb_result( $model, $db_row, $rest_request, $deprecated = null ) { |
|
354 | - if( ! $rest_request instanceof \WP_REST_Request ) { |
|
353 | + public function create_entity_from_wpdb_result($model, $db_row, $rest_request, $deprecated = null) { |
|
354 | + if ( ! $rest_request instanceof \WP_REST_Request) { |
|
355 | 355 | //ok so this was called in the old style, where the 3rd arg was |
356 | 356 | //$include, and the 4th arg was $context |
357 | 357 | //now setup the request just to avoid fatal errors, although we won't be able |
358 | 358 | //to truly make use of it because it's kinda devoid of info |
359 | 359 | $rest_request = new \WP_REST_Request(); |
360 | - $rest_request->set_param( 'include', $rest_request ); |
|
361 | - $rest_request->set_param( 'caps', $deprecated ); |
|
360 | + $rest_request->set_param('include', $rest_request); |
|
361 | + $rest_request->set_param('caps', $deprecated); |
|
362 | 362 | } |
363 | - if( $rest_request->get_param( 'caps' ) == null ) { |
|
364 | - $rest_request->set_param( 'caps', \EEM_Base::caps_read ); |
|
363 | + if ($rest_request->get_param('caps') == null) { |
|
364 | + $rest_request->set_param('caps', \EEM_Base::caps_read); |
|
365 | 365 | } |
366 | - $entity_array = $this->_create_bare_entity_from_wpdb_results( $model, $db_row ); |
|
367 | - $entity_array = $this->_add_extra_fields( $model, $db_row, $entity_array ); |
|
368 | - $entity_array[ '_links' ] = $this->_get_entity_links( $model, $db_row, $entity_array ); |
|
369 | - $entity_array[ '_calculated_fields'] = $this->_get_entity_calculations( $model, $db_row, $rest_request ); |
|
370 | - $entity_array = $this->_include_requested_models( $model, $rest_request, $entity_array ); |
|
366 | + $entity_array = $this->_create_bare_entity_from_wpdb_results($model, $db_row); |
|
367 | + $entity_array = $this->_add_extra_fields($model, $db_row, $entity_array); |
|
368 | + $entity_array['_links'] = $this->_get_entity_links($model, $db_row, $entity_array); |
|
369 | + $entity_array['_calculated_fields'] = $this->_get_entity_calculations($model, $db_row, $rest_request); |
|
370 | + $entity_array = $this->_include_requested_models($model, $rest_request, $entity_array); |
|
371 | 371 | $entity_array = apply_filters( |
372 | 372 | 'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal', |
373 | 373 | $entity_array, |
374 | 374 | $model, |
375 | - $rest_request->get_param( 'caps' ), |
|
375 | + $rest_request->get_param('caps'), |
|
376 | 376 | $rest_request, |
377 | 377 | $this |
378 | 378 | ); |
379 | 379 | $result_without_inaccessible_fields = Capabilities::filter_out_inaccessible_entity_fields( |
380 | 380 | $entity_array, |
381 | 381 | $model, |
382 | - $rest_request->get_param( 'caps' ), |
|
382 | + $rest_request->get_param('caps'), |
|
383 | 383 | $this->get_model_version_info() |
384 | 384 | ); |
385 | 385 | $this->_set_debug_info( |
386 | 386 | 'inaccessible fields', |
387 | - array_keys( array_diff_key( $entity_array, $result_without_inaccessible_fields ) ) |
|
387 | + array_keys(array_diff_key($entity_array, $result_without_inaccessible_fields)) |
|
388 | 388 | ); |
389 | 389 | return apply_filters( |
390 | 390 | 'FHEE__Read__create_entity_from_wpdb_results__entity_return', |
391 | 391 | $result_without_inaccessible_fields, |
392 | 392 | $model, |
393 | - $rest_request->get_param( 'caps' ) |
|
393 | + $rest_request->get_param('caps') |
|
394 | 394 | ); |
395 | 395 | } |
396 | 396 | |
@@ -402,39 +402,39 @@ discard block |
||
402 | 402 | * @param array $db_row |
403 | 403 | * @return array entity mostly ready for converting to JSON and sending in the response |
404 | 404 | */ |
405 | - protected function _create_bare_entity_from_wpdb_results( \EEM_Base $model, $db_row ) { |
|
406 | - $result = $model->deduce_fields_n_values_from_cols_n_values( $db_row ); |
|
407 | - $result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) ); |
|
408 | - foreach( $result as $field_name => $raw_field_value ) { |
|
405 | + protected function _create_bare_entity_from_wpdb_results(\EEM_Base $model, $db_row) { |
|
406 | + $result = $model->deduce_fields_n_values_from_cols_n_values($db_row); |
|
407 | + $result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model)); |
|
408 | + foreach ($result as $field_name => $raw_field_value) { |
|
409 | 409 | $field_obj = $model->field_settings_for($field_name); |
410 | - $field_value = $field_obj->prepare_for_set_from_db( $raw_field_value ); |
|
411 | - if( $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_ignored() ) ){ |
|
412 | - unset( $result[ $field_name ] ); |
|
413 | - }elseif( |
|
414 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() ) |
|
415 | - ){ |
|
416 | - $result[ $field_name ] = array( |
|
417 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
418 | - 'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
410 | + $field_value = $field_obj->prepare_for_set_from_db($raw_field_value); |
|
411 | + if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) { |
|
412 | + unset($result[$field_name]); |
|
413 | + }elseif ( |
|
414 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format()) |
|
415 | + ) { |
|
416 | + $result[$field_name] = array( |
|
417 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
418 | + 'rendered' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
419 | 419 | ); |
420 | - }elseif( |
|
421 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() ) |
|
422 | - ){ |
|
423 | - $result[ $field_name ] = array( |
|
424 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
425 | - 'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
420 | + }elseif ( |
|
421 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format()) |
|
422 | + ) { |
|
423 | + $result[$field_name] = array( |
|
424 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
425 | + 'pretty' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
426 | 426 | ); |
427 | - } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
|
428 | - if( $field_value instanceof \DateTime ) { |
|
427 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
428 | + if ($field_value instanceof \DateTime) { |
|
429 | 429 | $timezone = $field_value->getTimezone(); |
430 | - $field_value->setTimezone( new \DateTimeZone( 'UTC' ) ); |
|
431 | - $result[ $field_name . '_gmt' ] = Model_Data_Translator::prepare_field_value_for_json( |
|
430 | + $field_value->setTimezone(new \DateTimeZone('UTC')); |
|
431 | + $result[$field_name.'_gmt'] = Model_Data_Translator::prepare_field_value_for_json( |
|
432 | 432 | $field_obj, |
433 | 433 | $field_value, |
434 | 434 | $this->get_model_version_info()->requested_version() |
435 | 435 | ); |
436 | - $field_value->setTimezone( $timezone ); |
|
437 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
436 | + $field_value->setTimezone($timezone); |
|
437 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
438 | 438 | $field_obj, |
439 | 439 | $field_value, |
440 | 440 | $this->get_model_version_info()->requested_version() |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | } else { |
445 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
445 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
446 | 446 | $field_obj, |
447 | - $field_obj->prepare_for_get( $field_value ), |
|
447 | + $field_obj->prepare_for_get($field_value), |
|
448 | 448 | $this->get_model_version_info()->requested_version() |
449 | 449 | ); |
450 | 450 | } |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | * @param array $entity_array |
460 | 460 | * @return array modified entity |
461 | 461 | */ |
462 | - protected function _add_extra_fields( \EEM_Base $model, $db_row, $entity_array ) { |
|
463 | - if( $model instanceof \EEM_CPT_Base ) { |
|
464 | - $entity_array[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ); |
|
462 | + protected function _add_extra_fields(\EEM_Base $model, $db_row, $entity_array) { |
|
463 | + if ($model instanceof \EEM_CPT_Base) { |
|
464 | + $entity_array['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]); |
|
465 | 465 | } |
466 | 466 | return $entity_array; |
467 | 467 | } |
@@ -475,20 +475,20 @@ discard block |
||
475 | 475 | * @param array $entity_array |
476 | 476 | * @return array the _links item in the entity |
477 | 477 | */ |
478 | - protected function _get_entity_links( $model, $db_row, $entity_array ) { |
|
478 | + protected function _get_entity_links($model, $db_row, $entity_array) { |
|
479 | 479 | //add basic links |
480 | 480 | $links = array( |
481 | 481 | 'self' => array( |
482 | 482 | array( |
483 | 483 | 'href' => $this->get_versioned_link_to( |
484 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] |
|
484 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()] |
|
485 | 485 | ) |
486 | 486 | ) |
487 | 487 | ), |
488 | 488 | 'collection' => array( |
489 | 489 | array( |
490 | 490 | 'href' => $this->get_versioned_link_to( |
491 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) |
|
491 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()) |
|
492 | 492 | ) |
493 | 493 | ) |
494 | 494 | ), |
@@ -496,24 +496,24 @@ discard block |
||
496 | 496 | |
497 | 497 | //add link to the wp core endpoint, if wp api is active |
498 | 498 | global $wp_rest_server; |
499 | - if( $model instanceof \EEM_CPT_Base && |
|
499 | + if ($model instanceof \EEM_CPT_Base && |
|
500 | 500 | $wp_rest_server instanceof \WP_REST_Server && |
501 | - $wp_rest_server->get_route_options( '/wp/v2/posts' ) ) { |
|
502 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array( |
|
501 | + $wp_rest_server->get_route_options('/wp/v2/posts')) { |
|
502 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array( |
|
503 | 503 | array( |
504 | - 'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ), |
|
504 | + 'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]), |
|
505 | 505 | 'single' => true |
506 | 506 | ) |
507 | 507 | ); |
508 | 508 | } |
509 | 509 | |
510 | 510 | //add links to related models |
511 | - foreach( $this->get_model_version_info()->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
512 | - $related_model_part = Read::get_related_entity_name( $relation_name, $relation_obj ); |
|
513 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part ] = array( |
|
511 | + foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) { |
|
512 | + $related_model_part = Read::get_related_entity_name($relation_name, $relation_obj); |
|
513 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array( |
|
514 | 514 | array( |
515 | 515 | 'href' => $this->get_versioned_link_to( |
516 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] . '/' . $related_model_part |
|
516 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()].'/'.$related_model_part |
|
517 | 517 | ), |
518 | 518 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false |
519 | 519 | ) |
@@ -529,51 +529,51 @@ discard block |
||
529 | 529 | * @param array $entity_array |
530 | 530 | * @return array the modified entity |
531 | 531 | */ |
532 | - protected function _include_requested_models( \EEM_Base $model, \WP_REST_Request $rest_request, $entity_array ) { |
|
533 | - $includes_for_this_model = $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'include' ), '' ); |
|
534 | - $includes_for_this_model = $this->_remove_model_names_from_array( $includes_for_this_model ); |
|
532 | + protected function _include_requested_models(\EEM_Base $model, \WP_REST_Request $rest_request, $entity_array) { |
|
533 | + $includes_for_this_model = $this->explode_and_get_items_prefixed_with($rest_request->get_param('include'), ''); |
|
534 | + $includes_for_this_model = $this->_remove_model_names_from_array($includes_for_this_model); |
|
535 | 535 | //if they passed in * or didn't specify any includes, return everything |
536 | - if( ! in_array( '*', $includes_for_this_model ) |
|
537 | - && ! empty( $includes_for_this_model ) ) { |
|
538 | - if( $model->has_primary_key_field() ) { |
|
536 | + if ( ! in_array('*', $includes_for_this_model) |
|
537 | + && ! empty($includes_for_this_model)) { |
|
538 | + if ($model->has_primary_key_field()) { |
|
539 | 539 | //always include the primary key. ya just gotta know that at least |
540 | 540 | $includes_for_this_model[] = $model->primary_key_name(); |
541 | 541 | } |
542 | - if( $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'calculate' ), '' ) ) { |
|
542 | + if ($this->explode_and_get_items_prefixed_with($rest_request->get_param('calculate'), '')) { |
|
543 | 543 | $includes_for_this_model[] = '_calculated_fields'; |
544 | 544 | } |
545 | - $entity_array = array_intersect_key( $entity_array, array_flip( $includes_for_this_model ) ); |
|
545 | + $entity_array = array_intersect_key($entity_array, array_flip($includes_for_this_model)); |
|
546 | 546 | } |
547 | - $relation_settings = $this->get_model_version_info()->relation_settings( $model ); |
|
548 | - foreach( $relation_settings as $relation_name => $relation_obj ) { |
|
547 | + $relation_settings = $this->get_model_version_info()->relation_settings($model); |
|
548 | + foreach ($relation_settings as $relation_name => $relation_obj) { |
|
549 | 549 | $related_fields_to_include = $this->explode_and_get_items_prefixed_with( |
550 | - $rest_request->get_param( 'include' ), |
|
550 | + $rest_request->get_param('include'), |
|
551 | 551 | $relation_name |
552 | 552 | ); |
553 | 553 | $related_fields_to_calculate = $this->explode_and_get_items_prefixed_with( |
554 | - $rest_request->get_param( 'calculate' ), |
|
554 | + $rest_request->get_param('calculate'), |
|
555 | 555 | $relation_name |
556 | 556 | ); |
557 | 557 | //did they specify they wanted to include a related model, or |
558 | 558 | //specific fields from a related model? |
559 | 559 | //or did they specify to calculate a field from a related model? |
560 | - if( $related_fields_to_include || $related_fields_to_calculate ) { |
|
560 | + if ($related_fields_to_include || $related_fields_to_calculate) { |
|
561 | 561 | //if so, we should include at least some part of the related model |
562 | 562 | $pretend_related_request = new \WP_REST_Request(); |
563 | 563 | $pretend_related_request->set_query_params( |
564 | 564 | array( |
565 | - 'caps' => $rest_request->get_param( 'caps' ), |
|
565 | + 'caps' => $rest_request->get_param('caps'), |
|
566 | 566 | 'include' => $related_fields_to_include, |
567 | 567 | 'calculate' => $related_fields_to_calculate, |
568 | 568 | ) |
569 | 569 | ); |
570 | - $pretend_related_request->add_header( 'no_rest_headers', true ); |
|
570 | + $pretend_related_request->add_header('no_rest_headers', true); |
|
571 | 571 | $related_results = $this->get_entities_from_relation( |
572 | - $entity_array[ $model->primary_key_name() ], |
|
572 | + $entity_array[$model->primary_key_name()], |
|
573 | 573 | $relation_obj, |
574 | 574 | $pretend_related_request |
575 | 575 | ); |
576 | - $entity_array[ Read::get_related_entity_name( $relation_name, $relation_obj ) ] = $related_results instanceof \WP_Error |
|
576 | + $entity_array[Read::get_related_entity_name($relation_name, $relation_obj)] = $related_results instanceof \WP_Error |
|
577 | 577 | ? null |
578 | 578 | : $related_results; |
579 | 579 | } |
@@ -587,8 +587,8 @@ discard block |
||
587 | 587 | * @param array $arr |
588 | 588 | * @return array |
589 | 589 | */ |
590 | - private function _remove_model_names_from_array( $arr ) { |
|
591 | - return array_diff( $arr, array_keys( \EE_Registry::instance()->non_abstract_db_models ) ); |
|
590 | + private function _remove_model_names_from_array($arr) { |
|
591 | + return array_diff($arr, array_keys(\EE_Registry::instance()->non_abstract_db_models)); |
|
592 | 592 | } |
593 | 593 | /** |
594 | 594 | * Gets the calculated fields for the response |
@@ -598,15 +598,15 @@ discard block |
||
598 | 598 | * @param \WP_REST_Request $rest_request |
599 | 599 | * @return \stdClass the _calculations item in the entity |
600 | 600 | */ |
601 | - protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) { |
|
601 | + protected function _get_entity_calculations($model, $wpdb_row, $rest_request) { |
|
602 | 602 | $calculated_fields = $this->explode_and_get_items_prefixed_with( |
603 | - $rest_request->get_param( 'calculate' ), |
|
603 | + $rest_request->get_param('calculate'), |
|
604 | 604 | '' |
605 | 605 | ); |
606 | 606 | //note: setting calculate=* doesn't do anything |
607 | 607 | $calculated_fields_to_return = new \stdClass(); |
608 | - foreach( $calculated_fields as $field_to_calculate ) { |
|
609 | - try{ |
|
608 | + foreach ($calculated_fields as $field_to_calculate) { |
|
609 | + try { |
|
610 | 610 | $calculated_fields_to_return->$field_to_calculate = Model_Data_Translator::prepare_field_value_for_json( |
611 | 611 | null, |
612 | 612 | $this->_fields_calculator->retrieve_calculated_field_value( |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | ), |
619 | 619 | $this->get_model_version_info()->requested_version() |
620 | 620 | ); |
621 | - } catch( Rest_Exception $e ) { |
|
621 | + } catch (Rest_Exception $e) { |
|
622 | 622 | //if we don't have permission to read it, just leave it out. but let devs know about the problem |
623 | 623 | $this->_set_response_header( |
624 | - 'Notices-Field-Calculation-Errors[' . $e->get_string_code() . '][' . $model->get_this_model_name() . '][' . $field_to_calculate . ']', |
|
624 | + 'Notices-Field-Calculation-Errors['.$e->get_string_code().']['.$model->get_this_model_name().']['.$field_to_calculate.']', |
|
625 | 625 | $e->getMessage(), |
626 | 626 | true |
627 | 627 | ); |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | * @param string $link_part_after_version_and_slash eg "events/10/datetimes" |
636 | 636 | * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes" |
637 | 637 | */ |
638 | - public function get_versioned_link_to( $link_part_after_version_and_slash ) { |
|
638 | + public function get_versioned_link_to($link_part_after_version_and_slash) { |
|
639 | 639 | return rest_url( |
640 | 640 | \EED_Core_Rest_Api::ee_api_namespace |
641 | 641 | . $this->get_model_version_info()->requested_version() |
@@ -651,11 +651,11 @@ discard block |
||
651 | 651 | * @param \EE_Model_Relation_Base $relation_obj |
652 | 652 | * @return string |
653 | 653 | */ |
654 | - public static function get_related_entity_name( $relation_name, $relation_obj ){ |
|
655 | - if( $relation_obj instanceof \EE_Belongs_To_Relation ) { |
|
656 | - return strtolower( $relation_name ); |
|
657 | - }else{ |
|
658 | - return \EEH_Inflector::pluralize_and_lower( $relation_name ); |
|
654 | + public static function get_related_entity_name($relation_name, $relation_obj) { |
|
655 | + if ($relation_obj instanceof \EE_Belongs_To_Relation) { |
|
656 | + return strtolower($relation_name); |
|
657 | + } else { |
|
658 | + return \EEH_Inflector::pluralize_and_lower($relation_name); |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | |
@@ -668,43 +668,43 @@ discard block |
||
668 | 668 | * @param \WP_REST_Request $request |
669 | 669 | * @return array|\WP_Error |
670 | 670 | */ |
671 | - public function get_entity_from_model( $model, $request ) { |
|
672 | - $query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1); |
|
673 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
671 | + public function get_entity_from_model($model, $request) { |
|
672 | + $query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1); |
|
673 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
674 | 674 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
675 | 675 | } |
676 | 676 | $restricted_query_params = $query_params; |
677 | - $restricted_query_params[ 'caps' ] = $this->validate_context( $request->get_param( 'caps' ) ); |
|
678 | - $this->_set_debug_info( 'model query params', $restricted_query_params ); |
|
679 | - $model_rows = $model->get_all_wpdb_results( $restricted_query_params ); |
|
680 | - if ( ! empty ( $model_rows ) ) { |
|
677 | + $restricted_query_params['caps'] = $this->validate_context($request->get_param('caps')); |
|
678 | + $this->_set_debug_info('model query params', $restricted_query_params); |
|
679 | + $model_rows = $model->get_all_wpdb_results($restricted_query_params); |
|
680 | + if ( ! empty ($model_rows)) { |
|
681 | 681 | return $this->create_entity_from_wpdb_result( |
682 | 682 | $model, |
683 | - array_shift( $model_rows ), |
|
683 | + array_shift($model_rows), |
|
684 | 684 | $request ); |
685 | 685 | } else { |
686 | 686 | //ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities |
687 | - $lowercase_model_name = strtolower( $model->get_this_model_name() ); |
|
688 | - $model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params ); |
|
689 | - if( ! empty( $model_rows_found_sans_restrictions ) ) { |
|
687 | + $lowercase_model_name = strtolower($model->get_this_model_name()); |
|
688 | + $model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params); |
|
689 | + if ( ! empty($model_rows_found_sans_restrictions)) { |
|
690 | 690 | //you got shafted- it existed but we didn't want to tell you! |
691 | 691 | return new \WP_Error( |
692 | 692 | 'rest_user_cannot_read', |
693 | 693 | sprintf( |
694 | - __( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ), |
|
695 | - strtolower( $model->get_this_model_name() ), |
|
694 | + __('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'), |
|
695 | + strtolower($model->get_this_model_name()), |
|
696 | 696 | Capabilities::get_missing_permissions_string( |
697 | 697 | $model, |
698 | - $this->validate_context( $request->get_param( 'caps' ) ) ) |
|
698 | + $this->validate_context($request->get_param('caps')) ) |
|
699 | 699 | ), |
700 | - array( 'status' => 403 ) |
|
700 | + array('status' => 403) |
|
701 | 701 | ); |
702 | 702 | } else { |
703 | 703 | //it's not you. It just doesn't exist |
704 | 704 | return new \WP_Error( |
705 | - sprintf( 'rest_%s_invalid_id', $lowercase_model_name ), |
|
706 | - sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ), |
|
707 | - array( 'status' => 404 ) |
|
705 | + sprintf('rest_%s_invalid_id', $lowercase_model_name), |
|
706 | + sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name), |
|
707 | + array('status' => 404) |
|
708 | 708 | ); |
709 | 709 | } |
710 | 710 | } |
@@ -717,14 +717,14 @@ discard block |
||
717 | 717 | * @param string $context |
718 | 718 | * @return string array key of EEM_Base::cap_contexts_to_cap_action_map() |
719 | 719 | */ |
720 | - public function validate_context( $context ) { |
|
721 | - if( ! $context ) { |
|
720 | + public function validate_context($context) { |
|
721 | + if ( ! $context) { |
|
722 | 722 | $context = \EEM_Base::caps_read; |
723 | 723 | } |
724 | 724 | $valid_contexts = \EEM_Base::valid_cap_contexts(); |
725 | - if( in_array( $context, $valid_contexts ) ){ |
|
725 | + if (in_array($context, $valid_contexts)) { |
|
726 | 726 | return $context; |
727 | - }else{ |
|
727 | + } else { |
|
728 | 728 | return \EEM_Base::caps_read; |
729 | 729 | } |
730 | 730 | } |
@@ -743,87 +743,87 @@ discard block |
||
743 | 743 | * that absolutely no results should be returned |
744 | 744 | * @throws \EE_Error |
745 | 745 | */ |
746 | - public function create_model_query_params( $model, $query_parameters ) { |
|
746 | + public function create_model_query_params($model, $query_parameters) { |
|
747 | 747 | $model_query_params = array( ); |
748 | - if ( isset( $query_parameters[ 'where' ] ) ) { |
|
749 | - $model_query_params[ 0 ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
750 | - $query_parameters[ 'where' ], |
|
748 | + if (isset($query_parameters['where'])) { |
|
749 | + $model_query_params[0] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
750 | + $query_parameters['where'], |
|
751 | 751 | $model, |
752 | 752 | $this->get_model_version_info()->requested_version() |
753 | 753 | ); |
754 | 754 | } |
755 | - if ( isset( $query_parameters[ 'order_by' ] ) ) { |
|
756 | - $order_by = $query_parameters[ 'order_by' ]; |
|
757 | - } elseif ( isset( $query_parameters[ 'orderby' ] ) ) { |
|
758 | - $order_by = $query_parameters[ 'orderby' ]; |
|
759 | - }else{ |
|
755 | + if (isset($query_parameters['order_by'])) { |
|
756 | + $order_by = $query_parameters['order_by']; |
|
757 | + } elseif (isset($query_parameters['orderby'])) { |
|
758 | + $order_by = $query_parameters['orderby']; |
|
759 | + } else { |
|
760 | 760 | $order_by = null; |
761 | 761 | } |
762 | - if( $order_by !== null ){ |
|
763 | - if( is_array( $order_by ) ) { |
|
764 | - $order_by = Model_Data_Translator::prepare_field_names_in_array_keys_from_json( $order_by ); |
|
762 | + if ($order_by !== null) { |
|
763 | + if (is_array($order_by)) { |
|
764 | + $order_by = Model_Data_Translator::prepare_field_names_in_array_keys_from_json($order_by); |
|
765 | 765 | } else { |
766 | 766 | //it's a single item |
767 | - $order_by = Model_Data_Translator::prepare_field_name_from_json( $order_by ); |
|
767 | + $order_by = Model_Data_Translator::prepare_field_name_from_json($order_by); |
|
768 | 768 | } |
769 | - $model_query_params[ 'order_by' ] = $order_by; |
|
769 | + $model_query_params['order_by'] = $order_by; |
|
770 | 770 | } |
771 | - if ( isset( $query_parameters[ 'group_by' ] ) ) { |
|
772 | - $group_by = $query_parameters[ 'group_by' ]; |
|
773 | - } elseif ( isset( $query_parameters[ 'groupby' ] ) ) { |
|
774 | - $group_by = $query_parameters[ 'groupby' ]; |
|
775 | - }else{ |
|
776 | - $group_by = array_keys( $model->get_combined_primary_key_fields() ); |
|
771 | + if (isset($query_parameters['group_by'])) { |
|
772 | + $group_by = $query_parameters['group_by']; |
|
773 | + } elseif (isset($query_parameters['groupby'])) { |
|
774 | + $group_by = $query_parameters['groupby']; |
|
775 | + } else { |
|
776 | + $group_by = array_keys($model->get_combined_primary_key_fields()); |
|
777 | 777 | } |
778 | 778 | //make sure they're all real names |
779 | - if( is_array( $group_by ) ) { |
|
780 | - $group_by = Model_Data_Translator::prepare_field_names_from_json( $group_by ); |
|
779 | + if (is_array($group_by)) { |
|
780 | + $group_by = Model_Data_Translator::prepare_field_names_from_json($group_by); |
|
781 | 781 | } |
782 | - if( $group_by !== null ){ |
|
783 | - $model_query_params[ 'group_by' ] = $group_by; |
|
782 | + if ($group_by !== null) { |
|
783 | + $model_query_params['group_by'] = $group_by; |
|
784 | 784 | } |
785 | - if ( isset( $query_parameters[ 'having' ] ) ) { |
|
786 | - $model_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
787 | - $query_parameters[ 'having' ], |
|
785 | + if (isset($query_parameters['having'])) { |
|
786 | + $model_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
787 | + $query_parameters['having'], |
|
788 | 788 | $model, |
789 | 789 | $this->get_model_version_info()->requested_version() |
790 | 790 | ); |
791 | 791 | } |
792 | - if ( isset( $query_parameters[ 'order' ] ) ) { |
|
793 | - $model_query_params[ 'order' ] = $query_parameters[ 'order' ]; |
|
792 | + if (isset($query_parameters['order'])) { |
|
793 | + $model_query_params['order'] = $query_parameters['order']; |
|
794 | 794 | } |
795 | - if ( isset( $query_parameters[ 'mine' ] ) ){ |
|
796 | - $model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params ); |
|
795 | + if (isset($query_parameters['mine'])) { |
|
796 | + $model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params); |
|
797 | 797 | } |
798 | - if( isset( $query_parameters[ 'limit' ] ) ) { |
|
798 | + if (isset($query_parameters['limit'])) { |
|
799 | 799 | //limit should be either a string like '23' or '23,43', or an array with two items in it |
800 | - if( ! is_array( $query_parameters[ 'limit' ] ) ) { |
|
801 | - $limit_array = explode(',', (string)$query_parameters['limit']); |
|
802 | - }else { |
|
803 | - $limit_array = $query_parameters[ 'limit' ]; |
|
800 | + if ( ! is_array($query_parameters['limit'])) { |
|
801 | + $limit_array = explode(',', (string) $query_parameters['limit']); |
|
802 | + } else { |
|
803 | + $limit_array = $query_parameters['limit']; |
|
804 | 804 | } |
805 | 805 | $sanitized_limit = array(); |
806 | - foreach( $limit_array as $key => $limit_part ) { |
|
807 | - if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) { |
|
806 | + foreach ($limit_array as $key => $limit_part) { |
|
807 | + if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) { |
|
808 | 808 | throw new \EE_Error( |
809 | 809 | sprintf( |
810 | - __( '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' ), |
|
811 | - json_encode( $query_parameters[ 'limit' ] ) |
|
810 | + __('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'), |
|
811 | + json_encode($query_parameters['limit']) |
|
812 | 812 | ) |
813 | 813 | ); |
814 | 814 | } |
815 | - $sanitized_limit[] = (int)$limit_part; |
|
815 | + $sanitized_limit[] = (int) $limit_part; |
|
816 | 816 | } |
817 | - $model_query_params[ 'limit' ] = implode( ',', $sanitized_limit ); |
|
818 | - }else{ |
|
819 | - $model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
817 | + $model_query_params['limit'] = implode(',', $sanitized_limit); |
|
818 | + } else { |
|
819 | + $model_query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
820 | 820 | } |
821 | - if( isset( $query_parameters[ 'caps' ] ) ) { |
|
822 | - $model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] ); |
|
823 | - }else{ |
|
824 | - $model_query_params[ 'caps' ] = \EEM_Base::caps_read; |
|
821 | + if (isset($query_parameters['caps'])) { |
|
822 | + $model_query_params['caps'] = $this->validate_context($query_parameters['caps']); |
|
823 | + } else { |
|
824 | + $model_query_params['caps'] = \EEM_Base::caps_read; |
|
825 | 825 | } |
826 | - return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model ); |
|
826 | + return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | |
@@ -835,13 +835,13 @@ discard block |
||
835 | 835 | * @param array $query_params sub-array from @see EEM_Base::get_all() |
836 | 836 | * @return array |
837 | 837 | */ |
838 | - public function prepare_rest_query_params_key_for_models( $model, $query_params ) { |
|
838 | + public function prepare_rest_query_params_key_for_models($model, $query_params) { |
|
839 | 839 | $model_ready_query_params = array(); |
840 | - foreach( $query_params as $key => $value ) { |
|
841 | - if( is_array( $value ) ) { |
|
842 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value ); |
|
843 | - }else{ |
|
844 | - $model_ready_query_params[ $key ] = $value; |
|
840 | + foreach ($query_params as $key => $value) { |
|
841 | + if (is_array($value)) { |
|
842 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value); |
|
843 | + } else { |
|
844 | + $model_ready_query_params[$key] = $value; |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | return $model_ready_query_params; |
@@ -855,13 +855,13 @@ discard block |
||
855 | 855 | * @param $query_params |
856 | 856 | * @return array |
857 | 857 | */ |
858 | - public function prepare_rest_query_params_values_for_models( $model, $query_params ) { |
|
858 | + public function prepare_rest_query_params_values_for_models($model, $query_params) { |
|
859 | 859 | $model_ready_query_params = array(); |
860 | - foreach( $query_params as $key => $value ) { |
|
861 | - if( is_array( $value ) ) { |
|
862 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value ); |
|
860 | + foreach ($query_params as $key => $value) { |
|
861 | + if (is_array($value)) { |
|
862 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value); |
|
863 | 863 | } else { |
864 | - $model_ready_query_params[ $key ] = $value; |
|
864 | + $model_ready_query_params[$key] = $value; |
|
865 | 865 | } |
866 | 866 | } |
867 | 867 | return $model_ready_query_params; |
@@ -876,33 +876,33 @@ discard block |
||
876 | 876 | * we only return strings starting with that and a period; if no prefix was specified |
877 | 877 | * we return all items containing NO periods |
878 | 878 | */ |
879 | - public function explode_and_get_items_prefixed_with( $string_to_explode, $prefix ) { |
|
880 | - if( is_string( $string_to_explode ) ) { |
|
881 | - $exploded_contents = explode( ',', $string_to_explode ); |
|
882 | - } else if( is_array( $string_to_explode ) ) { |
|
879 | + public function explode_and_get_items_prefixed_with($string_to_explode, $prefix) { |
|
880 | + if (is_string($string_to_explode)) { |
|
881 | + $exploded_contents = explode(',', $string_to_explode); |
|
882 | + } else if (is_array($string_to_explode)) { |
|
883 | 883 | $exploded_contents = $string_to_explode; |
884 | 884 | } else { |
885 | 885 | $exploded_contents = array(); |
886 | 886 | } |
887 | 887 | //if the string was empty, we want an empty array |
888 | - $exploded_contents = array_filter( $exploded_contents ); |
|
888 | + $exploded_contents = array_filter($exploded_contents); |
|
889 | 889 | $contents_with_prefix = array(); |
890 | - foreach( $exploded_contents as $item ) { |
|
891 | - $item = trim( $item ); |
|
890 | + foreach ($exploded_contents as $item) { |
|
891 | + $item = trim($item); |
|
892 | 892 | //if no prefix was provided, so we look for items with no "." in them |
893 | - if( ! $prefix ) { |
|
893 | + if ( ! $prefix) { |
|
894 | 894 | //does this item have a period? |
895 | - if( strpos( $item, '.' ) === false ) { |
|
895 | + if (strpos($item, '.') === false) { |
|
896 | 896 | //if not, then its what we're looking for |
897 | 897 | $contents_with_prefix[] = $item; |
898 | 898 | } |
899 | - } else if( strpos( $item, $prefix . '.' ) === 0 ) { |
|
899 | + } else if (strpos($item, $prefix.'.') === 0) { |
|
900 | 900 | //this item has the prefix and a period, grab it |
901 | 901 | $contents_with_prefix[] = substr( |
902 | 902 | $item, |
903 | - strpos( $item, $prefix . '.' ) + strlen( $prefix . '.' ) |
|
903 | + strpos($item, $prefix.'.') + strlen($prefix.'.') |
|
904 | 904 | ); |
905 | - } else if( $item === $prefix ) { |
|
905 | + } else if ($item === $prefix) { |
|
906 | 906 | //this item is JUST the prefix |
907 | 907 | //so let's grab everything after, which is a blank string |
908 | 908 | $contents_with_prefix[] = ''; |
@@ -925,33 +925,33 @@ discard block |
||
925 | 925 | * the fields for that model, with the model's name removed from each. |
926 | 926 | * If $include_string was blank or '*' returns an empty array |
927 | 927 | */ |
928 | - public function extract_includes_for_this_model( $include_string, $model_name = null ) { |
|
929 | - if( is_array( $include_string ) ) { |
|
930 | - $include_string = implode( ',', $include_string ); |
|
928 | + public function extract_includes_for_this_model($include_string, $model_name = null) { |
|
929 | + if (is_array($include_string)) { |
|
930 | + $include_string = implode(',', $include_string); |
|
931 | 931 | } |
932 | - if( $include_string === '*' || $include_string === '' ) { |
|
932 | + if ($include_string === '*' || $include_string === '') { |
|
933 | 933 | return array(); |
934 | 934 | } |
935 | - $includes = explode( ',', $include_string ); |
|
935 | + $includes = explode(',', $include_string); |
|
936 | 936 | $extracted_fields_to_include = array(); |
937 | - if( $model_name ){ |
|
938 | - foreach( $includes as $field_to_include ) { |
|
939 | - $field_to_include = trim( $field_to_include ); |
|
940 | - if( strpos( $field_to_include, $model_name . '.' ) === 0 ) { |
|
937 | + if ($model_name) { |
|
938 | + foreach ($includes as $field_to_include) { |
|
939 | + $field_to_include = trim($field_to_include); |
|
940 | + if (strpos($field_to_include, $model_name.'.') === 0) { |
|
941 | 941 | //found the model name at the exact start |
942 | - $field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include ); |
|
942 | + $field_sans_model_name = str_replace($model_name.'.', '', $field_to_include); |
|
943 | 943 | $extracted_fields_to_include[] = $field_sans_model_name; |
944 | - }elseif( $field_to_include == $model_name ){ |
|
944 | + }elseif ($field_to_include == $model_name) { |
|
945 | 945 | $extracted_fields_to_include[] = '*'; |
946 | 946 | } |
947 | 947 | } |
948 | - }else{ |
|
948 | + } else { |
|
949 | 949 | //look for ones with no period |
950 | - foreach( $includes as $field_to_include ) { |
|
951 | - $field_to_include = trim( $field_to_include ); |
|
950 | + foreach ($includes as $field_to_include) { |
|
951 | + $field_to_include = trim($field_to_include); |
|
952 | 952 | if ( |
953 | - strpos( $field_to_include, '.' ) === false |
|
954 | - && ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include ) |
|
953 | + strpos($field_to_include, '.') === false |
|
954 | + && ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include) |
|
955 | 955 | ) { |
956 | 956 | $extracted_fields_to_include[] = $field_to_include; |
957 | 957 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
3 | 3 | |
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 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | self::$_field_calculator = new Calculated_Model_Fields(); |
38 | - return parent::get_instance( __CLASS__ ); |
|
38 | + return parent::get_instance(__CLASS__); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | |
66 | 66 | |
67 | 67 | public static function set_hooks_both() { |
68 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
69 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
70 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
71 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
68 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
69 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
70 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
71 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
72 | 72 | EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
73 | 73 | } |
74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * Loads all the hooks which make requests to old versions of the API |
88 | 88 | * appear the same as they always did |
89 | 89 | */ |
90 | - public static function set_hooks_for_changes(){ |
|
90 | + public static function set_hooks_for_changes() { |
|
91 | 91 | self::_set_hooks_for_changes(); |
92 | 92 | } |
93 | 93 | |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | * replace it with application passwords. |
98 | 98 | */ |
99 | 99 | public static function maybe_notify_of_basic_auth_removal() { |
100 | - if( |
|
100 | + if ( |
|
101 | 101 | apply_filters( |
102 | 102 | 'FHEE__EED_Core_Rest_Api__maybe_notify_of_basic_auth_removal__override', |
103 | - ! isset( $_SERVER['PHP_AUTH_USER'] ) |
|
104 | - && ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) |
|
103 | + ! isset($_SERVER['PHP_AUTH_USER']) |
|
104 | + && ! isset($_SERVER['HTTP_AUTHORIZATION']) |
|
105 | 105 | ) |
106 | 106 | ) { |
107 | 107 | //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
@@ -109,20 +109,20 @@ discard block |
||
109 | 109 | } |
110 | 110 | //ok they're using the WP API with Basic Auth |
111 | 111 | $message = sprintf( |
112 | - __( 'We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso' ), |
|
112 | + __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso'), |
|
113 | 113 | '<a href="https://wordpress.org/plugins/application-passwords/">', |
114 | 114 | '</a>', |
115 | 115 | '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
116 | 116 | '<br/>' |
117 | 117 | ); |
118 | - EE_Error::add_persistent_admin_notice( 'using_basic_auth', $message ); |
|
119 | - if( ! get_option( 'ee_notified_admin_on_basic_auth_removal', false ) ) { |
|
120 | - add_option( 'ee_notified_admin_on_basic_auth_removal', true ); |
|
118 | + EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
119 | + if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
120 | + add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
121 | 121 | //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
122 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
122 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
123 | 123 | //and send the message to the site admin too |
124 | - wp_mail( get_option( 'admin_email' ), __( 'Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso' ), $message ); |
|
125 | - remove_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
124 | + wp_mail(get_option('admin_email'), __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
125 | + remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | /** |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | * appear the same as they always did |
131 | 131 | */ |
132 | 132 | protected static function _set_hooks_for_changes() { |
133 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
134 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
133 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
134 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
135 | 135 | //ignore the base parent class |
136 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
136 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
137 | 137 | continue; |
138 | 138 | } |
139 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
140 | - if ( class_exists( $full_classname )) { |
|
139 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
140 | + if (class_exists($full_classname)) { |
|
141 | 141 | $instance_of_class = new $full_classname; |
142 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
142 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
143 | 143 | $instance_of_class->set_hooks(); |
144 | 144 | } |
145 | 145 | } |
@@ -152,16 +152,16 @@ discard block |
||
152 | 152 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
153 | 153 | */ |
154 | 154 | public static function register_routes() { |
155 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
156 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
157 | - foreach( $routes as $route ) { |
|
155 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
156 | + foreach ($relative_urls as $endpoint => $routes) { |
|
157 | + foreach ($routes as $route) { |
|
158 | 158 | register_rest_route( |
159 | 159 | $namespace, |
160 | 160 | $endpoint, |
161 | 161 | array( |
162 | - 'callback' => $route[ 'callback' ], |
|
163 | - 'methods' => $route[ 'methods' ], |
|
164 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
162 | + 'callback' => $route['callback'], |
|
163 | + 'methods' => $route['methods'], |
|
164 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
165 | 165 | ) |
166 | 166 | ); |
167 | 167 | } |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | * next time the WP API is used |
176 | 176 | */ |
177 | 177 | public static function invalidate_cached_route_data_on_version_change() { |
178 | - if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) { |
|
178 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
179 | 179 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
180 | 180 | } |
181 | - foreach( EE_Registry::instance()->addons as $addon ){ |
|
182 | - if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) { |
|
181 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
182 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
183 | 183 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
184 | 184 | } |
185 | 185 | } |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public static function invalidate_cached_route_data() { |
192 | 192 | //delete the saved EE REST API routes |
193 | - foreach( EED_Core_Rest_Api::versions_served() as $version => $hidden ){ |
|
194 | - delete_option( EED_Core_Rest_Api::saved_routes_option_names . $version ); |
|
193 | + foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
|
194 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names.$version); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public static function get_ee_route_data() { |
207 | 207 | $ee_routes = array(); |
208 | - foreach( self::versions_served() as $version => $hidden_endpoints ) { |
|
209 | - $ee_routes[ self::ee_api_namespace . $version ] = self::_get_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
208 | + foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
209 | + $ee_routes[self::ee_api_namespace.$version] = self::_get_ee_route_data_for_version($version, $hidden_endpoints); |
|
210 | 210 | } |
211 | 211 | return $ee_routes; |
212 | 212 | } |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | * @param boolean $hidden_endpoints |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - protected static function _get_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
222 | - $ee_routes = get_option( self::saved_routes_option_names . $version , null ); |
|
223 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
224 | - $ee_routes = self::_save_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
221 | + protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
222 | + $ee_routes = get_option(self::saved_routes_option_names.$version, null); |
|
223 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
224 | + $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
225 | 225 | } |
226 | 226 | return $ee_routes; |
227 | 227 | } |
@@ -235,18 +235,18 @@ discard block |
||
235 | 235 | * @param boolean $hidden_endpoints |
236 | 236 | * @return mixed|null|void |
237 | 237 | */ |
238 | - protected static function _save_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
238 | + protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
239 | 239 | $instance = self::instance(); |
240 | 240 | $routes = apply_filters( |
241 | 241 | 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
242 | 242 | array_replace_recursive( |
243 | - $instance->_get_config_route_data_for_version( $version, $hidden_endpoints ), |
|
244 | - $instance->_get_meta_route_data_for_version( $version, $hidden_endpoints ), |
|
245 | - $instance->_get_model_route_data_for_version( $version, $hidden_endpoints ), |
|
246 | - $instance->_get_rpc_route_data_for_version( $version, $hidden_endpoints ) |
|
243 | + $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
244 | + $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
245 | + $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
246 | + $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
247 | 247 | ) |
248 | 248 | ); |
249 | - update_option( self::saved_routes_option_names . $version, $routes, true ); |
|
249 | + update_option(self::saved_routes_option_names.$version, $routes, true); |
|
250 | 250 | return $routes; |
251 | 251 | } |
252 | 252 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return void |
258 | 258 | */ |
259 | 259 | public static function save_ee_routes() { |
260 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
260 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
261 | 261 | $instance = self::instance(); |
262 | 262 | $routes = apply_filters( |
263 | 263 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $instance->_register_rpc_routes() |
269 | 269 | ) |
270 | 270 | ); |
271 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
271 | + update_option(self::saved_routes_option_names, $routes, true); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | */ |
280 | 280 | protected function _register_model_routes() { |
281 | 281 | $model_routes = array( ); |
282 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
283 | - $model_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
282 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
283 | + $model_routes[EED_Core_Rest_Api::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
284 | 284 | } |
285 | 285 | return $model_routes; |
286 | 286 | } |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | * @param boolean $hidden_endpoint |
292 | 292 | * @return array |
293 | 293 | */ |
294 | - protected function _get_model_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
295 | - $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info( $version ); |
|
294 | + protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) { |
|
295 | + $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
296 | 296 | $models_to_register = apply_filters( |
297 | 297 | 'FHEE__EED_Core_REST_API___register_model_routes', |
298 | 298 | $model_version_info->models_for_requested_version() |
@@ -301,21 +301,21 @@ discard block |
||
301 | 301 | unset($models_to_register['Extra_Meta']); |
302 | 302 | unset($models_to_register['Extra_Join']); |
303 | 303 | $model_routes = array(); |
304 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
305 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
304 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
305 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
306 | 306 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
307 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
308 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
309 | - $model_routes[ $plural_model_route ] = array( |
|
307 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
308 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
309 | + $model_routes[$plural_model_route] = array( |
|
310 | 310 | array( |
311 | 311 | 'callback' => array( |
312 | 312 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
313 | 313 | 'handle_request_get_all' ), |
314 | 314 | 'methods' => WP_REST_Server::READABLE, |
315 | 315 | 'hidden_endpoint' => $hidden_endpoint, |
316 | - 'args' => $this->_get_read_query_params( $model, $version ), |
|
316 | + 'args' => $this->_get_read_query_params($model, $version), |
|
317 | 317 | '_links' => array( |
318 | - 'self' => rest_url( EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route ), |
|
318 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route), |
|
319 | 319 | ) |
320 | 320 | ), |
321 | 321 | // array( |
@@ -326,14 +326,14 @@ discard block |
||
326 | 326 | // 'hidden_endpoint' => $hidden_endpoint |
327 | 327 | // ) |
328 | 328 | ); |
329 | - $model_routes[ $singular_model_route ] = array( |
|
329 | + $model_routes[$singular_model_route] = array( |
|
330 | 330 | array( |
331 | 331 | 'callback' => array( |
332 | 332 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
333 | 333 | 'handle_request_get_one' ), |
334 | 334 | 'methods' => WP_REST_Server::READABLE, |
335 | 335 | 'hidden_endpoint' => $hidden_endpoint, |
336 | - 'args' => $this->_get_response_selection_query_params( $model, $version) |
|
336 | + 'args' => $this->_get_response_selection_query_params($model, $version) |
|
337 | 337 | ), |
338 | 338 | // array( |
339 | 339 | // 'callback' => array( |
@@ -344,19 +344,19 @@ discard block |
||
344 | 344 | // ), |
345 | 345 | ); |
346 | 346 | //@todo: also handle DELETE for a single item |
347 | - foreach ( $model_version_info->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
347 | + foreach ($model_version_info->relation_settings($model) as $relation_name => $relation_obj) { |
|
348 | 348 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
349 | 349 | $relation_name, |
350 | 350 | $relation_obj |
351 | 351 | ); |
352 | - $model_routes[ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
352 | + $model_routes[$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
353 | 353 | array( |
354 | 354 | 'callback' => array( |
355 | 355 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
356 | 356 | 'handle_request_get_related' ), |
357 | 357 | 'methods' => WP_REST_Server::READABLE, |
358 | 358 | 'hidden_endpoint' => $hidden_endpoint, |
359 | - 'args' => $this->_get_read_query_params( $relation_obj->get_other_model(), $version ), |
|
359 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
360 | 360 | ), |
361 | 361 | // array( |
362 | 362 | // 'callback' => array( |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | */ |
380 | 380 | protected function _register_rpc_routes() { |
381 | 381 | $routes = array(); |
382 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
383 | - $routes[ self::ee_api_namespace . $version ] = $this->_get_rpc_route_data_for_version( $version, $hidden_endpoint ); |
|
382 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
383 | + $routes[self::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version($version, $hidden_endpoint); |
|
384 | 384 | } |
385 | 385 | return $routes; |
386 | 386 | } |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | * @param boolean $hidden_endpoint |
392 | 392 | * @return array |
393 | 393 | */ |
394 | - protected function _get_rpc_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
394 | + protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) { |
|
395 | 395 | $this_versions_routes = array(); |
396 | 396 | //checkin endpoint |
397 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
397 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
398 | 398 | array( |
399 | 399 | 'callback' => array( |
400 | 400 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | 'force' => array( |
406 | 406 | 'required' => false, |
407 | 407 | 'default' => false, |
408 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
408 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
409 | 409 | ) |
410 | 410 | ) |
411 | 411 | ) |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param string $version |
425 | 425 | * @return array |
426 | 426 | */ |
427 | - protected function _get_response_selection_query_params( \EEM_Base $model, $version ) { |
|
427 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) { |
|
428 | 428 | return apply_filters( |
429 | 429 | 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
430 | 430 | array( |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | 'calculate' => array( |
436 | 436 | 'required' => false, |
437 | 437 | 'default' => '', |
438 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model( $model ) |
|
438 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model) |
|
439 | 439 | ) |
440 | 440 | ), |
441 | 441 | $model, |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | * @return array describing the args acceptable when querying this model |
454 | 454 | * @throws \EE_Error |
455 | 455 | */ |
456 | - protected function _get_read_query_params( \EEM_Base $model, $version ) { |
|
456 | + protected function _get_read_query_params(\EEM_Base $model, $version) { |
|
457 | 457 | $default_orderby = array(); |
458 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
459 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
458 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
459 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
460 | 460 | } |
461 | 461 | return array_merge( |
462 | - $this->_get_response_selection_query_params( $model, $version ), |
|
462 | + $this->_get_response_selection_query_params($model, $version), |
|
463 | 463 | array( |
464 | 464 | 'where' => array( |
465 | 465 | 'required' => false, |
@@ -496,8 +496,8 @@ discard block |
||
496 | 496 | */ |
497 | 497 | protected function _register_config_routes() { |
498 | 498 | $config_routes = array(); |
499 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
500 | - $config_routes[ self::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
499 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
500 | + $config_routes[self::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
501 | 501 | } |
502 | 502 | return $config_routes; |
503 | 503 | } |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @param boolean $hidden_endpoint |
509 | 509 | * @return array |
510 | 510 | */ |
511 | - protected function _get_config_route_data_for_version( $version, $hidden_endpoint ) { |
|
511 | + protected function _get_config_route_data_for_version($version, $hidden_endpoint) { |
|
512 | 512 | return array( |
513 | 513 | 'config' => array( |
514 | 514 | array( |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | */ |
539 | 539 | protected function _register_meta_routes() { |
540 | 540 | $meta_routes = array(); |
541 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
542 | - $meta_routes[ self::ee_api_namespace . $version ] = $this->_get_meta_route_data_for_version( $version, $hidden_endpoint ); |
|
541 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
542 | + $meta_routes[self::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version($version, $hidden_endpoint); |
|
543 | 543 | } |
544 | 544 | return $meta_routes; |
545 | 545 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @param boolean $hidden_endpoint |
551 | 551 | * @return array |
552 | 552 | */ |
553 | - protected function _get_meta_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
553 | + protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) { |
|
554 | 554 | return array( |
555 | 555 | 'resources' => array( |
556 | 556 | array( |
@@ -572,13 +572,13 @@ discard block |
||
572 | 572 | * @param array $route_data |
573 | 573 | * @return array |
574 | 574 | */ |
575 | - public static function hide_old_endpoints( $route_data ) { |
|
576 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
577 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
578 | - foreach( $routes as $route ) { |
|
579 | - if( $route[ 'hidden_endpoint' ] ) { |
|
580 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
581 | - unset( $route_data[ $full_route ] ); |
|
575 | + public static function hide_old_endpoints($route_data) { |
|
576 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
577 | + foreach ($relative_urls as $endpoint => $routes) { |
|
578 | + foreach ($routes as $route) { |
|
579 | + if ($route['hidden_endpoint']) { |
|
580 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
581 | + unset($route_data[$full_route]); |
|
582 | 582 | } |
583 | 583 | } |
584 | 584 | } |
@@ -617,8 +617,8 @@ discard block |
||
617 | 617 | */ |
618 | 618 | public static function latest_rest_api_version() { |
619 | 619 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
620 | - $versions_served_keys = array_keys( $versions_served ); |
|
621 | - return end( $versions_served_keys ); |
|
620 | + $versions_served_keys = array_keys($versions_served); |
|
621 | + return end($versions_served_keys); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -632,32 +632,32 @@ discard block |
||
632 | 632 | public static function versions_served() { |
633 | 633 | $versions_served = array(); |
634 | 634 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
635 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
636 | - reset( $possibly_served_versions ); |
|
637 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
638 | - $latest_version = end( $versions_served_historically ); |
|
639 | - reset( $versions_served_historically ); |
|
635 | + $lowest_compatible_version = end($possibly_served_versions); |
|
636 | + reset($possibly_served_versions); |
|
637 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
638 | + $latest_version = end($versions_served_historically); |
|
639 | + reset($versions_served_historically); |
|
640 | 640 | //for each version of core we have ever served: |
641 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
641 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
642 | 642 | //if it's not above the current core version, and it's compatible with the current version of core |
643 | - if( $key_versioned_endpoint == $latest_version ) { |
|
643 | + if ($key_versioned_endpoint == $latest_version) { |
|
644 | 644 | //don't hide the latest version in the index |
645 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
646 | - } else if( |
|
645 | + $versions_served[$key_versioned_endpoint] = false; |
|
646 | + } else if ( |
|
647 | 647 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
648 | 648 | && $key_versioned_endpoint >= $lowest_compatible_version |
649 | 649 | ) { |
650 | 650 | //include, but hide, previous versions which are still supported |
651 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
652 | - } elseif( |
|
651 | + $versions_served[$key_versioned_endpoint] = true; |
|
652 | + } elseif ( |
|
653 | 653 | apply_filters( |
654 | 654 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
655 | 655 | false, |
656 | 656 | $possibly_served_versions |
657 | 657 | ) |
658 | - ){ |
|
658 | + ) { |
|
659 | 659 | //if a version is no longer supported, don't include it in index or list of versions served |
660 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
660 | + $versions_served[$key_versioned_endpoint] = true; |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 | return $versions_served; |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * @return string |
671 | 671 | */ |
672 | 672 | public static function core_version() { |
673 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
673 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | * @param WP $WP |
696 | 696 | * @return void |
697 | 697 | */ |
698 | - public function run( $WP ) { |
|
698 | + public function run($WP) { |
|
699 | 699 | |
700 | 700 | } |
701 | 701 |
@@ -864,8 +864,8 @@ |
||
864 | 864 | //set the attendee array to blank on each loop; |
865 | 865 | $aee = array(); |
866 | 866 | if ( isset( $this->_data->reg_obj ) |
867 | - && ( $this->_data->reg_obj->attendee_ID() != $att_id ) |
|
868 | - && $this->_single_message |
|
867 | + && ( $this->_data->reg_obj->attendee_ID() != $att_id ) |
|
868 | + && $this->_single_message |
|
869 | 869 | ) { |
870 | 870 | continue; |
871 | 871 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * EE_Base_Class_Object |
275 | 275 | * @return mixed ( EE_Base_Class||EE_Base_Class[] ) |
276 | 276 | */ |
277 | - abstract protected function _get_data_for_context( $context, EE_Registration $registration, $id ); |
|
277 | + abstract protected function _get_data_for_context($context, EE_Registration $registration, $id); |
|
278 | 278 | |
279 | 279 | |
280 | 280 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @deprecated 4.9.0 |
302 | 302 | * @return int |
303 | 303 | */ |
304 | - protected function _get_id_for_msg_url( $context, EE_Registration $registration ) { |
|
304 | + protected function _get_id_for_msg_url($context, EE_Registration $registration) { |
|
305 | 305 | return 0; |
306 | 306 | } |
307 | 307 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * sending. |
331 | 331 | * @since 4.9.0 |
332 | 332 | */ |
333 | - public function do_messenger_hooks( $messenger = null ) { |
|
333 | + public function do_messenger_hooks($messenger = null) { |
|
334 | 334 | $this->_active_messenger = $messenger; |
335 | 335 | $this->_do_messenger_hooks(); |
336 | 336 | } |
@@ -379,10 +379,10 @@ discard block |
||
379 | 379 | * @param mixed $data This sets the data property for the message type with the incoming data used for generating. |
380 | 380 | * @return string (the reference for the data handler) (will be an empty string if could not be determined). |
381 | 381 | */ |
382 | - public function get_data_handler( $data ) { |
|
382 | + public function get_data_handler($data) { |
|
383 | 383 | $this->_data = $data; |
384 | 384 | $this->_set_data_handler(); |
385 | - return apply_filters( 'FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this ); |
|
385 | + return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -419,26 +419,26 @@ discard block |
||
419 | 419 | * @deprecated 4.9.0 Likely 4.9.10 or 4.10.0 will remove this method completely |
420 | 420 | * @return string generated url |
421 | 421 | */ |
422 | - public function get_url_trigger( $context, $sending_messenger, EE_Registration $registration ) { |
|
422 | + public function get_url_trigger($context, $sending_messenger, EE_Registration $registration) { |
|
423 | 423 | //validate context |
424 | 424 | //valid context? |
425 | - if ( ! isset( $this->_contexts[ $context ] ) ) { |
|
425 | + if ( ! isset($this->_contexts[$context])) { |
|
426 | 426 | throw new EE_Error( |
427 | 427 | sprintf( |
428 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
428 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
429 | 429 | $context, |
430 | - get_class( $this ) |
|
430 | + get_class($this) |
|
431 | 431 | ) |
432 | 432 | ); |
433 | 433 | } |
434 | 434 | //valid sending_messenger? |
435 | 435 | $not_valid_msgr = false; |
436 | - foreach ( $this->_with_messengers as $generating => $sendings ) { |
|
437 | - if ( empty( $sendings ) || array_search( $sending_messenger, $sendings ) === false ) { |
|
436 | + foreach ($this->_with_messengers as $generating => $sendings) { |
|
437 | + if (empty($sendings) || array_search($sending_messenger, $sendings) === false) { |
|
438 | 438 | $not_valid_msgr = true; |
439 | 439 | } |
440 | 440 | } |
441 | - if ( $not_valid_msgr ) { |
|
441 | + if ($not_valid_msgr) { |
|
442 | 442 | throw new EE_Error( |
443 | 443 | sprintf( |
444 | 444 | __( |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | 'event_espresso' |
447 | 447 | ), |
448 | 448 | $sending_messenger, |
449 | - get_class( $this ) |
|
449 | + get_class($this) |
|
450 | 450 | ) |
451 | 451 | ); |
452 | 452 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | $this->name, |
458 | 458 | $registration, |
459 | 459 | $this->_GRP_ID, |
460 | - $this->_get_id_for_msg_url( $context, $registration ) |
|
460 | + $this->_get_id_for_msg_url($context, $registration) |
|
461 | 461 | ); |
462 | 462 | } |
463 | 463 | |
@@ -476,26 +476,26 @@ discard block |
||
476 | 476 | * EE_Base_Class_Object |
477 | 477 | * @return mixed (EE_Base_Class||EE_Base_Class[]) |
478 | 478 | */ |
479 | - public function get_data_for_context( $context, EE_Registration $registration, $id = 0 ) { |
|
479 | + public function get_data_for_context($context, EE_Registration $registration, $id = 0) { |
|
480 | 480 | //valid context? |
481 | - if ( ! isset( $this->_contexts[ $context ] ) ) { |
|
481 | + if ( ! isset($this->_contexts[$context])) { |
|
482 | 482 | throw new EE_Error( |
483 | 483 | sprintf( |
484 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
484 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
485 | 485 | $context, |
486 | - get_class( $this ) |
|
486 | + get_class($this) |
|
487 | 487 | ) |
488 | 488 | ); |
489 | 489 | } |
490 | 490 | //get data and apply global and class specific filters on it. |
491 | 491 | $data = apply_filters( |
492 | 492 | 'FHEE__EE_message_type__get_data_for_context__data', |
493 | - $this->_get_data_for_context( $context, $registration, $id ), |
|
493 | + $this->_get_data_for_context($context, $registration, $id), |
|
494 | 494 | $this |
495 | 495 | ); |
496 | - $data = apply_filters( 'FHEE__' . get_class( $this ) . '__get_data_for_context__data', $data, $this ); |
|
496 | + $data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this); |
|
497 | 497 | //if empty then something went wrong! |
498 | - if ( empty( $data ) ) { |
|
498 | + if (empty($data)) { |
|
499 | 499 | throw new EE_Error( |
500 | 500 | sprintf( |
501 | 501 | __( |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | */ |
540 | 540 | protected function _set_with_messengers() { |
541 | 541 | $this->_with_messengers = array( |
542 | - 'email' => array( 'html' ), |
|
542 | + 'email' => array('html'), |
|
543 | 543 | ); |
544 | 544 | } |
545 | 545 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | */ |
554 | 554 | public function with_messengers() { |
555 | 555 | return apply_filters( |
556 | - 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class( $this ), |
|
556 | + 'FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this), |
|
557 | 557 | $this->_with_messengers |
558 | 558 | ); |
559 | 559 | } |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | $messengers = array() |
581 | 581 | ) { |
582 | 582 | //we can also further refine the context by action (if present). |
583 | - return $this->_get_admin_page_content( $page, $action, $extra, $messengers ); |
|
583 | + return $this->_get_admin_page_content($page, $action, $extra, $messengers); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | |
@@ -615,10 +615,10 @@ discard block |
||
615 | 615 | public function get_master_templates() { |
616 | 616 | //first class specific filter then filter that by the global filter. |
617 | 617 | $master_templates = apply_filters( |
618 | - 'FHEE__' . get_class( $this ) . '__get_master_templates', |
|
618 | + 'FHEE__'.get_class($this).'__get_master_templates', |
|
619 | 619 | $this->_master_templates |
620 | 620 | ); |
621 | - return apply_filters( 'FHEE__EE_message_type__get_master_templates', $master_templates, $this ); |
|
621 | + return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | |
@@ -632,20 +632,20 @@ discard block |
||
632 | 632 | * @return array An array indexed by context where each context is an array of EE_Messages_Addressee objects for |
633 | 633 | * that context |
634 | 634 | */ |
635 | - public function get_addressees( EE_Messages_incoming_data $data, $context = '' ) { |
|
635 | + public function get_addressees(EE_Messages_incoming_data $data, $context = '') { |
|
636 | 636 | //override _data |
637 | 637 | $this->_data = $data; |
638 | 638 | $addressees = array(); |
639 | 639 | //if incoming context then limit to that context |
640 | - if ( ! empty( $context ) ) { |
|
641 | - $cntxt = ! empty( $this->_contexts[ $context ] ) ? $this->_contexts[ $context ] : ''; |
|
642 | - if ( ! empty( $cntxt ) ) { |
|
640 | + if ( ! empty($context)) { |
|
641 | + $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : ''; |
|
642 | + if ( ! empty($cntxt)) { |
|
643 | 643 | $this->_contexts = array(); |
644 | - $this->_contexts[ $context ] = $cntxt; |
|
644 | + $this->_contexts[$context] = $cntxt; |
|
645 | 645 | } |
646 | 646 | } |
647 | 647 | $this->_set_default_addressee_data(); |
648 | - if ( $this->_process_data() ) { |
|
648 | + if ($this->_process_data()) { |
|
649 | 649 | $addressees = $this->_addressees; |
650 | 650 | } |
651 | 651 | return $addressees; |
@@ -661,14 +661,14 @@ discard block |
||
661 | 661 | */ |
662 | 662 | protected function _process_data() { |
663 | 663 | //at a minimum, we NEED EE_Attendee objects. |
664 | - if ( empty( $this->_data->attendees ) ) { |
|
665 | - return false; //there's no data to process! |
|
664 | + if (empty($this->_data->attendees)) { |
|
665 | + return false; //there's no data to process! |
|
666 | 666 | } |
667 | 667 | // process addressees for each context. Child classes will have to have methods for |
668 | 668 | // each context defined to handle the processing of the data object within them |
669 | - foreach ( $this->_contexts as $context => $details ) { |
|
670 | - $xpctd_method = '_' . $context . '_addressees'; |
|
671 | - if ( ! method_exists( $this, $xpctd_method ) ) { |
|
669 | + foreach ($this->_contexts as $context => $details) { |
|
670 | + $xpctd_method = '_'.$context.'_addressees'; |
|
671 | + if ( ! method_exists($this, $xpctd_method)) { |
|
672 | 672 | throw new EE_Error( |
673 | 673 | sprintf( |
674 | 674 | __( |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | ) |
681 | 681 | ); |
682 | 682 | } |
683 | - $this->_addressees[ $context ] = call_user_func( array( $this, $xpctd_method ) ); |
|
683 | + $this->_addressees[$context] = call_user_func(array($this, $xpctd_method)); |
|
684 | 684 | } |
685 | 685 | return true; //data was processed successfully. |
686 | 686 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | 'grand_total_line_item' => $this->_data->grand_total_line_item, |
703 | 703 | 'txn' => $this->_data->txn, |
704 | 704 | 'payments' => $this->_data->payments, |
705 | - 'payment' => isset( $this->_data->payment ) && $this->_data->payment instanceof EE_Payment |
|
705 | + 'payment' => isset($this->_data->payment) && $this->_data->payment instanceof EE_Payment |
|
706 | 706 | ? $this->_data->payment |
707 | 707 | : null, |
708 | 708 | 'reg_objs' => $this->_data->reg_objs, |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | 'txn_status' => $this->_data->txn_status, |
716 | 716 | 'total_ticket_count' => $this->_data->total_ticket_count, |
717 | 717 | ); |
718 | - if ( is_array( $this->_data->primary_attendee_data ) ) { |
|
718 | + if (is_array($this->_data->primary_attendee_data)) { |
|
719 | 719 | $this->_default_addressee_data = array_merge( |
720 | 720 | $this->_default_addressee_data, |
721 | 721 | $this->_data->primary_attendee_data |
@@ -759,24 +759,24 @@ discard block |
||
759 | 759 | 'messenger', |
760 | 760 | ); |
761 | 761 | $contexts = $this->get_contexts(); |
762 | - foreach ( $contexts as $context => $details ) { |
|
763 | - $this->_valid_shortcodes[ $context ] = $all_shortcodes; |
|
762 | + foreach ($contexts as $context => $details) { |
|
763 | + $this->_valid_shortcodes[$context] = $all_shortcodes; |
|
764 | 764 | //make sure non admin context does not include the event_author shortcodes |
765 | - if ( $context != 'admin' ) { |
|
766 | - if ( ( $key = array_search( 'event_author', $this->_valid_shortcodes[ $context ] ) ) !== false ) { |
|
767 | - unset( $this->_valid_shortcodes[ $context ][ $key ] ); |
|
765 | + if ($context != 'admin') { |
|
766 | + if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) { |
|
767 | + unset($this->_valid_shortcodes[$context][$key]); |
|
768 | 768 | } |
769 | 769 | } |
770 | 770 | } |
771 | 771 | // make sure admin context does not include the recipient_details shortcodes |
772 | 772 | // IF we have admin context hooked in message types might not have that context. |
773 | - if ( ! empty( $this->_valid_shortcodes['admin'] ) ) { |
|
774 | - if ( ( $key = array_search( 'recipient_details', $this->_valid_shortcodes['admin'] ) ) !== false ) { |
|
775 | - unset( $this->_valid_shortcodes['admin'][ $key ] ); |
|
773 | + if ( ! empty($this->_valid_shortcodes['admin'])) { |
|
774 | + if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) { |
|
775 | + unset($this->_valid_shortcodes['admin'][$key]); |
|
776 | 776 | } |
777 | 777 | //make sure admin context does not include the recipient_details shortcodes |
778 | - if ( ( $key = array_search( 'recipient_list', $this->_valid_shortcodes['admin'] ) ) !== false ) { |
|
779 | - unset( $this->_valid_shortcodes['admin'][ $key ] ); |
|
778 | + if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) { |
|
779 | + unset($this->_valid_shortcodes['admin'][$key]); |
|
780 | 780 | } |
781 | 781 | } |
782 | 782 | } |
@@ -789,9 +789,9 @@ discard block |
||
789 | 789 | * @param array $new_config array of valid shortcodes (by context) |
790 | 790 | * @return void sets valid_shortcodes property |
791 | 791 | */ |
792 | - public function reset_valid_shortcodes_config( $new_config ) { |
|
793 | - foreach ( $new_config as $context => $shortcodes ) { |
|
794 | - $this->_valid_shortcodes[ $context ] = $shortcodes; |
|
792 | + public function reset_valid_shortcodes_config($new_config) { |
|
793 | + foreach ($new_config as $context => $shortcodes) { |
|
794 | + $this->_valid_shortcodes[$context] = $shortcodes; |
|
795 | 795 | } |
796 | 796 | } |
797 | 797 | |
@@ -808,13 +808,13 @@ discard block |
||
808 | 808 | $addressees = array(); |
809 | 809 | // first we need to get the event admin user id for all the events |
810 | 810 | // and setup an addressee object for each unique admin user. |
811 | - foreach ( $this->_data->events as $line_ref => $event ) { |
|
812 | - $admin_id = $this->_get_event_admin_id( $event['ID'] ); |
|
811 | + foreach ($this->_data->events as $line_ref => $event) { |
|
812 | + $admin_id = $this->_get_event_admin_id($event['ID']); |
|
813 | 813 | //make sure we are just including the events that belong to this admin! |
814 | - $admin_events[ $admin_id ][ $line_ref ] = $event; |
|
814 | + $admin_events[$admin_id][$line_ref] = $event; |
|
815 | 815 | } |
816 | 816 | //k now we can loop through the event_admins and setup the addressee data. |
817 | - foreach ( $admin_events as $admin_id => $event_details ) { |
|
817 | + foreach ($admin_events as $admin_id => $event_details) { |
|
818 | 818 | $aee = array( |
819 | 819 | 'user_id' => $admin_id, |
820 | 820 | 'events' => $event_details, |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | 'recipient_id' => $admin_id, |
823 | 823 | 'recipient_type' => 'WP_User', |
824 | 824 | ); |
825 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
826 | - $addressees[] = new EE_Messages_Addressee( $aee ); |
|
825 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
826 | + $addressees[] = new EE_Messages_Addressee($aee); |
|
827 | 827 | } |
828 | 828 | return $addressees; |
829 | 829 | } |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | $aee['recipient_id'] = $aee['primary_att_obj'] instanceof EE_Attendee ? $aee['primary_att_obj']->ID() : 0; |
844 | 844 | $aee['recipient_type'] = 'Attendee'; |
845 | 845 | //great now we can instantiate the $addressee object and return (as an array); |
846 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
846 | + $add[] = new EE_Messages_Addressee($aee); |
|
847 | 847 | return $add; |
848 | 848 | } |
849 | 849 | |
@@ -860,25 +860,25 @@ discard block |
||
860 | 860 | //we just have to loop through the attendees. We'll also set the attached events for each attendee. |
861 | 861 | //use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we? |
862 | 862 | $already_processed = array(); |
863 | - foreach ( $this->_data->attendees as $att_id => $details ) { |
|
863 | + foreach ($this->_data->attendees as $att_id => $details) { |
|
864 | 864 | //set the attendee array to blank on each loop; |
865 | 865 | $aee = array(); |
866 | - if ( isset( $this->_data->reg_obj ) |
|
867 | - && ( $this->_data->reg_obj->attendee_ID() != $att_id ) |
|
866 | + if (isset($this->_data->reg_obj) |
|
867 | + && ($this->_data->reg_obj->attendee_ID() != $att_id) |
|
868 | 868 | && $this->_single_message |
869 | 869 | ) { |
870 | 870 | continue; |
871 | 871 | } |
872 | 872 | // is $this->_regs_for_sending present? |
873 | 873 | // If so, let's make sure we ONLY generate addressee for registrations in that array. |
874 | - if ( ! empty( $this->_regs_for_sending ) && is_array( $this->_regs_for_sending ) ) { |
|
875 | - $regs_allowed = array_intersect_key( array_flip( $this->_regs_for_sending ), $details['reg_objs'] ); |
|
876 | - if ( empty( $regs_allowed ) ) { |
|
874 | + if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) { |
|
875 | + $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']); |
|
876 | + if (empty($regs_allowed)) { |
|
877 | 877 | continue; |
878 | 878 | } |
879 | 879 | } |
880 | 880 | if ( |
881 | - in_array( $details['attendee_email'], $already_processed ) |
|
881 | + in_array($details['attendee_email'], $already_processed) |
|
882 | 882 | && apply_filters( |
883 | 883 | 'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends', |
884 | 884 | true, |
@@ -889,14 +889,14 @@ discard block |
||
889 | 889 | continue; |
890 | 890 | } |
891 | 891 | $already_processed[] = $details['attendee_email']; |
892 | - foreach ( $details as $item => $value ) { |
|
893 | - $aee[ $item ] = $value; |
|
894 | - if ( $item == 'line_ref' ) { |
|
895 | - foreach ( $value as $event_id ) { |
|
896 | - $aee['events'][ $event_id ] = $this->_data->events[ $event_id ]; |
|
892 | + foreach ($details as $item => $value) { |
|
893 | + $aee[$item] = $value; |
|
894 | + if ($item == 'line_ref') { |
|
895 | + foreach ($value as $event_id) { |
|
896 | + $aee['events'][$event_id] = $this->_data->events[$event_id]; |
|
897 | 897 | } |
898 | 898 | } |
899 | - if ( $item == 'attendee_email' ) { |
|
899 | + if ($item == 'attendee_email') { |
|
900 | 900 | $aee['attendee_email'] = $value; |
901 | 901 | } |
902 | 902 | /*if ( $item == 'registration_id' ) { |
@@ -905,13 +905,13 @@ discard block |
||
905 | 905 | } |
906 | 906 | // note the FIRST reg object in this array is the one |
907 | 907 | // we'll use for this attendee as the primary registration for this attendee. |
908 | - $aee['reg_obj'] = reset( $this->_data->attendees[ $att_id ]['reg_objs'] ); |
|
908 | + $aee['reg_obj'] = reset($this->_data->attendees[$att_id]['reg_objs']); |
|
909 | 909 | $aee['attendees'] = $this->_data->attendees; |
910 | 910 | $aee['recipient_id'] = $att_id; |
911 | 911 | $aee['recipient_type'] = 'Attendee'; |
912 | 912 | //merge in the primary attendee data |
913 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
914 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
913 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
914 | + $add[] = new EE_Messages_Addressee($aee); |
|
915 | 915 | } |
916 | 916 | return $add; |
917 | 917 | } |
@@ -922,8 +922,8 @@ discard block |
||
922 | 922 | * @param $event_id |
923 | 923 | * @return int |
924 | 924 | */ |
925 | - protected function _get_event_admin_id( $event_id ) { |
|
926 | - $event = EEM_Event::instance()->get_one_by_ID( $event_id ); |
|
925 | + protected function _get_event_admin_id($event_id) { |
|
926 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
927 | 927 | return $event instanceof EE_Event ? $event->wp_user() : 0; |
928 | 928 | } |
929 | 929 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param array $addressee_data We're expecting an incoming array of data that will be used to fill the properties |
261 | 261 | * for the object. |
262 | 262 | */ |
263 | - public function __construct( $addressee_data ) { |
|
263 | + public function __construct($addressee_data) { |
|
264 | 264 | $this->_data = $addressee_data; |
265 | 265 | $this->_set_properties(); |
266 | 266 | } |
@@ -275,15 +275,15 @@ discard block |
||
275 | 275 | * @return void. |
276 | 276 | */ |
277 | 277 | protected function _set_properties() { |
278 | - foreach ( $this->_data as $prop => $value ) { |
|
279 | - if ( property_exists( $this, $prop ) ) { |
|
278 | + foreach ($this->_data as $prop => $value) { |
|
279 | + if (property_exists($this, $prop)) { |
|
280 | 280 | $this->{$prop} = $value; |
281 | 281 | } |
282 | 282 | } |
283 | 283 | //if user_id present we'll use this to set the fname and lname and admin_email. |
284 | - if ( ! empty( $this->user_id ) ) { |
|
284 | + if ( ! empty($this->user_id)) { |
|
285 | 285 | $this->user_id = (int) $this->user_id; |
286 | - $user = get_userdata( $this->user_id ); |
|
286 | + $user = get_userdata($this->user_id); |
|
287 | 287 | $this->fname = $user->user_firstname; |
288 | 288 | $this->lname = $user->user_lastname; |
289 | 289 | $this->admin_email = $user->user_email; |
@@ -1,6 +1,6 @@ discard block |
||
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 | /** |
@@ -40,50 +40,50 @@ discard block |
||
40 | 40 | |
41 | 41 | |
42 | 42 | protected function _init_props() { |
43 | - $this->label = esc_html__( 'Transaction Shortcodes', 'event_espresso' ); |
|
44 | - $this->description = esc_html__( 'All shortcodes specific to transaction related data', 'event_espresso' ); |
|
43 | + $this->label = esc_html__('Transaction Shortcodes', 'event_espresso'); |
|
44 | + $this->description = esc_html__('All shortcodes specific to transaction related data', 'event_espresso'); |
|
45 | 45 | $this->_shortcodes = array( |
46 | - '[TXN_ID]' => esc_html__( 'The transaction id for the purchase.', 'event_espresso' ), |
|
47 | - '[PAYMENT_URL]' => esc_html__( 'This is a link to make a payment for the event', 'event_espresso' ), |
|
48 | - '[PAYMENT_LINK_IF_NEEDED_*]' => esc_html__( 'This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso' ) . '<ul>' |
|
49 | - . '<li>' . sprintf( esc_html__( '%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
50 | - . '<li>' . sprintf( esc_html__( '%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
51 | - . '<li>' . sprintf( esc_html__( '%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
46 | + '[TXN_ID]' => esc_html__('The transaction id for the purchase.', 'event_espresso'), |
|
47 | + '[PAYMENT_URL]' => esc_html__('This is a link to make a payment for the event', 'event_espresso'), |
|
48 | + '[PAYMENT_LINK_IF_NEEDED_*]' => esc_html__('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso').'<ul>' |
|
49 | + . '<li>'.sprintf(esc_html__('%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
50 | + . '<li>'.sprintf(esc_html__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
51 | + . '<li>'.sprintf(esc_html__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
52 | 52 | . '</ul>', |
53 | - '[PAYMENT_DUE_DATE_*]' => esc_html__( 'This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso' ) |
|
53 | + '[PAYMENT_DUE_DATE_*]' => esc_html__('This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso') |
|
54 | 54 | . '<ul>' |
55 | - . '<li>' . sprintf( esc_html__( '%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
56 | - . '<li>' . sprintf( esc_html__( '%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
57 | - . '<li>' . sprintf( esc_html__( '%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>', |
|
58 | - '[INVOICE_LINK]' => esc_html__( 'This is a full html link to the invoice', 'event_espresso' ), |
|
59 | - '[INVOICE_URL]' => esc_html__( 'This is just the url for the invoice', 'event_espresso' ), |
|
60 | - '[INVOICE_LOGO_URL]' => esc_html__( 'This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso' ), |
|
61 | - '[INVOICE_LOGO]' => esc_html__( 'This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso' ), |
|
62 | - '[INVOICE_PAYEE_NAME]' => esc_html__( 'This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
63 | - '[INVOICE_PAYEE_ADDRESS]' => esc_html__( 'This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
64 | - '[INVOICE_PAYMENT_INSTRUCTIONS]' => esc_html__( 'This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso' ), |
|
65 | - '[INVOICE_PAYEE_EMAIL]' => esc_html__( 'This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
66 | - '[INVOICE_PAYEE_TAX_NUMBER_*]' => sprintf( esc_html__( 'This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso' ), '<code>', '</code>' ), |
|
67 | - '[TOTAL_COST]' => esc_html__( 'The total cost for the transaction', 'event_espresso' ), |
|
68 | - '[TXN_STATUS]' => esc_html__( 'The transaction status for the transaction.', 'event_espresso' ), |
|
69 | - '[TXN_STATUS_ID]' => esc_html__( 'The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso' ), |
|
70 | - '[PAYMENT_STATUS]' => esc_html__( 'The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.', 'event_espresso' ), |
|
71 | - '[PAYMENT_GATEWAY]' => esc_html__( 'The payment gateway used for the transaction', 'event_espresso' ), |
|
72 | - '[AMOUNT_PAID]' => esc_html__( 'The amount paid or refunded. This will only have a value if there was a payment or refund at the time of generating the message.', 'event_espresso' ), |
|
73 | - '[LAST_AMOUNT_PAID]' => esc_html__( 'This is the last payment or refund made on the transaction related to the message being generated.', 'event_espresso' ), |
|
74 | - '[TOTAL_AMOUNT_PAID]' => esc_html__( 'This parses to the total amount paid over all payments', 'event_espresso' ), |
|
75 | - '[TOTAL_OWING]' => esc_html__( 'The total owing on a transaction with no attributes.', 'event_espresso' ), |
|
76 | - '[TXN_SUBTOTAL]' => esc_html__( 'The subtotal for all txn line items.', 'event_espresso' ), |
|
77 | - '[TXN_TAX_SUBTOTAL]' => esc_html__( 'The subtotal for all tax line items.', 'event_espresso' ), |
|
78 | - '[OWING_STATUS_MESSAGE_*]' => esc_html__( 'A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso' ) . '<p></ul>' . |
|
79 | - '<li><strong>still_owing</strong>:' . esc_html__( 'If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:', 'event_espresso' ) . sprintf( esc_html__( '%sPlease make a payment.%s', 'event_espresso' ), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ) . '</li>' . |
|
80 | - '<li><strong>none_owing</strong>:' . esc_html__( 'If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total owing.', 'event_espresso' ) . '</li></ul></p>', |
|
81 | - '[TXN_TOTAL_TICKETS]' => esc_html__( 'The total number of all tickets purchased in a transaction', 'event_espresso' ), |
|
82 | - '[TKT_QTY_PURCHASED]' => sprintf( esc_html__( 'The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s', 'event_espresso' ), '<strong>', '</strong>' ), |
|
83 | - '[TRANSACTION_ADMIN_URL]' => esc_html__( 'The url to the admin page for this transaction', 'event_espresso' ), |
|
84 | - '[RECEIPT_URL]' => esc_html__( 'This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso' ), |
|
85 | - '[INVOICE_RECEIPT_SWITCHER_URL]' => esc_html__( 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso' ), |
|
86 | - '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( esc_html__( 'The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso' ), '<code>', '</code>' ) |
|
55 | + . '<li>'.sprintf(esc_html__('%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
56 | + . '<li>'.sprintf(esc_html__('%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
57 | + . '<li>'.sprintf(esc_html__('%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso'), '<strong>', '</strong>').'</li>', |
|
58 | + '[INVOICE_LINK]' => esc_html__('This is a full html link to the invoice', 'event_espresso'), |
|
59 | + '[INVOICE_URL]' => esc_html__('This is just the url for the invoice', 'event_espresso'), |
|
60 | + '[INVOICE_LOGO_URL]' => esc_html__('This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso'), |
|
61 | + '[INVOICE_LOGO]' => esc_html__('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso'), |
|
62 | + '[INVOICE_PAYEE_NAME]' => esc_html__('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
63 | + '[INVOICE_PAYEE_ADDRESS]' => esc_html__('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
64 | + '[INVOICE_PAYMENT_INSTRUCTIONS]' => esc_html__('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso'), |
|
65 | + '[INVOICE_PAYEE_EMAIL]' => esc_html__('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
66 | + '[INVOICE_PAYEE_TAX_NUMBER_*]' => sprintf(esc_html__('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso'), '<code>', '</code>'), |
|
67 | + '[TOTAL_COST]' => esc_html__('The total cost for the transaction', 'event_espresso'), |
|
68 | + '[TXN_STATUS]' => esc_html__('The transaction status for the transaction.', 'event_espresso'), |
|
69 | + '[TXN_STATUS_ID]' => esc_html__('The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso'), |
|
70 | + '[PAYMENT_STATUS]' => esc_html__('The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.', 'event_espresso'), |
|
71 | + '[PAYMENT_GATEWAY]' => esc_html__('The payment gateway used for the transaction', 'event_espresso'), |
|
72 | + '[AMOUNT_PAID]' => esc_html__('The amount paid or refunded. This will only have a value if there was a payment or refund at the time of generating the message.', 'event_espresso'), |
|
73 | + '[LAST_AMOUNT_PAID]' => esc_html__('This is the last payment or refund made on the transaction related to the message being generated.', 'event_espresso'), |
|
74 | + '[TOTAL_AMOUNT_PAID]' => esc_html__('This parses to the total amount paid over all payments', 'event_espresso'), |
|
75 | + '[TOTAL_OWING]' => esc_html__('The total owing on a transaction with no attributes.', 'event_espresso'), |
|
76 | + '[TXN_SUBTOTAL]' => esc_html__('The subtotal for all txn line items.', 'event_espresso'), |
|
77 | + '[TXN_TAX_SUBTOTAL]' => esc_html__('The subtotal for all tax line items.', 'event_espresso'), |
|
78 | + '[OWING_STATUS_MESSAGE_*]' => esc_html__('A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso').'<p></ul>'. |
|
79 | + '<li><strong>still_owing</strong>:'.esc_html__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:', 'event_espresso').sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>').'</li>'. |
|
80 | + '<li><strong>none_owing</strong>:'.esc_html__('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total owing.', 'event_espresso').'</li></ul></p>', |
|
81 | + '[TXN_TOTAL_TICKETS]' => esc_html__('The total number of all tickets purchased in a transaction', 'event_espresso'), |
|
82 | + '[TKT_QTY_PURCHASED]' => sprintf(esc_html__('The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s', 'event_espresso'), '<strong>', '</strong>'), |
|
83 | + '[TRANSACTION_ADMIN_URL]' => esc_html__('The url to the admin page for this transaction', 'event_espresso'), |
|
84 | + '[RECEIPT_URL]' => esc_html__('This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso'), |
|
85 | + '[INVOICE_RECEIPT_SWITCHER_URL]' => esc_html__('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
86 | + '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(esc_html__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso'), '<code>', '</code>') |
|
87 | 87 | ); |
88 | 88 | } |
89 | 89 | |
@@ -94,40 +94,40 @@ discard block |
||
94 | 94 | * @param string $shortcode the shortcode to be parsed. |
95 | 95 | * @return string parsed shortcode |
96 | 96 | */ |
97 | - protected function _parser( $shortcode ) { |
|
97 | + protected function _parser($shortcode) { |
|
98 | 98 | |
99 | 99 | //attempt to get the transaction. Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction. |
100 | 100 | $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
101 | - $transaction = ! $transaction instanceof EE_Transaction && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn: $transaction; |
|
101 | + $transaction = ! $transaction instanceof EE_Transaction && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn : $transaction; |
|
102 | 102 | |
103 | 103 | //payment |
104 | 104 | $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null; |
105 | - $payment = ! $payment instanceof EE_Payment && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment: $payment; |
|
105 | + $payment = ! $payment instanceof EE_Payment && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment : $payment; |
|
106 | 106 | |
107 | 107 | |
108 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
108 | + if ( ! $transaction instanceof EE_Transaction) { |
|
109 | 109 | return ''; |
110 | 110 | } |
111 | 111 | |
112 | - switch ( $shortcode ) { |
|
112 | + switch ($shortcode) { |
|
113 | 113 | case '[TXN_ID]' : |
114 | 114 | return $transaction->ID(); |
115 | 115 | break; |
116 | 116 | |
117 | 117 | case '[PAYMENT_URL]' : |
118 | 118 | $payment_url = $transaction->payment_overview_url(); |
119 | - return empty( $payment_url ) ? esc_html__( 'http://dummypaymenturlforpreview.com', 'event_espresso' ) : $payment_url; |
|
119 | + return empty($payment_url) ? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
120 | 120 | break; |
121 | 121 | |
122 | 122 | case '[INVOICE_LINK]' : |
123 | 123 | $invoice_url = $transaction->invoice_url(); |
124 | - $invoice_url = empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
125 | - return sprintf( esc_html__( '%sClick here for Invoice%s', 'event_espresso' ), '<a href="' . $invoice_url . '">', '</a>' ); |
|
124 | + $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
125 | + return sprintf(esc_html__('%sClick here for Invoice%s', 'event_espresso'), '<a href="'.$invoice_url.'">', '</a>'); |
|
126 | 126 | break; /**/ |
127 | 127 | |
128 | 128 | case '[INVOICE_URL]' : |
129 | 129 | $invoice_url = $transaction->invoice_url(); |
130 | - return empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
130 | + return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
131 | 131 | break; |
132 | 132 | |
133 | 133 | case '[INVOICE_LOGO_URL]' : |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | break; |
136 | 136 | |
137 | 137 | case '[INVOICE_LOGO]' : |
138 | - return $this->_get_invoice_logo( true ); |
|
138 | + return $this->_get_invoice_logo(true); |
|
139 | 139 | break; |
140 | 140 | |
141 | 141 | case '[INVOICE_PAYEE_NAME]' : |
@@ -157,18 +157,18 @@ discard block |
||
157 | 157 | |
158 | 158 | case '[TOTAL_COST]' : |
159 | 159 | $total = $transaction->total(); |
160 | - return ! empty($total) ? EEH_Template::format_currency( $total ) : ''; |
|
160 | + return ! empty($total) ? EEH_Template::format_currency($total) : ''; |
|
161 | 161 | break; |
162 | 162 | |
163 | 163 | case '[PAYMENT_STATUS]' : |
164 | 164 | $status = $transaction->pretty_status(); |
165 | - return ! empty($status) ? $status : esc_html__( 'Unknown', 'event_espresso' ); |
|
165 | + return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
166 | 166 | break; /**/ |
167 | 167 | |
168 | 168 | // note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity. |
169 | 169 | case '[TXN_STATUS]': |
170 | 170 | $status = $transaction->pretty_status(); |
171 | - return ! empty( $status ) ? $status : esc_html__( 'Unknown', 'event_espresso' ); |
|
171 | + return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
172 | 172 | break; |
173 | 173 | |
174 | 174 | case '[TXN_STATUS_ID]' : |
@@ -176,36 +176,36 @@ discard block |
||
176 | 176 | break; |
177 | 177 | |
178 | 178 | case '[PAYMENT_GATEWAY]' : |
179 | - return $this->_get_payment_gateway( $transaction ); |
|
179 | + return $this->_get_payment_gateway($transaction); |
|
180 | 180 | break; |
181 | 181 | |
182 | 182 | case '[AMOUNT_PAID]' : |
183 | 183 | return $payment instanceof EE_Payment |
184 | - ? EEH_Template::format_currency( $payment->amount() ) |
|
185 | - : EEH_Template::format_currency( 0 ); |
|
184 | + ? EEH_Template::format_currency($payment->amount()) |
|
185 | + : EEH_Template::format_currency(0); |
|
186 | 186 | break; |
187 | 187 | |
188 | 188 | case '[LAST_AMOUNT_PAID]' : |
189 | 189 | $last_payment = $transaction->last_payment(); |
190 | 190 | return $last_payment instanceof EE_Payment |
191 | - ? EEH_Template::format_currency( $last_payment->amount() ) |
|
192 | - : EEH_Template::format_currency( 0 ); |
|
191 | + ? EEH_Template::format_currency($last_payment->amount()) |
|
192 | + : EEH_Template::format_currency(0); |
|
193 | 193 | |
194 | 194 | case '[TOTAL_AMOUNT_PAID]' : |
195 | - return EEH_Template::format_currency( $transaction->paid() ); |
|
195 | + return EEH_Template::format_currency($transaction->paid()); |
|
196 | 196 | break; |
197 | 197 | |
198 | 198 | case '[TOTAL_OWING]' : |
199 | 199 | $total_owing = $transaction->remaining(); |
200 | - return EEH_Template::format_currency( $total_owing ); |
|
200 | + return EEH_Template::format_currency($total_owing); |
|
201 | 201 | break; |
202 | 202 | |
203 | 203 | case '[TXN_SUBTOTAL]' : |
204 | - return EEH_Template::format_currency( $this->_get_subtotal() ); |
|
204 | + return EEH_Template::format_currency($this->_get_subtotal()); |
|
205 | 205 | break; |
206 | 206 | |
207 | 207 | case '[TXN_TAX_SUBTOTAL]' : |
208 | - return EEH_Template::format_currency( $this->_get_subtotal( true ) ); |
|
208 | + return EEH_Template::format_currency($this->_get_subtotal(true)); |
|
209 | 209 | break; |
210 | 210 | |
211 | 211 | case '[TKT_QTY_PURCHASED]' : |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | break; |
215 | 215 | |
216 | 216 | case '[TRANSACTION_ADMIN_URL]' : |
217 | - require_once EE_CORE . 'admin/EE_Admin_Page.core.php'; |
|
218 | - $query_args = array( 'page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() ); |
|
219 | - $url = EE_Admin_Page::add_query_args_and_nonce( $query_args, admin_url( 'admin.php' ) ); |
|
217 | + require_once EE_CORE.'admin/EE_Admin_Page.core.php'; |
|
218 | + $query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID()); |
|
219 | + $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')); |
|
220 | 220 | return $url; |
221 | 221 | break; |
222 | 222 | |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | //get primary_registration |
225 | 225 | $reg = $this->_data->primary_reg_obj; |
226 | 226 | |
227 | - if ( ! $reg instanceof EE_Registration ) { |
|
227 | + if ( ! $reg instanceof EE_Registration) { |
|
228 | 228 | return ''; |
229 | 229 | } |
230 | 230 | return $reg->receipt_url(); |
231 | 231 | break; |
232 | 232 | |
233 | 233 | case '[INVOICE_RECEIPT_SWITCHER_URL]' : |
234 | - return $this->_get_invoice_receipt_switcher( false ); |
|
234 | + return $this->_get_invoice_receipt_switcher(false); |
|
235 | 235 | break; |
236 | 236 | |
237 | 237 | case '[INVOICE_RECEIPT_SWITCHER_BUTTON]' : |
@@ -241,20 +241,20 @@ discard block |
||
241 | 241 | |
242 | 242 | } |
243 | 243 | |
244 | - if ( strpos( $shortcode, '[OWING_STATUS_MESSAGE_*' ) !== false ) { |
|
245 | - return $this->_get_custom_total_owing( $shortcode ); |
|
244 | + if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== false) { |
|
245 | + return $this->_get_custom_total_owing($shortcode); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( strpos( $shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*' ) !== false ) { |
|
249 | - return $this->_get_invoice_payee_tax_number( $shortcode ); |
|
248 | + if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== false) { |
|
249 | + return $this->_get_invoice_payee_tax_number($shortcode); |
|
250 | 250 | } |
251 | 251 | |
252 | - if ( strpos( $shortcode, '[PAYMENT_LINK_IF_NEEDED_*' ) !== false ) { |
|
253 | - return $this->_get_payment_link_if_needed( $shortcode ); |
|
252 | + if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== false) { |
|
253 | + return $this->_get_payment_link_if_needed($shortcode); |
|
254 | 254 | } |
255 | 255 | |
256 | - if ( strpos( $shortcode, '[PAYMENT_DUE_DATE_*' ) !== false ) { |
|
257 | - return $this->_get_payment_due_date( $shortcode, $transaction ); |
|
256 | + if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) { |
|
257 | + return $this->_get_payment_due_date($shortcode, $transaction); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | return ''; |
@@ -271,19 +271,19 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return string parsed. |
273 | 273 | */ |
274 | - private function _get_custom_total_owing( $shortcode ) { |
|
275 | - $valid_shortcodes = array( 'transaction' ); |
|
276 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
274 | + private function _get_custom_total_owing($shortcode) { |
|
275 | + $valid_shortcodes = array('transaction'); |
|
276 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
277 | 277 | |
278 | 278 | //ensure default is set. |
279 | 279 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
280 | 280 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
281 | 281 | |
282 | - if ( $total_owing > 0 ) { |
|
283 | - $owing_content = ! empty( $attrs['still_owing'] ) ? $attrs['still_owing'] : sprintf( esc_html__( '%sPlease make a payment.%s', 'event_espresso' ), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ); |
|
284 | - $owing_content = $this->_shortcode_helper->parse_message_template( $owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
282 | + if ($total_owing > 0) { |
|
283 | + $owing_content = ! empty($attrs['still_owing']) ? $attrs['still_owing'] : sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>'); |
|
284 | + $owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message); |
|
285 | 285 | } else { |
286 | - $owing_content = ! empty( $attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
286 | + $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | return $owing_content; |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | * @param EE_Transaction $transaction |
296 | 296 | * @return string |
297 | 297 | */ |
298 | - private function _get_payment_gateway( $transaction ) { |
|
299 | - $pm = $this->_get_payment_method( $transaction ); |
|
298 | + private function _get_payment_gateway($transaction) { |
|
299 | + $pm = $this->_get_payment_method($transaction); |
|
300 | 300 | return $pm instanceof EE_Payment_Method ? $pm->name() : ''; |
301 | 301 | } |
302 | 302 | |
@@ -311,37 +311,37 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return string url or html |
313 | 313 | */ |
314 | - private function _get_invoice_logo( $img_tags = false ) { |
|
314 | + private function _get_invoice_logo($img_tags = false) { |
|
315 | 315 | //try to get the invoice payment method's logo for this transaction image first |
316 | 316 | $pm = $this->_get_payment_method(); |
317 | - if ( $pm instanceof EE_Payment_Method ){ |
|
318 | - $invoice_logo_url = $pm->get_extra_meta( 'pdf_logo_image', true ); |
|
317 | + if ($pm instanceof EE_Payment_Method) { |
|
318 | + $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', true); |
|
319 | 319 | } else { |
320 | 320 | $invoice_logo_url = null; |
321 | 321 | } |
322 | - if ( empty( $invoice_logo_url ) ){ |
|
322 | + if (empty($invoice_logo_url)) { |
|
323 | 323 | $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url; |
324 | 324 | } |
325 | 325 | |
326 | - if ( empty( $invoice_logo_url ) ) { |
|
326 | + if (empty($invoice_logo_url)) { |
|
327 | 327 | return ''; |
328 | 328 | } |
329 | 329 | |
330 | - if ( ! $img_tags ) { |
|
330 | + if ( ! $img_tags) { |
|
331 | 331 | return $invoice_logo_url; |
332 | 332 | } |
333 | 333 | |
334 | 334 | //image tags have been requested. |
335 | - $image_size = getimagesize( $invoice_logo_url ); |
|
335 | + $image_size = getimagesize($invoice_logo_url); |
|
336 | 336 | |
337 | 337 | //if image is wider than 200px, set the width to 200 |
338 | - if ( $image_size[0] > 300 ) { |
|
338 | + if ($image_size[0] > 300) { |
|
339 | 339 | $image_width = 300; |
340 | 340 | } else { |
341 | 341 | $image_width = $image_size[0]; |
342 | 342 | } |
343 | 343 | |
344 | - return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />'; |
|
344 | + return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />'; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | private function _get_invoice_payee_name() { |
359 | 359 | $payee_name = null; |
360 | 360 | $pm = $this->_get_payment_method(); |
361 | - if ( $pm instanceof EE_Payment_Method ){ |
|
362 | - $payee_name = $pm->get_extra_meta( 'pdf_payee_name', true ); |
|
361 | + if ($pm instanceof EE_Payment_Method) { |
|
362 | + $payee_name = $pm->get_extra_meta('pdf_payee_name', true); |
|
363 | 363 | } |
364 | - $payee_name = empty( $payee_name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : $payee_name; |
|
364 | + $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name; |
|
365 | 365 | return $payee_name; |
366 | 366 | } |
367 | 367 | |
@@ -373,16 +373,16 @@ discard block |
||
373 | 373 | * @param EE_Transaction|null $transaction |
374 | 374 | * @return \EE_Payment_Method|mixed|null|void |
375 | 375 | */ |
376 | - private function _get_payment_method( $transaction = null ){ |
|
377 | - if ( $transaction instanceof EE_Transaction ) { |
|
376 | + private function _get_payment_method($transaction = null) { |
|
377 | + if ($transaction instanceof EE_Transaction) { |
|
378 | 378 | $payment_method = $transaction->payment_method(); |
379 | - if ( empty( $payment_method ) ) { |
|
380 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' ) ); |
|
379 | + if (empty($payment_method)) { |
|
380 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
381 | 381 | } |
382 | 382 | return $payment_method; |
383 | 383 | } else { |
384 | 384 | //get the first payment method we can find |
385 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' ) ); |
|
385 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | private function _get_invoice_payee_email() { |
400 | 400 | $payee_email = null; |
401 | 401 | $pm = $this->_get_payment_method(); |
402 | - if ( $pm instanceof EE_Payment_Method ){ |
|
403 | - $payee_email = $pm->get_extra_meta( 'pdf_payee_email', true ); |
|
402 | + if ($pm instanceof EE_Payment_Method) { |
|
403 | + $payee_email = $pm->get_extra_meta('pdf_payee_email', true); |
|
404 | 404 | } |
405 | - $payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email; |
|
405 | + $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email; |
|
406 | 406 | return $payee_email; |
407 | 407 | } |
408 | 408 | |
@@ -418,24 +418,24 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @return string |
420 | 420 | */ |
421 | - private function _get_invoice_payee_tax_number( $shortcode ) { |
|
421 | + private function _get_invoice_payee_tax_number($shortcode) { |
|
422 | 422 | $payee_tax_number = null; |
423 | 423 | $pm = $this->_get_payment_method(); |
424 | - if ( $pm instanceof EE_Payment_Method ){ |
|
425 | - $payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', true ); |
|
424 | + if ($pm instanceof EE_Payment_Method) { |
|
425 | + $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true); |
|
426 | 426 | } |
427 | - $payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
427 | + $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
428 | 428 | |
429 | - if ( empty( $payee_tax_number ) ) { |
|
429 | + if (empty($payee_tax_number)) { |
|
430 | 430 | return ''; |
431 | 431 | } |
432 | 432 | |
433 | 433 | //any attributes? |
434 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
434 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
435 | 435 | |
436 | 436 | //prefix? |
437 | - $prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : esc_html__( 'VAT/Tax Number: ', 'event_espresso' ); |
|
438 | - return $prefix . $payee_tax_number; |
|
437 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso'); |
|
438 | + return $prefix.$payee_tax_number; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | |
@@ -452,22 +452,22 @@ discard block |
||
452 | 452 | private function _get_invoice_payee_address() { |
453 | 453 | $payee_address = null; |
454 | 454 | $pm = $this->_get_payment_method(); |
455 | - if ( $pm instanceof EE_Payment_Method ){ |
|
456 | - $payee_address = $pm->get_extra_meta( 'pdf_payee_address', true ); |
|
455 | + if ($pm instanceof EE_Payment_Method) { |
|
456 | + $payee_address = $pm->get_extra_meta('pdf_payee_address', true); |
|
457 | 457 | } |
458 | - if ( empty( $payee_address ) ) { |
|
458 | + if (empty($payee_address)) { |
|
459 | 459 | $organization = EE_Registry::instance()->CFG->organization; |
460 | - $payee_address = $organization->get_pretty( 'address_1' ) . '<br>'; |
|
461 | - $payee_address .= ! empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : ''; |
|
462 | - $payee_address .= $organization->get_pretty( 'city' ) . '<br>'; |
|
460 | + $payee_address = $organization->get_pretty('address_1').'<br>'; |
|
461 | + $payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : ''; |
|
462 | + $payee_address .= $organization->get_pretty('city').'<br>'; |
|
463 | 463 | |
464 | 464 | //state |
465 | - $state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID ); |
|
466 | - $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
465 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
466 | + $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
467 | 467 | |
468 | 468 | //Country |
469 | - $payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : ''; |
|
470 | - $payee_address .= ! empty( $organization->zip ) ? $organization->zip : ''; |
|
469 | + $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : ''; |
|
470 | + $payee_address .= ! empty($organization->zip) ? $organization->zip : ''; |
|
471 | 471 | } |
472 | 472 | return $payee_address; |
473 | 473 | } |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | private function _get_invoice_payment_instructions() { |
486 | 486 | $instructions = null; |
487 | 487 | $pm = $this->_get_payment_method(); |
488 | - return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', true ) : ''; |
|
488 | + return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : ''; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -499,27 +499,27 @@ discard block |
||
499 | 499 | * |
500 | 500 | * @return string |
501 | 501 | */ |
502 | - protected function _get_invoice_receipt_switcher( $button = true ) { |
|
502 | + protected function _get_invoice_receipt_switcher($button = true) { |
|
503 | 503 | $reg = $this->_data->primary_reg_obj; |
504 | - $message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : ''; |
|
505 | - if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) { |
|
504 | + $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : ''; |
|
505 | + if ( ! $reg instanceof EE_Registration || empty($message_type)) { |
|
506 | 506 | return ''; |
507 | 507 | } |
508 | 508 | |
509 | - $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
510 | - $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? esc_html__( 'View Invoice', 'event_espresso' ) : esc_html__( 'Switch to Invoice', 'event_espresso' ); |
|
511 | - $switch_to_label = ! $switch_to_invoice ? esc_html__( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label; |
|
509 | + $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
510 | + $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso'); |
|
511 | + $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label; |
|
512 | 512 | $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url(); |
513 | 513 | |
514 | - if ( ! $button ) { |
|
514 | + if ( ! $button) { |
|
515 | 515 | return $switch_to_url; |
516 | 516 | } |
517 | 517 | |
518 | - if ( ! empty( $switch_to_url ) ) { |
|
518 | + if ( ! empty($switch_to_url)) { |
|
519 | 519 | |
520 | 520 | return ' |
521 | - <form method="post" action="' . $switch_to_url . '" > |
|
522 | - <input class="print_button" type="submit" value="' . $switch_to_label . '" /> |
|
521 | + <form method="post" action="' . $switch_to_url.'" > |
|
522 | + <input class="print_button" type="submit" value="' . $switch_to_label.'" /> |
|
523 | 523 | </form> |
524 | 524 | '; |
525 | 525 | } |
@@ -559,10 +559,10 @@ discard block |
||
559 | 559 | * |
560 | 560 | * @return int |
561 | 561 | */ |
562 | - private function _get_subtotal( $tax = false ) { |
|
563 | - $grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : null; |
|
562 | + private function _get_subtotal($tax = false) { |
|
563 | + $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null; |
|
564 | 564 | |
565 | - if ( ! $grand_total instanceof EE_Line_Item ) { |
|
565 | + if ( ! $grand_total instanceof EE_Line_Item) { |
|
566 | 566 | return 0; |
567 | 567 | } |
568 | 568 | |
@@ -581,26 +581,26 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @return string parsed. |
583 | 583 | */ |
584 | - private function _get_payment_link_if_needed( $shortcode ) { |
|
585 | - $valid_shortcodes = array( 'transaction' ); |
|
586 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
584 | + private function _get_payment_link_if_needed($shortcode) { |
|
585 | + $valid_shortcodes = array('transaction'); |
|
586 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
587 | 587 | |
588 | 588 | //ensure default is set. |
589 | 589 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
590 | 590 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
591 | 591 | |
592 | - if ( $total_owing > 0 ) { |
|
593 | - $class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout'; |
|
594 | - $custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
595 | - $container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p'; |
|
596 | - $opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : ''; |
|
597 | - $opening_tag .= ! empty( $opening_tag ) && ! empty( $class ) ? ' class="' . $class . '"' : $opening_tag; |
|
598 | - $opening_tag .= ! empty( $opening_tag ) ? '>' : $opening_tag; |
|
599 | - $closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : ''; |
|
600 | - $content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag; |
|
592 | + if ($total_owing > 0) { |
|
593 | + $class = isset($attrs['class']) ? $attrs['class'] : 'callout'; |
|
594 | + $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
595 | + $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p'; |
|
596 | + $opening_tag = ! empty($container_tag) ? '<'.$container_tag : ''; |
|
597 | + $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag; |
|
598 | + $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag; |
|
599 | + $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : ''; |
|
600 | + $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag; |
|
601 | 601 | |
602 | 602 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
603 | - $owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
603 | + $owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message); |
|
604 | 604 | } else { |
605 | 605 | return ''; |
606 | 606 | } |
@@ -620,31 +620,31 @@ discard block |
||
620 | 620 | * @param EE_Transaction $transaction |
621 | 621 | * @return string |
622 | 622 | */ |
623 | - protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) { |
|
623 | + protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) { |
|
624 | 624 | //if transaction is paid in full then we can just return an empty string |
625 | - if ( $transaction->remaining() === 0 ) { |
|
625 | + if ($transaction->remaining() === 0) { |
|
626 | 626 | return ''; |
627 | 627 | } |
628 | 628 | |
629 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
630 | - $format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' ); |
|
631 | - $days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30; |
|
632 | - $prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : esc_html__( 'Payment in full due by: ', 'event_espresso' ); |
|
633 | - $transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' ); |
|
629 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
630 | + $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format'); |
|
631 | + $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30; |
|
632 | + $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : esc_html__('Payment in full due by: ', 'event_espresso'); |
|
633 | + $transaction_created = $transaction->get_DateTime_object('TXN_timestamp'); |
|
634 | 634 | |
635 | 635 | //setup date due: |
636 | 636 | try { |
637 | - if ( $transaction_created instanceof DateTime ) { |
|
638 | - $date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format ); |
|
637 | + if ($transaction_created instanceof DateTime) { |
|
638 | + $date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format); |
|
639 | 639 | } else { |
640 | 640 | throw new Exception(); |
641 | 641 | } |
642 | - } catch( Exception $e ) { |
|
642 | + } catch (Exception $e) { |
|
643 | 643 | //format was likely invalid. |
644 | 644 | $date_due = 'Unable to calculate date due, likely the format string is invalid.'; |
645 | 645 | } |
646 | 646 | |
647 | - return $prefix_text . $date_due; |
|
647 | + return $prefix_text.$date_due; |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | } //end EE_Transaction Shortcodes library |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param bool $routing |
57 | 57 | * @return Transactions_Admin_Page |
58 | 58 | */ |
59 | - public function __construct( $routing = TRUE ) { |
|
60 | - parent::__construct( $routing ); |
|
59 | + public function __construct($routing = TRUE) { |
|
60 | + parent::__construct($routing); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @return void |
81 | 81 | */ |
82 | 82 | protected function _ajax_hooks() { |
83 | - add_action('wp_ajax_espresso_apply_payment', array( $this, 'apply_payments_or_refunds')); |
|
84 | - add_action('wp_ajax_espresso_apply_refund', array( $this, 'apply_payments_or_refunds')); |
|
85 | - add_action('wp_ajax_espresso_delete_payment', array( $this, 'delete_payment')); |
|
83 | + add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds')); |
|
84 | + add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds')); |
|
85 | + add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment')); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | 'buttons' => array( |
98 | 98 | 'add' => esc_html__('Add New Transaction', 'event_espresso'), |
99 | 99 | 'edit' => esc_html__('Edit Transaction', 'event_espresso'), |
100 | - 'delete' => esc_html__('Delete Transaction','event_espresso'), |
|
100 | + 'delete' => esc_html__('Delete Transaction', 'event_espresso'), |
|
101 | 101 | ) |
102 | 102 | ); |
103 | 103 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | $this->_set_transaction_status_array(); |
115 | 115 | |
116 | - $txn_id = ! empty( $this->_req_data['TXN_ID'] ) && ! is_array( $this->_req_data['TXN_ID'] ) ? $this->_req_data['TXN_ID'] : 0; |
|
116 | + $txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0; |
|
117 | 117 | |
118 | 118 | $this->_page_routes = array( |
119 | 119 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | 'filename' => 'transactions_overview_views_filters_search' |
186 | 186 | ), |
187 | 187 | ), |
188 | - 'help_tour' => array( 'Transactions_Overview_Help_Tour' ), |
|
188 | + 'help_tour' => array('Transactions_Overview_Help_Tour'), |
|
189 | 189 | /** |
190 | 190 | * commented out because currently we are not displaying tips for transaction list table status but this |
191 | 191 | * may change in a later iteration so want to keep the code for then. |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | 'nav' => array( |
198 | 198 | 'label' => esc_html__('View Transaction', 'event_espresso'), |
199 | 199 | 'order' => 5, |
200 | - 'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url, |
|
200 | + 'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url) : $this->_admin_base_url, |
|
201 | 201 | 'persistent' => FALSE |
202 | 202 | ), |
203 | 203 | 'help_tabs' => array( |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | 'filename' => 'transactions_view_transaction_primary_registrant_billing_information' |
219 | 219 | ), |
220 | 220 | ), |
221 | - 'qtips' => array( 'Transaction_Details_Tips' ), |
|
222 | - 'help_tour' => array( 'Transaction_Details_Help_Tour' ), |
|
221 | + 'qtips' => array('Transaction_Details_Tips'), |
|
222 | + 'help_tour' => array('Transaction_Details_Help_Tour'), |
|
223 | 223 | 'metaboxes' => array('_transaction_details_metaboxes'), |
224 | 224 | |
225 | 225 | 'require_nonce' => FALSE |
@@ -237,23 +237,23 @@ discard block |
||
237 | 237 | // IF a registration was JUST added via the admin... |
238 | 238 | if ( |
239 | 239 | isset( |
240 | - $this->_req_data[ 'redirect_from' ], |
|
241 | - $this->_req_data[ 'EVT_ID' ], |
|
242 | - $this->_req_data[ 'event_name' ] |
|
240 | + $this->_req_data['redirect_from'], |
|
241 | + $this->_req_data['EVT_ID'], |
|
242 | + $this->_req_data['event_name'] |
|
243 | 243 | ) |
244 | 244 | ) { |
245 | 245 | // then set a cookie so that we can block any attempts to use |
246 | 246 | // the back button as a way to enter another registration. |
247 | - setcookie( 'ee_registration_added', $this->_req_data[ 'EVT_ID' ], time() + WEEK_IN_SECONDS, '/' ); |
|
247 | + setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/'); |
|
248 | 248 | // and update the global |
249 | - $_COOKIE[ 'ee_registration_added' ] = $this->_req_data[ 'EVT_ID' ]; |
|
249 | + $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID']; |
|
250 | 250 | } |
251 | - EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = esc_html__( 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso' ); |
|
252 | - EE_Registry::$i18n_js_strings[ 'error_occurred' ] = esc_html__( 'An error occurred! Please refresh the page and try again.', 'event_espresso' ); |
|
253 | - EE_Registry::$i18n_js_strings[ 'txn_status_array' ] = self::$_txn_status; |
|
254 | - EE_Registry::$i18n_js_strings[ 'pay_status_array' ] = self::$_pay_status; |
|
255 | - EE_Registry::$i18n_js_strings[ 'payments_total' ] = esc_html__( 'Payments Total', 'event_espresso' ); |
|
256 | - EE_Registry::$i18n_js_strings[ 'transaction_overpaid' ] = esc_html__( 'This transaction has been overpaid ! Payments Total', 'event_espresso' ); |
|
251 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso'); |
|
252 | + EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__('An error occurred! Please refresh the page and try again.', 'event_espresso'); |
|
253 | + EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status; |
|
254 | + EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status; |
|
255 | + EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso'); |
|
256 | + EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__('This transaction has been overpaid ! Payments Total', 'event_espresso'); |
|
257 | 257 | } |
258 | 258 | public function admin_notices() {} |
259 | 259 | public function admin_footer_scripts() {} |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function load_scripts_styles() { |
322 | 322 | //enqueue style |
323 | - wp_register_style( 'espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
323 | + wp_register_style('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
324 | 324 | wp_enqueue_style('espresso_txn'); |
325 | 325 | |
326 | 326 | //scripts |
327 | 327 | add_filter('FHEE_load_accounting_js', '__return_true'); |
328 | 328 | |
329 | 329 | //scripts |
330 | - wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE); |
|
330 | + wp_register_script('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE); |
|
331 | 331 | wp_enqueue_script('espresso_txn'); |
332 | 332 | |
333 | 333 | } |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * @return void |
368 | 368 | */ |
369 | 369 | protected function _set_list_table_views_default() { |
370 | - $this->_views = array ( |
|
371 | - 'all' => array ( |
|
370 | + $this->_views = array( |
|
371 | + 'all' => array( |
|
372 | 372 | 'slug' => 'all', |
373 | 373 | 'label' => esc_html__('View All Transactions', 'event_espresso'), |
374 | 374 | 'count' => 0 |
@@ -396,20 +396,20 @@ discard block |
||
396 | 396 | * @return void |
397 | 397 | */ |
398 | 398 | private function _set_transaction_object() { |
399 | - if ( is_object( $this->_transaction) ) |
|
399 | + if (is_object($this->_transaction)) |
|
400 | 400 | return; //get out we've already set the object |
401 | 401 | |
402 | 402 | $TXN = EEM_Transaction::instance(); |
403 | 403 | |
404 | - $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE; |
|
404 | + $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE; |
|
405 | 405 | |
406 | 406 | //get transaction object |
407 | 407 | $this->_transaction = $TXN->get_one_by_ID($TXN_ID); |
408 | - $this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL; |
|
408 | + $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : NULL; |
|
409 | 409 | |
410 | - if ( empty( $this->_transaction ) ) { |
|
411 | - $error_msg = esc_html__('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso'); |
|
412 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
410 | + if (empty($this->_transaction)) { |
|
411 | + $error_msg = esc_html__('An error occurred and the details for Transaction ID #', 'event_espresso').$TXN_ID.esc_html__(' could not be retrieved.', 'event_espresso'); |
|
412 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -422,12 +422,12 @@ discard block |
||
422 | 422 | * @return array |
423 | 423 | */ |
424 | 424 | protected function _transaction_legend_items() { |
425 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
425 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
426 | 426 | $items = array(); |
427 | 427 | |
428 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
429 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' ); |
|
430 | - if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) { |
|
428 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
429 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
430 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
431 | 431 | $items['view_related_messages'] = array( |
432 | 432 | 'class' => $related_for_icon['css_class'], |
433 | 433 | 'desc' => $related_for_icon['label'], |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | |
438 | 438 | $items = apply_filters( |
439 | 439 | 'FHEE__Transactions_Admin_Page___transaction_legend_items__items', |
440 | - array_merge( $items, |
|
440 | + array_merge($items, |
|
441 | 441 | array( |
442 | 442 | 'view_details' => array( |
443 | 443 | 'class' => 'dashicons dashicons-cart', |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | ), |
450 | 450 | 'view_receipt' => array( |
451 | 451 | 'class' => 'dashicons dashicons-media-default', |
452 | - 'desc' => esc_html__('View Transaction Receipt', 'event_espresso' ) |
|
452 | + 'desc' => esc_html__('View Transaction Receipt', 'event_espresso') |
|
453 | 453 | ), |
454 | 454 | 'view_registration' => array( |
455 | 455 | 'class' => 'dashicons dashicons-clipboard', |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | ) |
460 | 460 | ); |
461 | 461 | |
462 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ) { |
|
463 | - if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) { |
|
462 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) { |
|
463 | + if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
464 | 464 | $items['send_payment_reminder'] = array( |
465 | 465 | 'class' => 'dashicons dashicons-email-alt', |
466 | 466 | 'desc' => esc_html__('Send Payment Reminder', 'event_espresso') |
@@ -481,29 +481,29 @@ discard block |
||
481 | 481 | 'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items', |
482 | 482 | array( |
483 | 483 | 'overpaid' => array( |
484 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code, |
|
485 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::overpaid_status_code, FALSE, 'sentence' ) |
|
484 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code, |
|
485 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, FALSE, 'sentence') |
|
486 | 486 | ), |
487 | 487 | 'complete' => array( |
488 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code, |
|
489 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::complete_status_code, FALSE, 'sentence' ) |
|
488 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code, |
|
489 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, FALSE, 'sentence') |
|
490 | 490 | ), |
491 | 491 | 'incomplete' => array( |
492 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code, |
|
493 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::incomplete_status_code, FALSE, 'sentence' ) |
|
492 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code, |
|
493 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, FALSE, 'sentence') |
|
494 | 494 | ), |
495 | 495 | 'abandoned' => array( |
496 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code, |
|
497 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::abandoned_status_code, FALSE, 'sentence' ) |
|
496 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code, |
|
497 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, FALSE, 'sentence') |
|
498 | 498 | ), |
499 | 499 | 'failed' => array( |
500 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code, |
|
501 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::failed_status_code, FALSE, 'sentence' ) |
|
500 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code, |
|
501 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, FALSE, 'sentence') |
|
502 | 502 | ) |
503 | 503 | ) |
504 | 504 | ); |
505 | 505 | |
506 | - return array_merge( $items, $more_items); |
|
506 | + return array_merge($items, $more_items); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | |
@@ -516,9 +516,9 @@ discard block |
||
516 | 516 | */ |
517 | 517 | protected function _transactions_overview_list_table() { |
518 | 518 | $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
519 | - $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'] ) : NULL; |
|
520 | - $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL ) . '" title="' . esc_attr__('Click to Edit event', 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>' ) : ''; |
|
521 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_transaction_legend_items() ); |
|
519 | + $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : NULL; |
|
520 | + $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL).'" title="'.esc_attr__('Click to Edit event', 'event_espresso').'">'.$event->get('EVT_name').'</a>', '</h3>') : ''; |
|
521 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
522 | 522 | $this->display_admin_list_table_page_with_no_sidebar(); |
523 | 523 | } |
524 | 524 | |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | * @return void |
533 | 533 | */ |
534 | 534 | protected function _transaction_details() { |
535 | - do_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction ); |
|
535 | + do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction); |
|
536 | 536 | |
537 | 537 | $this->_set_transaction_status_array(); |
538 | 538 | |
@@ -545,14 +545,14 @@ discard block |
||
545 | 545 | $attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : NULL; |
546 | 546 | |
547 | 547 | $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID(); |
548 | - $this->_template_args['txn_nmbr']['label'] = esc_html__( 'Transaction Number', 'event_espresso' ); |
|
548 | + $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso'); |
|
549 | 549 | |
550 | 550 | $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp'); |
551 | - $this->_template_args['txn_datetime']['label'] = esc_html__( 'Date', 'event_espresso' ); |
|
551 | + $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
552 | 552 | |
553 | - $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ]; |
|
554 | - $this->_template_args['txn_status']['label'] = esc_html__( 'Transaction Status', 'event_espresso' ); |
|
555 | - $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID'); |
|
553 | + $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')]; |
|
554 | + $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso'); |
|
555 | + $this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID'); |
|
556 | 556 | |
557 | 557 | $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total'); |
558 | 558 | $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid'); |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | ) |
566 | 566 | ) { |
567 | 567 | $this->_template_args['send_payment_reminder_button'] = |
568 | - EEH_MSG_Template::is_mt_active( 'payment_reminder' ) |
|
568 | + EEH_MSG_Template::is_mt_active('payment_reminder') |
|
569 | 569 | && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code |
570 | 570 | && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code |
571 | 571 | ? EEH_Template::get_button_or_link( |
@@ -587,40 +587,40 @@ discard block |
||
587 | 587 | } |
588 | 588 | |
589 | 589 | $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid'); |
590 | - $this->_template_args['amount_due'] = EEH_Template::format_currency( $amount_due, TRUE ); |
|
591 | - if ( EE_Registry::instance()->CFG->currency->sign_b4 ) { |
|
592 | - $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due']; |
|
590 | + $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, TRUE); |
|
591 | + if (EE_Registry::instance()->CFG->currency->sign_b4) { |
|
592 | + $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign.$this->_template_args['amount_due']; |
|
593 | 593 | } else { |
594 | - $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign; |
|
594 | + $this->_template_args['amount_due'] = $this->_template_args['amount_due'].EE_Registry::instance()->CFG->currency->sign; |
|
595 | 595 | } |
596 | - $this->_template_args['amount_due_class'] = ''; |
|
596 | + $this->_template_args['amount_due_class'] = ''; |
|
597 | 597 | |
598 | - if ( $this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total') ) { |
|
598 | + if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) { |
|
599 | 599 | // paid in full |
600 | - $this->_template_args['amount_due'] = FALSE; |
|
601 | - } elseif ( $this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total') ) { |
|
600 | + $this->_template_args['amount_due'] = FALSE; |
|
601 | + } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) { |
|
602 | 602 | // overpaid |
603 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
604 | - } elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') > 0 )) { |
|
603 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
604 | + } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) { |
|
605 | 605 | // monies owing |
606 | - $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
607 | - } elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') == 0 )) { |
|
606 | + $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
607 | + } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) { |
|
608 | 608 | // no payments made yet |
609 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
610 | - } elseif ( $this->_transaction->get('TXN_total') == 0 ) { |
|
609 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
610 | + } elseif ($this->_transaction->get('TXN_total') == 0) { |
|
611 | 611 | // free event |
612 | - $this->_template_args['amount_due'] = FALSE; |
|
612 | + $this->_template_args['amount_due'] = FALSE; |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | $payment_method = $this->_transaction->payment_method(); |
616 | 616 | |
617 | 617 | $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method |
618 | 618 | ? $payment_method->admin_name() |
619 | - : esc_html__( 'Unknown', 'event_espresso' ); |
|
619 | + : esc_html__('Unknown', 'event_espresso'); |
|
620 | 620 | |
621 | 621 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
622 | 622 | // link back to overview |
623 | - $this->_template_args['txn_overview_url'] = ! empty ( $_SERVER['HTTP_REFERER'] ) |
|
623 | + $this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER']) |
|
624 | 624 | ? $_SERVER['HTTP_REFERER'] |
625 | 625 | : TXN_ADMIN_URL; |
626 | 626 | |
@@ -628,13 +628,13 @@ discard block |
||
628 | 628 | // next link |
629 | 629 | $next_txn = $this->_transaction->next( |
630 | 630 | null, |
631 | - array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ), |
|
631 | + array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
632 | 632 | 'TXN_ID' |
633 | 633 | ); |
634 | 634 | $this->_template_args['next_transaction'] = $next_txn |
635 | 635 | ? $this->_next_link( |
636 | 636 | EE_Admin_Page::add_query_args_and_nonce( |
637 | - array( 'action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID'] ), |
|
637 | + array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']), |
|
638 | 638 | TXN_ADMIN_URL |
639 | 639 | ), |
640 | 640 | 'dashicons dashicons-arrow-right ee-icon-size-22' |
@@ -643,13 +643,13 @@ discard block |
||
643 | 643 | // previous link |
644 | 644 | $previous_txn = $this->_transaction->previous( |
645 | 645 | null, |
646 | - array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ), |
|
646 | + array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
647 | 647 | 'TXN_ID' |
648 | 648 | ); |
649 | 649 | $this->_template_args['previous_transaction'] = $previous_txn |
650 | 650 | ? $this->_previous_link( |
651 | 651 | EE_Admin_Page::add_query_args_and_nonce( |
652 | - array( 'action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID'] ), |
|
652 | + array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']), |
|
653 | 653 | TXN_ADMIN_URL |
654 | 654 | ), |
655 | 655 | 'dashicons dashicons-arrow-left ee-icon-size-22' |
@@ -659,16 +659,16 @@ discard block |
||
659 | 659 | // were we just redirected here after adding a new registration ??? |
660 | 660 | if ( |
661 | 661 | isset( |
662 | - $this->_req_data[ 'redirect_from' ], |
|
663 | - $this->_req_data[ 'EVT_ID' ], |
|
664 | - $this->_req_data[ 'event_name' ] |
|
662 | + $this->_req_data['redirect_from'], |
|
663 | + $this->_req_data['EVT_ID'], |
|
664 | + $this->_req_data['event_name'] |
|
665 | 665 | ) |
666 | 666 | ) { |
667 | 667 | if ( |
668 | 668 | EE_Registry::instance()->CAP->current_user_can( |
669 | 669 | 'ee_edit_registrations', |
670 | 670 | 'espresso_registrations_new_registration', |
671 | - $this->_req_data[ 'EVT_ID' ] |
|
671 | + $this->_req_data['EVT_ID'] |
|
672 | 672 | ) |
673 | 673 | ) { |
674 | 674 | $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="'; |
@@ -678,25 +678,25 @@ discard block |
||
678 | 678 | 'action' => 'new_registration', |
679 | 679 | 'return' => 'default', |
680 | 680 | 'TXN_ID' => $this->_transaction->ID(), |
681 | - 'event_id' => $this->_req_data[ 'EVT_ID' ], |
|
681 | + 'event_id' => $this->_req_data['EVT_ID'], |
|
682 | 682 | ), |
683 | 683 | REG_ADMIN_URL |
684 | 684 | ); |
685 | 685 | $this->_admin_page_title .= '">'; |
686 | 686 | |
687 | 687 | $this->_admin_page_title .= sprintf( |
688 | - esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso' ), |
|
689 | - htmlentities( urldecode( $this->_req_data[ 'event_name' ] ), ENT_QUOTES, 'UTF-8' ) |
|
688 | + esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'), |
|
689 | + htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8') |
|
690 | 690 | ); |
691 | 691 | $this->_admin_page_title .= '</a>'; |
692 | 692 | } |
693 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
693 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
694 | 694 | } |
695 | 695 | // grab messages at the last second |
696 | 696 | $this->_template_args['notices'] = EE_Error::get_notices(); |
697 | 697 | // path to template |
698 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php'; |
|
699 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
698 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php'; |
|
699 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
700 | 700 | |
701 | 701 | // the details template wrapper |
702 | 702 | $this->display_admin_page_with_sidebar(); |
@@ -715,18 +715,18 @@ discard block |
||
715 | 715 | |
716 | 716 | $this->_set_transaction_object(); |
717 | 717 | |
718 | - add_meta_box( 'edit-txn-details-mbox', esc_html__( 'Transaction Details', 'event_espresso' ), array( $this, 'txn_details_meta_box' ), $this->_wp_page_slug, 'normal', 'high' ); |
|
718 | + add_meta_box('edit-txn-details-mbox', esc_html__('Transaction Details', 'event_espresso'), array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high'); |
|
719 | 719 | add_meta_box( |
720 | 720 | 'edit-txn-attendees-mbox', |
721 | - esc_html__( 'Attendees Registered in this Transaction', 'event_espresso' ), |
|
722 | - array( $this, 'txn_attendees_meta_box' ), |
|
721 | + esc_html__('Attendees Registered in this Transaction', 'event_espresso'), |
|
722 | + array($this, 'txn_attendees_meta_box'), |
|
723 | 723 | $this->_wp_page_slug, |
724 | 724 | 'normal', |
725 | 725 | 'high', |
726 | - array( 'TXN_ID' => $this->_transaction->ID() ) |
|
726 | + array('TXN_ID' => $this->_transaction->ID()) |
|
727 | 727 | ); |
728 | - add_meta_box( 'edit-txn-registrant-mbox', esc_html__( 'Primary Contact', 'event_espresso' ), array( $this, 'txn_registrant_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' ); |
|
729 | - add_meta_box( 'edit-txn-billing-info-mbox', esc_html__( 'Billing Information', 'event_espresso' ), array( $this, 'txn_billing_info_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' ); |
|
728 | + add_meta_box('edit-txn-registrant-mbox', esc_html__('Primary Contact', 'event_espresso'), array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
729 | + add_meta_box('edit-txn-billing-info-mbox', esc_html__('Billing Information', 'event_espresso'), array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
730 | 730 | |
731 | 731 | } |
732 | 732 | |
@@ -747,15 +747,15 @@ discard block |
||
747 | 747 | |
748 | 748 | //get line table |
749 | 749 | EEH_Autoloader::register_line_item_display_autoloaders(); |
750 | - $Line_Item_Display = new EE_Line_Item_Display( 'admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy' ); |
|
751 | - $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item( $this->_transaction->total_line_item() ); |
|
750 | + $Line_Item_Display = new EE_Line_Item_Display('admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy'); |
|
751 | + $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item()); |
|
752 | 752 | $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code'); |
753 | 753 | |
754 | 754 | // process taxes |
755 | - $taxes = $this->_transaction->get_many_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_tax ))); |
|
756 | - $this->_template_args['taxes'] = ! empty( $taxes ) ? $taxes : FALSE; |
|
755 | + $taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
756 | + $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : FALSE; |
|
757 | 757 | |
758 | - $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE ); |
|
758 | + $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE); |
|
759 | 759 | $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total'); |
760 | 760 | $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID'); |
761 | 761 | |
@@ -763,63 +763,63 @@ discard block |
||
763 | 763 | |
764 | 764 | // process payment details |
765 | 765 | $payments = $this->_transaction->get_many_related('Payment'); |
766 | - if( ! empty( $payments ) ) { |
|
767 | - $this->_template_args[ 'payments' ] = $payments; |
|
768 | - $this->_template_args[ 'existing_reg_payments' ] = $this->_get_registration_payment_IDs( $payments ); |
|
766 | + if ( ! empty($payments)) { |
|
767 | + $this->_template_args['payments'] = $payments; |
|
768 | + $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments); |
|
769 | 769 | } else { |
770 | - $this->_template_args[ 'payments' ] = false; |
|
771 | - $this->_template_args[ 'existing_reg_payments' ] = array(); |
|
770 | + $this->_template_args['payments'] = false; |
|
771 | + $this->_template_args['existing_reg_payments'] = array(); |
|
772 | 772 | } |
773 | 773 | |
774 | - $this->_template_args['edit_payment_url'] = add_query_arg( array( 'action' => 'edit_payment' ), TXN_ADMIN_URL ); |
|
775 | - $this->_template_args['delete_payment_url'] = add_query_arg( array( 'action' => 'espresso_delete_payment' ), TXN_ADMIN_URL ); |
|
774 | + $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL); |
|
775 | + $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL); |
|
776 | 776 | |
777 | - if ( isset( $txn_details['invoice_number'] )) { |
|
777 | + if (isset($txn_details['invoice_number'])) { |
|
778 | 778 | $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code']; |
779 | - $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__( 'Invoice Number', 'event_espresso' ); |
|
779 | + $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__('Invoice Number', 'event_espresso'); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session'); |
783 | - $this->_template_args['txn_details']['registration_session']['label'] = esc_html__( 'Registration Session', 'event_espresso' ); |
|
783 | + $this->_template_args['txn_details']['registration_session']['label'] = esc_html__('Registration Session', 'event_espresso'); |
|
784 | 784 | |
785 | - $this->_template_args['txn_details']['ip_address']['value'] = isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : ''; |
|
786 | - $this->_template_args['txn_details']['ip_address']['label'] = esc_html__( 'Transaction placed from IP', 'event_espresso' ); |
|
785 | + $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : ''; |
|
786 | + $this->_template_args['txn_details']['ip_address']['label'] = esc_html__('Transaction placed from IP', 'event_espresso'); |
|
787 | 787 | |
788 | - $this->_template_args['txn_details']['user_agent']['value'] = isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : ''; |
|
789 | - $this->_template_args['txn_details']['user_agent']['label'] = esc_html__( 'Registrant User Agent', 'event_espresso' ); |
|
788 | + $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : ''; |
|
789 | + $this->_template_args['txn_details']['user_agent']['label'] = esc_html__('Registrant User Agent', 'event_espresso'); |
|
790 | 790 | |
791 | 791 | $reg_steps = '<ul>'; |
792 | - foreach ( $this->_transaction->reg_steps() as $reg_step => $reg_step_status ) { |
|
793 | - if ( $reg_step_status === true ) { |
|
794 | - $reg_steps .= '<li style="color:#70cc50">' . sprintf( esc_html__( '%1$s : Completed', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>'; |
|
795 | - } else if ( is_numeric( $reg_step_status ) && $reg_step_status !== false ) { |
|
796 | - $reg_steps .= '<li style="color:#2EA2CC">' . sprintf( |
|
797 | - esc_html__( '%1$s : Initiated %2$s', 'event_espresso' ), |
|
798 | - ucwords( str_replace( '_', ' ', $reg_step ) ), |
|
799 | - gmdate( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), ( $reg_step_status + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) ) |
|
800 | - ) . '</li>'; |
|
792 | + foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) { |
|
793 | + if ($reg_step_status === true) { |
|
794 | + $reg_steps .= '<li style="color:#70cc50">'.sprintf(esc_html__('%1$s : Completed', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>'; |
|
795 | + } else if (is_numeric($reg_step_status) && $reg_step_status !== false) { |
|
796 | + $reg_steps .= '<li style="color:#2EA2CC">'.sprintf( |
|
797 | + esc_html__('%1$s : Initiated %2$s', 'event_espresso'), |
|
798 | + ucwords(str_replace('_', ' ', $reg_step)), |
|
799 | + gmdate(get_option('date_format').' '.get_option('time_format'), ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))) |
|
800 | + ).'</li>'; |
|
801 | 801 | } else { |
802 | - $reg_steps .= '<li style="color:#E76700">' . sprintf( esc_html__( '%1$s : Never Initiated', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>'; |
|
802 | + $reg_steps .= '<li style="color:#E76700">'.sprintf(esc_html__('%1$s : Never Initiated', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>'; |
|
803 | 803 | } |
804 | 804 | } |
805 | 805 | $reg_steps .= '</ul>'; |
806 | 806 | $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps; |
807 | - $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__( 'Registration Step Progress', 'event_espresso' ); |
|
807 | + $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__('Registration Step Progress', 'event_espresso'); |
|
808 | 808 | |
809 | 809 | |
810 | 810 | $this->_get_registrations_to_apply_payment_to(); |
811 | - $this->_get_payment_methods( $payments ); |
|
811 | + $this->_get_payment_methods($payments); |
|
812 | 812 | $this->_get_payment_status_array(); |
813 | 813 | $this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction. |
814 | 814 | |
815 | - $this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'transaction' ), TXN_ADMIN_URL ); |
|
816 | - $this->_template_args['apply_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_apply_payment' ), WP_AJAX_URL ); |
|
817 | - $this->_template_args['delete_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_delete_payment' ), WP_AJAX_URL ); |
|
815 | + $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL); |
|
816 | + $this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL); |
|
817 | + $this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL); |
|
818 | 818 | |
819 | 819 | // 'espresso_delete_payment_nonce' |
820 | 820 | |
821 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
822 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
821 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
822 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
823 | 823 | |
824 | 824 | } |
825 | 825 | |
@@ -834,27 +834,27 @@ discard block |
||
834 | 834 | * @param EE_Payment[] $payments |
835 | 835 | * @return array |
836 | 836 | */ |
837 | - protected function _get_registration_payment_IDs( $payments = array() ) { |
|
837 | + protected function _get_registration_payment_IDs($payments = array()) { |
|
838 | 838 | $existing_reg_payments = array(); |
839 | 839 | // get all reg payments for these payments |
840 | - $reg_payments = EEM_Registration_Payment::instance()->get_all( array( |
|
840 | + $reg_payments = EEM_Registration_Payment::instance()->get_all(array( |
|
841 | 841 | array( |
842 | 842 | 'PAY_ID' => array( |
843 | 843 | 'IN', |
844 | - array_keys( $payments ) |
|
844 | + array_keys($payments) |
|
845 | 845 | ) |
846 | 846 | ) |
847 | - ) ); |
|
848 | - if ( ! empty( $reg_payments ) ) { |
|
849 | - foreach ( $payments as $payment ) { |
|
850 | - if ( ! $payment instanceof EE_Payment ) { |
|
847 | + )); |
|
848 | + if ( ! empty($reg_payments)) { |
|
849 | + foreach ($payments as $payment) { |
|
850 | + if ( ! $payment instanceof EE_Payment) { |
|
851 | 851 | continue; |
852 | - } else if ( ! isset( $existing_reg_payments[ $payment->ID() ] ) ) { |
|
853 | - $existing_reg_payments[ $payment->ID() ] = array(); |
|
852 | + } else if ( ! isset($existing_reg_payments[$payment->ID()])) { |
|
853 | + $existing_reg_payments[$payment->ID()] = array(); |
|
854 | 854 | } |
855 | - foreach ( $reg_payments as $reg_payment ) { |
|
856 | - if ( $reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID() ) { |
|
857 | - $existing_reg_payments[ $payment->ID() ][ ] = $reg_payment->registration_ID(); |
|
855 | + foreach ($reg_payments as $reg_payment) { |
|
856 | + if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) { |
|
857 | + $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID(); |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | } |
@@ -887,54 +887,54 @@ discard block |
||
887 | 887 | ) |
888 | 888 | ) |
889 | 889 | ); |
890 | - $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div( |
|
890 | + $registrations_to_apply_payment_to = EEH_HTML::br().EEH_HTML::div( |
|
891 | 891 | '', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;' |
892 | 892 | ); |
893 | - $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div( '', '', 'admin-primary-mbox-tbl-wrap' ); |
|
894 | - $registrations_to_apply_payment_to .= EEH_HTML::table( '', '', 'admin-primary-mbox-tbl' ); |
|
893 | + $registrations_to_apply_payment_to .= EEH_HTML::br().EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
894 | + $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl'); |
|
895 | 895 | $registrations_to_apply_payment_to .= EEH_HTML::thead( |
896 | 896 | EEH_HTML::tr( |
897 | - EEH_HTML::th( esc_html__( 'ID', 'event_espresso' ) ) . |
|
898 | - EEH_HTML::th( esc_html__( 'Registrant', 'event_espresso' ) ) . |
|
899 | - EEH_HTML::th( esc_html__( 'Ticket', 'event_espresso' ) ) . |
|
900 | - EEH_HTML::th( esc_html__( 'Event', 'event_espresso' ) ) . |
|
901 | - EEH_HTML::th( esc_html__( 'Paid', 'event_espresso' ), '', 'txn-admin-payment-paid-td jst-cntr' ) . |
|
902 | - EEH_HTML::th( esc_html__( 'Owing', 'event_espresso' ), '', 'txn-admin-payment-owing-td jst-cntr' ) . |
|
903 | - EEH_HTML::th( esc_html__( 'Apply', 'event_espresso' ), '', 'jst-cntr' ) |
|
897 | + EEH_HTML::th(esc_html__('ID', 'event_espresso')). |
|
898 | + EEH_HTML::th(esc_html__('Registrant', 'event_espresso')). |
|
899 | + EEH_HTML::th(esc_html__('Ticket', 'event_espresso')). |
|
900 | + EEH_HTML::th(esc_html__('Event', 'event_espresso')). |
|
901 | + EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr'). |
|
902 | + EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr'). |
|
903 | + EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr') |
|
904 | 904 | ) |
905 | 905 | ); |
906 | 906 | $registrations_to_apply_payment_to .= EEH_HTML::tbody(); |
907 | 907 | // get registrations for TXN |
908 | - $registrations = $this->_transaction->registrations( $query_params ); |
|
909 | - foreach ( $registrations as $registration ) { |
|
910 | - if ( $registration instanceof EE_Registration ) { |
|
908 | + $registrations = $this->_transaction->registrations($query_params); |
|
909 | + foreach ($registrations as $registration) { |
|
910 | + if ($registration instanceof EE_Registration) { |
|
911 | 911 | $attendee_name = $registration->attendee() instanceof EE_Attendee |
912 | 912 | ? $registration->attendee()->full_name() |
913 | - : esc_html__( 'Unknown Attendee', 'event_espresso' ); |
|
913 | + : esc_html__('Unknown Attendee', 'event_espresso'); |
|
914 | 914 | $owing = $registration->final_price() - $registration->paid(); |
915 | 915 | $taxable = $registration->ticket()->taxable() |
916 | - ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__( '+ tax', 'event_espresso' ) . '</span>' |
|
916 | + ? ' <span class="smaller-text lt-grey-text"> '.esc_html__('+ tax', 'event_espresso').'</span>' |
|
917 | 917 | : ''; |
918 | - $checked = empty( $existing_reg_payments ) || in_array( $registration->ID(), $existing_reg_payments ) |
|
918 | + $checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments) |
|
919 | 919 | ? ' checked="checked"' |
920 | 920 | : ''; |
921 | 921 | $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
922 | 922 | $registrations_to_apply_payment_to .= EEH_HTML::tr( |
923 | - EEH_HTML::td( $registration->ID() ) . |
|
924 | - EEH_HTML::td( $attendee_name ) . |
|
923 | + EEH_HTML::td($registration->ID()). |
|
924 | + EEH_HTML::td($attendee_name). |
|
925 | 925 | EEH_HTML::td( |
926 | - $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable |
|
927 | - ) . |
|
928 | - EEH_HTML::td( $registration->event_name() ) . |
|
929 | - EEH_HTML::td( $registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr' ) . |
|
930 | - EEH_HTML::td( EEH_Template::format_currency( $owing ), '', 'txn-admin-payment-owing-td jst-cntr' ) . |
|
926 | + $registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable |
|
927 | + ). |
|
928 | + EEH_HTML::td($registration->event_name()). |
|
929 | + EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr'). |
|
930 | + EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr'). |
|
931 | 931 | EEH_HTML::td( |
932 | - '<input type="checkbox" value="' . $registration->ID() |
|
932 | + '<input type="checkbox" value="'.$registration->ID() |
|
933 | 933 | . '" name="txn_admin_payment[registrations]"' |
934 | - . $checked . $disabled . '>', |
|
934 | + . $checked.$disabled.'>', |
|
935 | 935 | '', 'jst-cntr' |
936 | 936 | ), |
937 | - 'apply-payment-registration-row-' . $registration->ID() |
|
937 | + 'apply-payment-registration-row-'.$registration->ID() |
|
938 | 938 | ); |
939 | 939 | } |
940 | 940 | } |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | '', 'clear description' |
950 | 950 | ); |
951 | 951 | $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
952 | - $this->_template_args[ 'registrations_to_apply_payment_to' ] = $registrations_to_apply_payment_to; |
|
952 | + $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to; |
|
953 | 953 | } |
954 | 954 | |
955 | 955 | |
@@ -966,9 +966,9 @@ discard block |
||
966 | 966 | $statuses = EEM_Registration::reg_status_array(array(), TRUE); |
967 | 967 | //let's add a "don't change" option. |
968 | 968 | $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso'); |
969 | - $status_array = array_merge( $status_array, $statuses ); |
|
970 | - $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input( 'txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status' ); |
|
971 | - $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input( 'delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status' ); |
|
969 | + $status_array = array_merge($status_array, $statuses); |
|
970 | + $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status'); |
|
971 | + $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status'); |
|
972 | 972 | |
973 | 973 | } |
974 | 974 | |
@@ -983,21 +983,21 @@ discard block |
||
983 | 983 | * @param EE_Payment[] to show on this page |
984 | 984 | * @return void |
985 | 985 | */ |
986 | - private function _get_payment_methods( $payments = array() ) { |
|
986 | + private function _get_payment_methods($payments = array()) { |
|
987 | 987 | $payment_methods_of_payments = array(); |
988 | - foreach( $payments as $payment ){ |
|
989 | - if( $payment instanceof EE_Payment ){ |
|
990 | - $payment_methods_of_payments[] = $payment->get( 'PMD_ID' ); |
|
988 | + foreach ($payments as $payment) { |
|
989 | + if ($payment instanceof EE_Payment) { |
|
990 | + $payment_methods_of_payments[] = $payment->get('PMD_ID'); |
|
991 | 991 | } |
992 | 992 | } |
993 | - if( $payment_methods_of_payments ){ |
|
994 | - $query_args = array( array( 'OR*payment_method_for_payment' => array( |
|
995 | - 'PMD_ID' => array( 'IN', $payment_methods_of_payments ), |
|
996 | - 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ) ); |
|
997 | - }else{ |
|
998 | - $query_args = array( array( 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ); |
|
993 | + if ($payment_methods_of_payments) { |
|
994 | + $query_args = array(array('OR*payment_method_for_payment' => array( |
|
995 | + 'PMD_ID' => array('IN', $payment_methods_of_payments), |
|
996 | + 'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%') ))); |
|
997 | + } else { |
|
998 | + $query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%'))); |
|
999 | 999 | } |
1000 | - $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all( $query_args ); |
|
1000 | + $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | |
@@ -1011,17 +1011,17 @@ discard block |
||
1011 | 1011 | * @param array $metabox |
1012 | 1012 | * @return void |
1013 | 1013 | */ |
1014 | - public function txn_attendees_meta_box( $post, $metabox = array( 'args' => array() )) { |
|
1014 | + public function txn_attendees_meta_box($post, $metabox = array('args' => array())) { |
|
1015 | 1015 | |
1016 | - extract( $metabox['args'] ); |
|
1016 | + extract($metabox['args']); |
|
1017 | 1017 | $this->_template_args['post'] = $post; |
1018 | 1018 | $this->_template_args['event_attendees'] = array(); |
1019 | 1019 | // process items in cart |
1020 | - $line_items = $this->_transaction->get_many_related('Line_Item', array( array( 'LIN_type' => 'line-item' ) ) ); |
|
1021 | - if ( ! empty( $line_items )) { |
|
1022 | - foreach ( $line_items as $item ) { |
|
1023 | - if ( $item instanceof EE_Line_Item ) { |
|
1024 | - switch( $item->OBJ_type() ) { |
|
1020 | + $line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item'))); |
|
1021 | + if ( ! empty($line_items)) { |
|
1022 | + foreach ($line_items as $item) { |
|
1023 | + if ($item instanceof EE_Line_Item) { |
|
1024 | + switch ($item->OBJ_type()) { |
|
1025 | 1025 | |
1026 | 1026 | case 'Event' : |
1027 | 1027 | break; |
@@ -1029,39 +1029,39 @@ discard block |
||
1029 | 1029 | case 'Ticket' : |
1030 | 1030 | $ticket = $item->ticket(); |
1031 | 1031 | //right now we're only handling tickets here. Cause its expected that only tickets will have attendees right? |
1032 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
1032 | + if ( ! $ticket instanceof EE_Ticket) { |
|
1033 | 1033 | continue; |
1034 | 1034 | } |
1035 | 1035 | try { |
1036 | 1036 | $event_name = $ticket->get_event_name(); |
1037 | - } catch ( Exception $e ) { |
|
1038 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1039 | - $event_name = esc_html__( 'Unknown Event', 'event_espresso' ); |
|
1037 | + } catch (Exception $e) { |
|
1038 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1039 | + $event_name = esc_html__('Unknown Event', 'event_espresso'); |
|
1040 | 1040 | } |
1041 | - $event_name .= ' - ' . $item->get( 'LIN_name' ); |
|
1042 | - $ticket_price = EEH_Template::format_currency( $item->get( 'LIN_unit_price' ) ); |
|
1041 | + $event_name .= ' - '.$item->get('LIN_name'); |
|
1042 | + $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price')); |
|
1043 | 1043 | // now get all of the registrations for this transaction that use this ticket |
1044 | - $registrations = $ticket->get_many_related('Registration', array( array('TXN_ID' => $this->_transaction->ID() ))); |
|
1045 | - foreach( $registrations as $registration ) { |
|
1046 | - if ( ! $registration instanceof EE_Registration ) { |
|
1044 | + $registrations = $ticket->get_many_related('Registration', array(array('TXN_ID' => $this->_transaction->ID()))); |
|
1045 | + foreach ($registrations as $registration) { |
|
1046 | + if ( ! $registration instanceof EE_Registration) { |
|
1047 | 1047 | continue; |
1048 | 1048 | } |
1049 | - $this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID(); |
|
1050 | - $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->count(); |
|
1051 | - $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name; |
|
1052 | - $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price; |
|
1049 | + $this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID(); |
|
1050 | + $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->count(); |
|
1051 | + $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name; |
|
1052 | + $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price; |
|
1053 | 1053 | // attendee info |
1054 | 1054 | $attendee = $registration->get_first_related('Attendee'); |
1055 | - if ( $attendee instanceof EE_Attendee ) { |
|
1056 | - $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
|
1057 | - $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
|
1058 | - $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event', 'event_espresso') . '">' . $attendee->email() . '</a>'; |
|
1059 | - $this->_template_args['event_attendees'][$registration->ID()]['address'] = implode(',<br>', $attendee->full_address_as_array() ); |
|
1055 | + if ($attendee instanceof EE_Attendee) { |
|
1056 | + $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
|
1057 | + $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
|
1058 | + $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:'.$attendee->email().'?subject='.$event_name.esc_html__(' Event', 'event_espresso').'">'.$attendee->email().'</a>'; |
|
1059 | + $this->_template_args['event_attendees'][$registration->ID()]['address'] = implode(',<br>', $attendee->full_address_as_array()); |
|
1060 | 1060 | } else { |
1061 | 1061 | $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = ''; |
1062 | - $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = ''; |
|
1062 | + $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = ''; |
|
1063 | 1063 | $this->_template_args['event_attendees'][$registration->ID()]['email'] = ''; |
1064 | - $this->_template_args['event_attendees'][$registration->ID()]['address'] = ''; |
|
1064 | + $this->_template_args['event_attendees'][$registration->ID()]['address'] = ''; |
|
1065 | 1065 | } |
1066 | 1066 | } |
1067 | 1067 | break; |
@@ -1070,12 +1070,12 @@ discard block |
||
1070 | 1070 | } |
1071 | 1071 | } |
1072 | 1072 | |
1073 | - $this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'attendees' ), TXN_ADMIN_URL ); |
|
1074 | - echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE ); |
|
1073 | + $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'attendees'), TXN_ADMIN_URL); |
|
1074 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE); |
|
1075 | 1075 | |
1076 | 1076 | } else { |
1077 | 1077 | echo sprintf( |
1078 | - esc_html__( '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso' ), |
|
1078 | + esc_html__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso'), |
|
1079 | 1079 | '<p class="important-notice">', |
1080 | 1080 | '</p>' |
1081 | 1081 | ); |
@@ -1094,19 +1094,19 @@ discard block |
||
1094 | 1094 | */ |
1095 | 1095 | public function txn_registrant_side_meta_box() { |
1096 | 1096 | $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null; |
1097 | - if ( ! $primary_att instanceof EE_Attendee ) { |
|
1097 | + if ( ! $primary_att instanceof EE_Attendee) { |
|
1098 | 1098 | $this->_template_args['no_attendee_message'] = esc_html__('There is no attached contact for this transaction. The transaction either failed due to an error or was abandoned.', 'event_espresso'); |
1099 | 1099 | $primary_att = EEM_Attendee::instance()->create_default_object(); |
1100 | 1100 | } |
1101 | - $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
1101 | + $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
1102 | 1102 | $this->_template_args['prime_reg_fname'] = $primary_att->fname(); |
1103 | 1103 | $this->_template_args['prime_reg_lname'] = $primary_att->lname(); |
1104 | - $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
1104 | + $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
1105 | 1105 | $this->_template_args['prime_reg_phone'] = $primary_att->phone(); |
1106 | - $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'edit_attendee', 'post' => $primary_att->ID() ), REG_ADMIN_URL ); |
|
1106 | + $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $primary_att->ID()), REG_ADMIN_URL); |
|
1107 | 1107 | // get formatted address for registrant |
1108 | - $this->_template_args[ 'formatted_address' ] = EEH_Address::format( $primary_att ); |
|
1109 | - echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE ); |
|
1108 | + $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); |
|
1109 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE); |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | 1112 | |
@@ -1122,12 +1122,12 @@ discard block |
||
1122 | 1122 | |
1123 | 1123 | $this->_template_args['billing_form'] = $this->_transaction->billing_info(); |
1124 | 1124 | $this->_template_args['billing_form_url'] = add_query_arg( |
1125 | - array( 'action' => 'edit_transaction', 'process' => 'billing' ), |
|
1125 | + array('action' => 'edit_transaction', 'process' => 'billing'), |
|
1126 | 1126 | TXN_ADMIN_URL |
1127 | 1127 | ); |
1128 | 1128 | |
1129 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
1130 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );/**/ |
|
1129 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
1130 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); /**/ |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | |
@@ -1140,42 +1140,42 @@ discard block |
||
1140 | 1140 | * @return void |
1141 | 1141 | */ |
1142 | 1142 | public function apply_payments_or_refunds() { |
1143 | - $json_response_data = array( 'return_data' => FALSE ); |
|
1143 | + $json_response_data = array('return_data' => FALSE); |
|
1144 | 1144 | $valid_data = $this->_validate_payment_request_data(); |
1145 | - if ( ! empty( $valid_data ) ) { |
|
1146 | - $PAY_ID = $valid_data[ 'PAY_ID' ]; |
|
1145 | + if ( ! empty($valid_data)) { |
|
1146 | + $PAY_ID = $valid_data['PAY_ID']; |
|
1147 | 1147 | //save the new payment |
1148 | - $payment = $this->_create_payment_from_request_data( $valid_data ); |
|
1148 | + $payment = $this->_create_payment_from_request_data($valid_data); |
|
1149 | 1149 | // get the TXN for this payment |
1150 | 1150 | $transaction = $payment->transaction(); |
1151 | 1151 | // verify transaction |
1152 | - if ( $transaction instanceof EE_Transaction ) { |
|
1152 | + if ($transaction instanceof EE_Transaction) { |
|
1153 | 1153 | // calculate_total_payments_and_update_status |
1154 | - $this->_process_transaction_payments( $transaction ); |
|
1155 | - $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to( $payment ); |
|
1156 | - $this->_remove_existing_registration_payments( $payment, $PAY_ID ); |
|
1154 | + $this->_process_transaction_payments($transaction); |
|
1155 | + $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment); |
|
1156 | + $this->_remove_existing_registration_payments($payment, $PAY_ID); |
|
1157 | 1157 | // apply payment to registrations (if applicable) |
1158 | - if ( ! empty( $REG_IDs ) ) { |
|
1159 | - $this->_update_registration_payments( $transaction, $payment, $REG_IDs ); |
|
1158 | + if ( ! empty($REG_IDs)) { |
|
1159 | + $this->_update_registration_payments($transaction, $payment, $REG_IDs); |
|
1160 | 1160 | $this->_maybe_send_notifications(); |
1161 | 1161 | // now process status changes for the same registrations |
1162 | - $this->_process_registration_status_change( $transaction, $REG_IDs ); |
|
1162 | + $this->_process_registration_status_change($transaction, $REG_IDs); |
|
1163 | 1163 | } |
1164 | - $this->_maybe_send_notifications( $payment ); |
|
1164 | + $this->_maybe_send_notifications($payment); |
|
1165 | 1165 | //prepare to render page |
1166 | - $json_response_data[ 'return_data' ] = $this->_build_payment_json_response( $payment, $REG_IDs ); |
|
1167 | - do_action( 'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment ); |
|
1166 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs); |
|
1167 | + do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment); |
|
1168 | 1168 | } else { |
1169 | 1169 | EE_Error::add_error( |
1170 | - esc_html__( 'A valid Transaction for this payment could not be retrieved.', 'event_espresso' ), |
|
1170 | + esc_html__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'), |
|
1171 | 1171 | __FILE__, __FUNCTION__, __LINE__ |
1172 | 1172 | ); |
1173 | 1173 | } |
1174 | 1174 | } else { |
1175 | - EE_Error::add_error( esc_html__( 'The payment form data could not be processed. Please try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1175 | + EE_Error::add_error(esc_html__('The payment form data could not be processed. Please try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | - $notices = EE_Error::get_notices( false, false, false ); |
|
1178 | + $notices = EE_Error::get_notices(false, false, false); |
|
1179 | 1179 | $this->_template_args = array( |
1180 | 1180 | 'data' => $json_response_data, |
1181 | 1181 | 'error' => $notices['errors'], |
@@ -1192,30 +1192,30 @@ discard block |
||
1192 | 1192 | * @return array |
1193 | 1193 | */ |
1194 | 1194 | protected function _validate_payment_request_data() { |
1195 | - if ( ! isset( $this->_req_data[ 'txn_admin_payment' ] ) ) { |
|
1195 | + if ( ! isset($this->_req_data['txn_admin_payment'])) { |
|
1196 | 1196 | return false; |
1197 | 1197 | } |
1198 | 1198 | $payment_form = $this->_generate_payment_form_section(); |
1199 | 1199 | try { |
1200 | - if ( $payment_form->was_submitted() ) { |
|
1200 | + if ($payment_form->was_submitted()) { |
|
1201 | 1201 | $payment_form->receive_form_submission(); |
1202 | - if ( ! $payment_form->is_valid() ) { |
|
1202 | + if ( ! $payment_form->is_valid()) { |
|
1203 | 1203 | $submission_error_messages = array(); |
1204 | - foreach ( $payment_form->get_validation_errors_accumulated() as $validation_error ) { |
|
1205 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1204 | + foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) { |
|
1205 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1206 | 1206 | $submission_error_messages[] = sprintf( |
1207 | - _x( '%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso' ), |
|
1207 | + _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'), |
|
1208 | 1208 | $validation_error->get_form_section()->html_label_text(), |
1209 | 1209 | $validation_error->getMessage() |
1210 | 1210 | ); |
1211 | 1211 | } |
1212 | 1212 | } |
1213 | - EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1213 | + EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1214 | 1214 | return array(); |
1215 | 1215 | } |
1216 | 1216 | } |
1217 | - } catch ( EE_Error $e ) { |
|
1218 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1217 | + } catch (EE_Error $e) { |
|
1218 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1219 | 1219 | return array(); |
1220 | 1220 | } |
1221 | 1221 | return $payment_form->valid_data(); |
@@ -1237,63 +1237,63 @@ discard block |
||
1237 | 1237 | array( |
1238 | 1238 | 'default' => 0, |
1239 | 1239 | 'required' => false, |
1240 | - 'html_label_text' => esc_html__( 'Payment ID', 'event_espresso' ), |
|
1241 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
1240 | + 'html_label_text' => esc_html__('Payment ID', 'event_espresso'), |
|
1241 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1242 | 1242 | ) |
1243 | 1243 | ), |
1244 | 1244 | 'TXN_ID' => new EE_Text_Input( |
1245 | 1245 | array( |
1246 | 1246 | 'default' => 0, |
1247 | 1247 | 'required' => true, |
1248 | - 'html_label_text' => esc_html__( 'Transaction ID', 'event_espresso' ), |
|
1249 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
1248 | + 'html_label_text' => esc_html__('Transaction ID', 'event_espresso'), |
|
1249 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1250 | 1250 | ) |
1251 | 1251 | ), |
1252 | 1252 | 'type' => new EE_Text_Input( |
1253 | 1253 | array( |
1254 | 1254 | 'default' => 1, |
1255 | 1255 | 'required' => true, |
1256 | - 'html_label_text' => esc_html__( 'Payment or Refund', 'event_espresso' ), |
|
1257 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
1256 | + 'html_label_text' => esc_html__('Payment or Refund', 'event_espresso'), |
|
1257 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1258 | 1258 | ) |
1259 | 1259 | ), |
1260 | 1260 | 'amount' => new EE_Text_Input( |
1261 | 1261 | array( |
1262 | 1262 | 'default' => 0, |
1263 | 1263 | 'required' => true, |
1264 | - 'html_label_text' => esc_html__( 'Payment amount', 'event_espresso' ), |
|
1265 | - 'validation_strategies' => array( new EE_Float_Normalization() ) |
|
1264 | + 'html_label_text' => esc_html__('Payment amount', 'event_espresso'), |
|
1265 | + 'validation_strategies' => array(new EE_Float_Normalization()) |
|
1266 | 1266 | ) |
1267 | 1267 | ), |
1268 | 1268 | 'status' => new EE_Text_Input( |
1269 | 1269 | array( |
1270 | 1270 | 'default' => EEM_Payment::status_id_approved, |
1271 | 1271 | 'required' => true, |
1272 | - 'html_label_text' => esc_html__( 'Payment status', 'event_espresso' ), |
|
1272 | + 'html_label_text' => esc_html__('Payment status', 'event_espresso'), |
|
1273 | 1273 | ) |
1274 | 1274 | ), |
1275 | 1275 | 'PMD_ID' => new EE_Text_Input( |
1276 | 1276 | array( |
1277 | 1277 | 'default' => 2, |
1278 | 1278 | 'required' => true, |
1279 | - 'html_label_text' => esc_html__( 'Payment Method', 'event_espresso' ), |
|
1280 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
1279 | + 'html_label_text' => esc_html__('Payment Method', 'event_espresso'), |
|
1280 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1281 | 1281 | ) |
1282 | 1282 | ), |
1283 | 1283 | 'date' => new EE_Text_Input( |
1284 | 1284 | array( |
1285 | 1285 | 'default' => time(), |
1286 | 1286 | 'required' => true, |
1287 | - 'html_label_text' => esc_html__( 'Payment date', 'event_espresso' ), |
|
1287 | + 'html_label_text' => esc_html__('Payment date', 'event_espresso'), |
|
1288 | 1288 | ) |
1289 | 1289 | ), |
1290 | 1290 | 'txn_id_chq_nmbr' => new EE_Text_Input( |
1291 | 1291 | array( |
1292 | 1292 | 'default' => '', |
1293 | 1293 | 'required' => false, |
1294 | - 'html_label_text' => esc_html__( 'Transaction or Cheque Number', 'event_espresso' ), |
|
1294 | + 'html_label_text' => esc_html__('Transaction or Cheque Number', 'event_espresso'), |
|
1295 | 1295 | 'validation_strategies' => array( |
1296 | - new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1296 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100), |
|
1297 | 1297 | ) |
1298 | 1298 | ) |
1299 | 1299 | ), |
@@ -1301,9 +1301,9 @@ discard block |
||
1301 | 1301 | array( |
1302 | 1302 | 'default' => '', |
1303 | 1303 | 'required' => false, |
1304 | - 'html_label_text' => esc_html__( 'Purchase Order Number', 'event_espresso' ), |
|
1304 | + 'html_label_text' => esc_html__('Purchase Order Number', 'event_espresso'), |
|
1305 | 1305 | 'validation_strategies' => array( |
1306 | - new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1306 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100), |
|
1307 | 1307 | ) |
1308 | 1308 | ) |
1309 | 1309 | ), |
@@ -1311,9 +1311,9 @@ discard block |
||
1311 | 1311 | array( |
1312 | 1312 | 'default' => '', |
1313 | 1313 | 'required' => false, |
1314 | - 'html_label_text' => esc_html__( 'Extra Field for Accounting', 'event_espresso' ), |
|
1314 | + 'html_label_text' => esc_html__('Extra Field for Accounting', 'event_espresso'), |
|
1315 | 1315 | 'validation_strategies' => array( |
1316 | - new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1316 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100), |
|
1317 | 1317 | ) |
1318 | 1318 | ) |
1319 | 1319 | ), |
@@ -1330,37 +1330,37 @@ discard block |
||
1330 | 1330 | * @param array $valid_data |
1331 | 1331 | * @return EE_Payment |
1332 | 1332 | */ |
1333 | - protected function _create_payment_from_request_data( $valid_data ) { |
|
1334 | - $PAY_ID = $valid_data[ 'PAY_ID' ]; |
|
1333 | + protected function _create_payment_from_request_data($valid_data) { |
|
1334 | + $PAY_ID = $valid_data['PAY_ID']; |
|
1335 | 1335 | // get payment amount |
1336 | - $amount = $valid_data[ 'amount' ] ? abs( $valid_data[ 'amount' ] ) : 0; |
|
1336 | + $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0; |
|
1337 | 1337 | // payments have a type value of 1 and refunds have a type value of -1 |
1338 | 1338 | // so multiplying amount by type will give a positive value for payments, and negative values for refunds |
1339 | - $amount = $valid_data[ 'type' ] < 0 ? $amount * -1 : $amount; |
|
1339 | + $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount; |
|
1340 | 1340 | // for some reason the date string coming in has extra spaces between the date and time. This fixes that. |
1341 | - $date = $valid_data['date'] ? preg_replace( '/\s+/', ' ', $valid_data['date'] ) : date( 'Y-m-d g:i a', current_time( 'timestamp' ) ); |
|
1341 | + $date = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a', current_time('timestamp')); |
|
1342 | 1342 | $payment = EE_Payment::new_instance( |
1343 | 1343 | array( |
1344 | - 'TXN_ID' => $valid_data[ 'TXN_ID' ], |
|
1345 | - 'STS_ID' => $valid_data[ 'status' ], |
|
1344 | + 'TXN_ID' => $valid_data['TXN_ID'], |
|
1345 | + 'STS_ID' => $valid_data['status'], |
|
1346 | 1346 | 'PAY_timestamp' => $date, |
1347 | 1347 | 'PAY_source' => EEM_Payment_Method::scope_admin, |
1348 | - 'PMD_ID' => $valid_data[ 'PMD_ID' ], |
|
1348 | + 'PMD_ID' => $valid_data['PMD_ID'], |
|
1349 | 1349 | 'PAY_amount' => $amount, |
1350 | - 'PAY_txn_id_chq_nmbr' => $valid_data[ 'txn_id_chq_nmbr' ], |
|
1351 | - 'PAY_po_number' => $valid_data[ 'po_number' ], |
|
1352 | - 'PAY_extra_accntng' => $valid_data[ 'accounting' ], |
|
1350 | + 'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'], |
|
1351 | + 'PAY_po_number' => $valid_data['po_number'], |
|
1352 | + 'PAY_extra_accntng' => $valid_data['accounting'], |
|
1353 | 1353 | 'PAY_details' => $valid_data, |
1354 | 1354 | 'PAY_ID' => $PAY_ID |
1355 | 1355 | ), |
1356 | 1356 | '', |
1357 | - array( 'Y-m-d', 'g:i a' ) |
|
1357 | + array('Y-m-d', 'g:i a') |
|
1358 | 1358 | ); |
1359 | 1359 | |
1360 | - if ( ! $payment->save() ) { |
|
1360 | + if ( ! $payment->save()) { |
|
1361 | 1361 | EE_Error::add_error( |
1362 | 1362 | sprintf( |
1363 | - esc_html__( 'Payment %1$d has not been successfully saved to the database.', 'event_espresso' ), |
|
1363 | + esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'), |
|
1364 | 1364 | $payment->ID() |
1365 | 1365 | ), |
1366 | 1366 | __FILE__, __FUNCTION__, __LINE__ |
@@ -1377,15 +1377,15 @@ discard block |
||
1377 | 1377 | * @param \EE_Transaction $transaction |
1378 | 1378 | * @return array |
1379 | 1379 | */ |
1380 | - protected function _process_transaction_payments( EE_Transaction $transaction ) { |
|
1380 | + protected function _process_transaction_payments(EE_Transaction $transaction) { |
|
1381 | 1381 | /** @type EE_Transaction_Payments $transaction_payments */ |
1382 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1382 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1383 | 1383 | //update the transaction with this payment |
1384 | - if ( $transaction_payments->calculate_total_payments_and_update_status( $transaction ) ) { |
|
1385 | - EE_Error::add_success( esc_html__( 'The payment has been processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1384 | + if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) { |
|
1385 | + EE_Error::add_success(esc_html__('The payment has been processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1386 | 1386 | } else { |
1387 | 1387 | EE_Error::add_error( |
1388 | - esc_html__( 'The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso' ) |
|
1388 | + esc_html__('The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso') |
|
1389 | 1389 | , __FILE__, __FUNCTION__, __LINE__ |
1390 | 1390 | ); |
1391 | 1391 | } |
@@ -1401,19 +1401,19 @@ discard block |
||
1401 | 1401 | * @param \EE_Payment $payment |
1402 | 1402 | * @return array |
1403 | 1403 | */ |
1404 | - protected function _get_REG_IDs_to_apply_payment_to( EE_Payment $payment ) { |
|
1404 | + protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) { |
|
1405 | 1405 | $REG_IDs = array(); |
1406 | 1406 | // grab array of IDs for specific registrations to apply changes to |
1407 | - if ( isset( $this->_req_data[ 'txn_admin_payment' ][ 'registrations' ] ) ) { |
|
1408 | - $REG_IDs = (array)$this->_req_data[ 'txn_admin_payment' ][ 'registrations' ]; |
|
1407 | + if (isset($this->_req_data['txn_admin_payment']['registrations'])) { |
|
1408 | + $REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations']; |
|
1409 | 1409 | } |
1410 | 1410 | //nothing specified ? then get all reg IDs |
1411 | - if ( empty( $REG_IDs ) ) { |
|
1411 | + if (empty($REG_IDs)) { |
|
1412 | 1412 | $registrations = $payment->transaction()->registrations(); |
1413 | - $REG_IDs = ! empty( $registrations ) ? array_keys( $registrations ) : $this->_get_existing_reg_payment_REG_IDs( $payment ); |
|
1413 | + $REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1414 | 1414 | } |
1415 | 1415 | // ensure that REG_IDs are integers and NOT strings |
1416 | - return array_map( 'intval', $REG_IDs ); |
|
1416 | + return array_map('intval', $REG_IDs); |
|
1417 | 1417 | } |
1418 | 1418 | |
1419 | 1419 | |
@@ -1430,7 +1430,7 @@ discard block |
||
1430 | 1430 | /** |
1431 | 1431 | * @param array $existing_reg_payment_REG_IDs |
1432 | 1432 | */ |
1433 | - public function set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs = null ) { |
|
1433 | + public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) { |
|
1434 | 1434 | $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs; |
1435 | 1435 | } |
1436 | 1436 | |
@@ -1445,13 +1445,13 @@ discard block |
||
1445 | 1445 | * @param \EE_Payment $payment |
1446 | 1446 | * @return array |
1447 | 1447 | */ |
1448 | - protected function _get_existing_reg_payment_REG_IDs( EE_Payment $payment ) { |
|
1449 | - if ( $this->existing_reg_payment_REG_IDs() === null ) { |
|
1448 | + protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) { |
|
1449 | + if ($this->existing_reg_payment_REG_IDs() === null) { |
|
1450 | 1450 | // let's get any existing reg payment records for this payment |
1451 | - $existing_reg_payment_REG_IDs = $payment->get_many_related( 'Registration' ); |
|
1451 | + $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration'); |
|
1452 | 1452 | // but we only want the REG IDs, so grab the array keys |
1453 | - $existing_reg_payment_REG_IDs = ! empty( $existing_reg_payment_REG_IDs ) ? array_keys( $existing_reg_payment_REG_IDs ) : array(); |
|
1454 | - $this->set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs ); |
|
1453 | + $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array(); |
|
1454 | + $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs); |
|
1455 | 1455 | } |
1456 | 1456 | return $this->existing_reg_payment_REG_IDs(); |
1457 | 1457 | } |
@@ -1470,23 +1470,23 @@ discard block |
||
1470 | 1470 | * @param int $PAY_ID |
1471 | 1471 | * @return bool; |
1472 | 1472 | */ |
1473 | - protected function _remove_existing_registration_payments( EE_Payment $payment, $PAY_ID = 0 ) { |
|
1473 | + protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) { |
|
1474 | 1474 | // newly created payments will have nothing recorded for $PAY_ID |
1475 | - if ( $PAY_ID == 0 ) { |
|
1475 | + if ($PAY_ID == 0) { |
|
1476 | 1476 | return false; |
1477 | 1477 | } |
1478 | - $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment ); |
|
1479 | - if ( empty( $existing_reg_payment_REG_IDs )) { |
|
1478 | + $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1479 | + if (empty($existing_reg_payment_REG_IDs)) { |
|
1480 | 1480 | return false; |
1481 | 1481 | } |
1482 | 1482 | /** @type EE_Transaction_Payments $transaction_payments */ |
1483 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1483 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1484 | 1484 | return $transaction_payments->delete_registration_payments_and_update_registrations( |
1485 | 1485 | $payment, |
1486 | 1486 | array( |
1487 | 1487 | array( |
1488 | 1488 | 'PAY_ID' => $payment->ID(), |
1489 | - 'REG_ID' => array( 'IN', $existing_reg_payment_REG_IDs ), |
|
1489 | + 'REG_ID' => array('IN', $existing_reg_payment_REG_IDs), |
|
1490 | 1490 | ) |
1491 | 1491 | ) |
1492 | 1492 | ); |
@@ -1505,25 +1505,25 @@ discard block |
||
1505 | 1505 | * @param array $REG_IDs |
1506 | 1506 | * @return bool |
1507 | 1507 | */ |
1508 | - protected function _update_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array() ) { |
|
1508 | + protected function _update_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array()) { |
|
1509 | 1509 | // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments() |
1510 | 1510 | // so let's do that using our set of REG_IDs from the form |
1511 | 1511 | $registration_query_where_params = array( |
1512 | - 'REG_ID' => array( 'IN', $REG_IDs ) |
|
1512 | + 'REG_ID' => array('IN', $REG_IDs) |
|
1513 | 1513 | ); |
1514 | 1514 | // but add in some conditions regarding payment, |
1515 | 1515 | // so that we don't apply payments to registrations that are free or have already been paid for |
1516 | 1516 | // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative ) |
1517 | - if ( ! $payment->is_a_refund() ) { |
|
1518 | - $registration_query_where_params[ 'REG_final_price' ] = array( '!=', 0 ); |
|
1519 | - $registration_query_where_params[ 'REG_final_price*' ] = array( '!=', 'REG_paid', true ); |
|
1517 | + if ( ! $payment->is_a_refund()) { |
|
1518 | + $registration_query_where_params['REG_final_price'] = array('!=', 0); |
|
1519 | + $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true); |
|
1520 | 1520 | } |
1521 | 1521 | //EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ ); |
1522 | - $registrations = $transaction->registrations( array( $registration_query_where_params ) ); |
|
1523 | - if ( ! empty( $registrations ) ) { |
|
1522 | + $registrations = $transaction->registrations(array($registration_query_where_params)); |
|
1523 | + if ( ! empty($registrations)) { |
|
1524 | 1524 | /** @type EE_Payment_Processor $payment_processor */ |
1525 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1526 | - $payment_processor->process_registration_payments( $transaction, $payment, $registrations ); |
|
1525 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1526 | + $payment_processor->process_registration_payments($transaction, $payment, $registrations); |
|
1527 | 1527 | } |
1528 | 1528 | } |
1529 | 1529 | |
@@ -1539,22 +1539,22 @@ discard block |
||
1539 | 1539 | * @param array $REG_IDs |
1540 | 1540 | * @return bool |
1541 | 1541 | */ |
1542 | - protected function _process_registration_status_change( EE_Transaction $transaction, $REG_IDs = array() ) { |
|
1542 | + protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) { |
|
1543 | 1543 | // first if there is no change in status then we get out. |
1544 | 1544 | if ( |
1545 | - ! isset( $this->_req_data['txn_reg_status_change'], $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ) |
|
1545 | + ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status']) |
|
1546 | 1546 | || $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN' |
1547 | 1547 | ) { |
1548 | 1548 | //no error message, no change requested, just nothing to do man. |
1549 | 1549 | return FALSE; |
1550 | 1550 | } |
1551 | 1551 | /** @type EE_Transaction_Processor $transaction_processor */ |
1552 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1552 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1553 | 1553 | // made it here dude? Oh WOW. K, let's take care of changing the statuses |
1554 | 1554 | return $transaction_processor->manually_update_registration_statuses( |
1555 | 1555 | $transaction, |
1556 | - sanitize_text_field( $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ), |
|
1557 | - array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) |
|
1556 | + sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']), |
|
1557 | + array(array('REG_ID' => array('IN', $REG_IDs))) |
|
1558 | 1558 | ); |
1559 | 1559 | } |
1560 | 1560 | |
@@ -1569,16 +1569,16 @@ discard block |
||
1569 | 1569 | * @param bool | null $delete_txn_reg_status_change |
1570 | 1570 | * @return array |
1571 | 1571 | */ |
1572 | - protected function _build_payment_json_response( EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null ) { |
|
1572 | + protected function _build_payment_json_response(EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null) { |
|
1573 | 1573 | // was the payment deleted ? |
1574 | - if ( is_bool( $delete_txn_reg_status_change )) { |
|
1574 | + if (is_bool($delete_txn_reg_status_change)) { |
|
1575 | 1575 | return array( |
1576 | 1576 | 'PAY_ID' => $payment->ID(), |
1577 | 1577 | 'amount' => $payment->amount(), |
1578 | 1578 | 'total_paid' => $payment->transaction()->paid(), |
1579 | 1579 | 'txn_status' => $payment->transaction()->status_ID(), |
1580 | 1580 | 'pay_status' => $payment->STS_ID(), |
1581 | - 'registrations' => $this->_registration_payment_data_array( $REG_IDs ), |
|
1581 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
1582 | 1582 | 'delete_txn_reg_status_change' => $delete_txn_reg_status_change, |
1583 | 1583 | ); |
1584 | 1584 | } else { |
@@ -1590,16 +1590,16 @@ discard block |
||
1590 | 1590 | 'pay_status' => $payment->STS_ID(), |
1591 | 1591 | 'PAY_ID' => $payment->ID(), |
1592 | 1592 | 'STS_ID' => $payment->STS_ID(), |
1593 | - 'status' => self::$_pay_status[ $payment->STS_ID() ], |
|
1594 | - 'date' => $payment->timestamp( 'Y-m-d', 'h:i a' ), |
|
1595 | - 'method' => strtoupper( $payment->source() ), |
|
1593 | + 'status' => self::$_pay_status[$payment->STS_ID()], |
|
1594 | + 'date' => $payment->timestamp('Y-m-d', 'h:i a'), |
|
1595 | + 'method' => strtoupper($payment->source()), |
|
1596 | 1596 | 'PM_ID' => $payment->payment_method() ? $payment->payment_method()->ID() : 1, |
1597 | - 'gateway' => $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__( "Unknown", 'event_espresso' ), |
|
1597 | + 'gateway' => $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__("Unknown", 'event_espresso'), |
|
1598 | 1598 | 'gateway_response' => $payment->gateway_response(), |
1599 | 1599 | 'txn_id_chq_nmbr' => $payment->txn_id_chq_nmbr(), |
1600 | 1600 | 'po_number' => $payment->po_number(), |
1601 | 1601 | 'extra_accntng' => $payment->extra_accntng(), |
1602 | - 'registrations' => $this->_registration_payment_data_array( $REG_IDs ), |
|
1602 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
1603 | 1603 | ); |
1604 | 1604 | } |
1605 | 1605 | } |
@@ -1614,39 +1614,39 @@ discard block |
||
1614 | 1614 | * @return void |
1615 | 1615 | */ |
1616 | 1616 | public function delete_payment() { |
1617 | - $json_response_data = array( 'return_data' => FALSE ); |
|
1618 | - $PAY_ID = isset( $this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) ? absint( $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) : 0; |
|
1619 | - if ( $PAY_ID ) { |
|
1620 | - $delete_txn_reg_status_change = isset( $this->_req_data[ 'delete_txn_reg_status_change' ] ) ? $this->_req_data[ 'delete_txn_reg_status_change' ] : false; |
|
1621 | - $payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID ); |
|
1622 | - if ( $payment instanceof EE_Payment ) { |
|
1623 | - $REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment ); |
|
1617 | + $json_response_data = array('return_data' => FALSE); |
|
1618 | + $PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0; |
|
1619 | + if ($PAY_ID) { |
|
1620 | + $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false; |
|
1621 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
1622 | + if ($payment instanceof EE_Payment) { |
|
1623 | + $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1624 | 1624 | /** @type EE_Transaction_Payments $transaction_payments */ |
1625 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1626 | - if ( $transaction_payments->delete_payment_and_update_transaction( $payment )) { |
|
1627 | - $json_response_data['return_data'] = $this->_build_payment_json_response( $payment, $REG_IDs, $delete_txn_reg_status_change ); |
|
1628 | - if ( $delete_txn_reg_status_change ) { |
|
1625 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1626 | + if ($transaction_payments->delete_payment_and_update_transaction($payment)) { |
|
1627 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, $delete_txn_reg_status_change); |
|
1628 | + if ($delete_txn_reg_status_change) { |
|
1629 | 1629 | $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change; |
1630 | 1630 | //MAKE sure we also add the delete_txn_req_status_change to the |
1631 | 1631 | //$_REQUEST global because that's how messages will be looking for it. |
1632 | 1632 | $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change; |
1633 | 1633 | $this->_maybe_send_notifications(); |
1634 | - $this->_process_registration_status_change( $payment->transaction(), $REG_IDs ); |
|
1634 | + $this->_process_registration_status_change($payment->transaction(), $REG_IDs); |
|
1635 | 1635 | } |
1636 | 1636 | } |
1637 | 1637 | } else { |
1638 | 1638 | EE_Error::add_error( |
1639 | - esc_html__( 'Valid Payment data could not be retrieved from the database.', 'event_espresso' ), |
|
1639 | + esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'), |
|
1640 | 1640 | __FILE__, __FUNCTION__, __LINE__ |
1641 | 1641 | ); |
1642 | 1642 | } |
1643 | 1643 | } else { |
1644 | 1644 | EE_Error::add_error( |
1645 | - esc_html__( 'A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso' ), |
|
1645 | + esc_html__('A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso'), |
|
1646 | 1646 | __FILE__, __FUNCTION__, __LINE__ |
1647 | 1647 | ); |
1648 | 1648 | } |
1649 | - $notices = EE_Error::get_notices( false, false, false); |
|
1649 | + $notices = EE_Error::get_notices(false, false, false); |
|
1650 | 1650 | $this->_template_args = array( |
1651 | 1651 | 'data' => $json_response_data, |
1652 | 1652 | 'success' => $notices['success'], |
@@ -1666,16 +1666,16 @@ discard block |
||
1666 | 1666 | * @param array $REG_IDs |
1667 | 1667 | * @return array |
1668 | 1668 | */ |
1669 | - protected function _registration_payment_data_array( $REG_IDs ) { |
|
1669 | + protected function _registration_payment_data_array($REG_IDs) { |
|
1670 | 1670 | $registration_payment_data = array(); |
1671 | 1671 | //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows. |
1672 | - if ( ! empty( $REG_IDs ) ) { |
|
1673 | - $registrations = EEM_Registration::instance()->get_all( array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) ); |
|
1674 | - foreach ( $registrations as $registration ) { |
|
1675 | - if ( $registration instanceof EE_Registration ) { |
|
1676 | - $registration_payment_data[ $registration->ID() ] = array( |
|
1672 | + if ( ! empty($REG_IDs)) { |
|
1673 | + $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs)))); |
|
1674 | + foreach ($registrations as $registration) { |
|
1675 | + if ($registration instanceof EE_Registration) { |
|
1676 | + $registration_payment_data[$registration->ID()] = array( |
|
1677 | 1677 | 'paid' => $registration->pretty_paid(), |
1678 | - 'owing' => EEH_Template::format_currency( $registration->final_price() - $registration->paid() ), |
|
1678 | + 'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()), |
|
1679 | 1679 | ); |
1680 | 1680 | } |
1681 | 1681 | } |
@@ -1695,30 +1695,30 @@ discard block |
||
1695 | 1695 | * @access protected |
1696 | 1696 | * @param \EE_Payment | null $payment |
1697 | 1697 | */ |
1698 | - protected function _maybe_send_notifications( $payment = null ) { |
|
1699 | - switch ( $payment instanceof EE_Payment ) { |
|
1698 | + protected function _maybe_send_notifications($payment = null) { |
|
1699 | + switch ($payment instanceof EE_Payment) { |
|
1700 | 1700 | // payment notifications |
1701 | 1701 | case true : |
1702 | 1702 | if ( |
1703 | 1703 | isset( |
1704 | - $this->_req_data[ 'txn_payments' ], |
|
1705 | - $this->_req_data[ 'txn_payments' ][ 'send_notifications' ] |
|
1704 | + $this->_req_data['txn_payments'], |
|
1705 | + $this->_req_data['txn_payments']['send_notifications'] |
|
1706 | 1706 | ) && |
1707 | - filter_var( $this->_req_data[ 'txn_payments' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN ) |
|
1707 | + filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
1708 | 1708 | ) { |
1709 | - $this->_process_payment_notification( $payment ); |
|
1709 | + $this->_process_payment_notification($payment); |
|
1710 | 1710 | } |
1711 | 1711 | break; |
1712 | 1712 | // registration notifications |
1713 | 1713 | case false : |
1714 | 1714 | if ( |
1715 | 1715 | isset( |
1716 | - $this->_req_data[ 'txn_reg_status_change' ], |
|
1717 | - $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] |
|
1716 | + $this->_req_data['txn_reg_status_change'], |
|
1717 | + $this->_req_data['txn_reg_status_change']['send_notifications'] |
|
1718 | 1718 | ) && |
1719 | - filter_var( $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN ) |
|
1719 | + filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
1720 | 1720 | ) { |
1721 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
1721 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
1722 | 1722 | } |
1723 | 1723 | break; |
1724 | 1724 | } |
@@ -1734,11 +1734,11 @@ discard block |
||
1734 | 1734 | * @return void |
1735 | 1735 | */ |
1736 | 1736 | protected function _send_payment_reminder() { |
1737 | - $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE; |
|
1738 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
1739 | - $query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID'] ) : array(); |
|
1740 | - do_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction ); |
|
1741 | - $this->_redirect_after_action( FALSE, esc_html__('payment reminder', 'event_espresso'), esc_html__('sent', 'event_espresso'), $query_args, TRUE ); |
|
1737 | + $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE; |
|
1738 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
1739 | + $query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID']) : array(); |
|
1740 | + do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction); |
|
1741 | + $this->_redirect_after_action(FALSE, esc_html__('payment reminder', 'event_espresso'), esc_html__('sent', 'event_espresso'), $query_args, TRUE); |
|
1742 | 1742 | } |
1743 | 1743 | |
1744 | 1744 | |
@@ -1752,36 +1752,36 @@ discard block |
||
1752 | 1752 | * @param string $view |
1753 | 1753 | * @return mixed int = count || array of transaction objects |
1754 | 1754 | */ |
1755 | - public function get_transactions( $perpage, $count = FALSE, $view = '' ) { |
|
1755 | + public function get_transactions($perpage, $count = FALSE, $view = '') { |
|
1756 | 1756 | |
1757 | 1757 | $TXN = EEM_Transaction::instance(); |
1758 | 1758 | |
1759 | - $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' )); |
|
1760 | - $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' ); |
|
1759 | + $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year')); |
|
1760 | + $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y'); |
|
1761 | 1761 | |
1762 | 1762 | //make sure our timestamps start and end right at the boundaries for each day |
1763 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
1764 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
1763 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
1764 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
1765 | 1765 | |
1766 | 1766 | |
1767 | 1767 | //convert to timestamps |
1768 | - $start_date = strtotime( $start_date ); |
|
1769 | - $end_date = strtotime( $end_date ); |
|
1768 | + $start_date = strtotime($start_date); |
|
1769 | + $end_date = strtotime($end_date); |
|
1770 | 1770 | |
1771 | 1771 | //makes sure start date is the lowest value and vice versa |
1772 | - $start_date = min( $start_date, $end_date ); |
|
1773 | - $end_date = max( $start_date, $end_date ); |
|
1772 | + $start_date = min($start_date, $end_date); |
|
1773 | + $end_date = max($start_date, $end_date); |
|
1774 | 1774 | |
1775 | 1775 | //convert to correct format for query |
1776 | - $start_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' ); |
|
1777 | - $end_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' ); |
|
1776 | + $start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
1777 | + $end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
1778 | 1778 | |
1779 | 1779 | |
1780 | 1780 | |
1781 | 1781 | //set orderby |
1782 | 1782 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
1783 | 1783 | |
1784 | - switch ( $this->_req_data['orderby'] ) { |
|
1784 | + switch ($this->_req_data['orderby']) { |
|
1785 | 1785 | case 'TXN_ID': |
1786 | 1786 | $orderby = 'TXN_ID'; |
1787 | 1787 | break; |
@@ -1795,66 +1795,66 @@ discard block |
||
1795 | 1795 | $orderby = 'TXN_timestamp'; |
1796 | 1796 | } |
1797 | 1797 | |
1798 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
1799 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
1800 | - $per_page = isset( $perpage ) && !empty( $perpage ) ? $perpage : 10; |
|
1801 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
1798 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
1799 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
1800 | + $per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10; |
|
1801 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
1802 | 1802 | |
1803 | - $offset = ($current_page-1)*$per_page; |
|
1804 | - $limit = array( $offset, $per_page ); |
|
1803 | + $offset = ($current_page - 1) * $per_page; |
|
1804 | + $limit = array($offset, $per_page); |
|
1805 | 1805 | |
1806 | 1806 | $_where = array( |
1807 | - 'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date) ), |
|
1807 | + 'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)), |
|
1808 | 1808 | 'Registration.REG_count' => 1 |
1809 | 1809 | ); |
1810 | 1810 | |
1811 | - if ( isset( $this->_req_data['EVT_ID'] ) ) { |
|
1811 | + if (isset($this->_req_data['EVT_ID'])) { |
|
1812 | 1812 | $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID']; |
1813 | 1813 | } |
1814 | 1814 | |
1815 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1816 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1815 | + if (isset($this->_req_data['s'])) { |
|
1816 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1817 | 1817 | $_where['OR'] = array( |
1818 | - 'Registration.Event.EVT_name' => array( 'LIKE', $search_string ), |
|
1819 | - 'Registration.Event.EVT_desc' => array( 'LIKE', $search_string ), |
|
1820 | - 'Registration.Event.EVT_short_desc' => array( 'LIKE' , $search_string ), |
|
1821 | - 'Registration.Attendee.ATT_full_name' => array( 'LIKE', $search_string ), |
|
1822 | - 'Registration.Attendee.ATT_fname' => array( 'LIKE', $search_string ), |
|
1823 | - 'Registration.Attendee.ATT_lname' => array( 'LIKE', $search_string ), |
|
1824 | - 'Registration.Attendee.ATT_short_bio' => array( 'LIKE', $search_string ), |
|
1825 | - 'Registration.Attendee.ATT_email' => array('LIKE', $search_string ), |
|
1826 | - 'Registration.Attendee.ATT_address' => array( 'LIKE', $search_string ), |
|
1827 | - 'Registration.Attendee.ATT_address2' => array( 'LIKE', $search_string ), |
|
1828 | - 'Registration.Attendee.ATT_city' => array( 'LIKE', $search_string ), |
|
1829 | - 'Registration.REG_final_price' => array( 'LIKE', $search_string ), |
|
1830 | - 'Registration.REG_code' => array( 'LIKE', $search_string ), |
|
1831 | - 'Registration.REG_count' => array( 'LIKE' , $search_string ), |
|
1832 | - 'Registration.REG_group_size' => array( 'LIKE' , $search_string ), |
|
1833 | - 'Registration.Ticket.TKT_name' => array( 'LIKE', $search_string ), |
|
1834 | - 'Registration.Ticket.TKT_description' => array( 'LIKE', $search_string ), |
|
1835 | - 'Payment.PAY_source' => array('LIKE', $search_string ), |
|
1836 | - 'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string ), |
|
1837 | - 'TXN_session_data' => array( 'LIKE', $search_string ), |
|
1838 | - 'Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $search_string ) |
|
1818 | + 'Registration.Event.EVT_name' => array('LIKE', $search_string), |
|
1819 | + 'Registration.Event.EVT_desc' => array('LIKE', $search_string), |
|
1820 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $search_string), |
|
1821 | + 'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
1822 | + 'Registration.Attendee.ATT_fname' => array('LIKE', $search_string), |
|
1823 | + 'Registration.Attendee.ATT_lname' => array('LIKE', $search_string), |
|
1824 | + 'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
1825 | + 'Registration.Attendee.ATT_email' => array('LIKE', $search_string), |
|
1826 | + 'Registration.Attendee.ATT_address' => array('LIKE', $search_string), |
|
1827 | + 'Registration.Attendee.ATT_address2' => array('LIKE', $search_string), |
|
1828 | + 'Registration.Attendee.ATT_city' => array('LIKE', $search_string), |
|
1829 | + 'Registration.REG_final_price' => array('LIKE', $search_string), |
|
1830 | + 'Registration.REG_code' => array('LIKE', $search_string), |
|
1831 | + 'Registration.REG_count' => array('LIKE', $search_string), |
|
1832 | + 'Registration.REG_group_size' => array('LIKE', $search_string), |
|
1833 | + 'Registration.Ticket.TKT_name' => array('LIKE', $search_string), |
|
1834 | + 'Registration.Ticket.TKT_description' => array('LIKE', $search_string), |
|
1835 | + 'Payment.PAY_source' => array('LIKE', $search_string), |
|
1836 | + 'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string), |
|
1837 | + 'TXN_session_data' => array('LIKE', $search_string), |
|
1838 | + 'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string) |
|
1839 | 1839 | ); |
1840 | 1840 | } |
1841 | 1841 | |
1842 | 1842 | //failed transactions |
1843 | - $failed = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'failed' && ! $count ) || ( $count && $view == 'failed' ) ? TRUE: FALSE; |
|
1844 | - $abandoned = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'abandoned' && ! $count ) || ( $count && $view == 'abandoned' ) ? TRUE: FALSE; |
|
1843 | + $failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? TRUE : FALSE; |
|
1844 | + $abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? TRUE : FALSE; |
|
1845 | 1845 | |
1846 | - if ( $failed ) { |
|
1847 | - $_where[ 'STS_ID' ] = EEM_Transaction::failed_status_code; |
|
1848 | - } else if ( $abandoned ) { |
|
1846 | + if ($failed) { |
|
1847 | + $_where['STS_ID'] = EEM_Transaction::failed_status_code; |
|
1848 | + } else if ($abandoned) { |
|
1849 | 1849 | $_where['STS_ID'] = EEM_Transaction::abandoned_status_code; |
1850 | 1850 | } else { |
1851 | - $_where['STS_ID'] = array( '!=', EEM_Transaction::failed_status_code ); |
|
1852 | - $_where['STS_ID*'] = array( '!=', EEM_Transaction::abandoned_status_code ); |
|
1851 | + $_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code); |
|
1852 | + $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code); |
|
1853 | 1853 | } |
1854 | 1854 | |
1855 | - $query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'limit' => $limit ); |
|
1855 | + $query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit); |
|
1856 | 1856 | |
1857 | - $transactions = $count ? $TXN->count( array($_where), 'TXN_ID', TRUE ) : $TXN->get_all($query_params); |
|
1857 | + $transactions = $count ? $TXN->count(array($_where), 'TXN_ID', TRUE) : $TXN->get_all($query_params); |
|
1858 | 1858 | |
1859 | 1859 | |
1860 | 1860 | return $transactions; |
@@ -245,13 +245,13 @@ discard block |
||
245 | 245 | 'persistent' => FALSE |
246 | 246 | ), |
247 | 247 | 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
248 | - 'help_tabs' => array( |
|
248 | + 'help_tabs' => array( |
|
249 | 249 | 'registration_form_add_question_help_tab' => array( |
250 | 250 | 'title' => esc_html__('Add Question', 'event_espresso'), |
251 | 251 | 'filename' => 'registration_form_add_question' |
252 | 252 | ), |
253 | 253 | ), |
254 | - 'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'), |
|
254 | + 'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'), |
|
255 | 255 | 'require_nonce' => FALSE |
256 | 256 | ), |
257 | 257 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | 'filename' => 'registration_form_add_question_group' |
269 | 269 | ), |
270 | 270 | ), |
271 | - 'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'), |
|
271 | + 'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'), |
|
272 | 272 | 'require_nonce' => FALSE |
273 | 273 | ), |
274 | 274 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | 'filename' => 'registration_form_edit_question_group' |
287 | 287 | ), |
288 | 288 | ), |
289 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'), |
|
289 | + 'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'), |
|
290 | 290 | 'require_nonce' => FALSE |
291 | 291 | ), |
292 | 292 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | 'filename' => 'registration_form_reg_form_settings' |
306 | 306 | ), |
307 | 307 | ), |
308 | - 'help_tour' => array( 'Registration_Form_Settings_Help_Tour'), |
|
308 | + 'help_tour' => array( 'Registration_Form_Settings_Help_Tour'), |
|
309 | 309 | 'require_nonce' => FALSE |
310 | 310 | ) |
311 | 311 | |
@@ -430,11 +430,11 @@ discard block |
||
430 | 430 | |
431 | 431 | protected function _questions_overview_list_table() { |
432 | 432 | $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
433 | - 'add_question', |
|
434 | - 'add_question', |
|
435 | - array(), |
|
436 | - 'add-new-h2' |
|
437 | - ); |
|
433 | + 'add_question', |
|
434 | + 'add_question', |
|
435 | + array(), |
|
436 | + 'add-new-h2' |
|
437 | + ); |
|
438 | 438 | parent::_questions_overview_list_table(); |
439 | 439 | } |
440 | 440 | |
@@ -443,11 +443,11 @@ discard block |
||
443 | 443 | protected function _question_groups_overview_list_table() { |
444 | 444 | $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
445 | 445 | $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
446 | - 'add_question_group', |
|
447 | - 'add_question_group', |
|
448 | - array(), |
|
449 | - 'add-new-h2' |
|
450 | - ); |
|
446 | + 'add_question_group', |
|
447 | + 'add_question_group', |
|
448 | + array(), |
|
449 | + 'add-new-h2' |
|
450 | + ); |
|
451 | 451 | $this->display_admin_list_table_page_with_sidebar(); |
452 | 452 | } |
453 | 453 | |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | * @return EE_Form_Section_Proper |
944 | 944 | */ |
945 | 945 | protected function _email_validation_settings_form() { |
946 | - return new EE_Form_Section_Proper( |
|
946 | + return new EE_Form_Section_Proper( |
|
947 | 947 | array( |
948 | 948 | 'name' => 'email_validation_settings', |
949 | 949 | 'html_id' => 'email_validation_settings', |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | ), |
962 | 962 | array( |
963 | 963 | 'html_label_text' => esc_html__( 'Email Validation Level', 'event_espresso' ) |
964 | - . EEH_Template::get_help_tab_link( 'email_validation_info' ), |
|
964 | + . EEH_Template::get_help_tab_link( 'email_validation_info' ), |
|
965 | 965 | 'html_help_text' => esc_html__( 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', 'event_espresso'), |
966 | 966 | 'default' => isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
967 | 967 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
@@ -983,8 +983,8 @@ discard block |
||
983 | 983 | * @return \EE_Registration_Config |
984 | 984 | */ |
985 | 985 | public function update_email_validation_settings_form( EE_Registration_Config $EE_Registration_Config ) { |
986 | - $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
987 | - try { |
|
986 | + $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
987 | + try { |
|
988 | 988 | $email_validation_settings_form = $this->_email_validation_settings_form(); |
989 | 989 | // if not displaying a form, then check for form submission |
990 | 990 | if ( $email_validation_settings_form->was_submitted() ) { |
@@ -995,38 +995,38 @@ discard block |
||
995 | 995 | // grab validated data from form |
996 | 996 | $valid_data = $email_validation_settings_form->valid_data(); |
997 | 997 | if ( isset( $valid_data['email_validation_level'] ) ) { |
998 | - $email_validation_level = $valid_data['email_validation_level']; |
|
999 | - // now if they want to use international email addresses |
|
1000 | - if ( $email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns' ) { |
|
1001 | - // in case we need to reset their email validation level, |
|
1002 | - // make sure that the previous value wasn't already set to one of the i18n options. |
|
1003 | - if ( $prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns' ) { |
|
1004 | - // if so, then reset it back to "basic" since that is the only other option that, |
|
1005 | - // despite offering poor validation, supports i18n email addresses |
|
1006 | - $prev_email_validation_level = 'basic'; |
|
1007 | - } |
|
1008 | - // confirm our i18n email validation will work on the server |
|
1009 | - if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1010 | - // or reset email validation level to previous value |
|
1011 | - $email_validation_level = $prev_email_validation_level; |
|
1012 | - } |
|
1013 | - } |
|
1014 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1015 | - } else { |
|
998 | + $email_validation_level = $valid_data['email_validation_level']; |
|
999 | + // now if they want to use international email addresses |
|
1000 | + if ( $email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns' ) { |
|
1001 | + // in case we need to reset their email validation level, |
|
1002 | + // make sure that the previous value wasn't already set to one of the i18n options. |
|
1003 | + if ( $prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns' ) { |
|
1004 | + // if so, then reset it back to "basic" since that is the only other option that, |
|
1005 | + // despite offering poor validation, supports i18n email addresses |
|
1006 | + $prev_email_validation_level = 'basic'; |
|
1007 | + } |
|
1008 | + // confirm our i18n email validation will work on the server |
|
1009 | + if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1010 | + // or reset email validation level to previous value |
|
1011 | + $email_validation_level = $prev_email_validation_level; |
|
1012 | + } |
|
1013 | + } |
|
1014 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1015 | + } else { |
|
1016 | 1016 | EE_Error::add_error( |
1017 | 1017 | esc_html__( |
1018 | 1018 | 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
1019 | 1019 | 'event_espresso' |
1020 | 1020 | ), |
1021 | - __FILE__, __FUNCTION__, __LINE__ |
|
1022 | - ); |
|
1021 | + __FILE__, __FUNCTION__, __LINE__ |
|
1022 | + ); |
|
1023 | 1023 | } |
1024 | 1024 | } else { |
1025 | 1025 | if ( $email_validation_settings_form->submission_error_message() !== '' ) { |
1026 | 1026 | EE_Error::add_error( |
1027 | 1027 | $email_validation_settings_form->submission_error_message(), |
1028 | - __FILE__, __FUNCTION__, __LINE__ |
|
1029 | - ); |
|
1028 | + __FILE__, __FUNCTION__, __LINE__ |
|
1029 | + ); |
|
1030 | 1030 | } |
1031 | 1031 | } |
1032 | 1032 | } |
@@ -1038,61 +1038,61 @@ discard block |
||
1038 | 1038 | |
1039 | 1039 | |
1040 | 1040 | |
1041 | - /** |
|
1042 | - * confirms that the server's PHP version has the PCRE module enabled, |
|
1043 | - * and that the PCRE version works with our i18n email validation |
|
1044 | - * |
|
1045 | - * @param \EE_Registration_Config $EE_Registration_Config |
|
1046 | - * @param string $email_validation_level |
|
1047 | - * @return bool |
|
1048 | - */ |
|
1049 | - private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1050 | - { |
|
1051 | - // first check that PCRE is enabled |
|
1052 | - if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
1053 | - EE_Error::add_error( |
|
1054 | - sprintf( |
|
1055 | - esc_html__( |
|
1056 | - 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1057 | - 'event_espresso' |
|
1058 | - ), |
|
1059 | - '<br />' |
|
1060 | - ), |
|
1061 | - __FILE__, |
|
1062 | - __FUNCTION__, |
|
1063 | - __LINE__ |
|
1064 | - ); |
|
1065 | - return false; |
|
1066 | - } else { |
|
1067 | - // PCRE support is enabled, but let's still |
|
1068 | - // perform a test to see if the server will support it. |
|
1069 | - // but first, save the updated validation level to the config, |
|
1070 | - // so that the validation strategy picks it up. |
|
1071 | - // this will get bumped back down if it doesn't work |
|
1072 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1073 | - try { |
|
1074 | - $email_validator = new EE_Email_Validation_Strategy(); |
|
1075 | - $i18n_email_address = apply_filters( |
|
1076 | - 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1077 | - 'jägerjü[email protected]' |
|
1078 | - ); |
|
1079 | - $email_validator->validate($i18n_email_address); |
|
1080 | - } catch (Exception $e) { |
|
1081 | - EE_Error::add_error( |
|
1082 | - sprintf( |
|
1083 | - esc_html__( |
|
1084 | - 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1085 | - 'event_espresso' |
|
1086 | - ), |
|
1087 | - '<br />', |
|
1088 | - '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>' |
|
1089 | - ), |
|
1090 | - __FILE__, __FUNCTION__, __LINE__ |
|
1091 | - ); |
|
1092 | - return false; |
|
1093 | - } |
|
1094 | - } |
|
1095 | - return true; |
|
1096 | - } |
|
1041 | + /** |
|
1042 | + * confirms that the server's PHP version has the PCRE module enabled, |
|
1043 | + * and that the PCRE version works with our i18n email validation |
|
1044 | + * |
|
1045 | + * @param \EE_Registration_Config $EE_Registration_Config |
|
1046 | + * @param string $email_validation_level |
|
1047 | + * @return bool |
|
1048 | + */ |
|
1049 | + private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1050 | + { |
|
1051 | + // first check that PCRE is enabled |
|
1052 | + if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
1053 | + EE_Error::add_error( |
|
1054 | + sprintf( |
|
1055 | + esc_html__( |
|
1056 | + 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1057 | + 'event_espresso' |
|
1058 | + ), |
|
1059 | + '<br />' |
|
1060 | + ), |
|
1061 | + __FILE__, |
|
1062 | + __FUNCTION__, |
|
1063 | + __LINE__ |
|
1064 | + ); |
|
1065 | + return false; |
|
1066 | + } else { |
|
1067 | + // PCRE support is enabled, but let's still |
|
1068 | + // perform a test to see if the server will support it. |
|
1069 | + // but first, save the updated validation level to the config, |
|
1070 | + // so that the validation strategy picks it up. |
|
1071 | + // this will get bumped back down if it doesn't work |
|
1072 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1073 | + try { |
|
1074 | + $email_validator = new EE_Email_Validation_Strategy(); |
|
1075 | + $i18n_email_address = apply_filters( |
|
1076 | + 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1077 | + 'jägerjü[email protected]' |
|
1078 | + ); |
|
1079 | + $email_validator->validate($i18n_email_address); |
|
1080 | + } catch (Exception $e) { |
|
1081 | + EE_Error::add_error( |
|
1082 | + sprintf( |
|
1083 | + esc_html__( |
|
1084 | + 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1085 | + 'event_espresso' |
|
1086 | + ), |
|
1087 | + '<br />', |
|
1088 | + '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>' |
|
1089 | + ), |
|
1090 | + __FILE__, __FUNCTION__, __LINE__ |
|
1091 | + ); |
|
1092 | + return false; |
|
1093 | + } |
|
1094 | + } |
|
1095 | + return true; |
|
1096 | + } |
|
1097 | 1097 | |
1098 | 1098 | } |
@@ -1,5 +1,5 @@ discard block |
||
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 | /** |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
37 | 37 | * @access public |
38 | 38 | */ |
39 | - public function __construct( $routing = TRUE ) { |
|
40 | - define( 'REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS ); |
|
41 | - define( 'REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS ); |
|
42 | - define( 'REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/' ); |
|
43 | - define( 'REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS ); |
|
44 | - define( 'REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/' ); |
|
45 | - parent::__construct( $routing ); |
|
39 | + public function __construct($routing = TRUE) { |
|
40 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form'.DS); |
|
41 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets'.DS); |
|
42 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/'); |
|
43 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates'.DS); |
|
44 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/'); |
|
45 | + parent::__construct($routing); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | |
53 | 53 | protected function _extend_page_config() { |
54 | 54 | $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
55 | - $qst_id = ! empty( $this->_req_data['QST_ID'] ) && ! is_array( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0; |
|
56 | - $qsg_id = ! empty( $this->_req_data['QSG_ID'] ) && ! is_array( $this->_req_data['QSG_ID'] ) ? $this->_req_data['QSG_ID'] : 0; |
|
55 | + $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
56 | + $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0; |
|
57 | 57 | |
58 | 58 | $new_page_routes = array( |
59 | 59 | 'question_groups' => array( |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | 'func' => '_trash_or_restore_questions', |
87 | 87 | 'capability' => 'ee_delete_question', |
88 | 88 | 'obj_id' => $qst_id, |
89 | - 'args' => array( 'trash' => FALSE ), |
|
89 | + 'args' => array('trash' => FALSE), |
|
90 | 90 | 'noheader' => TRUE |
91 | 91 | ), |
92 | 92 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | 'trash_question_group' => array( |
147 | 147 | 'func' => '_trash_or_restore_question_groups', |
148 | - 'args' => array( 'trash' => TRUE ), |
|
148 | + 'args' => array('trash' => TRUE), |
|
149 | 149 | 'capability' => 'ee_delete_question_group', |
150 | 150 | 'obj_id' => $qsg_id, |
151 | 151 | 'noheader' => TRUE |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | 'restore_question_group' => array( |
155 | 155 | 'func' => '_trash_or_restore_question_groups', |
156 | - 'args' => array( 'trash' => FALSE ), |
|
156 | + 'args' => array('trash' => FALSE), |
|
157 | 157 | 'capability' => 'ee_delete_question_group', |
158 | 158 | 'obj_id' => $qsg_id, |
159 | 159 | 'noheader' => TRUE |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | 'update_question_group' => array( |
170 | 170 | 'func' => '_insert_or_update_question_group', |
171 | - 'args' => array('new_question_group' => FALSE ), |
|
171 | + 'args' => array('new_question_group' => FALSE), |
|
172 | 172 | 'capability' => 'ee_edit_question_group', |
173 | 173 | 'obj_id' => $qsg_id, |
174 | 174 | 'noheader' => TRUE, |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | 'noheader' => TRUE |
207 | 207 | ), |
208 | 208 | ); |
209 | - $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
|
209 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
210 | 210 | |
211 | 211 | $new_page_config = array( |
212 | 212 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | 'filename' => 'registration_form_question_groups_views_bulk_actions_search' |
231 | 231 | ), |
232 | 232 | ), |
233 | - 'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'), |
|
233 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
234 | 234 | 'metaboxes' => $this->_default_espresso_metaboxes, |
235 | 235 | 'require_nonce' => FALSE, |
236 | 236 | 'qtips' => array( |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | 'order' => 5, |
245 | 245 | 'persistent' => FALSE |
246 | 246 | ), |
247 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
247 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
248 | 248 | 'help_tabs' => array( |
249 | 249 | 'registration_form_add_question_help_tab' => array( |
250 | 250 | 'title' => esc_html__('Add Question', 'event_espresso'), |
251 | 251 | 'filename' => 'registration_form_add_question' |
252 | 252 | ), |
253 | 253 | ), |
254 | - 'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'), |
|
254 | + 'help_tour' => array('Registration_Form_Add_Question_Help_Tour'), |
|
255 | 255 | 'require_nonce' => FALSE |
256 | 256 | ), |
257 | 257 | |
@@ -261,14 +261,14 @@ discard block |
||
261 | 261 | 'order' => 5, |
262 | 262 | 'persistent' => FALSE |
263 | 263 | ), |
264 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
264 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
265 | 265 | 'help_tabs' => array( |
266 | 266 | 'registration_form_add_question_group_help_tab' => array( |
267 | 267 | 'title' => esc_html__('Add Question Group', 'event_espresso'), |
268 | 268 | 'filename' => 'registration_form_add_question_group' |
269 | 269 | ), |
270 | 270 | ), |
271 | - 'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'), |
|
271 | + 'help_tour' => array('Registration_Form_Add_Question_Group_Help_Tour'), |
|
272 | 272 | 'require_nonce' => FALSE |
273 | 273 | ), |
274 | 274 | |
@@ -277,16 +277,16 @@ discard block |
||
277 | 277 | 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
278 | 278 | 'order' => 5, |
279 | 279 | 'persistent' => FALSE, |
280 | - '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 |
|
280 | + '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 |
|
281 | 281 | ), |
282 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
282 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
283 | 283 | 'help_tabs' => array( |
284 | 284 | 'registration_form_edit_question_group_help_tab' => array( |
285 | 285 | 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
286 | 286 | 'filename' => 'registration_form_edit_question_group' |
287 | 287 | ), |
288 | 288 | ), |
289 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'), |
|
289 | + 'help_tour' => array('Registration_Form_Edit_Question_Group_Help_Tour'), |
|
290 | 290 | 'require_nonce' => FALSE |
291 | 291 | ), |
292 | 292 | |
@@ -298,19 +298,19 @@ discard block |
||
298 | 298 | 'labels' => array( |
299 | 299 | 'publishbox' => esc_html__('Update Settings', 'event_espresso') |
300 | 300 | ), |
301 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
301 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
302 | 302 | 'help_tabs' => array( |
303 | 303 | 'registration_form_reg_form_settings_help_tab' => array( |
304 | 304 | 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
305 | 305 | 'filename' => 'registration_form_reg_form_settings' |
306 | 306 | ), |
307 | 307 | ), |
308 | - 'help_tour' => array( 'Registration_Form_Settings_Help_Tour'), |
|
308 | + 'help_tour' => array('Registration_Form_Settings_Help_Tour'), |
|
309 | 309 | 'require_nonce' => FALSE |
310 | 310 | ) |
311 | 311 | |
312 | 312 | ); |
313 | - $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
|
313 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
314 | 314 | |
315 | 315 | //change the list table we're going to use so it's the NEW list table! |
316 | 316 | $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
325 | 325 | 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
326 | 326 | ); |
327 | - $this->_labels['buttons'] = array_merge( $this->_labels['buttons'], $new_labels ); |
|
327 | + $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
328 | 328 | |
329 | 329 | } |
330 | 330 | |
@@ -333,14 +333,14 @@ discard block |
||
333 | 333 | |
334 | 334 | |
335 | 335 | protected function _ajax_hooks() { |
336 | - add_action('wp_ajax_espresso_update_question_group_order', array( $this, 'update_question_group_order' )); |
|
336 | + add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
340 | 340 | |
341 | 341 | |
342 | 342 | public function load_scripts_styles_question_groups() { |
343 | - wp_enqueue_script( 'espresso_ajax_table_sorting' ); |
|
343 | + wp_enqueue_script('espresso_ajax_table_sorting'); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @return void |
362 | 362 | */ |
363 | 363 | public function load_sortable_question_script() { |
364 | - wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
364 | + wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
365 | 365 | wp_enqueue_script('ee-question-sortable'); |
366 | 366 | } |
367 | 367 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | ) |
381 | 381 | ); |
382 | 382 | |
383 | - if ( EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) { |
|
383 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) { |
|
384 | 384 | $this->_views['trash'] = array( |
385 | 385 | 'slug' => 'trash', |
386 | 386 | 'label' => esc_html__('Trash', 'event_espresso'), |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | ) |
411 | 411 | ); |
412 | 412 | |
413 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_question_groups', 'espresso_registration_form_trash_question_groups' ) ) { |
|
413 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups', 'espresso_registration_form_trash_question_groups')) { |
|
414 | 414 | $this->_views['trash'] = array( |
415 | 415 | 'slug' => 'trash', |
416 | 416 | 'label' => esc_html__('Trash', 'event_espresso'), |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | |
430 | 430 | |
431 | 431 | protected function _questions_overview_list_table() { |
432 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
432 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
433 | 433 | 'add_question', |
434 | 434 | 'add_question', |
435 | 435 | array(), |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | |
443 | 443 | protected function _question_groups_overview_list_table() { |
444 | 444 | $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
445 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
445 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
446 | 446 | 'add_question_group', |
447 | 447 | 'add_question_group', |
448 | 448 | array(), |
@@ -456,24 +456,24 @@ discard block |
||
456 | 456 | |
457 | 457 | |
458 | 458 | |
459 | - protected function _delete_question(){ |
|
460 | - $success = $this->_delete_items( $this->_question_model ); |
|
459 | + protected function _delete_question() { |
|
460 | + $success = $this->_delete_items($this->_question_model); |
|
461 | 461 | $this->_redirect_after_action( |
462 | 462 | $success, |
463 | - $this->_question_model->item_name( $success ), |
|
463 | + $this->_question_model->item_name($success), |
|
464 | 464 | 'deleted', |
465 | - array( 'action' => 'default', 'status' => 'all' ) |
|
465 | + array('action' => 'default', 'status' => 'all') |
|
466 | 466 | ); |
467 | 467 | } |
468 | 468 | |
469 | 469 | |
470 | 470 | protected function _delete_questions() { |
471 | - $success = $this->_delete_items( $this->_question_model ); |
|
471 | + $success = $this->_delete_items($this->_question_model); |
|
472 | 472 | $this->_redirect_after_action( |
473 | 473 | $success, |
474 | - $this->_question_model->item_name( $success ), |
|
474 | + $this->_question_model->item_name($success), |
|
475 | 475 | 'deleted permanently', |
476 | - array( 'action' => 'default', 'status' => 'trash' ) |
|
476 | + array('action' => 'default', 'status' => 'trash') |
|
477 | 477 | ); |
478 | 478 | } |
479 | 479 | |
@@ -484,26 +484,26 @@ discard block |
||
484 | 484 | * @param EEM_Soft_Delete_Base $model |
485 | 485 | * @return int number of items deleted permanently |
486 | 486 | */ |
487 | - private function _delete_items(EEM_Soft_Delete_Base $model){ |
|
487 | + private function _delete_items(EEM_Soft_Delete_Base $model) { |
|
488 | 488 | $success = 0; |
489 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
490 | - if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
489 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
490 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
491 | 491 | // if array has more than one element than success message should be plural |
492 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
492 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
493 | 493 | // cycle thru bulk action checkboxes |
494 | - while (list( $ID, $value ) = each($this->_req_data['checkbox'])) { |
|
495 | - if ( ! $this->_delete_item( $ID, $model ) ) { |
|
494 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
495 | + if ( ! $this->_delete_item($ID, $model)) { |
|
496 | 496 | $success = 0; |
497 | 497 | } |
498 | 498 | } |
499 | 499 | |
500 | - }elseif( !empty($this->_req_data['QSG_ID'])){ |
|
501 | - $success = $this->_delete_item( $this->_req_data['QSG_ID'], $model ); |
|
500 | + }elseif ( ! empty($this->_req_data['QSG_ID'])) { |
|
501 | + $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
502 | 502 | |
503 | - }elseif( !empty($this->_req_data['QST_ID'])){ |
|
504 | - $success = $this->_delete_item( $this->_req_data['QST_ID'], $model ); |
|
505 | - }else{ |
|
506 | - EE_Error::add_error( sprintf(esc_html__("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__ ); |
|
503 | + }elseif ( ! empty($this->_req_data['QST_ID'])) { |
|
504 | + $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
505 | + } else { |
|
506 | + EE_Error::add_error(sprintf(esc_html__("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__); |
|
507 | 507 | } |
508 | 508 | return $success; |
509 | 509 | } |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | * @param EEM_Soft_Delete_Base $model |
515 | 515 | * @return boolean |
516 | 516 | */ |
517 | - protected function _delete_item( $id, $model ) { |
|
518 | - if( $model instanceof EEM_Question ) { |
|
519 | - EEM_Question_Option::instance()->delete_permanently( array( array( 'QST_ID' => absint( $id ) ) ) ); |
|
517 | + protected function _delete_item($id, $model) { |
|
518 | + if ($model instanceof EEM_Question) { |
|
519 | + EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
520 | 520 | } |
521 | - return $model->delete_permanently_by_ID( absint( $id ) ); |
|
521 | + return $model->delete_permanently_by_ID(absint($id)); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | |
@@ -530,41 +530,41 @@ discard block |
||
530 | 530 | |
531 | 531 | |
532 | 532 | |
533 | - protected function _edit_question_group( $type = 'add' ) { |
|
534 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
535 | - $ID=isset( $this->_req_data['QSG_ID'] ) && ! empty( $this->_req_data['QSG_ID'] ) ? absint( $this->_req_data['QSG_ID'] ) : FALSE; |
|
533 | + protected function _edit_question_group($type = 'add') { |
|
534 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
535 | + $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) ? absint($this->_req_data['QSG_ID']) : FALSE; |
|
536 | 536 | |
537 | - switch( $this->_req_action ) { |
|
537 | + switch ($this->_req_action) { |
|
538 | 538 | case 'add_question_group' : |
539 | - $this->_admin_page_title = esc_html__( 'Add Question Group', 'event_espresso' ); |
|
539 | + $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
540 | 540 | break; |
541 | 541 | case 'edit_question_group' : |
542 | - $this->_admin_page_title = esc_html__( 'Edit Question Group', 'event_espresso' ); |
|
542 | + $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
543 | 543 | break; |
544 | 544 | default : |
545 | - $this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action )); |
|
545 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
546 | 546 | } |
547 | 547 | // add ID to title if editing |
548 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
549 | - if($ID){ |
|
548 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
549 | + if ($ID) { |
|
550 | 550 | /** @var EE_Question_Group $questionGroup */ |
551 | - $questionGroup=$this->_question_group_model->get_one_by_ID( $ID); |
|
552 | - $additional_hidden_fields=array('QSG_ID'=>array('type'=>'hidden','value'=>$ID)); |
|
551 | + $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
552 | + $additional_hidden_fields = array('QSG_ID'=>array('type'=>'hidden', 'value'=>$ID)); |
|
553 | 553 | $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
554 | - }else{ |
|
554 | + } else { |
|
555 | 555 | /** @var EE_Question_Group $questionGroup */ |
556 | 556 | $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
557 | 557 | $questionGroup->set_order_to_latest(); |
558 | 558 | $this->_set_add_edit_form_tags('insert_question_group'); |
559 | 559 | } |
560 | 560 | $this->_template_args['values'] = $this->_yes_no_values; |
561 | - $this->_template_args['all_questions']=$questionGroup->questions_in_and_not_in_group(); |
|
562 | - $this->_template_args['QSG_ID']=$ID ? $ID : TRUE; |
|
563 | - $this->_template_args['question_group']=$questionGroup; |
|
561 | + $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
562 | + $this->_template_args['QSG_ID'] = $ID ? $ID : TRUE; |
|
563 | + $this->_template_args['question_group'] = $questionGroup; |
|
564 | 564 | |
565 | - $redirect_URL = add_query_arg( array( 'action' => 'question_groups'), $this->_admin_base_url ); |
|
566 | - $this->_set_publish_post_box_vars( 'id', $ID, FALSE, $redirect_URL ); |
|
567 | - $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 ); |
|
565 | + $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
566 | + $this->_set_publish_post_box_vars('id', $ID, FALSE, $redirect_URL); |
|
567 | + $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); |
|
568 | 568 | |
569 | 569 | // the details template wrapper |
570 | 570 | $this->display_admin_page_with_sidebar(); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | |
576 | 576 | protected function _delete_question_groups() { |
577 | 577 | $success = $this->_delete_items($this->_question_group_model); |
578 | - $this->_redirect_after_action( $success, $this->_question_group_model->item_name($success), 'deleted permanently', array( 'action'=>'question_groups', 'status'=>'trash' )); |
|
578 | + $this->_redirect_after_action($success, $this->_question_group_model->item_name($success), 'deleted permanently', array('action'=>'question_groups', 'status'=>'trash')); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -583,71 +583,71 @@ discard block |
||
583 | 583 | /** |
584 | 584 | * @param bool $new_question_group |
585 | 585 | */ |
586 | - protected function _insert_or_update_question_group( $new_question_group = TRUE) { |
|
587 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
588 | - $set_column_values=$this->_set_column_values_for($this->_question_group_model); |
|
589 | - if ( $new_question_group ){ |
|
586 | + protected function _insert_or_update_question_group($new_question_group = TRUE) { |
|
587 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
588 | + $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
589 | + if ($new_question_group) { |
|
590 | 590 | $QSG_ID = $this->_question_group_model->insert($set_column_values); |
591 | 591 | $success = $QSG_ID ? 1 : 0; |
592 | 592 | } else { |
593 | 593 | $QSG_ID = absint($this->_req_data['QSG_ID']); |
594 | - unset( $set_column_values[ 'QSG_ID' ] ); |
|
595 | - $success= $this->_question_group_model->update( $set_column_values, array( array( 'QSG_ID' => $QSG_ID ))); |
|
594 | + unset($set_column_values['QSG_ID']); |
|
595 | + $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
596 | 596 | } |
597 | - $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( EEM_Attendee::system_question_phone ); |
|
597 | + $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone); |
|
598 | 598 | // update the existing related questions |
599 | 599 | // 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) |
600 | - if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ] )) { |
|
600 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) { |
|
601 | 601 | // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
602 | - EEM_Question_Group_Question::instance()->delete( array( array( 'QST_ID' => $phone_question_id, 'QSG_ID' => array( '!=', $QSG_ID )))); |
|
602 | + EEM_Question_Group_Question::instance()->delete(array(array('QST_ID' => $phone_question_id, 'QSG_ID' => array('!=', $QSG_ID)))); |
|
603 | 603 | } |
604 | 604 | /** @type EE_Question_Group $question_group */ |
605 | - $question_group=$this->_question_group_model->get_one_by_ID( $QSG_ID ); |
|
605 | + $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
606 | 606 | $questions = $question_group->questions(); |
607 | 607 | // make sure system phone question is added to list of questions for this group |
608 | - if ( ! isset( $questions[$phone_question_id ] )) { |
|
609 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID( $phone_question_id ); |
|
608 | + if ( ! isset($questions[$phone_question_id])) { |
|
609 | + $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
610 | 610 | } |
611 | 611 | |
612 | - foreach( $questions as $question_ID => $question ){ |
|
612 | + foreach ($questions as $question_ID => $question) { |
|
613 | 613 | // first we always check for order. |
614 | - if ( ! empty( $this->_req_data['question_orders'][ $question_ID ] ) ){ |
|
614 | + if ( ! empty($this->_req_data['question_orders'][$question_ID])) { |
|
615 | 615 | //update question order |
616 | - $question_group->update_question_order( $question_ID, $this->_req_data['question_orders'][ $question_ID ] ); |
|
616 | + $question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | // then we always check if adding or removing. |
620 | - if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ] )) { |
|
621 | - $question_group->add_question( $question_ID ); |
|
620 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) { |
|
621 | + $question_group->add_question($question_ID); |
|
622 | 622 | } else { |
623 | 623 | // 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) |
624 | 624 | if ( |
625 | 625 | in_array( |
626 | 626 | $question->system_ID(), |
627 | - EEM_Question::instance()->required_system_questions_in_system_question_group( $question_group->system_group() ) |
|
627 | + EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group()) |
|
628 | 628 | ) |
629 | 629 | ) { |
630 | 630 | continue; |
631 | 631 | } else { |
632 | - $question_group->remove_question( $question_ID ); |
|
632 | + $question_group->remove_question($question_ID); |
|
633 | 633 | } |
634 | 634 | } |
635 | 635 | } |
636 | 636 | // save new related questions |
637 | - if ( isset( $this->_req_data['questions'] )) { |
|
638 | - foreach( $this->_req_data['questions'] as $QST_ID ){ |
|
639 | - $question_group->add_question( $QST_ID ); |
|
640 | - if ( isset( $this->_req_data['question_orders'][ $QST_ID ] )) { |
|
641 | - $question_group->update_question_order( $QST_ID, $this->_req_data['question_orders'][ $QST_ID ] ); |
|
637 | + if (isset($this->_req_data['questions'])) { |
|
638 | + foreach ($this->_req_data['questions'] as $QST_ID) { |
|
639 | + $question_group->add_question($QST_ID); |
|
640 | + if (isset($this->_req_data['question_orders'][$QST_ID])) { |
|
641 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]); |
|
642 | 642 | } |
643 | 643 | } |
644 | 644 | } |
645 | 645 | |
646 | - if ( $success !== FALSE ) { |
|
647 | - $msg = $new_question_group ? sprintf( esc_html__('The %s has been created', 'event_espresso'), $this->_question_group_model->item_name() ) : sprintf( esc_html__('The %s has been updated', 'event_espresso' ), $this->_question_group_model->item_name() ); |
|
648 | - EE_Error::add_success( $msg ); |
|
646 | + if ($success !== FALSE) { |
|
647 | + $msg = $new_question_group ? sprintf(esc_html__('The %s has been created', 'event_espresso'), $this->_question_group_model->item_name()) : sprintf(esc_html__('The %s has been updated', 'event_espresso'), $this->_question_group_model->item_name()); |
|
648 | + EE_Error::add_success($msg); |
|
649 | 649 | } |
650 | - $this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group','QSG_ID'=>$QSG_ID), TRUE); |
|
650 | + $this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group', 'QSG_ID'=>$QSG_ID), TRUE); |
|
651 | 651 | |
652 | 652 | } |
653 | 653 | |
@@ -655,20 +655,20 @@ discard block |
||
655 | 655 | * duplicates a question and all its question options and redirects to the new question. |
656 | 656 | */ |
657 | 657 | public function _duplicate_question() { |
658 | - $question_ID = (int)$this->_req_data[ 'QST_ID' ]; |
|
659 | - $question = EEM_Question::instance()->get_one_by_ID( $question_ID ); |
|
660 | - if( $question instanceof EE_Question ) { |
|
658 | + $question_ID = (int) $this->_req_data['QST_ID']; |
|
659 | + $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
660 | + if ($question instanceof EE_Question) { |
|
661 | 661 | $new_question = $question->duplicate(); |
662 | - if( $new_question instanceof EE_Question ) { |
|
663 | - $this->_redirect_after_action( true, esc_html__( 'Question', 'event_espresso' ), esc_html__( 'Duplicated', 'event_espresso' ), array('action'=>'edit_question', 'QST_ID' => $new_question->ID() ), TRUE); |
|
662 | + if ($new_question instanceof EE_Question) { |
|
663 | + $this->_redirect_after_action(true, esc_html__('Question', 'event_espresso'), esc_html__('Duplicated', 'event_espresso'), array('action'=>'edit_question', 'QST_ID' => $new_question->ID()), TRUE); |
|
664 | 664 | } else { |
665 | 665 | global $wpdb; |
666 | - EE_Error::add_error( sprintf( esc_html__( 'Could not duplicate question with ID %1$d because: %2$s', 'event_espresso' ), $question_ID, $wpdb->last_error ), __FILE__, __FUNCTION__, __LINE__ ); |
|
667 | - $this->_redirect_after_action(false, '', '', array('action'=>'default'), false ); |
|
666 | + EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %1$d because: %2$s', 'event_espresso'), $question_ID, $wpdb->last_error), __FILE__, __FUNCTION__, __LINE__); |
|
667 | + $this->_redirect_after_action(false, '', '', array('action'=>'default'), false); |
|
668 | 668 | } |
669 | 669 | } else { |
670 | - EE_Error::add_error( sprintf( esc_html__( 'Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso' ), $question_ID ), __FILE__, __FUNCTION__, __LINE__ ); |
|
671 | - $this->_redirect_after_action( false, '', '', array( 'action' => 'default' ), false ); |
|
670 | + EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__); |
|
671 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
672 | 672 | } |
673 | 673 | } |
674 | 674 | |
@@ -677,8 +677,8 @@ discard block |
||
677 | 677 | /** |
678 | 678 | * @param bool $trash |
679 | 679 | */ |
680 | - protected function _trash_or_restore_question_groups( $trash = TRUE) { |
|
681 | - $this->_trash_or_restore_items( $this->_question_group_model, $trash ); |
|
680 | + protected function _trash_or_restore_question_groups($trash = TRUE) { |
|
681 | + $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | |
@@ -686,9 +686,9 @@ discard block |
||
686 | 686 | /** |
687 | 687 | *_trash_question |
688 | 688 | */ |
689 | - protected function _trash_question(){ |
|
690 | - $success=$this->_question_model->delete_by_ID( (int)$this->_req_data['QST_ID'] ); |
|
691 | - $query_args=array('action'=>'default','status'=>'all'); |
|
689 | + protected function _trash_question() { |
|
690 | + $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
691 | + $query_args = array('action'=>'default', 'status'=>'all'); |
|
692 | 692 | $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
693 | 693 | } |
694 | 694 | |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | /** |
698 | 698 | * @param bool $trash |
699 | 699 | */ |
700 | - protected function _trash_or_restore_questions( $trash=TRUE){ |
|
701 | - $this->_trash_or_restore_items( $this->_question_model, $trash ); |
|
700 | + protected function _trash_or_restore_questions($trash = TRUE) { |
|
701 | + $this->_trash_or_restore_items($this->_question_model, $trash); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | |
@@ -710,21 +710,21 @@ discard block |
||
710 | 710 | *@param EEM_Soft_Delete_Base $model |
711 | 711 | * @param boolean $trash whether to trash or restore |
712 | 712 | */ |
713 | - private function _trash_or_restore_items( EEM_Soft_Delete_Base $model, $trash = TRUE ) { |
|
713 | + private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = TRUE) { |
|
714 | 714 | |
715 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
715 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
716 | 716 | |
717 | 717 | $success = 1; |
718 | 718 | //Checkboxes |
719 | 719 | //echo "trash $trash"; |
720 | 720 | //var_dump($this->_req_data['checkbox']);die; |
721 | - if ( isset( $this->_req_data['checkbox'] )) { |
|
722 | - if ( ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] )) { |
|
721 | + if (isset($this->_req_data['checkbox'])) { |
|
722 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
723 | 723 | // if array has more than one element than success message should be plural |
724 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
724 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
725 | 725 | // cycle thru bulk action checkboxes |
726 | - while (list( $ID, $value ) = each($this->_req_data['checkbox'])) { |
|
727 | - if ( ! $model->delete_or_restore_by_ID($trash,absint($ID))) { |
|
726 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
727 | + if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
728 | 728 | $success = 0; |
729 | 729 | } |
730 | 730 | } |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | } else { |
733 | 733 | // grab single id and delete |
734 | 734 | $ID = absint($this->_req_data['checkbox']); |
735 | - if ( ! $model->delete_or_restore_by_ID($trash,$ID)) { |
|
735 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
736 | 736 | $success = 0; |
737 | 737 | } |
738 | 738 | } |
@@ -740,25 +740,25 @@ discard block |
||
740 | 740 | } else { |
741 | 741 | // delete via trash link |
742 | 742 | // grab single id and delete |
743 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
744 | - if ( ! $model->delete_or_restore_by_ID($trash,$ID)) { |
|
743 | + $ID = absint($this->_req_data[$model->primary_key_name()]); |
|
744 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
745 | 745 | $success = 0; |
746 | 746 | } |
747 | 747 | |
748 | 748 | } |
749 | 749 | |
750 | 750 | |
751 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) ); |
|
751 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; //strtolower( $model->item_name(2) ); |
|
752 | 752 | //echo "action :$action"; |
753 | 753 | //$action = 'questions' ? 'default' : $action; |
754 | - if($trash){ |
|
754 | + if ($trash) { |
|
755 | 755 | $action_desc = 'trashed'; |
756 | 756 | $status = 'trash'; |
757 | - }else{ |
|
757 | + } else { |
|
758 | 758 | $action_desc = 'restored'; |
759 | 759 | $status = 'all'; |
760 | 760 | } |
761 | - $this->_redirect_after_action( $success, $model->item_name($success), $action_desc, array( 'action' => $action, 'status'=>$status ) ); |
|
761 | + $this->_redirect_after_action($success, $model->item_name($success), $action_desc, array('action' => $action, 'status'=>$status)); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | |
@@ -769,16 +769,16 @@ discard block |
||
769 | 769 | * @param bool|false $count |
770 | 770 | * @return \EE_Soft_Delete_Base_Class[]|int |
771 | 771 | */ |
772 | - public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) { |
|
772 | + public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) { |
|
773 | 773 | $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
774 | 774 | |
775 | - if( $count ){ |
|
775 | + if ($count) { |
|
776 | 776 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
777 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
778 | - $results=$this->_question_model->count_deleted($where); |
|
779 | - }else{ |
|
777 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
778 | + $results = $this->_question_model->count_deleted($where); |
|
779 | + } else { |
|
780 | 780 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
781 | - $results=$this->_question_model->get_all_deleted($query_params); |
|
781 | + $results = $this->_question_model->get_all_deleted($query_params); |
|
782 | 782 | } |
783 | 783 | return $results; |
784 | 784 | } |
@@ -791,13 +791,13 @@ discard block |
||
791 | 791 | * @param bool|false $count |
792 | 792 | * @return \EE_Soft_Delete_Base_Class[] |
793 | 793 | */ |
794 | - public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
795 | - $questionGroupModel=EEM_Question_Group::instance(); |
|
796 | - $query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page); |
|
797 | - if ($count){ |
|
798 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
794 | + public function get_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
795 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
796 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
797 | + if ($count) { |
|
798 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
799 | 799 | $results = $questionGroupModel->count($where); |
800 | - }else{ |
|
800 | + } else { |
|
801 | 801 | $results = $questionGroupModel->get_all($query_params); |
802 | 802 | } |
803 | 803 | return $results; |
@@ -811,14 +811,14 @@ discard block |
||
811 | 811 | * @param bool $count |
812 | 812 | * @return \EE_Soft_Delete_Base_Class[]|int |
813 | 813 | */ |
814 | - public function get_trashed_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
815 | - $questionGroupModel=EEM_Question_Group::instance(); |
|
816 | - $query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page); |
|
817 | - if($count){ |
|
818 | - $where = isset( $query_params[0] ) ? array($query_params[0]) : array(); |
|
814 | + public function get_trashed_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
815 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
816 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
817 | + if ($count) { |
|
818 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
819 | 819 | $query_params['limit'] = NULL; |
820 | 820 | $results = $questionGroupModel->count_deleted($where); |
821 | - }else{ |
|
821 | + } else { |
|
822 | 822 | $results = $questionGroupModel->get_all_deleted($query_params); |
823 | 823 | } |
824 | 824 | return $results; |
@@ -831,32 +831,32 @@ discard block |
||
831 | 831 | */ |
832 | 832 | public function update_question_group_order() { |
833 | 833 | |
834 | - $success = esc_html__( 'Question group order was updated successfully.', 'event_espresso' ); |
|
834 | + $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
835 | 835 | |
836 | 836 | // grab our row IDs |
837 | - $row_ids = isset( $this->_req_data['row_ids'] ) && ! empty( $this->_req_data['row_ids'] ) |
|
838 | - ? explode( ',', rtrim( $this->_req_data['row_ids'], ',' )) |
|
837 | + $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
838 | + ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
839 | 839 | : array(); |
840 | 840 | |
841 | - $perpage = !empty( $this->_req_data['perpage'] ) |
|
841 | + $perpage = ! empty($this->_req_data['perpage']) |
|
842 | 842 | ? (int) $this->_req_data['perpage'] |
843 | 843 | : NULL; |
844 | - $curpage = !empty( $this->_req_data['curpage'] ) |
|
844 | + $curpage = ! empty($this->_req_data['curpage']) |
|
845 | 845 | ? (int) $this->_req_data['curpage'] |
846 | 846 | : NULL; |
847 | 847 | |
848 | - if ( ! empty( $row_ids ) ) { |
|
848 | + if ( ! empty($row_ids)) { |
|
849 | 849 | //figure out where we start the row_id count at for the current page. |
850 | - $qsgcount = empty( $curpage ) ? 0 : ($curpage - 1 ) * $perpage; |
|
850 | + $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
851 | 851 | |
852 | - $row_count = count( $row_ids ); |
|
853 | - for( $i = 0; $i < $row_count; $i++ ) { |
|
852 | + $row_count = count($row_ids); |
|
853 | + for ($i = 0; $i < $row_count; $i++) { |
|
854 | 854 | //Update the questions when re-ordering |
855 | 855 | $updated = EEM_Question_Group::instance()->update( |
856 | - array( 'QSG_order' => $qsgcount ), |
|
857 | - array( array( 'QSG_ID' => $row_ids[ $i ] ) ) |
|
856 | + array('QSG_order' => $qsgcount), |
|
857 | + array(array('QSG_ID' => $row_ids[$i])) |
|
858 | 858 | ); |
859 | - if ( $updated === false ) { |
|
859 | + if ($updated === false) { |
|
860 | 860 | $success = false; |
861 | 861 | } |
862 | 862 | $qsgcount++; |
@@ -866,10 +866,10 @@ discard block |
||
866 | 866 | } |
867 | 867 | |
868 | 868 | $errors = ! $success |
869 | - ? esc_html__( 'An error occurred. The question group order was not updated.', 'event_espresso' ) |
|
869 | + ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
870 | 870 | : false; |
871 | 871 | |
872 | - echo json_encode( array( 'return_data' => false, 'success' => $success, 'errors' => $errors )); |
|
872 | + echo json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
873 | 873 | die(); |
874 | 874 | |
875 | 875 | } |
@@ -888,17 +888,17 @@ discard block |
||
888 | 888 | $this->_template_args['values'] = $this->_yes_no_values; |
889 | 889 | add_action( |
890 | 890 | 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
891 | - array( $this, 'email_validation_settings_form' ), |
|
891 | + array($this, 'email_validation_settings_form'), |
|
892 | 892 | 2 |
893 | 893 | ); |
894 | - $this->_template_args = (array)apply_filters( |
|
894 | + $this->_template_args = (array) apply_filters( |
|
895 | 895 | 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
896 | 896 | $this->_template_args |
897 | 897 | ); |
898 | - $this->_set_add_edit_form_tags( 'update_reg_form_settings' ); |
|
899 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
898 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
899 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
900 | 900 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
901 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
901 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php', |
|
902 | 902 | $this->_template_args, |
903 | 903 | TRUE |
904 | 904 | ); |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | EE_Registry::instance()->CFG, |
920 | 920 | __FILE__, __FUNCTION__, __LINE__ |
921 | 921 | ); |
922 | - $this->_redirect_after_action( $success, esc_html__('Registration Form Options', 'event_espresso'), 'updated', array( 'action' => 'view_reg_form_settings' ) ); |
|
922 | + $this->_redirect_after_action($success, esc_html__('Registration Form Options', 'event_espresso'), 'updated', array('action' => 'view_reg_form_settings')); |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | |
@@ -950,20 +950,20 @@ discard block |
||
950 | 950 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
951 | 951 | 'subsections' => array( |
952 | 952 | 'email_validation_hdr' => new EE_Form_Section_HTML( |
953 | - EEH_HTML::h2( esc_html__( 'Email Validation Settings', 'event_espresso' ) ) |
|
953 | + EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
954 | 954 | ), |
955 | 955 | 'email_validation_level' => new EE_Select_Input( |
956 | 956 | array( |
957 | - 'basic' => esc_html__( 'Basic', 'event_espresso' ), |
|
958 | - 'wp_default' => esc_html__( 'WordPress Default', 'event_espresso' ), |
|
959 | - 'i18n' => esc_html__( 'International', 'event_espresso' ), |
|
960 | - 'i18n_dns' => esc_html__( 'International + DNS Check', 'event_espresso' ), |
|
957 | + 'basic' => esc_html__('Basic', 'event_espresso'), |
|
958 | + 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
959 | + 'i18n' => esc_html__('International', 'event_espresso'), |
|
960 | + 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
961 | 961 | ), |
962 | 962 | array( |
963 | - 'html_label_text' => esc_html__( 'Email Validation Level', 'event_espresso' ) |
|
964 | - . EEH_Template::get_help_tab_link( 'email_validation_info' ), |
|
965 | - 'html_help_text' => esc_html__( 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', 'event_espresso'), |
|
966 | - 'default' => isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
963 | + 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
964 | + . EEH_Template::get_help_tab_link('email_validation_info'), |
|
965 | + 'html_help_text' => esc_html__('These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', 'event_espresso'), |
|
966 | + 'default' => isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
967 | 967 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
968 | 968 | : 'wp_default', |
969 | 969 | 'required' => false |
@@ -982,25 +982,25 @@ discard block |
||
982 | 982 | * @param \EE_Registration_Config $EE_Registration_Config |
983 | 983 | * @return \EE_Registration_Config |
984 | 984 | */ |
985 | - public function update_email_validation_settings_form( EE_Registration_Config $EE_Registration_Config ) { |
|
985 | + public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) { |
|
986 | 986 | $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
987 | 987 | try { |
988 | 988 | $email_validation_settings_form = $this->_email_validation_settings_form(); |
989 | 989 | // if not displaying a form, then check for form submission |
990 | - if ( $email_validation_settings_form->was_submitted() ) { |
|
990 | + if ($email_validation_settings_form->was_submitted()) { |
|
991 | 991 | // capture form data |
992 | 992 | $email_validation_settings_form->receive_form_submission(); |
993 | 993 | // validate form data |
994 | - if ( $email_validation_settings_form->is_valid() ) { |
|
994 | + if ($email_validation_settings_form->is_valid()) { |
|
995 | 995 | // grab validated data from form |
996 | 996 | $valid_data = $email_validation_settings_form->valid_data(); |
997 | - if ( isset( $valid_data['email_validation_level'] ) ) { |
|
997 | + if (isset($valid_data['email_validation_level'])) { |
|
998 | 998 | $email_validation_level = $valid_data['email_validation_level']; |
999 | 999 | // now if they want to use international email addresses |
1000 | - if ( $email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns' ) { |
|
1000 | + if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1001 | 1001 | // in case we need to reset their email validation level, |
1002 | 1002 | // make sure that the previous value wasn't already set to one of the i18n options. |
1003 | - if ( $prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns' ) { |
|
1003 | + if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
1004 | 1004 | // if so, then reset it back to "basic" since that is the only other option that, |
1005 | 1005 | // despite offering poor validation, supports i18n email addresses |
1006 | 1006 | $prev_email_validation_level = 'basic'; |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | ); |
1023 | 1023 | } |
1024 | 1024 | } else { |
1025 | - if ( $email_validation_settings_form->submission_error_message() !== '' ) { |
|
1025 | + if ($email_validation_settings_form->submission_error_message() !== '') { |
|
1026 | 1026 | EE_Error::add_error( |
1027 | 1027 | $email_validation_settings_form->submission_error_message(), |
1028 | 1028 | __FILE__, __FUNCTION__, __LINE__ |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | } |
1031 | 1031 | } |
1032 | 1032 | } |
1033 | - } catch ( EE_Error $e ) { |
|
1033 | + } catch (EE_Error $e) { |
|
1034 | 1034 | $e->get_error(); |
1035 | 1035 | } |
1036 | 1036 | return $EE_Registration_Config; |
@@ -1,5 +1,5 @@ discard block |
||
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 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $this->_cpt_edit_routes = array( |
67 | 67 | 'espresso_events' => 'edit' |
68 | 68 | ); |
69 | - add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) ); |
|
69 | + add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit')); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | protected function _ajax_hooks() { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | 'edit' => esc_html__('Update Event', 'event_espresso'), |
93 | 93 | 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
94 | 94 | 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
95 | - 'template_settings' => esc_html__( 'Update Settings', 'event_espresso' ) |
|
95 | + 'template_settings' => esc_html__('Update Settings', 'event_espresso') |
|
96 | 96 | ) |
97 | 97 | ); |
98 | 98 | } |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | //load field generator helper |
103 | 103 | |
104 | 104 | //is there a evt_id in the request? |
105 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
106 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
105 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
106 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
107 | 107 | |
108 | 108 | |
109 | 109 | $this->_page_routes = array( |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | 'help_tour' => array( |
318 | 318 | 'Event_Editor_Help_Tour' |
319 | 319 | ), |
320 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
320 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
321 | 321 | 'require_nonce' => FALSE |
322 | 322 | ), |
323 | 323 | 'edit' => array( |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | /*'help_tour' => array( |
374 | 374 | 'Event_Edit_Help_Tour' |
375 | 375 | ),*/ |
376 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
376 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
377 | 377 | 'require_nonce' => FALSE |
378 | 378 | ), |
379 | 379 | 'default_event_settings' => array( |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | 'filename' => 'events_default_settings_status' |
396 | 396 | ) |
397 | 397 | ), |
398 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour'), |
|
398 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
399 | 399 | 'require_nonce' => FALSE |
400 | 400 | ), |
401 | 401 | //template settings |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | 'filename' => 'general_settings_templates' |
412 | 412 | ) |
413 | 413 | ), |
414 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
414 | + 'help_tour' => array('Templates_Help_Tour'), |
|
415 | 415 | 'require_nonce' => FALSE |
416 | 416 | ), |
417 | 417 | //event category stuff |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | 'label' => esc_html__('Edit Category', 'event_espresso'), |
436 | 436 | 'order' => 15, |
437 | 437 | 'persistent' => FALSE, |
438 | - '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 |
|
438 | + '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 |
|
439 | 439 | ), |
440 | 440 | 'help_tabs' => array( |
441 | 441 | 'edit_category_help_tab' => array( |
@@ -505,14 +505,14 @@ discard block |
||
505 | 505 | |
506 | 506 | public function load_scripts_styles() { |
507 | 507 | |
508 | - wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
509 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
508 | + wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
509 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
510 | 510 | wp_enqueue_style('events-admin-css'); |
511 | 511 | wp_enqueue_style('ee-cat-admin'); |
512 | 512 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
513 | 513 | //registers for all views |
514 | 514 | //scripts |
515 | - 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); |
|
515 | + 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); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | public function load_scripts_styles_edit() { |
531 | 531 | //styles |
532 | 532 | wp_enqueue_style('espresso-ui-theme'); |
533 | - wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
533 | + wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
534 | 534 | wp_enqueue_style('event-editor-css'); |
535 | 535 | |
536 | 536 | //scripts |
537 | - wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION ); |
|
537 | + wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION); |
|
538 | 538 | wp_enqueue_script('event-datetime-metabox'); |
539 | 539 | |
540 | 540 | } |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | |
570 | 570 | |
571 | 571 | public function admin_init() { |
572 | - EE_Registry::$i18n_js_strings[ 'image_confirm' ] = esc_html__( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ); |
|
572 | + EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | |
@@ -590,12 +590,12 @@ discard block |
||
590 | 590 | */ |
591 | 591 | public function verify_event_edit($event = NULL) { |
592 | 592 | // no event? |
593 | - if ( empty( $event )) { |
|
593 | + if (empty($event)) { |
|
594 | 594 | // set event |
595 | 595 | $event = $this->_cpt_model_obj; |
596 | 596 | } |
597 | 597 | // STILL no event? |
598 | - if ( empty ( $event )) { |
|
598 | + if (empty ($event)) { |
|
599 | 599 | return; |
600 | 600 | } |
601 | 601 | $orig_status = $event->status(); |
@@ -609,27 +609,27 @@ discard block |
||
609 | 609 | return; |
610 | 610 | } |
611 | 611 | //made it here so it IS active... next check that any of the tickets are sold. |
612 | - if ( $event->is_sold_out( true ) ) { |
|
613 | - if ( $orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status ) { |
|
612 | + if ($event->is_sold_out(true)) { |
|
613 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
614 | 614 | EE_Error::add_attention( |
615 | 615 | sprintf( |
616 | - esc_html__( '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' ), |
|
617 | - EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' ) |
|
616 | + esc_html__('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'), |
|
617 | + EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence') |
|
618 | 618 | ) |
619 | 619 | ); |
620 | 620 | } |
621 | 621 | return; |
622 | - } else if ( $orig_status === EEM_Event::sold_out ) { |
|
622 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
623 | 623 | EE_Error::add_attention( |
624 | 624 | sprintf( |
625 | - esc_html__( '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.', |
|
626 | - 'event_espresso' ), |
|
627 | - EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
|
625 | + esc_html__('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.', |
|
626 | + 'event_espresso'), |
|
627 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
628 | 628 | ) |
629 | 629 | ); |
630 | 630 | } |
631 | 631 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
632 | - if ( ! $event->tickets_on_sale() ) { |
|
632 | + if ( ! $event->tickets_on_sale()) { |
|
633 | 633 | return; |
634 | 634 | } |
635 | 635 | //made it here so show warning |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | */ |
649 | 649 | protected function _edit_event_warning() { |
650 | 650 | // we don't want to add warnings during these requests |
651 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] === 'editpost' ) { |
|
651 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
652 | 652 | return; |
653 | 653 | } |
654 | 654 | EE_Error::add_attention( |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | ), |
680 | 680 | ); |
681 | 681 | |
682 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
682 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
683 | 683 | $this->_views['trash'] = array( |
684 | 684 | 'slug' => 'trash', |
685 | 685 | 'label' => esc_html__('Trash', 'event_espresso'), |
@@ -709,39 +709,39 @@ discard block |
||
709 | 709 | 'desc' => esc_html__('View Registrations for Event', 'event_espresso') |
710 | 710 | ) |
711 | 711 | ); |
712 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
712 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
713 | 713 | $statuses = array( |
714 | 714 | 'sold_out_status' => array( |
715 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
716 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' ) |
|
715 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
716 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence') |
|
717 | 717 | ), |
718 | 718 | 'active_status' => array( |
719 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
720 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' ) |
|
719 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
720 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence') |
|
721 | 721 | ), |
722 | 722 | 'upcoming_status' => array( |
723 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
724 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' ) |
|
723 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
724 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence') |
|
725 | 725 | ), |
726 | 726 | 'postponed_status' => array( |
727 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
728 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' ) |
|
727 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
728 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence') |
|
729 | 729 | ), |
730 | 730 | 'cancelled_status' => array( |
731 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
732 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' ) |
|
731 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
732 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence') |
|
733 | 733 | ), |
734 | 734 | 'expired_status' => array( |
735 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
736 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' ) |
|
735 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
736 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence') |
|
737 | 737 | ), |
738 | 738 | 'inactive_status' => array( |
739 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
740 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' ) |
|
739 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
740 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence') |
|
741 | 741 | ) |
742 | 742 | ); |
743 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
744 | - return array_merge( $items, $statuses ); |
|
743 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
744 | + return array_merge($items, $statuses); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | |
@@ -753,8 +753,8 @@ discard block |
||
753 | 753 | * @return EEM_Event |
754 | 754 | */ |
755 | 755 | private function _event_model() { |
756 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
757 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
756 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
757 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
758 | 758 | } |
759 | 759 | return $this->_event_model; |
760 | 760 | } |
@@ -773,12 +773,12 @@ discard block |
||
773 | 773 | * @param string $new_slug what the slug is |
774 | 774 | * @return string The new html string for the permalink area |
775 | 775 | */ |
776 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
776 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
777 | 777 | //make sure this is only when editing |
778 | - if ( !empty( $id ) ) { |
|
779 | - $post = get_post( $id ); |
|
780 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' . esc_html__('Shortcode', 'event_espresso') . '</a> '; |
|
781 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' . $post->ID . ']">'; |
|
778 | + if ( ! empty($id)) { |
|
779 | + $post = get_post($id); |
|
780 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">'.esc_html__('Shortcode', 'event_espresso').'</a> '; |
|
781 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='.$post->ID.']">'; |
|
782 | 782 | } |
783 | 783 | return $return; |
784 | 784 | } |
@@ -794,10 +794,10 @@ discard block |
||
794 | 794 | * @return string html for generated table |
795 | 795 | */ |
796 | 796 | protected function _events_overview_list_table() { |
797 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
798 | - $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), esc_html__("View Event Archive Page", "event_espresso"), 'button' ) . |
|
797 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
798 | + $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), esc_html__("View Event Archive Page", "event_espresso"), 'button'). |
|
799 | 799 | $this->_display_legend($this->_event_legend_items()); |
800 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
|
800 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
|
801 | 801 | $this->display_admin_list_table_page_with_no_sidebar(); |
802 | 802 | } |
803 | 803 | |
@@ -813,51 +813,51 @@ discard block |
||
813 | 813 | |
814 | 814 | |
815 | 815 | |
816 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
816 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
817 | 817 | |
818 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
818 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
819 | 819 | //getout we're not processing an event save. |
820 | 820 | return; |
821 | 821 | } |
822 | 822 | |
823 | 823 | $event_values = array( |
824 | - 'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
825 | - 'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
824 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
825 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
826 | 826 | 'EVT_additional_limit' => min( |
827 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
828 | - !empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ), |
|
829 | - '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, |
|
830 | - 'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
831 | - 'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
832 | - 'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL, |
|
833 | - 'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL, |
|
834 | - 'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL |
|
827 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
828 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ), |
|
829 | + '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, |
|
830 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
831 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
832 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL, |
|
833 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL, |
|
834 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL |
|
835 | 835 | ); |
836 | 836 | |
837 | 837 | //update event |
838 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
838 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
839 | 839 | |
840 | 840 | |
841 | 841 | //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! |
842 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
843 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
842 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
843 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
844 | 844 | |
845 | 845 | |
846 | 846 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
847 | - $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') ) ); |
|
847 | + $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'))); |
|
848 | 848 | |
849 | 849 | $att_success = TRUE; |
850 | 850 | |
851 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
852 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
853 | - $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
851 | + foreach ($event_update_callbacks as $e_callback) { |
|
852 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
853 | + $att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | //any errors? |
857 | - if ( $success && FALSE === $att_success ) { |
|
858 | - EE_Error::add_error( esc_html__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
859 | - } else if ( $success === FALSE ) { |
|
860 | - EE_Error::add_error( esc_html__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
857 | + if ($success && FALSE === $att_success) { |
|
858 | + EE_Error::add_error(esc_html__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
859 | + } else if ($success === FALSE) { |
|
860 | + EE_Error::add_error(esc_html__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | |
@@ -867,14 +867,14 @@ discard block |
||
867 | 867 | /** |
868 | 868 | * @see parent::restore_item() |
869 | 869 | */ |
870 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
870 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
871 | 871 | //copy existing event meta to new post |
872 | 872 | $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
873 | - if ( $post_evt instanceof EE_Event ) { |
|
873 | + if ($post_evt instanceof EE_Event) { |
|
874 | 874 | //meta revision restore |
875 | - $post_evt->restore_revision( $revision_id ); |
|
875 | + $post_evt->restore_revision($revision_id); |
|
876 | 876 | //related objs restore |
877 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
877 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | |
@@ -887,52 +887,52 @@ discard block |
||
887 | 887 | * @param array $data The request data from the form |
888 | 888 | * @return bool Success or fail. |
889 | 889 | */ |
890 | - protected function _default_venue_update( $evtobj, $data ) { |
|
891 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
890 | + protected function _default_venue_update($evtobj, $data) { |
|
891 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
892 | 892 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
893 | 893 | $rows_affected = NULL; |
894 | - $venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL; |
|
894 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL; |
|
895 | 895 | |
896 | 896 | // very important. If we don't have a venue name... |
897 | 897 | // then we'll get out because not necessary to create empty venue |
898 | - if ( empty( $data['venue_title'] ) ) { |
|
898 | + if (empty($data['venue_title'])) { |
|
899 | 899 | return false; |
900 | 900 | } |
901 | 901 | |
902 | 902 | $venue_array = array( |
903 | 903 | 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
904 | - 'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL, |
|
905 | - 'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL, |
|
906 | - 'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL, |
|
907 | - 'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL, |
|
908 | - 'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL, |
|
909 | - 'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL, |
|
910 | - 'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL, |
|
911 | - 'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL, |
|
912 | - 'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL, |
|
913 | - 'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL, |
|
914 | - 'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL, |
|
915 | - 'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL, |
|
916 | - 'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL, |
|
917 | - 'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
918 | - 'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL, |
|
919 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
904 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL, |
|
905 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL, |
|
906 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL, |
|
907 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL, |
|
908 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL, |
|
909 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL, |
|
910 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL, |
|
911 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL, |
|
912 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL, |
|
913 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL, |
|
914 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL, |
|
915 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL, |
|
916 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL, |
|
917 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
918 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL, |
|
919 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
920 | 920 | 'status' => 'publish' |
921 | 921 | ); |
922 | 922 | |
923 | 923 | |
924 | 924 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
925 | - if ( !empty( $venue_id ) ) { |
|
926 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
927 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
925 | + if ( ! empty($venue_id)) { |
|
926 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
927 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
928 | 928 | //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. |
929 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
929 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
930 | 930 | return $rows_affected > 0 ? TRUE : FALSE; |
931 | 931 | } else { |
932 | 932 | //we insert the venue |
933 | - $venue_id = $venue_model->insert( $venue_array ); |
|
934 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
935 | - return !empty( $venue_id ) ? TRUE : FALSE; |
|
933 | + $venue_id = $venue_model->insert($venue_array); |
|
934 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
935 | + return ! empty($venue_id) ? TRUE : FALSE; |
|
936 | 936 | } |
937 | 937 | //when we have the ancestor come in it's already been handled by the revision save. |
938 | 938 | } |
@@ -946,54 +946,54 @@ discard block |
||
946 | 946 | * @param array $data The request data from the form |
947 | 947 | * @return bool success or fail |
948 | 948 | */ |
949 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
949 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
950 | 950 | $success = true; |
951 | 951 | $saved_dtt = null; |
952 | 952 | $saved_tickets = array(); |
953 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
953 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
954 | 954 | |
955 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
955 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
956 | 956 | //trim all values to ensure any excess whitespace is removed. |
957 | - $dtt = array_map( 'trim', $dtt ); |
|
958 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
957 | + $dtt = array_map('trim', $dtt); |
|
958 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
959 | 959 | $datetime_values = array( |
960 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
960 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
961 | 961 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
962 | 962 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
963 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
963 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
964 | 964 | 'DTT_order' => $row, |
965 | 965 | ); |
966 | 966 | |
967 | 967 | //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. |
968 | 968 | |
969 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
970 | - $DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
971 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
972 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
973 | - foreach ( $datetime_values as $field => $value ) { |
|
974 | - $DTM->set( $field, $value ); |
|
969 | + if ( ! empty($dtt['DTT_ID'])) { |
|
970 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']); |
|
971 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
972 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
973 | + foreach ($datetime_values as $field => $value) { |
|
974 | + $DTM->set($field, $value); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | //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. |
978 | 978 | $saved_dtts[$DTM->ID()] = $DTM; |
979 | 979 | } else { |
980 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE ); |
|
981 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
982 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
983 | - $DTM->set_timezone( $evtobj->get_timezone() ); |
|
984 | - foreach ( $datetime_values as $field => $value ) { |
|
985 | - $DTM->set( $field, $value ); |
|
980 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE); |
|
981 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
982 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
983 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
984 | + foreach ($datetime_values as $field => $value) { |
|
985 | + $DTM->set($field, $value); |
|
986 | 986 | } |
987 | 987 | } |
988 | 988 | $DTM->save(); |
989 | 989 | |
990 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
990 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
991 | 991 | |
992 | 992 | //load DTT helper |
993 | 993 | |
994 | 994 | //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. |
995 | - if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) { |
|
996 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') ); |
|
995 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
996 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
997 | 997 | $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
998 | 998 | $DTT->save(); |
999 | 999 | } |
@@ -1001,45 +1001,45 @@ discard block |
||
1001 | 1001 | //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. |
1002 | 1002 | $saved_dtt = $DTT; |
1003 | 1003 | |
1004 | - $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. |
|
1004 | + $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. |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | //no dtts get deleted so we don't do any of that logic here. |
1008 | 1008 | //update tickets next |
1009 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
1010 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
1011 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1009 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1010 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1011 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1012 | 1012 | $update_prices = false; |
1013 | - $ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1013 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1014 | 1014 | |
1015 | 1015 | // trim inputs to ensure any excess whitespace is removed. |
1016 | - $tkt = array_map( 'trim', $tkt ); |
|
1016 | + $tkt = array_map('trim', $tkt); |
|
1017 | 1017 | |
1018 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1018 | + if (empty($tkt['TKT_start_date'])) { |
|
1019 | 1019 | //let's use now in the set timezone. |
1020 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1021 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1020 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1021 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1024 | + if (empty($tkt['TKT_end_date'])) { |
|
1025 | 1025 | //use the start date of the first datetime |
1026 | 1026 | $dtt = $evtobj->first_datetime(); |
1027 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] ); |
|
1027 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]); |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | $TKT_values = array( |
1031 | - 'TKT_ID' => !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
1032 | - 'TTM_ID' => !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1033 | - 'TKT_name' => !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1034 | - 'TKT_description' => !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1031 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
1032 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1033 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1034 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1035 | 1035 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1036 | 1036 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1037 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1038 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ], |
|
1039 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1040 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1037 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1038 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1039 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1040 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1041 | 1041 | 'TKT_row' => $row, |
1042 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1042 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1043 | 1043 | 'TKT_price' => $ticket_price |
1044 | 1044 | ); |
1045 | 1045 | |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | |
1048 | 1048 | |
1049 | 1049 | //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. |
1050 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1050 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1051 | 1051 | $TKT_values['TKT_ID'] = 0; |
1052 | 1052 | $TKT_values['TKT_is_default'] = 0; |
1053 | 1053 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1058,58 +1058,58 @@ discard block |
||
1058 | 1058 | //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. |
1059 | 1059 | //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. |
1060 | 1060 | |
1061 | - if ( !empty( $tkt['TKT_ID'] ) ) { |
|
1062 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1063 | - if ( $TKT instanceof EE_Ticket ) { |
|
1064 | - $ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false; |
|
1061 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1062 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']); |
|
1063 | + if ($TKT instanceof EE_Ticket) { |
|
1064 | + $ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false; |
|
1065 | 1065 | //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. |
1066 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false; |
|
1067 | - $TKT->set_date_format( $incoming_date_formats[ 0 ] ); |
|
1068 | - $TKT->set_time_format( $incoming_date_formats[ 1 ] ); |
|
1066 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false; |
|
1067 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1068 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1069 | 1069 | //set new values |
1070 | - foreach ( $TKT_values as $field => $value ) { |
|
1071 | - if ( $field == 'TKT_qty' ) { |
|
1072 | - $TKT->set_qty( $value ); |
|
1070 | + foreach ($TKT_values as $field => $value) { |
|
1071 | + if ($field == 'TKT_qty') { |
|
1072 | + $TKT->set_qty($value); |
|
1073 | 1073 | } else { |
1074 | - $TKT->set( $field, $value ); |
|
1074 | + $TKT->set($field, $value); |
|
1075 | 1075 | } |
1076 | 1076 | } |
1077 | 1077 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1078 | - if ( $create_new_TKT ) { |
|
1078 | + if ($create_new_TKT) { |
|
1079 | 1079 | //archive the old ticket first |
1080 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1080 | + $TKT->set('TKT_deleted', 1); |
|
1081 | 1081 | $TKT->save(); |
1082 | 1082 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1083 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1083 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1084 | 1084 | //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. |
1085 | 1085 | $TKT = clone $TKT; |
1086 | - $TKT->set( 'TKT_ID', 0 ); |
|
1087 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1088 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1089 | - $TKT->set( 'TKT_sold', 0 ); |
|
1086 | + $TKT->set('TKT_ID', 0); |
|
1087 | + $TKT->set('TKT_deleted', 0); |
|
1088 | + $TKT->set('TKT_price', $ticket_price); |
|
1089 | + $TKT->set('TKT_sold', 0); |
|
1090 | 1090 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1091 | 1091 | $update_prices = true; |
1092 | 1092 | } |
1093 | 1093 | //make sure price is set if it hasn't been already |
1094 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1094 | + $TKT->set('TKT_price', $ticket_price); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | } else { |
1098 | 1098 | //no TKT_id so a new TKT |
1099 | 1099 | $TKT_values['TKT_price'] = $ticket_price; |
1100 | - $TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE ); |
|
1101 | - if ( $TKT instanceof EE_Ticket ) { |
|
1100 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE); |
|
1101 | + if ($TKT instanceof EE_Ticket) { |
|
1102 | 1102 | //need to reset values to properly account for the date formats |
1103 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1104 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1105 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1103 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1104 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1105 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1106 | 1106 | |
1107 | 1107 | //set new values |
1108 | - foreach ( $TKT_values as $field => $value ) { |
|
1109 | - if ( $field == 'TKT_qty' ) { |
|
1110 | - $TKT->set_qty( $value ); |
|
1108 | + foreach ($TKT_values as $field => $value) { |
|
1109 | + if ($field == 'TKT_qty') { |
|
1110 | + $TKT->set_qty($value); |
|
1111 | 1111 | } else { |
1112 | - $TKT->set( $field, $value ); |
|
1112 | + $TKT->set($field, $value); |
|
1113 | 1113 | } |
1114 | 1114 | } |
1115 | 1115 | |
@@ -1117,31 +1117,31 @@ discard block |
||
1117 | 1117 | } |
1118 | 1118 | } |
1119 | 1119 | // cap ticket qty by datetime reg limits |
1120 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1120 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1121 | 1121 | //update ticket. |
1122 | 1122 | $TKT->save(); |
1123 | 1123 | |
1124 | 1124 | //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. |
1125 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
1126 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
1125 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1126 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1127 | 1127 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
1128 | 1128 | $TKT->save(); |
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | //initially let's add the ticket to the dtt |
1132 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1132 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1133 | 1133 | |
1134 | 1134 | $saved_tickets[$TKT->ID()] = $TKT; |
1135 | 1135 | |
1136 | 1136 | //add prices to ticket |
1137 | - $this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices ); |
|
1137 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1138 | 1138 | } |
1139 | 1139 | //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. |
1140 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1141 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1140 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1141 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1142 | 1142 | |
1143 | - foreach ( $tickets_removed as $id ) { |
|
1144 | - $id = absint( $id ); |
|
1143 | + foreach ($tickets_removed as $id) { |
|
1144 | + $id = absint($id); |
|
1145 | 1145 | |
1146 | 1146 | //get the ticket for this id |
1147 | 1147 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | //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) |
1150 | 1150 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
1151 | 1151 | |
1152 | - foreach( $dtts as $dtt ) { |
|
1152 | + foreach ($dtts as $dtt) { |
|
1153 | 1153 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
1154 | 1154 | } |
1155 | 1155 | |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1161 | 1161 | $tkt_to_remove->delete_permanently(); |
1162 | 1162 | } |
1163 | - return array( $saved_dtt, $saved_tickets ); |
|
1163 | + return array($saved_dtt, $saved_tickets); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | |
@@ -1175,31 +1175,31 @@ discard block |
||
1175 | 1175 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1176 | 1176 | * @return void |
1177 | 1177 | */ |
1178 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) { |
|
1179 | - foreach ( $prices as $row => $prc ) { |
|
1178 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) { |
|
1179 | + foreach ($prices as $row => $prc) { |
|
1180 | 1180 | $PRC_values = array( |
1181 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
1182 | - 'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL, |
|
1183 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1184 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1185 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1181 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
1182 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL, |
|
1183 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1184 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1185 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1186 | 1186 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1187 | 1187 | 'PRC_order' => $row |
1188 | 1188 | ); |
1189 | 1189 | |
1190 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1190 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1191 | 1191 | $PRC_values['PRC_ID'] = 0; |
1192 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
1192 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
1193 | 1193 | } else { |
1194 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1194 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1195 | 1195 | //update this price with new values |
1196 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1197 | - $PRC->set( $field, $newprc ); |
|
1196 | + foreach ($PRC_values as $field => $newprc) { |
|
1197 | + $PRC->set($field, $newprc); |
|
1198 | 1198 | } |
1199 | 1199 | $PRC->save(); |
1200 | 1200 | } |
1201 | 1201 | |
1202 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1202 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1203 | 1203 | } |
1204 | 1204 | } |
1205 | 1205 | |
@@ -1237,9 +1237,9 @@ discard block |
||
1237 | 1237 | //load formatter helper |
1238 | 1238 | |
1239 | 1239 | //args for getting related registrations |
1240 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1241 | - $not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) ); |
|
1242 | - $pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) ); |
|
1240 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1241 | + $not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved)); |
|
1242 | + $pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment)); |
|
1243 | 1243 | |
1244 | 1244 | |
1245 | 1245 | // publish box |
@@ -1268,9 +1268,9 @@ discard block |
||
1268 | 1268 | ), |
1269 | 1269 | REG_ADMIN_URL |
1270 | 1270 | ), |
1271 | - 'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ), |
|
1272 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ), |
|
1273 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ), |
|
1271 | + 'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args), |
|
1272 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args), |
|
1273 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args), |
|
1274 | 1274 | 'misc_pub_section_class' => apply_filters( |
1275 | 1275 | 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
1276 | 1276 | 'misc-pub-section' |
@@ -1289,9 +1289,9 @@ discard block |
||
1289 | 1289 | 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
1290 | 1290 | $this->_cpt_model_obj |
1291 | 1291 | ); |
1292 | - $publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean(); |
|
1292 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1293 | 1293 | // load template |
1294 | - EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args ); |
|
1294 | + EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args); |
|
1295 | 1295 | } |
1296 | 1296 | |
1297 | 1297 | |
@@ -1323,16 +1323,16 @@ discard block |
||
1323 | 1323 | $this->verify_cpt_object(); |
1324 | 1324 | add_meta_box( |
1325 | 1325 | 'espresso_event_editor_tickets', |
1326 | - esc_html__( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1327 | - array( $this, 'ticket_metabox' ), |
|
1326 | + esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1327 | + array($this, 'ticket_metabox'), |
|
1328 | 1328 | $this->page_slug, |
1329 | 1329 | 'normal', |
1330 | 1330 | 'high' |
1331 | 1331 | ); |
1332 | 1332 | add_meta_box( |
1333 | 1333 | 'espresso_event_editor_event_options', |
1334 | - esc_html__( 'Event Registration Options', 'event_espresso' ), |
|
1335 | - array( $this, 'registration_options_meta_box' ), |
|
1334 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
1335 | + array($this, 'registration_options_meta_box'), |
|
1336 | 1336 | $this->page_slug, |
1337 | 1337 | 'side', |
1338 | 1338 | 'default' |
@@ -1362,36 +1362,36 @@ discard block |
||
1362 | 1362 | 'disabled' => '' |
1363 | 1363 | ); |
1364 | 1364 | |
1365 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL; |
|
1365 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL; |
|
1366 | 1366 | |
1367 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1367 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1368 | 1368 | |
1369 | 1369 | /** |
1370 | 1370 | * 1. Start with retrieving Datetimes |
1371 | 1371 | * 2. Fore each datetime get related tickets |
1372 | 1372 | * 3. For each ticket get related prices |
1373 | 1373 | */ |
1374 | - $times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id ); |
|
1374 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1375 | 1375 | /** @type EE_Datetime $first_datetime */ |
1376 | - $first_datetime = reset( $times ); |
|
1376 | + $first_datetime = reset($times); |
|
1377 | 1377 | //do we get related tickets? |
1378 | - if ( $first_datetime instanceof EE_Datetime |
|
1379 | - && $first_datetime->ID() !== 0 ) { |
|
1378 | + if ($first_datetime instanceof EE_Datetime |
|
1379 | + && $first_datetime->ID() !== 0) { |
|
1380 | 1380 | $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
1381 | 1381 | $template_args['time'] = $first_datetime; |
1382 | 1382 | $related_tickets = $first_datetime->tickets( |
1383 | 1383 | array( |
1384 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1384 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1385 | 1385 | 'default_where_conditions' => 'none' |
1386 | 1386 | ) |
1387 | 1387 | ); |
1388 | 1388 | |
1389 | - if ( !empty($related_tickets) ) { |
|
1389 | + if ( ! empty($related_tickets)) { |
|
1390 | 1390 | $template_args['total_ticket_rows'] = count($related_tickets); |
1391 | 1391 | $row = 0; |
1392 | - foreach ( $related_tickets as $ticket ) { |
|
1392 | + foreach ($related_tickets as $ticket) { |
|
1393 | 1393 | $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
1394 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row ); |
|
1394 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row); |
|
1395 | 1395 | |
1396 | 1396 | $row++; |
1397 | 1397 | } |
@@ -1399,13 +1399,13 @@ discard block |
||
1399 | 1399 | $template_args['total_ticket_rows'] = 1; |
1400 | 1400 | /** @type EE_Ticket $ticket */ |
1401 | 1401 | $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
1402 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1402 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1403 | 1403 | } |
1404 | 1404 | } else { |
1405 | 1405 | $template_args['time'] = $times[0]; |
1406 | 1406 | /** @type EE_Ticket $ticket */ |
1407 | 1407 | $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
1408 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1408 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1409 | 1409 | // NOTE: we're just sending the first default row |
1410 | 1410 | // (decaf can't manage default tickets so this should be sufficient); |
1411 | 1411 | } |
@@ -1414,8 +1414,8 @@ discard block |
||
1414 | 1414 | $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
1415 | 1415 | $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
1416 | 1416 | $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
1417 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE ); |
|
1418 | - $template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' ); |
|
1417 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE); |
|
1418 | + $template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'); |
|
1419 | 1419 | EEH_Template::display_template($template, $template_args); |
1420 | 1420 | } |
1421 | 1421 | |
@@ -1430,21 +1430,21 @@ discard block |
||
1430 | 1430 | * @param int $row |
1431 | 1431 | * @return string generated html for the ticket row. |
1432 | 1432 | */ |
1433 | - private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) { |
|
1433 | + private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) { |
|
1434 | 1434 | $template_args = array( |
1435 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1436 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '', |
|
1435 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1436 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '', |
|
1437 | 1437 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1438 | 1438 | 'TKT_ID' => $ticket->get('TKT_ID'), |
1439 | 1439 | 'TKT_name' => $ticket->get('TKT_name'), |
1440 | 1440 | 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
1441 | 1441 | 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
1442 | 1442 | 'TKT_is_default' => $ticket->get('TKT_is_default'), |
1443 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty','input'), |
|
1443 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1444 | 1444 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1445 | 1445 | 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
1446 | - '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', |
|
1447 | - 'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled' |
|
1446 | + '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', |
|
1447 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled' |
|
1448 | 1448 | ); |
1449 | 1449 | |
1450 | 1450 | $price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object(); |
@@ -1460,23 +1460,23 @@ discard block |
||
1460 | 1460 | |
1461 | 1461 | //make sure we have default start and end dates if skeleton |
1462 | 1462 | //handle rows that should NOT be empty |
1463 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1463 | + if (empty($template_args['TKT_start_date'])) { |
|
1464 | 1464 | //if empty then the start date will be now. |
1465 | 1465 | $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
1466 | 1466 | } |
1467 | 1467 | |
1468 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1468 | + if (empty($template_args['TKT_end_date'])) { |
|
1469 | 1469 | //get the earliest datetime (if present); |
1470 | - $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; |
|
1470 | + $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; |
|
1471 | 1471 | |
1472 | - if ( !empty( $earliest_dtt ) ) |
|
1472 | + if ( ! empty($earliest_dtt)) |
|
1473 | 1473 | $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
1474 | 1474 | else |
1475 | - $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1475 | + $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))); |
|
1476 | 1476 | } |
1477 | 1477 | |
1478 | - $template_args = array_merge( $template_args, $price_args ); |
|
1479 | - $template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1478 | + $template_args = array_merge($template_args, $price_args); |
|
1479 | + $template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1480 | 1480 | return EEH_Template::display_template($template, $template_args, TRUE); |
1481 | 1481 | } |
1482 | 1482 | |
@@ -1505,8 +1505,8 @@ discard block |
||
1505 | 1505 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
1506 | 1506 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
1507 | 1507 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
1508 | - $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 ); |
|
1509 | - $templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
1508 | + $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); |
|
1509 | + $templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
1510 | 1510 | EEH_Template::display_template($templatepath, $template_args); |
1511 | 1511 | } |
1512 | 1512 | |
@@ -1534,21 +1534,21 @@ discard block |
||
1534 | 1534 | $EEME = $this->_event_model(); |
1535 | 1535 | |
1536 | 1536 | $offset = ($current_page - 1) * $per_page; |
1537 | - $limit = $count ? NULL : $offset . ',' . $per_page; |
|
1537 | + $limit = $count ? NULL : $offset.','.$per_page; |
|
1538 | 1538 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1539 | 1539 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1540 | 1540 | |
1541 | 1541 | if (isset($this->_req_data['month_range'])) { |
1542 | 1542 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1543 | - $month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1544 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1543 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1544 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1545 | 1545 | } |
1546 | 1546 | |
1547 | 1547 | $where = array(); |
1548 | 1548 | |
1549 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
1549 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
1550 | 1550 | //determine what post_status our condition will have for the query. |
1551 | - switch ( $status ) { |
|
1551 | + switch ($status) { |
|
1552 | 1552 | case 'month' : |
1553 | 1553 | case 'today' : |
1554 | 1554 | case NULL : |
@@ -1556,7 +1556,7 @@ discard block |
||
1556 | 1556 | break; |
1557 | 1557 | |
1558 | 1558 | case 'draft' : |
1559 | - $where['status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1559 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1560 | 1560 | break; |
1561 | 1561 | |
1562 | 1562 | default : |
@@ -1564,43 +1564,43 @@ discard block |
||
1564 | 1564 | } |
1565 | 1565 | |
1566 | 1566 | //categories? |
1567 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1567 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1568 | 1568 | |
1569 | - if ( !empty ( $category ) ) { |
|
1569 | + if ( ! empty ($category)) { |
|
1570 | 1570 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1571 | 1571 | $where['Term_Taxonomy.term_id'] = $category; |
1572 | 1572 | } |
1573 | 1573 | |
1574 | 1574 | //date where conditions |
1575 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1575 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1576 | 1576 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1577 | - $DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) ); |
|
1578 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1579 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) ); |
|
1580 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) ); |
|
1577 | + $DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone())); |
|
1578 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1579 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1580 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1581 | 1581 | } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
1582 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1583 | - $start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) ); |
|
1584 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1585 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1586 | - } else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) { |
|
1587 | - $now = date( 'Y-m-01' ); |
|
1588 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1589 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1590 | - $end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1591 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1582 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1583 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1584 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1585 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1586 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1587 | + $now = date('Y-m-01'); |
|
1588 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1589 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1590 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1591 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1592 | 1592 | } |
1593 | 1593 | |
1594 | 1594 | |
1595 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1596 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1595 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1596 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1597 | 1597 | } else { |
1598 | - if ( ! isset( $where['status'] ) ) { |
|
1599 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1598 | + if ( ! isset($where['status'])) { |
|
1599 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1600 | 1600 | $where['OR'] = array( |
1601 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1601 | + 'status*restrict_private' => array('!=', 'private'), |
|
1602 | 1602 | 'AND' => array( |
1603 | - 'status*inclusive' => array( '=', 'private' ), |
|
1603 | + 'status*inclusive' => array('=', 'private'), |
|
1604 | 1604 | 'EVT_wp_user' => get_current_user_id() |
1605 | 1605 | ) |
1606 | 1606 | ); |
@@ -1608,16 +1608,16 @@ discard block |
||
1608 | 1608 | } |
1609 | 1609 | } |
1610 | 1610 | |
1611 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1612 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1611 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1612 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1613 | 1613 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1614 | 1614 | } |
1615 | 1615 | } |
1616 | 1616 | |
1617 | 1617 | |
1618 | 1618 | //search query handling |
1619 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1620 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1619 | + if (isset($this->_req_data['s'])) { |
|
1620 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1621 | 1621 | $where['OR'] = array( |
1622 | 1622 | 'EVT_name' => array('LIKE', $search_string), |
1623 | 1623 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1626,32 +1626,32 @@ discard block |
||
1626 | 1626 | } |
1627 | 1627 | |
1628 | 1628 | |
1629 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1630 | - $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 ); |
|
1629 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1630 | + $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); |
|
1631 | 1631 | |
1632 | 1632 | |
1633 | 1633 | //let's first check if we have special requests coming in. |
1634 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1635 | - switch ( $this->_req_data['active_status'] ) { |
|
1634 | + if (isset($this->_req_data['active_status'])) { |
|
1635 | + switch ($this->_req_data['active_status']) { |
|
1636 | 1636 | case 'upcoming' : |
1637 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1637 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1638 | 1638 | break; |
1639 | 1639 | |
1640 | 1640 | case 'expired' : |
1641 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1641 | + return $EEME->get_expired_events($query_params, $count); |
|
1642 | 1642 | break; |
1643 | 1643 | |
1644 | 1644 | case 'active' : |
1645 | - return $EEME->get_active_events( $query_params, $count ); |
|
1645 | + return $EEME->get_active_events($query_params, $count); |
|
1646 | 1646 | break; |
1647 | 1647 | |
1648 | 1648 | case 'inactive' : |
1649 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1649 | + return $EEME->get_inactive_events($query_params, $count); |
|
1650 | 1650 | break; |
1651 | 1651 | } |
1652 | 1652 | } |
1653 | 1653 | |
1654 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1654 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1655 | 1655 | |
1656 | 1656 | return $events; |
1657 | 1657 | } |
@@ -1660,23 +1660,23 @@ discard block |
||
1660 | 1660 | |
1661 | 1661 | |
1662 | 1662 | //handling for WordPress CPT actions (trash, restore, delete) |
1663 | - public function trash_cpt_item( $post_id ) { |
|
1663 | + public function trash_cpt_item($post_id) { |
|
1664 | 1664 | $this->_req_data['EVT_ID'] = $post_id; |
1665 | - $this->_trash_or_restore_event( 'trash', FALSE ); |
|
1665 | + $this->_trash_or_restore_event('trash', FALSE); |
|
1666 | 1666 | } |
1667 | 1667 | |
1668 | 1668 | |
1669 | 1669 | |
1670 | 1670 | |
1671 | - public function restore_cpt_item( $post_id ) { |
|
1671 | + public function restore_cpt_item($post_id) { |
|
1672 | 1672 | $this->_req_data['EVT_ID'] = $post_id; |
1673 | - $this->_trash_or_restore_event( 'draft', FALSE ); |
|
1673 | + $this->_trash_or_restore_event('draft', FALSE); |
|
1674 | 1674 | } |
1675 | 1675 | |
1676 | 1676 | |
1677 | - public function delete_cpt_item( $post_id ) { |
|
1677 | + public function delete_cpt_item($post_id) { |
|
1678 | 1678 | $this->_req_data['EVT_ID'] = $post_id; |
1679 | - $this->_delete_event( FALSE ); |
|
1679 | + $this->_delete_event(FALSE); |
|
1680 | 1680 | } |
1681 | 1681 | |
1682 | 1682 | |
@@ -1688,7 +1688,7 @@ discard block |
||
1688 | 1688 | * @param string $event_status |
1689 | 1689 | * @return void |
1690 | 1690 | */ |
1691 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) { |
|
1691 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) { |
|
1692 | 1692 | //determine the event id and set to array. |
1693 | 1693 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE; |
1694 | 1694 | // loop thru events |
@@ -1696,7 +1696,7 @@ discard block |
||
1696 | 1696 | // clean status |
1697 | 1697 | $event_status = sanitize_key($event_status); |
1698 | 1698 | // grab status |
1699 | - if (!empty($event_status)) { |
|
1699 | + if ( ! empty($event_status)) { |
|
1700 | 1700 | $success = $this->_change_event_status($EVT_ID, $event_status); |
1701 | 1701 | } else { |
1702 | 1702 | $success = FALSE; |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | } |
1711 | 1711 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1712 | 1712 | |
1713 | - if ( $redirect_after ) |
|
1713 | + if ($redirect_after) |
|
1714 | 1714 | $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
1715 | 1715 | } |
1716 | 1716 | |
@@ -1725,7 +1725,7 @@ discard block |
||
1725 | 1725 | // clean status |
1726 | 1726 | $event_status = sanitize_key($event_status); |
1727 | 1727 | // grab status |
1728 | - if (!empty($event_status)) { |
|
1728 | + if ( ! empty($event_status)) { |
|
1729 | 1729 | $success = TRUE; |
1730 | 1730 | //determine the event id and set to array. |
1731 | 1731 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | $results = $this->_change_event_status($EVT_ID, $event_status); |
1736 | 1736 | $success = $results !== FALSE ? $success : FALSE; |
1737 | 1737 | } else { |
1738 | - $msg = sprintf( esc_html__('An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', 'event_espresso'), $EVT_ID); |
|
1738 | + $msg = sprintf(esc_html__('An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', 'event_espresso'), $EVT_ID); |
|
1739 | 1739 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1740 | 1740 | $success = FALSE; |
1741 | 1741 | } |
@@ -1760,15 +1760,15 @@ discard block |
||
1760 | 1760 | * @param string $event_status |
1761 | 1761 | * @return bool |
1762 | 1762 | */ |
1763 | - private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
1763 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1764 | 1764 | // grab event id |
1765 | - if (!$EVT_ID) { |
|
1765 | + if ( ! $EVT_ID) { |
|
1766 | 1766 | $msg = esc_html__('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1767 | 1767 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1768 | 1768 | return FALSE; |
1769 | 1769 | } |
1770 | 1770 | |
1771 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1771 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1772 | 1772 | |
1773 | 1773 | // clean status |
1774 | 1774 | $event_status = sanitize_key($event_status); |
@@ -1794,11 +1794,11 @@ discard block |
||
1794 | 1794 | $hook = FALSE; |
1795 | 1795 | } |
1796 | 1796 | //use class to change status |
1797 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1797 | + $this->_cpt_model_obj->set_status($event_status); |
|
1798 | 1798 | $success = $this->_cpt_model_obj->save(); |
1799 | 1799 | |
1800 | 1800 | if ($success === FALSE) { |
1801 | - $msg = sprintf( esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
1801 | + $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
1802 | 1802 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1803 | 1803 | return FALSE; |
1804 | 1804 | } |
@@ -1816,15 +1816,15 @@ discard block |
||
1816 | 1816 | * @access protected |
1817 | 1817 | * @param bool $redirect_after |
1818 | 1818 | */ |
1819 | - protected function _delete_event( $redirect_after = TRUE ) { |
|
1819 | + protected function _delete_event($redirect_after = TRUE) { |
|
1820 | 1820 | //determine the event id and set to array. |
1821 | 1821 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL; |
1822 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1822 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1823 | 1823 | |
1824 | 1824 | |
1825 | 1825 | // loop thru events |
1826 | 1826 | if ($EVT_ID) { |
1827 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1827 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1828 | 1828 | // get list of events with no prices |
1829 | 1829 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
1830 | 1830 | // remove this event from the list of events with no prices |
@@ -1838,7 +1838,7 @@ discard block |
||
1838 | 1838 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1839 | 1839 | } |
1840 | 1840 | |
1841 | - if ( $redirect_after ) |
|
1841 | + if ($redirect_after) |
|
1842 | 1842 | $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
1843 | 1843 | } |
1844 | 1844 | |
@@ -1856,12 +1856,12 @@ discard block |
||
1856 | 1856 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
1857 | 1857 | // loop thru events |
1858 | 1858 | foreach ($EVT_IDs as $EVT_ID) { |
1859 | - $EVT_ID = absint( $EVT_ID ); |
|
1860 | - if ( $EVT_ID ) { |
|
1861 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
1859 | + $EVT_ID = absint($EVT_ID); |
|
1860 | + if ($EVT_ID) { |
|
1861 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
1862 | 1862 | $success = $results !== FALSE ? $success : FALSE; |
1863 | 1863 | // remove this event from the list of events with no prices |
1864 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1864 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1865 | 1865 | } else { |
1866 | 1866 | $success = FALSE; |
1867 | 1867 | $msg = esc_html__('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso'); |
@@ -1881,9 +1881,9 @@ discard block |
||
1881 | 1881 | * @param int $EVT_ID |
1882 | 1882 | * @return bool |
1883 | 1883 | */ |
1884 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
1884 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
1885 | 1885 | // grab event id |
1886 | - if ( ! $EVT_ID ) { |
|
1886 | + if ( ! $EVT_ID) { |
|
1887 | 1887 | $msg = esc_html__('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1888 | 1888 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1889 | 1889 | return FALSE; |
@@ -1892,19 +1892,19 @@ discard block |
||
1892 | 1892 | ! $this->_cpt_model_obj instanceof EE_Event |
1893 | 1893 | || $this->_cpt_model_obj->ID() !== $EVT_ID |
1894 | 1894 | ) { |
1895 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1895 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1896 | 1896 | } |
1897 | 1897 | |
1898 | - if ( ! $this->_cpt_model_obj instanceof EE_Event ) { |
|
1898 | + if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
1899 | 1899 | return false; |
1900 | 1900 | } |
1901 | 1901 | |
1902 | 1902 | //need to delete related tickets and prices first. |
1903 | 1903 | $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
1904 | - foreach ( $datetimes as $datetime ) { |
|
1904 | + foreach ($datetimes as $datetime) { |
|
1905 | 1905 | $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
1906 | 1906 | $tickets = $datetime->get_many_related('Ticket'); |
1907 | - foreach ( $tickets as $ticket ) { |
|
1907 | + foreach ($tickets as $ticket) { |
|
1908 | 1908 | $ticket->_remove_relation_to($datetime, 'Datetime'); |
1909 | 1909 | $ticket->delete_related_permanently('Price'); |
1910 | 1910 | $ticket->delete_permanently(); |
@@ -1914,14 +1914,14 @@ discard block |
||
1914 | 1914 | |
1915 | 1915 | //what about related venues or terms? |
1916 | 1916 | $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
1917 | - foreach ( $venues as $venue ) { |
|
1917 | + foreach ($venues as $venue) { |
|
1918 | 1918 | $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
1919 | 1919 | } |
1920 | 1920 | |
1921 | 1921 | //any attached question groups? |
1922 | 1922 | $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
1923 | - if ( !empty( $question_groups ) ) { |
|
1924 | - foreach ( $question_groups as $question_group ) { |
|
1923 | + if ( ! empty($question_groups)) { |
|
1924 | + foreach ($question_groups as $question_group) { |
|
1925 | 1925 | $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
1926 | 1926 | } |
1927 | 1927 | } |
@@ -1930,26 +1930,26 @@ discard block |
||
1930 | 1930 | |
1931 | 1931 | |
1932 | 1932 | //Message Template Groups |
1933 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
1933 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
1934 | 1934 | |
1935 | 1935 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
1936 | 1936 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
1937 | 1937 | |
1938 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
1938 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
1939 | 1939 | $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
1940 | 1940 | } |
1941 | 1941 | |
1942 | 1942 | $success = $this->_cpt_model_obj->delete_permanently(); |
1943 | 1943 | // did it all go as planned ? |
1944 | 1944 | if ($success) { |
1945 | - $msg = sprintf( esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
1945 | + $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
1946 | 1946 | EE_Error::add_success($msg); |
1947 | 1947 | } else { |
1948 | - $msg = sprintf( esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), $EVT_ID); |
|
1948 | + $msg = sprintf(esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), $EVT_ID); |
|
1949 | 1949 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1950 | 1950 | return FALSE; |
1951 | 1951 | } |
1952 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID ); |
|
1952 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
1953 | 1953 | return TRUE; |
1954 | 1954 | } |
1955 | 1955 | |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | */ |
1967 | 1967 | public function total_events() { |
1968 | 1968 | |
1969 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
1969 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
1970 | 1970 | return $count; |
1971 | 1971 | } |
1972 | 1972 | |
@@ -1981,10 +1981,10 @@ discard block |
||
1981 | 1981 | */ |
1982 | 1982 | public function total_events_draft() { |
1983 | 1983 | $where = array( |
1984 | - 'status' => array( 'IN', array('draft', 'auto-draft' ) ) |
|
1984 | + 'status' => array('IN', array('draft', 'auto-draft')) |
|
1985 | 1985 | ); |
1986 | 1986 | |
1987 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
1987 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1988 | 1988 | return $count; |
1989 | 1989 | } |
1990 | 1990 | |
@@ -2003,7 +2003,7 @@ discard block |
||
2003 | 2003 | 'status' => 'trash' |
2004 | 2004 | ); |
2005 | 2005 | |
2006 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2006 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2007 | 2007 | return $count; |
2008 | 2008 | } |
2009 | 2009 | |
@@ -2031,11 +2031,11 @@ discard block |
||
2031 | 2031 | // translated |
2032 | 2032 | TRUE |
2033 | 2033 | ); |
2034 | - $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; |
|
2034 | + $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; |
|
2035 | 2035 | |
2036 | 2036 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2037 | 2037 | $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
2038 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE); |
|
2038 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE); |
|
2039 | 2039 | $this->display_admin_page_with_sidebar(); |
2040 | 2040 | } |
2041 | 2041 | |
@@ -2061,9 +2061,9 @@ discard block |
||
2061 | 2061 | |
2062 | 2062 | protected function _template_settings() { |
2063 | 2063 | $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
2064 | - $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' ) . '" />'; |
|
2065 | - $this->_template_args['preview_text'] = '<strong>'.esc_html__( '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>'; |
|
2066 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2064 | + $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').'" />'; |
|
2065 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__('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>'; |
|
2066 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2067 | 2067 | } |
2068 | 2068 | |
2069 | 2069 | |
@@ -2076,22 +2076,22 @@ discard block |
||
2076 | 2076 | * @return void |
2077 | 2077 | */ |
2078 | 2078 | private function _set_category_object() { |
2079 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
2079 | + if (isset($this->_category->id) && ! empty($this->_category->id)) |
|
2080 | 2080 | return; //already have the category object so get out. |
2081 | 2081 | |
2082 | 2082 | //set default category object |
2083 | 2083 | $this->_set_empty_category_object(); |
2084 | 2084 | |
2085 | 2085 | //only set if we've got an id |
2086 | - if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) { |
|
2086 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2087 | 2087 | return; |
2088 | 2088 | } |
2089 | 2089 | |
2090 | 2090 | $category_id = absint($this->_req_data['EVT_CAT_ID']); |
2091 | 2091 | |
2092 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2092 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2093 | 2093 | |
2094 | - if ( !empty( $term ) ) { |
|
2094 | + if ( ! empty($term)) { |
|
2095 | 2095 | $this->_category->category_name = $term->name; |
2096 | 2096 | $this->_category->category_identifier = $term->slug; |
2097 | 2097 | $this->_category->category_desc = $term->description; |
@@ -2105,15 +2105,15 @@ discard block |
||
2105 | 2105 | |
2106 | 2106 | private function _set_empty_category_object() { |
2107 | 2107 | $this->_category = new stdClass(); |
2108 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2108 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2109 | 2109 | $this->_category->id = $this->_category->parent = 0; |
2110 | 2110 | } |
2111 | 2111 | |
2112 | 2112 | |
2113 | 2113 | protected function _category_list_table() { |
2114 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2114 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2115 | 2115 | $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
2116 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
|
2116 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
|
2117 | 2117 | $this->display_admin_list_table_page_with_sidebar(); |
2118 | 2118 | } |
2119 | 2119 | |
@@ -2127,14 +2127,14 @@ discard block |
||
2127 | 2127 | $this->_set_add_edit_form_tags($route); |
2128 | 2128 | |
2129 | 2129 | $this->_set_category_object(); |
2130 | - $id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
2130 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2131 | 2131 | |
2132 | 2132 | $delete_action = 'delete_category'; |
2133 | 2133 | |
2134 | 2134 | //custom redirect |
2135 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url ); |
|
2135 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url); |
|
2136 | 2136 | |
2137 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2137 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2138 | 2138 | |
2139 | 2139 | //take care of contents |
2140 | 2140 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
@@ -2148,25 +2148,25 @@ discard block |
||
2148 | 2148 | 'type' => 'wp_editor', |
2149 | 2149 | 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
2150 | 2150 | 'class' => 'my_editor_custom', |
2151 | - 'wpeditor_args' => array('media_buttons' => FALSE ) |
|
2151 | + 'wpeditor_args' => array('media_buttons' => FALSE) |
|
2152 | 2152 | ); |
2153 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2153 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2154 | 2154 | |
2155 | - $all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
2155 | + $all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); |
|
2156 | 2156 | |
2157 | 2157 | //setup category select for term parents. |
2158 | 2158 | $category_select_values[] = array( |
2159 | 2159 | 'text' => esc_html__('No Parent', 'event_espresso'), |
2160 | 2160 | 'id' => 0 |
2161 | 2161 | ); |
2162 | - foreach ( $all_terms as $term ) { |
|
2162 | + foreach ($all_terms as $term) { |
|
2163 | 2163 | $category_select_values[] = array( |
2164 | 2164 | 'text' => $term->name, |
2165 | 2165 | 'id' => $term->term_id |
2166 | 2166 | ); |
2167 | 2167 | } |
2168 | 2168 | |
2169 | - $category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
2169 | + $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); |
|
2170 | 2170 | |
2171 | 2171 | $template_args = array( |
2172 | 2172 | 'category' => $this->_category, |
@@ -2176,15 +2176,15 @@ discard block |
||
2176 | 2176 | 'disable' => '', |
2177 | 2177 | 'disabled_message' => FALSE |
2178 | 2178 | ); |
2179 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2180 | - return EEH_Template::display_template($template, $template_args, TRUE ); |
|
2179 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2180 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
2181 | 2181 | } |
2182 | 2182 | |
2183 | 2183 | |
2184 | 2184 | protected function _delete_categories() { |
2185 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2185 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2186 | 2186 | |
2187 | - foreach ( $cat_ids as $cat_id ) { |
|
2187 | + foreach ($cat_ids as $cat_id) { |
|
2188 | 2188 | $this->_delete_category($cat_id); |
2189 | 2189 | } |
2190 | 2190 | |
@@ -2192,7 +2192,7 @@ discard block |
||
2192 | 2192 | $query_args = array( |
2193 | 2193 | 'action' => 'category_list' |
2194 | 2194 | ); |
2195 | - $this->_redirect_after_action(0,'','',$query_args); |
|
2195 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2196 | 2196 | |
2197 | 2197 | } |
2198 | 2198 | |
@@ -2202,61 +2202,61 @@ discard block |
||
2202 | 2202 | |
2203 | 2203 | protected function _delete_category($cat_id) { |
2204 | 2204 | global $wpdb; |
2205 | - $cat_id = absint( $cat_id ); |
|
2206 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2205 | + $cat_id = absint($cat_id); |
|
2206 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2207 | 2207 | } |
2208 | 2208 | |
2209 | 2209 | |
2210 | 2210 | |
2211 | 2211 | protected function _insert_or_update_category($new_category) { |
2212 | 2212 | |
2213 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
2213 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE); |
|
2214 | 2214 | $success = 0; //we already have a success message so lets not send another. |
2215 | 2215 | |
2216 | - if ( $cat_id ) { |
|
2216 | + if ($cat_id) { |
|
2217 | 2217 | $query_args = array( |
2218 | 2218 | 'action' => 'edit_category', |
2219 | 2219 | 'EVT_CAT_ID' => $cat_id |
2220 | 2220 | ); |
2221 | 2221 | } else { |
2222 | - $query_args = array( 'action' => 'add_category' ); |
|
2222 | + $query_args = array('action' => 'add_category'); |
|
2223 | 2223 | } |
2224 | - $this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
2224 | + $this->_redirect_after_action($success, '', '', $query_args, TRUE); |
|
2225 | 2225 | |
2226 | 2226 | } |
2227 | 2227 | |
2228 | 2228 | |
2229 | 2229 | |
2230 | - private function _insert_category( $update = FALSE ) { |
|
2230 | + private function _insert_category($update = FALSE) { |
|
2231 | 2231 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2232 | - $category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2233 | - $category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2234 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2232 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2233 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2234 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2235 | 2235 | |
2236 | - if ( empty( $category_name ) ) { |
|
2237 | - $msg = esc_html__( 'You must add a name for the category.', 'event_espresso' ); |
|
2238 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2236 | + if (empty($category_name)) { |
|
2237 | + $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2238 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2239 | 2239 | return false; |
2240 | 2240 | } |
2241 | 2241 | |
2242 | - $term_args=array( |
|
2242 | + $term_args = array( |
|
2243 | 2243 | 'name'=>$category_name, |
2244 | 2244 | 'description'=>$category_desc, |
2245 | 2245 | 'parent'=>$category_parent |
2246 | 2246 | ); |
2247 | 2247 | //was the category_identifier input disabled? |
2248 | - if(isset($this->_req_data['category_identifier'])){ |
|
2248 | + if (isset($this->_req_data['category_identifier'])) { |
|
2249 | 2249 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2250 | 2250 | } |
2251 | - $insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2251 | + $insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2252 | 2252 | |
2253 | - if ( !is_array( $insert_ids ) ) { |
|
2254 | - $msg = esc_html__( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
2255 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2253 | + if ( ! is_array($insert_ids)) { |
|
2254 | + $msg = esc_html__('An error occurred and the category has not been saved to the database.', 'event_espresso'); |
|
2255 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2256 | 2256 | } else { |
2257 | 2257 | $cat_id = $insert_ids['term_id']; |
2258 | - $msg = sprintf ( esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name ); |
|
2259 | - EE_Error::add_success( $msg ); |
|
2258 | + $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2259 | + EE_Error::add_success($msg); |
|
2260 | 2260 | } |
2261 | 2261 | |
2262 | 2262 | return $cat_id; |
@@ -2265,32 +2265,32 @@ discard block |
||
2265 | 2265 | |
2266 | 2266 | |
2267 | 2267 | |
2268 | - public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
2268 | + public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) { |
|
2269 | 2269 | global $wpdb; |
2270 | 2270 | |
2271 | 2271 | //testing term stuff |
2272 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2273 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2274 | - $limit = ($current_page-1)*$per_page; |
|
2272 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2273 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2274 | + $limit = ($current_page - 1) * $per_page; |
|
2275 | 2275 | |
2276 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2276 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2277 | 2277 | |
2278 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2279 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2278 | + if (isset($this->_req_data['s'])) { |
|
2279 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2280 | 2280 | $where['OR'] = array( |
2281 | - 'Term.name' => array( 'LIKE', $sstr), |
|
2282 | - 'description' => array( 'LIKE', $sstr ) |
|
2281 | + 'Term.name' => array('LIKE', $sstr), |
|
2282 | + 'description' => array('LIKE', $sstr) |
|
2283 | 2283 | ); |
2284 | 2284 | } |
2285 | 2285 | |
2286 | 2286 | $query_params = array( |
2287 | - $where , |
|
2288 | - 'order_by' => array( $orderby => $order ), |
|
2289 | - 'limit' => $limit . ',' . $per_page, |
|
2287 | + $where, |
|
2288 | + 'order_by' => array($orderby => $order), |
|
2289 | + 'limit' => $limit.','.$per_page, |
|
2290 | 2290 | 'force_join' => array('Term') |
2291 | 2291 | ); |
2292 | 2292 | |
2293 | - $categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2293 | + $categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2294 | 2294 | |
2295 | 2295 | return $categories; |
2296 | 2296 | } |
@@ -1,5 +1,5 @@ discard block |
||
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,8 +30,8 @@ discard block |
||
30 | 30 | class Maintenance_Admin_Page extends EE_Admin_Page { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $routing = TRUE ) { |
|
34 | - parent::__construct( $routing ); |
|
33 | + public function __construct($routing = TRUE) { |
|
34 | + parent::__construct($routing); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | |
47 | 47 | |
48 | 48 | protected function _ajax_hooks() { |
49 | - add_action('wp_ajax_migration_step',array($this,'migration_step')); |
|
50 | - add_action('wp_ajax_add_error_to_migrations_ran',array($this,'add_error_to_migrations_ran')); |
|
49 | + add_action('wp_ajax_migration_step', array($this, 'migration_step')); |
|
50 | + add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran')); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $this->_admin_page_title = EE_MAINTENANCE_LABEL; |
57 | 57 | $this->_labels = array( |
58 | 58 | 'buttons' => array( |
59 | - 'reset_capabilities' => __( 'Reset Event Espresso Capabilities', 'event_espresso' ) |
|
59 | + 'reset_capabilities' => __('Reset Event Espresso Capabilities', 'event_espresso') |
|
60 | 60 | ) |
61 | 61 | ); |
62 | 62 | } |
@@ -155,23 +155,23 @@ discard block |
||
155 | 155 | * default maintenance page. If we're in maintenance mode level 2, then we need to show |
156 | 156 | * the migration scripts and all that UI. |
157 | 157 | */ |
158 | - public function _maintenance(){ |
|
158 | + public function _maintenance() { |
|
159 | 159 | //it all depends if we're in maintenance model level 1 (frontend-only) or |
160 | 160 | //level 2 (everything except maintenance page) |
161 | - try{ |
|
161 | + try { |
|
162 | 162 | //get the current maintenance level and check if |
163 | 163 | //we are removed |
164 | 164 | $mm = EE_Maintenance_Mode::instance()->level(); |
165 | 165 | $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
166 | - if( $mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm){ |
|
166 | + if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) { |
|
167 | 167 | //we just took the site out of maintenance mode, so notify the user. |
168 | 168 | //unfortunately this message appears to be echoed on the NEXT page load... |
169 | 169 | //oh well, we should really be checking for this on addon deactivation anyways |
170 | - EE_Error::add_attention( __( 'Site taken out of maintenance mode because no data migration scripts are required', 'event_espresso' ) ); |
|
171 | - $this->_process_notices( array( 'page' => 'espresso_maintenance_settings'), false ); |
|
170 | + EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required', 'event_espresso')); |
|
171 | + $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false); |
|
172 | 172 | } |
173 | 173 | //in case an exception is thrown while trying to handle migrations |
174 | - switch(EE_Maintenance_Mode::instance()->level()){ |
|
174 | + switch (EE_Maintenance_Mode::instance()->level()) { |
|
175 | 175 | case EE_Maintenance_Mode::level_0_not_in_maintenance: |
176 | 176 | case EE_Maintenance_Mode::level_1_frontend_only_maintenance: |
177 | 177 | $show_maintenance_switch = true; |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | case EE_Maintenance_Mode::level_2_complete_maintenance: |
184 | 184 | $show_maintenance_switch = false; |
185 | 185 | $show_migration_progress = true; |
186 | - if(isset($this->_req_data['continue_migration'])){ |
|
186 | + if (isset($this->_req_data['continue_migration'])) { |
|
187 | 187 | $show_backup_db_text = false; |
188 | - }else{ |
|
188 | + } else { |
|
189 | 189 | $show_backup_db_text = true; |
190 | 190 | } |
191 | 191 | $scripts_needing_to_run = EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts(); |
192 | 192 | $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating(); |
193 | 193 | $script_names = array(); |
194 | 194 | $current_script = NULL; |
195 | - foreach($scripts_needing_to_run as $script){ |
|
196 | - if($script instanceof EE_Data_Migration_Script_Base){ |
|
197 | - if( ! $current_script){ |
|
195 | + foreach ($scripts_needing_to_run as $script) { |
|
196 | + if ($script instanceof EE_Data_Migration_Script_Base) { |
|
197 | + if ( ! $current_script) { |
|
198 | 198 | $current_script = $script; |
199 | 199 | $current_script->migration_page_hooks(); |
200 | 200 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } |
206 | 206 | $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
207 | 207 | $exception_thrown = false; |
208 | - }catch(EE_Error $e){ |
|
208 | + } catch (EE_Error $e) { |
|
209 | 209 | |
210 | 210 | EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
211 | 211 | //now, just so we can display the page correctly, make a error migration script stage object |
@@ -215,54 +215,54 @@ discard block |
||
215 | 215 | $exception_thrown = true; |
216 | 216 | } |
217 | 217 | $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set(); |
218 | - $current_db_state = str_replace( '.decaf', '', $current_db_state ); |
|
219 | - if($exception_thrown || |
|
220 | - ( $most_recent_migration && |
|
218 | + $current_db_state = str_replace('.decaf', '', $current_db_state); |
|
219 | + if ($exception_thrown || |
|
220 | + ($most_recent_migration && |
|
221 | 221 | $most_recent_migration instanceof EE_Data_Migration_Script_Base && |
222 | 222 | $most_recent_migration->is_broken() |
223 | - )){ |
|
224 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
225 | - $this->_template_args[ 'support_url' ] = 'http://eventespresso.com/support/forums/'; |
|
226 | - $this->_template_args[ 'next_url' ] = EEH_URL::add_query_args_and_nonce(array( 'action' => 'confirm_migration_crash_report_sent', 'success' => '0' ), EE_MAINTENANCE_ADMIN_URL ); |
|
227 | - }elseif($addons_should_be_upgraded_first){ |
|
228 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
229 | - }else{ |
|
230 | - if($most_recent_migration && |
|
231 | - $most_recent_migration instanceof EE_Data_Migration_Script_Base && |
|
232 | - $most_recent_migration->can_continue()){ |
|
223 | + )) { |
|
224 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_was_borked_page.template.php'; |
|
225 | + $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
|
226 | + $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', 'success' => '0'), EE_MAINTENANCE_ADMIN_URL); |
|
227 | + }elseif ($addons_should_be_upgraded_first) { |
|
228 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_upgrade_addons_before_migrating.template.php'; |
|
229 | + } else { |
|
230 | + if ($most_recent_migration && |
|
231 | + $most_recent_migration instanceof EE_Data_Migration_Script_Base && |
|
232 | + $most_recent_migration->can_continue()) { |
|
233 | 233 | $show_backup_db_text = false; |
234 | 234 | $show_continue_current_migration_script = true; |
235 | 235 | $show_most_recent_migration = true; |
236 | - }elseif(isset($this->_req_data['continue_migration'])){ |
|
236 | + }elseif (isset($this->_req_data['continue_migration'])) { |
|
237 | 237 | $show_most_recent_migration = true; |
238 | 238 | $show_continue_current_migration_script = false; |
239 | - }else{ |
|
239 | + } else { |
|
240 | 240 | $show_most_recent_migration = false; |
241 | 241 | $show_continue_current_migration_script = false; |
242 | 242 | } |
243 | 243 | |
244 | - if(isset($current_script)){ |
|
244 | + if (isset($current_script)) { |
|
245 | 245 | $migrates_to = $current_script->migrates_to_version(); |
246 | - $plugin_slug = $migrates_to[ 'slug' ]; |
|
247 | - $new_version = $migrates_to[ 'version' ]; |
|
248 | - $this->_template_args = array_merge($this->_template_args,array( |
|
249 | - 'current_db_state'=> sprintf(__("EE%s (%s)", "event_espresso"), isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3,$plugin_slug), |
|
250 | - 'next_db_state'=>isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'),$new_version,$plugin_slug) : NULL)); |
|
246 | + $plugin_slug = $migrates_to['slug']; |
|
247 | + $new_version = $migrates_to['version']; |
|
248 | + $this->_template_args = array_merge($this->_template_args, array( |
|
249 | + 'current_db_state'=> sprintf(__("EE%s (%s)", "event_espresso"), isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug), |
|
250 | + 'next_db_state'=>isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'), $new_version, $plugin_slug) : NULL)); |
|
251 | 251 | } |
252 | 252 | |
253 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
253 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_page.template.php'; |
|
254 | 254 | $this->_template_args = array_merge( |
255 | 255 | $this->_template_args, |
256 | 256 | array( |
257 | - 'show_most_recent_migration' => $show_most_recent_migration,//flag for showing the most recent migration's status and/or errors |
|
258 | - 'show_migration_progress' => $show_migration_progress,//flag for showing the option to run migrations and see their progress |
|
259 | - 'show_backup_db_text' => $show_backup_db_text,//flag for showing text telling the user to backup their DB |
|
260 | - 'show_maintenance_switch'=> $show_maintenance_switch,//flag for showing the option to change maintenance mode between levels 0 and 1 |
|
261 | - 'script_names'=>$script_names,//array of names of scripts that have run |
|
262 | - 'show_continue_current_migration_script'=>$show_continue_current_migration_script,//flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0 |
|
257 | + 'show_most_recent_migration' => $show_most_recent_migration, //flag for showing the most recent migration's status and/or errors |
|
258 | + 'show_migration_progress' => $show_migration_progress, //flag for showing the option to run migrations and see their progress |
|
259 | + 'show_backup_db_text' => $show_backup_db_text, //flag for showing text telling the user to backup their DB |
|
260 | + 'show_maintenance_switch'=> $show_maintenance_switch, //flag for showing the option to change maintenance mode between levels 0 and 1 |
|
261 | + 'script_names'=>$script_names, //array of names of scripts that have run |
|
262 | + 'show_continue_current_migration_script'=>$show_continue_current_migration_script, //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0 |
|
263 | 263 | 'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action'=>'reset_db'), EE_MAINTENANCE_ADMIN_URL), |
264 | - 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action'=>'change_maintenance_level'),EE_MAINTENANCE_ADMIN_URL), |
|
265 | - 'ultimate_db_state'=> sprintf(__("EE%s", 'event_espresso'),espresso_version()), |
|
264 | + 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action'=>'change_maintenance_level'), EE_MAINTENANCE_ADMIN_URL), |
|
265 | + 'ultimate_db_state'=> sprintf(__("EE%s", 'event_espresso'), espresso_version()), |
|
266 | 266 | ) |
267 | 267 | ); |
268 | 268 | //make sure we have the form fields helper available. It usually is, but sometimes it isn't |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | 'status_fatal_error'=> EE_Data_Migration_Manager::status_fatal_error, |
277 | 277 | 'status_completed'=> EE_Data_Migration_Manager::status_completed)); |
278 | 278 | } |
279 | - $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
279 | + $this->_template_args['most_recent_migration'] = $most_recent_migration; //the actual most recently ran migration |
|
280 | 280 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, TRUE); |
281 | 281 | $this->display_admin_page_with_sidebar(); |
282 | 282 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | /** |
287 | 287 | * returns JSON and executes another step of the currently-executing data migration (called via ajax) |
288 | 288 | */ |
289 | - public function migration_step(){ |
|
289 | + public function migration_step() { |
|
290 | 290 | $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request(); |
291 | 291 | $this->_return_json(); |
292 | 292 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * Can be used by js when it notices a response with HTML in it in order |
298 | 298 | * to log the malformed response |
299 | 299 | */ |
300 | - public function add_error_to_migrations_ran(){ |
|
300 | + public function add_error_to_migrations_ran() { |
|
301 | 301 | EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']); |
302 | 302 | $this->_template_args['data'] = array('ok'=>true); |
303 | 303 | $this->_return_json(); |
@@ -308,14 +308,14 @@ discard block |
||
308 | 308 | /** |
309 | 309 | * changes the maintenance level, provided there are still no migration scripts that shoudl run |
310 | 310 | */ |
311 | - public function _change_maintenance_level(){ |
|
311 | + public function _change_maintenance_level() { |
|
312 | 312 | $new_level = intval($this->_req_data['maintenance_mode_level']); |
313 | - if( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){ |
|
313 | + if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
314 | 314 | EE_Maintenance_Mode::instance()->set_maintenance_level($new_level); |
315 | 315 | $success = true; |
316 | - }else{ |
|
316 | + } else { |
|
317 | 317 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
318 | - $success= false; |
|
318 | + $success = false; |
|
319 | 319 | } |
320 | 320 | $this->_redirect_after_action($success, 'Maintenance Mode', __("Updated", "event_espresso")); |
321 | 321 | } |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @throws \EE_Error |
329 | 329 | */ |
330 | - public function _data_reset_and_delete(){ |
|
331 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
330 | + public function _data_reset_and_delete() { |
|
331 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_data_reset_and_delete.template.php'; |
|
332 | 332 | $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button( |
333 | 333 | 'reset_capabilities', |
334 | 334 | 'reset_capabilities', |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | false |
339 | 339 | ); |
340 | 340 | $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
341 | - array( 'action' => 'delete_db' ), |
|
341 | + array('action' => 'delete_db'), |
|
342 | 342 | EE_MAINTENANCE_ADMIN_URL |
343 | 343 | ); |
344 | 344 | $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
345 | - array( 'action' => 'reset_db' ), |
|
345 | + array('action' => 'reset_db'), |
|
346 | 346 | EE_MAINTENANCE_ADMIN_URL |
347 | 347 | ); |
348 | 348 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | |
357 | 357 | |
358 | 358 | protected function _reset_capabilities() { |
359 | - EE_Registry::instance()->CAP->init_caps( true ); |
|
360 | - EE_Error::add_success( __('Default Event Espresso capabilities have been restored for all current roles.', 'event_espresso' ) ); |
|
361 | - $this->_redirect_after_action( FALSE, '', '', array( 'action' => 'data_reset' ), TRUE ); |
|
359 | + EE_Registry::instance()->CAP->init_caps(true); |
|
360 | + EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.', 'event_espresso')); |
|
361 | + $this->_redirect_after_action(FALSE, '', '', array('action' => 'data_reset'), TRUE); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | */ |
369 | 369 | protected function _reattempt_migration() { |
370 | 370 | EE_Data_Migration_Manager::instance()->reattempt(); |
371 | - $this->_redirect_after_action( FALSE, '', '', array( 'action' => 'default' ), TRUE ); |
|
371 | + $this->_redirect_after_action(FALSE, '', '', array('action' => 'default'), TRUE); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | /** |
378 | 378 | * shows the big ol' System Information page |
379 | 379 | */ |
380 | - public function _system_status(){ |
|
381 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
380 | + public function _system_status() { |
|
381 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_system_stati_page.template.php'; |
|
382 | 382 | $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
383 | 383 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, TRUE); |
384 | 384 | $this->display_admin_page_with_sidebar(); |
@@ -386,30 +386,30 @@ discard block |
||
386 | 386 | |
387 | 387 | |
388 | 388 | |
389 | - public function _send_migration_crash_report(){ |
|
389 | + public function _send_migration_crash_report() { |
|
390 | 390 | $from = $this->_req_data['from']; |
391 | 391 | $from_name = $this->_req_data['from_name']; |
392 | 392 | $body = $this->_req_data['body']; |
393 | - try{ |
|
393 | + try { |
|
394 | 394 | $success = wp_mail(EE_SUPPORT_EMAIL, |
395 | 395 | 'Migration Crash Report', |
396 | - $body."/r/n<br>". print_r(EEM_System_Status::instance()->get_system_stati(),true), |
|
396 | + $body."/r/n<br>".print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
397 | 397 | array( |
398 | 398 | "from:$from_name<$from>", |
399 | 399 | // 'content-type:text/html charset=UTF-8' |
400 | 400 | )); |
401 | - }catch( Exception $e ){ |
|
401 | + } catch (Exception $e) { |
|
402 | 402 | $success = FALSE; |
403 | 403 | } |
404 | - $this->_redirect_after_action($success, __("Migration Crash Report", "event_espresso"), __("sent", "event_espresso"),array('success'=>$success,'action'=>'confirm_migration_crash_report_sent')); |
|
404 | + $this->_redirect_after_action($success, __("Migration Crash Report", "event_espresso"), __("sent", "event_espresso"), array('success'=>$success, 'action'=>'confirm_migration_crash_report_sent')); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
408 | 408 | |
409 | - public function _confirm_migration_crash_report_sent(){ |
|
410 | - try{ |
|
409 | + public function _confirm_migration_crash_report_sent() { |
|
410 | + try { |
|
411 | 411 | $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
412 | - }catch(EE_Error $e){ |
|
412 | + } catch (EE_Error $e) { |
|
413 | 413 | |
414 | 414 | EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
415 | 415 | //now, just so we can display the page correctly, make a error migration script stage object |
@@ -417,14 +417,14 @@ discard block |
||
417 | 417 | $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
418 | 418 | $most_recent_migration->add_error($e->getMessage()); |
419 | 419 | } |
420 | - $success = $this->_req_data['success']=='1' ? true : false; |
|
420 | + $success = $this->_req_data['success'] == '1' ? true : false; |
|
421 | 421 | $this->_template_args['success'] = $success; |
422 | - $this->_template_args[ 'most_recent_migration' ] = $most_recent_migration; |
|
422 | + $this->_template_args['most_recent_migration'] = $most_recent_migration; |
|
423 | 423 | $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'reset_db'), EE_MAINTENANCE_ADMIN_URL); |
424 | - $this->_template_args[ 'reset_db_page_url' ] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'data_reset'), EE_MAINTENANCE_ADMIN_URL); |
|
425 | - $this->_template_args[ 'reattempt_action_url' ] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'reattempt_migration'), EE_MAINTENANCE_ADMIN_URL ); |
|
426 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
427 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,$this->_template_args,TRUE); |
|
424 | + $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'data_reset'), EE_MAINTENANCE_ADMIN_URL); |
|
425 | + $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), EE_MAINTENANCE_ADMIN_URL); |
|
426 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_confirm_migration_crash_report_sent.template.php'; |
|
427 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, TRUE); |
|
428 | 428 | $this->display_admin_page_with_sidebar(); |
429 | 429 | } |
430 | 430 | |
@@ -437,18 +437,18 @@ discard block |
||
437 | 437 | * @param boolean $nuke_old_ee4_data controls whether or not we |
438 | 438 | * destroy the old ee4 data, or just try initializing ee4 default data |
439 | 439 | */ |
440 | - public function _reset_db( $nuke_old_ee4_data = TRUE ){ |
|
440 | + public function _reset_db($nuke_old_ee4_data = TRUE) { |
|
441 | 441 | EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
442 | 442 | |
443 | - if( $nuke_old_ee4_data ){ |
|
443 | + if ($nuke_old_ee4_data) { |
|
444 | 444 | EEH_Activation::delete_all_espresso_cpt_data(); |
445 | - EEH_Activation::delete_all_espresso_tables_and_data( FALSE ); |
|
445 | + EEH_Activation::delete_all_espresso_tables_and_data(FALSE); |
|
446 | 446 | EEH_Activation::remove_cron_tasks(); |
447 | 447 | } |
448 | 448 | //make sure when we reset the registry's config that it |
449 | 449 | //switches to using the new singleton |
450 | - EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset( TRUE ); |
|
451 | - EE_System::instance()->initialize_db_if_no_migrations_required( TRUE ); |
|
450 | + EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(TRUE); |
|
451 | + EE_System::instance()->initialize_db_if_no_migrations_required(TRUE); |
|
452 | 452 | EE_System::instance()->redirect_to_about_ee(); |
453 | 453 | } |
454 | 454 | |
@@ -457,20 +457,20 @@ discard block |
||
457 | 457 | /** |
458 | 458 | * Deletes ALL EE tables, Records, and Options from the database. |
459 | 459 | */ |
460 | - public function _delete_db(){ |
|
460 | + public function _delete_db() { |
|
461 | 461 | EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
462 | 462 | EEH_Activation::delete_all_espresso_cpt_data(); |
463 | 463 | EEH_Activation::delete_all_espresso_tables_and_data(); |
464 | 464 | EEH_Activation::remove_cron_tasks(); |
465 | 465 | EEH_Activation::deactivate_event_espresso(); |
466 | - wp_safe_redirect( admin_url( 'plugins.php' )); |
|
466 | + wp_safe_redirect(admin_url('plugins.php')); |
|
467 | 467 | exit; |
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
471 | 471 | * sets up EE4 to rerun the migrations from ee3 to ee4 |
472 | 472 | */ |
473 | - public function _rerun_migration_from_ee3(){ |
|
473 | + public function _rerun_migration_from_ee3() { |
|
474 | 474 | EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
475 | 475 | EEH_Activation::delete_all_espresso_cpt_data(); |
476 | 476 | EEH_Activation::delete_all_espresso_tables_and_data(false); |
@@ -497,9 +497,9 @@ discard block |
||
497 | 497 | wp_enqueue_script('ee_admin_js'); |
498 | 498 | // wp_enqueue_media(); |
499 | 499 | // wp_enqueue_script('media-upload'); |
500 | - wp_enqueue_script('ee-maintenance',EE_MAINTENANCE_ASSETS_URL.'/ee-maintenance.js',array('jquery'),EVENT_ESPRESSO_VERSION,true); |
|
500 | + wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL.'/ee-maintenance.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
501 | 501 | |
502 | - wp_register_style( 'espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), EVENT_ESPRESSO_VERSION ); |
|
502 | + wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL.'ee-maintenance.css', array(), EVENT_ESPRESSO_VERSION); |
|
503 | 503 | wp_enqueue_style('espresso_maintenance'); |
504 | 504 | } |
505 | 505 |