@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | function __construct() { |
31 | 31 | parent::__construct( |
32 | 32 | 'ee-upcoming-events-widget', |
33 | - __( 'Event Espresso Upcoming Events', 'event_espresso' ), |
|
34 | - array( 'description' => __( 'A widget to display your upcoming events.', 'event_espresso' )), |
|
33 | + __('Event Espresso Upcoming Events', 'event_espresso'), |
|
34 | + array('description' => __('A widget to display your upcoming events.', 'event_espresso')), |
|
35 | 35 | array( |
36 | 36 | 'width' => 300, |
37 | 37 | 'height' => 350, |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @param array $instance Previously saved values from database. |
50 | 50 | * @return string|void |
51 | 51 | */ |
52 | - public function form( $instance ) { |
|
52 | + public function form($instance) { |
|
53 | 53 | |
54 | - EE_Registry::instance()->load_class( 'Question_Option', array(), FALSE, FALSE, TRUE ); |
|
54 | + EE_Registry::instance()->load_class('Question_Option', array(), FALSE, FALSE, TRUE); |
|
55 | 55 | // Set up some default widget settings. |
56 | 56 | $defaults = array( |
57 | 57 | 'title' => __('Upcoming Events', 'event_espresso'), |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | 'image_size' => 'medium' |
67 | 67 | ); |
68 | 68 | |
69 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
69 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
70 | 70 | // don't add HTML labels for EE_Form_Fields generated inputs |
71 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', '__return_empty_string' ); |
|
71 | + add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
|
72 | 72 | $yes_no_values = array( |
73 | - EE_Question_Option::new_instance( array( 'QSO_value' => FALSE, 'QSO_desc' => __('No', 'event_espresso'))), |
|
74 | - EE_Question_Option::new_instance( array( 'QSO_value' => TRUE, 'QSO_desc' => __('Yes', 'event_espresso'))) |
|
73 | + EE_Question_Option::new_instance(array('QSO_value' => FALSE, 'QSO_desc' => __('No', 'event_espresso'))), |
|
74 | + EE_Question_Option::new_instance(array('QSO_value' => TRUE, 'QSO_desc' => __('Yes', 'event_espresso'))) |
|
75 | 75 | ); |
76 | 76 | |
77 | 77 | ?> |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | <label for="<?php echo $this->get_field_id('title'); ?>"> |
83 | 83 | <?php _e('Title:', 'event_espresso'); ?> |
84 | 84 | </label> |
85 | - <input id="<?php echo $this->get_field_id('title'); ?>" class="widefat" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" type="text" /> |
|
85 | + <input id="<?php echo $this->get_field_id('title'); ?>" class="widefat" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title']); ?>" type="text" /> |
|
86 | 86 | </p> |
87 | 87 | <p> |
88 | 88 | <label for="<?php echo $this->get_field_id('category_name'); ?>"> |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | <?php |
92 | 92 | $event_categories = array(); |
93 | 93 | /** @type EEM_Term $EEM_Term */ |
94 | - $EEM_Term = EE_Registry::instance()->load_model( 'Term' ); |
|
95 | - $categories = $EEM_Term->get_all_ee_categories( TRUE ); |
|
96 | - if ( $categories ) { |
|
97 | - foreach ( $categories as $category ) { |
|
98 | - if ( $category instanceof EE_Term ) { |
|
99 | - $event_categories[] = EE_Question_Option::new_instance( array( 'QSO_value' => $category->get( 'slug' ), 'QSO_desc' => $category->get( 'name' ))); |
|
94 | + $EEM_Term = EE_Registry::instance()->load_model('Term'); |
|
95 | + $categories = $EEM_Term->get_all_ee_categories(TRUE); |
|
96 | + if ($categories) { |
|
97 | + foreach ($categories as $category) { |
|
98 | + if ($category instanceof EE_Term) { |
|
99 | + $event_categories[] = EE_Question_Option::new_instance(array('QSO_value' => $category->get('slug'), 'QSO_desc' => $category->get('name'))); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
103 | - array_unshift( $event_categories, EE_Question_Option::new_instance( array( 'QSO_value' => '', 'QSO_desc' => __(' - display all - ', 'event_espresso')))); |
|
103 | + array_unshift($event_categories, EE_Question_Option::new_instance(array('QSO_value' => '', 'QSO_desc' => __(' - display all - ', 'event_espresso')))); |
|
104 | 104 | echo EEH_Form_Fields::select( |
105 | 105 | __('Event Category:', 'event_espresso'), |
106 | 106 | $instance['category_name'], |
@@ -137,16 +137,16 @@ discard block |
||
137 | 137 | <?php |
138 | 138 | $image_sizes = array(); |
139 | 139 | $sizes = get_intermediate_image_sizes(); |
140 | - if ( $sizes ) { |
|
140 | + if ($sizes) { |
|
141 | 141 | // loop thru images and create option objects out of them |
142 | - foreach ( $sizes as $image_size ) { |
|
143 | - $image_size = trim( $image_size ); |
|
142 | + foreach ($sizes as $image_size) { |
|
143 | + $image_size = trim($image_size); |
|
144 | 144 | // no big images plz |
145 | - if ( ! in_array( $image_size, array( 'large', 'post-thumbnail' ))) { |
|
146 | - $image_sizes[] = EE_Question_Option::new_instance( array( 'QSO_value' => $image_size, 'QSO_desc' => $image_size )); |
|
145 | + if ( ! in_array($image_size, array('large', 'post-thumbnail'))) { |
|
146 | + $image_sizes[] = EE_Question_Option::new_instance(array('QSO_value' => $image_size, 'QSO_desc' => $image_size)); |
|
147 | 147 | } |
148 | 148 | } |
149 | - $image_sizes[] = EE_Question_Option::new_instance( array( 'QSO_value' => 'none', 'QSO_desc' => __('don\'t show images', 'event_espresso') )); |
|
149 | + $image_sizes[] = EE_Question_Option::new_instance(array('QSO_value' => 'none', 'QSO_desc' => __('don\'t show images', 'event_espresso'))); |
|
150 | 150 | } |
151 | 151 | echo EEH_Form_Fields::select( |
152 | 152 | __('Image Size:', 'event_espresso'), |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | <label for="<?php echo $this->get_field_id('date_limit'); ?>"> |
205 | 205 | <?php _e('Number of Dates to Display:', 'event_espresso'); ?> |
206 | 206 | </label> |
207 | - <input id="<?php echo $this->get_field_id('date_limit'); ?>" name="<?php echo $this->get_field_name('date_limit'); ?>" value="<?php echo esc_attr( $instance['date_limit'] ); ?>" size="3" type="text" /> |
|
207 | + <input id="<?php echo $this->get_field_id('date_limit'); ?>" name="<?php echo $this->get_field_name('date_limit'); ?>" value="<?php echo esc_attr($instance['date_limit']); ?>" size="3" type="text" /> |
|
208 | 208 | </p> |
209 | 209 | <p> |
210 | 210 | <label for="<?php echo $this->get_field_id('date_range'); ?>"> |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return array Updated safe values to be saved. |
238 | 238 | */ |
239 | - public function update( $new_instance, $old_instance ) { |
|
239 | + public function update($new_instance, $old_instance) { |
|
240 | 240 | $instance = $old_instance; |
241 | - $instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : ''; |
|
241 | + $instance['title'] = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : ''; |
|
242 | 242 | $instance['category_name'] = $new_instance['category_name']; |
243 | 243 | $instance['show_expired'] = $new_instance['show_expired']; |
244 | 244 | $instance['limit'] = $new_instance['limit']; |
@@ -261,18 +261,18 @@ discard block |
||
261 | 261 | * @param array $args Widget arguments. |
262 | 262 | * @param array $instance Saved values from database. |
263 | 263 | */ |
264 | - public function widget( $args, $instance ) { |
|
264 | + public function widget($args, $instance) { |
|
265 | 265 | |
266 | 266 | global $post; |
267 | 267 | // make sure there is some kinda post object |
268 | - if ( $post instanceof WP_Post ) { |
|
268 | + if ($post instanceof WP_Post) { |
|
269 | 269 | $before_widget = ''; |
270 | 270 | $before_title = ''; |
271 | 271 | $after_title = ''; |
272 | 272 | $after_widget = ''; |
273 | 273 | // but NOT an events archives page, cuz that would be like two event lists on the same page |
274 | - $show_everywhere = isset( $instance['show_everywhere'] ) ? (bool) absint( $instance['show_everywhere'] ) : TRUE; |
|
275 | - if ( $show_everywhere || ! ( $post->post_type == 'espresso_events' && is_archive() )) { |
|
274 | + $show_everywhere = isset($instance['show_everywhere']) ? (bool) absint($instance['show_everywhere']) : TRUE; |
|
275 | + if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) { |
|
276 | 276 | // let's use some of the event helper functions' |
277 | 277 | // make separate vars out of attributes |
278 | 278 | |
@@ -291,76 +291,76 @@ discard block |
||
291 | 291 | // Before widget (defined by themes). |
292 | 292 | echo $before_widget; |
293 | 293 | // Display the widget title if one was input (before and after defined by themes). |
294 | - if ( ! empty( $title )) { |
|
295 | - echo $before_title . $title . $after_title; |
|
294 | + if ( ! empty($title)) { |
|
295 | + echo $before_title.$title.$after_title; |
|
296 | 296 | } |
297 | 297 | // grab widget settings |
298 | - $category = isset( $instance['category_name'] ) && ! empty( $instance['category_name'] ) ? $instance['category_name'] : FALSE; |
|
299 | - $show_expired = isset( $instance['show_expired'] ) ? (bool) absint( $instance['show_expired'] ) : FALSE; |
|
300 | - $image_size = isset( $instance['image_size'] ) && ! empty( $instance['image_size'] ) ? $instance['image_size'] : 'medium'; |
|
301 | - $show_desc = isset( $instance['show_desc'] ) ? (bool) absint( $instance['show_desc'] ) : TRUE; |
|
302 | - $show_dates = isset( $instance['show_dates'] ) ? (bool) absint( $instance['show_dates'] ) : TRUE; |
|
303 | - $date_limit = isset( $instance['date_limit'] ) && ! empty( $instance['date_limit'] ) ? $instance['date_limit'] : NULL; |
|
304 | - $date_range = isset( $instance['date_range'] ) && ! empty( $instance['date_range'] ) ? $instance['date_range'] : FALSE; |
|
298 | + $category = isset($instance['category_name']) && ! empty($instance['category_name']) ? $instance['category_name'] : FALSE; |
|
299 | + $show_expired = isset($instance['show_expired']) ? (bool) absint($instance['show_expired']) : FALSE; |
|
300 | + $image_size = isset($instance['image_size']) && ! empty($instance['image_size']) ? $instance['image_size'] : 'medium'; |
|
301 | + $show_desc = isset($instance['show_desc']) ? (bool) absint($instance['show_desc']) : TRUE; |
|
302 | + $show_dates = isset($instance['show_dates']) ? (bool) absint($instance['show_dates']) : TRUE; |
|
303 | + $date_limit = isset($instance['date_limit']) && ! empty($instance['date_limit']) ? $instance['date_limit'] : NULL; |
|
304 | + $date_range = isset($instance['date_range']) && ! empty($instance['date_range']) ? $instance['date_range'] : FALSE; |
|
305 | 305 | // start to build our where clause |
306 | 306 | $where = array( |
307 | 307 | // 'Datetime.DTT_is_primary' => 1, |
308 | 308 | 'status' => 'publish' |
309 | 309 | ); |
310 | 310 | // add category |
311 | - if ( $category ) { |
|
311 | + if ($category) { |
|
312 | 312 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
313 | 313 | $where['Term_Taxonomy.Term.slug'] = $category; |
314 | 314 | } |
315 | 315 | // if NOT expired then we want events that start today or in the future |
316 | - if ( ! $show_expired ) { |
|
317 | - $where['Datetime.DTT_EVT_end'] = array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ); |
|
316 | + if ( ! $show_expired) { |
|
317 | + $where['Datetime.DTT_EVT_end'] = array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')); |
|
318 | 318 | } |
319 | 319 | // run the query |
320 | - $events = EE_Registry::instance()->load_model( 'Event' )->get_all( array( |
|
320 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array( |
|
321 | 321 | $where, |
322 | - 'limit' => $instance['limit'] > 0 ? '0,' . $instance['limit'] : '0,10', |
|
322 | + 'limit' => $instance['limit'] > 0 ? '0,'.$instance['limit'] : '0,10', |
|
323 | 323 | 'order_by' => 'Datetime.DTT_EVT_start', |
324 | 324 | 'order' => 'ASC', |
325 | 325 | 'group_by' => 'EVT_ID' |
326 | 326 | )); |
327 | 327 | |
328 | - if ( ! empty( $events )) { |
|
328 | + if ( ! empty($events)) { |
|
329 | 329 | echo '<ul class="ee-upcoming-events-widget-ul">'; |
330 | - foreach ( $events as $event ) { |
|
331 | - if ( $event instanceof EE_Event && ( !is_single() || $post->ID != $event->ID() ) ) { |
|
330 | + foreach ($events as $event) { |
|
331 | + if ($event instanceof EE_Event && ( ! is_single() || $post->ID != $event->ID())) { |
|
332 | 332 | //printr( $event, '$event <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
333 | - echo '<li id="ee-upcoming-events-widget-li-' . $event->ID() . '" class="ee-upcoming-events-widget-li">'; |
|
333 | + echo '<li id="ee-upcoming-events-widget-li-'.$event->ID().'" class="ee-upcoming-events-widget-li">'; |
|
334 | 334 | // how big is the event name ? |
335 | - $name_length = strlen( $event->name() ); |
|
336 | - switch( $name_length ) { |
|
335 | + $name_length = strlen($event->name()); |
|
336 | + switch ($name_length) { |
|
337 | 337 | case $name_length > 70 : |
338 | - $len_class = ' three-line'; |
|
338 | + $len_class = ' three-line'; |
|
339 | 339 | break; |
340 | 340 | case $name_length > 35 : |
341 | - $len_class = ' two-line'; |
|
341 | + $len_class = ' two-line'; |
|
342 | 342 | break; |
343 | 343 | default : |
344 | - $len_class = ' one-line'; |
|
344 | + $len_class = ' one-line'; |
|
345 | 345 | } |
346 | - echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a' . $len_class . '" href="' . get_permalink( $event->ID() ) . '">' . $event->name() . '</a></h5>'; |
|
347 | - if ( has_post_thumbnail( $event->ID() ) && $image_size != 'none' ) { |
|
348 | - echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="' . get_permalink( $event->ID() ) . '">' . get_the_post_thumbnail( $event->ID(), $image_size ) . '</a></div>'; |
|
346 | + echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a'.$len_class.'" href="'.get_permalink($event->ID()).'">'.$event->name().'</a></h5>'; |
|
347 | + if (has_post_thumbnail($event->ID()) && $image_size != 'none') { |
|
348 | + echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="'.get_permalink($event->ID()).'">'.get_the_post_thumbnail($event->ID(), $image_size).'</a></div>'; |
|
349 | 349 | } |
350 | - $desc = $event->short_description( 25 ); |
|
351 | - if ( $show_dates ) { |
|
352 | - $date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', get_option( 'date_format' )); |
|
353 | - $time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', get_option( 'time_format' )); |
|
354 | - $single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', get_option( 'date_format' )); |
|
355 | - $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', get_option( 'time_format' )); |
|
356 | - if ( $date_range == TRUE ) { |
|
357 | - echo espresso_event_date_range( $date_format, $time_format, $single_date_format, $single_time_format, $event->ID() ); |
|
358 | - }else{ |
|
359 | - echo espresso_list_of_event_dates( $event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit ); |
|
350 | + $desc = $event->short_description(25); |
|
351 | + if ($show_dates) { |
|
352 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', get_option('date_format')); |
|
353 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', get_option('time_format')); |
|
354 | + $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', get_option('date_format')); |
|
355 | + $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', get_option('time_format')); |
|
356 | + if ($date_range == TRUE) { |
|
357 | + echo espresso_event_date_range($date_format, $time_format, $single_date_format, $single_time_format, $event->ID()); |
|
358 | + } else { |
|
359 | + echo espresso_list_of_event_dates($event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit); |
|
360 | 360 | } |
361 | 361 | } |
362 | - if ( $show_desc && $desc ) { |
|
363 | - echo '<p style="margin-top: .5em">' . $desc . '</p>'; |
|
362 | + if ($show_desc && $desc) { |
|
363 | + echo '<p style="margin-top: .5em">'.$desc.'</p>'; |
|
364 | 364 | } |
365 | 365 | echo '</li>'; |
366 | 366 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @return string |
384 | 384 | */ |
385 | 385 | public function make_the_title_a_link($title) { |
386 | - return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
386 | + return '<a href="'.EEH_Event_View::event_archive_url().'">'.$title.'</a>'; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\address\formatters; |
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 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param string $CNT_ISO |
29 | 29 | * @return string |
30 | 30 | */ |
31 | - public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) { |
|
31 | + public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) { |
|
32 | 32 | $address_formats = apply_filters( |
33 | 33 | 'FHEE__EE_Inline_Address_Formatter__address_formats', |
34 | 34 | array( |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ) |
40 | 40 | ); |
41 | 41 | // if the incoming country has a set format, use that, else use the default |
42 | - $formatted_address = isset( $address_formats[ $CNT_ISO ] ) ? $address_formats[ $CNT_ISO ] |
|
42 | + $formatted_address = isset($address_formats[$CNT_ISO]) ? $address_formats[$CNT_ISO] |
|
43 | 43 | : $address_formats['ZZZ']; |
44 | 44 | return $this->parse_formatted_address( |
45 | 45 | $address, |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | - * @param $method_name |
|
340 | + * @param string $method_name |
|
341 | 341 | */ |
342 | 342 | public static function doing_it_wrong_call( $method_name ) { |
343 | 343 | EE_Error::doing_it_wrong( __CLASS__, sprintf( __('The %s in this class is deprecated as of EE4.5.0. All functionality formerly in this class is now in the EED_Messages module.', 'event_espresso'), $method_name ), '4.5.0', E_USER_DEPRECATED ); |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | |
1151 | 1151 | /** |
1152 | 1152 | * @deprecated 4.9.0 |
1153 | - * @return array |
|
1153 | + * @return EE_messenger[] |
|
1154 | 1154 | */ |
1155 | 1155 | public function get_installed_messengers() { |
1156 | 1156 | // EE_messages has been deprecated |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * ************************************************************************ |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param \EE_Checkout $checkout |
32 | 32 | * @return string |
33 | 33 | */ |
34 | -function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) { |
|
34 | +function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) { |
|
35 | 35 | // list of old filters |
36 | 36 | $deprecated_filters = array( |
37 | 37 | 'update_registration_details' => true, |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | 'proceed_to' => true, |
42 | 42 | ); |
43 | 43 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
44 | - foreach ( $deprecated_filters as $deprecated_filter => $on ) { |
|
44 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
45 | 45 | // was this filter called ? |
46 | - if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) { |
|
46 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
47 | 47 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
48 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) { |
|
48 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) { |
|
49 | 49 | EE_Error::doing_it_wrong( |
50 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
50 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
51 | 51 | sprintf( |
52 | - __( 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ), |
|
53 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
52 | + __('The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'), |
|
53 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
54 | 54 | '<br />', |
55 | 55 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
56 | 56 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -60,24 +60,24 @@ discard block |
||
60 | 60 | ); |
61 | 61 | } |
62 | 62 | } else { |
63 | - unset( $deprecated_filters[ $deprecated_filter ] ); |
|
63 | + unset($deprecated_filters[$deprecated_filter]); |
|
64 | 64 | } |
65 | 65 | } |
66 | - if ( ! empty( $deprecated_filters )) { |
|
67 | - |
|
68 | - if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) { |
|
69 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text ); |
|
70 | - } else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) { |
|
71 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text ); |
|
72 | - } else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) { |
|
73 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text ); |
|
66 | + if ( ! empty($deprecated_filters)) { |
|
67 | + |
|
68 | + if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
69 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text); |
|
70 | + } else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
71 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text); |
|
72 | + } else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
73 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text); |
|
74 | 74 | } |
75 | - if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
76 | - if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) { |
|
77 | - $submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text ); |
|
75 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
76 | + if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
77 | + $submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text); |
|
78 | 78 | } |
79 | - if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) { |
|
80 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name(); |
|
79 | + if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
80 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name(); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | return $submit_button_text; |
86 | 86 | |
87 | 87 | } |
88 | -add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 ); |
|
88 | +add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2); |
|
89 | 89 | |
90 | 90 | |
91 | 91 | |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | * @param \EE_Checkout $checkout |
97 | 97 | * @param boolean $status_updates |
98 | 98 | */ |
99 | -function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) { |
|
99 | +function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) { |
|
100 | 100 | $action_ref = NULL; |
101 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
102 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
103 | - if ( $action_ref ) { |
|
101 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
102 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
103 | + if ($action_ref) { |
|
104 | 104 | |
105 | 105 | EE_Error::doing_it_wrong( |
106 | 106 | $action_ref, |
107 | 107 | sprintf( |
108 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ), |
|
108 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'), |
|
109 | 109 | '<br />', |
110 | 110 | '/core/business/EE_Transaction_Processor.class.php', |
111 | 111 | 'AHEE__EE_Transaction_Processor__finalize', |
@@ -116,29 +116,29 @@ discard block |
||
116 | 116 | '4.6.0', |
117 | 117 | E_USER_DEPRECATED |
118 | 118 | ); |
119 | - switch ( $action_ref ) { |
|
119 | + switch ($action_ref) { |
|
120 | 120 | case 'AHEE__EE_Transaction__finalize__new_transaction' : |
121 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request ); |
|
121 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request); |
|
122 | 122 | break; |
123 | 123 | case 'AHEE__EE_Transaction__finalize__all_transaction' : |
124 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request ); |
|
124 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request); |
|
125 | 125 | break; |
126 | 126 | } |
127 | 127 | } |
128 | 128 | } |
129 | -add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 ); |
|
129 | +add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2); |
|
130 | 130 | /** |
131 | 131 | * ee_deprecated_finalize_registration |
132 | 132 | * |
133 | 133 | * @param EE_Registration $registration |
134 | 134 | */ |
135 | -function ee_deprecated_finalize_registration( EE_Registration $registration ) { |
|
136 | - $action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
137 | - if ( $action_ref ) { |
|
135 | +function ee_deprecated_finalize_registration(EE_Registration $registration) { |
|
136 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
137 | + if ($action_ref) { |
|
138 | 138 | EE_Error::doing_it_wrong( |
139 | 139 | $action_ref, |
140 | 140 | sprintf( |
141 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ), |
|
141 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'), |
|
142 | 142 | '<br />', |
143 | 143 | '/core/business/EE_Registration_Processor.class.php', |
144 | 144 | 'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook' |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | '4.6.0', |
147 | 147 | E_USER_DEPRECATED |
148 | 148 | ); |
149 | - do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ))); |
|
149 | + do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))); |
|
150 | 150 | } |
151 | 151 | } |
152 | -add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 ); |
|
152 | +add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1); |
|
153 | 153 | |
154 | 154 | |
155 | 155 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return array |
172 | 172 | */ |
173 | -function ee_deprecated_get_templates( $templates, EE_messenger $messenger, EE_message_type $message_type, EE_Messages_Template_Pack $template_pack ) { |
|
173 | +function ee_deprecated_get_templates($templates, EE_messenger $messenger, EE_message_type $message_type, EE_Messages_Template_Pack $template_pack) { |
|
174 | 174 | $old_default_classnames = array( |
175 | 175 | 'EE_Messages_Email_Cancelled_Registration_Defaults', |
176 | 176 | 'EE_Messages_Email_Declined_Registration_Defaults', |
@@ -186,23 +186,23 @@ discard block |
||
186 | 186 | |
187 | 187 | $old_class_instance = new stdClass(); |
188 | 188 | |
189 | - foreach ( $old_default_classnames as $classname ) { |
|
190 | - $filter_ref = 'FHEE__' . $classname . '___create_new_templates___templates'; |
|
191 | - if ( has_filter( $filter_ref ) ) { |
|
192 | - EE_Error::doing_it_wrong( $filter_ref, __('This filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the new filter provided which is "FHEE__EE_Template_Pack___get_templates__templates" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED ); |
|
189 | + foreach ($old_default_classnames as $classname) { |
|
190 | + $filter_ref = 'FHEE__'.$classname.'___create_new_templates___templates'; |
|
191 | + if (has_filter($filter_ref)) { |
|
192 | + EE_Error::doing_it_wrong($filter_ref, __('This filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the new filter provided which is "FHEE__EE_Template_Pack___get_templates__templates" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED); |
|
193 | 193 | } |
194 | - $templates = apply_filters( $filter_ref, $templates, $old_class_instance ); |
|
194 | + $templates = apply_filters($filter_ref, $templates, $old_class_instance); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return $templates; |
198 | 198 | } |
199 | -add_filter( 'FHEE__EE_Template_Pack___get_templates__templates', 'ee_deprecated_get_templates', 10, 4 ); |
|
199 | +add_filter('FHEE__EE_Template_Pack___get_templates__templates', 'ee_deprecated_get_templates', 10, 4); |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called. |
203 | 203 | * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately. |
204 | 204 | */ |
205 | -function ee_deprecated_hooks(){ |
|
205 | +function ee_deprecated_hooks() { |
|
206 | 206 | /** |
207 | 207 | * @var $hooks array where keys are hook names, and their values are array{ |
208 | 208 | * @type string $version when deprecated |
@@ -213,26 +213,26 @@ discard block |
||
213 | 213 | $hooks = array( |
214 | 214 | 'AHEE__EE_System___do_setup_validations' => array( |
215 | 215 | 'version' => '4.6.0', |
216 | - 'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ), |
|
216 | + 'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'), |
|
217 | 217 | 'still_works' => FALSE |
218 | 218 | ) |
219 | 219 | ); |
220 | - foreach( $hooks as $name => $deprecation_info ){ |
|
221 | - if( has_action( $name ) ){ |
|
220 | + foreach ($hooks as $name => $deprecation_info) { |
|
221 | + if (has_action($name)) { |
|
222 | 222 | EE_Error::doing_it_wrong( |
223 | 223 | $name, |
224 | 224 | sprintf( |
225 | - __('This filter is deprecated. %1$s%2$s','event_espresso'), |
|
226 | - $deprecation_info[ 'still_works' ] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ), |
|
227 | - isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' ) |
|
225 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
226 | + $deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'), |
|
227 | + isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso') |
|
228 | 228 | ), |
229 | - isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ), |
|
229 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso'), |
|
230 | 230 | E_USER_DEPRECATED |
231 | 231 | ); |
232 | 232 | } |
233 | 233 | } |
234 | 234 | } |
235 | -add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' ); |
|
235 | +add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
|
236 | 236 | |
237 | 237 | |
238 | 238 | |
@@ -255,25 +255,25 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @return string The default contents for the messenger, message type, context and field. |
257 | 257 | */ |
258 | -function ee_deprecated_get_default_field_content( $contents, $actual_path, EE_messenger $messenger, EE_message_type $message_type, $field, $context, EE_Messages_Template_Pack $template_pack ) { |
|
258 | +function ee_deprecated_get_default_field_content($contents, $actual_path, EE_messenger $messenger, EE_message_type $message_type, $field, $context, EE_Messages_Template_Pack $template_pack) { |
|
259 | 259 | |
260 | 260 | $classnames_to_try = array( |
261 | - get_class( $messenger ) => $messenger, |
|
262 | - get_class( $message_type ) => $message_type, |
|
261 | + get_class($messenger) => $messenger, |
|
262 | + get_class($message_type) => $message_type, |
|
263 | 263 | 'EE_Messages_Base' => $message_type |
264 | 264 | ); |
265 | 265 | |
266 | - foreach ( $classnames_to_try as $classname => $obj ) { |
|
267 | - $filter_ref = 'FHEE__' . $classname . '__get_default_field_content'; |
|
268 | - if ( has_filter( $filter_ref ) ) { |
|
269 | - EE_Error::doing_it_wrong( $filter_ref, __('This filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_specific_template__contents" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED ); |
|
266 | + foreach ($classnames_to_try as $classname => $obj) { |
|
267 | + $filter_ref = 'FHEE__'.$classname.'__get_default_field_content'; |
|
268 | + if (has_filter($filter_ref)) { |
|
269 | + EE_Error::doing_it_wrong($filter_ref, __('This filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_specific_template__contents" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED); |
|
270 | 270 | } |
271 | - $contents = apply_filters( $filter_ref, $contents, $obj ); |
|
271 | + $contents = apply_filters($filter_ref, $contents, $obj); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | return $contents; |
275 | 275 | } |
276 | -add_filter( 'FHEE__EE_Messages_Template_Pack__get_specific_template__contents', 'ee_deprecated_get_default_field_content', 10, 7 ); |
|
276 | +add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', 'ee_deprecated_get_default_field_content', 10, 7); |
|
277 | 277 | |
278 | 278 | |
279 | 279 | |
@@ -301,23 +301,23 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @return string The path to the file being used. |
303 | 303 | */ |
304 | -function ee_deprecated_get_inline_css_template_filters( $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack ) { |
|
304 | +function ee_deprecated_get_inline_css_template_filters($variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack) { |
|
305 | 305 | |
306 | - if ( $messenger == 'email' ) { |
|
306 | + if ($messenger == 'email') { |
|
307 | 307 | $filter_ref = $url ? 'FHEE__EE_Email_messenger__get_inline_css_template__css_url' : 'FHEE__EE_Email_messenger__get_inline_css_template__css_path'; |
308 | - } elseif ( $messenger == 'html' ) { |
|
308 | + } elseif ($messenger == 'html') { |
|
309 | 309 | $filter_ref = $url ? 'FHEE__EE_Html_messenger__get_inline_css_template__css_url' : 'FHEE__EE_Html_messenger__get_inline_css_template__css_path'; |
310 | 310 | } else { |
311 | 311 | return $variation_path; |
312 | 312 | } |
313 | 313 | |
314 | - if ( has_filter( $filter_ref ) ) { |
|
315 | - EE_Error::doing_it_wrong( $filter_ref, __('This filter is deprecated. It is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_variation" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED ); |
|
314 | + if (has_filter($filter_ref)) { |
|
315 | + EE_Error::doing_it_wrong($filter_ref, __('This filter is deprecated. It is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_variation" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED); |
|
316 | 316 | } |
317 | 317 | |
318 | - return apply_filters( $filter_ref, $variation_path, $url, $type ); |
|
318 | + return apply_filters($filter_ref, $variation_path, $url, $type); |
|
319 | 319 | } |
320 | -add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', 'ee_deprecated_get_inline_css_template_filters', 10, 8 ); |
|
320 | +add_filter('FHEE__EE_Messages_Template_Pack__get_variation', 'ee_deprecated_get_inline_css_template_filters', 10, 8); |
|
321 | 321 | |
322 | 322 | |
323 | 323 | |
@@ -333,78 +333,78 @@ discard block |
||
333 | 333 | class EE_Messages_Init extends EE_Base { |
334 | 334 | |
335 | 335 | public function __construct() { |
336 | - self::doing_it_wrong_call( __METHOD__ ); |
|
336 | + self::doing_it_wrong_call(__METHOD__); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | 340 | * @param $method_name |
341 | 341 | */ |
342 | - public static function doing_it_wrong_call( $method_name ) { |
|
343 | - EE_Error::doing_it_wrong( __CLASS__, sprintf( __('The %s in this class is deprecated as of EE4.5.0. All functionality formerly in this class is now in the EED_Messages module.', 'event_espresso'), $method_name ), '4.5.0', E_USER_DEPRECATED ); |
|
342 | + public static function doing_it_wrong_call($method_name) { |
|
343 | + EE_Error::doing_it_wrong(__CLASS__, sprintf(__('The %s in this class is deprecated as of EE4.5.0. All functionality formerly in this class is now in the EED_Messages module.', 'event_espresso'), $method_name), '4.5.0', E_USER_DEPRECATED); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
347 | 347 | * @deprecated 4.5.0 |
348 | 348 | */ |
349 | 349 | public static function set_autoloaders() { |
350 | - self::doing_it_wrong_call( __METHOD__ ); |
|
350 | + self::doing_it_wrong_call(__METHOD__); |
|
351 | 351 | EED_Messages::set_autoloaders(); |
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
355 | 355 | * @deprecated 4.5.0 |
356 | 356 | */ |
357 | - public function payment_reminder( $transaction ) { |
|
358 | - self::doing_it_wrong_call( __METHOD__ ); |
|
359 | - EED_Messages::payment_reminder( $transaction ); |
|
357 | + public function payment_reminder($transaction) { |
|
358 | + self::doing_it_wrong_call(__METHOD__); |
|
359 | + EED_Messages::payment_reminder($transaction); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
363 | 363 | * @deprecated 4.5.0 |
364 | 364 | */ |
365 | - public function payment( $transaction, $payment ) { |
|
366 | - self::doing_it_wrong_call( __METHOD__ ); |
|
367 | - EED_Messages::payment( $transaction, $payment ); |
|
365 | + public function payment($transaction, $payment) { |
|
366 | + self::doing_it_wrong_call(__METHOD__); |
|
367 | + EED_Messages::payment($transaction, $payment); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
371 | 371 | * @deprecated 4.5.0 |
372 | 372 | */ |
373 | - public function cancelled_registration( $transaction ) { |
|
374 | - self::doing_it_wrong_call( __METHOD__ ); |
|
375 | - EED_Messages::cancelled_registration( $transaction ); |
|
373 | + public function cancelled_registration($transaction) { |
|
374 | + self::doing_it_wrong_call(__METHOD__); |
|
375 | + EED_Messages::cancelled_registration($transaction); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
379 | 379 | * @deprecated 4.5.0 |
380 | 380 | */ |
381 | - public function maybe_registration( $transaction, $reg_msg, $from_admin ) { |
|
382 | - self::doing_it_wrong_call( __METHOD__ ); |
|
383 | - EED_Messages::maybe_registration( $transaction, $reg_msg, $from_admin ); |
|
381 | + public function maybe_registration($transaction, $reg_msg, $from_admin) { |
|
382 | + self::doing_it_wrong_call(__METHOD__); |
|
383 | + EED_Messages::maybe_registration($transaction, $reg_msg, $from_admin); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
387 | 387 | * @deprecated 4.5.0 |
388 | 388 | */ |
389 | - public function process_resend( $success, $req_data ) { |
|
390 | - self::doing_it_wrong_call( __METHOD__ ); |
|
391 | - EED_Messages::process_resend( $req_data ); |
|
389 | + public function process_resend($success, $req_data) { |
|
390 | + self::doing_it_wrong_call(__METHOD__); |
|
391 | + EED_Messages::process_resend($req_data); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
395 | 395 | * @deprecated 4.5.0 |
396 | 396 | */ |
397 | - public function process_admin_payment( $success, $payment ) { |
|
398 | - self::doing_it_wrong_call( __METHOD__ ); |
|
399 | - EED_Messages::process_admin_payment( $payment ); |
|
397 | + public function process_admin_payment($success, $payment) { |
|
398 | + self::doing_it_wrong_call(__METHOD__); |
|
399 | + EED_Messages::process_admin_payment($payment); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
403 | 403 | * @deprecated 4.5.0 |
404 | 404 | */ |
405 | - public function send_newsletter_message( $contacts, $grp_id ) { |
|
406 | - self::doing_it_wrong_call( __METHOD__ ); |
|
407 | - EED_Messages::send_newsletter_message( $contacts, $grp_id ); |
|
405 | + public function send_newsletter_message($contacts, $grp_id) { |
|
406 | + self::doing_it_wrong_call(__METHOD__); |
|
407 | + EED_Messages::send_newsletter_message($contacts, $grp_id); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | * |
426 | 426 | * @return array additional cpts. |
427 | 427 | */ |
428 | -function ee_deprecated_get_cpts( $cpts ) { |
|
429 | - if ( has_filter( 'FHEE__EE_Register_CPTs__construct__CPTs' ) ) { |
|
430 | - EE_Error::doing_it_wrong( 'FHEE__EE_Register_CPTs__construct__CPTs', __('This filter is deprecated. It will still work for the time being. However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_CPTs__cpts" found in EE_Register_CPTs::get_CPTs()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED ); |
|
428 | +function ee_deprecated_get_cpts($cpts) { |
|
429 | + if (has_filter('FHEE__EE_Register_CPTs__construct__CPTs')) { |
|
430 | + EE_Error::doing_it_wrong('FHEE__EE_Register_CPTs__construct__CPTs', __('This filter is deprecated. It will still work for the time being. However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_CPTs__cpts" found in EE_Register_CPTs::get_CPTs()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED); |
|
431 | 431 | } |
432 | - return apply_filters( 'FHEE__EE_Register_CPTs__construct__CPTs', $cpts ); |
|
432 | + return apply_filters('FHEE__EE_Register_CPTs__construct__CPTs', $cpts); |
|
433 | 433 | } |
434 | -add_filter( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', 'ee_deprecated_get_cpts', 10 ); |
|
434 | +add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', 'ee_deprecated_get_cpts', 10); |
|
435 | 435 | |
436 | 436 | |
437 | 437 | |
@@ -445,13 +445,13 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @return array additional custom taxonomies. |
447 | 447 | */ |
448 | -function ee_deprecated_get_taxonomies( $cts ) { |
|
449 | - if ( has_filter( 'FHEE__EE_Register_CPTs__construct__taxonomies' ) ) { |
|
450 | - EE_Error::doing_it_wrong( 'FHEE__EE_Register_CPTs__construct__taxonomies', __('This filter is deprecated. It will still work for the time being. However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_taxonomies__taxonomies" found in EE_Register_CPTs::get_taxonomies()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED ); |
|
448 | +function ee_deprecated_get_taxonomies($cts) { |
|
449 | + if (has_filter('FHEE__EE_Register_CPTs__construct__taxonomies')) { |
|
450 | + EE_Error::doing_it_wrong('FHEE__EE_Register_CPTs__construct__taxonomies', __('This filter is deprecated. It will still work for the time being. However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_taxonomies__taxonomies" found in EE_Register_CPTs::get_taxonomies()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED); |
|
451 | 451 | } |
452 | - return apply_filters( 'FHEE__EE_Register_CPTs__construct__taxonomies', $cts ); |
|
452 | + return apply_filters('FHEE__EE_Register_CPTs__construct__taxonomies', $cts); |
|
453 | 453 | } |
454 | -add_filter( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', 'ee_deprecated_get_taxonomies', 10 ); |
|
454 | +add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', 'ee_deprecated_get_taxonomies', 10); |
|
455 | 455 | |
456 | 456 | |
457 | 457 | |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | * @return boolean |
464 | 464 | */ |
465 | 465 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() { |
466 | - $in_use = has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' ) |
|
467 | - || has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' ); |
|
468 | - if( $in_use ) { |
|
466 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
467 | + || has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'); |
|
468 | + if ($in_use) { |
|
469 | 469 | $msg = __( |
470 | 470 | 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
471 | 471 | . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
@@ -474,18 +474,18 @@ discard block |
||
474 | 474 | 'event_espresso' ) |
475 | 475 | ; |
476 | 476 | EE_Error::doing_it_wrong( |
477 | - __CLASS__ . '::' . __FUNCTION__, |
|
477 | + __CLASS__.'::'.__FUNCTION__, |
|
478 | 478 | $msg, |
479 | 479 | '4.8.32.rc.000' |
480 | 480 | ); |
481 | 481 | //it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
482 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
483 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
482 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
483 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | return $in_use; |
487 | 487 | } |
488 | -add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' ); |
|
488 | +add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'); |
|
489 | 489 | |
490 | 490 | /** |
491 | 491 | * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165 |
@@ -494,34 +494,34 @@ discard block |
||
494 | 494 | * @param EE_Admin_Page $admin_page |
495 | 495 | * @return void |
496 | 496 | */ |
497 | -function ee_deprecated_update_attendee_registration_form_old( $admin_page ) { |
|
497 | +function ee_deprecated_update_attendee_registration_form_old($admin_page) { |
|
498 | 498 | //check if the old hooks are in use. If not, do the default |
499 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
500 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
499 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
500 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
501 | 501 | return; |
502 | 502 | } |
503 | 503 | $req_data = $admin_page->get_request_data(); |
504 | - $qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE; |
|
505 | - $REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE; |
|
506 | - $qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns ); |
|
507 | - if ( ! $REG_ID || ! $qstns ) { |
|
508 | - EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
504 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE; |
|
505 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE; |
|
506 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
507 | + if ( ! $REG_ID || ! $qstns) { |
|
508 | + EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
509 | 509 | } |
510 | 510 | $success = TRUE; |
511 | 511 | |
512 | 512 | // allow others to get in on this awesome fun :D |
513 | - do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns ); |
|
513 | + do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns); |
|
514 | 514 | // loop thru questions... FINALLY!!! |
515 | 515 | |
516 | - foreach ( $qstns as $QST_ID => $qstn ) { |
|
516 | + foreach ($qstns as $QST_ID => $qstn) { |
|
517 | 517 | //if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
518 | - if ( !is_array($qstn) ) { |
|
519 | - $success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn); |
|
518 | + if ( ! is_array($qstn)) { |
|
519 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
520 | 520 | continue; |
521 | 521 | } |
522 | 522 | |
523 | 523 | |
524 | - foreach ( $qstn as $ANS_ID => $ANS_value ) { |
|
524 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
525 | 525 | //get answer |
526 | 526 | $query_params = array( |
527 | 527 | 0 => array( |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | ); |
533 | 533 | $answer = EEM_Answer::instance()->get_one($query_params); |
534 | 534 | //this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
535 | - if ( ! $answer instanceof EE_Answer ) { |
|
535 | + if ( ! $answer instanceof EE_Answer) { |
|
536 | 536 | $set_values = array( |
537 | 537 | 'QST_ID' => $QST_ID, |
538 | 538 | 'REG_ID' => $REG_ID, |
@@ -547,11 +547,11 @@ discard block |
||
547 | 547 | } |
548 | 548 | } |
549 | 549 | $what = __('Registration Form', 'event_espresso'); |
550 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
551 | - $admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
550 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
551 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
552 | 552 | exit; |
553 | 553 | } |
554 | -add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 ); |
|
554 | +add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1); |
|
555 | 555 | /** |
556 | 556 | * Render the registration admin page's custom questions area in the old fashion |
557 | 557 | * and firing the old hooks. When this method is removed, we can probably also |
@@ -564,31 +564,31 @@ discard block |
||
564 | 564 | * @return bool |
565 | 565 | * @throws \EE_Error |
566 | 566 | */ |
567 | -function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) { |
|
567 | +function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) { |
|
568 | 568 | //check if the old hooks are in use. If not, do the default |
569 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
570 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
569 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
570 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
571 | 571 | return $do_default_action; |
572 | 572 | } |
573 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 ); |
|
574 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 ); |
|
575 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 ); |
|
576 | - add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 ); |
|
573 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1); |
|
574 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1); |
|
575 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
576 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
577 | 577 | |
578 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') ); |
|
578 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID')); |
|
579 | 579 | |
580 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
580 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
581 | 581 | $template_args = array( |
582 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ), |
|
582 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
583 | 583 | 'reg_questions_form_action' => 'edit_registration', |
584 | 584 | 'REG_ID' => $registration->ID() |
585 | 585 | ); |
586 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
587 | - echo EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
586 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
587 | + echo EEH_Template::display_template($template_path, $template_args, TRUE); |
|
588 | 588 | //indicate that we should not do the default admin page code |
589 | 589 | return false; |
590 | 590 | } |
591 | -add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 ); |
|
591 | +add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3); |
|
592 | 592 | |
593 | 593 | |
594 | 594 | |
@@ -629,9 +629,9 @@ discard block |
||
629 | 629 | '4.9.0' |
630 | 630 | ); |
631 | 631 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
632 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
633 | - $messenger = $message_resource_manager->get_messenger( $messenger_name ); |
|
634 | - $message_type = $message_resource_manager->get_message_type( $message_type_name ); |
|
632 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
633 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
634 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
635 | 635 | return EE_Registry::instance()->load_lib( |
636 | 636 | 'Messages_Template_Defaults', |
637 | 637 | array( |
@@ -696,15 +696,15 @@ discard block |
||
696 | 696 | /** |
697 | 697 | * @param string $method |
698 | 698 | */ |
699 | - public function _class_is_deprecated( $method ) { |
|
699 | + public function _class_is_deprecated($method) { |
|
700 | 700 | // EE_messages has been deprecated |
701 | 701 | EE_Error::doing_it_wrong( |
702 | - 'EE_messages::' . $method, |
|
703 | - __( 'EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.' ), |
|
702 | + 'EE_messages::'.$method, |
|
703 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
704 | 704 | '4.9.0' |
705 | 705 | ); |
706 | 706 | // Please use EE_Message_Resource_Manager instead |
707 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
707 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | |
@@ -714,10 +714,10 @@ discard block |
||
714 | 714 | * @param string $messenger_name |
715 | 715 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
716 | 716 | */ |
717 | - public function ensure_messenger_is_active( $messenger_name ) { |
|
717 | + public function ensure_messenger_is_active($messenger_name) { |
|
718 | 718 | // EE_messages has been deprecated |
719 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
720 | - return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name ); |
|
719 | + $this->_class_is_deprecated(__FUNCTION__); |
|
720 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | |
@@ -729,10 +729,10 @@ discard block |
||
729 | 729 | * @return bool true if it got activated (or was active) and false if not. |
730 | 730 | * @throws \EE_Error |
731 | 731 | */ |
732 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
732 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
733 | 733 | // EE_messages has been deprecated |
734 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
735 | - return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger ); |
|
734 | + $this->_class_is_deprecated(__FUNCTION__); |
|
735 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | |
@@ -745,10 +745,10 @@ discard block |
||
745 | 745 | * they are already setup.) |
746 | 746 | * @return boolean an array of generated templates or false if nothing generated/activated. |
747 | 747 | */ |
748 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ) { |
|
748 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
749 | 749 | // EE_messages has been deprecated |
750 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
751 | - return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate ); |
|
750 | + $this->_class_is_deprecated(__FUNCTION__); |
|
751 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | * |
761 | 761 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
762 | 762 | */ |
763 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
763 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
764 | 764 | // EE_messages has been deprecated |
765 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
766 | - return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type ); |
|
765 | + $this->_class_is_deprecated(__FUNCTION__); |
|
766 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | |
@@ -773,10 +773,10 @@ discard block |
||
773 | 773 | * @param string $messenger |
774 | 774 | * @return EE_messenger | null |
775 | 775 | */ |
776 | - public function get_messenger_if_active( $messenger ) { |
|
776 | + public function get_messenger_if_active($messenger) { |
|
777 | 777 | // EE_messages has been deprecated |
778 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
779 | - return $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
778 | + $this->_class_is_deprecated(__FUNCTION__); |
|
779 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | |
@@ -797,9 +797,9 @@ discard block |
||
797 | 797 | * 'message_type' => null |
798 | 798 | * ) |
799 | 799 | */ |
800 | - public function validate_for_use( EE_Message $message ) { |
|
800 | + public function validate_for_use(EE_Message $message) { |
|
801 | 801 | // EE_messages has been deprecated |
802 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
802 | + $this->_class_is_deprecated(__FUNCTION__); |
|
803 | 803 | return array( |
804 | 804 | 'messenger' => $message->messenger_object(), |
805 | 805 | 'message_type' => $message->message_type_object(), |
@@ -827,41 +827,41 @@ discard block |
||
827 | 827 | $send = true |
828 | 828 | ) { |
829 | 829 | // EE_messages has been deprecated |
830 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
830 | + $this->_class_is_deprecated(__FUNCTION__); |
|
831 | 831 | /** @type EE_Messages_Processor $processor */ |
832 | - $processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
832 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
833 | 833 | $error = false; |
834 | 834 | //try to intelligently determine what method we'll call based on the incoming data. |
835 | 835 | //if generating and sending are different then generate and send immediately. |
836 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
836 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
837 | 837 | //in the legacy system, when generating and sending were different, that means all the |
838 | 838 | //vars are already in the request object. So let's just use that. |
839 | 839 | try { |
840 | 840 | /** @type EE_Message_To_Generate_From_Request $mtg */ |
841 | - $mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
842 | - $processor->generate_and_send_now( $mtg ); |
|
843 | - } catch ( EE_Error $e ) { |
|
841 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
842 | + $processor->generate_and_send_now($mtg); |
|
843 | + } catch (EE_Error $e) { |
|
844 | 844 | $error_msg = __( |
845 | 845 | 'Please note that a system message failed to send due to a technical issue.', |
846 | 846 | 'event_espresso' |
847 | 847 | ); |
848 | 848 | // add specific message for developers if WP_DEBUG in on |
849 | - $error_msg .= '||' . $e->getMessage(); |
|
850 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
849 | + $error_msg .= '||'.$e->getMessage(); |
|
850 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
851 | 851 | $error = true; |
852 | 852 | } |
853 | 853 | } else { |
854 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
854 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
855 | 855 | //let's find out if there were any errors and how many successfully were queued. |
856 | 856 | $count_errors = $processor->get_queue()->count_STS_in_queue( |
857 | - array( EEM_Message::status_failed, EEM_Message::status_debug_only ) |
|
857 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
858 | 858 | ); |
859 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
860 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
859 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
860 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
861 | 861 | $count_errors = $count_errors + $count_retry; |
862 | - if ( $count_errors > 0 ) { |
|
862 | + if ($count_errors > 0) { |
|
863 | 863 | $error = true; |
864 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
864 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
865 | 865 | $message = sprintf( |
866 | 866 | __( |
867 | 867 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | $count_errors, |
871 | 871 | $count_queued |
872 | 872 | ); |
873 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
873 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
874 | 874 | $message = sprintf( |
875 | 875 | __( |
876 | 876 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -879,7 +879,7 @@ discard block |
||
879 | 879 | $count_errors, |
880 | 880 | $count_queued |
881 | 881 | ); |
882 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
882 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
883 | 883 | $message = sprintf( |
884 | 884 | __( |
885 | 885 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -897,9 +897,9 @@ discard block |
||
897 | 897 | $count_errors |
898 | 898 | ); |
899 | 899 | } |
900 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
900 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
901 | 901 | } else { |
902 | - if ( $count_queued === 1 ) { |
|
902 | + if ($count_queued === 1) { |
|
903 | 903 | $message = sprintf( |
904 | 904 | __( |
905 | 905 | '%d message successfully queued for generation.', |
@@ -916,18 +916,18 @@ discard block |
||
916 | 916 | $count_queued |
917 | 917 | ); |
918 | 918 | } |
919 | - EE_Error::add_success( $message ); |
|
919 | + EE_Error::add_success($message); |
|
920 | 920 | } |
921 | 921 | } |
922 | 922 | //if no error then return the generated message(s). |
923 | - if ( ! $error && ! $send ) { |
|
924 | - $generated_queue = $processor->generate_queue( false ); |
|
923 | + if ( ! $error && ! $send) { |
|
924 | + $generated_queue = $processor->generate_queue(false); |
|
925 | 925 | //get message and return. |
926 | 926 | $generated_queue->get_message_repository()->rewind(); |
927 | 927 | $messages = array(); |
928 | - while ( $generated_queue->get_message_repository()->valid() ) { |
|
928 | + while ($generated_queue->get_message_repository()->valid()) { |
|
929 | 929 | $message = $generated_queue->get_message_repository()->current(); |
930 | - if ( $message instanceof EE_Message ) { |
|
930 | + if ($message instanceof EE_Message) { |
|
931 | 931 | //set properties that might be expected by add-ons (backward compat) |
932 | 932 | $message->content = $message->content(); |
933 | 933 | $message->template_pack = $message->get_template_pack(); |
@@ -952,10 +952,10 @@ discard block |
||
952 | 952 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
953 | 953 | * @return string The body of the message. |
954 | 954 | */ |
955 | - public function preview_message( $type, $context, $messenger, $send = false ) { |
|
955 | + public function preview_message($type, $context, $messenger, $send = false) { |
|
956 | 956 | // EE_messages has been deprecated |
957 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
958 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
957 | + $this->_class_is_deprecated(__FUNCTION__); |
|
958 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | |
@@ -969,14 +969,14 @@ discard block |
||
969 | 969 | * |
970 | 970 | * @return bool success or fail. |
971 | 971 | */ |
972 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
972 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
973 | 973 | // EE_messages has been deprecated |
974 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
974 | + $this->_class_is_deprecated(__FUNCTION__); |
|
975 | 975 | //setup for sending to new method. |
976 | 976 | /** @type EE_Messages_Queue $queue */ |
977 | - $queue = EE_Registry::instance()->load_lib( 'Messages_Queue' ); |
|
977 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
978 | 978 | //make sure we have a proper message object |
979 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
979 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
980 | 980 | $msg = EE_Message_Factory::create( |
981 | 981 | array( |
982 | 982 | 'MSG_messenger' => $messenger, |
@@ -988,15 +988,15 @@ discard block |
||
988 | 988 | } else { |
989 | 989 | $msg = $message; |
990 | 990 | } |
991 | - if ( ! $msg instanceof EE_Message ) { |
|
991 | + if ( ! $msg instanceof EE_Message) { |
|
992 | 992 | return false; |
993 | 993 | } |
994 | 994 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
995 | - if ( ! empty( $msg->content ) ) { |
|
996 | - $msg->set( 'MSG_content', $msg->content ); |
|
995 | + if ( ! empty($msg->content)) { |
|
996 | + $msg->set('MSG_content', $msg->content); |
|
997 | 997 | } |
998 | - $queue->add( $msg ); |
|
999 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
998 | + $queue->add($msg); |
|
999 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | |
@@ -1010,11 +1010,11 @@ discard block |
||
1010 | 1010 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
1011 | 1011 | * @throws \EE_Error |
1012 | 1012 | */ |
1013 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
1013 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
1014 | 1014 | // EE_messages has been deprecated |
1015 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1016 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1017 | - return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global ); |
|
1015 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1016 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1017 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | |
@@ -1025,11 +1025,11 @@ discard block |
||
1025 | 1025 | * @param string $message_type_name name of EE_message_type |
1026 | 1026 | * @return array |
1027 | 1027 | */ |
1028 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
1028 | + public function get_fields($messenger_name, $message_type_name) { |
|
1029 | 1029 | // EE_messages has been deprecated |
1030 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1031 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1032 | - return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name ); |
|
1030 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1031 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1032 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | |
@@ -1043,13 +1043,13 @@ discard block |
||
1043 | 1043 | * @return array multidimensional array of messenger and message_type objects |
1044 | 1044 | * (messengers index, and message_type index); |
1045 | 1045 | */ |
1046 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
1046 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
1047 | 1047 | // EE_messages has been deprecated |
1048 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1049 | - if ( $skip_cache ) { |
|
1048 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1049 | + if ($skip_cache) { |
|
1050 | 1050 | $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
1051 | 1051 | } |
1052 | - switch ( $type ) { |
|
1052 | + switch ($type) { |
|
1053 | 1053 | case 'messengers' : |
1054 | 1054 | return array( |
1055 | 1055 | 'messenger' => $this->_message_resource_manager->installed_messengers(), |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | */ |
1079 | 1079 | public function get_active_messengers() { |
1080 | 1080 | // EE_messages has been deprecated |
1081 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1081 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1082 | 1082 | return $this->_message_resource_manager->active_messengers(); |
1083 | 1083 | } |
1084 | 1084 | |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | */ |
1091 | 1091 | public function get_active_message_types() { |
1092 | 1092 | // EE_messages has been deprecated |
1093 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1093 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1094 | 1094 | return $this->_message_resource_manager->list_of_active_message_types(); |
1095 | 1095 | } |
1096 | 1096 | |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | */ |
1103 | 1103 | public function get_active_message_type_objects() { |
1104 | 1104 | // EE_messages has been deprecated |
1105 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1105 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1106 | 1106 | return $this->_message_resource_manager->get_active_message_type_objects(); |
1107 | 1107 | } |
1108 | 1108 | |
@@ -1114,10 +1114,10 @@ discard block |
||
1114 | 1114 | * @param string $messenger The messenger being checked |
1115 | 1115 | * @return EE_message_type[] (or empty array if none present) |
1116 | 1116 | */ |
1117 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
1117 | + public function get_active_message_types_per_messenger($messenger) { |
|
1118 | 1118 | // EE_messages has been deprecated |
1119 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1120 | - return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger ); |
|
1119 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1120 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | |
@@ -1128,10 +1128,10 @@ discard block |
||
1128 | 1128 | * @param string $message_type The string should correspond to a message type. |
1129 | 1129 | * @return EE_message_type|null |
1130 | 1130 | */ |
1131 | - public function get_active_message_type( $messenger, $message_type ) { |
|
1131 | + public function get_active_message_type($messenger, $message_type) { |
|
1132 | 1132 | // EE_messages has been deprecated |
1133 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1134 | - return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type ); |
|
1133 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1134 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | */ |
1143 | 1143 | public function get_installed_message_types() { |
1144 | 1144 | // EE_messages has been deprecated |
1145 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1145 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1146 | 1146 | return $this->_message_resource_manager->installed_message_types(); |
1147 | 1147 | } |
1148 | 1148 | |
@@ -1154,7 +1154,7 @@ discard block |
||
1154 | 1154 | */ |
1155 | 1155 | public function get_installed_messengers() { |
1156 | 1156 | // EE_messages has been deprecated |
1157 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1157 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1158 | 1158 | return $this->_message_resource_manager->installed_messengers(); |
1159 | 1159 | } |
1160 | 1160 | |
@@ -1165,10 +1165,10 @@ discard block |
||
1165 | 1165 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
1166 | 1166 | * @return array |
1167 | 1167 | */ |
1168 | - public function get_all_contexts( $slugs_only = true ) { |
|
1168 | + public function get_all_contexts($slugs_only = true) { |
|
1169 | 1169 | // EE_messages has been deprecated |
1170 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1171 | - return $this->_message_resource_manager->get_all_contexts( $slugs_only ); |
|
1170 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1171 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 |
@@ -278,6 +278,7 @@ |
||
278 | 278 | |
279 | 279 | /** |
280 | 280 | * @param mixed string | EED_Module $module |
281 | + * @param string $module |
|
281 | 282 | */ |
282 | 283 | public function add_module( $module ) { |
283 | 284 | if ( $module instanceof EED_Module ) { |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | * @param \EE_Dependency_Map $dependency_map |
179 | 179 | * @return \EE_Registry instance |
180 | 180 | */ |
181 | - public static function instance( \EE_Dependency_Map $dependency_map = null ) { |
|
181 | + public static function instance(\EE_Dependency_Map $dependency_map = null) { |
|
182 | 182 | // check if class object is instantiated |
183 | - if ( ! self::$_instance instanceof EE_Registry ) { |
|
184 | - self::$_instance = new EE_Registry( $dependency_map ); |
|
183 | + if ( ! self::$_instance instanceof EE_Registry) { |
|
184 | + self::$_instance = new EE_Registry($dependency_map); |
|
185 | 185 | } |
186 | 186 | return self::$_instance; |
187 | 187 | } |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | * @param \EE_Dependency_Map $dependency_map |
197 | 197 | * @return \EE_Registry |
198 | 198 | */ |
199 | - protected function __construct( \EE_Dependency_Map $dependency_map ) { |
|
199 | + protected function __construct(\EE_Dependency_Map $dependency_map) { |
|
200 | 200 | $this->_dependency_map = $dependency_map; |
201 | - add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
|
201 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -225,19 +225,19 @@ discard block |
||
225 | 225 | $this->modules = new StdClass(); |
226 | 226 | $this->shortcodes = new StdClass(); |
227 | 227 | $this->widgets = new StdClass(); |
228 | - $this->load_core( 'Base', array(), true ); |
|
228 | + $this->load_core('Base', array(), true); |
|
229 | 229 | // add our request and response objects to the cache |
230 | - $request_loader = $this->_dependency_map->class_loader( 'EE_Request' ); |
|
230 | + $request_loader = $this->_dependency_map->class_loader('EE_Request'); |
|
231 | 231 | $this->_set_cached_class( |
232 | 232 | $request_loader(), |
233 | 233 | 'EE_Request' |
234 | 234 | ); |
235 | - $response_loader = $this->_dependency_map->class_loader( 'EE_Response' ); |
|
235 | + $response_loader = $this->_dependency_map->class_loader('EE_Response'); |
|
236 | 236 | $this->_set_cached_class( |
237 | 237 | $response_loader(), |
238 | 238 | 'EE_Response' |
239 | 239 | ); |
240 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) ); |
|
240 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function init() { |
252 | 252 | // Get current page protocol |
253 | - $protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
|
253 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
254 | 254 | // Output admin-ajax.php URL with same protocol as current page |
255 | - self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol ); |
|
256 | - self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false; |
|
255 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
256 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | |
@@ -264,14 +264,14 @@ discard block |
||
264 | 264 | * @return string |
265 | 265 | */ |
266 | 266 | public static function localize_i18n_js_strings() { |
267 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
268 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
269 | - if ( is_scalar( $value ) ) { |
|
270 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
267 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
268 | + foreach ($i18n_js_strings as $key => $value) { |
|
269 | + if (is_scalar($value)) { |
|
270 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
274 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | |
@@ -279,15 +279,15 @@ discard block |
||
279 | 279 | /** |
280 | 280 | * @param mixed string | EED_Module $module |
281 | 281 | */ |
282 | - public function add_module( $module ) { |
|
283 | - if ( $module instanceof EED_Module ) { |
|
284 | - $module_class = get_class( $module ); |
|
282 | + public function add_module($module) { |
|
283 | + if ($module instanceof EED_Module) { |
|
284 | + $module_class = get_class($module); |
|
285 | 285 | $this->modules->{$module_class} = $module; |
286 | 286 | } else { |
287 | - if ( ! class_exists( 'EE_Module_Request_Router' ) ) { |
|
288 | - $this->load_core( 'Module_Request_Router' ); |
|
287 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
288 | + $this->load_core('Module_Request_Router'); |
|
289 | 289 | } |
290 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
290 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | * @param string $module_name |
298 | 298 | * @return mixed EED_Module | NULL |
299 | 299 | */ |
300 | - public function get_module( $module_name = '' ) { |
|
301 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
300 | + public function get_module($module_name = '') { |
|
301 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -312,20 +312,20 @@ discard block |
||
312 | 312 | * @param bool $load_only |
313 | 313 | * @return mixed |
314 | 314 | */ |
315 | - public function load_core( $class_name, $arguments = array(), $load_only = false ) { |
|
315 | + public function load_core($class_name, $arguments = array(), $load_only = false) { |
|
316 | 316 | $core_paths = apply_filters( |
317 | 317 | 'FHEE__EE_Registry__load_core__core_paths', |
318 | 318 | array( |
319 | 319 | EE_CORE, |
320 | 320 | EE_ADMIN, |
321 | 321 | EE_CPTS, |
322 | - EE_CORE . 'data_migration_scripts' . DS, |
|
323 | - EE_CORE . 'request_stack' . DS, |
|
324 | - EE_CORE . 'middleware' . DS, |
|
322 | + EE_CORE.'data_migration_scripts'.DS, |
|
323 | + EE_CORE.'request_stack'.DS, |
|
324 | + EE_CORE.'middleware'.DS, |
|
325 | 325 | ) |
326 | 326 | ); |
327 | 327 | // retrieve instantiated class |
328 | - return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only ); |
|
328 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -339,15 +339,15 @@ discard block |
||
339 | 339 | * @param bool $load_only |
340 | 340 | * @return mixed |
341 | 341 | */ |
342 | - public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
|
342 | + public function load_service($class_name, $arguments = array(), $load_only = false) { |
|
343 | 343 | $service_paths = apply_filters( |
344 | 344 | 'FHEE__EE_Registry__load_service__service_paths', |
345 | 345 | array( |
346 | - EE_CORE . 'services' . DS, |
|
346 | + EE_CORE.'services'.DS, |
|
347 | 347 | ) |
348 | 348 | ); |
349 | 349 | // retrieve instantiated class |
350 | - return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only ); |
|
350 | + return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | * @param mixed $arguments |
361 | 361 | * @return EE_Data_Migration_Script_Base |
362 | 362 | */ |
363 | - public function load_dms( $class_name, $arguments = array() ) { |
|
363 | + public function load_dms($class_name, $arguments = array()) { |
|
364 | 364 | // retrieve instantiated class |
365 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false ); |
|
365 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | |
@@ -377,14 +377,14 @@ discard block |
||
377 | 377 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
378 | 378 | * @return EE_Base_Class | bool |
379 | 379 | */ |
380 | - public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
|
381 | - $paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array( |
|
380 | + public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) { |
|
381 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
382 | 382 | EE_CORE, |
383 | 383 | EE_CLASSES, |
384 | 384 | EE_BUSINESS |
385 | - ) ); |
|
385 | + )); |
|
386 | 386 | // retrieve instantiated class |
387 | - return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
387 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | * @param bool $load_only |
398 | 398 | * @return EEH_Base | bool |
399 | 399 | */ |
400 | - public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
|
400 | + public function load_helper($class_name, $arguments = array(), $load_only = true) { |
|
401 | 401 | // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed |
402 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) ); |
|
402 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
403 | 403 | // retrieve instantiated class |
404 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only ); |
|
404 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -416,16 +416,16 @@ discard block |
||
416 | 416 | * @param bool $cache whether to cache the object or not. |
417 | 417 | * @return mixed |
418 | 418 | */ |
419 | - public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) { |
|
419 | + public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true) { |
|
420 | 420 | $paths = array( |
421 | 421 | EE_LIBRARIES, |
422 | - EE_LIBRARIES . 'messages' . DS, |
|
423 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
424 | - EE_LIBRARIES . 'qtips' . DS, |
|
425 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
422 | + EE_LIBRARIES.'messages'.DS, |
|
423 | + EE_LIBRARIES.'shortcodes'.DS, |
|
424 | + EE_LIBRARIES.'qtips'.DS, |
|
425 | + EE_LIBRARIES.'payment_methods'.DS, |
|
426 | 426 | ); |
427 | 427 | // retrieve instantiated class |
428 | - return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only ); |
|
428 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | |
@@ -438,13 +438,13 @@ discard block |
||
438 | 438 | * @param bool $load_only |
439 | 439 | * @return EEM_Base | bool |
440 | 440 | */ |
441 | - public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
|
442 | - $paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array( |
|
441 | + public function load_model($class_name, $arguments = array(), $load_only = false) { |
|
442 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
443 | 443 | EE_MODELS, |
444 | 444 | EE_CORE |
445 | - ) ); |
|
445 | + )); |
|
446 | 446 | // retrieve instantiated class |
447 | - return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only ); |
|
447 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -457,15 +457,15 @@ discard block |
||
457 | 457 | * @param bool $load_only |
458 | 458 | * @return mixed | bool |
459 | 459 | */ |
460 | - public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
|
460 | + public function load_model_class($class_name, $arguments = array(), $load_only = true) { |
|
461 | 461 | $paths = array( |
462 | - EE_MODELS . 'fields' . DS, |
|
463 | - EE_MODELS . 'helpers' . DS, |
|
464 | - EE_MODELS . 'relations' . DS, |
|
465 | - EE_MODELS . 'strategies' . DS |
|
462 | + EE_MODELS.'fields'.DS, |
|
463 | + EE_MODELS.'helpers'.DS, |
|
464 | + EE_MODELS.'relations'.DS, |
|
465 | + EE_MODELS.'strategies'.DS |
|
466 | 466 | ); |
467 | 467 | // retrieve instantiated class |
468 | - return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only ); |
|
468 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | |
@@ -475,8 +475,8 @@ discard block |
||
475 | 475 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
476 | 476 | * @return boolean |
477 | 477 | */ |
478 | - public function is_model_name( $model_name ) { |
|
479 | - return isset( $this->models[ $model_name ] ) ? true : false; |
|
478 | + public function is_model_name($model_name) { |
|
479 | + return isset($this->models[$model_name]) ? true : false; |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | |
@@ -491,9 +491,9 @@ discard block |
||
491 | 491 | * @param bool $load_only |
492 | 492 | * @return mixed |
493 | 493 | */ |
494 | - public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
|
494 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) { |
|
495 | 495 | // retrieve instantiated class |
496 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only ); |
|
496 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | |
@@ -508,9 +508,9 @@ discard block |
||
508 | 508 | * @param bool $load_only |
509 | 509 | * @return EE_Addon |
510 | 510 | */ |
511 | - public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
|
511 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) { |
|
512 | 512 | // retrieve instantiated class |
513 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only ); |
|
513 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | |
@@ -541,46 +541,46 @@ discard block |
||
541 | 541 | $load_only = false |
542 | 542 | ) { |
543 | 543 | // strip php file extension |
544 | - $class_name = str_replace( '.php', '', trim( $class_name ) ); |
|
544 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
545 | 545 | // does the class have a prefix ? |
546 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
546 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
547 | 547 | // make sure $class_prefix is uppercase |
548 | - $class_prefix = strtoupper( trim( $class_prefix ) ); |
|
548 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
549 | 549 | // add class prefix ONCE!!! |
550 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
550 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
551 | 551 | } |
552 | - $class_exists = class_exists( $class_name ); |
|
552 | + $class_exists = class_exists($class_name); |
|
553 | 553 | // if we're only loading the class and it already exists, then let's just return true immediately |
554 | - if ( $load_only && $class_exists ) { |
|
554 | + if ($load_only && $class_exists) { |
|
555 | 555 | return true; |
556 | 556 | } |
557 | 557 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
558 | 558 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
559 | 559 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
560 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
560 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
561 | 561 | // return object if it's already cached |
562 | - $cached_class = $this->_get_cached_class( $class_name, $class_prefix ); |
|
563 | - if ( $cached_class !== null ) { |
|
562 | + $cached_class = $this->_get_cached_class($class_name, $class_prefix); |
|
563 | + if ($cached_class !== null) { |
|
564 | 564 | return $cached_class; |
565 | 565 | } |
566 | 566 | } |
567 | 567 | // if the class doesn't already exist.. then we need to try and find the file and load it |
568 | - if ( ! $class_exists ) { |
|
568 | + if ( ! $class_exists) { |
|
569 | 569 | // get full path to file |
570 | - $path = $this->_resolve_path( $class_name, $type, $file_paths ); |
|
570 | + $path = $this->_resolve_path($class_name, $type, $file_paths); |
|
571 | 571 | // load the file |
572 | - $loaded = $this->_require_file( $path, $class_name, $type, $file_paths ); |
|
572 | + $loaded = $this->_require_file($path, $class_name, $type, $file_paths); |
|
573 | 573 | // if loading failed, or we are only loading a file but NOT instantiating an object |
574 | - if ( ! $loaded || $load_only ) { |
|
574 | + if ( ! $loaded || $load_only) { |
|
575 | 575 | // return boolean if only loading, or null if an object was expected |
576 | 576 | return $load_only ? $loaded : null; |
577 | 577 | } |
578 | 578 | } |
579 | 579 | // instantiate the requested object |
580 | - $class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db ); |
|
581 | - if ( $this->_cache_on && $cache ) { |
|
580 | + $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db); |
|
581 | + if ($this->_cache_on && $cache) { |
|
582 | 582 | // save it for later... kinda like gum { : $ |
583 | - $this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db ); |
|
583 | + $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db); |
|
584 | 584 | } |
585 | 585 | $this->_cache_on = true; |
586 | 586 | return $class_obj; |
@@ -603,21 +603,21 @@ discard block |
||
603 | 603 | * @param string $class_prefix |
604 | 604 | * @return null|object |
605 | 605 | */ |
606 | - protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
|
607 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
608 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
606 | + protected function _get_cached_class($class_name, $class_prefix = '') { |
|
607 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
608 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
609 | 609 | } else { |
610 | 610 | // have to specify something, but not anything that will conflict |
611 | 611 | $class_abbreviation = 'FANCY_BATMAN_PANTS'; |
612 | 612 | } |
613 | 613 | // check if class has already been loaded, and return it if it has been |
614 | - if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) { |
|
614 | + if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) { |
|
615 | 615 | return $this->{$class_abbreviation}; |
616 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
616 | + } else if (isset ($this->{$class_name} )) { |
|
617 | 617 | return $this->{$class_name}; |
618 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
618 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
619 | 619 | return $this->LIB->{$class_name}; |
620 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
620 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
621 | 621 | return $this->addons->{$class_name}; |
622 | 622 | } |
623 | 623 | return null; |
@@ -638,20 +638,20 @@ discard block |
||
638 | 638 | * @param array $file_paths |
639 | 639 | * @return string | bool |
640 | 640 | */ |
641 | - protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
|
641 | + protected function _resolve_path($class_name, $type = '', $file_paths = array()) { |
|
642 | 642 | // make sure $file_paths is an array |
643 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
643 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
644 | 644 | // cycle thru paths |
645 | - foreach ( $file_paths as $key => $file_path ) { |
|
645 | + foreach ($file_paths as $key => $file_path) { |
|
646 | 646 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
647 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
647 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
648 | 648 | // prep file type |
649 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
649 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
650 | 650 | // build full file path |
651 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
651 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
652 | 652 | //does the file exist and can be read ? |
653 | - if ( is_readable( $file_paths[ $key ] ) ) { |
|
654 | - return $file_paths[ $key ]; |
|
653 | + if (is_readable($file_paths[$key])) { |
|
654 | + return $file_paths[$key]; |
|
655 | 655 | } |
656 | 656 | } |
657 | 657 | return false; |
@@ -673,29 +673,29 @@ discard block |
||
673 | 673 | * @return boolean |
674 | 674 | * @throws \EE_Error |
675 | 675 | */ |
676 | - protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
|
676 | + protected function _require_file($path, $class_name, $type = '', $file_paths = array()) { |
|
677 | 677 | // don't give up! you gotta... |
678 | 678 | try { |
679 | 679 | //does the file exist and can it be read ? |
680 | - if ( ! $path ) { |
|
680 | + if ( ! $path) { |
|
681 | 681 | // so sorry, can't find the file |
682 | - throw new EE_Error ( |
|
682 | + throw new EE_Error( |
|
683 | 683 | sprintf( |
684 | - __( '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' ), |
|
685 | - trim( $type, '.' ), |
|
684 | + __('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'), |
|
685 | + trim($type, '.'), |
|
686 | 686 | $class_name, |
687 | - '<br />' . implode( ',<br />', $file_paths ) |
|
687 | + '<br />'.implode(',<br />', $file_paths) |
|
688 | 688 | ) |
689 | 689 | ); |
690 | 690 | } |
691 | 691 | // get the file |
692 | - require_once( $path ); |
|
692 | + require_once($path); |
|
693 | 693 | // if the class isn't already declared somewhere |
694 | - if ( class_exists( $class_name, false ) === false ) { |
|
694 | + if (class_exists($class_name, false) === false) { |
|
695 | 695 | // so sorry, not a class |
696 | 696 | throw new EE_Error( |
697 | 697 | sprintf( |
698 | - __( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ), |
|
698 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
699 | 699 | $type, |
700 | 700 | $path, |
701 | 701 | $class_name |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | ); |
704 | 704 | } |
705 | 705 | |
706 | - } catch ( EE_Error $e ) { |
|
706 | + } catch (EE_Error $e) { |
|
707 | 707 | $e->get_error(); |
708 | 708 | return false; |
709 | 709 | } |
@@ -735,55 +735,55 @@ discard block |
||
735 | 735 | * @return null | object |
736 | 736 | * @throws \EE_Error |
737 | 737 | */ |
738 | - protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) { |
|
738 | + protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false) { |
|
739 | 739 | $class_obj = null; |
740 | 740 | // don't give up! you gotta... |
741 | 741 | try { |
742 | 742 | // create reflection |
743 | - $reflector = $this->get_ReflectionClass( $class_name ); |
|
743 | + $reflector = $this->get_ReflectionClass($class_name); |
|
744 | 744 | // make sure arguments are an array |
745 | - $arguments = is_array( $arguments ) ? $arguments : array( $arguments ); |
|
745 | + $arguments = is_array($arguments) ? $arguments : array($arguments); |
|
746 | 746 | // and if arguments array is numerically and sequentially indexed, then we want it to remain as is, |
747 | 747 | // else wrap it in an additional array so that it doesn't get split into multiple parameters |
748 | - $arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments ) |
|
748 | + $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments) |
|
749 | 749 | ? $arguments |
750 | - : array( $arguments ); |
|
750 | + : array($arguments); |
|
751 | 751 | // attempt to inject dependencies ? |
752 | - if ( $this->_dependency_map->has( $class_name ) ) { |
|
753 | - $arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments ); |
|
752 | + if ($this->_dependency_map->has($class_name)) { |
|
753 | + $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments); |
|
754 | 754 | } |
755 | 755 | // instantiate the class and add to the LIB array for tracking |
756 | 756 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
757 | - if ( $reflector->getConstructor() === null || $reflector->isAbstract() ) { |
|
757 | + if ($reflector->getConstructor() === null || $reflector->isAbstract()) { |
|
758 | 758 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
759 | 759 | //$instantiation_mode = "no constructor"; |
760 | 760 | $class_obj = true; |
761 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
761 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
762 | 762 | //$instantiation_mode = "new_instance_from_db"; |
763 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
764 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
763 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
764 | + } else if (method_exists($class_name, 'new_instance')) { |
|
765 | 765 | //$instantiation_mode = "new_instance"; |
766 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
767 | - } else if ( method_exists( $class_name, 'instance' ) ) { |
|
766 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
767 | + } else if (method_exists($class_name, 'instance')) { |
|
768 | 768 | //$instantiation_mode = "instance"; |
769 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
770 | - } else if ( $reflector->isInstantiable() ) { |
|
769 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
770 | + } else if ($reflector->isInstantiable()) { |
|
771 | 771 | //$instantiation_mode = "isInstantiable"; |
772 | - $class_obj = $reflector->newInstanceArgs( $arguments ); |
|
772 | + $class_obj = $reflector->newInstanceArgs($arguments); |
|
773 | 773 | } else { |
774 | 774 | // heh ? something's not right ! |
775 | 775 | //$instantiation_mode = 'none'; |
776 | 776 | throw new EE_Error( |
777 | 777 | sprintf( |
778 | - __( 'The %s file %s could not be instantiated.', 'event_espresso' ), |
|
778 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
779 | 779 | $type, |
780 | 780 | $class_name |
781 | 781 | ) |
782 | 782 | ); |
783 | 783 | } |
784 | - } catch ( Exception $e ) { |
|
785 | - if ( ! $e instanceof EE_Error ) { |
|
786 | - $e = new EE_Error( $e->getMessage() ); |
|
784 | + } catch (Exception $e) { |
|
785 | + if ( ! $e instanceof EE_Error) { |
|
786 | + $e = new EE_Error($e->getMessage()); |
|
787 | 787 | } |
788 | 788 | $e->get_error(); |
789 | 789 | } |
@@ -797,8 +797,8 @@ discard block |
||
797 | 797 | * @param array $array |
798 | 798 | * @return bool |
799 | 799 | */ |
800 | - protected function _array_is_numerically_and_sequentially_indexed( array $array ) { |
|
801 | - return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true; |
|
800 | + protected function _array_is_numerically_and_sequentially_indexed(array $array) { |
|
801 | + return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true; |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | |
@@ -813,14 +813,14 @@ discard block |
||
813 | 813 | * @param string $class_name |
814 | 814 | * @return ReflectionClass |
815 | 815 | */ |
816 | - public function get_ReflectionClass( $class_name ) { |
|
816 | + public function get_ReflectionClass($class_name) { |
|
817 | 817 | if ( |
818 | - ! isset( $this->_reflectors[ $class_name ] ) |
|
819 | - || ! $this->_reflectors[ $class_name ] instanceof ReflectionClass |
|
818 | + ! isset($this->_reflectors[$class_name]) |
|
819 | + || ! $this->_reflectors[$class_name] instanceof ReflectionClass |
|
820 | 820 | ) { |
821 | - $this->_reflectors[ $class_name ] = new ReflectionClass( $class_name ); |
|
821 | + $this->_reflectors[$class_name] = new ReflectionClass($class_name); |
|
822 | 822 | } |
823 | - return $this->_reflectors[ $class_name ]; |
|
823 | + return $this->_reflectors[$class_name]; |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | |
@@ -845,45 +845,45 @@ discard block |
||
845 | 845 | * @param array $arguments |
846 | 846 | * @return array |
847 | 847 | */ |
848 | - protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
|
848 | + protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) { |
|
849 | 849 | // let's examine the constructor |
850 | 850 | $constructor = $reflector->getConstructor(); |
851 | 851 | // whu? huh? nothing? |
852 | - if ( ! $constructor ) { |
|
852 | + if ( ! $constructor) { |
|
853 | 853 | return $arguments; |
854 | 854 | } |
855 | 855 | // get constructor parameters |
856 | 856 | $params = $constructor->getParameters(); |
857 | 857 | // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected |
858 | - $argument_keys = array_keys( $arguments ); |
|
858 | + $argument_keys = array_keys($arguments); |
|
859 | 859 | // now loop thru all of the constructors expected parameters |
860 | - foreach ( $params as $index => $param ) { |
|
860 | + foreach ($params as $index => $param) { |
|
861 | 861 | // is this a dependency for a specific class ? |
862 | 862 | $param_class = $param->getClass() ? $param->getClass()->name : null; |
863 | 863 | if ( |
864 | 864 | // param is not even a class |
865 | - empty( $param_class ) |
|
865 | + empty($param_class) |
|
866 | 866 | // and something already exists in the incoming arguments for this param |
867 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
867 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
868 | 868 | ) { |
869 | 869 | // so let's skip this argument and move on to the next |
870 | 870 | continue; |
871 | 871 | } else if ( |
872 | 872 | // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class |
873 | - ! empty( $param_class ) |
|
874 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
875 | - && $arguments[ $argument_keys[ $index ] ] instanceof $param_class |
|
873 | + ! empty($param_class) |
|
874 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
875 | + && $arguments[$argument_keys[$index]] instanceof $param_class |
|
876 | 876 | ) { |
877 | 877 | // skip this argument and move on to the next |
878 | 878 | continue; |
879 | 879 | } else if ( |
880 | 880 | // parameter is type hinted as a class, and should be injected |
881 | - ! empty( $param_class ) |
|
882 | - && $this->_dependency_map->has_dependency_for_class( $class_name, $param_class ) |
|
881 | + ! empty($param_class) |
|
882 | + && $this->_dependency_map->has_dependency_for_class($class_name, $param_class) |
|
883 | 883 | ) { |
884 | - $arguments = $this->_resolve_dependency( $class_name, $param_class, $arguments, $index ); |
|
884 | + $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index); |
|
885 | 885 | } else { |
886 | - $arguments[ $index ] = $param->getDefaultValue(); |
|
886 | + $arguments[$index] = $param->getDefaultValue(); |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | } |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | * @param mixed $index |
901 | 901 | * @return array |
902 | 902 | */ |
903 | - protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) { |
|
903 | + protected function _resolve_dependency($class_name, $param_class, $arguments, $index) { |
|
904 | 904 | $dependency = null; |
905 | 905 | // should dependency be loaded from cache ? |
906 | 906 | $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency( |
@@ -910,30 +910,30 @@ discard block |
||
910 | 910 | : false; |
911 | 911 | // we might have a dependency... |
912 | 912 | // let's MAYBE try and find it in our cache if that's what's been requested |
913 | - $cached_class = $cache_on ? $this->_get_cached_class( $param_class ) : null; |
|
913 | + $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null; |
|
914 | 914 | // and grab it if it exists |
915 | - if ( $cached_class instanceof $param_class ) { |
|
915 | + if ($cached_class instanceof $param_class) { |
|
916 | 916 | $dependency = $cached_class; |
917 | - } else if ( $param_class != $class_name ) { |
|
917 | + } else if ($param_class != $class_name) { |
|
918 | 918 | // obtain the loader method from the dependency map |
919 | - $loader = $this->_dependency_map->class_loader( $param_class ); |
|
919 | + $loader = $this->_dependency_map->class_loader($param_class); |
|
920 | 920 | // is loader a custom closure ? |
921 | - if ( $loader instanceof Closure ) { |
|
921 | + if ($loader instanceof Closure) { |
|
922 | 922 | $dependency = $loader(); |
923 | 923 | } else { |
924 | 924 | // set the cache on property for the recursive loading call |
925 | 925 | $this->_cache_on = $cache_on; |
926 | 926 | // if not, then let's try and load it via the registry |
927 | - $dependency = $this->{$loader}( $param_class ); |
|
927 | + $dependency = $this->{$loader}($param_class); |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | // did we successfully find the correct dependency ? |
931 | - if ( $dependency instanceof $param_class ) { |
|
931 | + if ($dependency instanceof $param_class) { |
|
932 | 932 | // then let's inject it into the incoming array of arguments at the correct location |
933 | - if ( isset( $argument_keys[ $index ] ) ) { |
|
934 | - $arguments[ $argument_keys[ $index ] ] = $dependency; |
|
933 | + if (isset($argument_keys[$index])) { |
|
934 | + $arguments[$argument_keys[$index]] = $dependency; |
|
935 | 935 | } else { |
936 | - $arguments[ $index ] = $dependency; |
|
936 | + $arguments[$index] = $dependency; |
|
937 | 937 | } |
938 | 938 | } |
939 | 939 | return $arguments; |
@@ -958,16 +958,16 @@ discard block |
||
958 | 958 | * @param bool $from_db |
959 | 959 | * @return void |
960 | 960 | */ |
961 | - protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) { |
|
961 | + protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false) { |
|
962 | 962 | // return newly instantiated class |
963 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
964 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
963 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
964 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
965 | 965 | $this->{$class_abbreviation} = $class_obj; |
966 | - } else if ( property_exists( $this, $class_name ) ) { |
|
966 | + } else if (property_exists($this, $class_name)) { |
|
967 | 967 | $this->{$class_name} = $class_obj; |
968 | - } else if ( $class_prefix == 'addon' ) { |
|
968 | + } else if ($class_prefix == 'addon') { |
|
969 | 969 | $this->addons->{$class_name} = $class_obj; |
970 | - } else if ( ! $from_db ) { |
|
970 | + } else if ( ! $from_db) { |
|
971 | 971 | $this->LIB->{$class_name} = $class_obj; |
972 | 972 | } |
973 | 973 | } |
@@ -984,12 +984,12 @@ discard block |
||
984 | 984 | * @param array $arguments |
985 | 985 | * @return object |
986 | 986 | */ |
987 | - public static function factory( $classname, $arguments = array() ) { |
|
988 | - $loader = self::instance()->_dependency_map->class_loader( $classname ); |
|
989 | - if ( $loader instanceof Closure ) { |
|
990 | - return $loader( $arguments ); |
|
991 | - } else if ( method_exists( EE_Registry::instance(), $loader ) ) { |
|
992 | - return EE_Registry::instance()->{$loader}( $classname, $arguments ); |
|
987 | + public static function factory($classname, $arguments = array()) { |
|
988 | + $loader = self::instance()->_dependency_map->class_loader($classname); |
|
989 | + if ($loader instanceof Closure) { |
|
990 | + return $loader($arguments); |
|
991 | + } else if (method_exists(EE_Registry::instance(), $loader)) { |
|
992 | + return EE_Registry::instance()->{$loader}($classname, $arguments); |
|
993 | 993 | } |
994 | 994 | return null; |
995 | 995 | } |
@@ -1002,9 +1002,9 @@ discard block |
||
1002 | 1002 | * @param string $name |
1003 | 1003 | * @return EE_Addon |
1004 | 1004 | */ |
1005 | - public function get_addon_by_name( $name ) { |
|
1006 | - foreach ( $this->addons as $addon ) { |
|
1007 | - if ( $addon->name() == $name ) { |
|
1005 | + public function get_addon_by_name($name) { |
|
1006 | + foreach ($this->addons as $addon) { |
|
1007 | + if ($addon->name() == $name) { |
|
1008 | 1008 | return $addon; |
1009 | 1009 | } |
1010 | 1010 | } |
@@ -1020,8 +1020,8 @@ discard block |
||
1020 | 1020 | */ |
1021 | 1021 | public function get_addons_by_name() { |
1022 | 1022 | $addons = array(); |
1023 | - foreach ( $this->addons as $addon ) { |
|
1024 | - $addons[ $addon->name() ] = $addon; |
|
1023 | + foreach ($this->addons as $addon) { |
|
1024 | + $addons[$addon->name()] = $addon; |
|
1025 | 1025 | } |
1026 | 1026 | return $addons; |
1027 | 1027 | } |
@@ -1036,14 +1036,14 @@ discard block |
||
1036 | 1036 | * @return \EEM_Base |
1037 | 1037 | * @throws \EE_Error |
1038 | 1038 | */ |
1039 | - public function reset_model( $model_name ) { |
|
1040 | - $model = $this->load_model( $model_name ); |
|
1041 | - $model_class_name = get_class( $model ); |
|
1039 | + public function reset_model($model_name) { |
|
1040 | + $model = $this->load_model($model_name); |
|
1041 | + $model_class_name = get_class($model); |
|
1042 | 1042 | //get that model reset it and make sure we nuke the old reference to it |
1043 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
1043 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
1044 | 1044 | $this->LIB->{$model_class_name} = $model::reset(); |
1045 | 1045 | } else { |
1046 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
1046 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
1047 | 1047 | } |
1048 | 1048 | return $this->LIB->{$model_class_name}; |
1049 | 1049 | } |
@@ -1081,26 +1081,26 @@ discard block |
||
1081 | 1081 | * |
1082 | 1082 | * @return EE_Registry |
1083 | 1083 | */ |
1084 | - public static function reset( $hard = false, $reinstantiate = true, $reset_models = true ) { |
|
1084 | + public static function reset($hard = false, $reinstantiate = true, $reset_models = true) { |
|
1085 | 1085 | $instance = self::instance(); |
1086 | 1086 | EEH_Activation::reset(); |
1087 | 1087 | |
1088 | 1088 | //properties that get reset |
1089 | 1089 | $instance->_cache_on = true; |
1090 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
1090 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
1091 | 1091 | $instance->CART = null; |
1092 | 1092 | $instance->MRM = null; |
1093 | 1093 | |
1094 | 1094 | //handle of objects cached on LIB |
1095 | - foreach ( $instance->_classes_to_unset_from_LIB_on_reset() as $class_name ) { |
|
1096 | - if ( isset( $instance->LIB->$class_name ) ) { |
|
1097 | - unset( $instance->LIB->$class_name ); |
|
1095 | + foreach ($instance->_classes_to_unset_from_LIB_on_reset() as $class_name) { |
|
1096 | + if (isset($instance->LIB->$class_name)) { |
|
1097 | + unset($instance->LIB->$class_name); |
|
1098 | 1098 | } |
1099 | 1099 | } |
1100 | 1100 | |
1101 | - if ( $reset_models ) { |
|
1102 | - foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) { |
|
1103 | - $instance->reset_model( $model_name ); |
|
1101 | + if ($reset_models) { |
|
1102 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
1103 | + $instance->reset_model($model_name); |
|
1104 | 1104 | } |
1105 | 1105 | } |
1106 | 1106 | |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | * @return array |
1116 | 1116 | */ |
1117 | 1117 | protected function _classes_to_unset_from_LIB_on_reset() { |
1118 | - return apply_filters( 'EE_Registry___classes_to_unset_from_LIB_on_reset', array( |
|
1118 | + return apply_filters('EE_Registry___classes_to_unset_from_LIB_on_reset', array( |
|
1119 | 1119 | 'EE_Data_Migration_Manager', |
1120 | 1120 | 'EE_Messages_Processor', |
1121 | 1121 | 'EE_Messages_Queue', |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | * @param $a |
1138 | 1138 | * @param $b |
1139 | 1139 | */ |
1140 | - final function __call( $a, $b ) { |
|
1140 | + final function __call($a, $b) { |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | /** |
1146 | 1146 | * @param $a |
1147 | 1147 | */ |
1148 | - final function __get( $a ) { |
|
1148 | + final function __get($a) { |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | |
@@ -1154,7 +1154,7 @@ discard block |
||
1154 | 1154 | * @param $a |
1155 | 1155 | * @param $b |
1156 | 1156 | */ |
1157 | - final function __set( $a, $b ) { |
|
1157 | + final function __set($a, $b) { |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | |
@@ -1162,7 +1162,7 @@ discard block |
||
1162 | 1162 | /** |
1163 | 1163 | * @param $a |
1164 | 1164 | */ |
1165 | - final function __isset( $a ) { |
|
1165 | + final function __isset($a) { |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | /** |
1171 | 1171 | * @param $a |
1172 | 1172 | */ |
1173 | - final function __unset( $a ) { |
|
1173 | + final function __unset($a) { |
|
1174 | 1174 | } |
1175 | 1175 | |
1176 | 1176 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | * @param $a |
1218 | 1218 | * @param $b |
1219 | 1219 | */ |
1220 | - final static function __callStatic( $a, $b ) { |
|
1220 | + final static function __callStatic($a, $b) { |
|
1221 | 1221 | } |
1222 | 1222 | |
1223 | 1223 | /** |
@@ -1226,9 +1226,9 @@ discard block |
||
1226 | 1226 | */ |
1227 | 1227 | public function cpt_models() { |
1228 | 1228 | $cpt_models = array(); |
1229 | - foreach( $this->non_abstract_db_models as $short_name => $classname ) { |
|
1230 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
1231 | - $cpt_models[ $short_name ] = $classname; |
|
1229 | + foreach ($this->non_abstract_db_models as $short_name => $classname) { |
|
1230 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
1231 | + $cpt_models[$short_name] = $classname; |
|
1232 | 1232 | } |
1233 | 1233 | } |
1234 | 1234 | return $cpt_models; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * remove param |
352 | 352 | * |
353 | 353 | * @access public |
354 | - * @param $key |
|
354 | + * @param string $key |
|
355 | 355 | * @return void |
356 | 356 | */ |
357 | 357 | public function un_set( $key ) { |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * add_output |
392 | 392 | * |
393 | 393 | * @access public |
394 | - * @param $string |
|
394 | + * @param string $string |
|
395 | 395 | * @return void |
396 | 396 | */ |
397 | 397 | public function add_output( $string ) { |
@@ -456,14 +456,14 @@ discard block |
||
456 | 456 | |
457 | 457 | |
458 | 458 | /** |
459 | - * @return bool |
|
459 | + * @return boolean|null |
|
460 | 460 | */ |
461 | 461 | public function __clone() {} |
462 | 462 | |
463 | 463 | |
464 | 464 | |
465 | 465 | /** |
466 | - * @return bool |
|
466 | + * @return boolean|null |
|
467 | 467 | */ |
468 | 468 | public function __wakeup() {} |
469 | 469 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * class EE_Request_Handler |
4 | 4 | * |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | * @param EE_Request $request |
51 | 51 | * @return \EE_Request_Handler |
52 | 52 | */ |
53 | - public function __construct( EE_Request $request ) { |
|
53 | + public function __construct(EE_Request $request) { |
|
54 | 54 | // grab request vars |
55 | 55 | $this->_params = $request->params(); |
56 | 56 | // AJAX ??? |
57 | - $this->ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false; |
|
58 | - $this->front_ajax = defined( 'EE_FRONT_AJAX' ) && EE_FRONT_AJAX ? true : false; |
|
59 | - do_action( 'AHEE__EE_Request_Handler__construct__complete' ); |
|
57 | + $this->ajax = defined('DOING_AJAX') && DOING_AJAX ? true : false; |
|
58 | + $this->front_ajax = defined('EE_FRONT_AJAX') && EE_FRONT_AJAX ? true : false; |
|
59 | + do_action('AHEE__EE_Request_Handler__construct__complete'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | * @param WP $wp |
69 | 69 | * @return void |
70 | 70 | */ |
71 | - public function parse_request( $wp = null ) { |
|
71 | + public function parse_request($wp = null) { |
|
72 | 72 | //if somebody forgot to provide us with WP, that's ok because its global |
73 | - if ( ! $wp instanceof WP ) { |
|
73 | + if ( ! $wp instanceof WP) { |
|
74 | 74 | global $wp; |
75 | 75 | } |
76 | - $this->set_request_vars( $wp ); |
|
76 | + $this->set_request_vars($wp); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -85,14 +85,14 @@ discard block |
||
85 | 85 | * @param WP $wp |
86 | 86 | * @return void |
87 | 87 | */ |
88 | - public function set_request_vars( $wp = null ) { |
|
89 | - if ( ! is_admin() ) { |
|
88 | + public function set_request_vars($wp = null) { |
|
89 | + if ( ! is_admin()) { |
|
90 | 90 | // set request post_id |
91 | - $this->set( 'post_id', $this->get_post_id_from_request( $wp )); |
|
91 | + $this->set('post_id', $this->get_post_id_from_request($wp)); |
|
92 | 92 | // set request post name |
93 | - $this->set( 'post_name', $this->get_post_name_from_request( $wp )); |
|
93 | + $this->set('post_name', $this->get_post_name_from_request($wp)); |
|
94 | 94 | // set request post_type |
95 | - $this->set( 'post_type', $this->get_post_type_from_request( $wp )); |
|
95 | + $this->set('post_type', $this->get_post_type_from_request($wp)); |
|
96 | 96 | // true or false ? is this page being used by EE ? |
97 | 97 | $this->set_espresso_page(); |
98 | 98 | } |
@@ -107,19 +107,19 @@ discard block |
||
107 | 107 | * @param WP $wp |
108 | 108 | * @return int |
109 | 109 | */ |
110 | - public function get_post_id_from_request( $wp = null ) { |
|
111 | - if ( ! $wp instanceof WP ){ |
|
110 | + public function get_post_id_from_request($wp = null) { |
|
111 | + if ( ! $wp instanceof WP) { |
|
112 | 112 | global $wp; |
113 | 113 | } |
114 | 114 | $post_id = null; |
115 | - if ( isset( $wp->query_vars['p'] )) { |
|
115 | + if (isset($wp->query_vars['p'])) { |
|
116 | 116 | $post_id = $wp->query_vars['p']; |
117 | 117 | } |
118 | - if ( ! $post_id && isset( $wp->query_vars['page_id'] )) { |
|
118 | + if ( ! $post_id && isset($wp->query_vars['page_id'])) { |
|
119 | 119 | $post_id = $wp->query_vars['page_id']; |
120 | 120 | } |
121 | - if ( ! $post_id && isset( $wp->request ) && is_numeric( basename( $wp->request ))) { |
|
122 | - $post_id = basename( $wp->request ); |
|
121 | + if ( ! $post_id && isset($wp->request) && is_numeric(basename($wp->request))) { |
|
122 | + $post_id = basename($wp->request); |
|
123 | 123 | } |
124 | 124 | return $post_id; |
125 | 125 | } |
@@ -133,35 +133,35 @@ discard block |
||
133 | 133 | * @param WP $wp |
134 | 134 | * @return string |
135 | 135 | */ |
136 | - public function get_post_name_from_request( $wp = null ) { |
|
137 | - if ( ! $wp instanceof WP ){ |
|
136 | + public function get_post_name_from_request($wp = null) { |
|
137 | + if ( ! $wp instanceof WP) { |
|
138 | 138 | global $wp; |
139 | 139 | } |
140 | 140 | $post_name = null; |
141 | - if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) { |
|
141 | + if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
|
142 | 142 | $post_name = $wp->query_vars['name']; |
143 | 143 | } |
144 | - if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) { |
|
144 | + if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
145 | 145 | $post_name = $wp->query_vars['pagename']; |
146 | 146 | } |
147 | - if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) { |
|
148 | - $possible_post_name = basename( $wp->request ); |
|
149 | - if ( ! is_numeric( $possible_post_name )) { |
|
147 | + if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) { |
|
148 | + $possible_post_name = basename($wp->request); |
|
149 | + if ( ! is_numeric($possible_post_name)) { |
|
150 | 150 | /** @type WPDB $wpdb */ |
151 | 151 | global $wpdb; |
152 | 152 | $SQL = "SELECT ID from $wpdb->posts WHERE post_status='publish' AND post_name=%s"; |
153 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name )); |
|
154 | - if ( $possible_post_name ) { |
|
153 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name)); |
|
154 | + if ($possible_post_name) { |
|
155 | 155 | $post_name = $possible_post_name; |
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
159 | - if ( ! $post_name && $this->get( 'post_id' )) { |
|
159 | + if ( ! $post_name && $this->get('post_id')) { |
|
160 | 160 | /** @type WPDB $wpdb */ |
161 | 161 | global $wpdb; |
162 | 162 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_status='publish' AND ID=%d"; |
163 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' ))); |
|
164 | - if( $possible_post_name ) { |
|
163 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); |
|
164 | + if ($possible_post_name) { |
|
165 | 165 | $post_name = $possible_post_name; |
166 | 166 | } |
167 | 167 | } |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | * @param WP $wp |
178 | 178 | * @return mixed |
179 | 179 | */ |
180 | - public function get_post_type_from_request( $wp = null ) { |
|
181 | - if ( ! $wp instanceof WP ){ |
|
180 | + public function get_post_type_from_request($wp = null) { |
|
181 | + if ( ! $wp instanceof WP) { |
|
182 | 182 | global $wp; |
183 | 183 | } |
184 | - return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null; |
|
184 | + return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -191,18 +191,18 @@ discard block |
||
191 | 191 | * @param WP $wp |
192 | 192 | * @return bool|string|void |
193 | 193 | */ |
194 | - public function get_current_page_permalink( $wp = null ) { |
|
195 | - $post_id = $this->get_post_id_from_request( $wp ); |
|
196 | - if ( $post_id ) { |
|
197 | - $current_page_permalink = get_permalink( $post_id ); |
|
194 | + public function get_current_page_permalink($wp = null) { |
|
195 | + $post_id = $this->get_post_id_from_request($wp); |
|
196 | + if ($post_id) { |
|
197 | + $current_page_permalink = get_permalink($post_id); |
|
198 | 198 | } else { |
199 | - if ( ! $wp instanceof WP ) { |
|
199 | + if ( ! $wp instanceof WP) { |
|
200 | 200 | global $wp; |
201 | 201 | } |
202 | - if ( $wp->request ) { |
|
203 | - $current_page_permalink = site_url( $wp->request ); |
|
202 | + if ($wp->request) { |
|
203 | + $current_page_permalink = site_url($wp->request); |
|
204 | 204 | } else { |
205 | - $current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) ); |
|
205 | + $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI'])); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | return $current_page_permalink; |
@@ -219,41 +219,41 @@ discard block |
||
219 | 219 | public function test_for_espresso_page() { |
220 | 220 | global $wp; |
221 | 221 | /** @type EE_CPT_Strategy $EE_CPT_Strategy */ |
222 | - $EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
222 | + $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); |
|
223 | 223 | $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
224 | - if ( is_array( $espresso_CPT_taxonomies ) ) { |
|
225 | - foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) { |
|
226 | - if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) { |
|
224 | + if (is_array($espresso_CPT_taxonomies)) { |
|
225 | + foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) { |
|
226 | + if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { |
|
227 | 227 | return true; |
228 | 228 | } |
229 | 229 | } |
230 | 230 | } |
231 | 231 | // load espresso CPT endpoints |
232 | 232 | $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints(); |
233 | - $post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints ); |
|
234 | - $post_types = (array)$this->get( 'post_type' ); |
|
235 | - foreach ( $post_types as $post_type ) { |
|
233 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints); |
|
234 | + $post_types = (array) $this->get('post_type'); |
|
235 | + foreach ($post_types as $post_type) { |
|
236 | 236 | // was a post name passed ? |
237 | - if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) { |
|
237 | + if (isset($post_type_CPT_endpoints[$post_type])) { |
|
238 | 238 | // kk we know this is an espresso page, but is it a specific post ? |
239 | - if ( ! $this->get( 'post_name' ) ) { |
|
239 | + if ( ! $this->get('post_name')) { |
|
240 | 240 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
241 | - $post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] : null; |
|
241 | + $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) ? $post_type_CPT_endpoints[$this->get('post_type')] : null; |
|
242 | 242 | // if the post type matches on of our then set the endpoint |
243 | - if ( $post_name ) { |
|
244 | - $this->set( 'post_name', $post_name ); |
|
243 | + if ($post_name) { |
|
244 | + $this->set('post_name', $post_name); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | return true; |
248 | 248 | } |
249 | 249 | } |
250 | - if ( $this->get( 'post_name' )) { |
|
250 | + if ($this->get('post_name')) { |
|
251 | 251 | // load all pages using espresso shortcodes |
252 | - $post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
252 | + $post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
253 | 253 | // make sure core pages are included |
254 | - $espresso_pages = array_merge( $espresso_CPT_endpoints, $post_shortcodes ); |
|
254 | + $espresso_pages = array_merge($espresso_CPT_endpoints, $post_shortcodes); |
|
255 | 255 | // was a post name passed ? |
256 | - if ( isset( $espresso_pages[ $this->get( 'post_name' ) ] )) { |
|
256 | + if (isset($espresso_pages[$this->get('post_name')])) { |
|
257 | 257 | return true; |
258 | 258 | } |
259 | 259 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param null|bool $value |
270 | 270 | * @return mixed |
271 | 271 | */ |
272 | - public function set_espresso_page( $value = null ) { |
|
272 | + public function set_espresso_page($value = null) { |
|
273 | 273 | $value = $value ? $value : $this->test_for_espresso_page(); |
274 | 274 | $this->_params['is_espresso_page'] = $value; |
275 | 275 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @return mixed |
284 | 284 | */ |
285 | 285 | public function is_espresso_page() { |
286 | - return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false; |
|
286 | + return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | |
@@ -307,14 +307,14 @@ discard block |
||
307 | 307 | * @param bool $override_ee |
308 | 308 | * @return void |
309 | 309 | */ |
310 | - public function set( $key, $value, $override_ee = false ) { |
|
310 | + public function set($key, $value, $override_ee = false) { |
|
311 | 311 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
312 | 312 | if ( |
313 | 313 | $key !== 'ee' || |
314 | - ( $key === 'ee' && empty( $this->_params['ee'] )) |
|
315 | - || ( $key === 'ee' && ! empty( $this->_params['ee'] ) && $override_ee ) |
|
314 | + ($key === 'ee' && empty($this->_params['ee'])) |
|
315 | + || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee) |
|
316 | 316 | ) { |
317 | - $this->_params[ $key ] = $value; |
|
317 | + $this->_params[$key] = $value; |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
@@ -328,8 +328,8 @@ discard block |
||
328 | 328 | * @param null $default |
329 | 329 | * @return mixed |
330 | 330 | */ |
331 | - public function get( $key, $default = null ) { |
|
332 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
331 | + public function get($key, $default = null) { |
|
332 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | * @param $key |
342 | 342 | * @return boolean |
343 | 343 | */ |
344 | - public function is_set( $key ) { |
|
345 | - return isset( $this->_params[ $key ] ) ? true : false; |
|
344 | + public function is_set($key) { |
|
345 | + return isset($this->_params[$key]) ? true : false; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @param $key |
355 | 355 | * @return void |
356 | 356 | */ |
357 | - public function un_set( $key ) { |
|
358 | - unset( $this->_params[ $key ] ); |
|
357 | + public function un_set($key) { |
|
358 | + unset($this->_params[$key]); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | * @param $value |
369 | 369 | * @return void |
370 | 370 | */ |
371 | - public function set_notice( $key, $value ) { |
|
372 | - $this->_notice[ $key ] = $value; |
|
371 | + public function set_notice($key, $value) { |
|
372 | + $this->_notice[$key] = $value; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | * @param $key |
382 | 382 | * @return mixed |
383 | 383 | */ |
384 | - public function get_notice( $key ) { |
|
385 | - return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null; |
|
384 | + public function get_notice($key) { |
|
385 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | * @param $string |
395 | 395 | * @return void |
396 | 396 | */ |
397 | - public function add_output( $string ) { |
|
397 | + public function add_output($string) { |
|
398 | 398 | $this->_output .= $string; |
399 | 399 | } |
400 | 400 | |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | * @param $item |
417 | 417 | * @param $key |
418 | 418 | */ |
419 | - public function sanitize_text_field_for_array_walk( &$item, &$key ) { |
|
420 | - $item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item ); |
|
419 | + public function sanitize_text_field_for_array_walk(&$item, &$key) { |
|
420 | + $item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * @param $b |
428 | 428 | * @return bool |
429 | 429 | */ |
430 | - public function __set($a,$b) { return false; } |
|
430 | + public function __set($a, $b) { return false; } |
|
431 | 431 | |
432 | 432 | |
433 | 433 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | class Custom_Messages_Template_List_Table extends EE_Admin_List_Table { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $admin_page ) { |
|
33 | + public function __construct($admin_page) { |
|
34 | 34 | //Set parent defaults |
35 | 35 | parent::__construct($admin_page); |
36 | 36 | } |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | protected function _setup_data() { |
52 | - $this->_data = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, FALSE, FALSE, FALSE ); |
|
53 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, TRUE, TRUE, FALSE ); |
|
52 | + $this->_data = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, FALSE, FALSE, FALSE); |
|
53 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, TRUE, TRUE, FALSE); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | |
60 | 60 | protected function _set_properties() { |
61 | 61 | $this->_wp_list_args = array( |
62 | - 'singular' => __('Message Template Group', 'event_espresso' ), |
|
63 | - 'plural' => __('Message Template', 'event_espresso' ), |
|
62 | + 'singular' => __('Message Template Group', 'event_espresso'), |
|
63 | + 'plural' => __('Message Template', 'event_espresso'), |
|
64 | 64 | 'ajax' => TRUE, //for now, |
65 | 65 | 'screen' => $this->get_admin_page()->get_current_screen()->id |
66 | 66 | ); |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | 'cb' => '<input type="checkbox" />', |
70 | 70 | 'name' => __('Template Name', 'event_espresso'), |
71 | 71 | 'message_type' => __('Message Type', 'event_espresso'), |
72 | - 'messenger' => __( 'Messenger', 'event_espresso'), |
|
73 | - 'description' => __( 'Description', 'event_espresso' ), |
|
74 | - 'events' => __( 'Events', 'event_espresso'), //count of events using this template. |
|
72 | + 'messenger' => __('Messenger', 'event_espresso'), |
|
73 | + 'description' => __('Description', 'event_espresso'), |
|
74 | + 'events' => __('Events', 'event_espresso'), //count of events using this template. |
|
75 | 75 | 'actions' => '' |
76 | 76 | //'messages_sent' => __( 'Total Sent', 'event_espresso' ) //todo this will come later when we've got message tracking in place. |
77 | 77 | ); |
78 | 78 | |
79 | 79 | $this->_sortable_columns = array( |
80 | - 'messenger' => array( 'MTP_messenger' => TRUE ), |
|
80 | + 'messenger' => array('MTP_messenger' => TRUE), |
|
81 | 81 | //'message_type' => array( 'MTP_message_type' => FALSE ) |
82 | 82 | ); |
83 | 83 | |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return string |
98 | 98 | */ |
99 | - public function single_row( $item ) { |
|
99 | + public function single_row($item) { |
|
100 | 100 | $message_type = $item->message_type_obj(); |
101 | 101 | $messenger = $item->messenger_obj(); |
102 | 102 | |
103 | - if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger ) { |
|
103 | + if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
104 | 104 | echo ''; |
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | - parent::single_row( $item ); |
|
108 | + parent::single_row($item); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $mt_values = $this->get_admin_page()->get_message_types_for_list_table(); |
122 | 122 | //setup messengers for selects |
123 | 123 | $m_values[0]['id'] = 'all'; |
124 | - $m_values[0]['text'] = __('All Messengers', 'event_espresso' ); |
|
124 | + $m_values[0]['text'] = __('All Messengers', 'event_espresso'); |
|
125 | 125 | |
126 | 126 | $msgr_default[0] = array( |
127 | 127 | 'id' => 'none_selected', |
@@ -133,28 +133,28 @@ discard block |
||
133 | 133 | 'text' => __('Show All', 'event_espresso') |
134 | 134 | ); |
135 | 135 | |
136 | - $msgr_filters = !empty($m_values) ? array_merge( $msgr_default, $m_values ) : array(); |
|
137 | - $mt_filters = !empty($mt_values) ? array_merge( $mt_default, $mt_values ) : array(); |
|
136 | + $msgr_filters = ! empty($m_values) ? array_merge($msgr_default, $m_values) : array(); |
|
137 | + $mt_filters = ! empty($mt_values) ? array_merge($mt_default, $mt_values) : array(); |
|
138 | 138 | |
139 | - if ( empty( $m_values ) ) |
|
139 | + if (empty($m_values)) |
|
140 | 140 | $msgr_filters[0] = array( |
141 | 141 | 'id' => 'no_messenger_options', |
142 | 142 | 'text' => __('No Messengers active', 'event_espresso') |
143 | 143 | ); |
144 | 144 | |
145 | - if ( empty($mt_values) ) |
|
145 | + if (empty($mt_values)) |
|
146 | 146 | $mt_filters[0] = array( |
147 | 147 | 'id' => 'no_message_type_options', |
148 | 148 | 'text' => __('No Message Types active', 'event_espresso') |
149 | 149 | ); |
150 | 150 | |
151 | - if ( count( $m_values ) >= 1 && !empty( $m_values ) ) { |
|
152 | - unset( $msgr_filters[0] ); |
|
153 | - $msgr_filters = array_values( $msgr_filters ); //reindex keys |
|
151 | + if (count($m_values) >= 1 && ! empty($m_values)) { |
|
152 | + unset($msgr_filters[0]); |
|
153 | + $msgr_filters = array_values($msgr_filters); //reindex keys |
|
154 | 154 | } |
155 | 155 | |
156 | - $filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_key( $this->_req_data['ee_messenger_filter_by']) : '' ); |
|
157 | - $filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_key( $this->_req_data['ee_message_type_filter_by']) : ''); |
|
156 | + $filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_key($this->_req_data['ee_messenger_filter_by']) : ''); |
|
157 | + $filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_key($this->_req_data['ee_message_type_filter_by']) : ''); |
|
158 | 158 | return $filters; |
159 | 159 | } |
160 | 160 | |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | * we're just removing the search box for message templates, not needed. |
163 | 163 | * @return string (empty); |
164 | 164 | */ |
165 | - function search_box( $text, $input_id ) { |
|
165 | + function search_box($text, $input_id) { |
|
166 | 166 | return ''; |
167 | 167 | } |
168 | 168 | |
169 | 169 | |
170 | 170 | protected function _add_view_counts() { |
171 | - foreach ( $this->_views as $view => $args ) { |
|
172 | - $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( $this->_per_page, $view, TRUE, TRUE, FALSE ); |
|
171 | + foreach ($this->_views as $view => $args) { |
|
172 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates($this->_per_page, $view, TRUE, TRUE, FALSE); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -183,16 +183,16 @@ discard block |
||
183 | 183 | * @return string |
184 | 184 | */ |
185 | 185 | public function no_items() { |
186 | - if ( $this->_view !== 'trashed' ) |
|
187 | - printf( __('%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', 'event_espresso'), '<strong>', '</strong>' ); |
|
186 | + if ($this->_view !== 'trashed') |
|
187 | + printf(__('%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', 'event_espresso'), '<strong>', '</strong>'); |
|
188 | 188 | else |
189 | 189 | parent::no_items(); |
190 | 190 | } |
191 | 191 | |
192 | 192 | |
193 | 193 | |
194 | - public function column_cb( $item ) { |
|
195 | - return sprintf( '<input type="checkbox" name="checkbox[%s] value="1" />', $item->GRP_ID() ); |
|
194 | + public function column_cb($item) { |
|
195 | + return sprintf('<input type="checkbox" name="checkbox[%s] value="1" />', $item->GRP_ID()); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -200,29 +200,29 @@ discard block |
||
200 | 200 | |
201 | 201 | |
202 | 202 | |
203 | - function column_name( $item ) { |
|
204 | - return '<p>' . $item->name() . '</p>'; |
|
203 | + function column_name($item) { |
|
204 | + return '<p>'.$item->name().'</p>'; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
208 | 208 | |
209 | 209 | |
210 | - function column_description( $item ) { |
|
211 | - return '<p>' . $item->description() . '</p>'; |
|
210 | + function column_description($item) { |
|
211 | + return '<p>'.$item->description().'</p>'; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
215 | 215 | |
216 | - function column_actions( $item ) { |
|
217 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ) { |
|
216 | + function column_actions($item) { |
|
217 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template')) { |
|
218 | 218 | $create_args = array( |
219 | 219 | 'GRP_ID' => $item->ID(), |
220 | 220 | 'messenger' => $item->messenger(), |
221 | 221 | 'message_type' => $item->message_type(), |
222 | 222 | 'action' => 'add_new_message_template' |
223 | 223 | ); |
224 | - $create_link = EE_Admin_Page::add_query_args_and_nonce( $create_args, EE_MSG_ADMIN_URL ); |
|
225 | - return sprintf( '<p><a href="%s" class="button button-small">%s</a></p>', $create_link, __('Create Custom', 'event_espresso') ); |
|
224 | + $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
225 | + return sprintf('<p><a href="%s" class="button button-small">%s</a></p>', $create_link, __('Create Custom', 'event_espresso')); |
|
226 | 226 | } |
227 | 227 | return ''; |
228 | 228 | } |
@@ -239,27 +239,27 @@ discard block |
||
239 | 239 | $actions = array(); |
240 | 240 | |
241 | 241 | // edit link but only if item isn't trashed. |
242 | - if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ) { |
|
243 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_message_template', 'id'=>$item->GRP_ID() ), EE_MSG_ADMIN_URL ); |
|
244 | - $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template', 'event_espresso' ) . '">' . __( 'Edit', 'event_espresso' ) . '</a>'; |
|
242 | + if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID())) { |
|
243 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID()), EE_MSG_ADMIN_URL); |
|
244 | + $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>'; |
|
245 | 245 | } |
246 | 246 | |
247 | - $name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() )? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template', 'event_espresso' ) . '">' . ucwords( $item->messenger_obj()->label['singular'] ) . '</a>' : ucwords( $item->messenger_obj()->label['singular'] ); |
|
248 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'trash_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL ); |
|
247 | + $name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template', 'event_espresso').'">'.ucwords($item->messenger_obj()->label['singular']).'</a>' : ucwords($item->messenger_obj()->label['singular']); |
|
248 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'trash_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL); |
|
249 | 249 | // restore link |
250 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'restore_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL ); |
|
250 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'restore_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL); |
|
251 | 251 | // delete price link |
252 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'delete_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL ); |
|
252 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'delete_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL); |
|
253 | 253 | |
254 | - if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_trash_message_template', $item->ID() ) ) { |
|
255 | - $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' . esc_attr__( 'Move Template Group to Trash', 'event_espresso' ) . '">' . __( 'Move to Trash', 'event_espresso' ) . '</a>'; |
|
254 | + if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_trash_message_template', $item->ID())) { |
|
255 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Move Template Group to Trash', 'event_espresso').'">'.__('Move to Trash', 'event_espresso').'</a>'; |
|
256 | 256 | } else { |
257 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_restore_message_template', $item->ID() ) ) { |
|
258 | - $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' . esc_attr__( 'Restore Message Template', 'event_espresso' ) . '">' . __( 'Restore', 'event_espresso' ) . '</a>'; |
|
257 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_restore_message_template', $item->ID())) { |
|
258 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Message Template', 'event_espresso').'">'.__('Restore', 'event_espresso').'</a>'; |
|
259 | 259 | } |
260 | 260 | |
261 | - if ( $this->_view == 'trashed' && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_delete_message_template', $item->ID() ) ) { |
|
262 | - $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="' . esc_attr__( 'Delete Template Group Permanently', 'event_espresso' ) . '">' . __( 'Delete Permanently', 'event_espresso' ) . '</a>'; |
|
261 | + if ($this->_view == 'trashed' && EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_delete_message_template', $item->ID())) { |
|
262 | + $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="'.esc_attr__('Delete Template Group Permanently', 'event_espresso').'">'.__('Delete Permanently', 'event_espresso').'</a>'; |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
@@ -268,15 +268,15 @@ discard block |
||
268 | 268 | $c_configs = $item->contexts_config(); |
269 | 269 | $ctxt = array(); |
270 | 270 | $context_templates = $item->context_templates(); |
271 | - foreach ( $context_templates as $context => $template_fields ) { |
|
272 | - $mtp_to = !empty( $context_templates[$context]['to'] ) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL; |
|
273 | - $inactive = empty( $mtp_to ) && !empty( $context_templates[$context]['to'] ) ? ' class="mtp-inactive"' : ''; |
|
271 | + foreach ($context_templates as $context => $template_fields) { |
|
272 | + $mtp_to = ! empty($context_templates[$context]['to']) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL; |
|
273 | + $inactive = empty($mtp_to) && ! empty($context_templates[$context]['to']) ? ' class="mtp-inactive"' : ''; |
|
274 | 274 | $context_title = ucwords($c_configs[$context]['label']); |
275 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL ); |
|
276 | - $ctxt[] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a' . $inactive . ' href="'. $edit_link . '" title="' . esc_attr__('Edit Context', 'event_espresso') . '">' . $context_title . '</a>' : $context_title; |
|
275 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL); |
|
276 | + $ctxt[] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a'.$inactive.' href="'.$edit_link.'" title="'.esc_attr__('Edit Context', 'event_espresso').'">'.$context_title.'</a>' : $context_title; |
|
277 | 277 | } |
278 | 278 | |
279 | - $ctx_content = !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? sprintf( __('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural']) ) . implode(' | ', $ctxt) : ''; |
|
279 | + $ctx_content = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? sprintf(__('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural'])).implode(' | ', $ctxt) : ''; |
|
280 | 280 | |
281 | 281 | |
282 | 282 | //Return the name contents |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | /* $1%s */ $name_link, |
285 | 285 | /* $2%s */ $item->GRP_ID(), |
286 | 286 | /* %4$s */ $ctx_content, |
287 | - /* $3%s */ $this->row_actions( $actions ) |
|
287 | + /* $3%s */ $this->row_actions($actions) |
|
288 | 288 | ); |
289 | 289 | } |
290 | 290 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @return string message_type name |
306 | 306 | */ |
307 | 307 | function column_message_type($item) { |
308 | - return ucwords($item->message_type_obj()->label['singular'] ); |
|
308 | + return ucwords($item->message_type_obj()->label['singular']); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $this->_name = 'pricing'; |
55 | 55 | |
56 | 56 | //capability check |
57 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) { |
|
57 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | //if we were going to add our own metaboxes we'd use the below. |
63 | 63 | $this->_metaboxes = array( |
64 | 64 | 0 => array( |
65 | - 'page_route' => array('edit','create_new'), |
|
65 | + 'page_route' => array('edit', 'create_new'), |
|
66 | 66 | 'func' => 'pricing_metabox', |
67 | 67 | 'label' => __('Event Tickets & Datetimes', 'event_espresso'), |
68 | 68 | 'priority' => 'high', |
69 | 69 | 'context' => 'normal' |
70 | 70 | ), |
71 | 71 | |
72 | - );/**/ |
|
72 | + ); /**/ |
|
73 | 73 | |
74 | 74 | $this->_remove_metaboxes = array( |
75 | 75 | 0 => array( |
@@ -88,24 +88,24 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @var array Expected an array returned with 'date' and 'time' keys. |
90 | 90 | */ |
91 | - $this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
91 | + $this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
92 | 92 | 'date' => 'Y-m-d', |
93 | 93 | 'time' => 'h:i a' |
94 | 94 | )); |
95 | 95 | |
96 | 96 | //validate |
97 | - $this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null; |
|
98 | - $this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null; |
|
97 | + $this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null; |
|
98 | + $this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null; |
|
99 | 99 | |
100 | 100 | //validate format strings |
101 | - $format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
102 | - if ( is_array( $format_validation ) ) { |
|
103 | - $msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>'; |
|
104 | - foreach ( $format_validation as $error ) { |
|
105 | - $msg .= '<li>' . $error . '</li>'; |
|
101 | + $format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
102 | + if (is_array($format_validation)) { |
|
103 | + $msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>'; |
|
104 | + foreach ($format_validation as $error) { |
|
105 | + $msg .= '<li>'.$error.'</li>'; |
|
106 | 106 | } |
107 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
108 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
107 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
108 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
109 | 109 | $this->_date_format_strings = array( |
110 | 110 | 'date' => 'Y-m-d', |
111 | 111 | 'time' => 'h:i a' |
@@ -116,60 +116,60 @@ discard block |
||
116 | 116 | $this->_scripts_styles = array( |
117 | 117 | 'registers' => array( |
118 | 118 | 'ee-tickets-datetimes-css' => array( |
119 | - 'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css', |
|
119 | + 'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css', |
|
120 | 120 | 'type' => 'css' |
121 | 121 | ), |
122 | 122 | 'ee-dtt-ticket-metabox' => array( |
123 | - 'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js', |
|
123 | + 'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js', |
|
124 | 124 | 'depends' => array('ee-datepicker', 'ee-dialog', 'underscore') |
125 | 125 | ) |
126 | 126 | ), |
127 | 127 | 'deregisters' => array( |
128 | - 'event-editor-css' => array('type' => 'css' ), |
|
128 | + 'event-editor-css' => array('type' => 'css'), |
|
129 | 129 | 'event-datetime-metabox' => array('type' => 'js') |
130 | 130 | ), |
131 | 131 | 'enqueues' => array( |
132 | - 'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ), |
|
133 | - 'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' ) |
|
132 | + 'ee-tickets-datetimes-css' => array('edit', 'create_new'), |
|
133 | + 'ee-dtt-ticket-metabox' => array('edit', 'create_new') |
|
134 | 134 | ), |
135 | 135 | 'localize' => array( |
136 | 136 | 'ee-dtt-ticket-metabox' => array( |
137 | 137 | 'DTT_TRASH_BLOCK' => array( |
138 | 138 | 'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'), |
139 | 139 | 'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'), |
140 | - 'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>', |
|
140 | + 'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>', |
|
141 | 141 | 'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
142 | 142 | 'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
143 | - 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>' |
|
143 | + 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>' |
|
144 | 144 | ), |
145 | 145 | 'DTT_ERROR_MSG' => array( |
146 | 146 | 'no_ticket_name' => __('General Admission', 'event_espresso'), |
147 | - 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>' |
|
147 | + 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>' |
|
148 | 148 | ), |
149 | 149 | 'DTT_OVERSELL_WARNING' => array( |
150 | 150 | 'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', 'event_espresso'), |
151 | 151 | 'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', 'event_espresso') |
152 | 152 | ), |
153 | - 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ), |
|
154 | - 'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) ) |
|
153 | + 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']), |
|
154 | + 'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week')) |
|
155 | 155 | ) |
156 | 156 | ) |
157 | 157 | ); |
158 | 158 | |
159 | 159 | |
160 | - add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 ); |
|
161 | - add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 ); |
|
160 | + add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10); |
|
161 | + add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
165 | 165 | |
166 | - public function caf_updates( $update_callbacks ) { |
|
167 | - foreach ( $update_callbacks as $key => $callback ) { |
|
168 | - if ( $callback[1] == '_default_tickets_update' ) |
|
169 | - unset( $update_callbacks[$key] ); |
|
166 | + public function caf_updates($update_callbacks) { |
|
167 | + foreach ($update_callbacks as $key => $callback) { |
|
168 | + if ($callback[1] == '_default_tickets_update') |
|
169 | + unset($update_callbacks[$key]); |
|
170 | 170 | } |
171 | 171 | |
172 | - $update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' ); |
|
172 | + $update_callbacks[] = array($this, 'dtt_and_tickets_caf_update'); |
|
173 | 173 | return $update_callbacks; |
174 | 174 | } |
175 | 175 | |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | * @param array $data The request data from the form |
183 | 183 | * @return bool success or fail |
184 | 184 | */ |
185 | - public function dtt_and_tickets_caf_update( $evtobj, $data ) { |
|
185 | + public function dtt_and_tickets_caf_update($evtobj, $data) { |
|
186 | 186 | //first we need to start with datetimes cause they are the "root" items attached to events. |
187 | - $saved_dtts = $this->_update_dtts( $evtobj, $data ); |
|
187 | + $saved_dtts = $this->_update_dtts($evtobj, $data); |
|
188 | 188 | //next tackle the tickets (and prices?) |
189 | - $this->_update_tkts( $evtobj, $saved_dtts, $data ); |
|
189 | + $this->_update_tkts($evtobj, $saved_dtts, $data); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | |
@@ -197,41 +197,41 @@ discard block |
||
197 | 197 | * @param array $data the request data from the form |
198 | 198 | * @return EE_Datetime[] |
199 | 199 | */ |
200 | - protected function _update_dtts( $evt_obj, $data ) { |
|
201 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
200 | + protected function _update_dtts($evt_obj, $data) { |
|
201 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
202 | 202 | $saved_dtt_ids = array(); |
203 | 203 | $saved_dtt_objs = array(); |
204 | 204 | |
205 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
205 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
206 | 206 | //trim all values to ensure any excess whitespace is removed. |
207 | 207 | $dtt = array_map( |
208 | - function( $datetime_data ) { |
|
209 | - return is_array( $datetime_data ) ? $datetime_data : trim( $datetime_data ); |
|
208 | + function($datetime_data) { |
|
209 | + return is_array($datetime_data) ? $datetime_data : trim($datetime_data); |
|
210 | 210 | }, |
211 | 211 | $dtt |
212 | 212 | ); |
213 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
213 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
214 | 214 | $datetime_values = array( |
215 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
216 | - 'DTT_name' => ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '', |
|
217 | - 'DTT_description' => ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '', |
|
215 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
216 | + 'DTT_name' => ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '', |
|
217 | + 'DTT_description' => ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '', |
|
218 | 218 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
219 | 219 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
220 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ], |
|
221 | - 'DTT_order' => ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'], |
|
220 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
221 | + 'DTT_order' => ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'], |
|
222 | 222 | ); |
223 | 223 | |
224 | 224 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
225 | 225 | |
226 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
227 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
226 | + if ( ! empty($dtt['DTT_ID'])) { |
|
227 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']); |
|
228 | 228 | |
229 | 229 | //set date and time format according to what is set in this class. |
230 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
231 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
230 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
231 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
232 | 232 | |
233 | - foreach ( $datetime_values as $field => $value ) { |
|
234 | - $DTM->set( $field, $value ); |
|
233 | + foreach ($datetime_values as $field => $value) { |
|
234 | + $DTM->set($field, $value); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. |
@@ -239,24 +239,24 @@ discard block |
||
239 | 239 | $saved_dtt_ids[$DTM->ID()] = $DTM->ID(); |
240 | 240 | |
241 | 241 | } else { |
242 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE ); |
|
242 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE); |
|
243 | 243 | |
244 | 244 | //reset date and times to match the format |
245 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
246 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
247 | - foreach( $datetime_values as $field => $value ) { |
|
248 | - $DTM->set( $field, $value ); |
|
245 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
246 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
247 | + foreach ($datetime_values as $field => $value) { |
|
248 | + $DTM->set($field, $value); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | 252 | |
253 | 253 | $DTM->save(); |
254 | - $DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' ); |
|
254 | + $DTM = $evt_obj->_add_relation_to($DTM, 'Datetime'); |
|
255 | 255 | $evt_obj->save(); |
256 | 256 | |
257 | 257 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
258 | - if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) { |
|
259 | - $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') ); |
|
258 | + if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) { |
|
259 | + $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start')); |
|
260 | 260 | $DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days'); |
261 | 261 | $DTM->save(); |
262 | 262 | } |
@@ -271,25 +271,25 @@ discard block |
||
271 | 271 | } |
272 | 272 | |
273 | 273 | //now we need to REMOVE any dtts that got deleted. Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point. |
274 | - $old_datetimes = explode(',', $data['datetime_IDs'] ); |
|
274 | + $old_datetimes = explode(',', $data['datetime_IDs']); |
|
275 | 275 | $old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes; |
276 | 276 | |
277 | - if ( is_array( $old_datetimes ) ) { |
|
278 | - $dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids ); |
|
279 | - foreach ( $dtts_to_delete as $id ) { |
|
280 | - $id = absint( $id ); |
|
281 | - if ( empty( $id ) ) |
|
277 | + if (is_array($old_datetimes)) { |
|
278 | + $dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids); |
|
279 | + foreach ($dtts_to_delete as $id) { |
|
280 | + $id = absint($id); |
|
281 | + if (empty($id)) |
|
282 | 282 | continue; |
283 | 283 | |
284 | 284 | $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id); |
285 | 285 | |
286 | 286 | //remove tkt relationships. |
287 | 287 | $related_tickets = $dtt_to_remove->get_many_related('Ticket'); |
288 | - foreach ( $related_tickets as $tkt ) { |
|
288 | + foreach ($related_tickets as $tkt) { |
|
289 | 289 | $dtt_to_remove->_remove_relation_to($tkt, 'Ticket'); |
290 | 290 | } |
291 | 291 | |
292 | - $evt_obj->_remove_relation_to( $id, 'Datetime' ); |
|
292 | + $evt_obj->_remove_relation_to($id, 'Datetime'); |
|
293 | 293 | $dtt_to_remove->refresh_cache_of_related_objects(); |
294 | 294 | |
295 | 295 | } |
@@ -310,85 +310,85 @@ discard block |
||
310 | 310 | * @param array $data incoming request data |
311 | 311 | * @return EE_Ticket[] |
312 | 312 | */ |
313 | - protected function _update_tkts( $evtobj, $saved_dtts, $data ) { |
|
313 | + protected function _update_tkts($evtobj, $saved_dtts, $data) { |
|
314 | 314 | |
315 | 315 | $new_tkt = null; |
316 | 316 | $new_default = null; |
317 | 317 | //stripslashes because WP filtered the $_POST ($data) array to add slashes |
318 | 318 | $data = stripslashes_deep($data); |
319 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
319 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
320 | 320 | $saved_tickets = $dtts_on_existing = array(); |
321 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
321 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
322 | 322 | |
323 | 323 | //load money helper |
324 | 324 | |
325 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
325 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
326 | 326 | |
327 | 327 | $update_prices = $create_new_TKT = FALSE; |
328 | 328 | |
329 | 329 | //figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session. |
330 | 330 | |
331 | - $starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]); |
|
332 | - $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] ); |
|
331 | + $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]); |
|
332 | + $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]); |
|
333 | 333 | $dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows); |
334 | 334 | $dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows); |
335 | 335 | |
336 | 336 | // trim inputs to ensure any excess whitespace is removed. |
337 | 337 | $tkt = array_map( |
338 | - function( $ticket_data ) { |
|
339 | - return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data ); |
|
338 | + function($ticket_data) { |
|
339 | + return is_array($ticket_data) ? $ticket_data : trim($ticket_data); |
|
340 | 340 | }, |
341 | 341 | $tkt |
342 | 342 | ); |
343 | 343 | |
344 | 344 | //note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models. |
345 | 345 | //note incoming ['TKT_price'] value is already in standard notation (via js). |
346 | - $ticket_price = isset( $tkt['TKT_price'] ) ? round ( (float) $tkt['TKT_price'], 3 ) : 0; |
|
346 | + $ticket_price = isset($tkt['TKT_price']) ? round((float) $tkt['TKT_price'], 3) : 0; |
|
347 | 347 | |
348 | 348 | //note incoming base price needs converted from localized value. |
349 | - $base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0; |
|
349 | + $base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0; |
|
350 | 350 | //if ticket price == 0 and $base_price != 0 then ticket price == base_price |
351 | 351 | $ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price; |
352 | - $base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0; |
|
352 | + $base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0; |
|
353 | 353 | |
354 | 354 | $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array(); |
355 | 355 | |
356 | 356 | $now = null; |
357 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
357 | + if (empty($tkt['TKT_start_date'])) { |
|
358 | 358 | //lets' use now in the set timezone. |
359 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
360 | - $tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
359 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
360 | + $tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
361 | 361 | } |
362 | 362 | |
363 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
363 | + if (empty($tkt['TKT_end_date'])) { |
|
364 | 364 | /** |
365 | 365 | * set the TKT_end_date to the first datetime attached to the ticket. |
366 | 366 | */ |
367 | - $first_dtt = $saved_dtts[reset( $tkt_dtt_rows )]; |
|
368 | - $tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] ); |
|
367 | + $first_dtt = $saved_dtts[reset($tkt_dtt_rows)]; |
|
368 | + $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $TKT_values = array( |
372 | - 'TKT_ID' => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
373 | - 'TTM_ID' => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
374 | - 'TKT_name' => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
375 | - 'TKT_description' => ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
372 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
373 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
374 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
375 | + 'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
376 | 376 | 'TKT_start_date' => $tkt['TKT_start_date'], |
377 | 377 | 'TKT_end_date' => $tkt['TKT_end_date'], |
378 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ], |
|
379 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'], |
|
380 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
381 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
378 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
379 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
380 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
381 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
382 | 382 | 'TKT_row' => $row, |
383 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0, |
|
384 | - 'TKT_taxable' => ! empty( $tkt['TKT_taxable'] ) ? 1 : 0, |
|
385 | - 'TKT_required' => ! empty( $tkt['TKT_required'] ) ? 1 : 0, |
|
383 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0, |
|
384 | + 'TKT_taxable' => ! empty($tkt['TKT_taxable']) ? 1 : 0, |
|
385 | + 'TKT_required' => ! empty($tkt['TKT_required']) ? 1 : 0, |
|
386 | 386 | 'TKT_price' => $ticket_price |
387 | 387 | ); |
388 | 388 | |
389 | 389 | |
390 | 390 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
391 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
391 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
392 | 392 | $TKT_values['TKT_ID'] = 0; |
393 | 393 | $TKT_values['TKT_is_default'] = 0; |
394 | 394 | $update_prices = TRUE; |
@@ -400,21 +400,21 @@ discard block |
||
400 | 400 | // but DID have it's items modified. |
401 | 401 | // keep in mind that if the TKT has been sold (and we have changed pricing information), |
402 | 402 | // then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
403 | - if ( absint( $TKT_values['TKT_ID'] ) ) { |
|
404 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
405 | - if ( $TKT instanceof EE_Ticket ) { |
|
403 | + if (absint($TKT_values['TKT_ID'])) { |
|
404 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']); |
|
405 | + if ($TKT instanceof EE_Ticket) { |
|
406 | 406 | |
407 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
407 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
408 | 408 | // are there any registrations using this ticket ? |
409 | 409 | $tickets_sold = $TKT->count_related( |
410 | 410 | 'Registration', |
411 | - array( array( |
|
412 | - 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) |
|
413 | - ) ) |
|
411 | + array(array( |
|
412 | + 'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)) |
|
413 | + )) |
|
414 | 414 | ); |
415 | 415 | //set ticket formats |
416 | - $TKT->set_date_format( $this->_date_format_strings['date'] ); |
|
417 | - $TKT->set_time_format( $this->_date_format_strings['time'] ); |
|
416 | + $TKT->set_date_format($this->_date_format_strings['date']); |
|
417 | + $TKT->set_time_format($this->_date_format_strings['time']); |
|
418 | 418 | |
419 | 419 | // let's just check the total price for the existing ticket |
420 | 420 | // and determine if it matches the new total price. |
@@ -424,17 +424,17 @@ discard block |
||
424 | 424 | ? TRUE : FALSE; |
425 | 425 | |
426 | 426 | //set new values |
427 | - foreach ( $TKT_values as $field => $value ) { |
|
428 | - if ( $field === 'TKT_qty' ) { |
|
429 | - $TKT->set_qty( $value ); |
|
427 | + foreach ($TKT_values as $field => $value) { |
|
428 | + if ($field === 'TKT_qty') { |
|
429 | + $TKT->set_qty($value); |
|
430 | 430 | } else { |
431 | - $TKT->set( $field, $value ); |
|
431 | + $TKT->set($field, $value); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | 435 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
436 | - if ( $create_new_TKT ) { |
|
437 | - $new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id ); |
|
436 | + if ($create_new_TKT) { |
|
437 | + $new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id); |
|
438 | 438 | } |
439 | 439 | } |
440 | 440 | |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | $TKT = EE_Ticket::new_instance( |
444 | 444 | $TKT_values, |
445 | 445 | $timezone, |
446 | - array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ] ) |
|
446 | + array($this->_date_format_strings['date'], $this->_date_format_strings['time']) |
|
447 | 447 | ); |
448 | - if ( $TKT instanceof EE_Ticket ) { |
|
448 | + if ($TKT instanceof EE_Ticket) { |
|
449 | 449 | // make sure ticket has an ID of setting relations won't work |
450 | 450 | $TKT->save(); |
451 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
451 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
452 | 452 | $update_prices = TRUE; |
453 | 453 | } |
454 | 454 | } |
@@ -456,37 +456,37 @@ discard block |
||
456 | 456 | //$TKT->save(); |
457 | 457 | |
458 | 458 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
459 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
460 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
459 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
460 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
461 | 461 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
462 | 462 | } |
463 | 463 | |
464 | 464 | //let's make sure the base price is handled |
465 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT; |
|
465 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT; |
|
466 | 466 | |
467 | 467 | //add/update price_modifiers |
468 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT; |
|
468 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT; |
|
469 | 469 | |
470 | 470 | //need to make sue that the TKT_price is accurate after saving the prices. |
471 | 471 | $TKT->ensure_TKT_Price_correct(); |
472 | 472 | |
473 | 473 | //handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave. |
474 | - if ( ! defined('DOING_AUTOSAVE' ) ) { |
|
475 | - if ( !empty($tkt['TKT_is_default_selector'] ) ) { |
|
474 | + if ( ! defined('DOING_AUTOSAVE')) { |
|
475 | + if ( ! empty($tkt['TKT_is_default_selector'])) { |
|
476 | 476 | $update_prices = TRUE; |
477 | 477 | $new_default = clone $TKT; |
478 | - $new_default->set( 'TKT_ID', 0 ); |
|
479 | - $new_default->set( 'TKT_is_default', 1 ); |
|
480 | - $new_default->set( 'TKT_row', 1 ); |
|
481 | - $new_default->set( 'TKT_price', $ticket_price ); |
|
478 | + $new_default->set('TKT_ID', 0); |
|
479 | + $new_default->set('TKT_is_default', 1); |
|
480 | + $new_default->set('TKT_row', 1); |
|
481 | + $new_default->set('TKT_price', $ticket_price); |
|
482 | 482 | //remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object) |
483 | 483 | $new_default->_remove_relations('Datetime'); |
484 | 484 | //todo we need to add the current attached prices as new prices to the new default ticket. |
485 | - $new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices ); |
|
485 | + $new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices); |
|
486 | 486 | //don't forget the base price! |
487 | - $new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id ); |
|
487 | + $new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id); |
|
488 | 488 | $new_default->save(); |
489 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data ); |
|
489 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data); |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | |
@@ -497,19 +497,19 @@ discard block |
||
497 | 497 | //let's assign any tickets that have been setup to the saved_tickets tracker |
498 | 498 | //save existing TKT |
499 | 499 | $TKT->save(); |
500 | - if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) { |
|
500 | + if ($create_new_TKT && $new_tkt instanceof EE_Ticket) { |
|
501 | 501 | //save new TKT |
502 | 502 | $new_tkt->save(); |
503 | 503 | //add new ticket to array |
504 | - $saved_tickets[ $new_tkt->ID() ] = $new_tkt; |
|
504 | + $saved_tickets[$new_tkt->ID()] = $new_tkt; |
|
505 | 505 | |
506 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data ); |
|
506 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data); |
|
507 | 507 | |
508 | 508 | } else { |
509 | 509 | //add tkt to saved tkts |
510 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
510 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
511 | 511 | |
512 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data ); |
|
512 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | } |
@@ -519,22 +519,22 @@ discard block |
||
519 | 519 | // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket). |
520 | 520 | // Or a draft event was saved and in the process of editing a ticket is trashed. |
521 | 521 | // No sense in keeping all the related data in the db! |
522 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
523 | - $tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) ); |
|
522 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
523 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
524 | 524 | |
525 | - foreach ( $tickets_removed as $id ) { |
|
526 | - $id = absint( $id ); |
|
525 | + foreach ($tickets_removed as $id) { |
|
526 | + $id = absint($id); |
|
527 | 527 | |
528 | 528 | //get the ticket for this id |
529 | 529 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
530 | 530 | |
531 | 531 | //if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime |
532 | - if ( $tkt_to_remove->get('TKT_is_default') ) |
|
532 | + if ($tkt_to_remove->get('TKT_is_default')) |
|
533 | 533 | continue; |
534 | 534 | |
535 | 535 | // if this tkt has any registrations attached so then we just ARCHIVE |
536 | 536 | // because we don't actually permanently delete these tickets. |
537 | - if ( $tkt_to_remove->count_related('Registration') > 0 ) { |
|
537 | + if ($tkt_to_remove->count_related('Registration') > 0) { |
|
538 | 538 | $tkt_to_remove->delete(); |
539 | 539 | continue; |
540 | 540 | } |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | // (remember this process can ONLY kick off if there are NO tkts_sold) |
544 | 544 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
545 | 545 | |
546 | - foreach( $dtts as $dtt ) { |
|
546 | + foreach ($dtts as $dtt) { |
|
547 | 547 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
548 | 548 | } |
549 | 549 | |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
552 | 552 | $tkt_to_remove->delete_related_permanently('Price'); |
553 | 553 | |
554 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove ); |
|
554 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove); |
|
555 | 555 | |
556 | 556 | // finally let's delete this ticket |
557 | 557 | // (which should not be blocked at this point b/c we've removed all our relationships) |
@@ -583,39 +583,39 @@ discard block |
||
583 | 583 | // and removing the ticket from datetimes it got removed from. |
584 | 584 | |
585 | 585 | // first let's add datetimes |
586 | - if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) { |
|
587 | - foreach ( $added_datetimes as $row_id ) { |
|
586 | + if ( ! empty($added_datetimes) && is_array($added_datetimes)) { |
|
587 | + foreach ($added_datetimes as $row_id) { |
|
588 | 588 | $row_id = (int) $row_id; |
589 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
590 | - $ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
589 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
590 | + $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
591 | 591 | // Is this an existing ticket (has an ID) and does it have any sold? |
592 | 592 | // If so, then we need to add that to the DTT sold because this DTT is getting added. |
593 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
594 | - $saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() ); |
|
595 | - $saved_datetimes[ $row_id ]->save(); |
|
593 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
594 | + $saved_datetimes[$row_id]->increase_sold($ticket->sold()); |
|
595 | + $saved_datetimes[$row_id]->save(); |
|
596 | 596 | } |
597 | 597 | } |
598 | 598 | } |
599 | 599 | } |
600 | 600 | // then remove datetimes |
601 | - if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) { |
|
602 | - foreach ( $removed_datetimes as $row_id ) { |
|
603 | - $row_id = (int)$row_id; |
|
601 | + if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
602 | + foreach ($removed_datetimes as $row_id) { |
|
603 | + $row_id = (int) $row_id; |
|
604 | 604 | // its entirely possible that a datetime got deleted (instead of just removed from relationship. |
605 | 605 | // So make sure we skip over this if the dtt isn't in the $saved_datetimes array) |
606 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
607 | - $ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
606 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
607 | + $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
608 | 608 | // Is this an existing ticket (has an ID) and does it have any sold? |
609 | 609 | // If so, then we need to remove it's sold from the DTT_sold. |
610 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
611 | - $saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() ); |
|
612 | - $saved_datetimes[ $row_id ]->save(); |
|
610 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
611 | + $saved_datetimes[$row_id]->decrease_sold($ticket->sold()); |
|
612 | + $saved_datetimes[$row_id]->save(); |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 | } |
616 | 616 | } |
617 | 617 | // cap ticket qty by datetime reg limits |
618 | - $ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) ); |
|
618 | + $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
619 | 619 | return $ticket; |
620 | 620 | } |
621 | 621 | |
@@ -636,39 +636,39 @@ discard block |
||
636 | 636 | EE_Ticket $ticket, |
637 | 637 | $price_rows = array(), |
638 | 638 | $ticket_price = 0, |
639 | - $base_price = 0 , |
|
639 | + $base_price = 0, |
|
640 | 640 | $base_price_id = 0 |
641 | 641 | ) { |
642 | 642 | |
643 | 643 | // create new ticket that's a copy of the existing |
644 | 644 | // except a new id of course (and not archived) |
645 | 645 | // AND has the new TKT_price associated with it. |
646 | - $new_ticket = clone( $ticket ); |
|
647 | - $new_ticket->set( 'TKT_ID', 0 ); |
|
648 | - $new_ticket->set( 'TKT_deleted', 0 ); |
|
649 | - $new_ticket->set( 'TKT_price', $ticket_price ); |
|
650 | - $new_ticket->set( 'TKT_sold', 0 ); |
|
646 | + $new_ticket = clone($ticket); |
|
647 | + $new_ticket->set('TKT_ID', 0); |
|
648 | + $new_ticket->set('TKT_deleted', 0); |
|
649 | + $new_ticket->set('TKT_price', $ticket_price); |
|
650 | + $new_ticket->set('TKT_sold', 0); |
|
651 | 651 | // let's get a new ID for this ticket |
652 | 652 | $new_ticket->save(); |
653 | 653 | // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket |
654 | - $datetimes_on_existing = $ticket->get_many_related( 'Datetime' ); |
|
654 | + $datetimes_on_existing = $ticket->get_many_related('Datetime'); |
|
655 | 655 | $new_ticket = $this->_update_ticket_datetimes( |
656 | 656 | $new_ticket, |
657 | 657 | $datetimes_on_existing, |
658 | - array_keys( $datetimes_on_existing ) |
|
658 | + array_keys($datetimes_on_existing) |
|
659 | 659 | ); |
660 | 660 | |
661 | 661 | // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array. |
662 | 662 | // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining |
663 | 663 | // available. |
664 | - if ( $ticket->sold() > 0 ) { |
|
664 | + if ($ticket->sold() > 0) { |
|
665 | 665 | $new_qty = $ticket->qty() - $ticket->sold(); |
666 | - $new_ticket->set_qty( $new_qty ); |
|
666 | + $new_ticket->set_qty($new_qty); |
|
667 | 667 | } |
668 | 668 | //now we update the prices just for this ticket |
669 | - $new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true ); |
|
669 | + $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true); |
|
670 | 670 | //and we update the base price |
671 | - $new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id ); |
|
671 | + $new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id); |
|
672 | 672 | return $new_ticket; |
673 | 673 | } |
674 | 674 | |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | * @param int|bool $base_price_id if present then this is the base_price_id being updated. |
689 | 689 | * @return EE_Ticket |
690 | 690 | */ |
691 | - protected function _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) { |
|
691 | + protected function _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) { |
|
692 | 692 | |
693 | 693 | //let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session. |
694 | 694 | $current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers(); |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | $updated_prices = array(); |
697 | 697 | |
698 | 698 | // if $base_price ! FALSE then updating a base price. |
699 | - if ( $base_price !== FALSE ) { |
|
699 | + if ($base_price !== FALSE) { |
|
700 | 700 | $prices[1] = array( |
701 | 701 | 'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id, |
702 | 702 | 'PRT_ID' => 1, |
@@ -707,47 +707,47 @@ discard block |
||
707 | 707 | } |
708 | 708 | |
709 | 709 | //possibly need to save tkt |
710 | - if ( ! $ticket->ID() ) |
|
710 | + if ( ! $ticket->ID()) |
|
711 | 711 | $ticket->save(); |
712 | 712 | |
713 | - foreach ( $prices as $row => $prc ) { |
|
714 | - $prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL; |
|
715 | - if ( empty($prt_id) ) |
|
713 | + foreach ($prices as $row => $prc) { |
|
714 | + $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL; |
|
715 | + if (empty($prt_id)) |
|
716 | 716 | continue; //prices MUST have a price type id. |
717 | 717 | $PRC_values = array( |
718 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
718 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
719 | 719 | 'PRT_ID' => $prt_id, |
720 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
721 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
722 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
720 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
721 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
722 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
723 | 723 | 'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor |
724 | 724 | 'PRC_order' => $row |
725 | 725 | ); |
726 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
726 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
727 | 727 | $PRC_values['PRC_ID'] = 0; |
728 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
728 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
729 | 729 | } else { |
730 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
730 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
731 | 731 | //update this price with new values |
732 | - foreach ( $PRC_values as $field => $newprc ) { |
|
733 | - $PRC->set( $field, $newprc ); |
|
732 | + foreach ($PRC_values as $field => $newprc) { |
|
733 | + $PRC->set($field, $newprc); |
|
734 | 734 | } |
735 | 735 | } |
736 | 736 | $PRC->save(); |
737 | 737 | $prcid = $PRC->ID(); |
738 | 738 | $updated_prices[$prcid] = $PRC; |
739 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
739 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | //now let's remove any prices that got removed from the ticket |
743 | - if ( !empty ( $current_prices_on_ticket ) ) { |
|
743 | + if ( ! empty ($current_prices_on_ticket)) { |
|
744 | 744 | $current = array_keys($current_prices_on_ticket); |
745 | 745 | $updated = array_keys($updated_prices); |
746 | 746 | $prices_to_remove = array_diff($current, $updated); |
747 | - if ( !empty( $prices_to_remove ) ) { |
|
748 | - foreach ( $prices_to_remove as $prc_id ) { |
|
747 | + if ( ! empty($prices_to_remove)) { |
|
748 | + foreach ($prices_to_remove as $prc_id) { |
|
749 | 749 | $p = $current_prices_on_ticket[$prc_id]; |
750 | - $ticket->_remove_relation_to( $p, 'Price' ); |
|
750 | + $ticket->_remove_relation_to($p, 'Price'); |
|
751 | 751 | |
752 | 752 | //delete permanently the price |
753 | 753 | $p->delete_permanently(); |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | |
761 | 761 | |
762 | 762 | |
763 | - public function autosave_handling( $event_admin_obj ) { |
|
763 | + public function autosave_handling($event_admin_obj) { |
|
764 | 764 | return $event_admin_obj; //doing nothing for the moment. |
765 | 765 | //todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method) |
766 | 766 | |
@@ -794,12 +794,12 @@ discard block |
||
794 | 794 | |
795 | 795 | //default main template args |
796 | 796 | $main_template_args = array( |
797 | - 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
797 | + 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
798 | 798 | 'existing_datetime_ids' => '', |
799 | 799 | 'total_dtt_rows' => 1, |
800 | - 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
800 | + 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
801 | 801 | 'datetime_rows' => '', |
802 | - 'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
802 | + 'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
803 | 803 | 'ticket_rows' => '', |
804 | 804 | 'existing_ticket_ids' => '', |
805 | 805 | 'total_ticket_rows' => 1, |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | |
810 | 810 | $timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL; |
811 | 811 | |
812 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
812 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
813 | 813 | |
814 | 814 | /** |
815 | 815 | * 1. Start with retrieving Datetimes |
@@ -817,8 +817,8 @@ discard block |
||
817 | 817 | * 3. For each ticket get related prices |
818 | 818 | */ |
819 | 819 | |
820 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) ); |
|
821 | - $times = $DTM->get_all_event_dates( $evtID ); |
|
820 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone)); |
|
821 | + $times = $DTM->get_all_event_dates($evtID); |
|
822 | 822 | |
823 | 823 | |
824 | 824 | |
@@ -826,31 +826,31 @@ discard block |
||
826 | 826 | |
827 | 827 | /** @see https://events.codebasehq.com/projects/event-espresso/tickets/9486 for why we are counting $dttrow and then setting that on the Datetime object */ |
828 | 828 | $dttrow = 1; |
829 | - foreach ( $times as $time ) { |
|
829 | + foreach ($times as $time) { |
|
830 | 830 | $dttid = $time->get('DTT_ID'); |
831 | - $time->set( 'DTT_order', $dttrow ); |
|
831 | + $time->set('DTT_order', $dttrow); |
|
832 | 832 | $existing_datetime_ids[] = $dttid; |
833 | 833 | |
834 | 834 | //tickets attached |
835 | - $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array(); |
|
835 | + $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array(); |
|
836 | 836 | |
837 | 837 | //if there are no related tickets this is likely a new event OR autodraft |
838 | 838 | // event so we need to generate the default tickets because dtts |
839 | 839 | // ALWAYS have at least one related ticket!!. EXCEPT, we dont' do this if there is already more than one |
840 | 840 | // datetime on the event. |
841 | - if ( empty ( $related_tickets ) && count( $times ) < 2 ) { |
|
841 | + if (empty ($related_tickets) && count($times) < 2) { |
|
842 | 842 | $related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
843 | 843 | |
844 | 844 | //this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save). |
845 | 845 | $default_prices = EEM_Price::instance()->get_all_default_prices(); |
846 | 846 | |
847 | - $main_default_ticket = reset( $related_tickets ); |
|
848 | - if ( $main_default_ticket instanceof EE_Ticket ) { |
|
849 | - foreach ( $default_prices as $default_price ) { |
|
850 | - if ( $default_price->is_base_price() ) { |
|
847 | + $main_default_ticket = reset($related_tickets); |
|
848 | + if ($main_default_ticket instanceof EE_Ticket) { |
|
849 | + foreach ($default_prices as $default_price) { |
|
850 | + if ($default_price->is_base_price()) { |
|
851 | 851 | continue; |
852 | 852 | } |
853 | - $main_default_ticket->cache( 'Price', $default_price ); |
|
853 | + $main_default_ticket->cache('Price', $default_price); |
|
854 | 854 | } |
855 | 855 | } |
856 | 856 | } |
@@ -859,11 +859,11 @@ discard block |
||
859 | 859 | //we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information. |
860 | 860 | |
861 | 861 | //loop through and setup the ticket rows and make sure the order is set. |
862 | - foreach ( $related_tickets as $ticket ) { |
|
862 | + foreach ($related_tickets as $ticket) { |
|
863 | 863 | $tktid = $ticket->get('TKT_ID'); |
864 | 864 | $tktrow = $ticket->get('TKT_row'); |
865 | 865 | //we only want unique tickets in our final display!! |
866 | - if ( !in_array( $tktid, $existing_ticket_ids ) ) { |
|
866 | + if ( ! in_array($tktid, $existing_ticket_ids)) { |
|
867 | 867 | $existing_ticket_ids[] = $tktid; |
868 | 868 | $all_tickets[] = $ticket; |
869 | 869 | } |
@@ -872,57 +872,57 @@ discard block |
||
872 | 872 | $datetime_tickets[$dttid][] = $tktrow; |
873 | 873 | |
874 | 874 | //temporary cache of this datetime info for this ticket for later processing of ticket rows. |
875 | - if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) ) |
|
875 | + if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) |
|
876 | 876 | $ticket_datetimes[$tktid][] = $dttrow; |
877 | 877 | } |
878 | 878 | $dttrow++; |
879 | 879 | } |
880 | 880 | |
881 | - $main_template_args['total_ticket_rows'] = count( $existing_ticket_ids ); |
|
882 | - $main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids ); |
|
883 | - $main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids ); |
|
881 | + $main_template_args['total_ticket_rows'] = count($existing_ticket_ids); |
|
882 | + $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
883 | + $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
884 | 884 | |
885 | 885 | //sort $all_tickets by order |
886 | - usort( $all_tickets, function( $a, $b ) { |
|
886 | + usort($all_tickets, function($a, $b) { |
|
887 | 887 | $a_order = (int) $a->get('TKT_order'); |
888 | 888 | $b_order = (int) $b->get('TKT_order'); |
889 | - if ( $a_order == $b_order ) { |
|
889 | + if ($a_order == $b_order) { |
|
890 | 890 | return 0; |
891 | 891 | } |
892 | - return ( $a_order < $b_order ) ? -1 : 1; |
|
892 | + return ($a_order < $b_order) ? -1 : 1; |
|
893 | 893 | }); |
894 | 894 | |
895 | 895 | //k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again. |
896 | 896 | $dttrow = 1; |
897 | - foreach ( $times as $time ) { |
|
898 | - $main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times ); |
|
897 | + foreach ($times as $time) { |
|
898 | + $main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times); |
|
899 | 899 | $dttrow++; |
900 | 900 | } |
901 | 901 | |
902 | 902 | //then loop through all tickets for the ticket rows. |
903 | 903 | $tktrow = 1; |
904 | - foreach ( $all_tickets as $ticket ) { |
|
905 | - $main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets ); |
|
904 | + foreach ($all_tickets as $ticket) { |
|
905 | + $main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets); |
|
906 | 906 | $tktrow++; |
907 | 907 | } |
908 | 908 | |
909 | 909 | $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets); |
910 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'; |
|
911 | - EEH_Template::display_template( $template, $main_template_args ); |
|
910 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'; |
|
911 | + EEH_Template::display_template($template, $main_template_args); |
|
912 | 912 | return; |
913 | 913 | } |
914 | 914 | |
915 | 915 | |
916 | 916 | |
917 | - protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) { |
|
917 | + protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) { |
|
918 | 918 | |
919 | 919 | $dtt_display_template_args = array( |
920 | - 'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ), |
|
921 | - 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ), |
|
920 | + 'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts), |
|
921 | + 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default), |
|
922 | 922 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow |
923 | 923 | ); |
924 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php'; |
|
925 | - return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE); |
|
924 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php'; |
|
925 | + return EEH_Template::display_template($template, $dtt_display_template_args, TRUE); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return string Generated edit row. |
942 | 942 | */ |
943 | - protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) { |
|
943 | + protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) { |
|
944 | 944 | |
945 | 945 | // if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true. |
946 | 946 | $default = ! $dtt instanceof EE_Datetime ? true : false; |
@@ -948,30 +948,30 @@ discard block |
||
948 | 948 | $template_args = array( |
949 | 949 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
950 | 950 | 'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes', |
951 | - 'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
951 | + 'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
952 | 952 | 'DTT_ID' => $default ? '' : $dtt->ID(), |
953 | 953 | 'DTT_name' => $default ? '' : $dtt->name(), |
954 | 954 | 'DTT_description' => $default ? '' : $dtt->description(), |
955 | - 'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
956 | - 'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
957 | - 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'), |
|
955 | + 'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
956 | + 'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
957 | + 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'), |
|
958 | 958 | 'DTT_order' => $default ? 'DTTNUM' : $dttrow, |
959 | 959 | 'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'), |
960 | - 'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
961 | - 'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
960 | + 'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
961 | + 'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
962 | 962 | ); |
963 | 963 | |
964 | - $template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
964 | + $template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
965 | 965 | |
966 | 966 | //allow filtering of template args at this point. |
967 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event ); |
|
967 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event); |
|
968 | 968 | |
969 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php'; |
|
970 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
969 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php'; |
|
970 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | |
974 | - protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) { |
|
974 | + protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) { |
|
975 | 975 | |
976 | 976 | $template_args = array( |
977 | 977 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
@@ -979,47 +979,47 @@ discard block |
||
979 | 979 | 'DTT_description' => $default ? '' : $dtt->description(), |
980 | 980 | 'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '', |
981 | 981 | 'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '', |
982 | - 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
982 | + 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
983 | 983 | 'DTT_ID' => $default ? '' : $dtt->ID() |
984 | 984 | ); |
985 | 985 | |
986 | 986 | //need to setup the list items (but only if this isnt' a default skeleton setup) |
987 | - if ( !$default ) { |
|
987 | + if ( ! $default) { |
|
988 | 988 | $tktrow = 1; |
989 | - foreach ( $all_tickets as $ticket ) { |
|
990 | - $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ); |
|
989 | + foreach ($all_tickets as $ticket) { |
|
990 | + $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default); |
|
991 | 991 | $tktrow++; |
992 | 992 | } |
993 | 993 | } |
994 | 994 | |
995 | 995 | //filter template args at this point |
996 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event ); |
|
996 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event); |
|
997 | 997 | |
998 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php'; |
|
999 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
998 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php'; |
|
999 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | |
1003 | 1003 | |
1004 | - protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) { |
|
1005 | - $tktid = !empty( $ticket ) ? $ticket->ID() : 0; |
|
1006 | - $dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1004 | + protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) { |
|
1005 | + $tktid = ! empty($ticket) ? $ticket->ID() : 0; |
|
1006 | + $dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1007 | 1007 | |
1008 | - $displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0; |
|
1008 | + $displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0; |
|
1009 | 1009 | $template_args = array( |
1010 | 1010 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
1011 | - 'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow, |
|
1011 | + 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
|
1012 | 1012 | 'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '', |
1013 | 1013 | 'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '', |
1014 | - 'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1015 | - 'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(), |
|
1014 | + 'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1015 | + 'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(), |
|
1016 | 1016 | ); |
1017 | 1017 | |
1018 | 1018 | //filter template args |
1019 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event ); |
|
1019 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event); |
|
1020 | 1020 | |
1021 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1022 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1021 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1022 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | |
@@ -1041,37 +1041,37 @@ discard block |
||
1041 | 1041 | * |
1042 | 1042 | * @return [type] [description] |
1043 | 1043 | */ |
1044 | - protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) { |
|
1044 | + protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) { |
|
1045 | 1045 | |
1046 | 1046 | //if $ticket is not an instance of EE_Ticket then force default to true. |
1047 | - $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1047 | + $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1048 | 1048 | |
1049 | - $prices = ! empty( $ticket ) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array(); |
|
1049 | + $prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array(); |
|
1050 | 1050 | |
1051 | 1051 | //if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on |
1052 | 1052 | //the object. This is done by not including any query_params. |
1053 | - if ( $ticket instanceof EE_Ticket && $ticket->is_default() && ( count( $prices ) === 1 || empty( $prices ) ) ) { |
|
1054 | - $prices = $ticket->get_many_related( 'Price' ); |
|
1053 | + if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) { |
|
1054 | + $prices = $ticket->get_many_related('Price'); |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | // check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket). This will future proof in case there is ever any behaviour change between what the primary_key defaults to. |
1058 | - $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE; |
|
1058 | + $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE; |
|
1059 | 1059 | |
1060 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1060 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1061 | 1061 | |
1062 | 1062 | $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal(); |
1063 | - $base_price = $default ? NULL : $ticket->base_price(); |
|
1063 | + $base_price = $default ? NULL : $ticket->base_price(); |
|
1064 | 1064 | $count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE); |
1065 | 1065 | |
1066 | 1066 | //breaking out complicated condition for ticket_status |
1067 | - if ( $default ) { |
|
1068 | - $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale; |
|
1067 | + if ($default) { |
|
1068 | + $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale; |
|
1069 | 1069 | } else { |
1070 | - $ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(); |
|
1070 | + $ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(); |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | //breaking out complicated condition for TKT_taxable |
1074 | - if ( $default ) { |
|
1074 | + if ($default) { |
|
1075 | 1075 | $TKT_taxable = ''; |
1076 | 1076 | } else { |
1077 | 1077 | $TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : ''; |
@@ -1086,19 +1086,19 @@ discard block |
||
1086 | 1086 | 'edit_tkt_expanded' => '', |
1087 | 1087 | 'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets', |
1088 | 1088 | 'TKT_name' => $default ? '' : $ticket->get('TKT_name'), |
1089 | - 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1090 | - 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1091 | - 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1089 | + 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1090 | + 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1091 | + 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1092 | 1092 | 'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE), |
1093 | 1093 | 'TKT_price_code' => EE_Registry::instance()->CFG->currency->code, |
1094 | 1094 | 'TKT_price_amount' => $default ? 0 : $ticket_subtotal, |
1095 | - 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'), |
|
1096 | - 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'), |
|
1097 | - 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'), |
|
1098 | - 'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ), |
|
1099 | - 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max','input'), |
|
1095 | + 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'), |
|
1096 | + 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'), |
|
1097 | + 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'), |
|
1098 | + 'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')), |
|
1099 | + 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'), |
|
1100 | 1100 | 'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'), |
1101 | - 'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ), |
|
1101 | + 'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))), |
|
1102 | 1102 | 'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'), |
1103 | 1103 | 'TKT_description' => $default ? '' : $ticket->get('TKT_description'), |
1104 | 1104 | 'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'), |
@@ -1107,99 +1107,99 @@ discard block |
||
1107 | 1107 | 'ticket_price_rows' => '', |
1108 | 1108 | 'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'), |
1109 | 1109 | 'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(), |
1110 | - 'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"', |
|
1111 | - 'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '', |
|
1110 | + 'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"', |
|
1111 | + 'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '', |
|
1112 | 1112 | 'total_price_rows' => count($prices) > 1 ? count($prices) : 1, |
1113 | 1113 | 'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '', |
1114 | 1114 | 'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts), |
1115 | 1115 | 'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts), |
1116 | - 'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ), |
|
1116 | + 'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)), |
|
1117 | 1117 | 'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'), |
1118 | 1118 | 'TKT_taxable' => $TKT_taxable, |
1119 | 1119 | 'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"', |
1120 | 1120 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1121 | - 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ), |
|
1121 | + 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE), |
|
1122 | 1122 | 'TKT_subtotal_amount' => $ticket_subtotal, |
1123 | - 'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ), |
|
1124 | - 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE, |
|
1123 | + 'tax_rows' => $this->_get_tax_rows($tktrow, $ticket), |
|
1124 | + 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE : FALSE, |
|
1125 | 1125 | 'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '', |
1126 | 1126 | 'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable', |
1127 | 1127 | 'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable' |
1128 | 1128 | ); |
1129 | 1129 | |
1130 | - $template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1130 | + $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1131 | 1131 | |
1132 | 1132 | //handle rows that should NOT be empty |
1133 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1133 | + if (empty($template_args['TKT_start_date'])) { |
|
1134 | 1134 | //if empty then the start date will be now. |
1135 | - $template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp')); |
|
1136 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1135 | + $template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp')); |
|
1136 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1139 | + if (empty($template_args['TKT_end_date'])) { |
|
1140 | 1140 | |
1141 | 1141 | //get the earliest datetime (if present); |
1142 | - $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1142 | + $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1143 | 1143 | |
1144 | - if ( !empty( $earliest_dtt ) ) { |
|
1145 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
1144 | + if ( ! empty($earliest_dtt)) { |
|
1145 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
1146 | 1146 | } else { |
1147 | 1147 | //default so let's just use what's been set for the default date-time which is 30 days from now. |
1148 | - $template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") ) ); |
|
1148 | + $template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y"))); |
|
1149 | 1149 | } |
1150 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1150 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | //generate ticket_datetime items |
1154 | - if ( ! $default ) { |
|
1154 | + if ( ! $default) { |
|
1155 | 1155 | $dttrow = 1; |
1156 | - foreach ( $all_dtts as $dtt ) { |
|
1157 | - $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ); |
|
1156 | + foreach ($all_dtts as $dtt) { |
|
1157 | + $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default); |
|
1158 | 1158 | $dttrow++; |
1159 | 1159 | } |
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | $prcrow = 1; |
1163 | - foreach ( $prices as $price ) { |
|
1164 | - if ( $price->is_base_price() ) { |
|
1163 | + foreach ($prices as $price) { |
|
1164 | + if ($price->is_base_price()) { |
|
1165 | 1165 | $prcrow++; |
1166 | 1166 | continue; |
1167 | 1167 | } |
1168 | - $show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1 ? FALSE : TRUE; |
|
1169 | - $show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE; |
|
1170 | - $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create ); |
|
1168 | + $show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE; |
|
1169 | + $show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE; |
|
1170 | + $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create); |
|
1171 | 1171 | $prcrow++; |
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | //filter $template_args |
1175 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event ); |
|
1175 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event); |
|
1176 | 1176 | |
1177 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php'; |
|
1178 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1177 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php'; |
|
1178 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | |
1182 | 1182 | |
1183 | 1183 | |
1184 | 1184 | |
1185 | - protected function _get_tax_rows( $tktrow, $ticket ) { |
|
1185 | + protected function _get_tax_rows($tktrow, $ticket) { |
|
1186 | 1186 | $tax_rows = ''; |
1187 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1187 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1188 | 1188 | $template_args = array(); |
1189 | - $taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1190 | - foreach ( $taxes as $tax ) { |
|
1191 | - $tax_added = $this->_get_tax_added( $tax, $ticket ); |
|
1189 | + $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1190 | + foreach ($taxes as $tax) { |
|
1191 | + $tax_added = $this->_get_tax_added($tax, $ticket); |
|
1192 | 1192 | $template_args = array( |
1193 | - 'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1193 | + 'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1194 | 1194 | 'tax_id' => $tax->ID(), |
1195 | 1195 | 'tkt_row' => $tktrow, |
1196 | 1196 | 'tax_label' => $tax->get('PRC_name'), |
1197 | 1197 | 'tax_added' => $tax_added, |
1198 | - 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ), |
|
1198 | + 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE), |
|
1199 | 1199 | 'tax_amount' => $tax->get('PRC_amount') |
1200 | 1200 | ); |
1201 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event ); |
|
1202 | - $tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1201 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event); |
|
1202 | + $tax_rows .= EEH_Template::display_template($template, $template_args, TRUE); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | |
@@ -1207,81 +1207,81 @@ discard block |
||
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | |
1210 | - protected function _get_tax_added( EE_Price $tax, $ticket ) { |
|
1211 | - $subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal(); |
|
1210 | + protected function _get_tax_added(EE_Price $tax, $ticket) { |
|
1211 | + $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal(); |
|
1212 | 1212 | return $subtotal * $tax->get('PRC_amount') / 100; |
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | |
1216 | 1216 | |
1217 | 1217 | |
1218 | - protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) { |
|
1219 | - $send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1218 | + protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) { |
|
1219 | + $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1220 | 1220 | $template_args = array( |
1221 | 1221 | 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
1222 | 1222 | 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
1223 | 1223 | 'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices', |
1224 | - 'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ), |
|
1224 | + 'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled), |
|
1225 | 1225 | 'PRC_ID' => $default && empty($price) ? 0 : $price->ID(), |
1226 | 1226 | 'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'), |
1227 | 1227 | 'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'), |
1228 | 1228 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1229 | 1229 | 'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"', |
1230 | - 'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1231 | - 'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1232 | - 'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ), |
|
1233 | - 'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1234 | - 'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ), |
|
1230 | + 'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1231 | + 'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1232 | + 'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''), |
|
1233 | + 'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1234 | + 'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'), |
|
1235 | 1235 | 'show_trash_icon' => $show_trash ? '' : ' style="display:none;"', |
1236 | 1236 | 'show_create_button' => $show_create ? '' : ' style="display:none;"', |
1237 | - 'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'), |
|
1238 | - 'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1237 | + 'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'), |
|
1238 | + 'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1239 | 1239 | ); |
1240 | 1240 | |
1241 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event ); |
|
1241 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event); |
|
1242 | 1242 | |
1243 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php'; |
|
1244 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1243 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php'; |
|
1244 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | |
1248 | - protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1249 | - if ( $price->is_base_price() ) { |
|
1250 | - return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ); |
|
1248 | + protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1249 | + if ($price->is_base_price()) { |
|
1250 | + return $this->_get_base_price_template($tktrow, $prcrow, $price, $default); |
|
1251 | 1251 | } else { |
1252 | - return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled ); |
|
1252 | + return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled); |
|
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | |
1258 | - protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) { |
|
1258 | + protected function _get_base_price_template($tktrow, $prcrow, $price, $default) { |
|
1259 | 1259 | $template_args = array( |
1260 | 1260 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1261 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1262 | - 'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'), |
|
1261 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1262 | + 'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'), |
|
1263 | 1263 | 'PRT_name' => __('Price', 'event_espresso'), |
1264 | 1264 | 'price_selected_operator' => '+', |
1265 | 1265 | 'price_selected_is_percent' => 0 |
1266 | 1266 | ); |
1267 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php'; |
|
1267 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php'; |
|
1268 | 1268 | |
1269 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event ); |
|
1269 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event); |
|
1270 | 1270 | |
1271 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1271 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | |
1275 | 1275 | |
1276 | - protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1277 | - $select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]'; |
|
1278 | - $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) ); |
|
1279 | - $price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php'; |
|
1280 | - $all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array(); |
|
1281 | - $selected_price_type_id = $default && empty( $price ) ? 0 : $price->type(); |
|
1276 | + protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1277 | + $select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]'; |
|
1278 | + $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3')))); |
|
1279 | + $price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php'; |
|
1280 | + $all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array(); |
|
1281 | + $selected_price_type_id = $default && empty($price) ? 0 : $price->type(); |
|
1282 | 1282 | $price_option_spans = ''; |
1283 | 1283 | //setup pricetypes for selector |
1284 | - foreach ( $price_types as $price_type ) { |
|
1284 | + foreach ($price_types as $price_type) { |
|
1285 | 1285 | $all_price_types[] = array( |
1286 | 1286 | 'id' => $price_type->ID(), |
1287 | 1287 | 'text' => $price_type->get('PRT_name'), |
@@ -1293,50 +1293,50 @@ discard block |
||
1293 | 1293 | 'PRT_operator' => $price_type->is_discount() ? '-' : '+', |
1294 | 1294 | 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0 |
1295 | 1295 | ); |
1296 | - $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE ); |
|
1296 | + $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1299 | + $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1300 | 1300 | $main_name = $select_name; |
1301 | - $select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name; |
|
1301 | + $select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name; |
|
1302 | 1302 | |
1303 | 1303 | $template_args = array( |
1304 | 1304 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1305 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1306 | - 'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ), |
|
1305 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1306 | + 'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'), |
|
1307 | 1307 | 'main_name' => $main_name, |
1308 | 1308 | 'selected_price_type_id' => $selected_price_type_id, |
1309 | 1309 | 'price_option_spans' => $price_option_spans, |
1310 | - 'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ), |
|
1311 | - 'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ), |
|
1310 | + 'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'), |
|
1311 | + 'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0), |
|
1312 | 1312 | 'disabled' => $disabled |
1313 | 1313 | ); |
1314 | 1314 | |
1315 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event ); |
|
1315 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event); |
|
1316 | 1316 | |
1317 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1317 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1318 | 1318 | |
1319 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1319 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | |
1323 | 1323 | |
1324 | - protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) { |
|
1325 | - $dttid = !empty($dtt) ? $dtt->ID() : 0; |
|
1326 | - $displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1327 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1324 | + protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) { |
|
1325 | + $dttid = ! empty($dtt) ? $dtt->ID() : 0; |
|
1326 | + $displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1327 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1328 | 1328 | $template_args = array( |
1329 | - 'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow, |
|
1329 | + 'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow, |
|
1330 | 1330 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1331 | - 'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '', |
|
1332 | - 'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '', |
|
1333 | - 'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ), |
|
1331 | + 'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '', |
|
1332 | + 'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '', |
|
1333 | + 'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE), |
|
1334 | 1334 | 'tkt_status_class' => '', |
1335 | 1335 | ); |
1336 | 1336 | |
1337 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event ); |
|
1338 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1339 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1337 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event); |
|
1338 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1339 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1340 | 1340 | } |
1341 | 1341 | |
1342 | 1342 | |
@@ -1344,53 +1344,53 @@ discard block |
||
1344 | 1344 | protected function _get_ticket_js_structure($all_dtts, $all_tickets) { |
1345 | 1345 | $template_args = array( |
1346 | 1346 | 'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts), |
1347 | - 'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE), |
|
1348 | - 'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ), |
|
1347 | + 'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE), |
|
1348 | + 'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL), |
|
1349 | 1349 | 'default_price_rows' => '', |
1350 | 1350 | 'default_base_price_amount' => 0, |
1351 | 1351 | 'default_base_price_name' => '', |
1352 | 1352 | 'default_base_price_description' => '', |
1353 | - 'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ), |
|
1354 | - 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ), |
|
1353 | + 'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE), |
|
1354 | + 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE), |
|
1355 | 1355 | 'existing_available_datetime_tickets_list' => '', |
1356 | 1356 | 'existing_available_ticket_datetimes_list' => '', |
1357 | - 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ), |
|
1358 | - 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ) |
|
1357 | + 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE), |
|
1358 | + 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE) |
|
1359 | 1359 | ); |
1360 | 1360 | |
1361 | 1361 | $tktrow = 1; |
1362 | - foreach ( $all_tickets as $ticket ) { |
|
1363 | - $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE ); |
|
1362 | + foreach ($all_tickets as $ticket) { |
|
1363 | + $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE); |
|
1364 | 1364 | $tktrow++; |
1365 | 1365 | } |
1366 | 1366 | |
1367 | 1367 | |
1368 | 1368 | $dttrow = 1; |
1369 | - foreach ( $all_dtts as $dtt ) { |
|
1370 | - $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE ); |
|
1369 | + foreach ($all_dtts as $dtt) { |
|
1370 | + $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE); |
|
1371 | 1371 | $dttrow++; |
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | $default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices(); |
1375 | 1375 | $prcrow = 1; |
1376 | - foreach ( $default_prices as $price ) { |
|
1377 | - if ( $price->is_base_price() ) { |
|
1376 | + foreach ($default_prices as $price) { |
|
1377 | + if ($price->is_base_price()) { |
|
1378 | 1378 | $template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float'); |
1379 | 1379 | $template_args['default_base_price_name'] = $price->get('PRC_name'); |
1380 | 1380 | $template_args['default_base_price_description'] = $price->get('PRC_desc'); |
1381 | 1381 | $prcrow++; |
1382 | 1382 | continue; |
1383 | 1383 | } |
1384 | - $show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1 ? FALSE : TRUE; |
|
1385 | - $show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE; |
|
1386 | - $template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create ); |
|
1384 | + $show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE; |
|
1385 | + $show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE; |
|
1386 | + $template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create); |
|
1387 | 1387 | $prcrow++; |
1388 | 1388 | } |
1389 | 1389 | |
1390 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event ); |
|
1390 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event); |
|
1391 | 1391 | |
1392 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1393 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1392 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1393 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return EED_Recaptcha |
44 | 44 | */ |
45 | 45 | public static function instance() { |
46 | - return parent::get_instance( __CLASS__ ); |
|
46 | + return parent::get_instance(__CLASS__); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -59,32 +59,32 @@ discard block |
||
59 | 59 | if ( |
60 | 60 | EE_Registry::instance()->CFG->registration->use_captcha |
61 | 61 | && ! ( |
62 | - EE_Registry::instance()->REQ->get( 'step', '' ) === 'payment_options' |
|
63 | - && (boolean) EE_Registry::instance()->REQ->get( 'revisit', false ) === true |
|
62 | + EE_Registry::instance()->REQ->get('step', '') === 'payment_options' |
|
63 | + && (boolean) EE_Registry::instance()->REQ->get('revisit', false) === true |
|
64 | 64 | ) |
65 | 65 | ) { |
66 | 66 | EED_Recaptcha::set_definitions(); |
67 | 67 | EED_Recaptcha::enqueue_styles_and_scripts(); |
68 | - add_action( 'wp', array( 'EED_Recaptcha', 'set_late_hooks' ), 1, 0 ); |
|
68 | + add_action('wp', array('EED_Recaptcha', 'set_late_hooks'), 1, 0); |
|
69 | 69 | add_action( |
70 | 70 | 'AHEE__before_spco_whats_next_buttons', |
71 | - array( 'EED_Recaptcha', 'display_recaptcha' ), 10, 0 |
|
71 | + array('EED_Recaptcha', 'display_recaptcha'), 10, 0 |
|
72 | 72 | ); |
73 | 73 | add_filter( |
74 | 74 | 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
75 | - array( 'EED_Recaptcha', 'not_a_robot' ), 10 |
|
75 | + array('EED_Recaptcha', 'not_a_robot'), 10 |
|
76 | 76 | ); |
77 | 77 | add_filter( |
78 | 78 | 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
79 | - array( 'EED_Recaptcha', 'not_a_robot' ), 10 |
|
79 | + array('EED_Recaptcha', 'not_a_robot'), 10 |
|
80 | 80 | ); |
81 | 81 | add_filter( |
82 | 82 | 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
83 | - array( 'EED_Recaptcha', 'recaptcha_response' ), 10, 1 |
|
83 | + array('EED_Recaptcha', 'recaptcha_response'), 10, 1 |
|
84 | 84 | ); |
85 | 85 | add_filter( |
86 | 86 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
87 | - array( 'EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method' ), 10, 1 |
|
87 | + array('EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method'), 10, 1 |
|
88 | 88 | ); |
89 | 89 | } |
90 | 90 | } |
@@ -103,18 +103,18 @@ discard block |
||
103 | 103 | if ( |
104 | 104 | EE_Registry::instance()->CFG->registration->use_captcha |
105 | 105 | && ! ( |
106 | - EE_Registry::instance()->REQ->get( 'step', '' ) === 'payment_options' |
|
107 | - && (boolean) EE_Registry::instance()->REQ->get( 'revisit', false ) === true |
|
106 | + EE_Registry::instance()->REQ->get('step', '') === 'payment_options' |
|
107 | + && (boolean) EE_Registry::instance()->REQ->get('revisit', false) === true |
|
108 | 108 | ) |
109 | 109 | ) { |
110 | 110 | EED_Recaptcha::enqueue_styles_and_scripts(); |
111 | - add_filter( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', array( 'EED_Recaptcha', 'not_a_robot' ), 10 ); |
|
112 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', array( 'EED_Recaptcha', 'not_a_robot' ), 10 ); |
|
113 | - add_filter( 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', array( 'EED_Recaptcha', 'recaptcha_response' ), 10, 1 ); |
|
111 | + add_filter('FHEE__EED_Single_Page_Checkout__init___continue_reg', array('EED_Recaptcha', 'not_a_robot'), 10); |
|
112 | + add_filter('FHEE__EE_SPCO_Reg_Step__set_completed___completed', array('EED_Recaptcha', 'not_a_robot'), 10); |
|
113 | + add_filter('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', array('EED_Recaptcha', 'recaptcha_response'), 10, 1); |
|
114 | 114 | } |
115 | 115 | // admin settings |
116 | - add_action( 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', array( 'EED_Recaptcha', 'admin_settings' ), 10, 1 ); |
|
117 | - add_filter( 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', array( 'EED_Recaptcha', 'update_admin_settings' ), 10, 1 ); |
|
116 | + add_action('AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', array('EED_Recaptcha', 'admin_settings'), 10, 1); |
|
117 | + add_filter('FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', array('EED_Recaptcha', 'update_admin_settings'), 10, 1); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | * @return void |
127 | 127 | */ |
128 | 128 | public static function set_definitions() { |
129 | - if ( is_user_logged_in() ) { |
|
129 | + if (is_user_logged_in()) { |
|
130 | 130 | EED_Recaptcha::$_not_a_robot = true; |
131 | 131 | } |
132 | - define( 'RECAPTCHA_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
133 | - define( 'RECAPTCHA_BASE_URL', plugin_dir_url( __FILE__ )); |
|
132 | + define('RECAPTCHA_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
133 | + define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | public static function set_late_hooks() { |
145 | 145 | add_filter( |
146 | 146 | 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
147 | - array( 'EED_Recaptcha', 'not_a_robot' ) |
|
147 | + array('EED_Recaptcha', 'not_a_robot') |
|
148 | 148 | ); |
149 | 149 | } |
150 | 150 | |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | * @return void |
158 | 158 | */ |
159 | 159 | public static function enqueue_styles_and_scripts() { |
160 | - wp_register_script( 'espresso_recaptcha', RECAPTCHA_BASE_URL . 'scripts' . DS . 'espresso_recaptcha.js', array( 'single_page_checkout' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
161 | - wp_register_script( 'google_recaptcha', 'https://www.google.com/recaptcha/api.js?hl=' . EE_Registry::instance()->CFG->registration->recaptcha_language, array( 'espresso_recaptcha' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
162 | - EE_Registry::$i18n_js_strings['no_SPCO_error'] = __( 'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
163 | - EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __( 'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
164 | - EE_Registry::$i18n_js_strings['recaptcha_fail'] = __( 'Please complete the anti-spam test before proceeding.', 'event_espresso' ); |
|
160 | + wp_register_script('espresso_recaptcha', RECAPTCHA_BASE_URL.'scripts'.DS.'espresso_recaptcha.js', array('single_page_checkout'), EVENT_ESPRESSO_VERSION, TRUE); |
|
161 | + wp_register_script('google_recaptcha', 'https://www.google.com/recaptcha/api.js?hl='.EE_Registry::instance()->CFG->registration->recaptcha_language, array('espresso_recaptcha'), EVENT_ESPRESSO_VERSION, TRUE); |
|
162 | + EE_Registry::$i18n_js_strings['no_SPCO_error'] = __('It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
163 | + EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __('There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
164 | + EE_Registry::$i18n_js_strings['recaptcha_fail'] = __('Please complete the anti-spam test before proceeding.', 'event_espresso'); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @access public |
173 | 173 | * @param \WP $WP |
174 | 174 | */ |
175 | - public function run( $WP ) { |
|
175 | + public function run($WP) { |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -182,8 +182,7 @@ discard block |
||
182 | 182 | * @return boolean |
183 | 183 | */ |
184 | 184 | public static function not_a_robot() { |
185 | - $not_a_robot = is_bool( EED_Recaptcha::$_not_a_robot ) ? EED_Recaptcha::$_not_a_robot : |
|
186 | - EED_Recaptcha::recaptcha_passed(); |
|
185 | + $not_a_robot = is_bool(EED_Recaptcha::$_not_a_robot) ? EED_Recaptcha::$_not_a_robot : EED_Recaptcha::recaptcha_passed(); |
|
187 | 186 | return $not_a_robot; |
188 | 187 | } |
189 | 188 | |
@@ -199,22 +198,22 @@ discard block |
||
199 | 198 | */ |
200 | 199 | public static function display_recaptcha() { |
201 | 200 | // logged in means you have already passed a turing test of sorts |
202 | - if ( is_user_logged_in() ) { |
|
201 | + if (is_user_logged_in()) { |
|
203 | 202 | return; |
204 | 203 | } |
205 | 204 | // don't display if not using recaptcha or user is logged in |
206 | - if ( EE_Registry::instance()->CFG->registration->use_captcha ) { |
|
205 | + if (EE_Registry::instance()->CFG->registration->use_captcha) { |
|
207 | 206 | // only display if they have NOT passed the test yet |
208 | - if ( ! EED_Recaptcha::$_not_a_robot ) { |
|
207 | + if ( ! EED_Recaptcha::$_not_a_robot) { |
|
209 | 208 | EEH_Template::display_template( |
210 | - RECAPTCHA_BASE_PATH . DS . 'templates' . DS . 'recaptcha.template.php', |
|
209 | + RECAPTCHA_BASE_PATH.DS.'templates'.DS.'recaptcha.template.php', |
|
211 | 210 | array( |
212 | 211 | 'recaptcha_publickey' => EE_Registry::instance()->CFG->registration->recaptcha_publickey, |
213 | 212 | 'recaptcha_theme' => EE_Registry::instance()->CFG->registration->recaptcha_theme, |
214 | 213 | 'recaptcha_type' => EE_Registry::instance()->CFG->registration->recaptcha_type |
215 | 214 | ) |
216 | 215 | ); |
217 | - wp_enqueue_script( 'google_recaptcha' ); |
|
216 | + wp_enqueue_script('google_recaptcha'); |
|
218 | 217 | } |
219 | 218 | } |
220 | 219 | } |
@@ -245,17 +244,17 @@ discard block |
||
245 | 244 | */ |
246 | 245 | public static function recaptcha_passed() { |
247 | 246 | // logged in means you have already passed a turing test of sorts |
248 | - if ( is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha() ) { |
|
247 | + if (is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha()) { |
|
249 | 248 | return TRUE; |
250 | 249 | } |
251 | 250 | // was test already passed? |
252 | - $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data( 'recaptcha_passed' ); |
|
253 | - $recaptcha_passed = filter_var( $recaptcha_passed, FILTER_VALIDATE_BOOLEAN ); |
|
251 | + $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data('recaptcha_passed'); |
|
252 | + $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN); |
|
254 | 253 | // verify recaptcha |
255 | 254 | EED_Recaptcha::_get_recaptcha_response(); |
256 | - if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response ) { |
|
255 | + if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
257 | 256 | $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
258 | - EE_Registry::instance()->SSN->set_session_data( array( 'recaptcha_passed' => $recaptcha_passed )); |
|
257 | + EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed)); |
|
259 | 258 | EE_Registry::instance()->SSN->update(); |
260 | 259 | } |
261 | 260 | EED_Recaptcha::$_not_a_robot = $recaptcha_passed; |
@@ -271,8 +270,8 @@ discard block |
||
271 | 270 | * @param array $recaptcha_response |
272 | 271 | * @return boolean |
273 | 272 | */ |
274 | - public static function recaptcha_response( $recaptcha_response = array() ) { |
|
275 | - if ( EED_Recaptcha::_bypass_recaptcha() ) { |
|
273 | + public static function recaptcha_response($recaptcha_response = array()) { |
|
274 | + if (EED_Recaptcha::_bypass_recaptcha()) { |
|
276 | 275 | $recaptcha_response['bypass_recaptcha'] = TRUE; |
277 | 276 | $recaptcha_response['recaptcha_passed'] = TRUE; |
278 | 277 | } else { |
@@ -292,16 +291,16 @@ discard block |
||
292 | 291 | */ |
293 | 292 | private static function _bypass_recaptcha() { |
294 | 293 | // an array of key value pairs that must match exactly with the incoming request, in order to bypass recaptcha for the current request ONLY |
295 | - $bypass_request_params_array = apply_filters( 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array() ); |
|
294 | + $bypass_request_params_array = apply_filters('FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array()); |
|
296 | 295 | // does $bypass_request_params_array have any values ? |
297 | - if ( empty( $bypass_request_params_array )) { |
|
296 | + if (empty($bypass_request_params_array)) { |
|
298 | 297 | return FALSE; |
299 | 298 | } |
300 | 299 | // initially set bypass to TRUE |
301 | 300 | $bypass_recaptcha = TRUE; |
302 | - foreach ( $bypass_request_params_array as $key => $value ) { |
|
301 | + foreach ($bypass_request_params_array as $key => $value) { |
|
303 | 302 | // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, otherwise carry over it's value. This way, one missed setting results in no bypass |
304 | - $bypass_recaptcha = isset( $_REQUEST[ $key ] ) && $_REQUEST[ $key ] === $value ? $bypass_recaptcha : FALSE; |
|
303 | + $bypass_recaptcha = isset($_REQUEST[$key]) && $_REQUEST[$key] === $value ? $bypass_recaptcha : FALSE; |
|
305 | 304 | } |
306 | 305 | return $bypass_recaptcha; |
307 | 306 | } |
@@ -316,7 +315,7 @@ discard block |
||
316 | 315 | * @return boolean |
317 | 316 | */ |
318 | 317 | private static function _get_recaptcha_response() { |
319 | - EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get( 'g-recaptcha-response', false ); |
|
318 | + EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get('g-recaptcha-response', false); |
|
320 | 319 | } |
321 | 320 | |
322 | 321 | |
@@ -330,26 +329,26 @@ discard block |
||
330 | 329 | */ |
331 | 330 | private static function _process_recaptcha_response() { |
332 | 331 | // verify library is loaded |
333 | - if ( ! class_exists( '\\ReCaptcha\\ReCaptcha' )) { |
|
334 | - require_once( RECAPTCHA_BASE_PATH . DS . 'autoload.php' ); |
|
332 | + if ( ! class_exists('\\ReCaptcha\\ReCaptcha')) { |
|
333 | + require_once(RECAPTCHA_BASE_PATH.DS.'autoload.php'); |
|
335 | 334 | } |
336 | 335 | // The response from reCAPTCHA |
337 | 336 | EED_Recaptcha::_get_recaptcha_response(); |
338 | 337 | $recaptcha_response = EED_Recaptcha::$_recaptcha_response; |
339 | 338 | // Was there a reCAPTCHA response? |
340 | - if ( $recaptcha_response ) { |
|
339 | + if ($recaptcha_response) { |
|
341 | 340 | // if allow_url_fopen is Off, then set a different request method |
342 | - $request_method = ! ini_get( 'allow_url_fopen' ) ? new \ReCaptcha\RequestMethod\SocketPost() : null; |
|
341 | + $request_method = ! ini_get('allow_url_fopen') ? new \ReCaptcha\RequestMethod\SocketPost() : null; |
|
343 | 342 | $recaptcha = new \ReCaptcha\ReCaptcha( |
344 | 343 | EE_Registry::instance()->CFG->registration->recaptcha_privatekey, |
345 | 344 | $request_method |
346 | 345 | ); |
347 | 346 | $recaptcha_response = $recaptcha->verify( |
348 | 347 | EED_Recaptcha::$_recaptcha_response, |
349 | - $_SERVER[ 'REMOTE_ADDR' ] |
|
348 | + $_SERVER['REMOTE_ADDR'] |
|
350 | 349 | ); |
351 | 350 | } |
352 | - if ( $recaptcha_response instanceof \ReCaptcha\Response && $recaptcha_response->isSuccess() ) { |
|
351 | + if ($recaptcha_response instanceof \ReCaptcha\Response && $recaptcha_response->isSuccess()) { |
|
353 | 352 | return TRUE; |
354 | 353 | } |
355 | 354 | // sorry... it appears you can't don't know what soup or hamburgers are !!! |
@@ -393,12 +392,12 @@ discard block |
||
393 | 392 | 'subsections' => apply_filters( |
394 | 393 | 'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections', |
395 | 394 | array( |
396 | - 'main_settings_hdr' => new EE_Form_Section_HTML( EEH_HTML::h2( __( 'reCAPTCHA Anti-spam Settings', 'event_espresso' ) . EEH_Template::get_help_tab_link( 'recaptcha_info' ))), |
|
395 | + 'main_settings_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(__('reCAPTCHA Anti-spam Settings', 'event_espresso').EEH_Template::get_help_tab_link('recaptcha_info'))), |
|
397 | 396 | 'main_settings' => EED_Recaptcha::_recaptcha_main_settings(), |
398 | - 'appearance_settings_hdr' => new EE_Form_Section_HTML( EEH_HTML::h2( __( 'reCAPTCHA Appearance', 'event_espresso' ) )), |
|
397 | + 'appearance_settings_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(__('reCAPTCHA Appearance', 'event_espresso'))), |
|
399 | 398 | 'appearance_settings' => EED_Recaptcha::_recaptcha_appearance_settings(), |
400 | 399 | // 'recaptcha_example' => new EE_Form_Section_HTML( EED_Recaptcha::display_recaptcha() ), |
401 | - 'required_fields_note' => new EE_Form_Section_HTML( EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' )) |
|
400 | + 'required_fields_note' => new EE_Form_Section_HTML(EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')) |
|
402 | 401 | ) |
403 | 402 | ) |
404 | 403 | ) |
@@ -425,28 +424,28 @@ discard block |
||
425 | 424 | array( |
426 | 425 | 'use_captcha' => new EE_Yes_No_Input( |
427 | 426 | array( |
428 | - 'html_label_text' => __( 'Use reCAPTCHA', 'event_espresso' ), |
|
427 | + 'html_label_text' => __('Use reCAPTCHA', 'event_espresso'), |
|
429 | 428 | 'html_help_text' => sprintf( |
430 | - __( 'reCAPTCHA is a free service that protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.', 'event_espresso' ), |
|
429 | + __('reCAPTCHA is a free service that protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.', 'event_espresso'), |
|
431 | 430 | '<a href="https://www.google.com/recaptcha/intro/index.html">', |
432 | 431 | '</a>' |
433 | 432 | ), |
434 | - 'default' => isset( EE_Registry::instance()->CFG->registration->use_captcha ) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE, |
|
433 | + 'default' => isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE, |
|
435 | 434 | 'display_html_label_text' => FALSE |
436 | 435 | ) |
437 | 436 | ), |
438 | 437 | 'recaptcha_publickey' => new EE_Text_Input( |
439 | 438 | array( |
440 | - 'html_label_text' => __( 'Site Key', 'event_espresso' ), |
|
441 | - 'html_help_text' => __( 'The site key is used to display the widget on your site.', 'event_espresso' ), |
|
442 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) : '' |
|
439 | + 'html_label_text' => __('Site Key', 'event_espresso'), |
|
440 | + 'html_help_text' => __('The site key is used to display the widget on your site.', 'event_espresso'), |
|
441 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_publickey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_publickey) : '' |
|
443 | 442 | ) |
444 | 443 | ), |
445 | 444 | 'recaptcha_privatekey' => new EE_Text_Input( |
446 | 445 | array( |
447 | - 'html_label_text' => __( 'Secret Key', 'event_espresso' ), |
|
448 | - 'html_help_text' => __( 'The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.', 'event_espresso' ), |
|
449 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) : '' |
|
446 | + 'html_label_text' => __('Secret Key', 'event_espresso'), |
|
447 | + 'html_help_text' => __('The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.', 'event_espresso'), |
|
448 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) : '' |
|
450 | 449 | ) |
451 | 450 | ) |
452 | 451 | ) |
@@ -478,81 +477,81 @@ discard block |
||
478 | 477 | array( |
479 | 478 | 'recaptcha_theme' => new EE_Radio_Button_Input( |
480 | 479 | array( |
481 | - 'light' => __( 'Light', 'event_espresso' ), |
|
482 | - 'dark' => __( 'Dark', 'event_espresso' ) |
|
480 | + 'light' => __('Light', 'event_espresso'), |
|
481 | + 'dark' => __('Dark', 'event_espresso') |
|
483 | 482 | ), |
484 | 483 | array( |
485 | - 'html_label_text' => __( 'Theme', 'event_espresso' ), |
|
486 | - 'html_help_text' => __( 'The color theme of the widget.', 'event_espresso' ), |
|
487 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_theme ) ? EE_Registry::instance()->CFG->registration->recaptcha_theme : 'light', |
|
484 | + 'html_label_text' => __('Theme', 'event_espresso'), |
|
485 | + 'html_help_text' => __('The color theme of the widget.', 'event_espresso'), |
|
486 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_theme) ? EE_Registry::instance()->CFG->registration->recaptcha_theme : 'light', |
|
488 | 487 | 'display_html_label_text' => FALSE |
489 | 488 | ) |
490 | 489 | ), |
491 | 490 | 'recaptcha_type' => new EE_Radio_Button_Input( |
492 | 491 | array( |
493 | - 'image' => __( 'Image', 'event_espresso' ), |
|
494 | - 'audio' => __( 'Audio', 'event_espresso' ) |
|
492 | + 'image' => __('Image', 'event_espresso'), |
|
493 | + 'audio' => __('Audio', 'event_espresso') |
|
495 | 494 | ), |
496 | 495 | array( |
497 | - 'html_label_text' => __( 'Type', 'event_espresso' ), |
|
498 | - 'html_help_text' => __( 'The type of CAPTCHA to serve.', 'event_espresso' ), |
|
499 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_type ) ? EE_Registry::instance()->CFG->registration->recaptcha_type : 'image', |
|
496 | + 'html_label_text' => __('Type', 'event_espresso'), |
|
497 | + 'html_help_text' => __('The type of CAPTCHA to serve.', 'event_espresso'), |
|
498 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_type) ? EE_Registry::instance()->CFG->registration->recaptcha_type : 'image', |
|
500 | 499 | 'display_html_label_text' =>FALSE |
501 | 500 | ) |
502 | 501 | ), |
503 | 502 | 'recaptcha_language' => new EE_Select_Input( |
504 | 503 | array( |
505 | - 'ar' => __( 'Arabic', 'event_espresso' ), |
|
506 | - 'bg' => __( 'Bulgarian', 'event_espresso' ), |
|
507 | - 'ca' => __( 'Catalan', 'event_espresso' ), |
|
508 | - 'zh-CN' => __( 'Chinese (Simplified)', 'event_espresso' ), |
|
509 | - 'zh-TW' => __( 'Chinese (Traditional) ', 'event_espresso' ), |
|
510 | - 'hr' => __( 'Croatian', 'event_espresso' ), |
|
511 | - 'cs' => __( 'Czech', 'event_espresso' ), |
|
512 | - 'da' => __( 'Danish', 'event_espresso' ), |
|
513 | - 'nl' => __( 'Dutch', 'event_espresso' ), |
|
514 | - 'en-GB' => __( 'English (UK)', 'event_espresso' ), |
|
515 | - 'en' => __( 'English (US)', 'event_espresso' ), |
|
516 | - 'fil' => __( 'Filipino', 'event_espresso' ), |
|
517 | - 'fi' => __( 'Finnish', 'event_espresso' ), |
|
518 | - 'fr' => __( 'French', 'event_espresso' ), |
|
519 | - 'fr-CA' => __( 'French (Canadian)', 'event_espresso' ), |
|
520 | - 'de' => __( 'German', 'event_espresso' ), |
|
521 | - 'de-AT' => __( 'German (Austria)', 'event_espresso' ), |
|
522 | - 'de-CH' => __( 'German (Switzerland)', 'event_espresso' ), |
|
523 | - 'el' => __( 'Greek', 'event_espresso' ), |
|
524 | - 'iw' => __( 'Hebrew', 'event_espresso' ), |
|
525 | - 'hi' => __( 'Hindi', 'event_espresso' ), |
|
526 | - 'hu' => __( 'Hungarian', 'event_espresso' ), |
|
527 | - 'id' => __( 'Indonesian', 'event_espresso' ), |
|
528 | - 'it' => __( 'Italian', 'event_espresso' ), |
|
529 | - 'ja' => __( 'Japanese', 'event_espresso' ), |
|
530 | - 'ko' => __( 'Korean', 'event_espresso' ), |
|
531 | - 'lv' => __( 'Latvian', 'event_espresso' ), |
|
532 | - 'lt' => __( 'Lithuanian', 'event_espresso' ), |
|
533 | - 'no' => __( 'Norwegian', 'event_espresso' ), |
|
534 | - 'fa' => __( 'Persian', 'event_espresso' ), |
|
535 | - 'pl' => __( 'Polish', 'event_espresso' ), |
|
536 | - 'pt' => __( 'Portuguese', 'event_espresso' ), |
|
537 | - 'pt-BR' => __( 'Portuguese (Brazil)', 'event_espresso' ), |
|
538 | - 'pt-PT' => __( 'Portuguese (Portugal)', 'event_espresso' ), |
|
539 | - 'ro' => __( 'Romanian', 'event_espresso' ), |
|
540 | - 'ru' => __( 'Russian', 'event_espresso' ), |
|
541 | - 'sr' => __( 'Serbian', 'event_espresso' ), |
|
542 | - 'sk' => __( 'Slovak', 'event_espresso' ), |
|
543 | - 'sl' => __( 'Slovenian', 'event_espresso' ), |
|
544 | - 'es' => __( 'Spanish', 'event_espresso' ), |
|
545 | - 'es-419' => __( 'Spanish (Latin America)', 'event_espresso' ), |
|
546 | - 'sv' => __( 'Swedish', 'event_espresso' ), |
|
547 | - 'th' => __( 'Thai', 'event_espresso' ), |
|
548 | - 'tr' => __( 'Turkish', 'event_espresso' ), |
|
549 | - 'uk' => __( 'Ukrainian', 'event_espresso' ), |
|
550 | - 'vi' => __( 'Vietnamese', 'event_espresso') |
|
504 | + 'ar' => __('Arabic', 'event_espresso'), |
|
505 | + 'bg' => __('Bulgarian', 'event_espresso'), |
|
506 | + 'ca' => __('Catalan', 'event_espresso'), |
|
507 | + 'zh-CN' => __('Chinese (Simplified)', 'event_espresso'), |
|
508 | + 'zh-TW' => __('Chinese (Traditional) ', 'event_espresso'), |
|
509 | + 'hr' => __('Croatian', 'event_espresso'), |
|
510 | + 'cs' => __('Czech', 'event_espresso'), |
|
511 | + 'da' => __('Danish', 'event_espresso'), |
|
512 | + 'nl' => __('Dutch', 'event_espresso'), |
|
513 | + 'en-GB' => __('English (UK)', 'event_espresso'), |
|
514 | + 'en' => __('English (US)', 'event_espresso'), |
|
515 | + 'fil' => __('Filipino', 'event_espresso'), |
|
516 | + 'fi' => __('Finnish', 'event_espresso'), |
|
517 | + 'fr' => __('French', 'event_espresso'), |
|
518 | + 'fr-CA' => __('French (Canadian)', 'event_espresso'), |
|
519 | + 'de' => __('German', 'event_espresso'), |
|
520 | + 'de-AT' => __('German (Austria)', 'event_espresso'), |
|
521 | + 'de-CH' => __('German (Switzerland)', 'event_espresso'), |
|
522 | + 'el' => __('Greek', 'event_espresso'), |
|
523 | + 'iw' => __('Hebrew', 'event_espresso'), |
|
524 | + 'hi' => __('Hindi', 'event_espresso'), |
|
525 | + 'hu' => __('Hungarian', 'event_espresso'), |
|
526 | + 'id' => __('Indonesian', 'event_espresso'), |
|
527 | + 'it' => __('Italian', 'event_espresso'), |
|
528 | + 'ja' => __('Japanese', 'event_espresso'), |
|
529 | + 'ko' => __('Korean', 'event_espresso'), |
|
530 | + 'lv' => __('Latvian', 'event_espresso'), |
|
531 | + 'lt' => __('Lithuanian', 'event_espresso'), |
|
532 | + 'no' => __('Norwegian', 'event_espresso'), |
|
533 | + 'fa' => __('Persian', 'event_espresso'), |
|
534 | + 'pl' => __('Polish', 'event_espresso'), |
|
535 | + 'pt' => __('Portuguese', 'event_espresso'), |
|
536 | + 'pt-BR' => __('Portuguese (Brazil)', 'event_espresso'), |
|
537 | + 'pt-PT' => __('Portuguese (Portugal)', 'event_espresso'), |
|
538 | + 'ro' => __('Romanian', 'event_espresso'), |
|
539 | + 'ru' => __('Russian', 'event_espresso'), |
|
540 | + 'sr' => __('Serbian', 'event_espresso'), |
|
541 | + 'sk' => __('Slovak', 'event_espresso'), |
|
542 | + 'sl' => __('Slovenian', 'event_espresso'), |
|
543 | + 'es' => __('Spanish', 'event_espresso'), |
|
544 | + 'es-419' => __('Spanish (Latin America)', 'event_espresso'), |
|
545 | + 'sv' => __('Swedish', 'event_espresso'), |
|
546 | + 'th' => __('Thai', 'event_espresso'), |
|
547 | + 'tr' => __('Turkish', 'event_espresso'), |
|
548 | + 'uk' => __('Ukrainian', 'event_espresso'), |
|
549 | + 'vi' => __('Vietnamese', 'event_espresso') |
|
551 | 550 | ), |
552 | 551 | array( |
553 | - 'html_label_text' => __( 'Language', 'event_espresso' ), |
|
554 | - 'html_help_text' => __( 'Forces the widget to render in a specific language.', 'event_espresso' ), |
|
555 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_language ) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en' |
|
552 | + 'html_label_text' => __('Language', 'event_espresso'), |
|
553 | + 'html_help_text' => __('Forces the widget to render in a specific language.', 'event_espresso'), |
|
554 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_language) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en' |
|
556 | 555 | ) |
557 | 556 | ) |
558 | 557 | ) |
@@ -600,25 +599,25 @@ discard block |
||
600 | 599 | * @param EE_Registration_Config $EE_Registration_Config |
601 | 600 | * @return array |
602 | 601 | */ |
603 | - public static function update_admin_settings( EE_Registration_Config $EE_Registration_Config ) { |
|
602 | + public static function update_admin_settings(EE_Registration_Config $EE_Registration_Config) { |
|
604 | 603 | try { |
605 | 604 | $recaptcha_settings_form = EED_Recaptcha::_recaptcha_settings_form(); |
606 | 605 | // if not displaying a form, then check for form submission |
607 | - if ( $recaptcha_settings_form->was_submitted() ) { |
|
606 | + if ($recaptcha_settings_form->was_submitted()) { |
|
608 | 607 | // capture form data |
609 | 608 | $recaptcha_settings_form->receive_form_submission(); |
610 | 609 | // validate form data |
611 | - if ( $recaptcha_settings_form->is_valid() ) { |
|
610 | + if ($recaptcha_settings_form->is_valid()) { |
|
612 | 611 | // grab validated data from form |
613 | 612 | $valid_data = $recaptcha_settings_form->valid_data(); |
614 | 613 | // user proofing recaptcha: If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message. |
615 | 614 | if ( |
616 | - apply_filters( 'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys', TRUE, $EE_Registration_Config ) |
|
615 | + apply_filters('FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys', TRUE, $EE_Registration_Config) |
|
617 | 616 | && $valid_data['main_settings']['use_captcha'] |
618 | - && ( ! $EE_Registration_Config->use_captcha && ( empty( $valid_data['main_settings']['recaptcha_publickey'] ) || empty( $valid_data['main_settings']['recaptcha_privatekey'] ))) |
|
617 | + && ( ! $EE_Registration_Config->use_captcha && (empty($valid_data['main_settings']['recaptcha_publickey']) || empty($valid_data['main_settings']['recaptcha_privatekey']))) |
|
619 | 618 | ) { |
620 | 619 | $valid_data['main_settings']['use_captcha'] = FALSE; |
621 | - EE_Error::add_error( __('The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
620 | + EE_Error::add_error(__('The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
622 | 621 | } |
623 | 622 | $EE_Registration_Config->use_captcha = $valid_data['main_settings']['use_captcha']; |
624 | 623 | $EE_Registration_Config->recaptcha_publickey = $valid_data['main_settings']['recaptcha_publickey']; |
@@ -627,12 +626,12 @@ discard block |
||
627 | 626 | $EE_Registration_Config->recaptcha_theme = $valid_data['appearance_settings']['recaptcha_theme']; |
628 | 627 | $EE_Registration_Config->recaptcha_language = $valid_data['appearance_settings']['recaptcha_language']; |
629 | 628 | } else { |
630 | - if ( $recaptcha_settings_form->submission_error_message() != '' ) { |
|
631 | - EE_Error::add_error( $recaptcha_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
629 | + if ($recaptcha_settings_form->submission_error_message() != '') { |
|
630 | + EE_Error::add_error($recaptcha_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
632 | 631 | } |
633 | 632 | } |
634 | 633 | } |
635 | - } catch( EE_Error $e ) { |
|
634 | + } catch (EE_Error $e) { |
|
636 | 635 | $e->get_error(); |
637 | 636 | } |
638 | 637 |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
7 | 7 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
8 | 8 | |
9 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | * @param \WP_REST_Request $request |
47 | 47 | * @return \WP_REST_Response|\WP_Error |
48 | 48 | */ |
49 | - public static function handle_request_get_all( \WP_REST_Request $request) { |
|
49 | + public static function handle_request_get_all(\WP_REST_Request $request) { |
|
50 | 50 | $controller = new Read(); |
51 | - try{ |
|
51 | + try { |
|
52 | 52 | $matches = $controller->parse_route( |
53 | 53 | $request->get_route(), |
54 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~', |
|
55 | - array( 'version', 'model' ) |
|
54 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~', |
|
55 | + array('version', 'model') |
|
56 | 56 | ); |
57 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
58 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
59 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
57 | + $controller->set_requested_version($matches['version']); |
|
58 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
59 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
60 | 60 | return $controller->send_response( |
61 | 61 | new \WP_Error( |
62 | 62 | 'endpoint_parsing_error', |
63 | 63 | sprintf( |
64 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
64 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
65 | 65 | $model_name_singular |
66 | 66 | ) |
67 | 67 | ) |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | } |
70 | 70 | return $controller->send_response( |
71 | 71 | $controller->get_entities_from_model( |
72 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
72 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
73 | 73 | $request |
74 | 74 | ) |
75 | 75 | ); |
76 | - } catch( \Exception $e ) { |
|
77 | - return $controller->send_response( $e ); |
|
76 | + } catch (\Exception $e) { |
|
77 | + return $controller->send_response($e); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -84,21 +84,21 @@ discard block |
||
84 | 84 | * @param \WP_REST_Request $request |
85 | 85 | * @return \WP_REST_Response|\WP_Error |
86 | 86 | */ |
87 | - public static function handle_request_get_one( \WP_REST_Request $request ) { |
|
87 | + public static function handle_request_get_one(\WP_REST_Request $request) { |
|
88 | 88 | $controller = new Read(); |
89 | - try{ |
|
89 | + try { |
|
90 | 90 | $matches = $controller->parse_route( |
91 | 91 | $request->get_route(), |
92 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~', |
|
93 | - array( 'version', 'model', 'id' ) ); |
|
94 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
95 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
96 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
92 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~', |
|
93 | + array('version', 'model', 'id') ); |
|
94 | + $controller->set_requested_version($matches['version']); |
|
95 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
96 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
97 | 97 | return $controller->send_response( |
98 | 98 | new \WP_Error( |
99 | 99 | 'endpoint_parsing_error', |
100 | 100 | sprintf( |
101 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
101 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
102 | 102 | $model_name_singular |
103 | 103 | ) |
104 | 104 | ) |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | } |
107 | 107 | return $controller->send_response( |
108 | 108 | $controller->get_entity_from_model( |
109 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
109 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
110 | 110 | $request |
111 | 111 | ) |
112 | 112 | ); |
113 | - } catch( \Exception $e ) { |
|
114 | - return $controller->send_response( $e ); |
|
113 | + } catch (\Exception $e) { |
|
114 | + return $controller->send_response($e); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -123,40 +123,40 @@ discard block |
||
123 | 123 | * @param \WP_REST_Request $request |
124 | 124 | * @return \WP_REST_Response|\WP_Error |
125 | 125 | */ |
126 | - public static function handle_request_get_related( \WP_REST_Request $request ) { |
|
126 | + public static function handle_request_get_related(\WP_REST_Request $request) { |
|
127 | 127 | $controller = new Read(); |
128 | - try{ |
|
128 | + try { |
|
129 | 129 | $matches = $controller->parse_route( |
130 | 130 | $request->get_route(), |
131 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~', |
|
132 | - array( 'version', 'model', 'id', 'related_model' ) |
|
131 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~', |
|
132 | + array('version', 'model', 'id', 'related_model') |
|
133 | 133 | ); |
134 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
135 | - $main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
136 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) { |
|
134 | + $controller->set_requested_version($matches['version']); |
|
135 | + $main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
136 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) { |
|
137 | 137 | return $controller->send_response( |
138 | 138 | new \WP_Error( |
139 | 139 | 'endpoint_parsing_error', |
140 | 140 | sprintf( |
141 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
141 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
142 | 142 | $main_model_name_singular |
143 | 143 | ) |
144 | 144 | ) |
145 | 145 | ); |
146 | 146 | } |
147 | - $main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular ); |
|
147 | + $main_model = $controller->get_model_version_info()->load_model($main_model_name_singular); |
|
148 | 148 | //assume the related model name is plural and try to find the model's name |
149 | - $related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] ); |
|
150 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
149 | + $related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']); |
|
150 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
151 | 151 | //so the word didn't singularize well. Maybe that's just because it's a singular word? |
152 | - $related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] ); |
|
152 | + $related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']); |
|
153 | 153 | } |
154 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
154 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
155 | 155 | return $controller->send_response( |
156 | 156 | new \WP_Error( |
157 | 157 | 'endpoint_parsing_error', |
158 | 158 | sprintf( |
159 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
159 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
160 | 160 | $related_model_name_singular |
161 | 161 | ) |
162 | 162 | ) |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | |
166 | 166 | return $controller->send_response( |
167 | 167 | $controller->get_entities_from_relation( |
168 | - $request->get_param( 'id' ), |
|
169 | - $main_model->related_settings_for( $related_model_name_singular ) , |
|
168 | + $request->get_param('id'), |
|
169 | + $main_model->related_settings_for($related_model_name_singular), |
|
170 | 170 | $request |
171 | 171 | ) |
172 | 172 | ); |
173 | - } catch( \Exception $e ) { |
|
174 | - return $controller->send_response( $e ); |
|
173 | + } catch (\Exception $e) { |
|
174 | + return $controller->send_response($e); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
@@ -184,28 +184,28 @@ discard block |
||
184 | 184 | * @param \WP_REST_Request $request |
185 | 185 | * @return array |
186 | 186 | */ |
187 | - public function get_entities_from_model( $model, $request) { |
|
188 | - $query_params = $this->create_model_query_params( $model, $request->get_params() ); |
|
189 | - if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) { |
|
190 | - $model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ); |
|
187 | + public function get_entities_from_model($model, $request) { |
|
188 | + $query_params = $this->create_model_query_params($model, $request->get_params()); |
|
189 | + if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) { |
|
190 | + $model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()); |
|
191 | 191 | return new \WP_Error( |
192 | - sprintf( 'rest_%s_cannot_list', $model_name_plural ), |
|
192 | + sprintf('rest_%s_cannot_list', $model_name_plural), |
|
193 | 193 | sprintf( |
194 | - __( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ), |
|
194 | + __('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'), |
|
195 | 195 | $model_name_plural, |
196 | - Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) |
|
196 | + Capabilities::get_missing_permissions_string($model, $query_params['caps']) |
|
197 | 197 | ), |
198 | - array( 'status' => 403 ) |
|
198 | + array('status' => 403) |
|
199 | 199 | ); |
200 | 200 | } |
201 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
202 | - $this->_set_headers_from_query_params( $model, $query_params ); |
|
201 | + if ( ! $request->get_header('no_rest_headers')) { |
|
202 | + $this->_set_headers_from_query_params($model, $query_params); |
|
203 | 203 | } |
204 | 204 | /** @type array $results */ |
205 | - $results = $model->get_all_wpdb_results( $query_params ); |
|
205 | + $results = $model->get_all_wpdb_results($query_params); |
|
206 | 206 | $nice_results = array( ); |
207 | - foreach ( $results as $result ) { |
|
208 | - $nice_results[ ] = $this->create_entity_from_wpdb_result( |
|
207 | + foreach ($results as $result) { |
|
208 | + $nice_results[] = $this->create_entity_from_wpdb_result( |
|
209 | 209 | $model, |
210 | 210 | $result, |
211 | 211 | $request |
@@ -226,64 +226,64 @@ discard block |
||
226 | 226 | * @param \WP_REST_Request $request |
227 | 227 | * @return array |
228 | 228 | */ |
229 | - public function get_entities_from_relation( $id, $relation, $request ) { |
|
230 | - $context = $this->validate_context( $request->get_param( 'caps' )); |
|
229 | + public function get_entities_from_relation($id, $relation, $request) { |
|
230 | + $context = $this->validate_context($request->get_param('caps')); |
|
231 | 231 | $model = $relation->get_this_model(); |
232 | 232 | $related_model = $relation->get_other_model(); |
233 | 233 | //check if they can access the 1st model object |
234 | - $query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 ); |
|
235 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
234 | + $query_params = array(array($model->primary_key_name() => $id), 'limit' => 1); |
|
235 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
236 | 236 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
237 | 237 | } |
238 | 238 | $restricted_query_params = $query_params; |
239 | - $restricted_query_params[ 'caps' ] = $context; |
|
240 | - $this->_set_debug_info( 'main model query params', $restricted_query_params ); |
|
241 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) ); |
|
239 | + $restricted_query_params['caps'] = $context; |
|
240 | + $this->_set_debug_info('main model query params', $restricted_query_params); |
|
241 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context)); |
|
242 | 242 | |
243 | - if( |
|
243 | + if ( |
|
244 | 244 | ! ( |
245 | - Capabilities::current_user_has_partial_access_to( $related_model, $context ) |
|
246 | - && $model->exists( $restricted_query_params ) |
|
245 | + Capabilities::current_user_has_partial_access_to($related_model, $context) |
|
246 | + && $model->exists($restricted_query_params) |
|
247 | 247 | ) |
248 | - ){ |
|
249 | - if( $relation instanceof \EE_Belongs_To_Relation ) { |
|
250 | - $related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() ); |
|
251 | - }else{ |
|
252 | - $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() ); |
|
248 | + ) { |
|
249 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
250 | + $related_model_name_maybe_plural = strtolower($related_model->get_this_model_name()); |
|
251 | + } else { |
|
252 | + $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name()); |
|
253 | 253 | } |
254 | 254 | return new \WP_Error( |
255 | - sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ), |
|
255 | + sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural), |
|
256 | 256 | sprintf( |
257 | - __( 'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ), |
|
257 | + __('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'), |
|
258 | 258 | $related_model_name_maybe_plural, |
259 | 259 | $relation->get_this_model()->get_this_model_name(), |
260 | 260 | implode( |
261 | 261 | ',', |
262 | 262 | array_keys( |
263 | - Capabilities::get_missing_permissions( $related_model, $context ) |
|
263 | + Capabilities::get_missing_permissions($related_model, $context) |
|
264 | 264 | ) |
265 | 265 | ) |
266 | 266 | ), |
267 | - array( 'status' => 403 ) |
|
267 | + array('status' => 403) |
|
268 | 268 | ); |
269 | 269 | } |
270 | - $query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() ); |
|
271 | - $query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id; |
|
272 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
273 | - $query_params[ 'caps' ] = $context; |
|
274 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
275 | - $this->_set_headers_from_query_params( $relation->get_other_model(), $query_params ); |
|
270 | + $query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params()); |
|
271 | + $query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id; |
|
272 | + $query_params['default_where_conditions'] = 'none'; |
|
273 | + $query_params['caps'] = $context; |
|
274 | + if ( ! $request->get_header('no_rest_headers')) { |
|
275 | + $this->_set_headers_from_query_params($relation->get_other_model(), $query_params); |
|
276 | 276 | } |
277 | 277 | /** @type array $results */ |
278 | - $results = $relation->get_other_model()->get_all_wpdb_results( $query_params ); |
|
278 | + $results = $relation->get_other_model()->get_all_wpdb_results($query_params); |
|
279 | 279 | $nice_results = array(); |
280 | - foreach( $results as $result ) { |
|
280 | + foreach ($results as $result) { |
|
281 | 281 | $nice_result = $this->create_entity_from_wpdb_result( |
282 | 282 | $relation->get_other_model(), |
283 | 283 | $result, |
284 | 284 | $request |
285 | 285 | ); |
286 | - if( $relation instanceof \EE_HABTM_Relation ) { |
|
286 | + if ($relation instanceof \EE_HABTM_Relation) { |
|
287 | 287 | //put the unusual stuff (properties from the HABTM relation) first, and make sure |
288 | 288 | //if there are conflicts we prefer the properties from the main model |
289 | 289 | $join_model_result = $this->create_entity_from_wpdb_result( |
@@ -291,18 +291,18 @@ discard block |
||
291 | 291 | $result, |
292 | 292 | $request |
293 | 293 | ); |
294 | - $joined_result = array_merge( $nice_result, $join_model_result ); |
|
294 | + $joined_result = array_merge($nice_result, $join_model_result); |
|
295 | 295 | //but keep the meta stuff from the main model |
296 | - if( isset( $nice_result['meta'] ) ){ |
|
296 | + if (isset($nice_result['meta'])) { |
|
297 | 297 | $joined_result['meta'] = $nice_result['meta']; |
298 | 298 | } |
299 | 299 | $nice_result = $joined_result; |
300 | 300 | } |
301 | 301 | $nice_results[] = $nice_result; |
302 | 302 | } |
303 | - if( $relation instanceof \EE_Belongs_To_Relation ){ |
|
304 | - return array_shift( $nice_results ); |
|
305 | - }else{ |
|
303 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
304 | + return array_shift($nice_results); |
|
305 | + } else { |
|
306 | 306 | return $nice_results; |
307 | 307 | } |
308 | 308 | } |
@@ -315,30 +315,30 @@ discard block |
||
315 | 315 | * @param array $query_params |
316 | 316 | * @return void |
317 | 317 | */ |
318 | - protected function _set_headers_from_query_params( $model, $query_params ) { |
|
319 | - $this->_set_debug_info( 'model query params', $query_params ); |
|
320 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) ); |
|
318 | + protected function _set_headers_from_query_params($model, $query_params) { |
|
319 | + $this->_set_debug_info('model query params', $query_params); |
|
320 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($model, $query_params['caps'])); |
|
321 | 321 | //normally the limit to a 2-part array, where the 2nd item is the limit |
322 | - if( ! isset( $query_params[ 'limit' ] ) ) { |
|
323 | - $query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
322 | + if ( ! isset($query_params['limit'])) { |
|
323 | + $query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
324 | 324 | } |
325 | - if( is_array( $query_params[ 'limit' ] ) ) { |
|
326 | - $limit_parts = $query_params[ 'limit' ]; |
|
325 | + if (is_array($query_params['limit'])) { |
|
326 | + $limit_parts = $query_params['limit']; |
|
327 | 327 | } else { |
328 | - $limit_parts = explode(',', $query_params[ 'limit' ] ); |
|
329 | - if( count( $limit_parts ) == 1 ){ |
|
330 | - $limit_parts = array(0, $limit_parts[ 0 ] ); |
|
328 | + $limit_parts = explode(',', $query_params['limit']); |
|
329 | + if (count($limit_parts) == 1) { |
|
330 | + $limit_parts = array(0, $limit_parts[0]); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | //remove the group by and having parts of the query, as those will |
334 | 334 | //make the sql query return an array of values, instead of just a single value |
335 | - unset( $query_params[ 'group_by' ], $query_params[ 'having' ], $query_params[ 'limit' ] ); |
|
336 | - $count = $model->count( $query_params, null, true ); |
|
335 | + unset($query_params['group_by'], $query_params['having'], $query_params['limit']); |
|
336 | + $count = $model->count($query_params, null, true); |
|
337 | 337 | |
338 | - $pages = $count / $limit_parts[ 1 ]; |
|
339 | - $this->_set_response_header( 'Total', $count, false ); |
|
340 | - $this->_set_response_header( 'PageSize', $limit_parts[ 1 ], false ); |
|
341 | - $this->_set_response_header( 'TotalPages', ceil( $pages ), false ); |
|
338 | + $pages = $count / $limit_parts[1]; |
|
339 | + $this->_set_response_header('Total', $count, false); |
|
340 | + $this->_set_response_header('PageSize', $limit_parts[1], false); |
|
341 | + $this->_set_response_header('TotalPages', ceil($pages), false); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | |
@@ -351,47 +351,47 @@ discard block |
||
351 | 351 | * @param string $deprecated no longer used |
352 | 352 | * @return array ready for being converted into json for sending to client |
353 | 353 | */ |
354 | - public function create_entity_from_wpdb_result( $model, $db_row, $rest_request, $deprecated = null ) { |
|
355 | - if( ! $rest_request instanceof \WP_REST_Request ) { |
|
354 | + public function create_entity_from_wpdb_result($model, $db_row, $rest_request, $deprecated = null) { |
|
355 | + if ( ! $rest_request instanceof \WP_REST_Request) { |
|
356 | 356 | //ok so this was called in the old style, where the 3rd arg was |
357 | 357 | //$include, and the 4th arg was $context |
358 | 358 | //now setup the request just to avoid fatal errors, although we won't be able |
359 | 359 | //to truly make use of it because it's kinda devoid of info |
360 | 360 | $rest_request = new \WP_REST_Request(); |
361 | - $rest_request->set_param( 'include', $rest_request ); |
|
362 | - $rest_request->set_param( 'caps', $deprecated ); |
|
361 | + $rest_request->set_param('include', $rest_request); |
|
362 | + $rest_request->set_param('caps', $deprecated); |
|
363 | 363 | } |
364 | - if( $rest_request->get_param( 'caps' ) == null ) { |
|
365 | - $rest_request->set_param( 'caps', \EEM_Base::caps_read ); |
|
364 | + if ($rest_request->get_param('caps') == null) { |
|
365 | + $rest_request->set_param('caps', \EEM_Base::caps_read); |
|
366 | 366 | } |
367 | - $entity_array = $this->_create_bare_entity_from_wpdb_results( $model, $db_row ); |
|
368 | - $entity_array = $this->_add_extra_fields( $model, $db_row, $entity_array ); |
|
369 | - $entity_array[ '_links' ] = $this->_get_entity_links( $model, $db_row, $entity_array ); |
|
370 | - $entity_array[ '_calculated_fields'] = $this->_get_entity_calculations( $model, $db_row, $rest_request ); |
|
371 | - $entity_array = $this->_include_requested_models( $model, $rest_request, $entity_array ); |
|
367 | + $entity_array = $this->_create_bare_entity_from_wpdb_results($model, $db_row); |
|
368 | + $entity_array = $this->_add_extra_fields($model, $db_row, $entity_array); |
|
369 | + $entity_array['_links'] = $this->_get_entity_links($model, $db_row, $entity_array); |
|
370 | + $entity_array['_calculated_fields'] = $this->_get_entity_calculations($model, $db_row, $rest_request); |
|
371 | + $entity_array = $this->_include_requested_models($model, $rest_request, $entity_array); |
|
372 | 372 | $entity_array = apply_filters( |
373 | 373 | 'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal', |
374 | 374 | $entity_array, |
375 | 375 | $model, |
376 | - $rest_request->get_param( 'caps' ), |
|
376 | + $rest_request->get_param('caps'), |
|
377 | 377 | $rest_request, |
378 | 378 | $this |
379 | 379 | ); |
380 | 380 | $result_without_inaccessible_fields = Capabilities::filter_out_inaccessible_entity_fields( |
381 | 381 | $entity_array, |
382 | 382 | $model, |
383 | - $rest_request->get_param( 'caps' ), |
|
383 | + $rest_request->get_param('caps'), |
|
384 | 384 | $this->get_model_version_info() |
385 | 385 | ); |
386 | 386 | $this->_set_debug_info( |
387 | 387 | 'inaccessible fields', |
388 | - array_keys( array_diff_key( $entity_array, $result_without_inaccessible_fields ) ) |
|
388 | + array_keys(array_diff_key($entity_array, $result_without_inaccessible_fields)) |
|
389 | 389 | ); |
390 | 390 | return apply_filters( |
391 | 391 | 'FHEE__Read__create_entity_from_wpdb_results__entity_return', |
392 | 392 | $result_without_inaccessible_fields, |
393 | 393 | $model, |
394 | - $rest_request->get_param( 'caps' ) |
|
394 | + $rest_request->get_param('caps') |
|
395 | 395 | ); |
396 | 396 | } |
397 | 397 | |
@@ -403,38 +403,38 @@ discard block |
||
403 | 403 | * @param array $db_row |
404 | 404 | * @return array entity mostly ready for converting to JSON and sending in the response |
405 | 405 | */ |
406 | - protected function _create_bare_entity_from_wpdb_results( \EEM_Base $model, $db_row ) { |
|
407 | - $result = $model->deduce_fields_n_values_from_cols_n_values( $db_row ); |
|
408 | - $result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) ); |
|
409 | - foreach( $result as $field_name => $raw_field_value ) { |
|
406 | + protected function _create_bare_entity_from_wpdb_results(\EEM_Base $model, $db_row) { |
|
407 | + $result = $model->deduce_fields_n_values_from_cols_n_values($db_row); |
|
408 | + $result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model)); |
|
409 | + foreach ($result as $field_name => $raw_field_value) { |
|
410 | 410 | $field_obj = $model->field_settings_for($field_name); |
411 | - $field_value = $field_obj->prepare_for_set_from_db( $raw_field_value ); |
|
412 | - if( $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_ignored() ) ){ |
|
413 | - unset( $result[ $field_name ] ); |
|
414 | - }elseif( |
|
415 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() ) |
|
416 | - ){ |
|
417 | - $result[ $field_name ] = array( |
|
418 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
419 | - 'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
411 | + $field_value = $field_obj->prepare_for_set_from_db($raw_field_value); |
|
412 | + if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) { |
|
413 | + unset($result[$field_name]); |
|
414 | + }elseif ( |
|
415 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format()) |
|
416 | + ) { |
|
417 | + $result[$field_name] = array( |
|
418 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
419 | + 'rendered' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
420 | 420 | ); |
421 | - }elseif( |
|
422 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() ) |
|
423 | - ){ |
|
424 | - $result[ $field_name ] = array( |
|
425 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
426 | - 'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
421 | + }elseif ( |
|
422 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format()) |
|
423 | + ) { |
|
424 | + $result[$field_name] = array( |
|
425 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
426 | + 'pretty' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
427 | 427 | ); |
428 | - } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
|
429 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
428 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
429 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
430 | 430 | $field_obj, |
431 | 431 | $field_value, |
432 | 432 | $this->get_model_version_info()->requested_version() |
433 | 433 | ); |
434 | 434 | } else { |
435 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
435 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
436 | 436 | $field_obj, |
437 | - $field_obj->prepare_for_get( $field_value ), |
|
437 | + $field_obj->prepare_for_get($field_value), |
|
438 | 438 | $this->get_model_version_info()->requested_version() |
439 | 439 | ); |
440 | 440 | } |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | * @param array $entity_array |
450 | 450 | * @return array modified entity |
451 | 451 | */ |
452 | - protected function _add_extra_fields( \EEM_Base $model, $db_row, $entity_array ) { |
|
453 | - if( $model instanceof \EEM_CPT_Base ) { |
|
454 | - $entity_array[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ); |
|
452 | + protected function _add_extra_fields(\EEM_Base $model, $db_row, $entity_array) { |
|
453 | + if ($model instanceof \EEM_CPT_Base) { |
|
454 | + $entity_array['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]); |
|
455 | 455 | } |
456 | 456 | return $entity_array; |
457 | 457 | } |
@@ -465,20 +465,20 @@ discard block |
||
465 | 465 | * @param array $entity_array |
466 | 466 | * @return array the _links item in the entity |
467 | 467 | */ |
468 | - protected function _get_entity_links( $model, $db_row, $entity_array ) { |
|
468 | + protected function _get_entity_links($model, $db_row, $entity_array) { |
|
469 | 469 | //add basic links |
470 | 470 | $links = array( |
471 | 471 | 'self' => array( |
472 | 472 | array( |
473 | 473 | 'href' => $this->get_versioned_link_to( |
474 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] |
|
474 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()] |
|
475 | 475 | ) |
476 | 476 | ) |
477 | 477 | ), |
478 | 478 | 'collection' => array( |
479 | 479 | array( |
480 | 480 | 'href' => $this->get_versioned_link_to( |
481 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) |
|
481 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()) |
|
482 | 482 | ) |
483 | 483 | ) |
484 | 484 | ), |
@@ -486,24 +486,24 @@ discard block |
||
486 | 486 | |
487 | 487 | //add link to the wp core endpoint, if wp api is active |
488 | 488 | global $wp_rest_server; |
489 | - if( $model instanceof \EEM_CPT_Base && |
|
489 | + if ($model instanceof \EEM_CPT_Base && |
|
490 | 490 | $wp_rest_server instanceof \WP_REST_Server && |
491 | - $wp_rest_server->get_route_options( '/wp/v2/posts' ) ) { |
|
492 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array( |
|
491 | + $wp_rest_server->get_route_options('/wp/v2/posts')) { |
|
492 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array( |
|
493 | 493 | array( |
494 | - 'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ), |
|
494 | + 'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]), |
|
495 | 495 | 'single' => true |
496 | 496 | ) |
497 | 497 | ); |
498 | 498 | } |
499 | 499 | |
500 | 500 | //add links to related models |
501 | - foreach( $this->get_model_version_info()->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
502 | - $related_model_part = Read::get_related_entity_name( $relation_name, $relation_obj ); |
|
503 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part ] = array( |
|
501 | + foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) { |
|
502 | + $related_model_part = Read::get_related_entity_name($relation_name, $relation_obj); |
|
503 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array( |
|
504 | 504 | array( |
505 | 505 | 'href' => $this->get_versioned_link_to( |
506 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] . '/' . $related_model_part |
|
506 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()].'/'.$related_model_part |
|
507 | 507 | ), |
508 | 508 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false |
509 | 509 | ) |
@@ -519,51 +519,51 @@ discard block |
||
519 | 519 | * @param array $entity_array |
520 | 520 | * @return array the modified entity |
521 | 521 | */ |
522 | - protected function _include_requested_models( \EEM_Base $model, \WP_REST_Request $rest_request, $entity_array ) { |
|
523 | - $includes_for_this_model = $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'include' ), '' ); |
|
524 | - $includes_for_this_model = $this->_remove_model_names_from_array( $includes_for_this_model ); |
|
522 | + protected function _include_requested_models(\EEM_Base $model, \WP_REST_Request $rest_request, $entity_array) { |
|
523 | + $includes_for_this_model = $this->explode_and_get_items_prefixed_with($rest_request->get_param('include'), ''); |
|
524 | + $includes_for_this_model = $this->_remove_model_names_from_array($includes_for_this_model); |
|
525 | 525 | //if they passed in * or didn't specify any includes, return everything |
526 | - if( ! in_array( '*', $includes_for_this_model ) |
|
527 | - && ! empty( $includes_for_this_model ) ) { |
|
528 | - if( $model->has_primary_key_field() ) { |
|
526 | + if ( ! in_array('*', $includes_for_this_model) |
|
527 | + && ! empty($includes_for_this_model)) { |
|
528 | + if ($model->has_primary_key_field()) { |
|
529 | 529 | //always include the primary key. ya just gotta know that at least |
530 | 530 | $includes_for_this_model[] = $model->primary_key_name(); |
531 | 531 | } |
532 | - if( $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'calculate' ), '' ) ) { |
|
532 | + if ($this->explode_and_get_items_prefixed_with($rest_request->get_param('calculate'), '')) { |
|
533 | 533 | $includes_for_this_model[] = '_calculated_fields'; |
534 | 534 | } |
535 | - $entity_array = array_intersect_key( $entity_array, array_flip( $includes_for_this_model ) ); |
|
535 | + $entity_array = array_intersect_key($entity_array, array_flip($includes_for_this_model)); |
|
536 | 536 | } |
537 | - $relation_settings = $this->get_model_version_info()->relation_settings( $model ); |
|
538 | - foreach( $relation_settings as $relation_name => $relation_obj ) { |
|
537 | + $relation_settings = $this->get_model_version_info()->relation_settings($model); |
|
538 | + foreach ($relation_settings as $relation_name => $relation_obj) { |
|
539 | 539 | $related_fields_to_include = $this->explode_and_get_items_prefixed_with( |
540 | - $rest_request->get_param( 'include' ), |
|
540 | + $rest_request->get_param('include'), |
|
541 | 541 | $relation_name |
542 | 542 | ); |
543 | 543 | $related_fields_to_calculate = $this->explode_and_get_items_prefixed_with( |
544 | - $rest_request->get_param( 'calculate' ), |
|
544 | + $rest_request->get_param('calculate'), |
|
545 | 545 | $relation_name |
546 | 546 | ); |
547 | 547 | //did they specify they wanted to include a related model, or |
548 | 548 | //specific fields from a related model? |
549 | 549 | //or did they specify to calculate a field from a related model? |
550 | - if( $related_fields_to_include || $related_fields_to_calculate ) { |
|
550 | + if ($related_fields_to_include || $related_fields_to_calculate) { |
|
551 | 551 | //if so, we should include at least some part of the related model |
552 | 552 | $pretend_related_request = new \WP_REST_Request(); |
553 | 553 | $pretend_related_request->set_query_params( |
554 | 554 | array( |
555 | - 'caps' => $rest_request->get_param( 'caps' ), |
|
555 | + 'caps' => $rest_request->get_param('caps'), |
|
556 | 556 | 'include' => $related_fields_to_include, |
557 | 557 | 'calculate' => $related_fields_to_calculate, |
558 | 558 | ) |
559 | 559 | ); |
560 | - $pretend_related_request->add_header( 'no_rest_headers', true ); |
|
560 | + $pretend_related_request->add_header('no_rest_headers', true); |
|
561 | 561 | $related_results = $this->get_entities_from_relation( |
562 | - $entity_array[ $model->primary_key_name() ], |
|
562 | + $entity_array[$model->primary_key_name()], |
|
563 | 563 | $relation_obj, |
564 | 564 | $pretend_related_request |
565 | 565 | ); |
566 | - $entity_array[ Read::get_related_entity_name( $relation_name, $relation_obj ) ] = $related_results instanceof \WP_Error |
|
566 | + $entity_array[Read::get_related_entity_name($relation_name, $relation_obj)] = $related_results instanceof \WP_Error |
|
567 | 567 | ? null |
568 | 568 | : $related_results; |
569 | 569 | } |
@@ -577,8 +577,8 @@ discard block |
||
577 | 577 | * @param array $arr |
578 | 578 | * @return array |
579 | 579 | */ |
580 | - private function _remove_model_names_from_array( $arr ) { |
|
581 | - return array_diff( $arr, array_keys( \EE_Registry::instance()->non_abstract_db_models ) ); |
|
580 | + private function _remove_model_names_from_array($arr) { |
|
581 | + return array_diff($arr, array_keys(\EE_Registry::instance()->non_abstract_db_models)); |
|
582 | 582 | } |
583 | 583 | /** |
584 | 584 | * Gets the calculated fields for the response |
@@ -588,15 +588,15 @@ discard block |
||
588 | 588 | * @param \WP_REST_Request $rest_request |
589 | 589 | * @return array the _calculations item in the entity |
590 | 590 | */ |
591 | - protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) { |
|
591 | + protected function _get_entity_calculations($model, $wpdb_row, $rest_request) { |
|
592 | 592 | $calculated_fields = $this->explode_and_get_items_prefixed_with( |
593 | - $rest_request->get_param( 'calculate' ), |
|
593 | + $rest_request->get_param('calculate'), |
|
594 | 594 | '' |
595 | 595 | ); |
596 | 596 | //note: setting calculate=* doesn't do anything |
597 | 597 | $calculated_fields_to_return = new \stdClass(); |
598 | - foreach( $calculated_fields as $field_to_calculate ) { |
|
599 | - try{ |
|
598 | + foreach ($calculated_fields as $field_to_calculate) { |
|
599 | + try { |
|
600 | 600 | $calculated_fields_to_return->$field_to_calculate = Model_Data_Translator::prepare_field_value_for_json( |
601 | 601 | null, |
602 | 602 | $this->_fields_calculator->retrieve_calculated_field_value( |
@@ -608,10 +608,10 @@ discard block |
||
608 | 608 | ), |
609 | 609 | $this->get_model_version_info()->requested_version() |
610 | 610 | ); |
611 | - } catch( Rest_Exception $e ) { |
|
611 | + } catch (Rest_Exception $e) { |
|
612 | 612 | //if we don't have permission to read it, just leave it out. but let devs know about the problem |
613 | 613 | $this->_set_response_header( |
614 | - 'Notices-Field-Calculation-Errors[' . $e->get_string_code() . '][' . $model->get_this_model_name() . '][' . $field_to_calculate . ']', |
|
614 | + 'Notices-Field-Calculation-Errors['.$e->get_string_code().']['.$model->get_this_model_name().']['.$field_to_calculate.']', |
|
615 | 615 | $e->getMessage(), |
616 | 616 | true |
617 | 617 | ); |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * @param string $link_part_after_version_and_slash eg "events/10/datetimes" |
626 | 626 | * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes" |
627 | 627 | */ |
628 | - public function get_versioned_link_to( $link_part_after_version_and_slash ) { |
|
628 | + public function get_versioned_link_to($link_part_after_version_and_slash) { |
|
629 | 629 | return rest_url( |
630 | 630 | \EED_Core_Rest_Api::ee_api_namespace |
631 | 631 | . $this->get_model_version_info()->requested_version() |
@@ -641,11 +641,11 @@ discard block |
||
641 | 641 | * @param \EE_Model_Relation_Base $relation_obj |
642 | 642 | * @return string |
643 | 643 | */ |
644 | - public static function get_related_entity_name( $relation_name, $relation_obj ){ |
|
645 | - if( $relation_obj instanceof \EE_Belongs_To_Relation ) { |
|
646 | - return strtolower( $relation_name ); |
|
647 | - }else{ |
|
648 | - return \EEH_Inflector::pluralize_and_lower( $relation_name ); |
|
644 | + public static function get_related_entity_name($relation_name, $relation_obj) { |
|
645 | + if ($relation_obj instanceof \EE_Belongs_To_Relation) { |
|
646 | + return strtolower($relation_name); |
|
647 | + } else { |
|
648 | + return \EEH_Inflector::pluralize_and_lower($relation_name); |
|
649 | 649 | } |
650 | 650 | } |
651 | 651 | |
@@ -658,43 +658,43 @@ discard block |
||
658 | 658 | * @param \WP_REST_Request $request |
659 | 659 | * @return array |
660 | 660 | */ |
661 | - public function get_entity_from_model( $model, $request ) { |
|
662 | - $query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1); |
|
663 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
661 | + public function get_entity_from_model($model, $request) { |
|
662 | + $query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1); |
|
663 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
664 | 664 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
665 | 665 | } |
666 | 666 | $restricted_query_params = $query_params; |
667 | - $restricted_query_params[ 'caps' ] = $this->validate_context( $request->get_param( 'caps' ) ); |
|
668 | - $this->_set_debug_info( 'model query params', $restricted_query_params ); |
|
669 | - $model_rows = $model->get_all_wpdb_results( $restricted_query_params ); |
|
670 | - if ( ! empty ( $model_rows ) ) { |
|
667 | + $restricted_query_params['caps'] = $this->validate_context($request->get_param('caps')); |
|
668 | + $this->_set_debug_info('model query params', $restricted_query_params); |
|
669 | + $model_rows = $model->get_all_wpdb_results($restricted_query_params); |
|
670 | + if ( ! empty ($model_rows)) { |
|
671 | 671 | return $this->create_entity_from_wpdb_result( |
672 | 672 | $model, |
673 | - array_shift( $model_rows ), |
|
673 | + array_shift($model_rows), |
|
674 | 674 | $request ); |
675 | 675 | } else { |
676 | 676 | //ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities |
677 | - $lowercase_model_name = strtolower( $model->get_this_model_name() ); |
|
678 | - $model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params ); |
|
679 | - if( ! empty( $model_rows_found_sans_restrictions ) ) { |
|
677 | + $lowercase_model_name = strtolower($model->get_this_model_name()); |
|
678 | + $model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params); |
|
679 | + if ( ! empty($model_rows_found_sans_restrictions)) { |
|
680 | 680 | //you got shafted- it existed but we didn't want to tell you! |
681 | 681 | return new \WP_Error( |
682 | 682 | 'rest_user_cannot_read', |
683 | 683 | sprintf( |
684 | - __( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ), |
|
685 | - strtolower( $model->get_this_model_name() ), |
|
684 | + __('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'), |
|
685 | + strtolower($model->get_this_model_name()), |
|
686 | 686 | Capabilities::get_missing_permissions_string( |
687 | 687 | $model, |
688 | - $this->validate_context( $request->get_param( 'caps' ) ) ) |
|
688 | + $this->validate_context($request->get_param('caps')) ) |
|
689 | 689 | ), |
690 | - array( 'status' => 403 ) |
|
690 | + array('status' => 403) |
|
691 | 691 | ); |
692 | 692 | } else { |
693 | 693 | //it's not you. It just doesn't exist |
694 | 694 | return new \WP_Error( |
695 | - sprintf( 'rest_%s_invalid_id', $lowercase_model_name ), |
|
696 | - sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ), |
|
697 | - array( 'status' => 404 ) |
|
695 | + sprintf('rest_%s_invalid_id', $lowercase_model_name), |
|
696 | + sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name), |
|
697 | + array('status' => 404) |
|
698 | 698 | ); |
699 | 699 | } |
700 | 700 | } |
@@ -707,14 +707,14 @@ discard block |
||
707 | 707 | * @param string $context |
708 | 708 | * @return string array key of EEM_Base::cap_contexts_to_cap_action_map() |
709 | 709 | */ |
710 | - public function validate_context( $context ) { |
|
711 | - if( ! $context ) { |
|
710 | + public function validate_context($context) { |
|
711 | + if ( ! $context) { |
|
712 | 712 | $context = \EEM_Base::caps_read; |
713 | 713 | } |
714 | 714 | $valid_contexts = \EEM_Base::valid_cap_contexts(); |
715 | - if( in_array( $context, $valid_contexts ) ){ |
|
715 | + if (in_array($context, $valid_contexts)) { |
|
716 | 716 | return $context; |
717 | - }else{ |
|
717 | + } else { |
|
718 | 718 | return \EEM_Base::caps_read; |
719 | 719 | } |
720 | 720 | } |
@@ -733,77 +733,77 @@ discard block |
||
733 | 733 | * that absolutely no results should be returned |
734 | 734 | * @throws \EE_Error |
735 | 735 | */ |
736 | - public function create_model_query_params( $model, $query_parameters ) { |
|
736 | + public function create_model_query_params($model, $query_parameters) { |
|
737 | 737 | $model_query_params = array( ); |
738 | - if ( isset( $query_parameters[ 'where' ] ) ) { |
|
739 | - $model_query_params[ 0 ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
740 | - $query_parameters[ 'where' ], |
|
738 | + if (isset($query_parameters['where'])) { |
|
739 | + $model_query_params[0] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
740 | + $query_parameters['where'], |
|
741 | 741 | $model, |
742 | 742 | $this->get_model_version_info()->requested_version() |
743 | 743 | ); |
744 | 744 | } |
745 | - if ( isset( $query_parameters[ 'order_by' ] ) ) { |
|
746 | - $order_by = $query_parameters[ 'order_by' ]; |
|
747 | - } elseif ( isset( $query_parameters[ 'orderby' ] ) ) { |
|
748 | - $order_by = $query_parameters[ 'orderby' ]; |
|
749 | - }else{ |
|
745 | + if (isset($query_parameters['order_by'])) { |
|
746 | + $order_by = $query_parameters['order_by']; |
|
747 | + } elseif (isset($query_parameters['orderby'])) { |
|
748 | + $order_by = $query_parameters['orderby']; |
|
749 | + } else { |
|
750 | 750 | $order_by = null; |
751 | 751 | } |
752 | - if( $order_by !== null ){ |
|
753 | - $model_query_params[ 'order_by' ] = $order_by; |
|
752 | + if ($order_by !== null) { |
|
753 | + $model_query_params['order_by'] = $order_by; |
|
754 | 754 | } |
755 | - if ( isset( $query_parameters[ 'group_by' ] ) ) { |
|
756 | - $group_by = $query_parameters[ 'group_by' ]; |
|
757 | - } elseif ( isset( $query_parameters[ 'groupby' ] ) ) { |
|
758 | - $group_by = $query_parameters[ 'groupby' ]; |
|
759 | - }else{ |
|
760 | - $group_by = array_keys( $model->get_combined_primary_key_fields() ); |
|
755 | + if (isset($query_parameters['group_by'])) { |
|
756 | + $group_by = $query_parameters['group_by']; |
|
757 | + } elseif (isset($query_parameters['groupby'])) { |
|
758 | + $group_by = $query_parameters['groupby']; |
|
759 | + } else { |
|
760 | + $group_by = array_keys($model->get_combined_primary_key_fields()); |
|
761 | 761 | } |
762 | - if( $group_by !== null ){ |
|
763 | - $model_query_params[ 'group_by' ] = $group_by; |
|
762 | + if ($group_by !== null) { |
|
763 | + $model_query_params['group_by'] = $group_by; |
|
764 | 764 | } |
765 | - if ( isset( $query_parameters[ 'having' ] ) ) { |
|
766 | - $model_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
767 | - $query_parameters[ 'having' ], |
|
765 | + if (isset($query_parameters['having'])) { |
|
766 | + $model_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
767 | + $query_parameters['having'], |
|
768 | 768 | $model, |
769 | 769 | $this->get_model_version_info()->requested_version() |
770 | 770 | ); |
771 | 771 | } |
772 | - if ( isset( $query_parameters[ 'order' ] ) ) { |
|
773 | - $model_query_params[ 'order' ] = $query_parameters[ 'order' ]; |
|
772 | + if (isset($query_parameters['order'])) { |
|
773 | + $model_query_params['order'] = $query_parameters['order']; |
|
774 | 774 | } |
775 | - if ( isset( $query_parameters[ 'mine' ] ) ){ |
|
776 | - $model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params ); |
|
775 | + if (isset($query_parameters['mine'])) { |
|
776 | + $model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params); |
|
777 | 777 | } |
778 | - if( isset( $query_parameters[ 'limit' ] ) ) { |
|
778 | + if (isset($query_parameters['limit'])) { |
|
779 | 779 | //limit should be either a string like '23' or '23,43', or an array with two items in it |
780 | - if( ! is_array( $query_parameters[ 'limit' ] ) ) { |
|
781 | - $limit_array = explode(',', (string)$query_parameters['limit']); |
|
782 | - }else { |
|
783 | - $limit_array = $query_parameters[ 'limit' ]; |
|
780 | + if ( ! is_array($query_parameters['limit'])) { |
|
781 | + $limit_array = explode(',', (string) $query_parameters['limit']); |
|
782 | + } else { |
|
783 | + $limit_array = $query_parameters['limit']; |
|
784 | 784 | } |
785 | 785 | $sanitized_limit = array(); |
786 | - foreach( $limit_array as $key => $limit_part ) { |
|
787 | - if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) { |
|
786 | + foreach ($limit_array as $key => $limit_part) { |
|
787 | + if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) { |
|
788 | 788 | throw new \EE_Error( |
789 | 789 | sprintf( |
790 | - __( 'An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso' ), |
|
791 | - json_encode( $query_parameters[ 'limit' ] ) |
|
790 | + __('An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso'), |
|
791 | + json_encode($query_parameters['limit']) |
|
792 | 792 | ) |
793 | 793 | ); |
794 | 794 | } |
795 | - $sanitized_limit[] = (int)$limit_part; |
|
795 | + $sanitized_limit[] = (int) $limit_part; |
|
796 | 796 | } |
797 | - $model_query_params[ 'limit' ] = implode( ',', $sanitized_limit ); |
|
798 | - }else{ |
|
799 | - $model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
797 | + $model_query_params['limit'] = implode(',', $sanitized_limit); |
|
798 | + } else { |
|
799 | + $model_query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
800 | 800 | } |
801 | - if( isset( $query_parameters[ 'caps' ] ) ) { |
|
802 | - $model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] ); |
|
803 | - }else{ |
|
804 | - $model_query_params[ 'caps' ] = \EEM_Base::caps_read; |
|
801 | + if (isset($query_parameters['caps'])) { |
|
802 | + $model_query_params['caps'] = $this->validate_context($query_parameters['caps']); |
|
803 | + } else { |
|
804 | + $model_query_params['caps'] = \EEM_Base::caps_read; |
|
805 | 805 | } |
806 | - return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model ); |
|
806 | + return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | |
@@ -815,13 +815,13 @@ discard block |
||
815 | 815 | * @param array $query_params sub-array from @see EEM_Base::get_all() |
816 | 816 | * @return array |
817 | 817 | */ |
818 | - public function prepare_rest_query_params_key_for_models( $model, $query_params ) { |
|
818 | + public function prepare_rest_query_params_key_for_models($model, $query_params) { |
|
819 | 819 | $model_ready_query_params = array(); |
820 | - foreach( $query_params as $key => $value ) { |
|
821 | - if( is_array( $value ) ) { |
|
822 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value ); |
|
823 | - }else{ |
|
824 | - $model_ready_query_params[ $key ] = $value; |
|
820 | + foreach ($query_params as $key => $value) { |
|
821 | + if (is_array($value)) { |
|
822 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value); |
|
823 | + } else { |
|
824 | + $model_ready_query_params[$key] = $value; |
|
825 | 825 | } |
826 | 826 | } |
827 | 827 | return $model_ready_query_params; |
@@ -835,13 +835,13 @@ discard block |
||
835 | 835 | * @param $query_params |
836 | 836 | * @return array |
837 | 837 | */ |
838 | - public function prepare_rest_query_params_values_for_models( $model, $query_params ) { |
|
838 | + public function prepare_rest_query_params_values_for_models($model, $query_params) { |
|
839 | 839 | $model_ready_query_params = array(); |
840 | - foreach( $query_params as $key => $value ) { |
|
841 | - if( is_array( $value ) ) { |
|
842 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value ); |
|
840 | + foreach ($query_params as $key => $value) { |
|
841 | + if (is_array($value)) { |
|
842 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value); |
|
843 | 843 | } else { |
844 | - $model_ready_query_params[ $key ] = $value; |
|
844 | + $model_ready_query_params[$key] = $value; |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | return $model_ready_query_params; |
@@ -856,33 +856,33 @@ discard block |
||
856 | 856 | * we only return strings starting with that and a period; if no prefix was specified |
857 | 857 | * we return all items containing NO periods |
858 | 858 | */ |
859 | - public function explode_and_get_items_prefixed_with( $string_to_explode, $prefix ) { |
|
860 | - if( is_string( $string_to_explode ) ) { |
|
861 | - $exploded_contents = explode( ',', $string_to_explode ); |
|
862 | - } else if( is_array( $string_to_explode ) ) { |
|
859 | + public function explode_and_get_items_prefixed_with($string_to_explode, $prefix) { |
|
860 | + if (is_string($string_to_explode)) { |
|
861 | + $exploded_contents = explode(',', $string_to_explode); |
|
862 | + } else if (is_array($string_to_explode)) { |
|
863 | 863 | $exploded_contents = $string_to_explode; |
864 | 864 | } else { |
865 | 865 | $exploded_contents = array(); |
866 | 866 | } |
867 | 867 | //if the string was empty, we want an empty array |
868 | - $exploded_contents = array_filter( $exploded_contents ); |
|
868 | + $exploded_contents = array_filter($exploded_contents); |
|
869 | 869 | $contents_with_prefix = array(); |
870 | - foreach( $exploded_contents as $item ) { |
|
871 | - $item = trim( $item ); |
|
870 | + foreach ($exploded_contents as $item) { |
|
871 | + $item = trim($item); |
|
872 | 872 | //if no prefix was provided, so we look for items with no "." in them |
873 | - if( ! $prefix ) { |
|
873 | + if ( ! $prefix) { |
|
874 | 874 | //does this item have a period? |
875 | - if( strpos( $item, '.' ) === false ) { |
|
875 | + if (strpos($item, '.') === false) { |
|
876 | 876 | //if not, then its what we're looking for |
877 | 877 | $contents_with_prefix[] = $item; |
878 | 878 | } |
879 | - } else if( strpos( $item, $prefix . '.' ) === 0 ) { |
|
879 | + } else if (strpos($item, $prefix.'.') === 0) { |
|
880 | 880 | //this item has the prefix and a period, grab it |
881 | 881 | $contents_with_prefix[] = substr( |
882 | 882 | $item, |
883 | - strpos( $item, $prefix . '.' ) + strlen( $prefix . '.' ) |
|
883 | + strpos($item, $prefix.'.') + strlen($prefix.'.') |
|
884 | 884 | ); |
885 | - } else if( $item === $prefix ) { |
|
885 | + } else if ($item === $prefix) { |
|
886 | 886 | //this item is JUST the prefix |
887 | 887 | //so let's grab everything after, which is a blank string |
888 | 888 | $contents_with_prefix[] = ''; |
@@ -905,33 +905,33 @@ discard block |
||
905 | 905 | * the fields for that model, with the model's name removed from each. |
906 | 906 | * If $include_string was blank or '*' returns an empty array |
907 | 907 | */ |
908 | - public function extract_includes_for_this_model( $include_string, $model_name = null ) { |
|
909 | - if( is_array( $include_string ) ) { |
|
910 | - $include_string = implode( ',', $include_string ); |
|
908 | + public function extract_includes_for_this_model($include_string, $model_name = null) { |
|
909 | + if (is_array($include_string)) { |
|
910 | + $include_string = implode(',', $include_string); |
|
911 | 911 | } |
912 | - if( $include_string === '*' || $include_string === '' ) { |
|
912 | + if ($include_string === '*' || $include_string === '') { |
|
913 | 913 | return array(); |
914 | 914 | } |
915 | - $includes = explode( ',', $include_string ); |
|
915 | + $includes = explode(',', $include_string); |
|
916 | 916 | $extracted_fields_to_include = array(); |
917 | - if( $model_name ){ |
|
918 | - foreach( $includes as $field_to_include ) { |
|
919 | - $field_to_include = trim( $field_to_include ); |
|
920 | - if( strpos( $field_to_include, $model_name . '.' ) === 0 ) { |
|
917 | + if ($model_name) { |
|
918 | + foreach ($includes as $field_to_include) { |
|
919 | + $field_to_include = trim($field_to_include); |
|
920 | + if (strpos($field_to_include, $model_name.'.') === 0) { |
|
921 | 921 | //found the model name at the exact start |
922 | - $field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include ); |
|
922 | + $field_sans_model_name = str_replace($model_name.'.', '', $field_to_include); |
|
923 | 923 | $extracted_fields_to_include[] = $field_sans_model_name; |
924 | - }elseif( $field_to_include == $model_name ){ |
|
924 | + }elseif ($field_to_include == $model_name) { |
|
925 | 925 | $extracted_fields_to_include[] = '*'; |
926 | 926 | } |
927 | 927 | } |
928 | - }else{ |
|
928 | + } else { |
|
929 | 929 | //look for ones with no period |
930 | - foreach( $includes as $field_to_include ) { |
|
931 | - $field_to_include = trim( $field_to_include ); |
|
930 | + foreach ($includes as $field_to_include) { |
|
931 | + $field_to_include = trim($field_to_include); |
|
932 | 932 | if ( |
933 | - strpos( $field_to_include, '.' ) === false |
|
934 | - && ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include ) |
|
933 | + strpos($field_to_include, '.') === false |
|
934 | + && ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include) |
|
935 | 935 | ) { |
936 | 936 | $extracted_fields_to_include[] = $field_to_include; |
937 | 937 | } |