@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public static function instance() { |
80 | 80 | // check if class object is instantiated |
81 | - if ( ! self::$_instance instanceof EE_CPT_Strategy ) { |
|
81 | + if ( ! self::$_instance instanceof EE_CPT_Strategy) { |
|
82 | 82 | self::$_instance = new self(); |
83 | 83 | } |
84 | 84 | return self::$_instance; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | // d( $this->_CPT_endpoints ); |
102 | 102 | // d( $this->_CPT_taxonomies ); |
103 | 103 | |
104 | - add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 5 ); |
|
104 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 5); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | */ |
115 | 115 | private function _set_CPT_endpoints() { |
116 | 116 | $_CPT_endpoints = array(); |
117 | - if ( is_array( $this->_CPTs )) { |
|
118 | - foreach ( $this->_CPTs as $CPT_type => $CPT ) { |
|
119 | - $_CPT_endpoints [ $CPT['plural_slug'] ] = $CPT_type; |
|
117 | + if (is_array($this->_CPTs)) { |
|
118 | + foreach ($this->_CPTs as $CPT_type => $CPT) { |
|
119 | + $_CPT_endpoints [$CPT['plural_slug']] = $CPT_type; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | return $_CPT_endpoints; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param WP_Query $WP_Query |
132 | 132 | * @return void |
133 | 133 | */ |
134 | - private function _set_EE_tags_on_WP_Query( WP_Query $WP_Query) { |
|
134 | + private function _set_EE_tags_on_WP_Query(WP_Query $WP_Query) { |
|
135 | 135 | $WP_Query->is_espresso_event_single = FALSE; |
136 | 136 | $WP_Query->is_espresso_event_archive = FALSE; |
137 | 137 | $WP_Query->is_espresso_event_taxonomy = FALSE; |
@@ -158,16 +158,16 @@ discard block |
||
158 | 158 | */ |
159 | 159 | private function _set_CPT_taxonomies() { |
160 | 160 | // check if taxonomies have already been set |
161 | - if ( empty( $this->_CPT_taxonomies )) { |
|
161 | + if (empty($this->_CPT_taxonomies)) { |
|
162 | 162 | // and that this CPT has taxonomies registered for it |
163 | - if ( isset( $this->CPT['args'] ) && isset( $this->CPT['args']['taxonomies'] )) { |
|
163 | + if (isset($this->CPT['args']) && isset($this->CPT['args']['taxonomies'])) { |
|
164 | 164 | // if so then grab them, but we want the taxonomy name as the key |
165 | - $taxonomies = array_flip( $this->CPT['args']['taxonomies'] ); |
|
165 | + $taxonomies = array_flip($this->CPT['args']['taxonomies']); |
|
166 | 166 | // then grab the list of ALL taxonomies |
167 | 167 | $all_taxonomies = EE_Register_CPTs::get_taxonomies(); |
168 | - foreach ( $taxonomies as $taxonomy => $details ) { |
|
168 | + foreach ($taxonomies as $taxonomy => $details) { |
|
169 | 169 | // add details to our taxonomies if they exist |
170 | - $taxonomies[ $taxonomy ] = isset( $all_taxonomies[ $taxonomy ] ) ? $all_taxonomies[ $taxonomy ] : NULL; |
|
170 | + $taxonomies[$taxonomy] = isset($all_taxonomies[$taxonomy]) ? $all_taxonomies[$taxonomy] : NULL; |
|
171 | 171 | } |
172 | 172 | $this->_CPT_taxonomies = $taxonomies; |
173 | 173 | } |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | * @return void |
193 | 193 | */ |
194 | 194 | private function _set_CPT_terms() { |
195 | - if ( empty( $this->_CPT_terms )) { |
|
195 | + if (empty($this->_CPT_terms)) { |
|
196 | 196 | $terms = EEM_Term::instance()->get_all_CPT_post_tags(); |
197 | - foreach ( $terms as $term ) { |
|
198 | - $this->_CPT_terms[ $term->slug() ] = $term; |
|
197 | + foreach ($terms as $term) { |
|
198 | + $this->_CPT_terms[$term->slug()] = $term; |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | } |
@@ -209,24 +209,24 @@ discard block |
||
209 | 209 | * @param $WP_Query |
210 | 210 | * @return void |
211 | 211 | */ |
212 | - private function _set_post_type_for_terms( WP_Query $WP_Query ) { |
|
212 | + private function _set_post_type_for_terms(WP_Query $WP_Query) { |
|
213 | 213 | // is a tag set ? |
214 | - if ( isset( $WP_Query->query['tag'] )) { |
|
214 | + if (isset($WP_Query->query['tag'])) { |
|
215 | 215 | // set post_tags |
216 | 216 | $this->_set_CPT_terms(); |
217 | 217 | // is this tag archive term in the list of terms used by our CPTs ? |
218 | - $term = isset ( $this->_CPT_terms[ $WP_Query->query['tag'] ] ) ? $this->_CPT_terms[ $WP_Query->query['tag'] ] : NULL; |
|
218 | + $term = isset ($this->_CPT_terms[$WP_Query->query['tag']]) ? $this->_CPT_terms[$WP_Query->query['tag']] : NULL; |
|
219 | 219 | // verify the term |
220 | - if ( $term instanceof EE_Term ) { |
|
221 | - $term->post_type = array_merge( array( 'post', 'page' ), (array)$term->post_type ); |
|
222 | - $term->post_type = apply_filters( 'FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type', $term->post_type, $term ); |
|
220 | + if ($term instanceof EE_Term) { |
|
221 | + $term->post_type = array_merge(array('post', 'page'), (array) $term->post_type); |
|
222 | + $term->post_type = apply_filters('FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type', $term->post_type, $term); |
|
223 | 223 | // if a post type is already set |
224 | - if ( isset( $WP_Query->query_vars['post_type'] )) { |
|
224 | + if (isset($WP_Query->query_vars['post_type'])) { |
|
225 | 225 | // add to existing array |
226 | - $term->post_type = array_merge ( (array)$WP_Query->query_vars['post_type'], $term->post_type ); |
|
226 | + $term->post_type = array_merge((array) $WP_Query->query_vars['post_type'], $term->post_type); |
|
227 | 227 | } |
228 | 228 | // just set post_type to our CPT |
229 | - $WP_Query->set( 'post_type', $term->post_type ); |
|
229 | + $WP_Query->set('post_type', $term->post_type); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
@@ -241,17 +241,17 @@ discard block |
||
241 | 241 | * in order for is_archive() and is_single() methods to work properly. |
242 | 242 | * @return void |
243 | 243 | */ |
244 | - public function _possibly_set_ee_request_var(){ |
|
244 | + public function _possibly_set_ee_request_var() { |
|
245 | 245 | // check if ee action var has been set |
246 | - if ( ! EE_Registry::instance()->REQ->is_set( 'ee' )) { |
|
246 | + if ( ! EE_Registry::instance()->REQ->is_set('ee')) { |
|
247 | 247 | // check that route exists for CPT archive slug |
248 | - if ( is_archive() && EE_Config::get_route( $this->CPT['plural_slug'] )) { |
|
248 | + if (is_archive() && EE_Config::get_route($this->CPT['plural_slug'])) { |
|
249 | 249 | // ie: set "ee" to "events" |
250 | - EE_Registry::instance()->REQ->set( 'ee', $this->CPT['plural_slug'] ); |
|
250 | + EE_Registry::instance()->REQ->set('ee', $this->CPT['plural_slug']); |
|
251 | 251 | // or does it match a single page CPT like /event/ |
252 | - } else if ( is_single() && EE_Config::get_route( $this->CPT['singular_slug'] )) { |
|
252 | + } else if (is_single() && EE_Config::get_route($this->CPT['singular_slug'])) { |
|
253 | 253 | // ie: set "ee" to "event" |
254 | - EE_Registry::instance()->REQ->set( 'ee', $this->CPT['singular_slug'] ); |
|
254 | + EE_Registry::instance()->REQ->set('ee', $this->CPT['singular_slug']); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | } |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | * @param WP_Query $WP_Query |
266 | 266 | * @return void |
267 | 267 | */ |
268 | - public function _set_paging( $WP_Query ) { |
|
269 | - if ( $WP_Query->is_main_query() && apply_filters( 'FHEE__EE_CPT_Strategy___set_paging', TRUE )) { |
|
270 | - $page = ( get_query_var('page') ) ? get_query_var('page') : NULL; |
|
271 | - $paged = ( get_query_var('paged') ) ? get_query_var('paged') : $page; |
|
272 | - $WP_Query->set( 'paged', $paged ); |
|
268 | + public function _set_paging($WP_Query) { |
|
269 | + if ($WP_Query->is_main_query() && apply_filters('FHEE__EE_CPT_Strategy___set_paging', TRUE)) { |
|
270 | + $page = (get_query_var('page')) ? get_query_var('page') : NULL; |
|
271 | + $paged = (get_query_var('paged')) ? get_query_var('paged') : $page; |
|
272 | + $WP_Query->set('paged', $paged); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
@@ -286,35 +286,35 @@ discard block |
||
286 | 286 | * @param WP_Query $WP_Query |
287 | 287 | * @return void |
288 | 288 | */ |
289 | - public function pre_get_posts( $WP_Query ) { |
|
289 | + public function pre_get_posts($WP_Query) { |
|
290 | 290 | // check that post-type is set |
291 | - if ( ! $WP_Query instanceof WP_Query ) { |
|
291 | + if ( ! $WP_Query instanceof WP_Query) { |
|
292 | 292 | return; |
293 | 293 | } |
294 | 294 | |
295 | 295 | // add our conditionals |
296 | - $this->_set_EE_tags_on_WP_Query( $WP_Query ); |
|
296 | + $this->_set_EE_tags_on_WP_Query($WP_Query); |
|
297 | 297 | // check for terms |
298 | - $this->_set_post_type_for_terms( $WP_Query ); |
|
298 | + $this->_set_post_type_for_terms($WP_Query); |
|
299 | 299 | // make sure paging is always set |
300 | - $this->_set_paging( $WP_Query ); |
|
300 | + $this->_set_paging($WP_Query); |
|
301 | 301 | |
302 | 302 | // is a taxonomy set ? |
303 | - if ( $WP_Query->is_tax ) { |
|
303 | + if ($WP_Query->is_tax) { |
|
304 | 304 | // loop thru our taxonomies |
305 | - foreach ( $this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details ) { |
|
305 | + foreach ($this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details) { |
|
306 | 306 | // check if one of our taxonomies is set as a query var |
307 | - if ( isset( $WP_Query->query[ $CPT_taxonomy ] )) { |
|
307 | + if (isset($WP_Query->query[$CPT_taxonomy])) { |
|
308 | 308 | // but which CPT does that correspond to??? hmmm... guess we gotta go looping |
309 | - foreach ( $this->_CPTs as $post_type => $CPT ) { |
|
309 | + foreach ($this->_CPTs as $post_type => $CPT) { |
|
310 | 310 | // verify our CPT has args, is public and has taxonomies set |
311 | - if ( isset( $CPT['args'] ) && $CPT['args']['public'] && ! empty( $CPT['args']['taxonomies'] )) { |
|
311 | + if (isset($CPT['args']) && $CPT['args']['public'] && ! empty($CPT['args']['taxonomies'])) { |
|
312 | 312 | // does the captured taxonomy belong to this CPT ? |
313 | - if ( in_array( $CPT_taxonomy, $CPT['args']['taxonomies'] )) { |
|
313 | + if (in_array($CPT_taxonomy, $CPT['args']['taxonomies'])) { |
|
314 | 314 | // if so, then add this CPT post_type to the current query's array of post_types' |
315 | - $WP_Query->query_vars['post_type'] = isset( $WP_Query->query_vars['post_type'] ) ? (array)$WP_Query->query_vars['post_type'] : array(); |
|
315 | + $WP_Query->query_vars['post_type'] = isset($WP_Query->query_vars['post_type']) ? (array) $WP_Query->query_vars['post_type'] : array(); |
|
316 | 316 | $WP_Query->query_vars['post_type'][] = $post_type; |
317 | - switch( $post_type ) { |
|
317 | + switch ($post_type) { |
|
318 | 318 | case 'espresso_events' : |
319 | 319 | $WP_Query->is_espresso_event_taxonomy = TRUE; |
320 | 320 | break; |
@@ -335,24 +335,24 @@ discard block |
||
335 | 335 | // d( $CPT_taxonomy ); |
336 | 336 | // d( $WP_Query ); |
337 | 337 | |
338 | - if ( isset( $WP_Query->query_vars['post_type'] )) { |
|
338 | + if (isset($WP_Query->query_vars['post_type'])) { |
|
339 | 339 | // loop thru post_types as array |
340 | - foreach ( (array)$WP_Query->query_vars['post_type'] as $post_type ) { |
|
340 | + foreach ((array) $WP_Query->query_vars['post_type'] as $post_type) { |
|
341 | 341 | |
342 | 342 | // is current query for an EE CPT ? |
343 | - if ( isset( $this->_CPTs[ $post_type ] )) { |
|
343 | + if (isset($this->_CPTs[$post_type])) { |
|
344 | 344 | // is EE on or off ? |
345 | - if ( EE_Maintenance_Mode::instance()->level() ) { |
|
345 | + if (EE_Maintenance_Mode::instance()->level()) { |
|
346 | 346 | // reroute CPT template view to maintenance_mode.template.php |
347 | - if( ! has_filter( 'template_include',array( 'EE_Maintenance_Mode', 'template_include' ))){ |
|
348 | - add_filter( 'template_include', array( 'EE_Maintenance_Mode', 'template_include' ), 99999 ); |
|
347 | + if ( ! has_filter('template_include', array('EE_Maintenance_Mode', 'template_include'))) { |
|
348 | + add_filter('template_include', array('EE_Maintenance_Mode', 'template_include'), 99999); |
|
349 | 349 | } |
350 | 350 | return; |
351 | 351 | } |
352 | 352 | // load EE_Request_Handler (this was added as a result of https://events.codebasehq.com/projects/event-espresso/tickets/9037 |
353 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
353 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
354 | 354 | // grab details for the CPT the current query is for |
355 | - $this->CPT = $this->_CPTs[ $post_type ]; |
|
355 | + $this->CPT = $this->_CPTs[$post_type]; |
|
356 | 356 | // set post type |
357 | 357 | $this->CPT['post_type'] = $post_type; |
358 | 358 | // set taxonomies |
@@ -360,27 +360,27 @@ discard block |
||
360 | 360 | // the post or category or term that is triggering EE |
361 | 361 | $this->CPT['espresso_page'] = EE_Registry::instance()->REQ->is_espresso_page(); |
362 | 362 | // requested post name |
363 | - $this->CPT['post_name'] = EE_Registry::instance()->REQ->get( 'post_name' ); |
|
363 | + $this->CPT['post_name'] = EE_Registry::instance()->REQ->get('post_name'); |
|
364 | 364 | //d( $this->CPT ); |
365 | 365 | // add support for viewing 'private', 'draft', or 'pending' posts |
366 | - if ( is_user_logged_in() && isset( $WP_Query->query_vars['p'] ) && $WP_Query->query_vars['p'] != 0 && current_user_can( 'edit_post', $WP_Query->query_vars['p'] )) { |
|
366 | + if (is_user_logged_in() && isset($WP_Query->query_vars['p']) && $WP_Query->query_vars['p'] != 0 && current_user_can('edit_post', $WP_Query->query_vars['p'])) { |
|
367 | 367 | // we can just inject directly into the WP_Query object |
368 | - $WP_Query->query['post_status'] = array( 'publish', 'private', 'draft', 'pending' ); |
|
368 | + $WP_Query->query['post_status'] = array('publish', 'private', 'draft', 'pending'); |
|
369 | 369 | // now set the main 'ee' request var so that the appropriate module can load the appropriate template(s) |
370 | - EE_Registry::instance()->REQ->set( 'ee', $this->CPT['singular_slug'] ); |
|
370 | + EE_Registry::instance()->REQ->set('ee', $this->CPT['singular_slug']); |
|
371 | 371 | } |
372 | - $this->_possibly_set_ee_request_var( $post_type ); |
|
372 | + $this->_possibly_set_ee_request_var($post_type); |
|
373 | 373 | // convert post_type to model name |
374 | - $model_name = str_replace( 'EE_', '', $this->CPT['class_name'] ); |
|
374 | + $model_name = str_replace('EE_', '', $this->CPT['class_name']); |
|
375 | 375 | // get CPT table data via CPT Model |
376 | - $this->CPT_model = EE_Registry::instance()->load_model( $model_name ); |
|
376 | + $this->CPT_model = EE_Registry::instance()->load_model($model_name); |
|
377 | 377 | $this->CPT['tables'] = $this->CPT_model->get_tables(); |
378 | 378 | // is there a Meta Table for this CPT? |
379 | - $this->CPT['meta_table'] = isset( $this->CPT['tables'][ $model_name . '_Meta' ] ) ? $this->CPT['tables'][ $model_name . '_Meta' ] : FALSE; |
|
379 | + $this->CPT['meta_table'] = isset($this->CPT['tables'][$model_name.'_Meta']) ? $this->CPT['tables'][$model_name.'_Meta'] : FALSE; |
|
380 | 380 | // creates classname like: CPT_Event_Strategy |
381 | - $CPT_Strategy_class_name = 'CPT_' . $model_name . '_Strategy'; |
|
381 | + $CPT_Strategy_class_name = 'CPT_'.$model_name.'_Strategy'; |
|
382 | 382 | // load and instantiate |
383 | - $CPT_Strategy = EE_Registry::instance()->load_core ( $CPT_Strategy_class_name, array( 'WP_Query' => $WP_Query, 'CPT' => $this->CPT )); |
|
383 | + $CPT_Strategy = EE_Registry::instance()->load_core($CPT_Strategy_class_name, array('WP_Query' => $WP_Query, 'CPT' => $this->CPT)); |
|
384 | 384 | |
385 | 385 | // !!!!!!!!!! IMPORTANT !!!!!!!!!!!! |
386 | 386 | // here's the list of available filters in the WP_Query object |
@@ -392,13 +392,13 @@ discard block |
||
392 | 392 | // 'post_limits' |
393 | 393 | // 'posts_fields' |
394 | 394 | // 'posts_join' |
395 | - add_filter( 'posts_fields', array( $this, 'posts_fields' )); |
|
396 | - add_filter( 'posts_join', array( $this, 'posts_join' )); |
|
397 | - add_filter( 'get_' . $this->CPT['post_type'] . '_metadata', array( $CPT_Strategy, 'get_EE_post_type_metadata' ), 1, 4 ); |
|
398 | - add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 1 ); |
|
399 | - add_filter( 'get_edit_post_link', array( $this, 'get_edit_post_link' ), 10, 2 ); |
|
395 | + add_filter('posts_fields', array($this, 'posts_fields')); |
|
396 | + add_filter('posts_join', array($this, 'posts_join')); |
|
397 | + add_filter('get_'.$this->CPT['post_type'].'_metadata', array($CPT_Strategy, 'get_EE_post_type_metadata'), 1, 4); |
|
398 | + add_filter('the_posts', array($this, 'the_posts'), 1, 1); |
|
399 | + add_filter('get_edit_post_link', array($this, 'get_edit_post_link'), 10, 2); |
|
400 | 400 | |
401 | - $this->_do_template_filters( $WP_Query ); |
|
401 | + $this->_do_template_filters($WP_Query); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | } |
@@ -413,13 +413,13 @@ discard block |
||
413 | 413 | * @param $SQL |
414 | 414 | * @return string |
415 | 415 | */ |
416 | - public function posts_fields( $SQL ) { |
|
416 | + public function posts_fields($SQL) { |
|
417 | 417 | // does this CPT have a meta table ? |
418 | - if ( ! empty( $this->CPT['meta_table'] )) { |
|
418 | + if ( ! empty($this->CPT['meta_table'])) { |
|
419 | 419 | // adds something like ", wp_esp_event_meta.* " to WP Query SELECT statement |
420 | - $SQL .= ', ' . $this->CPT['meta_table']->get_table_name() . '.* ' ; |
|
420 | + $SQL .= ', '.$this->CPT['meta_table']->get_table_name().'.* '; |
|
421 | 421 | } |
422 | - remove_filter( 'posts_fields', array( $this, 'posts_fields' )); |
|
422 | + remove_filter('posts_fields', array($this, 'posts_fields')); |
|
423 | 423 | return $SQL; |
424 | 424 | } |
425 | 425 | |
@@ -432,14 +432,14 @@ discard block |
||
432 | 432 | * @param $SQL |
433 | 433 | * @return string |
434 | 434 | */ |
435 | - public function posts_join( $SQL ) { |
|
435 | + public function posts_join($SQL) { |
|
436 | 436 | // does this CPT have a meta table ? |
437 | - if ( ! empty( $this->CPT['meta_table'] )) { |
|
437 | + if ( ! empty($this->CPT['meta_table'])) { |
|
438 | 438 | global $wpdb; |
439 | 439 | // adds something like " LEFT JOIN wp_esp_event_meta ON ( wp_esp_event_meta.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement |
440 | - $SQL .= ' LEFT JOIN ' . $this->CPT['meta_table']->get_table_name() . ' ON ( ' . $this->CPT['meta_table']->get_table_name() . '.' . $this->CPT['meta_table']->get_fk_on_table() . ' = ' . $wpdb->posts . '.ID ) '; |
|
440 | + $SQL .= ' LEFT JOIN '.$this->CPT['meta_table']->get_table_name().' ON ( '.$this->CPT['meta_table']->get_table_name().'.'.$this->CPT['meta_table']->get_fk_on_table().' = '.$wpdb->posts.'.ID ) '; |
|
441 | 441 | } |
442 | - remove_filter( 'posts_join', array( $this, 'posts_join' )); |
|
442 | + remove_filter('posts_join', array($this, 'posts_join')); |
|
443 | 443 | return $SQL; |
444 | 444 | } |
445 | 445 | |
@@ -452,18 +452,18 @@ discard block |
||
452 | 452 | * @param \WP_Post[] $posts |
453 | 453 | * @return \WP_Post[] |
454 | 454 | */ |
455 | - public function the_posts( $posts ) { |
|
455 | + public function the_posts($posts) { |
|
456 | 456 | // d( $posts ); |
457 | 457 | $CPT_class = $this->CPT['class_name']; |
458 | 458 | // loop thru posts |
459 | - if ( is_array( $posts )) { |
|
460 | - foreach( $posts as $key => $post ) { |
|
461 | - if ( isset( $this->_CPTs[ $post->post_type ] )) { |
|
462 | - $post->$CPT_class = $this->CPT_model->instantiate_class_from_post_object( $post ); |
|
459 | + if (is_array($posts)) { |
|
460 | + foreach ($posts as $key => $post) { |
|
461 | + if (isset($this->_CPTs[$post->post_type])) { |
|
462 | + $post->$CPT_class = $this->CPT_model->instantiate_class_from_post_object($post); |
|
463 | 463 | } |
464 | 464 | } |
465 | 465 | } |
466 | - remove_filter( 'the_posts', array( $this, 'the_posts' ), 1, 1 ); |
|
466 | + remove_filter('the_posts', array($this, 'the_posts'), 1, 1); |
|
467 | 467 | return $posts; |
468 | 468 | } |
469 | 469 | |
@@ -474,17 +474,17 @@ discard block |
||
474 | 474 | * @param $ID |
475 | 475 | * @return string |
476 | 476 | */ |
477 | - function get_edit_post_link( $url, $ID ) { |
|
477 | + function get_edit_post_link($url, $ID) { |
|
478 | 478 | //need to make sure we only edit links if our cpt |
479 | 479 | global $post; |
480 | - if ( ! isset( $this->_CPTs[ $post->post_type ] )) { |
|
480 | + if ( ! isset($this->_CPTs[$post->post_type])) { |
|
481 | 481 | return $url; |
482 | 482 | } |
483 | 483 | //k made it here so all is good. |
484 | 484 | $scheme = is_ssl() ? 'https' : 'http'; |
485 | - $url = get_admin_url( EE_Config::instance()->core->current_blog_id, 'admin.php', $scheme ); |
|
485 | + $url = get_admin_url(EE_Config::instance()->core->current_blog_id, 'admin.php', $scheme); |
|
486 | 486 | // http://example.com/wp-admin/admin.php?page=espresso_events&action=edit&post=205&edit_nonce=0d403530d6 |
487 | - return wp_nonce_url( add_query_arg( array( 'page' => $this->CPT['post_type'], 'post' =>$ID, 'action' =>'edit' ), $url ), 'edit', 'edit_nonce' ); |
|
487 | + return wp_nonce_url(add_query_arg(array('page' => $this->CPT['post_type'], 'post' =>$ID, 'action' =>'edit'), $url), 'edit', 'edit_nonce'); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | |
@@ -498,11 +498,11 @@ discard block |
||
498 | 498 | * @param WP_Query $WP_Query |
499 | 499 | * @return void |
500 | 500 | */ |
501 | - protected function _do_template_filters( WP_Query $WP_Query ) { |
|
501 | + protected function _do_template_filters(WP_Query $WP_Query) { |
|
502 | 502 | // if it's the main query and requested cpt supports page_templates, |
503 | - if ( $WP_Query->is_main_query() && ! empty( $this->CPT['args']['page_templates'] ) ) { |
|
503 | + if ($WP_Query->is_main_query() && ! empty($this->CPT['args']['page_templates'])) { |
|
504 | 504 | // then let's hook into the appropriate query_template hook |
505 | - add_filter( 'single_template', array( $this, 'single_cpt_template' ) ); |
|
505 | + add_filter('single_template', array($this, 'single_cpt_template')); |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
@@ -516,17 +516,17 @@ discard block |
||
516 | 516 | * @param string $current_template Existing default template path derived for this page call. |
517 | 517 | * @return string the path to the full template file. |
518 | 518 | */ |
519 | - public function single_cpt_template( $current_template ) { |
|
519 | + public function single_cpt_template($current_template) { |
|
520 | 520 | $object = get_queried_object(); |
521 | 521 | //does this called object HAVE a page template set that is something other than the default. |
522 | - $template = get_post_meta( $object->ID, '_wp_page_template', true ); |
|
522 | + $template = get_post_meta($object->ID, '_wp_page_template', true); |
|
523 | 523 | |
524 | 524 | //exit early if default or not set or invalid path (accounts for theme changes) |
525 | - if ( $template == 'default' || empty( $template ) || ! is_readable( get_stylesheet_directory() . '/' . $template ) ) { |
|
525 | + if ($template == 'default' || empty($template) || ! is_readable(get_stylesheet_directory().'/'.$template)) { |
|
526 | 526 | return $current_template; |
527 | 527 | } |
528 | 528 | //made it here so we SHOULD be able to just locate the template and then return it. |
529 | - $template = locate_template( array($template) ); |
|
529 | + $template = locate_template(array($template)); |
|
530 | 530 | |
531 | 531 | return $template; |
532 | 532 | } |
@@ -574,9 +574,9 @@ discard block |
||
574 | 574 | * @param array $arguments |
575 | 575 | * @return \EE_CPT_Default_Strategy |
576 | 576 | */ |
577 | - public function __construct( $arguments = array() ) { |
|
578 | - $this->CPT = isset( $arguments['CPT'] ) ? $arguments['CPT'] : NULL; |
|
579 | - $WP_Query = isset( $arguments['WP_Query'] ) ? $arguments['WP_Query'] : NULL; |
|
577 | + public function __construct($arguments = array()) { |
|
578 | + $this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : NULL; |
|
579 | + $WP_Query = isset($arguments['WP_Query']) ? $arguments['WP_Query'] : NULL; |
|
580 | 580 | //EEH_Debug_Tools::printr( $this->CPT, '$this->CPT <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
581 | 581 | // add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ), 999 ); |
582 | 582 | // add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 ); |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | * @param \WP_Query $WP_Query |
592 | 592 | * @return \WP_Query |
593 | 593 | */ |
594 | - public function pre_get_posts( WP_Query $WP_Query ) { |
|
594 | + public function pre_get_posts(WP_Query $WP_Query) { |
|
595 | 595 | //EEH_Debug_Tools::printr( $WP_Query, '$WP_Query <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
596 | - if ( ! $WP_Query->is_main_query() && ! $WP_Query->is_archive() ) { |
|
596 | + if ( ! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
597 | 597 | return $WP_Query; |
598 | 598 | } |
599 | 599 | // $WP_Query->set( 'post_type', array( $this->CPT['post_type'] )); |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | * @param \WP_Query $WP_Query |
612 | 612 | * @return \WP_Post[] |
613 | 613 | */ |
614 | - public function the_posts( $posts, WP_Query $WP_Query ) { |
|
614 | + public function the_posts($posts, WP_Query $WP_Query) { |
|
615 | 615 | return $posts; |
616 | 616 | } |
617 | 617 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * @param string $single |
628 | 628 | * @return mixed |
629 | 629 | */ |
630 | - public function get_EE_post_type_metadata( $meta_value = NULL, $post_id, $meta_key, $single ) { |
|
630 | + public function get_EE_post_type_metadata($meta_value = NULL, $post_id, $meta_key, $single) { |
|
631 | 631 | return $meta_value; |
632 | 632 | } |
633 | 633 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | |
43 | 43 | public function __construct() { |
44 | 44 | // construct request stack and run middleware apps as soon as all WP plugins are loaded |
45 | - add_action( 'plugins_loaded', array( $this, 'run_request_stack' ), 0 ); |
|
45 | + add_action('plugins_loaded', array($this, 'run_request_stack'), 0); |
|
46 | 46 | // set framework for the rest of EE to hook into when loading |
47 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_espresso_addons' ), 1 ); |
|
48 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'detect_activations_or_upgrades' ), 3 ); |
|
49 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_core_configuration' ), 5 ); |
|
50 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
51 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'brew_espresso' ), 9 ); |
|
47 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
|
48 | + add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
|
49 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5); |
|
50 | + add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7); |
|
51 | + add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | new EE_Load_Espresso_Core() |
66 | 66 | ); |
67 | 67 | $this->_request_stack->handle_request( |
68 | - new EE_Request( $_REQUEST ), |
|
68 | + new EE_Request($_REQUEST), |
|
69 | 69 | new EE_Response() |
70 | 70 | ); |
71 | 71 | $this->_request_stack->handle_response(); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | protected function load_autoloader() { |
80 | 80 | // load interfaces |
81 | - espresso_load_required( 'EEH_Autoloader', EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' ); |
|
81 | + espresso_load_required('EEH_Autoloader', EE_CORE.'helpers'.DS.'EEH_Autoloader.helper.php'); |
|
82 | 82 | EEH_Autoloader::instance(); |
83 | 83 | } |
84 | 84 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function set_autoloaders_for_required_files() { |
91 | 91 | // load interfaces |
92 | - espresso_load_required( 'EEI_Interfaces', EE_CORE . 'interfaces' . DS . 'EEI_Interfaces.php' ); |
|
92 | + espresso_load_required('EEI_Interfaces', EE_CORE.'interfaces'.DS.'EEI_Interfaces.php'); |
|
93 | 93 | // load helpers |
94 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_HELPERS ); |
|
94 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
95 | 95 | // load request stack |
96 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'request_stack' . DS ); |
|
96 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack'.DS); |
|
97 | 97 | // load middleware |
98 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'middleware' . DS ); |
|
98 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware'.DS); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | ) |
119 | 119 | ); |
120 | 120 | // load middleware onto stack : FILO (First In Last Out) |
121 | - foreach ( (array)$stack_apps as $stack_app ) { |
|
121 | + foreach ((array) $stack_apps as $stack_app) { |
|
122 | 122 | //$request_stack_builder->push( $stack_app ); |
123 | - $request_stack_builder->unshift( $stack_app ); |
|
123 | + $request_stack_builder->unshift($stack_app); |
|
124 | 124 | } |
125 | 125 | return apply_filters( |
126 | 126 | 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * no other logic should be performed at this point |
138 | 138 | */ |
139 | 139 | public static function load_espresso_addons() { |
140 | - do_action( 'AHEE__EE_Bootstrap__load_espresso_addons' ); |
|
140 | + do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * we can determine if anything needs activating or upgrading |
150 | 150 | */ |
151 | 151 | public static function detect_activations_or_upgrades() { |
152 | - do_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' ); |
|
152 | + do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * we can load and set all of the system configurations |
162 | 162 | */ |
163 | 163 | public static function load_core_configuration() { |
164 | - do_action( 'AHEE__EE_Bootstrap__load_core_configuration' ); |
|
164 | + do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * so that they are ready to be used throughout the system |
174 | 174 | */ |
175 | 175 | public static function register_shortcodes_modules_and_widgets() { |
176 | - do_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' ); |
|
176 | + do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * so let the fun begin... |
186 | 186 | */ |
187 | 187 | public static function brew_espresso() { |
188 | - do_action( 'AHEE__EE_Bootstrap__brew_espresso' ); |
|
188 | + do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param EE_Response $response |
51 | 51 | * @return EE_Response |
52 | 52 | */ |
53 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
53 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
54 | 54 | $this->request = $request; |
55 | 55 | $this->response = $response; |
56 | 56 | // central repository for classes |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | // workarounds for PHP < 5.3 |
59 | 59 | $this->_load_class_tools(); |
60 | 60 | // PSR4 Autoloaders |
61 | - EE_Registry::instance()->load_core( 'EE_Psr4AutoloaderInit' ); |
|
61 | + EE_Registry::instance()->load_core('EE_Psr4AutoloaderInit'); |
|
62 | 62 | // deprecated functions |
63 | - espresso_load_required( 'EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php' ); |
|
63 | + espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php'); |
|
64 | 64 | // load interfaces |
65 | - espresso_load_required( 'EEI_Payment_Method_Interfaces', EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php' ); |
|
65 | + espresso_load_required('EEI_Payment_Method_Interfaces', EE_LIBRARIES.'payment_methods'.DS.'EEI_Payment_Method_Interfaces.php'); |
|
66 | 66 | //// WP cron jobs |
67 | - EE_Registry::instance()->load_core( 'Cron_Tasks' ); |
|
68 | - EE_Registry::instance()->load_core( 'EE_System' ); |
|
67 | + EE_Registry::instance()->load_core('Cron_Tasks'); |
|
68 | + EE_Registry::instance()->load_core('EE_System'); |
|
69 | 69 | |
70 | 70 | return $this->response; |
71 | 71 | } |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | */ |
81 | 81 | private function _load_registry() { |
82 | - if ( is_readable( EE_CORE . 'EE_Registry.core.php' )) { |
|
83 | - require_once( EE_CORE . 'EE_Registry.core.php' ); |
|
82 | + if (is_readable(EE_CORE.'EE_Registry.core.php')) { |
|
83 | + require_once(EE_CORE.'EE_Registry.core.php'); |
|
84 | 84 | } else { |
85 | - $msg = __( 'The EE_Registry core class could not be loaded.', 'event_espresso' ); |
|
86 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
87 | - wp_die( EE_Error::get_notices() ); |
|
85 | + $msg = __('The EE_Registry core class could not be loaded.', 'event_espresso'); |
|
86 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
87 | + wp_die(EE_Error::get_notices()); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | * @return void |
97 | 97 | */ |
98 | 98 | private function _load_class_tools() { |
99 | - if ( is_readable( EE_HELPERS . 'EEH_Class_Tools.helper.php' )) { |
|
100 | - require_once( EE_HELPERS . 'EEH_Class_Tools.helper.php' ); |
|
99 | + if (is_readable(EE_HELPERS.'EEH_Class_Tools.helper.php')) { |
|
100 | + require_once(EE_HELPERS.'EEH_Class_Tools.helper.php'); |
|
101 | 101 | } else { |
102 | - $msg = __( 'The EEH_Class_Tools helper could not be loaded.', 'event_espresso' ); |
|
103 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
102 | + $msg = __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'); |
|
103 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param \EE_Request $request |
116 | 116 | * @param \EE_Response $response |
117 | 117 | */ |
118 | - public function handle_response( EE_Request $request, EE_Response $response ) { |
|
118 | + public function handle_response(EE_Request $request, EE_Response $response) { |
|
119 | 119 | //EEH_Debug_Tools::printr( $request, '$request', __FILE__, __LINE__ ); |
120 | 120 | //EEH_Debug_Tools::printr( $response, '$response', __FILE__, __LINE__ ); |
121 | 121 | //die(); |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * |
4 | 6 | * EE_Load_Espresso_Core |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public static function instance() { |
158 | 158 | // check if class object is instantiated |
159 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Registry )) { |
|
159 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Registry)) { |
|
160 | 160 | self::$_instance = new self(); |
161 | 161 | } |
162 | 162 | return self::$_instance; |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | * @return EE_Registry |
172 | 172 | */ |
173 | 173 | private function __construct() { |
174 | - $this->load_core( 'Base' ); |
|
174 | + $this->load_core('Base'); |
|
175 | 175 | // class library |
176 | 176 | $this->LIB = new StdClass(); |
177 | 177 | $this->addons = new StdClass(); |
178 | 178 | $this->modules = new StdClass(); |
179 | 179 | $this->shortcodes = new StdClass(); |
180 | 180 | $this->widgets = new StdClass(); |
181 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' )); |
|
181 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function init() { |
193 | 193 | // Get current page protocol |
194 | - $protocol = isset( $_SERVER['HTTPS'] ) ? 'https://' : 'http://'; |
|
194 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
195 | 195 | // Output admin-ajax.php URL with same protocol as current page |
196 | - self::$i18n_js_strings['ajax_url'] = admin_url( 'admin-ajax.php', $protocol ); |
|
197 | - self::$i18n_js_strings['wp_debug'] = defined( 'WP_DEBUG' ) ? WP_DEBUG : FALSE; |
|
196 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
197 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : FALSE; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | * @return string |
206 | 206 | */ |
207 | 207 | public static function localize_i18n_js_strings() { |
208 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
209 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
210 | - if ( is_scalar( $value ) ) { |
|
211 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
208 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
209 | + foreach ($i18n_js_strings as $key => $value) { |
|
210 | + if (is_scalar($value)) { |
|
211 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
215 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | /** |
221 | 221 | * @param mixed string | EED_Module $module |
222 | 222 | */ |
223 | - public function add_module( $module ) { |
|
224 | - if ( $module instanceof EED_Module ) { |
|
225 | - $module_class = get_class( $module ); |
|
223 | + public function add_module($module) { |
|
224 | + if ($module instanceof EED_Module) { |
|
225 | + $module_class = get_class($module); |
|
226 | 226 | $this->modules->{$module_class} = $module; |
227 | 227 | } else { |
228 | - if ( ! class_exists( 'EE_Module_Request_Router' )) { |
|
229 | - $this->load_core( 'Module_Request_Router' ); |
|
228 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
229 | + $this->load_core('Module_Request_Router'); |
|
230 | 230 | } |
231 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
231 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | * @param string $module_name |
239 | 239 | * @return mixed EED_Module | NULL |
240 | 240 | */ |
241 | - public function get_module( $module_name = '' ) { |
|
242 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : NULL; |
|
241 | + public function get_module($module_name = '') { |
|
242 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : NULL; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
@@ -252,18 +252,18 @@ discard block |
||
252 | 252 | * @param bool $load_only |
253 | 253 | * @return mixed |
254 | 254 | */ |
255 | - public function load_core ( $class_name, $arguments = array(), $load_only = FALSE ) { |
|
255 | + public function load_core($class_name, $arguments = array(), $load_only = FALSE) { |
|
256 | 256 | $core_paths = apply_filters( |
257 | 257 | 'FHEE__EE_Registry__load_core__core_paths', |
258 | 258 | array( |
259 | 259 | EE_CORE, |
260 | 260 | EE_ADMIN, |
261 | 261 | EE_CPTS, |
262 | - EE_CORE . 'data_migration_scripts' . DS |
|
262 | + EE_CORE.'data_migration_scripts'.DS |
|
263 | 263 | ) |
264 | 264 | ); |
265 | 265 | // retrieve instantiated class |
266 | - return $this->_load( $core_paths, 'EE_' , $class_name, 'core', $arguments, FALSE, TRUE, $load_only ); |
|
266 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, FALSE, TRUE, $load_only); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | * @param mixed $arguments |
277 | 277 | * @return EE_Data_Migration_Script_Base |
278 | 278 | */ |
279 | - public function load_dms ( $class_name, $arguments = array() ) { |
|
279 | + public function load_dms($class_name, $arguments = array()) { |
|
280 | 280 | // retrieve instantiated class |
281 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_' , $class_name, 'dms', $arguments, FALSE, FALSE, FALSE ); |
|
281 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, FALSE, FALSE, FALSE); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
294 | 294 | * @return EE_Base_Class |
295 | 295 | */ |
296 | - public function load_class ( $class_name, $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE ) { |
|
297 | - $paths = apply_filters('FHEE__EE_Registry__load_class__paths',array( |
|
296 | + public function load_class($class_name, $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE) { |
|
297 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
298 | 298 | EE_CORE, |
299 | 299 | EE_CLASSES, |
300 | 300 | EE_BUSINESS |
301 | 301 | )); |
302 | 302 | // retrieve instantiated class |
303 | - return $this->_load( $paths, 'EE_' , $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
303 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | * @param bool $load_only |
315 | 315 | * @return EEH_Base |
316 | 316 | */ |
317 | - public function load_helper ( $class_name, $arguments = array(), $load_only = TRUE ) { |
|
318 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS ) ); |
|
317 | + public function load_helper($class_name, $arguments = array(), $load_only = TRUE) { |
|
318 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
319 | 319 | // retrieve instantiated class |
320 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, FALSE, TRUE, $load_only ); |
|
320 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, FALSE, TRUE, $load_only); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | |
@@ -331,16 +331,16 @@ discard block |
||
331 | 331 | * @param bool $load_only |
332 | 332 | * @return mixed |
333 | 333 | */ |
334 | - public function load_lib ( $class_name, $arguments = array(), $load_only = FALSE ) { |
|
334 | + public function load_lib($class_name, $arguments = array(), $load_only = FALSE) { |
|
335 | 335 | $paths = array( |
336 | 336 | EE_LIBRARIES, |
337 | - EE_LIBRARIES . 'messages' . DS, |
|
338 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
339 | - EE_LIBRARIES . 'qtips' . DS, |
|
340 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
337 | + EE_LIBRARIES.'messages'.DS, |
|
338 | + EE_LIBRARIES.'shortcodes'.DS, |
|
339 | + EE_LIBRARIES.'qtips'.DS, |
|
340 | + EE_LIBRARIES.'payment_methods'.DS, |
|
341 | 341 | ); |
342 | 342 | // retrieve instantiated class |
343 | - return $this->_load( $paths, 'EE_' , $class_name, 'lib', $arguments, FALSE, TRUE, $load_only ); |
|
343 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, FALSE, TRUE, $load_only); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -353,13 +353,13 @@ discard block |
||
353 | 353 | * @param bool $load_only |
354 | 354 | * @return EEM_Base |
355 | 355 | */ |
356 | - public function load_model ( $class_name, $arguments = array(), $load_only = FALSE ) { |
|
357 | - $paths = apply_filters('FHEE__EE_Registry__load_model__paths',array( |
|
356 | + public function load_model($class_name, $arguments = array(), $load_only = FALSE) { |
|
357 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
358 | 358 | EE_MODELS, |
359 | 359 | EE_CORE |
360 | 360 | )); |
361 | 361 | // retrieve instantiated class |
362 | - return $this->_load( $paths, 'EEM_' , $class_name, 'model', $arguments, FALSE, TRUE, $load_only ); |
|
362 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, FALSE, TRUE, $load_only); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -372,15 +372,15 @@ discard block |
||
372 | 372 | * @param bool $load_only |
373 | 373 | * @return mixed |
374 | 374 | */ |
375 | - public function load_model_class ( $class_name, $arguments = array(), $load_only = TRUE ) { |
|
375 | + public function load_model_class($class_name, $arguments = array(), $load_only = TRUE) { |
|
376 | 376 | $paths = array( |
377 | - EE_MODELS . 'fields' . DS, |
|
378 | - EE_MODELS . 'helpers' . DS, |
|
379 | - EE_MODELS . 'relations' . DS, |
|
380 | - EE_MODELS . 'strategies' . DS |
|
377 | + EE_MODELS.'fields'.DS, |
|
378 | + EE_MODELS.'helpers'.DS, |
|
379 | + EE_MODELS.'relations'.DS, |
|
380 | + EE_MODELS.'strategies'.DS |
|
381 | 381 | ); |
382 | 382 | // retrieve instantiated class |
383 | - return $this->_load( $paths, 'EE_' , $class_name, '', $arguments, FALSE, TRUE, $load_only ); |
|
383 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, FALSE, TRUE, $load_only); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
393 | 393 | * @return boolean |
394 | 394 | */ |
395 | - public function is_model_name( $model_name ){ |
|
396 | - return isset( $this->models[ $model_name ] ) ? TRUE : FALSE; |
|
395 | + public function is_model_name($model_name) { |
|
396 | + return isset($this->models[$model_name]) ? TRUE : FALSE; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -408,9 +408,9 @@ discard block |
||
408 | 408 | * @param bool $load_only |
409 | 409 | * @return mixed |
410 | 410 | */ |
411 | - public function load_file ( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = TRUE ) { |
|
411 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = TRUE) { |
|
412 | 412 | // retrieve instantiated class |
413 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, FALSE, TRUE, $load_only ); |
|
413 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, FALSE, TRUE, $load_only); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | |
@@ -425,9 +425,9 @@ discard block |
||
425 | 425 | * @param bool $load_only |
426 | 426 | * @return EE_Addon |
427 | 427 | */ |
428 | - public function load_addon ( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = FALSE ) { |
|
428 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = FALSE) { |
|
429 | 429 | // retrieve instantiated class |
430 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, FALSE, TRUE, $load_only ); |
|
430 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, FALSE, TRUE, $load_only); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | |
@@ -445,15 +445,15 @@ discard block |
||
445 | 445 | * @internal param string $file_path - file path including file name |
446 | 446 | * @return bool | object |
447 | 447 | */ |
448 | - private function _load ( $file_paths = array(), $class_prefix = 'EE_', $class_name = FALSE, $type = 'class', $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE ) { |
|
448 | + private function _load($file_paths = array(), $class_prefix = 'EE_', $class_name = FALSE, $type = 'class', $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE) { |
|
449 | 449 | // strip php file extension |
450 | - $class_name = str_replace( '.php', '', trim( $class_name )); |
|
450 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
451 | 451 | // does the class have a prefix ? |
452 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
452 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
453 | 453 | // make sure $class_prefix is uppercase |
454 | - $class_prefix = strtoupper( trim( $class_prefix )); |
|
454 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
455 | 455 | // add class prefix ONCE!!! |
456 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
456 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $class_abbreviations = array( |
@@ -466,56 +466,56 @@ discard block |
||
466 | 466 | ); |
467 | 467 | |
468 | 468 | // check if class has already been loaded, and return it if it has been |
469 | - if ( isset( $class_abbreviations[ $class_name ] ) && ! is_null( $this->$class_abbreviations[ $class_name ] )) { |
|
470 | - return $this->$class_abbreviations[ $class_name ]; |
|
471 | - } else if ( isset ( $this->{$class_name} )) { |
|
469 | + if (isset($class_abbreviations[$class_name]) && ! is_null($this->$class_abbreviations[$class_name])) { |
|
470 | + return $this->$class_abbreviations[$class_name]; |
|
471 | + } else if (isset ($this->{$class_name} )) { |
|
472 | 472 | return $this->{$class_name}; |
473 | - } else if ( isset ( $this->LIB->$class_name )) { |
|
473 | + } else if (isset ($this->LIB->$class_name)) { |
|
474 | 474 | return $this->LIB->$class_name; |
475 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->$class_name )) { |
|
475 | + } else if ($class_prefix == 'addon' && isset ($this->addons->$class_name)) { |
|
476 | 476 | return $this->addons->$class_name; |
477 | 477 | } |
478 | 478 | |
479 | 479 | // assume all paths lead nowhere |
480 | 480 | $path = FALSE; |
481 | 481 | // make sure $file_paths is an array |
482 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
482 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
483 | 483 | // cycle thru paths |
484 | - foreach ( $file_paths as $key => $file_path ) { |
|
484 | + foreach ($file_paths as $key => $file_path) { |
|
485 | 485 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
486 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
486 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
487 | 487 | // prep file type |
488 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
488 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
489 | 489 | // build full file path |
490 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
490 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
491 | 491 | //does the file exist and can be read ? |
492 | - if ( is_readable( $file_paths[ $key ] )) { |
|
493 | - $path = $file_paths[ $key ]; |
|
492 | + if (is_readable($file_paths[$key])) { |
|
493 | + $path = $file_paths[$key]; |
|
494 | 494 | break; |
495 | 495 | } |
496 | 496 | } |
497 | 497 | // don't give up! you gotta... |
498 | 498 | try { |
499 | 499 | //does the file exist and can it be read ? |
500 | - if ( ! $path ) { |
|
500 | + if ( ! $path) { |
|
501 | 501 | // so sorry, can't find the file |
502 | - throw new EE_Error ( |
|
503 | - sprintf ( |
|
504 | - __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s','event_espresso'), |
|
505 | - trim( $type, '.' ), |
|
502 | + throw new EE_Error( |
|
503 | + sprintf( |
|
504 | + __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'), |
|
505 | + trim($type, '.'), |
|
506 | 506 | $class_name, |
507 | - '<br />' . implode( ',<br />', $file_paths ) |
|
507 | + '<br />'.implode(',<br />', $file_paths) |
|
508 | 508 | ) |
509 | 509 | ); |
510 | 510 | } |
511 | 511 | // get the file |
512 | - require_once( $path ); |
|
512 | + require_once($path); |
|
513 | 513 | // if the class isn't already declared somewhere |
514 | - if ( class_exists( $class_name, FALSE ) === FALSE ) { |
|
514 | + if (class_exists($class_name, FALSE) === FALSE) { |
|
515 | 515 | // so sorry, not a class |
516 | 516 | throw new EE_Error( |
517 | 517 | sprintf( |
518 | - __('The %s file %s does not appear to contain the %s Class.','event_espresso'), |
|
518 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
519 | 519 | $type, |
520 | 520 | $path, |
521 | 521 | $class_name |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | ); |
524 | 524 | } |
525 | 525 | |
526 | - } catch ( EE_Error $e ) { |
|
526 | + } catch (EE_Error $e) { |
|
527 | 527 | $e->get_error(); |
528 | 528 | } |
529 | 529 | |
@@ -531,38 +531,38 @@ discard block |
||
531 | 531 | // don't give up! you gotta... |
532 | 532 | try { |
533 | 533 | // create reflection |
534 | - $reflector = new ReflectionClass( $class_name ); |
|
534 | + $reflector = new ReflectionClass($class_name); |
|
535 | 535 | // instantiate the class and add to the LIB array for tracking |
536 | 536 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
537 | - if ( $reflector->getConstructor() === NULL || $reflector->isAbstract() || $load_only ) { |
|
537 | + if ($reflector->getConstructor() === NULL || $reflector->isAbstract() || $load_only) { |
|
538 | 538 | // $instantiation_mode = 0; |
539 | 539 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
540 | 540 | return TRUE; |
541 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
541 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
542 | 542 | // $instantiation_mode = 1; |
543 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
544 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
543 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
544 | + } else if (method_exists($class_name, 'new_instance')) { |
|
545 | 545 | // $instantiation_mode = 2; |
546 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
547 | - } else if ( method_exists( $class_name, 'instance' )) { |
|
546 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
547 | + } else if (method_exists($class_name, 'instance')) { |
|
548 | 548 | // $instantiation_mode = 3; |
549 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
550 | - } else if ( $reflector->isInstantiable() ) { |
|
549 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
550 | + } else if ($reflector->isInstantiable()) { |
|
551 | 551 | // $instantiation_mode = 4; |
552 | - $class_obj = $reflector->newInstance( $arguments ); |
|
553 | - } else if ( ! $load_only ) { |
|
552 | + $class_obj = $reflector->newInstance($arguments); |
|
553 | + } else if ( ! $load_only) { |
|
554 | 554 | // heh ? something's not right ! |
555 | 555 | // $instantiation_mode = 5; |
556 | 556 | throw new EE_Error( |
557 | 557 | sprintf( |
558 | - __('The %s file %s could not be instantiated.','event_espresso'), |
|
558 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
559 | 559 | $type, |
560 | 560 | $class_name |
561 | 561 | ) |
562 | 562 | ); |
563 | 563 | } |
564 | 564 | |
565 | - } catch ( EE_Error $e ) { |
|
565 | + } catch (EE_Error $e) { |
|
566 | 566 | $e->get_error(); |
567 | 567 | } |
568 | 568 | |
@@ -574,15 +574,15 @@ discard block |
||
574 | 574 | // EEH_Debug_Tools::printr( $class_obj, '$class_obj <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
575 | 575 | |
576 | 576 | |
577 | - if ( isset( $class_obj )) { |
|
577 | + if (isset($class_obj)) { |
|
578 | 578 | // return newly instantiated class |
579 | - if ( isset( $class_abbreviations[ $class_name ] )) { |
|
580 | - $this->$class_abbreviations[ $class_name ] = $class_obj; |
|
581 | - } else if ( EEH_Class_Tools::has_property( $this, $class_name )) { |
|
579 | + if (isset($class_abbreviations[$class_name])) { |
|
580 | + $this->$class_abbreviations[$class_name] = $class_obj; |
|
581 | + } else if (EEH_Class_Tools::has_property($this, $class_name)) { |
|
582 | 582 | $this->{$class_name} = $class_obj; |
583 | - } else if ( $class_prefix == 'addon' && $cache ) { |
|
583 | + } else if ($class_prefix == 'addon' && $cache) { |
|
584 | 584 | $this->addons->$class_name = $class_obj; |
585 | - } else if ( !$from_db && $cache ) { |
|
585 | + } else if ( ! $from_db && $cache) { |
|
586 | 586 | $this->LIB->$class_name = $class_obj; |
587 | 587 | } |
588 | 588 | return $class_obj; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * @param $a |
608 | 608 | * @param $b |
609 | 609 | */ |
610 | - final function __call($a,$b) {} |
|
610 | + final function __call($a, $b) {} |
|
611 | 611 | |
612 | 612 | |
613 | 613 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * @param $a |
623 | 623 | * @param $b |
624 | 624 | */ |
625 | - final function __set($a,$b) {} |
|
625 | + final function __set($a, $b) {} |
|
626 | 626 | |
627 | 627 | |
628 | 628 | |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * @param $a |
663 | 663 | * @param $b |
664 | 664 | */ |
665 | - final static function __callStatic($a,$b) {} |
|
665 | + final static function __callStatic($a, $b) {} |
|
666 | 666 | |
667 | 667 | /** |
668 | 668 | * Gets the addon by its name/slug (not classname. For that, just |
@@ -670,9 +670,9 @@ discard block |
||
670 | 670 | * @param string $name |
671 | 671 | * @return EE_Addon |
672 | 672 | */ |
673 | - public function get_addon_by_name( $name ){ |
|
674 | - foreach($this->addons as $addon){ |
|
675 | - if( $addon->name() == $name){ |
|
673 | + public function get_addon_by_name($name) { |
|
674 | + foreach ($this->addons as $addon) { |
|
675 | + if ($addon->name() == $name) { |
|
676 | 676 | return $addon; |
677 | 677 | } |
678 | 678 | } |
@@ -683,10 +683,10 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @return EE_Addon[] where the KEYS are the addon's name() |
685 | 685 | */ |
686 | - public function get_addons_by_name(){ |
|
686 | + public function get_addons_by_name() { |
|
687 | 687 | $addons = array(); |
688 | - foreach($this->addons as $addon){ |
|
689 | - $addons[ $addon->name() ] = $addon; |
|
688 | + foreach ($this->addons as $addon) { |
|
689 | + $addons[$addon->name()] = $addon; |
|
690 | 690 | } |
691 | 691 | return $addons; |
692 | 692 | } |
@@ -701,14 +701,14 @@ discard block |
||
701 | 701 | * @return EEM_Base |
702 | 702 | * @throws EE_Error |
703 | 703 | */ |
704 | - public function reset_model( $model_name ){ |
|
705 | - $model = $this->load_model( $model_name ); |
|
706 | - $model_class_name = get_class( $model ); |
|
704 | + public function reset_model($model_name) { |
|
705 | + $model = $this->load_model($model_name); |
|
706 | + $model_class_name = get_class($model); |
|
707 | 707 | //get that model reset it and make sure we nuke the old reference to it |
708 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
708 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
709 | 709 | $this->LIB->$model_class_name = $model::reset(); |
710 | - }else{ |
|
711 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
710 | + } else { |
|
711 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
712 | 712 | } |
713 | 713 | return $this->LIB->$model_class_name; |
714 | 714 | } |
@@ -724,15 +724,15 @@ discard block |
||
724 | 724 | * currently reinstantiate the singletons at the moment) |
725 | 725 | * @return EE_Registry |
726 | 726 | */ |
727 | - public static function reset( $hard = FALSE, $reinstantiate = TRUE ){ |
|
727 | + public static function reset($hard = FALSE, $reinstantiate = TRUE) { |
|
728 | 728 | $instance = self::instance(); |
729 | 729 | $instance->load_helper('Activation'); |
730 | 730 | EEH_Activation::reset(); |
731 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
731 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
732 | 732 | $instance->LIB->EE_Data_Migration_Manager = EE_Data_Migration_Manager::reset(); |
733 | 733 | $instance->LIB = new stdClass(); |
734 | - foreach( array_keys( $instance->non_abstract_db_models ) as $model_name ){ |
|
735 | - $instance->reset_model( $model_name ); |
|
734 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
735 | + $instance->reset_model($model_name); |
|
736 | 736 | } |
737 | 737 | return $instance; |
738 | 738 | } |
@@ -743,9 +743,9 @@ discard block |
||
743 | 743 | */ |
744 | 744 | public function cpt_models() { |
745 | 745 | $cpt_models = array(); |
746 | - foreach( $this->non_abstract_db_models as $shortname => $classname ) { |
|
747 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
748 | - $cpt_models[ $shortname ] = $classname; |
|
746 | + foreach ($this->non_abstract_db_models as $shortname => $classname) { |
|
747 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
748 | + $cpt_models[$shortname] = $classname; |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | return $cpt_models; |
@@ -707,7 +707,7 @@ |
||
707 | 707 | //get that model reset it and make sure we nuke the old reference to it |
708 | 708 | if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
709 | 709 | $this->LIB->$model_class_name = $model::reset(); |
710 | - }else{ |
|
710 | + } else{ |
|
711 | 711 | throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
712 | 712 | } |
713 | 713 | return $this->LIB->$model_class_name; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * ------------------------------------------------------------------------ |
11 | 11 | */ |
12 | -class EEH_URL{ |
|
12 | +class EEH_URL { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * _add_query_arg |
@@ -21,28 +21,28 @@ discard block |
||
21 | 21 | * @param bool $exclude_nonce If true then the nonce will be excluded from the generated url. |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - public static function add_query_args_and_nonce( $args = array(), $url = '', $exclude_nonce = false ) { |
|
25 | - if ( empty( $url ) ) { |
|
26 | - $user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso' ); |
|
27 | - $dev_msg = $user_msg . "\n" . sprintf( |
|
28 | - __('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso' ), |
|
24 | + public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false) { |
|
25 | + if (empty($url)) { |
|
26 | + $user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso'); |
|
27 | + $dev_msg = $user_msg."\n".sprintf( |
|
28 | + __('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso'), |
|
29 | 29 | __CLASS__ |
30 | 30 | ); |
31 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
31 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
32 | 32 | } |
33 | 33 | // check that an action exists and add nonce |
34 | - if ( ! $exclude_nonce ) { |
|
35 | - if ( isset( $args['action'] ) && ! empty( $args['action'] ) ) { |
|
36 | - $args = array_merge( $args, array( $args['action'] . '_nonce' => wp_create_nonce( $args['action'] . '_nonce' ) ) ); |
|
34 | + if ( ! $exclude_nonce) { |
|
35 | + if (isset($args['action']) && ! empty($args['action'])) { |
|
36 | + $args = array_merge($args, array($args['action'].'_nonce' => wp_create_nonce($args['action'].'_nonce'))); |
|
37 | 37 | } else { |
38 | - $args = array_merge( $args, array( 'action' => 'default', 'default_nonce' => wp_create_nonce( 'default_nonce' ) ) ); |
|
38 | + $args = array_merge($args, array('action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce'))); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | 42 | //finally, let's always add a return address (if present) :) |
43 | - $args = ! empty( $_REQUEST['action'] ) ? array_merge( $args, array( 'return' => $_REQUEST['action'] ) ) : $args; |
|
43 | + $args = ! empty($_REQUEST['action']) ? array_merge($args, array('return' => $_REQUEST['action'])) : $args; |
|
44 | 44 | |
45 | - return add_query_arg( $args, $url ); |
|
45 | + return add_query_arg($args, $url); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -55,17 +55,17 @@ discard block |
||
55 | 55 | * @param boolean $sslverify whether we care if the SSL certificate for the requested site is setup properly |
56 | 56 | * @return boolean |
57 | 57 | */ |
58 | - public static function remote_file_exists( $url, $args = array() ){ |
|
59 | - $results = wp_remote_request($url,array_merge( array( |
|
58 | + public static function remote_file_exists($url, $args = array()) { |
|
59 | + $results = wp_remote_request($url, array_merge(array( |
|
60 | 60 | 'method'=>'GET', |
61 | 61 | 'redirection'=>1 |
62 | - ), $args ) ); |
|
63 | - if( ! $results instanceof WP_Error && |
|
62 | + ), $args)); |
|
63 | + if ( ! $results instanceof WP_Error && |
|
64 | 64 | isset($results['response']) && |
65 | 65 | isset($results['response']['code']) && |
66 | - $results['response']['code'] == '200'){ |
|
66 | + $results['response']['code'] == '200') { |
|
67 | 67 | return true; |
68 | - }else{ |
|
68 | + } else { |
|
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | } |
@@ -81,29 +81,29 @@ discard block |
||
81 | 81 | * @param bool $base_url_only - TRUE will only return the scheme and host with no other parameters |
82 | 82 | * @return string |
83 | 83 | */ |
84 | - public static function refactor_url( $url = '', $remove_query = TRUE, $base_url_only = FALSE ) { |
|
84 | + public static function refactor_url($url = '', $remove_query = TRUE, $base_url_only = FALSE) { |
|
85 | 85 | // break apart incoming URL |
86 | - $url_bits = parse_url( $url ); |
|
86 | + $url_bits = parse_url($url); |
|
87 | 87 | // HTTP or HTTPS ? |
88 | - $scheme = isset( $url_bits[ 'scheme' ] ) ? $url_bits[ 'scheme' ] . '://' : 'http://'; |
|
88 | + $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'].'://' : 'http://'; |
|
89 | 89 | // domain |
90 | - $host = isset( $url_bits[ 'host' ] ) ? $url_bits[ 'host' ] : ''; |
|
90 | + $host = isset($url_bits['host']) ? $url_bits['host'] : ''; |
|
91 | 91 | // if only the base URL is requested, then return that now |
92 | - if ( $base_url_only ) { |
|
93 | - return $scheme . $host; |
|
92 | + if ($base_url_only) { |
|
93 | + return $scheme.$host; |
|
94 | 94 | } |
95 | - $port = isset( $url_bits[ 'port' ] ) ? ':' . $url_bits[ 'port' ] : ''; |
|
96 | - $user = isset( $url_bits[ 'user' ] ) ? $url_bits[ 'user' ] : ''; |
|
97 | - $pass = isset( $url_bits[ 'pass' ] ) ? ':' . $url_bits[ 'pass' ] : ''; |
|
98 | - $pass = ( $user || $pass ) ? $pass . '@' : ''; |
|
99 | - $path = isset( $url_bits[ 'path' ] ) ? $url_bits[ 'path' ] : ''; |
|
95 | + $port = isset($url_bits['port']) ? ':'.$url_bits['port'] : ''; |
|
96 | + $user = isset($url_bits['user']) ? $url_bits['user'] : ''; |
|
97 | + $pass = isset($url_bits['pass']) ? ':'.$url_bits['pass'] : ''; |
|
98 | + $pass = ($user || $pass) ? $pass.'@' : ''; |
|
99 | + $path = isset($url_bits['path']) ? $url_bits['path'] : ''; |
|
100 | 100 | // if the query string is not required, then return what we have so far |
101 | - if ( $remove_query ) { |
|
102 | - return $scheme . $user . $pass . $host . $port . $path; |
|
101 | + if ($remove_query) { |
|
102 | + return $scheme.$user.$pass.$host.$port.$path; |
|
103 | 103 | } |
104 | - $query = isset( $url_bits[ 'query' ] ) ? '?' . $url_bits[ 'query' ] : ''; |
|
105 | - $fragment = isset( $url_bits[ 'fragment' ] ) ? '#' . $url_bits[ 'fragment' ] : ''; |
|
106 | - return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; |
|
104 | + $query = isset($url_bits['query']) ? '?'.$url_bits['query'] : ''; |
|
105 | + $fragment = isset($url_bits['fragment']) ? '#'.$url_bits['fragment'] : ''; |
|
106 | + return $scheme.$user.$pass.$host.$port.$path.$query.$fragment; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -116,29 +116,29 @@ discard block |
||
116 | 116 | * @param bool $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will simply return the query string |
117 | 117 | * @return string|array |
118 | 118 | */ |
119 | - public static function get_query_string( $url = '', $as_array = TRUE ) { |
|
119 | + public static function get_query_string($url = '', $as_array = TRUE) { |
|
120 | 120 | // break apart incoming URL |
121 | - $url_bits = parse_url( $url ); |
|
121 | + $url_bits = parse_url($url); |
|
122 | 122 | // grab query string from URL |
123 | - $query = isset( $url_bits[ 'query' ] ) ? $url_bits[ 'query' ] : ''; |
|
123 | + $query = isset($url_bits['query']) ? $url_bits['query'] : ''; |
|
124 | 124 | // if we don't want the query string formatted into an array of key => value pairs, then just return it as is |
125 | - if ( ! $as_array ) { |
|
125 | + if ( ! $as_array) { |
|
126 | 126 | return $query; |
127 | 127 | } |
128 | 128 | // if no query string exists then just return an empty array now |
129 | - if ( empty( $query )) { |
|
129 | + if (empty($query)) { |
|
130 | 130 | return array(); |
131 | 131 | } |
132 | 132 | // empty array to hold results |
133 | 133 | $query_params = array(); |
134 | 134 | // now break apart the query string into separate params |
135 | - $query = explode( '&', $query ); |
|
135 | + $query = explode('&', $query); |
|
136 | 136 | // loop thru our query params |
137 | - foreach ( $query as $query_args ) { |
|
137 | + foreach ($query as $query_args) { |
|
138 | 138 | // break apart the key value pairs |
139 | - $query_args = explode( '=', $query_args ); |
|
139 | + $query_args = explode('=', $query_args); |
|
140 | 140 | // and add to our results array |
141 | - $query_params[ $query_args[0] ] = $query_args[1]; |
|
141 | + $query_params[$query_args[0]] = $query_args[1]; |
|
142 | 142 | } |
143 | 143 | return $query_params; |
144 | 144 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * prevent_prefetching |
150 | 150 | * @return void |
151 | 151 | */ |
152 | - public static function prevent_prefetching(){ |
|
152 | + public static function prevent_prefetching() { |
|
153 | 153 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
154 | 154 | remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
155 | 155 | } |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | * @param string $prefix Use this to prefix the string with something. |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - public static function generate_unique_token( $prefix = '' ) { |
|
168 | - $token = md5( uniqid() . mt_rand() ); |
|
169 | - return $prefix ? $prefix . '_' . $token : $token; |
|
167 | + public static function generate_unique_token($prefix = '') { |
|
168 | + $token = md5(uniqid().mt_rand()); |
|
169 | + return $prefix ? $prefix.'_'.$token : $token; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * add_nocache_headers |
176 | 176 | * @return void |
177 | 177 | */ |
178 | - public static function add_nocache_headers(){ |
|
178 | + public static function add_nocache_headers() { |
|
179 | 179 | // add no cache headers |
180 | 180 | // add_action( 'wp_head' , array( 'EED_Single_Page_Checkout', 'nocache_headers' ), 10 ); |
181 | 181 | // plus a little extra for nginx |
@@ -192,19 +192,19 @@ discard block |
||
192 | 192 | * @param string $server_variable |
193 | 193 | * @return string |
194 | 194 | */ |
195 | - public static function filter_input_server_url( $server_variable = 'REQUEST_URI' ){ |
|
195 | + public static function filter_input_server_url($server_variable = 'REQUEST_URI') { |
|
196 | 196 | $URL = ''; |
197 | 197 | $server_variables = array( |
198 | 198 | 'REQUEST_URI' => 1, |
199 | 199 | 'HTTP_HOST' => 1, |
200 | 200 | 'PHP_SELF' => 1, |
201 | 201 | ); |
202 | - $server_variable = strtoupper( $server_variable ); |
|
202 | + $server_variable = strtoupper($server_variable); |
|
203 | 203 | // whitelist INPUT_SERVER var |
204 | - if ( isset( $server_variables[ $server_variable ] ) ) { |
|
205 | - $URL = filter_input( INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE ); |
|
206 | - if ( empty( $URL ) ) { |
|
207 | - $URL = esc_url( $_SERVER[ $server_variable ] ); |
|
204 | + if (isset($server_variables[$server_variable])) { |
|
205 | + $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE); |
|
206 | + if (empty($URL)) { |
|
207 | + $URL = esc_url($_SERVER[$server_variable]); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | return $URL; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -class EE_CVV_Input extends EE_Text_Input{ |
|
11 | +class EE_CVV_Input extends EE_Text_Input { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @param array $input_settings { |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function __construct($input_settings = array()) { |
19 | 19 | $this->set_sensitive_data_removal_strategy(new EE_CCV_Sensitive_Data_Removal()); |
20 | - $this->_add_validation_strategy( new EE_Int_Validation_Strategy(isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
20 | + $this->_add_validation_strategy(new EE_Int_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
21 | 21 | parent::__construct($input_settings); |
22 | - if( |
|
23 | - ! isset( $input_settings[ 'include_whats_this_link' ] ) || |
|
24 | - ( isset( $input_settings[ 'include_whats_this_link' ] ) && |
|
25 | - $input_settings[ 'include_whats_this_link' ] == true ) ) { |
|
22 | + if ( |
|
23 | + ! isset($input_settings['include_whats_this_link']) || |
|
24 | + (isset($input_settings['include_whats_this_link']) && |
|
25 | + $input_settings['include_whats_this_link'] == true) ) { |
|
26 | 26 | $this->_html_label_text = sprintf( |
27 | 27 | _x( |
28 | 28 | '%1$s %2$s(What\'s this?)%3$s', |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | protected function _get_billing_values_from_form( $billing_form ){ |
443 | 443 | if($billing_form instanceof EE_Form_Section_Proper ){ |
444 | 444 | return $billing_form->input_pretty_values( true ); |
445 | - }else{ |
|
445 | + } else{ |
|
446 | 446 | return NULL; |
447 | 447 | } |
448 | 448 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | public function supports_sending_refunds(){ |
551 | 551 | if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
552 | 552 | return $this->_gateway->supports_sending_refunds(); |
553 | - }else{ |
|
553 | + } else{ |
|
554 | 554 | return false; |
555 | 555 | } |
556 | 556 | } |
@@ -588,11 +588,11 @@ discard block |
||
588 | 588 | public function payment_occurs(){ |
589 | 589 | if( ! $this->_gateway){ |
590 | 590 | return EE_PMT_Base::offline; |
591 | - }elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
591 | + } elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
592 | 592 | return EE_PMT_Base::onsite; |
593 | - }elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
593 | + } elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
594 | 594 | return EE_PMT_Base::offsite; |
595 | - }else{ |
|
595 | + } else{ |
|
596 | 596 | throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"),get_class($this))); |
597 | 597 | } |
598 | 598 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @since $VID:$ |
15 | 15 | * |
16 | 16 | */ |
17 | -abstract class EE_PMT_Base{ |
|
17 | +abstract class EE_PMT_Base { |
|
18 | 18 | |
19 | 19 | const onsite = 'on-site'; |
20 | 20 | const offsite = 'off-site'; |
@@ -95,36 +95,36 @@ discard block |
||
95 | 95 | * @return EE_PMT_Base |
96 | 96 | */ |
97 | 97 | function __construct($pm_instance = NULL) { |
98 | - if ( $pm_instance instanceof EE_Payment_Method ){ |
|
98 | + if ($pm_instance instanceof EE_Payment_Method) { |
|
99 | 99 | $this->set_instance($pm_instance); |
100 | 100 | } |
101 | 101 | $this->_set_file_folder(); |
102 | 102 | $this->_set_file_url(); |
103 | - if($this->_gateway){ |
|
104 | - $this->_gateway->set_payment_model( EEM_Payment::instance() ); |
|
105 | - $this->_gateway->set_payment_log( EEM_Change_Log::instance() ); |
|
106 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
107 | - $this->_gateway->set_template_helper( new EEH_Template() ); |
|
108 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
109 | - $this->_gateway->set_line_item_helper( new EEH_Line_Item() ); |
|
110 | - EE_Registry::instance()->load_helper( 'Money' ); |
|
111 | - $this->_gateway->set_money_helper( new EEH_Money() ); |
|
103 | + if ($this->_gateway) { |
|
104 | + $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
105 | + $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
106 | + EE_Registry::instance()->load_helper('Template'); |
|
107 | + $this->_gateway->set_template_helper(new EEH_Template()); |
|
108 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
109 | + $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
110 | + EE_Registry::instance()->load_helper('Money'); |
|
111 | + $this->_gateway->set_money_helper(new EEH_Money()); |
|
112 | 112 | } |
113 | - if ( ! isset( $this->_has_billing_form ) ) { |
|
113 | + if ( ! isset($this->_has_billing_form)) { |
|
114 | 114 | // by default, On Site gateways have a billing form |
115 | - if ( $this->payment_occurs() == EE_PMT_Base::onsite ) { |
|
116 | - $this->set_has_billing_form( true ); |
|
115 | + if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
116 | + $this->set_has_billing_form(true); |
|
117 | 117 | } else { |
118 | - $this->set_has_billing_form( false ); |
|
118 | + $this->set_has_billing_form(false); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | - if( ! $this->_pretty_name){ |
|
122 | + if ( ! $this->_pretty_name) { |
|
123 | 123 | throw new EE_Error(sprintf(__("You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", "event_espresso"))); |
124 | 124 | } |
125 | 125 | //if the child didn't specify a default button, use the credit card one |
126 | - if( $this->_default_button_url === NULL){ |
|
127 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png'; |
|
126 | + if ($this->_default_button_url === NULL) { |
|
127 | + $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods'.DS.'pay-by-credit-card.png'; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | /** |
134 | 134 | * @param boolean $has_billing_form |
135 | 135 | */ |
136 | - public function set_has_billing_form( $has_billing_form ) { |
|
137 | - $this->_has_billing_form = filter_var( $has_billing_form, FILTER_VALIDATE_BOOLEAN ); |
|
136 | + public function set_has_billing_form($has_billing_form) { |
|
137 | + $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * sets the file_folder property |
144 | 144 | */ |
145 | - protected function _set_file_folder(){ |
|
145 | + protected function _set_file_folder() { |
|
146 | 146 | $reflector = new ReflectionClass(get_class($this)); |
147 | 147 | $fn = $reflector->getFileName(); |
148 | - $this->_file_folder = dirname($fn).DS; |
|
148 | + $this->_file_folder = dirname($fn).DS; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | /** |
154 | 154 | * sets the file URL with a trailing slash for this PMT |
155 | 155 | */ |
156 | - protected function _set_file_url(){ |
|
157 | - $plugins_dir_fixed = str_replace('\\',DS,WP_PLUGIN_DIR); |
|
158 | - $file_folder_fixed = str_replace('\\',DS,$this->file_folder()); |
|
159 | - $file_path = str_replace($plugins_dir_fixed,WP_PLUGIN_URL,$file_folder_fixed); |
|
156 | + protected function _set_file_url() { |
|
157 | + $plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR); |
|
158 | + $file_folder_fixed = str_replace('\\', DS, $this->file_folder()); |
|
159 | + $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
160 | 160 | $this->_file_url = $file_path; |
161 | 161 | } |
162 | 162 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * Gets the default description on all payment methods of this type |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - public function default_description(){ |
|
167 | + public function default_description() { |
|
168 | 168 | return $this->_default_description; |
169 | 169 | } |
170 | 170 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * Returns the folder containing the PMT child class, with a trailing slash |
175 | 175 | * @return string |
176 | 176 | */ |
177 | - public function file_folder(){ |
|
177 | + public function file_folder() { |
|
178 | 178 | return $this->_file_folder; |
179 | 179 | } |
180 | 180 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | /** |
184 | 184 | * @return string |
185 | 185 | */ |
186 | - public function file_url(){ |
|
186 | + public function file_url() { |
|
187 | 187 | return $this->_file_url; |
188 | 188 | } |
189 | 189 | |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | * Its important teh payment method instance is set before |
195 | 195 | * @param EE_Payment_Method $payment_method_instance |
196 | 196 | */ |
197 | - function set_instance($payment_method_instance){ |
|
197 | + function set_instance($payment_method_instance) { |
|
198 | 198 | $this->_pm_instance = $payment_method_instance; |
199 | 199 | //if they have already requested the settings form, make sure its |
200 | 200 | //data matches this model object |
201 | - if($this->_settings_form){ |
|
201 | + if ($this->_settings_form) { |
|
202 | 202 | $this->settings_form()->populate_model_obj($payment_method_instance); |
203 | 203 | } |
204 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
204 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
205 | 205 | $this->_gateway->set_settings($payment_method_instance->settings_array()); |
206 | 206 | } |
207 | 207 | } |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | * Gets teh form for displaying to admins where they setup the payment method |
213 | 213 | * @return EE_Payment_Method_Form |
214 | 214 | */ |
215 | - function settings_form(){ |
|
216 | - if( ! $this->_settings_form){ |
|
215 | + function settings_form() { |
|
216 | + if ( ! $this->_settings_form) { |
|
217 | 217 | $this->_settings_form = $this->generate_new_settings_form(); |
218 | - $this->_settings_form->set_payment_method_type( $this ); |
|
219 | - $this->_settings_form->_construct_finalize(NULL, NULL ); |
|
218 | + $this->_settings_form->set_payment_method_type($this); |
|
219 | + $this->_settings_form->_construct_finalize(NULL, NULL); |
|
220 | 220 | //if we have already assigned a model object to this pmt, make |
221 | 221 | //sure its reflected in teh form we just generated |
222 | - if($this->_pm_instance){ |
|
222 | + if ($this->_pm_instance) { |
|
223 | 223 | $this->_settings_form->populate_model_obj($this->_pm_instance); |
224 | 224 | } |
225 | 225 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * this payment method type's settings form later in the request |
246 | 246 | * @param EE_Payment_Method_Form $form |
247 | 247 | */ |
248 | - public function set_settings_form($form){ |
|
248 | + public function set_settings_form($form) { |
|
249 | 249 | $this->_settings_form = $form; |
250 | 250 | } |
251 | 251 | |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | * @param array $extra_args |
269 | 269 | * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
270 | 270 | */ |
271 | - public function billing_form( EE_Transaction $transaction = NULL, $extra_args = array() ){ |
|
271 | + public function billing_form(EE_Transaction $transaction = NULL, $extra_args = array()) { |
|
272 | 272 | // has billing form already been regenerated ? or overwrite cache? |
273 | - if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form ){ |
|
274 | - $this->_billing_form = $this->generate_new_billing_form( $transaction, $extra_args ); |
|
273 | + if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
274 | + $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
275 | 275 | } |
276 | 276 | //if we know who the attendee is, and this is a billing form |
277 | 277 | //that uses attendee info, populate it |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | $transaction instanceof EE_Transaction && |
281 | 281 | $transaction->primary_registration() instanceof EE_Registration && |
282 | 282 | $transaction->primary_registration()->attendee() instanceof EE_Attendee |
283 | - ){ |
|
284 | - $this->_billing_form->populate_from_attendee( $transaction->primary_registration()->attendee() ); |
|
283 | + ) { |
|
284 | + $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
285 | 285 | } |
286 | 286 | return $this->_billing_form; |
287 | 287 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @param \EE_Transaction $transaction |
293 | 293 | * @return \EE_Billing_Info_Form |
294 | 294 | */ |
295 | - abstract function generate_new_billing_form( EE_Transaction $transaction = NULL ); |
|
295 | + abstract function generate_new_billing_form(EE_Transaction $transaction = NULL); |
|
296 | 296 | |
297 | 297 | |
298 | 298 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @param \EE_Billing_Info_Form $billing_form |
304 | 304 | * @return \EE_Billing_Info_Form |
305 | 305 | */ |
306 | - public function apply_billing_form_debug_settings( EE_Billing_Info_Form $billing_form ) { |
|
306 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) { |
|
307 | 307 | return $billing_form; |
308 | 308 | } |
309 | 309 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * if you have form |
315 | 315 | * @param EE_Payment_Method $form |
316 | 316 | */ |
317 | - public function set_billing_form($form){ |
|
317 | + public function set_billing_form($form) { |
|
318 | 318 | $this->_billing_form = $form; |
319 | 319 | } |
320 | 320 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * Returns whether or not this payment method requires HTTPS to be used |
325 | 325 | * @return boolean |
326 | 326 | */ |
327 | - function requires_https(){ |
|
327 | + function requires_https() { |
|
328 | 328 | return $this->_requires_https; |
329 | 329 | } |
330 | 330 | |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | * @return EE_Payment |
343 | 343 | * @throws EE_Error |
344 | 344 | */ |
345 | - function process_payment( EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null,$fail_url = '', $method = 'CART', $by_admin = false ){ |
|
345 | + function process_payment(EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null, $fail_url = '', $method = 'CART', $by_admin = false) { |
|
346 | 346 | // @todo: add surcharge for the payment method, if any |
347 | - if ( $this->_gateway ) { |
|
347 | + if ($this->_gateway) { |
|
348 | 348 | //there is a gateway, so we're going to make a payment object |
349 | 349 | //but wait! do they already have a payment in progress that we thought was failed? |
350 | 350 | $duplicate_properties = array( |
@@ -355,10 +355,10 @@ discard block |
||
355 | 355 | 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
356 | 356 | 'PAY_gateway_response' => null, |
357 | 357 | ); |
358 | - $payment = EEM_Payment::instance()->get_one( array( $duplicate_properties )); |
|
358 | + $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
359 | 359 | //if we didn't already have a payment in progress for the same thing, |
360 | 360 | //then we actually want to make a new payment |
361 | - if ( ! $payment instanceof EE_Payment ){ |
|
361 | + if ( ! $payment instanceof EE_Payment) { |
|
362 | 362 | $payment = EE_Payment::new_instance( |
363 | 363 | array_merge( |
364 | 364 | $duplicate_properties, |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | } |
375 | 375 | //make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
376 | 376 | $payment->save(); |
377 | - $billing_values = $this->_get_billing_values_from_form( $billing_info ); |
|
377 | + $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
378 | 378 | |
379 | 379 | // Offsite Gateway |
380 | - if( $this->_gateway instanceof EE_Offsite_Gateway ){ |
|
380 | + if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
381 | 381 | |
382 | 382 | $payment = $this->_gateway->set_redirection_info( |
383 | 383 | $payment, |
@@ -393,17 +393,17 @@ discard block |
||
393 | 393 | ); |
394 | 394 | $payment->save(); |
395 | 395 | // Onsite Gateway |
396 | - } elseif ( $this->_gateway instanceof EE_Onsite_Gateway ) { |
|
396 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
397 | 397 | |
398 | - $payment = $this->_gateway->do_direct_payment($payment,$billing_values); |
|
398 | + $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
399 | 399 | $payment->save(); |
400 | 400 | |
401 | 401 | } else { |
402 | 402 | throw new EE_Error( |
403 | 403 | sprintf( |
404 | - __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso' ), |
|
404 | + __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso'), |
|
405 | 405 | get_class($this), |
406 | - gettype( $this->_gateway ) |
|
406 | + gettype($this->_gateway) |
|
407 | 407 | ) |
408 | 408 | ); |
409 | 409 | } |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | } |
426 | 426 | |
427 | 427 | // if there is billing info, clean it and save it now |
428 | - if( $billing_info instanceof EE_Billing_Attendee_Info_Form ){ |
|
429 | - $this->_save_billing_info_to_attendee( $billing_info, $transaction ); |
|
428 | + if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
429 | + $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | return $payment; |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | * @param EE_Billing_Info_Form $billing_form |
440 | 440 | * @return array |
441 | 441 | */ |
442 | - protected function _get_billing_values_from_form( $billing_form ){ |
|
443 | - if($billing_form instanceof EE_Form_Section_Proper ){ |
|
444 | - return $billing_form->input_pretty_values( true ); |
|
445 | - }else{ |
|
442 | + protected function _get_billing_values_from_form($billing_form) { |
|
443 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
444 | + return $billing_form->input_pretty_values(true); |
|
445 | + } else { |
|
446 | 446 | return NULL; |
447 | 447 | } |
448 | 448 | } |
@@ -456,13 +456,13 @@ discard block |
||
456 | 456 | * @return EE_Payment |
457 | 457 | * @throws EE_Error |
458 | 458 | */ |
459 | - public function handle_ipn($req_data,$transaction){ |
|
459 | + public function handle_ipn($req_data, $transaction) { |
|
460 | 460 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
461 | - if( ! $this->_gateway instanceof EE_Offsite_Gateway){ |
|
462 | - throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r( $this->_gateway, TRUE ))); |
|
461 | + if ( ! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
462 | + throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r($this->_gateway, TRUE))); |
|
463 | 463 | |
464 | 464 | } |
465 | - $payment = $this->_gateway->handle_payment_update( $req_data, $transaction ); |
|
465 | + $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
466 | 466 | return $payment; |
467 | 467 | } |
468 | 468 | |
@@ -475,22 +475,22 @@ discard block |
||
475 | 475 | * @param EE_Transaction $transaction |
476 | 476 | * @return boolean success |
477 | 477 | */ |
478 | - protected function _save_billing_info_to_attendee($billing_form, $transaction){ |
|
479 | - if( ! $transaction || ! $transaction instanceof EE_Transaction){ |
|
478 | + protected function _save_billing_info_to_attendee($billing_form, $transaction) { |
|
479 | + if ( ! $transaction || ! $transaction instanceof EE_Transaction) { |
|
480 | 480 | EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
481 | 481 | return false; |
482 | 482 | } |
483 | 483 | $primary_reg = $transaction->primary_registration(); |
484 | - if( ! $primary_reg ){ |
|
484 | + if ( ! $primary_reg) { |
|
485 | 485 | EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
486 | 486 | return false; |
487 | 487 | } |
488 | 488 | $attendee = $primary_reg->attendee(); |
489 | - if( ! $attendee ){ |
|
489 | + if ( ! $attendee) { |
|
490 | 490 | EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
491 | 491 | return false; |
492 | 492 | } |
493 | - return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method() ); |
|
493 | + return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
494 | 494 | |
495 | 495 | } |
496 | 496 | |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * @param array $req_data |
504 | 504 | * @return EE_Payment |
505 | 505 | */ |
506 | - protected function find_payment_for_ipn( EE_Transaction $transaction, $req_data = array() ){ |
|
506 | + protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) { |
|
507 | 507 | return $transaction->last_payment(); |
508 | 508 | } |
509 | 509 | |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
521 | 521 | * @throws EE_Error |
522 | 522 | */ |
523 | - public function handle_unclaimed_ipn( $req_data = array() ){ |
|
524 | - throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this) )); |
|
523 | + public function handle_unclaimed_ipn($req_data = array()) { |
|
524 | + throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * @param EE_Transaction $transaction |
538 | 538 | * @return EE_Payment |
539 | 539 | */ |
540 | - public function finalize_payment_for($transaction){ |
|
540 | + public function finalize_payment_for($transaction) { |
|
541 | 541 | return $transaction->last_payment(); |
542 | 542 | } |
543 | 543 | |
@@ -547,10 +547,10 @@ discard block |
||
547 | 547 | * Whether or not this payment method's gateway supports sending refund requests |
548 | 548 | * @return boolean |
549 | 549 | */ |
550 | - public function supports_sending_refunds(){ |
|
551 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
550 | + public function supports_sending_refunds() { |
|
551 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
552 | 552 | return $this->_gateway->supports_sending_refunds(); |
553 | - }else{ |
|
553 | + } else { |
|
554 | 554 | return false; |
555 | 555 | } |
556 | 556 | } |
@@ -564,14 +564,14 @@ discard block |
||
564 | 564 | * @throws EE_Error |
565 | 565 | * @return EE_Payment |
566 | 566 | */ |
567 | - public function process_refund( EE_Payment $payment, $refund_info = array()){ |
|
568 | - if ( $this->_gateway && $this->_gateway instanceof EE_Gateway ) { |
|
569 | - return $this->_gateway->do_direct_refund( $payment, $refund_info ); |
|
567 | + public function process_refund(EE_Payment $payment, $refund_info = array()) { |
|
568 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
569 | + return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
570 | 570 | } else { |
571 | 571 | throw new EE_Error( |
572 | 572 | sprintf( |
573 | - __( 'Payment Method Type "%s" does not support sending refund requests', 'event_espresso' ), |
|
574 | - get_class( $this ) |
|
573 | + __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
574 | + get_class($this) |
|
575 | 575 | ) |
576 | 576 | ); |
577 | 577 | } |
@@ -585,15 +585,15 @@ discard block |
||
585 | 585 | * @return string |
586 | 586 | * @throws EE_Error |
587 | 587 | */ |
588 | - public function payment_occurs(){ |
|
589 | - if( ! $this->_gateway){ |
|
588 | + public function payment_occurs() { |
|
589 | + if ( ! $this->_gateway) { |
|
590 | 590 | return EE_PMT_Base::offline; |
591 | - }elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
591 | + }elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
592 | 592 | return EE_PMT_Base::onsite; |
593 | - }elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
593 | + }elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
594 | 594 | return EE_PMT_Base::offsite; |
595 | - }else{ |
|
596 | - throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"),get_class($this))); |
|
595 | + } else { |
|
596 | + throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"), get_class($this))); |
|
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
@@ -606,9 +606,9 @@ discard block |
||
606 | 606 | * @param EE_Payment $payment |
607 | 607 | * @return string |
608 | 608 | */ |
609 | - public function payment_overview_content(EE_Payment $payment){ |
|
609 | + public function payment_overview_content(EE_Payment $payment) { |
|
610 | 610 | EE_Registry::instance()->load_helper('Template'); |
611 | - return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance,'payment'=>$payment) , true); |
|
611 | + return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance, 'payment'=>$payment), true); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | * @type array $template_args any arguments you want passed to the template file while rendering. |
622 | 622 | * Keys will be variable names and values with be their values. |
623 | 623 | */ |
624 | - public function help_tabs_config(){ |
|
624 | + public function help_tabs_config() { |
|
625 | 625 | return array(); |
626 | 626 | } |
627 | 627 | |
@@ -632,9 +632,9 @@ discard block |
||
632 | 632 | * the payment method's table's PMT_type column) |
633 | 633 | * @return string |
634 | 634 | */ |
635 | - public function system_name(){ |
|
635 | + public function system_name() { |
|
636 | 636 | $classname = get_class($this); |
637 | - return str_replace("EE_PMT_",'',$classname); |
|
637 | + return str_replace("EE_PMT_", '', $classname); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | * A pretty i18n version of the PMT name |
644 | 644 | * @return string |
645 | 645 | */ |
646 | - public function pretty_name(){ |
|
646 | + public function pretty_name() { |
|
647 | 647 | return $this->_pretty_name; |
648 | 648 | } |
649 | 649 | |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * Gets the default absolute URL to the payment method type's button |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - public function default_button_url(){ |
|
656 | + public function default_button_url() { |
|
657 | 657 | return $this->_default_button_url; |
658 | 658 | } |
659 | 659 | |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | * Gets the gateway used by this payment method (if any) |
664 | 664 | * @return EE_Gateway |
665 | 665 | */ |
666 | - public function get_gateway(){ |
|
666 | + public function get_gateway() { |
|
667 | 667 | return $this->_gateway; |
668 | 668 | } |
669 | 669 | |
@@ -672,9 +672,9 @@ discard block |
||
672 | 672 | /** |
673 | 673 | * @return string html for the link to a help tab |
674 | 674 | */ |
675 | - public function get_help_tab_link(){ |
|
676 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
677 | - return EEH_Template::get_help_tab_link( $this->get_help_tab_name() ); |
|
675 | + public function get_help_tab_link() { |
|
676 | + EE_Registry::instance()->load_helper('Template'); |
|
677 | + return EEH_Template::get_help_tab_link($this->get_help_tab_name()); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | * Returns the name of the help tab for this PMT |
684 | 684 | * @return string |
685 | 685 | */ |
686 | - public function get_help_tab_name(){ |
|
687 | - return 'ee_' . strtolower( $this->system_name() ) . '_help_tab'; |
|
686 | + public function get_help_tab_name() { |
|
687 | + return 'ee_'.strtolower($this->system_name()).'_help_tab'; |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | /** |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | * this PMT by an admin |
693 | 693 | * @return string |
694 | 694 | */ |
695 | - public function cap_name(){ |
|
696 | - return 'ee_payment_method_' . strtolower( $this->system_name() ); |
|
695 | + public function cap_name() { |
|
696 | + return 'ee_payment_method_'.strtolower($this->system_name()); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | /** |
@@ -705,9 +705,9 @@ discard block |
||
705 | 705 | * @param EE_Payment $payment |
706 | 706 | * @return void |
707 | 707 | */ |
708 | - public function update_txn_based_on_payment( $payment ){ |
|
709 | - if( $this->_gateway instanceof EE_Gateway ){ |
|
710 | - $this->_gateway->update_txn_based_on_payment( $payment ); |
|
708 | + public function update_txn_based_on_payment($payment) { |
|
709 | + if ($this->_gateway instanceof EE_Gateway) { |
|
710 | + $this->_gateway->update_txn_based_on_payment($payment); |
|
711 | 711 | } |
712 | 712 | } |
713 | 713 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | //namespace EventEspresso\core\libraries\templates; |
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 | * Class EE_Template_Part |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @param string $template |
48 | 48 | * @param int $priority |
49 | 49 | */ |
50 | - public function __construct( $name, $label, $template, $priority = 100 ) { |
|
51 | - $this->set_name( $name ); |
|
52 | - $this->set_label( $label ); |
|
53 | - $this->set_template( $template ); |
|
54 | - $this->set_priority( $priority ); |
|
50 | + public function __construct($name, $label, $template, $priority = 100) { |
|
51 | + $this->set_name($name); |
|
52 | + $this->set_label($label); |
|
53 | + $this->set_template($template); |
|
54 | + $this->set_priority($priority); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * @param mixed $name |
70 | 70 | */ |
71 | - public function set_name( $name ) { |
|
71 | + public function set_name($name) { |
|
72 | 72 | $this->name = $name; |
73 | 73 | } |
74 | 74 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * @param string $label |
88 | 88 | */ |
89 | - public function set_label( $label ) { |
|
89 | + public function set_label($label) { |
|
90 | 90 | $this->label = $label; |
91 | 91 | } |
92 | 92 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * @param string $template |
106 | 106 | */ |
107 | - public function set_template( $template ) { |
|
107 | + public function set_template($template) { |
|
108 | 108 | $this->template = $template; |
109 | 109 | } |
110 | 110 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | /** |
123 | 123 | * @param int $priority |
124 | 124 | */ |
125 | - public function set_priority( $priority ) { |
|
126 | - $this->priority = intval( $priority ); |
|
125 | + public function set_priority($priority) { |
|
126 | + $this->priority = intval($priority); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | //namespace EventEspresso\core\libraries\templates; |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -70,23 +70,23 @@ discard block |
||
70 | 70 | * @param string $template - name or path of template to be used by EEH_Template::locate_template() |
71 | 71 | * @param int $priority - order in which template parts should be applied |
72 | 72 | */ |
73 | - public function add_template_part( $name, $label, $template, $priority ) { |
|
73 | + public function add_template_part($name, $label, $template, $priority) { |
|
74 | 74 | // SplPriorityQueue doesn't play nice with multiple items having the same priority |
75 | 75 | // so if the incoming priority is already occupied, then let's increment it by one, |
76 | 76 | // and then pass everything back into this method and try again with the new priority |
77 | - if ( isset( $this->priorities[ $priority ] ) ) { |
|
77 | + if (isset($this->priorities[$priority])) { |
|
78 | 78 | $priority++; |
79 | - $this->add_template_part( $name, $label, $template, $priority ); |
|
79 | + $this->add_template_part($name, $label, $template, $priority); |
|
80 | 80 | return; |
81 | 81 | } |
82 | 82 | // kk now we can mark this priority as being occupied |
83 | - $this->priorities[ $priority ] = true; |
|
83 | + $this->priorities[$priority] = true; |
|
84 | 84 | // create the template part and add to the queue |
85 | 85 | $this->template_parts->insert( |
86 | - new EE_Template_Part( $name, $label, $template, $priority ), |
|
86 | + new EE_Template_Part($name, $label, $template, $priority), |
|
87 | 87 | $priority |
88 | 88 | ); |
89 | - if ( $name == 'event' ) { |
|
89 | + if ($name == 'event') { |
|
90 | 90 | $this->event_desc_priority = $priority; |
91 | 91 | } |
92 | 92 | } |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | * @param string $content |
104 | 104 | * @return string |
105 | 105 | */ |
106 | - public function apply_template_part_filters( $content = '' ) { |
|
106 | + public function apply_template_part_filters($content = '') { |
|
107 | 107 | $this->template_parts->rewind(); |
108 | 108 | // loop through template parts and position content |
109 | - while ( $this->template_parts->valid() ) { |
|
109 | + while ($this->template_parts->valid()) { |
|
110 | 110 | $this->_position_template_part( |
111 | 111 | $content, |
112 | 112 | $this->template_parts->current()->template(), |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $this->template_parts->next(); |
116 | 116 | } |
117 | 117 | // now simply add our three strings of content together |
118 | - return $this->before_event_content . $this->event_content . $this->after_event_content; |
|
118 | + return $this->before_event_content.$this->event_content.$this->after_event_content; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -136,16 +136,16 @@ discard block |
||
136 | 136 | * @param int $priority |
137 | 137 | * @return string |
138 | 138 | */ |
139 | - protected function _position_template_part( $content, $template, $priority ) { |
|
139 | + protected function _position_template_part($content, $template, $priority) { |
|
140 | 140 | // Event Description content is the actual incoming content itself |
141 | - if ( $priority === $this->event_desc_priority ) { |
|
141 | + if ($priority === $this->event_desc_priority) { |
|
142 | 142 | $this->event_content = $content; |
143 | - } else if ( $priority < $this->event_desc_priority ) { |
|
143 | + } else if ($priority < $this->event_desc_priority) { |
|
144 | 144 | // everything BEFORE the Event Description |
145 | - $this->before_event_content .= EEH_Template::locate_template( $template ); |
|
146 | - } else if ( $priority > $this->event_desc_priority ) { |
|
145 | + $this->before_event_content .= EEH_Template::locate_template($template); |
|
146 | + } else if ($priority > $this->event_desc_priority) { |
|
147 | 147 | // everything AFTER the Event Description |
148 | - $this->after_event_content .= EEH_Template::locate_template( $template ); |
|
148 | + $this->after_event_content .= EEH_Template::locate_template($template); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -170,16 +170,16 @@ discard block |
||
170 | 170 | $list_item_css_class = '', |
171 | 171 | $list_item_css_id_prefix = '' |
172 | 172 | ) { |
173 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
174 | - $event_archive_display_order = EEH_HTML::ul( $list_css_id, $list_css_class ); |
|
173 | + EE_Registry::instance()->load_helper('HTML'); |
|
174 | + $event_archive_display_order = EEH_HTML::ul($list_css_id, $list_css_class); |
|
175 | 175 | $this->template_parts->rewind(); |
176 | 176 | // loop through template parts and add template content |
177 | - while ( $this->template_parts->valid() ) { |
|
177 | + while ($this->template_parts->valid()) { |
|
178 | 178 | $event_archive_display_order .= EEH_HTML::li( |
179 | - EEH_HTML::span( '', '', 'dashicons dashicons-arrow-up-alt2' ) . |
|
180 | - EEH_HTML::span( '', '', 'dashicons dashicons-arrow-down-alt2' ) . |
|
179 | + EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2'). |
|
180 | + EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2'). |
|
181 | 181 | $this->template_parts->current()->label(), |
182 | - $list_item_css_id_prefix . $this->template_parts->current()->name(), |
|
182 | + $list_item_css_id_prefix.$this->template_parts->current()->name(), |
|
183 | 183 | $list_item_css_class |
184 | 184 | ); |
185 | 185 | $this->template_parts->next(); |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @return string |
200 | 200 | */ |
201 | 201 | public function display_template_parts() { |
202 | - if ( WP_DEBUG ) { |
|
202 | + if (WP_DEBUG) { |
|
203 | 203 | $this->template_parts->rewind(); |
204 | - while ( $this->template_parts->valid() ) { |
|
205 | - EEH_Debug_Tools::printr( $this->template_parts->current(), 'template_part', __FILE__, __LINE__ ); |
|
204 | + while ($this->template_parts->valid()) { |
|
205 | + EEH_Debug_Tools::printr($this->template_parts->current(), 'template_part', __FILE__, __LINE__); |
|
206 | 206 | $this->template_parts->next(); |
207 | 207 | } |
208 | 208 | } |