@@ -26,12 +26,12 @@ |
||
26 | 26 | <input type="text" id="ee-google-map-api-key" class="regular-text" name="google_map_api_key" value="<?php echo $map_settings->google_map_api_key; ?>" /> |
27 | 27 | <p class="description"> |
28 | 28 | <?php |
29 | - printf( |
|
30 | - __('An API key is now required to use the Google Maps API: %1$sclick here to get an API key%2$s', 'event_espresso'), |
|
31 | - '<a href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend,geocoding_backend,directions_backend,distance_matrix_backend,elevation_backend,static_maps_backend&keyType=CLIENT_SIDE&reusekey=true" target="_blank">', |
|
32 | - '</a>' |
|
33 | - ); |
|
34 | - ?> |
|
29 | + printf( |
|
30 | + __('An API key is now required to use the Google Maps API: %1$sclick here to get an API key%2$s', 'event_espresso'), |
|
31 | + '<a href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend,geocoding_backend,directions_backend,distance_matrix_backend,elevation_backend,static_maps_backend&keyType=CLIENT_SIDE&reusekey=true" target="_blank">', |
|
32 | + '</a>' |
|
33 | + ); |
|
34 | + ?> |
|
35 | 35 | </p> |
36 | 36 | </td> |
37 | 37 | </tr> |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | </td> |
16 | 16 | </tr> |
17 | 17 | <?php |
18 | - if( apply_filters( 'FHEE__google_map__show_api_key_input', true ) ) { ?> |
|
18 | + if (apply_filters('FHEE__google_map__show_api_key_input', true)) { ?> |
|
19 | 19 | <tr> |
20 | 20 | <th> |
21 | 21 | <label for="ee-google-map-api-key"> |
@@ -110,19 +110,19 @@ discard block |
||
110 | 110 | <td> |
111 | 111 | <label for="event_details_control_type-default" class="ee-admin-radio-lbl"> |
112 | 112 | <?php $checked = $map_settings->event_details_control_type == 'default' ? 'checked="checked"' : ''; ?> |
113 | - <input id="event_details_control_type-default" type="radio" name="event_details_control_type" value="default"<?php echo $checked;?>/> |
|
113 | + <input id="event_details_control_type-default" type="radio" name="event_details_control_type" value="default"<?php echo $checked; ?>/> |
|
114 | 114 | <?php _e(' Default', 'event_espresso') ?> |
115 | 115 | </label> |
116 | 116 | |
117 | 117 | <label for="event_details_control_type-horizontal" class="ee-admin-radio-lbl"> |
118 | 118 | <?php $checked = $map_settings->event_details_control_type == 'horizontal' ? 'checked="checked"' : ''; ?> |
119 | - <input id="event_details_control_type-horizontal" type="radio" name="event_details_control_type" value="horizontal"<?php echo $checked;?>/> |
|
119 | + <input id="event_details_control_type-horizontal" type="radio" name="event_details_control_type" value="horizontal"<?php echo $checked; ?>/> |
|
120 | 120 | <?php _e(' Horizontal', 'event_espresso') ?> |
121 | 121 | </label> |
122 | 122 | |
123 | 123 | <label for="event_details_control_type-dropdown" class="ee-admin-radio-lbl"> |
124 | 124 | <?php $checked = $map_settings->event_details_control_type == 'dropdown' ? 'checked="checked"' : ''; ?> |
125 | - <input id="event_details_control_type-dropdown" type="radio" name="event_details_control_type" value="dropdown"<?php echo $checked;?>/> |
|
125 | + <input id="event_details_control_type-dropdown" type="radio" name="event_details_control_type" value="dropdown"<?php echo $checked; ?>/> |
|
126 | 126 | <?php _e(' Dropdown', 'event_espresso') ?> |
127 | 127 | </label> |
128 | 128 | </td> |
@@ -135,25 +135,25 @@ discard block |
||
135 | 135 | <td> |
136 | 136 | <label for="event_details_map_align-none" class="ee-admin-radio-lbl"> |
137 | 137 | <?php $checked = $map_settings->event_details_map_align == 'none' ? 'checked="checked"' : ''; ?> |
138 | - <input id="event_details_map_align-none" type="radio" name="event_details_map_align" value="none"<?php echo $checked;?>/> |
|
138 | + <input id="event_details_map_align-none" type="radio" name="event_details_map_align" value="none"<?php echo $checked; ?>/> |
|
139 | 139 | <?php _e(' None', 'event_espresso') ?> |
140 | 140 | </label> |
141 | 141 | |
142 | 142 | <label for="event_details_map_align-left" class="ee-admin-radio-lbl"> |
143 | 143 | <?php $checked = $map_settings->event_details_map_align == 'left' ? 'checked="checked"' : ''; ?> |
144 | - <input id="event_details_map_align-left" type="radio" name="event_details_map_align" value="left"<?php echo $checked;?>/> |
|
144 | + <input id="event_details_map_align-left" type="radio" name="event_details_map_align" value="left"<?php echo $checked; ?>/> |
|
145 | 145 | <?php _e(' Align Left', 'event_espresso') ?> |
146 | 146 | </label> |
147 | 147 | |
148 | 148 | <label for="event_details_map_align-center" class="ee-admin-radio-lbl"> |
149 | 149 | <?php $checked = $map_settings->event_details_map_align == 'center' ? 'checked="checked"' : ''; ?> |
150 | - <input id="event_details_map_align-center" type="radio" name="event_details_map_align" value="center"<?php echo $checked;?>/> |
|
150 | + <input id="event_details_map_align-center" type="radio" name="event_details_map_align" value="center"<?php echo $checked; ?>/> |
|
151 | 151 | <?php _e(' Align Center', 'event_espresso') ?> |
152 | 152 | </label> |
153 | 153 | |
154 | 154 | <label for="event_details_map_align-right" class="ee-admin-radio-lbl"> |
155 | 155 | <?php $checked = $map_settings->event_details_map_align == 'right' ? 'checked="checked"' : ''; ?> |
156 | - <input id="event_details_map_align-right" type="radio" name="event_details_map_align" value="right"<?php echo $checked;?>/> |
|
156 | + <input id="event_details_map_align-right" type="radio" name="event_details_map_align" value="right"<?php echo $checked; ?>/> |
|
157 | 157 | <?php _e(' Align Right', 'event_espresso') ?> |
158 | 158 | </label> |
159 | 159 | </td> |
@@ -228,19 +228,19 @@ discard block |
||
228 | 228 | <td> |
229 | 229 | <label for="event_list_control_type-default" class="ee-admin-radio-lbl"> |
230 | 230 | <?php $checked = $map_settings->event_list_control_type == 'default' ? 'checked="checked"' : ''; ?> |
231 | - <input id="event_list_control_type-default" type="radio" name="event_list_control_type" value="default"<?php echo $checked;?>/> |
|
231 | + <input id="event_list_control_type-default" type="radio" name="event_list_control_type" value="default"<?php echo $checked; ?>/> |
|
232 | 232 | <?php _e(' Default', 'event_espresso') ?> |
233 | 233 | </label> |
234 | 234 | |
235 | 235 | <label for="event_list_control_type-horizontal" class="ee-admin-radio-lbl"> |
236 | 236 | <?php $checked = $map_settings->event_list_control_type == 'horizontal' ? 'checked="checked"' : ''; ?> |
237 | - <input id="event_list_control_type-horizontal" type="radio" name="event_list_control_type" value="horizontal"<?php echo $checked;?>/> |
|
237 | + <input id="event_list_control_type-horizontal" type="radio" name="event_list_control_type" value="horizontal"<?php echo $checked; ?>/> |
|
238 | 238 | <?php _e(' Horizontal', 'event_espresso') ?> |
239 | 239 | </label> |
240 | 240 | |
241 | 241 | <label for="event_list_control_type-dropdown" class="ee-admin-radio-lbl"> |
242 | 242 | <?php $checked = $map_settings->event_list_control_type == 'dropdown' ? 'checked="checked"' : ''; ?> |
243 | - <input id="event_list_control_type-dropdown" type="radio" name="event_list_control_type" value="dropdown"<?php echo $checked;?>/> |
|
243 | + <input id="event_list_control_type-dropdown" type="radio" name="event_list_control_type" value="dropdown"<?php echo $checked; ?>/> |
|
244 | 244 | <?php _e(' Dropdown', 'event_espresso') ?> |
245 | 245 | </label> |
246 | 246 | |
@@ -254,25 +254,25 @@ discard block |
||
254 | 254 | <td> |
255 | 255 | <label for="event_list_map_align-none" class="ee-admin-radio-lbl"> |
256 | 256 | <?php $checked = $map_settings->event_list_map_align == 'none' ? 'checked="checked"' : ''; ?> |
257 | - <input id="event_list_map_align-none" type="radio" name="event_list_map_align" value="none"<?php echo $checked;?>/> |
|
257 | + <input id="event_list_map_align-none" type="radio" name="event_list_map_align" value="none"<?php echo $checked; ?>/> |
|
258 | 258 | <?php _e(' None', 'event_espresso') ?> |
259 | 259 | </label> |
260 | 260 | |
261 | 261 | <label for="event_list_map_align-left" class="ee-admin-radio-lbl"> |
262 | 262 | <?php $checked = $map_settings->event_list_map_align == 'left' ? 'checked="checked"' : ''; ?> |
263 | - <input id="event_list_map_align-left" type="radio" name="event_list_map_align" value="left"<?php echo $checked;?>/> |
|
263 | + <input id="event_list_map_align-left" type="radio" name="event_list_map_align" value="left"<?php echo $checked; ?>/> |
|
264 | 264 | <?php _e(' Align Left', 'event_espresso') ?> |
265 | 265 | </label> |
266 | 266 | |
267 | 267 | <label for="event_list_map_align-center" class="ee-admin-radio-lbl"> |
268 | 268 | <?php $checked = $map_settings->event_list_map_align == 'center' ? 'checked="checked"' : ''; ?> |
269 | - <input id="event_list_map_align-center" type="radio" name="event_list_map_align" value="center"<?php echo $checked;?>/> |
|
269 | + <input id="event_list_map_align-center" type="radio" name="event_list_map_align" value="center"<?php echo $checked; ?>/> |
|
270 | 270 | <?php _e(' Align Center', 'event_espresso') ?> |
271 | 271 | </label> |
272 | 272 | |
273 | 273 | <label for="event_list_map_align-right" class="ee-admin-radio-lbl"> |
274 | 274 | <?php $checked = $map_settings->event_list_map_align == 'right' ? 'checked="checked"' : ''; ?> |
275 | - <input id="event_list_map_align-right" type="radio" name="event_list_map_align" value="right"<?php echo $checked;?>/> |
|
275 | + <input id="event_list_map_align-right" type="radio" name="event_list_map_align" value="right"<?php echo $checked; ?>/> |
|
276 | 276 | <?php _e(' Align Right', 'event_espresso') ?> |
277 | 277 | </label> |
278 | 278 |
@@ -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,81 +291,81 @@ 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 | - $event_url = apply_filters( 'FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event ); |
|
347 | - echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a' . $len_class . '" href="' . $event_url . '">' . $event->name() . '</a></h5>'; |
|
348 | - if ( post_password_required( $event->ID() ) ) { |
|
349 | - $pswd_form = apply_filters( 'FHEE_EEW_Upcoming_Events__widget__password_form', get_the_password_form( $event->ID() ), $event ); |
|
346 | + $event_url = apply_filters('FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event); |
|
347 | + echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a'.$len_class.'" href="'.$event_url.'">'.$event->name().'</a></h5>'; |
|
348 | + if (post_password_required($event->ID())) { |
|
349 | + $pswd_form = apply_filters('FHEE_EEW_Upcoming_Events__widget__password_form', get_the_password_form($event->ID()), $event); |
|
350 | 350 | echo $pswd_form; |
351 | 351 | } else { |
352 | - if ( has_post_thumbnail( $event->ID() ) && $image_size != 'none' ) { |
|
353 | - echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="' . $event_url . '">' . get_the_post_thumbnail( $event->ID(), $image_size ) . '</a></div>'; |
|
352 | + if (has_post_thumbnail($event->ID()) && $image_size != 'none') { |
|
353 | + echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="'.$event_url.'">'.get_the_post_thumbnail($event->ID(), $image_size).'</a></div>'; |
|
354 | 354 | } |
355 | - $desc = $event->short_description( 25 ); |
|
356 | - if ( $show_dates ) { |
|
357 | - $date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', get_option( 'date_format' )); |
|
358 | - $time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', get_option( 'time_format' )); |
|
359 | - $single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', get_option( 'date_format' )); |
|
360 | - $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', get_option( 'time_format' )); |
|
361 | - if ( $date_range == TRUE ) { |
|
362 | - echo espresso_event_date_range( $date_format, $time_format, $single_date_format, $single_time_format, $event->ID() ); |
|
363 | - }else{ |
|
364 | - echo espresso_list_of_event_dates( $event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit ); |
|
355 | + $desc = $event->short_description(25); |
|
356 | + if ($show_dates) { |
|
357 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', get_option('date_format')); |
|
358 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', get_option('time_format')); |
|
359 | + $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', get_option('date_format')); |
|
360 | + $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', get_option('time_format')); |
|
361 | + if ($date_range == TRUE) { |
|
362 | + echo espresso_event_date_range($date_format, $time_format, $single_date_format, $single_time_format, $event->ID()); |
|
363 | + } else { |
|
364 | + echo espresso_list_of_event_dates($event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit); |
|
365 | 365 | } |
366 | 366 | } |
367 | - if ( $show_desc && $desc ) { |
|
368 | - echo '<p style="margin-top: .5em">' . $desc . '</p>'; |
|
367 | + if ($show_desc && $desc) { |
|
368 | + echo '<p style="margin-top: .5em">'.$desc.'</p>'; |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | echo '</li>'; |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * @return string |
390 | 390 | */ |
391 | 391 | public function make_the_title_a_link($title) { |
392 | - return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
392 | + return '<a href="'.EEH_Event_View::event_archive_url().'">'.$title.'</a>'; |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -360,7 +362,7 @@ discard block |
||
360 | 362 | $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', get_option( 'time_format' )); |
361 | 363 | if ( $date_range == TRUE ) { |
362 | 364 | echo espresso_event_date_range( $date_format, $time_format, $single_date_format, $single_time_format, $event->ID() ); |
363 | - }else{ |
|
365 | + } else{ |
|
364 | 366 | echo espresso_list_of_event_dates( $event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit ); |
365 | 367 | } |
366 | 368 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EE_PMT_Paypal_Pro extends EE_PMT_Base{ |
|
28 | +class EE_PMT_Paypal_Pro extends EE_PMT_Base { |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @param EE_Payment_Method $pm_instance |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | require_once($this->file_folder().'EEG_Paypal_Pro.gateway.php'); |
36 | 36 | $this->_gateway = new EEG_Paypal_Pro(); |
37 | 37 | $this->_pretty_name = __("Paypal Pro", 'event_espresso'); |
38 | - $this->_default_description = __( 'Please provide the following billing information.', 'event_espresso' ); |
|
38 | + $this->_default_description = __('Please provide the following billing information.', 'event_espresso'); |
|
39 | 39 | $this->_requires_https = true; |
40 | 40 | parent::__construct($pm_instance); |
41 | 41 | } |
@@ -51,21 +51,21 @@ discard block |
||
51 | 51 | 'extra_meta_inputs'=>array( |
52 | 52 | // 'paypal_email'=>new EE_Email_Input(), not actually used |
53 | 53 | 'username'=>new EE_Text_Input(array( |
54 | - 'html_label_text'=> sprintf(__("Paypal API Username %s", "event_espresso"),$this->get_help_tab_link()), |
|
54 | + 'html_label_text'=> sprintf(__("Paypal API Username %s", "event_espresso"), $this->get_help_tab_link()), |
|
55 | 55 | 'required' => true |
56 | 56 | )), |
57 | 57 | 'password'=>new EE_Text_Input(array( |
58 | - 'html_label_text'=> sprintf(__("Paypal API Password %s", "event_espresso"),$this->get_help_tab_link()), |
|
58 | + 'html_label_text'=> sprintf(__("Paypal API Password %s", "event_espresso"), $this->get_help_tab_link()), |
|
59 | 59 | 'required' => true |
60 | 60 | )), |
61 | 61 | 'signature'=>new EE_Text_Input(array( |
62 | - 'html_label_text'=> sprintf(__("Paypal API Signature %s", "event_espresso"),$this->get_help_tab_link()), |
|
62 | + 'html_label_text'=> sprintf(__("Paypal API Signature %s", "event_espresso"), $this->get_help_tab_link()), |
|
63 | 63 | 'required' => true |
64 | 64 | )), |
65 | 65 | 'credit_card_types'=>new EE_Checkbox_Multi_Input( |
66 | 66 | $this->card_types_supported(), |
67 | 67 | array( |
68 | - 'html_label_text' => __( 'Card Types Supported', 'event_espresso' ), |
|
68 | + 'html_label_text' => __('Card Types Supported', 'event_espresso'), |
|
69 | 69 | 'required' => true )), |
70 | 70 | ) |
71 | 71 | ) |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | * @throws \EE_Error |
80 | 80 | * @return EE_Billing_Info_Form |
81 | 81 | */ |
82 | - public function generate_new_billing_form( EE_Transaction $transaction = NULL ) { |
|
83 | - $allowed_types = $this->_pm_instance->get_extra_meta( 'credit_card_types', TRUE ); |
|
82 | + public function generate_new_billing_form(EE_Transaction $transaction = NULL) { |
|
83 | + $allowed_types = $this->_pm_instance->get_extra_meta('credit_card_types', TRUE); |
|
84 | 84 | //if allowed types is a string or empty array or null... |
85 | - if( empty( $allowed_types )) { |
|
85 | + if (empty($allowed_types)) { |
|
86 | 86 | $allowed_types = array(); |
87 | 87 | } |
88 | 88 | |
@@ -93,26 +93,26 @@ discard block |
||
93 | 93 | // 'html_id'=> 'ee-Paypal_Pro-billing-form', |
94 | 94 | 'subsections'=>array( |
95 | 95 | 'credit_card'=>new EE_Credit_Card_Input( |
96 | - array( 'required'=>TRUE, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __( 'Card Number', 'event_espresso' )) |
|
96 | + array('required'=>TRUE, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Number', 'event_espresso')) |
|
97 | 97 | ), |
98 | 98 | 'credit_card_type'=>new EE_Select_Input( |
99 | 99 | //the options are set dynamically |
100 | - array_intersect_key( EE_PMT_Paypal_Pro::card_types_supported(), array_flip( $allowed_types )), |
|
101 | - array( 'required'=>TRUE, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __( 'Card Type', 'event_espresso' )) |
|
100 | + array_intersect_key(EE_PMT_Paypal_Pro::card_types_supported(), array_flip($allowed_types)), |
|
101 | + array('required'=>TRUE, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Type', 'event_espresso')) |
|
102 | 102 | ), |
103 | 103 | 'exp_month'=>new EE_Credit_Card_Month_Input( |
104 | - TRUE, array( 'required'=>TRUE, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __( 'Expiry Month', 'event_espresso' ) ) |
|
104 | + TRUE, array('required'=>TRUE, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Month', 'event_espresso')) |
|
105 | 105 | ), |
106 | 106 | 'exp_year'=>new EE_Credit_Card_Year_Input( |
107 | - array( 'required'=>TRUE, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __( 'Expiry Year', 'event_espresso' ) ) |
|
107 | + array('required'=>TRUE, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Year', 'event_espresso')) |
|
108 | 108 | ), |
109 | 109 | 'cvv'=>new EE_CVV_Input( |
110 | - array( 'required'=>TRUE, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __( 'CVV', 'event_espresso' ) ) |
|
110 | + array('required'=>TRUE, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('CVV', 'event_espresso')) |
|
111 | 111 | ), |
112 | 112 | ) |
113 | 113 | ) |
114 | 114 | ); |
115 | - return $this->apply_billing_form_debug_settings( $billing_form ); |
|
115 | + return $this->apply_billing_form_debug_settings($billing_form); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -124,19 +124,19 @@ discard block |
||
124 | 124 | * @param \EE_Billing_Info_Form $billing_form |
125 | 125 | * @return \EE_Billing_Info_Form |
126 | 126 | */ |
127 | - public function apply_billing_form_debug_settings( EE_Billing_Info_Form $billing_form ) { |
|
128 | - if ( $this->_pm_instance->debug_mode() ) { |
|
127 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) { |
|
128 | + if ($this->_pm_instance->debug_mode()) { |
|
129 | 129 | $billing_form->add_subsections( |
130 | - array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ), |
|
130 | + array('fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html()), |
|
131 | 131 | 'credit_card' |
132 | 132 | ); |
133 | 133 | $billing_form->add_subsections( |
134 | - array( 'debug_content' => new EE_Form_Section_HTML_From_Template( dirname(__FILE__).DS.'templates'.DS.'paypal_pro_debug_info.template.php' )), |
|
134 | + array('debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__).DS.'templates'.DS.'paypal_pro_debug_info.template.php')), |
|
135 | 135 | 'first_name' |
136 | 136 | ); |
137 | - $billing_form->get_input( 'credit_card_type' )->set_default( 'Visa' ); |
|
138 | - $billing_form->get_input( 'exp_year' )->set_default( 2018); |
|
139 | - $billing_form->get_input( 'cvv' )->set_default( '115' ); |
|
137 | + $billing_form->get_input('credit_card_type')->set_default('Visa'); |
|
138 | + $billing_form->get_input('exp_year')->set_default(2018); |
|
139 | + $billing_form->get_input('cvv')->set_default('115'); |
|
140 | 140 | } |
141 | 141 | return $billing_form; |
142 | 142 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * Keys are their values, values are their pretty names. |
149 | 149 | * @return array |
150 | 150 | */ |
151 | - public static function card_types_supported(){ |
|
151 | + public static function card_types_supported() { |
|
152 | 152 | return array( |
153 | 153 | 'Visa'=> __("Visa", 'event_espresso'), |
154 | 154 | 'MasterCard'=> __("MasterCard", 'event_espresso'), |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @see EE_PMT_Base::help_tabs_config() |
165 | 165 | * @return array |
166 | 166 | */ |
167 | - public function help_tabs_config(){ |
|
167 | + public function help_tabs_config() { |
|
168 | 168 | return array( |
169 | 169 | $this->get_help_tab_name() => array( |
170 | 170 | 'title' => __('PayPal Pro Settings', 'event_espresso'), |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | * @param EE_Billing_Info_Form $billing_form |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - protected function _get_billing_values_from_form( $billing_form ){ |
|
183 | - $billing_values = parent::_get_billing_values_from_form( $billing_form ); |
|
184 | - $billing_values[ 'country' ] = $billing_form->get_input_value( 'country' ); |
|
185 | - $billing_values[ 'credit_card_type' ] = $billing_form->get_input_value( 'credit_card_type' ); |
|
182 | + protected function _get_billing_values_from_form($billing_form) { |
|
183 | + $billing_values = parent::_get_billing_values_from_form($billing_form); |
|
184 | + $billing_values['country'] = $billing_form->get_input_value('country'); |
|
185 | + $billing_values['credit_card_type'] = $billing_form->get_input_value('credit_card_type'); |
|
186 | 186 | return $billing_values; |
187 | 187 | } |
188 | 188 |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * Event Espresso |
@@ -3,35 +3,35 @@ |
||
3 | 3 | <br/> |
4 | 4 | <?php //echo EEH_Debug_Tools::printr( $event_attendees, 'event_attendees' ); ?> |
5 | 5 | <?php echo $attendee_notice; ?> |
6 | -<?php if ( !empty($attendees) ) : ?> |
|
6 | +<?php if ( ! empty($attendees)) : ?> |
|
7 | 7 | <div class="admin-primary-mbox-tbl-wrap"> |
8 | 8 | <table class="admin-primary-mbox-tbl"> |
9 | 9 | <thead> |
10 | 10 | <tr> |
11 | - <th class="jst-left"><?php _e( '#', 'event_espresso' );?></th> |
|
12 | - <th class="jst-left"><?php _e( 'Event Name', 'event_espresso' );?></th> |
|
13 | - <th class="jst-left"><?php _e( 'Attendee', 'event_espresso' );?></th> |
|
14 | - <th class="jst-rght"><?php _e( 'Price Paid', 'event_espresso' );?></th> |
|
15 | - <th class="jst-left"><?php _e( 'Email', 'event_espresso' );?></th> |
|
16 | - <th class="jst-left"><?php _e( 'Address', 'event_espresso' );?></th> |
|
17 | - <!--<th class="jst-cntr"><?php _e( 'Actions', 'event_espresso' );?></th>--> |
|
11 | + <th class="jst-left"><?php _e('#', 'event_espresso'); ?></th> |
|
12 | + <th class="jst-left"><?php _e('Event Name', 'event_espresso'); ?></th> |
|
13 | + <th class="jst-left"><?php _e('Attendee', 'event_espresso'); ?></th> |
|
14 | + <th class="jst-rght"><?php _e('Price Paid', 'event_espresso'); ?></th> |
|
15 | + <th class="jst-left"><?php _e('Email', 'event_espresso'); ?></th> |
|
16 | + <th class="jst-left"><?php _e('Address', 'event_espresso'); ?></th> |
|
17 | + <!--<th class="jst-cntr"><?php _e('Actions', 'event_espresso'); ?></th>--> |
|
18 | 18 | </tr> |
19 | 19 | </thead> |
20 | 20 | <tbody> |
21 | 21 | |
22 | - <?php foreach ( $attendees as $att_nmbr => $attendee ) : ?> |
|
22 | + <?php foreach ($attendees as $att_nmbr => $attendee) : ?> |
|
23 | 23 | |
24 | 24 | <tr> |
25 | - <td class="jst-left"><?php echo $att_nmbr;?></td> |
|
26 | - <td class="jst-left"><?php echo $attendee['event_name'];?></td> |
|
25 | + <td class="jst-left"><?php echo $att_nmbr; ?></td> |
|
26 | + <td class="jst-left"><?php echo $attendee['event_name']; ?></td> |
|
27 | 27 | <td class="jst-left"> |
28 | - <a href="<?php echo $attendee['att_link']; ?>" title="<?php esc_attr_e( 'View details for this attendee', 'event_espresso' );?>"> |
|
29 | - <?php echo $attendee['fname'] . ' ' . $attendee['lname'];?> |
|
28 | + <a href="<?php echo $attendee['att_link']; ?>" title="<?php esc_attr_e('View details for this attendee', 'event_espresso'); ?>"> |
|
29 | + <?php echo $attendee['fname'].' '.$attendee['lname']; ?> |
|
30 | 30 | </a> |
31 | 31 | </td> |
32 | - <td class="jst-rght"><?php echo $currency_sign . ' ' . number_format( $attendee['final_price'], 2 );?></td> |
|
33 | - <td class="jst-left"><?php echo $attendee['email'];?></td> |
|
34 | - <td class="jst-left"><?php echo $attendee['address'];?></td> |
|
32 | + <td class="jst-rght"><?php echo $currency_sign.' '.number_format($attendee['final_price'], 2); ?></td> |
|
33 | + <td class="jst-left"><?php echo $attendee['email']; ?></td> |
|
34 | + <td class="jst-left"><?php echo $attendee['address']; ?></td> |
|
35 | 35 | <!--<th class="jst-cntr">view</th>--> |
36 | 36 | </tr> |
37 | 37 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
3 | 3 | |
4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | self::$_field_calculator = new Calculated_Model_Fields(); |
38 | - return parent::get_instance( __CLASS__ ); |
|
38 | + return parent::get_instance(__CLASS__); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | |
66 | 66 | |
67 | 67 | public static function set_hooks_both() { |
68 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
69 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
70 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
71 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
68 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
69 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
70 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
71 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
72 | 72 | EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
73 | 73 | } |
74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * Loads all the hooks which make requests to old versions of the API |
88 | 88 | * appear the same as they always did |
89 | 89 | */ |
90 | - public static function set_hooks_for_changes(){ |
|
90 | + public static function set_hooks_for_changes() { |
|
91 | 91 | self::_set_hooks_for_changes(); |
92 | 92 | } |
93 | 93 | |
@@ -97,27 +97,27 @@ discard block |
||
97 | 97 | * replace it with application passwords. |
98 | 98 | */ |
99 | 99 | public static function maybe_notify_of_basic_auth_removal() { |
100 | - if( ! isset( $_SERVER['PHP_AUTH_USER'] ) |
|
101 | - && ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) ) { |
|
100 | + if ( ! isset($_SERVER['PHP_AUTH_USER']) |
|
101 | + && ! isset($_SERVER['HTTP_AUTHORIZATION'])) { |
|
102 | 102 | //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
103 | 103 | return; |
104 | 104 | } |
105 | 105 | //ok they're using the WP API with Basic Auth |
106 | 106 | $message = sprintf( |
107 | - __( 'We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso' ), |
|
107 | + __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso'), |
|
108 | 108 | '<a href="https://wordpress.org/plugins/application-passwords/">', |
109 | 109 | '</a>', |
110 | 110 | '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
111 | 111 | '<br/>' |
112 | 112 | ); |
113 | - EE_Error::add_persistent_admin_notice( 'using_basic_auth', $message ); |
|
114 | - if( ! get_option( 'ee_notified_admin_on_basic_auth_removal', false ) ) { |
|
115 | - add_option( 'ee_notified_admin_on_basic_auth_removal', true ); |
|
113 | + EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
114 | + if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
115 | + add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
116 | 116 | //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
117 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
117 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
118 | 118 | //and send the message to the site admin too |
119 | - wp_mail( get_option( 'admin_email' ), __( 'Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso' ), $message ); |
|
120 | - remove_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
119 | + wp_mail(get_option('admin_email'), __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
120 | + remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | /** |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | * appear the same as they always did |
126 | 126 | */ |
127 | 127 | protected static function _set_hooks_for_changes() { |
128 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
129 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
128 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
129 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
130 | 130 | //ignore the base parent class |
131 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
131 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
132 | 132 | continue; |
133 | 133 | } |
134 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
135 | - if ( class_exists( $full_classname )) { |
|
134 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
135 | + if (class_exists($full_classname)) { |
|
136 | 136 | $instance_of_class = new $full_classname; |
137 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
137 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
138 | 138 | $instance_of_class->set_hooks(); |
139 | 139 | } |
140 | 140 | } |
@@ -147,16 +147,16 @@ discard block |
||
147 | 147 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
148 | 148 | */ |
149 | 149 | public static function register_routes() { |
150 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
151 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
152 | - foreach( $routes as $route ) { |
|
150 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
151 | + foreach ($relative_urls as $endpoint => $routes) { |
|
152 | + foreach ($routes as $route) { |
|
153 | 153 | register_rest_route( |
154 | 154 | $namespace, |
155 | 155 | $endpoint, |
156 | 156 | array( |
157 | - 'callback' => $route[ 'callback' ], |
|
158 | - 'methods' => $route[ 'methods' ], |
|
159 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
157 | + 'callback' => $route['callback'], |
|
158 | + 'methods' => $route['methods'], |
|
159 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
160 | 160 | ) |
161 | 161 | ); |
162 | 162 | } |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | * next time the WP API is used |
171 | 171 | */ |
172 | 172 | public static function invalidate_cached_route_data_on_version_change() { |
173 | - if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) { |
|
173 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
174 | 174 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
175 | 175 | } |
176 | - foreach( EE_Registry::instance()->addons as $addon ){ |
|
177 | - if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) { |
|
176 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
177 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
178 | 178 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
179 | 179 | } |
180 | 180 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public static function invalidate_cached_route_data() { |
187 | 187 | //delete the saved EE REST API routes |
188 | - delete_option( EED_Core_Rest_Api::saved_routes_option_names ); |
|
188 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public static function get_ee_route_data() { |
200 | 200 | $ee_routes = array(); |
201 | - foreach( self::versions_served() as $version => $hidden_endpoints ) { |
|
202 | - $ee_routes[ self::ee_api_namespace . $version ] = self::_get_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
201 | + foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
202 | + $ee_routes[self::ee_api_namespace.$version] = self::_get_ee_route_data_for_version($version, $hidden_endpoints); |
|
203 | 203 | } |
204 | 204 | return $ee_routes; |
205 | 205 | } |
@@ -211,10 +211,10 @@ discard block |
||
211 | 211 | * @param boolean $hidden_endpoints |
212 | 212 | * @return array |
213 | 213 | */ |
214 | - protected static function _get_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
215 | - $ee_routes = get_option( self::saved_routes_option_names . $version , null ); |
|
216 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
217 | - $ee_routes = self::_save_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
214 | + protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
215 | + $ee_routes = get_option(self::saved_routes_option_names.$version, null); |
|
216 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
217 | + $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
218 | 218 | } |
219 | 219 | return $ee_routes; |
220 | 220 | } |
@@ -228,18 +228,18 @@ discard block |
||
228 | 228 | * @param boolean $hidden_endpoints |
229 | 229 | * @return mixed|null|void |
230 | 230 | */ |
231 | - protected static function _save_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
231 | + protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
232 | 232 | $instance = self::instance(); |
233 | 233 | $routes = apply_filters( |
234 | 234 | 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
235 | 235 | array_replace_recursive( |
236 | - $instance->_get_config_route_data_for_version( $version, $hidden_endpoints ), |
|
237 | - $instance->_get_meta_route_data_for_version( $version, $hidden_endpoints ), |
|
238 | - $instance->_get_model_route_data_for_version( $version, $hidden_endpoints ), |
|
239 | - $instance->_get_rpc_route_data_for_version( $version, $hidden_endpoints ) |
|
236 | + $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
237 | + $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
238 | + $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
239 | + $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
240 | 240 | ) |
241 | 241 | ); |
242 | - update_option( self::saved_routes_option_names . $version, $routes, true ); |
|
242 | + update_option(self::saved_routes_option_names.$version, $routes, true); |
|
243 | 243 | return $routes; |
244 | 244 | } |
245 | 245 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @return void |
251 | 251 | */ |
252 | 252 | public static function save_ee_routes() { |
253 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
253 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
254 | 254 | $instance = self::instance(); |
255 | 255 | $routes = apply_filters( |
256 | 256 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $instance->_register_rpc_routes() |
262 | 262 | ) |
263 | 263 | ); |
264 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
264 | + update_option(self::saved_routes_option_names, $routes, true); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | */ |
273 | 273 | protected function _register_model_routes() { |
274 | 274 | $model_routes = array( ); |
275 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
276 | - $model_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
275 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
276 | + $model_routes[EED_Core_Rest_Api::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
277 | 277 | } |
278 | 278 | return $model_routes; |
279 | 279 | } |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | * @param boolean $hidden_endpoint |
285 | 285 | * @return array |
286 | 286 | */ |
287 | - protected function _get_model_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
288 | - $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info( $version ); |
|
287 | + protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) { |
|
288 | + $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
289 | 289 | $models_to_register = apply_filters( |
290 | 290 | 'FHEE__EED_Core_REST_API___register_model_routes', |
291 | 291 | $model_version_info->models_for_requested_version() |
@@ -294,21 +294,21 @@ discard block |
||
294 | 294 | unset($models_to_register['Extra_Meta']); |
295 | 295 | unset($models_to_register['Extra_Join']); |
296 | 296 | $model_routes = array(); |
297 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
298 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
297 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
298 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
299 | 299 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
300 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
301 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
302 | - $model_routes[ $plural_model_route ] = array( |
|
300 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
301 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
302 | + $model_routes[$plural_model_route] = array( |
|
303 | 303 | array( |
304 | 304 | 'callback' => array( |
305 | 305 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
306 | 306 | 'handle_request_get_all' ), |
307 | 307 | 'methods' => WP_REST_Server::READABLE, |
308 | 308 | 'hidden_endpoint' => $hidden_endpoint, |
309 | - 'args' => $this->_get_read_query_params( $model, $version ), |
|
309 | + 'args' => $this->_get_read_query_params($model, $version), |
|
310 | 310 | '_links' => array( |
311 | - 'self' => rest_url( EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route ), |
|
311 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route), |
|
312 | 312 | ) |
313 | 313 | ), |
314 | 314 | // array( |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | // 'hidden_endpoint' => $hidden_endpoint |
320 | 320 | // ) |
321 | 321 | ); |
322 | - $model_routes[ $singular_model_route ] = array( |
|
322 | + $model_routes[$singular_model_route] = array( |
|
323 | 323 | array( |
324 | 324 | 'callback' => array( |
325 | 325 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
326 | 326 | 'handle_request_get_one' ), |
327 | 327 | 'methods' => WP_REST_Server::READABLE, |
328 | 328 | 'hidden_endpoint' => $hidden_endpoint, |
329 | - 'args' => $this->_get_response_selection_query_params( $model, $version) |
|
329 | + 'args' => $this->_get_response_selection_query_params($model, $version) |
|
330 | 330 | ), |
331 | 331 | // array( |
332 | 332 | // 'callback' => array( |
@@ -337,19 +337,19 @@ discard block |
||
337 | 337 | // ), |
338 | 338 | ); |
339 | 339 | //@todo: also handle DELETE for a single item |
340 | - foreach ( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
340 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
341 | 341 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
342 | 342 | $relation_name, |
343 | 343 | $relation_obj |
344 | 344 | ); |
345 | - $model_routes[ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
345 | + $model_routes[$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
346 | 346 | array( |
347 | 347 | 'callback' => array( |
348 | 348 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
349 | 349 | 'handle_request_get_related' ), |
350 | 350 | 'methods' => WP_REST_Server::READABLE, |
351 | 351 | 'hidden_endpoint' => $hidden_endpoint, |
352 | - 'args' => $this->_get_read_query_params( $relation_obj->get_other_model(), $version ), |
|
352 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
353 | 353 | ), |
354 | 354 | // array( |
355 | 355 | // 'callback' => array( |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | */ |
373 | 373 | protected function _register_rpc_routes() { |
374 | 374 | $routes = array(); |
375 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
376 | - $routes[ self::ee_api_namespace . $version ] = $this->_get_rpc_route_data_for_version( $version, $hidden_endpoint ); |
|
375 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
376 | + $routes[self::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version($version, $hidden_endpoint); |
|
377 | 377 | } |
378 | 378 | return $routes; |
379 | 379 | } |
@@ -384,10 +384,10 @@ discard block |
||
384 | 384 | * @param boolean $hidden_endpoint |
385 | 385 | * @return array |
386 | 386 | */ |
387 | - protected function _get_rpc_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
387 | + protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) { |
|
388 | 388 | $this_versions_routes = array(); |
389 | 389 | //checkin endpoint |
390 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
390 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
391 | 391 | array( |
392 | 392 | 'callback' => array( |
393 | 393 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | 'force' => array( |
399 | 399 | 'required' => false, |
400 | 400 | 'default' => false, |
401 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
401 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
402 | 402 | ) |
403 | 403 | ) |
404 | 404 | ) |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @param string $version |
418 | 418 | * @return array |
419 | 419 | */ |
420 | - protected function _get_response_selection_query_params( \EEM_Base $model, $version ) { |
|
420 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) { |
|
421 | 421 | return apply_filters( |
422 | 422 | 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
423 | 423 | array( |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | 'calculate' => array( |
429 | 429 | 'required' => false, |
430 | 430 | 'default' => '', |
431 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model( $model ) |
|
431 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model) |
|
432 | 432 | ) |
433 | 433 | ), |
434 | 434 | $model, |
@@ -446,13 +446,13 @@ discard block |
||
446 | 446 | * @return array describing the args acceptable when querying this model |
447 | 447 | * @throws \EE_Error |
448 | 448 | */ |
449 | - protected function _get_read_query_params( \EEM_Base $model, $version ) { |
|
449 | + protected function _get_read_query_params(\EEM_Base $model, $version) { |
|
450 | 450 | $default_orderby = array(); |
451 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
452 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
451 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
452 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
453 | 453 | } |
454 | 454 | return array_merge( |
455 | - $this->_get_response_selection_query_params( $model, $version ), |
|
455 | + $this->_get_response_selection_query_params($model, $version), |
|
456 | 456 | array( |
457 | 457 | 'where' => array( |
458 | 458 | 'required' => false, |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | */ |
490 | 490 | protected function _register_config_routes() { |
491 | 491 | $config_routes = array(); |
492 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
493 | - $config_routes[ self::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
492 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
493 | + $config_routes[self::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
494 | 494 | } |
495 | 495 | return $config_routes; |
496 | 496 | } |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @param boolean $hidden_endpoint |
502 | 502 | * @return array |
503 | 503 | */ |
504 | - protected function _get_config_route_data_for_version( $version, $hidden_endpoint ) { |
|
504 | + protected function _get_config_route_data_for_version($version, $hidden_endpoint) { |
|
505 | 505 | return array( |
506 | 506 | 'config' => array( |
507 | 507 | array( |
@@ -522,8 +522,8 @@ discard block |
||
522 | 522 | */ |
523 | 523 | protected function _register_meta_routes() { |
524 | 524 | $meta_routes = array(); |
525 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
526 | - $meta_routes[ self::ee_api_namespace . $version ] = $this->_get_meta_route_data_for_version( $version, $hidden_endpoint ); |
|
525 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
526 | + $meta_routes[self::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version($version, $hidden_endpoint); |
|
527 | 527 | } |
528 | 528 | return $meta_routes; |
529 | 529 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * @param boolean $hidden_endpoint |
535 | 535 | * @return array |
536 | 536 | */ |
537 | - protected function _get_meta_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
537 | + protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) { |
|
538 | 538 | return array( |
539 | 539 | 'resources' => array( |
540 | 540 | array( |
@@ -556,25 +556,25 @@ discard block |
||
556 | 556 | * @param array $route_data |
557 | 557 | * @return array |
558 | 558 | */ |
559 | - public static function hide_old_endpoints( $route_data ) { |
|
559 | + public static function hide_old_endpoints($route_data) { |
|
560 | 560 | //allow API clients to override which endpoints get hidden, in case |
561 | 561 | //they want to discover particular endpoints |
562 | 562 | //also, we don't have access to the request so we have to just grab it from the superglobal |
563 | 563 | $force_show_ee_namespace = ltrim( |
564 | - EEH_Array::is_set( $_REQUEST, 'force_show_ee_namespace', '' ), |
|
564 | + EEH_Array::is_set($_REQUEST, 'force_show_ee_namespace', ''), |
|
565 | 565 | '/' |
566 | 566 | ); |
567 | 567 | |
568 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
569 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
570 | - foreach( $routes as $route ) { |
|
568 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
569 | + foreach ($relative_urls as $endpoint => $routes) { |
|
570 | + foreach ($routes as $route) { |
|
571 | 571 | //by default, hide "hidden_endpoint"s, unless the request indicates |
572 | 572 | //to $force_show_ee_namespace, in which case only show that one |
573 | 573 | //namespace's endpoints (and hide all others) |
574 | - if( ( $route[ 'hidden_endpoint' ] && $force_show_ee_namespace === '' ) |
|
575 | - || ( $force_show_ee_namespace !== null && $force_show_ee_namespace !== $namespace ) ) { |
|
576 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
577 | - unset( $route_data[ $full_route ] ); |
|
574 | + if (($route['hidden_endpoint'] && $force_show_ee_namespace === '') |
|
575 | + || ($force_show_ee_namespace !== null && $force_show_ee_namespace !== $namespace)) { |
|
576 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
577 | + unset($route_data[$full_route]); |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | } |
@@ -613,8 +613,8 @@ discard block |
||
613 | 613 | */ |
614 | 614 | public static function latest_rest_api_version() { |
615 | 615 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
616 | - $versions_served_keys = array_keys( $versions_served ); |
|
617 | - return end( $versions_served_keys ); |
|
616 | + $versions_served_keys = array_keys($versions_served); |
|
617 | + return end($versions_served_keys); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | /** |
@@ -628,32 +628,32 @@ discard block |
||
628 | 628 | public static function versions_served() { |
629 | 629 | $versions_served = array(); |
630 | 630 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
631 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
632 | - reset( $possibly_served_versions ); |
|
633 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
634 | - $latest_version = end( $versions_served_historically ); |
|
635 | - reset( $versions_served_historically ); |
|
631 | + $lowest_compatible_version = end($possibly_served_versions); |
|
632 | + reset($possibly_served_versions); |
|
633 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
634 | + $latest_version = end($versions_served_historically); |
|
635 | + reset($versions_served_historically); |
|
636 | 636 | //for each version of core we have ever served: |
637 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
637 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
638 | 638 | //if it's not above the current core version, and it's compatible with the current version of core |
639 | - if( $key_versioned_endpoint == $latest_version ) { |
|
639 | + if ($key_versioned_endpoint == $latest_version) { |
|
640 | 640 | //don't hide the latest version in the index |
641 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
642 | - } else if( |
|
641 | + $versions_served[$key_versioned_endpoint] = false; |
|
642 | + } else if ( |
|
643 | 643 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
644 | 644 | && $key_versioned_endpoint >= $lowest_compatible_version |
645 | 645 | ) { |
646 | 646 | //include, but hide, previous versions which are still supported |
647 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
648 | - } elseif( |
|
647 | + $versions_served[$key_versioned_endpoint] = true; |
|
648 | + } elseif ( |
|
649 | 649 | apply_filters( |
650 | 650 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
651 | 651 | false, |
652 | 652 | $possibly_served_versions |
653 | 653 | ) |
654 | - ){ |
|
654 | + ) { |
|
655 | 655 | //if a version is no longer supported, don't include it in index or list of versions served |
656 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
656 | + $versions_served[$key_versioned_endpoint] = true; |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | return $versions_served; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * @return string |
667 | 667 | */ |
668 | 668 | public static function core_version() { |
669 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
669 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | * @param WP $WP |
692 | 692 | * @return void |
693 | 693 | */ |
694 | - public function run( $WP ) { |
|
694 | + public function run($WP) { |
|
695 | 695 | |
696 | 696 | } |
697 | 697 |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | * @return void |
881 | 881 | */ |
882 | 882 | public function deactivate_messenger( $messenger_name ) { |
883 | - $this->_initialize_collections(); |
|
884 | - if ( $messenger_name instanceof EE_messenger ) { |
|
883 | + $this->_initialize_collections(); |
|
884 | + if ( $messenger_name instanceof EE_messenger ) { |
|
885 | 885 | $messenger_name = $messenger_name->name; |
886 | 886 | } |
887 | 887 | unset( $this->_active_messengers[ $messenger_name ] ); |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | * @param string $message_type_name name of message type being deactivated |
898 | 898 | */ |
899 | 899 | public function deactivate_message_type( $message_type_name ) { |
900 | - $this->_initialize_collections(); |
|
900 | + $this->_initialize_collections(); |
|
901 | 901 | if ( $message_type_name instanceof EE_message_type ) { |
902 | 902 | $message_type_name = $message_type_name->name; |
903 | 903 | } |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | * @param string $messenger_name Name of messenger the message type is being deactivated for. |
928 | 928 | */ |
929 | 929 | public function deactivate_message_type_for_messenger( $message_type_name, $messenger_name ) { |
930 | - $this->_initialize_collections(); |
|
930 | + $this->_initialize_collections(); |
|
931 | 931 | if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
932 | 932 | unset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] ); |
933 | 933 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | * @return void |
135 | 135 | */ |
136 | 136 | protected function _initialize_collections() { |
137 | - if ( $this->_initialized ) { |
|
137 | + if ($this->_initialized) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | 140 | $this->_initialized = true; |
141 | 141 | $this->_messenger_collection_loader->load_messengers_from_folder(); |
142 | 142 | $this->_message_type_collection_loader->load_message_types_from_folder(); |
143 | - $this->get_has_activated_messengers_option( true ); |
|
143 | + $this->get_has_activated_messengers_option(true); |
|
144 | 144 | $this->_set_active_messengers_and_message_types(); |
145 | 145 | } |
146 | 146 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * @param string $messenger_name |
171 | 171 | * @return \EE_messenger |
172 | 172 | */ |
173 | - public function get_messenger( $messenger_name ) { |
|
174 | - return $this->messenger_collection()->get_by_info( $messenger_name ); |
|
173 | + public function get_messenger($messenger_name) { |
|
174 | + return $this->messenger_collection()->get_by_info($messenger_name); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * @param string $messenger |
183 | 183 | * @return EE_messenger | null |
184 | 184 | */ |
185 | - public function get_active_messenger( $messenger ) { |
|
185 | + public function get_active_messenger($messenger) { |
|
186 | 186 | $this->_initialize_collections(); |
187 | - return ! empty( $this->_active_messengers[ $messenger ] ) ? $this->_active_messengers[ $messenger ] : null; |
|
187 | + return ! empty($this->_active_messengers[$messenger]) ? $this->_active_messengers[$messenger] : null; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | * @return \EE_messenger[] |
194 | 194 | */ |
195 | 195 | public function installed_messengers() { |
196 | - if ( empty( $this->_installed_messengers ) ) { |
|
196 | + if (empty($this->_installed_messengers)) { |
|
197 | 197 | $this->_installed_messengers = array(); |
198 | 198 | $this->messenger_collection()->rewind(); |
199 | - while ( $this->messenger_collection()->valid() ) { |
|
200 | - $this->_installed_messengers[ $this->messenger_collection()->current()->name ] = $this->messenger_collection()->current(); |
|
199 | + while ($this->messenger_collection()->valid()) { |
|
200 | + $this->_installed_messengers[$this->messenger_collection()->current()->name] = $this->messenger_collection()->current(); |
|
201 | 201 | $this->messenger_collection()->next(); |
202 | 202 | } |
203 | 203 | } |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | * @return \EE_messenger |
212 | 212 | * @throws \EE_Error |
213 | 213 | */ |
214 | - public function valid_messenger( $messenger_name ) { |
|
215 | - $messenger = $this->get_messenger( $messenger_name ); |
|
216 | - if ( $messenger instanceof EE_messenger ) { |
|
214 | + public function valid_messenger($messenger_name) { |
|
215 | + $messenger = $this->get_messenger($messenger_name); |
|
216 | + if ($messenger instanceof EE_messenger) { |
|
217 | 217 | return $messenger; |
218 | 218 | } |
219 | 219 | throw new EE_Error( |
220 | 220 | sprintf( |
221 | - __( 'The "%1$s" messenger is either invalid or not installed', 'event_espresso' ), |
|
221 | + __('The "%1$s" messenger is either invalid or not installed', 'event_espresso'), |
|
222 | 222 | $messenger_name |
223 | 223 | ) |
224 | 224 | ); |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | * @param string $message_type_name |
251 | 251 | * @return \EE_message_type |
252 | 252 | */ |
253 | - public function get_message_type( $message_type_name ) { |
|
254 | - return $this->message_type_collection()->get_by_info( $message_type_name ); |
|
253 | + public function get_message_type($message_type_name) { |
|
254 | + return $this->message_type_collection()->get_by_info($message_type_name); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | * @param string $message_type_name |
264 | 264 | * @return \EE_message_type|null |
265 | 265 | */ |
266 | - public function get_active_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
267 | - return $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) |
|
268 | - ? $this->get_message_type( $message_type_name ) |
|
266 | + public function get_active_message_type_for_messenger($messenger_name, $message_type_name) { |
|
267 | + return $this->is_message_type_active_for_messenger($messenger_name, $message_type_name) |
|
268 | + ? $this->get_message_type($message_type_name) |
|
269 | 269 | : null; |
270 | 270 | } |
271 | 271 | |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @return bool |
281 | 281 | */ |
282 | - public function is_message_type_active_for_messenger( $messenger_name, $message_type_name ) { |
|
282 | + public function is_message_type_active_for_messenger($messenger_name, $message_type_name) { |
|
283 | 283 | $this->_initialize_collections(); |
284 | - return ! empty( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] ); |
|
284 | + return ! empty($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * @param string $messenger_name the name of the messenger to check if active. |
293 | 293 | * @return bool |
294 | 294 | */ |
295 | - public function is_messenger_active( $messenger_name ) { |
|
295 | + public function is_messenger_active($messenger_name) { |
|
296 | 296 | $this->_initialize_collections(); |
297 | - return ! empty( $this->_active_message_types[ $messenger_name ] ); |
|
297 | + return ! empty($this->_active_message_types[$messenger_name]); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | * @param string $message_type_name The slug of the message type getting the settings for. |
306 | 306 | * @return array |
307 | 307 | */ |
308 | - public function get_message_type_settings_for_messenger( $messenger_name, $message_type_name ) { |
|
308 | + public function get_message_type_settings_for_messenger($messenger_name, $message_type_name) { |
|
309 | 309 | $settings = array(); |
310 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
311 | - $settings = isset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] ) |
|
312 | - ? $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] |
|
310 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
311 | + $settings = isset($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings']) |
|
312 | + ? $this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings'] |
|
313 | 313 | : array(); |
314 | 314 | } |
315 | 315 | return $settings; |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | * @param string $messenger_name |
325 | 325 | * @return bool |
326 | 326 | */ |
327 | - public function messenger_has_active_message_types( $messenger_name ) { |
|
327 | + public function messenger_has_active_message_types($messenger_name) { |
|
328 | 328 | $this->_initialize_collections(); |
329 | 329 | return |
330 | - ! empty( $this->_active_message_types[ $messenger_name ] ) |
|
331 | - && ! empty( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ] ); |
|
330 | + ! empty($this->_active_message_types[$messenger_name]) |
|
331 | + && ! empty($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types']); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -341,15 +341,15 @@ discard block |
||
341 | 341 | * @param string $messenger_name The messenger being checked |
342 | 342 | * @return EE_message_type[]|array (empty array if no active_message_types) |
343 | 343 | */ |
344 | - public function get_active_message_types_for_messenger( $messenger_name ) { |
|
344 | + public function get_active_message_types_for_messenger($messenger_name) { |
|
345 | 345 | $message_types = array(); |
346 | - if ( ! $this->messenger_has_active_message_types( $messenger_name ) ) { |
|
346 | + if ( ! $this->messenger_has_active_message_types($messenger_name)) { |
|
347 | 347 | return $message_types; |
348 | 348 | } |
349 | 349 | $installed_message_types = $this->installed_message_types(); |
350 | - foreach ( $installed_message_types as $message_type_name => $message_type ) { |
|
351 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
352 | - $message_types[ $message_type_name ] = $message_type; |
|
350 | + foreach ($installed_message_types as $message_type_name => $message_type) { |
|
351 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
352 | + $message_types[$message_type_name] = $message_type; |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | return $message_types; |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | public function list_of_active_message_types() { |
368 | 368 | $active_message_type_names = array(); |
369 | 369 | $this->_initialize_collections(); |
370 | - foreach ( $this->_active_message_types as $messenger => $messenger_settings ) { |
|
371 | - if ( ! isset( $messenger_settings['settings'][ $messenger . '-message_types' ] ) ) { |
|
370 | + foreach ($this->_active_message_types as $messenger => $messenger_settings) { |
|
371 | + if ( ! isset($messenger_settings['settings'][$messenger.'-message_types'])) { |
|
372 | 372 | continue; |
373 | 373 | } |
374 | - foreach ( $messenger_settings['settings'][ $messenger . '-message_types' ] as $message_type_name => $message_type_config ) { |
|
375 | - if ( ! in_array( $message_type_name, $active_message_type_names ) ) { |
|
374 | + foreach ($messenger_settings['settings'][$messenger.'-message_types'] as $message_type_name => $message_type_config) { |
|
375 | + if ( ! in_array($message_type_name, $active_message_type_names)) { |
|
376 | 376 | $active_message_type_names[] = $message_type_name; |
377 | 377 | } |
378 | 378 | } |
@@ -392,9 +392,9 @@ discard block |
||
392 | 392 | $active_message_types = array(); |
393 | 393 | $installed_message_types = $this->installed_message_types(); |
394 | 394 | $active_message_type_names = $this->list_of_active_message_types(); |
395 | - foreach ( $active_message_type_names as $active_message_type_name ) { |
|
396 | - if ( isset( $installed_message_types[ $active_message_type_name ] ) ) { |
|
397 | - $active_message_types[ $active_message_type_name ] = $installed_message_types[ $active_message_type_name ]; |
|
395 | + foreach ($active_message_type_names as $active_message_type_name) { |
|
396 | + if (isset($installed_message_types[$active_message_type_name])) { |
|
397 | + $active_message_types[$active_message_type_name] = $installed_message_types[$active_message_type_name]; |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | return $active_message_types; |
@@ -406,10 +406,10 @@ discard block |
||
406 | 406 | * @return \EE_message_type[] |
407 | 407 | */ |
408 | 408 | public function installed_message_types() { |
409 | - if ( empty( $this->_installed_message_types ) ) { |
|
409 | + if (empty($this->_installed_message_types)) { |
|
410 | 410 | $this->message_type_collection()->rewind(); |
411 | - while ( $this->message_type_collection()->valid() ) { |
|
412 | - $this->_installed_message_types[ $this->message_type_collection()->current()->name ] = $this->message_type_collection()->current(); |
|
411 | + while ($this->message_type_collection()->valid()) { |
|
412 | + $this->_installed_message_types[$this->message_type_collection()->current()->name] = $this->message_type_collection()->current(); |
|
413 | 413 | $this->message_type_collection()->next(); |
414 | 414 | } |
415 | 415 | } |
@@ -422,14 +422,14 @@ discard block |
||
422 | 422 | * @return \EE_message_type |
423 | 423 | * @throws \EE_Error |
424 | 424 | */ |
425 | - public function valid_message_type( $message_type_name ) { |
|
426 | - $message_type = $this->get_message_type( $message_type_name ); |
|
427 | - if ( $message_type instanceof EE_message_type ) { |
|
425 | + public function valid_message_type($message_type_name) { |
|
426 | + $message_type = $this->get_message_type($message_type_name); |
|
427 | + if ($message_type instanceof EE_message_type) { |
|
428 | 428 | return $message_type; |
429 | 429 | } |
430 | 430 | throw new EE_Error( |
431 | 431 | sprintf( |
432 | - __( 'The "%1$s" message type is either invalid or not installed', 'event_espresso' ), |
|
432 | + __('The "%1$s" message type is either invalid or not installed', 'event_espresso'), |
|
433 | 433 | $message_type_name |
434 | 434 | ) |
435 | 435 | ); |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | * @return boolean |
446 | 446 | * @throws \EE_Error |
447 | 447 | */ |
448 | - public function valid_message_type_for_messenger( EE_messenger $messenger, $message_type_name ) { |
|
448 | + public function valid_message_type_for_messenger(EE_messenger $messenger, $message_type_name) { |
|
449 | 449 | $valid_message_types = $messenger->get_valid_message_types(); |
450 | - if ( ! in_array( $message_type_name, $valid_message_types ) ) { |
|
450 | + if ( ! in_array($message_type_name, $valid_message_types)) { |
|
451 | 451 | throw new EE_Error( |
452 | 452 | sprintf( |
453 | 453 | __( |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @return array |
476 | 476 | */ |
477 | - public function get_active_messengers_option( $reset = false) { |
|
478 | - if ( $reset ) { |
|
479 | - $this->_active_message_types = get_option( 'ee_active_messengers', array() ); |
|
477 | + public function get_active_messengers_option($reset = false) { |
|
478 | + if ($reset) { |
|
479 | + $this->_active_message_types = get_option('ee_active_messengers', array()); |
|
480 | 480 | } |
481 | 481 | return $this->_active_message_types; |
482 | 482 | } |
@@ -490,11 +490,11 @@ discard block |
||
490 | 490 | * representing this data is used. |
491 | 491 | * @return bool FALSE if not updated, TRUE if updated. |
492 | 492 | */ |
493 | - public function update_active_messengers_option( $active_messenger_settings = array() ) { |
|
494 | - $active_messenger_settings = empty( $active_messenger_settings ) ? $this->_active_message_types : $active_messenger_settings; |
|
493 | + public function update_active_messengers_option($active_messenger_settings = array()) { |
|
494 | + $active_messenger_settings = empty($active_messenger_settings) ? $this->_active_message_types : $active_messenger_settings; |
|
495 | 495 | //make sure _active_message_types is updated (this is the internal cache for the settings). |
496 | 496 | $this->_active_message_types = $active_messenger_settings; |
497 | - return update_option( 'ee_active_messengers', $active_messenger_settings ); |
|
497 | + return update_option('ee_active_messengers', $active_messenger_settings); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -509,9 +509,9 @@ discard block |
||
509 | 509 | * |
510 | 510 | * @return array |
511 | 511 | */ |
512 | - public function get_has_activated_messengers_option( $reset = false ) { |
|
513 | - if ( $reset || empty( $this->_has_activated_messengers_and_message_types ) ) { |
|
514 | - $this->_has_activated_messengers_and_message_types = get_option( 'ee_has_activated_messenger', array() ); |
|
512 | + public function get_has_activated_messengers_option($reset = false) { |
|
513 | + if ($reset || empty($this->_has_activated_messengers_and_message_types)) { |
|
514 | + $this->_has_activated_messengers_and_message_types = get_option('ee_has_activated_messenger', array()); |
|
515 | 515 | } |
516 | 516 | return $this->_has_activated_messengers_and_message_types; |
517 | 517 | } |
@@ -526,15 +526,15 @@ discard block |
||
526 | 526 | * |
527 | 527 | * @return bool FALSE if not updated, TRUE if updated. |
528 | 528 | */ |
529 | - public function update_has_activated_messengers_option( $has_activated_messengers = array() ) { |
|
529 | + public function update_has_activated_messengers_option($has_activated_messengers = array()) { |
|
530 | 530 | //make sure the option has been retrieved from first so we don't overwrite it accidentally. |
531 | - if ( empty( $has_activated_messengers ) && empty( $this->_has_activated_messengers_and_message_types ) ) { |
|
531 | + if (empty($has_activated_messengers) && empty($this->_has_activated_messengers_and_message_types)) { |
|
532 | 532 | $this->get_has_activated_messengers_option(); |
533 | 533 | } |
534 | - $has_activated_messengers = empty( $has_activated_messengers ) |
|
534 | + $has_activated_messengers = empty($has_activated_messengers) |
|
535 | 535 | ? $this->_has_activated_messengers_and_message_types |
536 | 536 | : $has_activated_messengers; |
537 | - return update_option( 'ee_has_activated_messenger', $has_activated_messengers ); |
|
537 | + return update_option('ee_has_activated_messenger', $has_activated_messengers); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | |
@@ -556,8 +556,8 @@ discard block |
||
556 | 556 | //echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() \n"; |
557 | 557 | // list of activated messengers as set via the admin |
558 | 558 | // note calling `get_active_messengers_options` also initializes the _active_message_types property. |
559 | - $this->get_active_messengers_option( true ); |
|
560 | - $this->ensure_messengers_are_active( array(), false, true ); |
|
559 | + $this->get_active_messengers_option(true); |
|
560 | + $this->ensure_messengers_are_active(array(), false, true); |
|
561 | 561 | $this->update_active_messengers_option(); |
562 | 562 | $this->update_has_activated_messengers_option(); |
563 | 563 | } |
@@ -575,11 +575,11 @@ discard block |
||
575 | 575 | * @param bool $update_option Whether to update the option in the db or not. |
576 | 576 | * @return boolean true if either already active or successfully activated. |
577 | 577 | */ |
578 | - public function ensure_messenger_is_active( $messenger_name, $update_option = true ) { |
|
579 | - if ( ! isset( $this->_active_messengers[ $messenger_name ] ) ) { |
|
578 | + public function ensure_messenger_is_active($messenger_name, $update_option = true) { |
|
579 | + if ( ! isset($this->_active_messengers[$messenger_name])) { |
|
580 | 580 | try { |
581 | - $this->activate_messenger( $messenger_name, array(), $update_option ); |
|
582 | - } catch( EE_Error $e ) { |
|
581 | + $this->activate_messenger($messenger_name, array(), $update_option); |
|
582 | + } catch (EE_Error $e) { |
|
583 | 583 | EE_Error::add_error( |
584 | 584 | $e->getMessage(), |
585 | 585 | __FILE__, |
@@ -606,25 +606,25 @@ discard block |
||
606 | 606 | * and a messenger is indicated as active, but is NOT installed, then it will automatically be |
607 | 607 | * deactivated. |
608 | 608 | */ |
609 | - public function ensure_messengers_are_active( $messenger_names = array(), $update_option = true, $verify = false ) { |
|
610 | - $messenger_names = empty( $messenger_names ) ? array_keys( $this->_active_message_types ) : $messenger_names; |
|
609 | + public function ensure_messengers_are_active($messenger_names = array(), $update_option = true, $verify = false) { |
|
610 | + $messenger_names = empty($messenger_names) ? array_keys($this->_active_message_types) : $messenger_names; |
|
611 | 611 | |
612 | 612 | $not_installed = array(); |
613 | - foreach( $messenger_names as $messenger_name ) { |
|
614 | - if ( $verify && ! $this->messenger_collection()->has_by_name( $messenger_name ) ) { |
|
613 | + foreach ($messenger_names as $messenger_name) { |
|
614 | + if ($verify && ! $this->messenger_collection()->has_by_name($messenger_name)) { |
|
615 | 615 | $not_installed[] = $messenger_name; |
616 | - $this->deactivate_messenger( $messenger_name ); |
|
616 | + $this->deactivate_messenger($messenger_name); |
|
617 | 617 | continue; |
618 | 618 | } |
619 | - $this->ensure_messenger_is_active( $messenger_name, $update_option ); |
|
619 | + $this->ensure_messenger_is_active($messenger_name, $update_option); |
|
620 | 620 | } |
621 | 621 | |
622 | - if ( ! empty( $not_installed_messenger ) ) { |
|
622 | + if ( ! empty($not_installed_messenger)) { |
|
623 | 623 | EE_Error::add_error( |
624 | 624 | sprintf( |
625 | - __( 'The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso' ), |
|
625 | + __('The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso'), |
|
626 | 626 | '<br />', |
627 | - implode( ', ', $not_installed_messenger ) |
|
627 | + implode(', ', $not_installed_messenger) |
|
628 | 628 | ), |
629 | 629 | __FILE__, __FUNCTION__, __LINE__ |
630 | 630 | ); |
@@ -643,18 +643,18 @@ discard block |
||
643 | 643 | * @return bool Returns true if already is active or if was activated successfully. |
644 | 644 | * @throws \EE_Error |
645 | 645 | */ |
646 | - public function ensure_message_type_is_active( $message_type_name, $messenger_name, $update_option = true ) { |
|
646 | + public function ensure_message_type_is_active($message_type_name, $messenger_name, $update_option = true) { |
|
647 | 647 | // grab the messenger to work with. |
648 | - $messenger = $this->valid_messenger( $messenger_name ); |
|
649 | - if ( $this->valid_message_type_for_messenger( $messenger, $message_type_name ) ) { |
|
648 | + $messenger = $this->valid_messenger($messenger_name); |
|
649 | + if ($this->valid_message_type_for_messenger($messenger, $message_type_name)) { |
|
650 | 650 | //ensure messenger is active (that's an inherent coupling between active message types and the |
651 | 651 | //messenger they are being activated for. |
652 | 652 | try { |
653 | - if ( ! $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
653 | + if ( ! $this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
654 | 654 | //all is good so let's just get it active |
655 | - $this->activate_messenger( $messenger_name, array( $message_type_name ), $update_option ); |
|
655 | + $this->activate_messenger($messenger_name, array($message_type_name), $update_option); |
|
656 | 656 | } |
657 | - } catch( EE_Error $e ) { |
|
657 | + } catch (EE_Error $e) { |
|
658 | 658 | EE_Error::add_error( |
659 | 659 | $e->getMessage(), |
660 | 660 | __FILE__, |
@@ -678,14 +678,14 @@ discard block |
||
678 | 678 | * @param string $messenger_name The name of the messenger that the message types are to be activated on. |
679 | 679 | * @param bool $update_option Whether to persist the activation to the database or not (default true). |
680 | 680 | */ |
681 | - public function ensure_message_types_are_active( $message_type_names, $messenger_name, $update_option = true ) { |
|
681 | + public function ensure_message_types_are_active($message_type_names, $messenger_name, $update_option = true) { |
|
682 | 682 | $message_type_names = (array) $message_type_names; |
683 | - foreach ( $message_type_names as $message_type_name ) { |
|
683 | + foreach ($message_type_names as $message_type_name) { |
|
684 | 684 | // note, intentionally not updating option here because we're in a loop. |
685 | 685 | // We'll follow the instructions of the incoming $update_option argument after the loop. |
686 | - $this->ensure_message_type_is_active( $message_type_name, $messenger_name, false ); |
|
686 | + $this->ensure_message_type_is_active($message_type_name, $messenger_name, false); |
|
687 | 687 | } |
688 | - if ( $update_option ) { |
|
688 | + if ($update_option) { |
|
689 | 689 | $this->update_active_messengers_option(); |
690 | 690 | $this->update_has_activated_messengers_option(); |
691 | 691 | } |
@@ -712,24 +712,24 @@ discard block |
||
712 | 712 | ) { |
713 | 713 | $templates = array(); |
714 | 714 | // grab the messenger to work with. |
715 | - $messenger = $this->messenger_collection()->get_by_info( $messenger_name ); |
|
715 | + $messenger = $this->messenger_collection()->get_by_info($messenger_name); |
|
716 | 716 | // it's inactive. Activate it. |
717 | - if ( $messenger instanceof EE_messenger ) { |
|
718 | - $this->_active_messengers[ $messenger->name ] = $messenger; |
|
717 | + if ($messenger instanceof EE_messenger) { |
|
718 | + $this->_active_messengers[$messenger->name] = $messenger; |
|
719 | 719 | //activate incoming message types set to be activated with messenger. |
720 | - $message_type_names = $this->_activate_message_types( $messenger, $message_type_names ); |
|
720 | + $message_type_names = $this->_activate_message_types($messenger, $message_type_names); |
|
721 | 721 | // setup any initial settings for the messenger if necessary. |
722 | - $this->add_settings_for_messenger( $messenger->name ); |
|
723 | - if ( $update_active_messengers_option ) { |
|
722 | + $this->add_settings_for_messenger($messenger->name); |
|
723 | + if ($update_active_messengers_option) { |
|
724 | 724 | $this->update_active_messengers_option(); |
725 | 725 | $this->update_has_activated_messengers_option(); |
726 | 726 | } |
727 | 727 | //generate new templates if necessary and ensure all related templates that are already in the database are |
728 | 728 | //marked active. Note, this will also deactivate a message type for a messenger if the template |
729 | 729 | //cannot be successfully created during its attempt (only happens for global template attempts). |
730 | - if ( ! empty( $message_type_names ) ) { |
|
731 | - $templates = EEH_MSG_Template::generate_new_templates( $messenger->name, $message_type_names, 0, true ); |
|
732 | - EEH_MSG_Template::update_to_active( array( $messenger->name ), $message_type_names ); |
|
730 | + if ( ! empty($message_type_names)) { |
|
731 | + $templates = EEH_MSG_Template::generate_new_templates($messenger->name, $message_type_names, 0, true); |
|
732 | + EEH_MSG_Template::update_to_active(array($messenger->name), $message_type_names); |
|
733 | 733 | } |
734 | 734 | } |
735 | 735 | return $templates; |
@@ -748,29 +748,29 @@ discard block |
||
748 | 748 | * |
749 | 749 | * @return array |
750 | 750 | */ |
751 | - protected function _activate_message_types( EE_messenger $messenger, $message_type_names = array() ) { |
|
751 | + protected function _activate_message_types(EE_messenger $messenger, $message_type_names = array()) { |
|
752 | 752 | //If $message_type_names is empty, AND $this->_active_message_types is empty, then that means |
753 | 753 | //things have never been initialized (which should happen on EEH_Activation::generate_message_templates). |
754 | 754 | //So ONLY then do we need to actually grab defaults and cycle through them. Otherwise we |
755 | 755 | //only override _active_message_types when an explicit array of $message_type_names has been provided. |
756 | - $message_type_names = empty( $message_type_names ) && ! isset( $this->_active_message_types[ $messenger->name ] ) |
|
756 | + $message_type_names = empty($message_type_names) && ! isset($this->_active_message_types[$messenger->name]) |
|
757 | 757 | ? $messenger->get_default_message_types() |
758 | 758 | : (array) $message_type_names; |
759 | 759 | |
760 | 760 | //now we ALWAYS need to make sure that the messenger is active for the message types we're activating! |
761 | - if ( ! isset( $this->_active_message_types[ $messenger->name ] ) ) { |
|
762 | - $this->_active_message_types[ $messenger->name ]['settings'] = array(); |
|
761 | + if ( ! isset($this->_active_message_types[$messenger->name])) { |
|
762 | + $this->_active_message_types[$messenger->name]['settings'] = array(); |
|
763 | 763 | } |
764 | 764 | |
765 | - if ( $message_type_names ) { |
|
765 | + if ($message_type_names) { |
|
766 | 766 | // cycle thru message types |
767 | - foreach ( $message_type_names as $message_type_name ) { |
|
767 | + foreach ($message_type_names as $message_type_name) { |
|
768 | 768 | //only register the message type as active IF it isn't already active |
769 | 769 | //and if its actually installed. |
770 | 770 | if ( |
771 | - ! $this->is_message_type_active_for_messenger( $messenger->name, $message_type_name ) |
|
771 | + ! $this->is_message_type_active_for_messenger($messenger->name, $message_type_name) |
|
772 | 772 | ) { |
773 | - $this->add_settings_for_message_type( $messenger->name, $message_type_name ); |
|
773 | + $this->add_settings_for_message_type($messenger->name, $message_type_name); |
|
774 | 774 | $this->_set_messenger_has_activated_message_type( |
775 | 775 | $messenger, |
776 | 776 | $message_type_name |
@@ -793,24 +793,24 @@ discard block |
||
793 | 793 | * @param string $message_type_name The name of the message type adding the settings for |
794 | 794 | * @param array $new_settings Any new settings being set for the message type and messenger |
795 | 795 | */ |
796 | - public function add_settings_for_message_type( $messenger_name, $message_type_name, $new_settings = array() ) { |
|
796 | + public function add_settings_for_message_type($messenger_name, $message_type_name, $new_settings = array()) { |
|
797 | 797 | // get installed message type from collection |
798 | - $message_type = $this->message_type_collection()->get_by_info( $message_type_name ); |
|
799 | - $existing_settings = $this->get_message_type_settings_for_messenger( $messenger_name, $message_type_name ); |
|
798 | + $message_type = $this->message_type_collection()->get_by_info($message_type_name); |
|
799 | + $existing_settings = $this->get_message_type_settings_for_messenger($messenger_name, $message_type_name); |
|
800 | 800 | //we need to setup any initial settings for message types |
801 | - if ( $message_type instanceof EE_message_type ) { |
|
801 | + if ($message_type instanceof EE_message_type) { |
|
802 | 802 | $default_settings = $message_type->get_admin_settings_fields(); |
803 | - foreach ( $default_settings as $field => $values ) { |
|
804 | - if ( isset( $new_settings[ $field ] ) ) { |
|
805 | - $existing_settings[ $field ] = $new_settings[ $field ]; |
|
803 | + foreach ($default_settings as $field => $values) { |
|
804 | + if (isset($new_settings[$field])) { |
|
805 | + $existing_settings[$field] = $new_settings[$field]; |
|
806 | 806 | continue; |
807 | 807 | } |
808 | - if ( ! isset( $existing_settings[ $field ] ) ) { |
|
809 | - $existing_settings[ $field ] = $values['default']; |
|
808 | + if ( ! isset($existing_settings[$field])) { |
|
809 | + $existing_settings[$field] = $values['default']; |
|
810 | 810 | } |
811 | 811 | } |
812 | 812 | } |
813 | - $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] = $existing_settings; |
|
813 | + $this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings'] = $existing_settings; |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | |
@@ -823,20 +823,20 @@ discard block |
||
823 | 823 | * @param \EE_messenger $messenger |
824 | 824 | * @param string $message_type_name |
825 | 825 | */ |
826 | - protected function _set_messenger_has_activated_message_type( EE_messenger $messenger, $message_type_name ) { |
|
826 | + protected function _set_messenger_has_activated_message_type(EE_messenger $messenger, $message_type_name) { |
|
827 | 827 | |
828 | 828 | //if _has_activated_messengers_and_message_types is empty then lets ensure its initialized |
829 | - if ( empty( $this->_has_activated_messengers_and_message_types ) ) { |
|
829 | + if (empty($this->_has_activated_messengers_and_message_types)) { |
|
830 | 830 | $this->get_has_activated_messengers_option(); |
831 | 831 | } |
832 | 832 | |
833 | 833 | // make sure this messenger has a record in the has_activated array |
834 | - if ( ! isset( $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) { |
|
835 | - $this->_has_activated_messengers_and_message_types[ $messenger->name ] = array(); |
|
834 | + if ( ! isset($this->_has_activated_messengers_and_message_types[$messenger->name])) { |
|
835 | + $this->_has_activated_messengers_and_message_types[$messenger->name] = array(); |
|
836 | 836 | } |
837 | 837 | // check if message type has already been added |
838 | - if ( ! in_array( $message_type_name, $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) { |
|
839 | - $this->_has_activated_messengers_and_message_types[ $messenger->name ][] = $message_type_name; |
|
838 | + if ( ! in_array($message_type_name, $this->_has_activated_messengers_and_message_types[$messenger->name])) { |
|
839 | + $this->_has_activated_messengers_and_message_types[$messenger->name][] = $message_type_name; |
|
840 | 840 | } |
841 | 841 | } |
842 | 842 | |
@@ -851,20 +851,20 @@ discard block |
||
851 | 851 | * @param string $messenger_name The name of the messenger the settings is being added for. |
852 | 852 | * @param array $new_settings An array of settings to update the existing settings. |
853 | 853 | */ |
854 | - public function add_settings_for_messenger( $messenger_name, $new_settings = array() ) { |
|
855 | - $messenger = $this->get_messenger( $messenger_name ); |
|
856 | - if ( $messenger instanceof EE_messenger ) { |
|
854 | + public function add_settings_for_messenger($messenger_name, $new_settings = array()) { |
|
855 | + $messenger = $this->get_messenger($messenger_name); |
|
856 | + if ($messenger instanceof EE_messenger) { |
|
857 | 857 | $msgr_settings = $messenger->get_admin_settings_fields(); |
858 | - if ( ! empty( $msgr_settings ) ) { |
|
859 | - foreach ( $msgr_settings as $field => $value ) { |
|
858 | + if ( ! empty($msgr_settings)) { |
|
859 | + foreach ($msgr_settings as $field => $value) { |
|
860 | 860 | //is there a new setting for this? |
861 | - if ( isset( $new_settings[ $field ] ) ) { |
|
862 | - $this->_active_message_types[ $messenger->name ]['settings'][ $field ] = $new_settings[ $field ]; |
|
861 | + if (isset($new_settings[$field])) { |
|
862 | + $this->_active_message_types[$messenger->name]['settings'][$field] = $new_settings[$field]; |
|
863 | 863 | continue; |
864 | 864 | } |
865 | 865 | //only set the default if it isn't already set. |
866 | - if ( ! isset( $this->_active_message_types[ $messenger->name ]['settings'][ $field ] ) ) { |
|
867 | - $this->_active_message_types[ $messenger->name ]['settings'][ $field ] = $value; |
|
866 | + if ( ! isset($this->_active_message_types[$messenger->name]['settings'][$field])) { |
|
867 | + $this->_active_message_types[$messenger->name]['settings'][$field] = $value; |
|
868 | 868 | } |
869 | 869 | } |
870 | 870 | } |
@@ -879,14 +879,14 @@ discard block |
||
879 | 879 | * @param string|EE_messenger $messenger_name name of messenger |
880 | 880 | * @return void |
881 | 881 | */ |
882 | - public function deactivate_messenger( $messenger_name ) { |
|
882 | + public function deactivate_messenger($messenger_name) { |
|
883 | 883 | $this->_initialize_collections(); |
884 | - if ( $messenger_name instanceof EE_messenger ) { |
|
884 | + if ($messenger_name instanceof EE_messenger) { |
|
885 | 885 | $messenger_name = $messenger_name->name; |
886 | 886 | } |
887 | - unset( $this->_active_messengers[ $messenger_name ] ); |
|
888 | - unset( $this->_active_message_types[ $messenger_name ] ); |
|
889 | - $this->_message_template_group_model->deactivate_message_template_groups_for( $messenger_name ); |
|
887 | + unset($this->_active_messengers[$messenger_name]); |
|
888 | + unset($this->_active_message_types[$messenger_name]); |
|
889 | + $this->_message_template_group_model->deactivate_message_template_groups_for($messenger_name); |
|
890 | 890 | $this->update_active_messengers_option(); |
891 | 891 | } |
892 | 892 | |
@@ -896,22 +896,22 @@ discard block |
||
896 | 896 | * |
897 | 897 | * @param string $message_type_name name of message type being deactivated |
898 | 898 | */ |
899 | - public function deactivate_message_type( $message_type_name ) { |
|
899 | + public function deactivate_message_type($message_type_name) { |
|
900 | 900 | $this->_initialize_collections(); |
901 | - if ( $message_type_name instanceof EE_message_type ) { |
|
901 | + if ($message_type_name instanceof EE_message_type) { |
|
902 | 902 | $message_type_name = $message_type_name->name; |
903 | 903 | } |
904 | - foreach ( $this->_active_message_types as $messenger_name => $settings ) { |
|
904 | + foreach ($this->_active_message_types as $messenger_name => $settings) { |
|
905 | 905 | unset( |
906 | - $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] |
|
906 | + $this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name] |
|
907 | 907 | ); |
908 | 908 | |
909 | 909 | //we always record (even on deactivation) that a message type has been activated because there should at |
910 | 910 | //least be a record in the "has_activated" option that it WAS active at one point. |
911 | - $messenger = $this->get_messenger( $messenger_name ); |
|
912 | - $this->_set_messenger_has_activated_message_type( $messenger, $message_type_name ); |
|
911 | + $messenger = $this->get_messenger($messenger_name); |
|
912 | + $this->_set_messenger_has_activated_message_type($messenger, $message_type_name); |
|
913 | 913 | } |
914 | - $this->_message_template_group_model->deactivate_message_template_groups_for( '', $message_type_name ); |
|
914 | + $this->_message_template_group_model->deactivate_message_template_groups_for('', $message_type_name); |
|
915 | 915 | $this->update_active_messengers_option(); |
916 | 916 | $this->update_has_activated_messengers_option(); |
917 | 917 | } |
@@ -926,12 +926,12 @@ discard block |
||
926 | 926 | * @param string $message_type_name Name of message type being deactivated. |
927 | 927 | * @param string $messenger_name Name of messenger the message type is being deactivated for. |
928 | 928 | */ |
929 | - public function deactivate_message_type_for_messenger( $message_type_name, $messenger_name ) { |
|
929 | + public function deactivate_message_type_for_messenger($message_type_name, $messenger_name) { |
|
930 | 930 | $this->_initialize_collections(); |
931 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
932 | - unset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] ); |
|
931 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
932 | + unset($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]); |
|
933 | 933 | } |
934 | - $this->_message_template_group_model->deactivate_message_template_groups_for( array( $messenger_name ), array( $message_type_name ) ); |
|
934 | + $this->_message_template_group_model->deactivate_message_template_groups_for(array($messenger_name), array($message_type_name)); |
|
935 | 935 | $this->update_active_messengers_option(); |
936 | 936 | } |
937 | 937 | |
@@ -948,12 +948,12 @@ discard block |
||
948 | 948 | * |
949 | 949 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
950 | 950 | */ |
951 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
951 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
952 | 952 | //get the $messengers the message type says it can be used with. |
953 | - foreach ( $message_type->with_messengers() as $generating_messenger => $secondary_messengers ) { |
|
953 | + foreach ($message_type->with_messengers() as $generating_messenger => $secondary_messengers) { |
|
954 | 954 | if ( |
955 | 955 | $messenger->name === $generating_messenger |
956 | - && $this->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) |
|
956 | + && $this->is_message_type_active_for_messenger($messenger->name, $message_type->name) |
|
957 | 957 | ) { |
958 | 958 | return true; |
959 | 959 | } |
@@ -990,25 +990,25 @@ discard block |
||
990 | 990 | * or all contexts indexed by message type. |
991 | 991 | * @return array |
992 | 992 | */ |
993 | - public function get_all_contexts( $slugs_only = true ) { |
|
993 | + public function get_all_contexts($slugs_only = true) { |
|
994 | 994 | $key = $slugs_only ? 'slugs' : 'all'; |
995 | 995 | // check if contexts has been setup yet. |
996 | - if ( empty( $this->_contexts[ $key ] ) ) { |
|
996 | + if (empty($this->_contexts[$key])) { |
|
997 | 997 | // So let's get all active message type objects and loop through to get all unique contexts |
998 | - foreach ( $this->get_active_message_type_objects() as $message_type ) { |
|
999 | - if ( $message_type instanceof EE_message_type ) { |
|
998 | + foreach ($this->get_active_message_type_objects() as $message_type) { |
|
999 | + if ($message_type instanceof EE_message_type) { |
|
1000 | 1000 | $message_type_contexts = $message_type->get_contexts(); |
1001 | - if ( $slugs_only ) { |
|
1002 | - foreach ( $message_type_contexts as $context => $context_details ) { |
|
1003 | - $this->_contexts[ $key ][ $context ] = $context_details[ 'label' ]; |
|
1001 | + if ($slugs_only) { |
|
1002 | + foreach ($message_type_contexts as $context => $context_details) { |
|
1003 | + $this->_contexts[$key][$context] = $context_details['label']; |
|
1004 | 1004 | } |
1005 | 1005 | } else { |
1006 | - $this->_contexts[ $key ][ $message_type->name ] = $message_type_contexts; |
|
1006 | + $this->_contexts[$key][$message_type->name] = $message_type_contexts; |
|
1007 | 1007 | } |
1008 | 1008 | } |
1009 | 1009 | } |
1010 | 1010 | } |
1011 | - return ! empty( $this->_contexts[ $key ] ) ? $this->_contexts[ $key ] : array(); |
|
1011 | + return ! empty($this->_contexts[$key]) ? $this->_contexts[$key] : array(); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | |
@@ -1027,9 +1027,9 @@ discard block |
||
1027 | 1027 | $installed_message_types = $this->installed_message_types(); |
1028 | 1028 | $all_message_types_valid = true; |
1029 | 1029 | //loop through list of active message types and verify they are installed. |
1030 | - foreach( $list_of_active_message_type_names as $message_type_name ) { |
|
1031 | - if ( ! isset( $installed_message_types[$message_type_name] ) ) { |
|
1032 | - $this->deactivate_message_type( $message_type_name ); |
|
1030 | + foreach ($list_of_active_message_type_names as $message_type_name) { |
|
1031 | + if ( ! isset($installed_message_types[$message_type_name])) { |
|
1032 | + $this->deactivate_message_type($message_type_name); |
|
1033 | 1033 | $all_message_types_valid = false; |
1034 | 1034 | } |
1035 | 1035 | } |
@@ -1048,10 +1048,10 @@ discard block |
||
1048 | 1048 | * @param $messenger_name |
1049 | 1049 | * @return bool |
1050 | 1050 | */ |
1051 | - public function has_message_type_been_activated_for_messenger( $message_type_name, $messenger_name ) { |
|
1051 | + public function has_message_type_been_activated_for_messenger($message_type_name, $messenger_name) { |
|
1052 | 1052 | $has_activated = $this->get_has_activated_messengers_option(); |
1053 | - return isset( $has_activated[ $messenger_name ] ) |
|
1054 | - && in_array( $message_type_name, $has_activated[ $messenger_name ] ); |
|
1053 | + return isset($has_activated[$messenger_name]) |
|
1054 | + && in_array($message_type_name, $has_activated[$messenger_name]); |
|
1055 | 1055 | } |
1056 | 1056 | } |
1057 | 1057 | // End of file EE_Message_Resource_Manager.lib.php |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * EE_Attendee_Shortcodes constructor. |
|
44 | - */ |
|
45 | - public function __construct() { |
|
42 | + /** |
|
43 | + * EE_Attendee_Shortcodes constructor. |
|
44 | + */ |
|
45 | + public function __construct() { |
|
46 | 46 | parent::__construct(); |
47 | 47 | } |
48 | 48 | |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | |
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * handles shortcode parsing |
|
77 | - * |
|
78 | - * @access protected |
|
79 | - * @param string $shortcode the shortcode to be parsed. |
|
80 | - * @return string |
|
81 | - * @throws \EE_Error |
|
82 | - */ |
|
83 | - protected function _parser( $shortcode ) { |
|
75 | + /** |
|
76 | + * handles shortcode parsing |
|
77 | + * |
|
78 | + * @access protected |
|
79 | + * @param string $shortcode the shortcode to be parsed. |
|
80 | + * @return string |
|
81 | + * @throws \EE_Error |
|
82 | + */ |
|
83 | + protected function _parser( $shortcode ) { |
|
84 | 84 | |
85 | 85 | |
86 | 86 | $this->_xtra = !empty($this->_extra_data ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : NULL; |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | if ( ! $registration instanceof EE_Registration ) { |
92 | 92 | //let's attempt to get the txn_id for the error message. |
93 | 93 | $txn_id = isset( $this->_xtra->txn ) && $this->_xtra->txn instanceof EE_Transaction ? $this->_xtra->txn->ID() : __('Unknown', 'event_espresso' ); |
94 | - $msg = __('There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', |
|
95 | - 'event_espresso'); |
|
96 | - $dev_msg = sprintf(__('The transaction ID for this request is: %s', 'event_espresso'), $txn_id); |
|
94 | + $msg = __('There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', |
|
95 | + 'event_espresso'); |
|
96 | + $dev_msg = sprintf(__('The transaction ID for this request is: %s', 'event_espresso'), $txn_id); |
|
97 | 97 | throw new EE_Error( "{$msg}||{$msg} {$dev_msg}" ); |
98 | 98 | } |
99 | 99 | |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | $attendee = isset( $this->_xtra->registrations[$registration->ID()]['att_obj'] ) ? $this->_xtra->registrations[$registration->ID()]['att_obj'] : null ; |
102 | 102 | |
103 | 103 | if ( ! $attendee instanceof EE_Attendee ) { |
104 | - $msg = __('There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', |
|
105 | - 'event_espresso'); |
|
106 | - $dev_msg = sprintf(__('The registration ID for this request is: %s', 'event_espresso'), |
|
107 | - $registration->ID()); |
|
104 | + $msg = __('There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', |
|
105 | + 'event_espresso'); |
|
106 | + $dev_msg = sprintf(__('The registration ID for this request is: %s', 'event_espresso'), |
|
107 | + $registration->ID()); |
|
108 | 108 | throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
109 | 109 | } |
110 | 110 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | '[ADDRESS2]' => __('Whatever was in the address 2 field for the registration.', 'event_espresso'), |
66 | 66 | '[CITY]' => __('The city for the registration.', 'event_espresso'), |
67 | 67 | '[ZIP_PC]' => __('The ZIP (or Postal) Code for the Registration.', 'event_espresso'), |
68 | - '[ADDRESS_STATE]' => __('The state/province for the registration.', 'event_espresso' ), |
|
68 | + '[ADDRESS_STATE]' => __('The state/province for the registration.', 'event_espresso'), |
|
69 | 69 | '[COUNTRY]' => __('The country for the registration.', 'event_espresso') |
70 | 70 | ); |
71 | 71 | } |
@@ -80,27 +80,27 @@ discard block |
||
80 | 80 | * @return string |
81 | 81 | * @throws \EE_Error |
82 | 82 | */ |
83 | - protected function _parser( $shortcode ) { |
|
83 | + protected function _parser($shortcode) { |
|
84 | 84 | |
85 | 85 | |
86 | - $this->_xtra = !empty($this->_extra_data ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : NULL; |
|
86 | + $this->_xtra = ! empty($this->_extra_data) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : NULL; |
|
87 | 87 | |
88 | 88 | //incoming object should only be a registration object. |
89 | 89 | $registration = ! $this->_data instanceof EE_Registration ? NULL : $this->_data; |
90 | 90 | |
91 | - if ( ! $registration instanceof EE_Registration ) { |
|
91 | + if ( ! $registration instanceof EE_Registration) { |
|
92 | 92 | //let's attempt to get the txn_id for the error message. |
93 | - $txn_id = isset( $this->_xtra->txn ) && $this->_xtra->txn instanceof EE_Transaction ? $this->_xtra->txn->ID() : __('Unknown', 'event_espresso' ); |
|
93 | + $txn_id = isset($this->_xtra->txn) && $this->_xtra->txn instanceof EE_Transaction ? $this->_xtra->txn->ID() : __('Unknown', 'event_espresso'); |
|
94 | 94 | $msg = __('There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', |
95 | 95 | 'event_espresso'); |
96 | 96 | $dev_msg = sprintf(__('The transaction ID for this request is: %s', 'event_espresso'), $txn_id); |
97 | - throw new EE_Error( "{$msg}||{$msg} {$dev_msg}" ); |
|
97 | + throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | //attendee obj for this registration |
101 | - $attendee = isset( $this->_xtra->registrations[$registration->ID()]['att_obj'] ) ? $this->_xtra->registrations[$registration->ID()]['att_obj'] : null ; |
|
101 | + $attendee = isset($this->_xtra->registrations[$registration->ID()]['att_obj']) ? $this->_xtra->registrations[$registration->ID()]['att_obj'] : null; |
|
102 | 102 | |
103 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
103 | + if ( ! $attendee instanceof EE_Attendee) { |
|
104 | 104 | $msg = __('There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', |
105 | 105 | 'event_espresso'); |
106 | 106 | $dev_msg = sprintf(__('The registration ID for this request is: %s', 'event_espresso'), |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
109 | 109 | } |
110 | 110 | |
111 | - switch ( $shortcode ) { |
|
111 | + switch ($shortcode) { |
|
112 | 112 | |
113 | 113 | case '[FNAME]' : |
114 | 114 | return $attendee->fname(); |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <div class="padding"> |
2 | 2 | <p> |
3 | - <?php esc_html_e('Displays a list of events based on a set of criteria on a WordPress page or post. Unless otherwise specified, events are sorted by start date.', 'event_espresso'); ?> <?php echo sprintf( esc_html__('For a full list of available shortcodes, please view the %sshortcode documentation%s on our website.', 'event_espresso'), '<a href="https://eventespresso.com/wiki/ee4-shortcodes-template-variables/">', '</a>' ); ?> |
|
3 | + <?php esc_html_e('Displays a list of events based on a set of criteria on a WordPress page or post. Unless otherwise specified, events are sorted by start date.', 'event_espresso'); ?> <?php echo sprintf(esc_html__('For a full list of available shortcodes, please view the %sshortcode documentation%s on our website.', 'event_espresso'), '<a href="https://eventespresso.com/wiki/ee4-shortcodes-template-variables/">', '</a>'); ?> |
|
4 | 4 | </p> |
5 | 5 | <ul> |
6 | 6 | <li><strong><?php esc_html_e('Show a list of all of your events', 'event_espresso'); ?></strong><br /> [ESPRESSO_EVENTS]</li> |
7 | 7 | <li><strong><?php esc_html_e('Set a custom title for the event list', 'event_espresso'); ?></strong><br /> [ESPRESSO_EVENTS title="My Super Event List"]</li> |
8 | 8 | <li><strong><?php esc_html_e('Limit (paginate) the number of events that are shown in the event list on a page or post', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS limit=5]</li> |
9 | 9 | <li><strong><?php esc_html_e('Add a custom CSS class to each event post/article', 'event_espresso'); ?></strong><br /> [ESPRESSO_EVENTS css_class=my-custom-class]</li> |
10 | - <li><strong><?php esc_html_e('Filter the event list by month and year', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS month="<?php echo date( 'F Y' ); ?>"]</li> |
|
10 | + <li><strong><?php esc_html_e('Filter the event list by month and year', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS month="<?php echo date('F Y'); ?>"]</li> |
|
11 | 11 | <li><strong><?php esc_html_e('Show expired events in the event list', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS show_expired=true]</li> |
12 | 12 | <li><strong><?php esc_html_e('Sorts the event list in ascending order', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS sort=ASC]</li> |
13 | 13 | <li><strong><?php esc_html_e('Sorts the event list in descending order', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS sort=DESC]</li> |
@@ -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 | /** |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
69 | 69 | * @access public |
70 | 70 | */ |
71 | - public function __construct( $routing = TRUE ) { |
|
72 | - require_once( EE_MODELS . 'EEM_Question.model.php' ); |
|
73 | - require_once( EE_MODELS . 'EEM_Question_Group.model.php' ); |
|
74 | - $this->_question_model= EEM_Question::instance(); |
|
75 | - $this->_question_group_model=EEM_Question_Group::instance(); |
|
76 | - parent::__construct( $routing ); |
|
71 | + public function __construct($routing = TRUE) { |
|
72 | + require_once(EE_MODELS.'EEM_Question.model.php'); |
|
73 | + require_once(EE_MODELS.'EEM_Question_Group.model.php'); |
|
74 | + $this->_question_model = EEM_Question::instance(); |
|
75 | + $this->_question_group_model = EEM_Question_Group::instance(); |
|
76 | + parent::__construct($routing); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | *_set_page_routes |
110 | 110 | */ |
111 | 111 | protected function _set_page_routes() { |
112 | - $qst_id = ! empty( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0; |
|
112 | + $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
113 | 113 | $this->_page_routes = array( |
114 | 114 | 'default' => array( |
115 | 115 | 'func' => '_questions_overview_list_table', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | 'update_question' => array( |
132 | 132 | 'func' => '_insert_or_update_question', |
133 | - 'args' => array('new_question' => FALSE ), |
|
133 | + 'args' => array('new_question' => FALSE), |
|
134 | 134 | 'capability' => 'ee_edit_question', |
135 | 135 | 'obj_id' => $qst_id, |
136 | 136 | 'noheader' => TRUE, |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | 'filename' => 'registration_form_questions_overview_views_bulk_actions_search' |
166 | 166 | ) |
167 | 167 | ), |
168 | - 'help_tour' => array( 'Registration_Form_Questions_Overview_Help_Tour'), |
|
168 | + 'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'), |
|
169 | 169 | 'require_nonce' => FALSE, |
170 | 170 | 'qtips' => array( |
171 | 171 | 'EE_Registration_Form_Tips' |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | 'filename' => 'registration_form_question_groups' |
185 | 185 | ), |
186 | 186 | ), |
187 | - 'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'), |
|
187 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
188 | 188 | 'require_nonce' => FALSE |
189 | 189 | ), |
190 | 190 | |
@@ -193,16 +193,16 @@ discard block |
||
193 | 193 | 'label' => esc_html__('Edit Question', 'event_espresso'), |
194 | 194 | 'order' => 15, |
195 | 195 | 'persistent' => FALSE, |
196 | - 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
196 | + 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), $this->_current_page_view_url) : $this->_admin_base_url |
|
197 | 197 | ), |
198 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
198 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
199 | 199 | 'help_tabs' => array( |
200 | 200 | 'registration_form_edit_question_group_help_tab' => array( |
201 | 201 | 'title' => esc_html__('Edit Question', 'event_espresso'), |
202 | 202 | 'filename' => 'registration_form_edit_question' |
203 | 203 | ), |
204 | 204 | ), |
205 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'), |
|
205 | + 'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'), |
|
206 | 206 | 'require_nonce' => FALSE |
207 | 207 | ), |
208 | 208 | ); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | //none of the below group are currently used for Event Categories |
231 | 231 | protected function _add_feature_pointers() {} |
232 | 232 | public function load_scripts_styles() { |
233 | - wp_register_style( 'espresso_registration', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
233 | + wp_register_style('espresso_registration', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
234 | 234 | wp_enqueue_style('espresso_registration'); |
235 | 235 | } |
236 | 236 | public function admin_init() {} |
@@ -246,20 +246,20 @@ discard block |
||
246 | 246 | |
247 | 247 | public function load_scripts_styles_add_question() { |
248 | 248 | $this->load_scripts_styles_forms(); |
249 | - wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
250 | - wp_enqueue_script( 'espresso_registration_form_single' ); |
|
249 | + wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
250 | + wp_enqueue_script('espresso_registration_form_single'); |
|
251 | 251 | } |
252 | 252 | public function load_scripts_styles_edit_question() { |
253 | 253 | $this->load_scripts_styles_forms(); |
254 | - wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
255 | - wp_enqueue_script( 'espresso_registration_form_single' ); |
|
254 | + wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
255 | + wp_enqueue_script('espresso_registration_form_single'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
259 | 259 | |
260 | 260 | |
261 | 261 | public function recaptcha_info_help_tab() { |
262 | - $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
262 | + $template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php'; |
|
263 | 263 | EEH_Template::display_template($template, array()); |
264 | 264 | } |
265 | 265 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | ) |
292 | 292 | ); |
293 | 293 | |
294 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) { |
|
294 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) { |
|
295 | 295 | $this->_views['trash'] = array( |
296 | 296 | 'slug' => 'trash', |
297 | 297 | 'label' => esc_html__('Trash', 'event_espresso'), |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | */ |
310 | 310 | protected function _questions_groups_preview() { |
311 | 311 | $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso'); |
312 | - $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__( 'Preview Question Groups Overview List Table screenshot', 'event_espresso' ) . '" />'; |
|
313 | - $this->_template_args['preview_text'] = '<strong>'.esc_html__( 'Question Groups is a feature that is only available in the Caffeinated version of Event Espresso. With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso' ).'</strong>'; |
|
314 | - $this->display_admin_caf_preview_page( 'question_groups_tab' ); |
|
312 | + $this->_template_args['preview_img'] = '<img src="'.REGISTRATION_FORM_ASSETS_URL.'caf_reg_form_preview.jpg" alt="'.esc_attr__('Preview Question Groups Overview List Table screenshot', 'event_espresso').'" />'; |
|
313 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__('Question Groups is a feature that is only available in the Caffeinated version of Event Espresso. With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso').'</strong>'; |
|
314 | + $this->display_admin_caf_preview_page('question_groups_tab'); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -322,58 +322,58 @@ discard block |
||
322 | 322 | * @param \EEM_Base $model |
323 | 323 | * @return array where each key is the name of a model's field/db column, and each value is its value. |
324 | 324 | */ |
325 | - protected function _set_column_values_for(EEM_Base $model){ |
|
326 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
327 | - $set_column_values=array(); |
|
325 | + protected function _set_column_values_for(EEM_Base $model) { |
|
326 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
327 | + $set_column_values = array(); |
|
328 | 328 | |
329 | 329 | //some initial checks for proper values. |
330 | 330 | //if QST_admin_only, then no matter what QST_required is we disable. |
331 | - if ( !empty( $this->_req_data['QST_admin_only'] ) ) { |
|
331 | + if ( ! empty($this->_req_data['QST_admin_only'])) { |
|
332 | 332 | $this->_req_data['QST_required'] = 0; |
333 | 333 | } |
334 | - foreach($model->field_settings() as $fieldName=>$settings){ |
|
334 | + foreach ($model->field_settings() as $fieldName=>$settings) { |
|
335 | 335 | // basically if QSG_identifier is empty or not set |
336 | - if ( $fieldName === 'QSG_identifier' && ( isset( $this->_req_data['QSG_identifier'] ) && empty( $this->_req_data['QSG_identifier'] ) )) { |
|
337 | - $QSG_name = isset( $this->_req_data['QSG_name'] ) ? $this->_req_data['QSG_name'] : '' ; |
|
338 | - $set_column_values[$fieldName] = sanitize_title($QSG_name ) . '-' . uniqid( '', true ); |
|
336 | + if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
|
337 | + $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
|
338 | + $set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid('', true); |
|
339 | 339 | // dd($set_column_values); |
340 | 340 | } |
341 | 341 | //if the admin label is blank, use a slug version of the question text |
342 | - else if ( $fieldName === 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] ) )) { |
|
343 | - $QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ; |
|
344 | - $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10)); |
|
342 | + else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
|
343 | + $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
|
344 | + $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
348 | - else if ( $fieldName === 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) { |
|
348 | + else if ($fieldName === 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) { |
|
349 | 349 | $set_column_values[$fieldName] = 0; |
350 | 350 | } |
351 | 351 | |
352 | - else if ( $fieldName === 'QST_max' ) { |
|
352 | + else if ($fieldName === 'QST_max') { |
|
353 | 353 | $qst_system = EEM_Question::instance()->get_var( |
354 | 354 | array( |
355 | 355 | array( |
356 | - 'QST_ID' => isset( $this->_req_data[ 'QST_ID' ] ) ? $this->_req_data[ 'QST_ID' ] : 0 |
|
356 | + 'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0 |
|
357 | 357 | ) |
358 | 358 | ), |
359 | 359 | 'QST_system' ); |
360 | - $max_max = EEM_Question::instance()->absolute_max_for_system_question( $qst_system ); |
|
361 | - if( empty( $this->_req_data[ 'QST_max' ] ) || |
|
362 | - $this->_req_data[ 'QST_max' ] > $max_max ) { |
|
363 | - $set_column_values[ $fieldName ] = $max_max; |
|
360 | + $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
361 | + if (empty($this->_req_data['QST_max']) || |
|
362 | + $this->_req_data['QST_max'] > $max_max) { |
|
363 | + $set_column_values[$fieldName] = $max_max; |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
367 | 367 | |
368 | 368 | //only add a property to the array if it's not null (otherwise the model should just use the default value) |
369 | - if( |
|
370 | - ! isset( $set_column_values[ $fieldName ] ) && |
|
371 | - isset($this->_req_data[$fieldName] ) ){ |
|
372 | - $set_column_values[$fieldName]=$this->_req_data[$fieldName]; |
|
369 | + if ( |
|
370 | + ! isset($set_column_values[$fieldName]) && |
|
371 | + isset($this->_req_data[$fieldName]) ) { |
|
372 | + $set_column_values[$fieldName] = $this->_req_data[$fieldName]; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | } |
376 | - return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
376 | + return $set_column_values; //validation fo this data to be performed by the model before insertion. |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -392,39 +392,39 @@ discard block |
||
392 | 392 | * _edit_question |
393 | 393 | */ |
394 | 394 | protected function _edit_question() { |
395 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
396 | - $ID=isset( $this->_req_data['QST_ID'] ) && ! empty( $this->_req_data['QST_ID'] ) ? absint( $this->_req_data['QST_ID'] ) : FALSE; |
|
395 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
396 | + $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : FALSE; |
|
397 | 397 | |
398 | - switch( $this->_req_action ) { |
|
398 | + switch ($this->_req_action) { |
|
399 | 399 | case 'add_question' : |
400 | - $this->_admin_page_title = esc_html__( 'Add Question', 'event_espresso' ); |
|
400 | + $this->_admin_page_title = esc_html__('Add Question', 'event_espresso'); |
|
401 | 401 | break; |
402 | 402 | case 'edit_question' : |
403 | - $this->_admin_page_title = esc_html__( 'Edit Question', 'event_espresso' ); |
|
403 | + $this->_admin_page_title = esc_html__('Edit Question', 'event_espresso'); |
|
404 | 404 | break; |
405 | 405 | default : |
406 | - $this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action )); |
|
406 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | // add PRC_ID to title if editing |
410 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
411 | - if($ID){ |
|
412 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
413 | - $additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID)); |
|
410 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
411 | + if ($ID) { |
|
412 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
413 | + $additional_hidden_fields = array('QST_ID'=>array('type'=>'hidden', 'value'=>$ID)); |
|
414 | 414 | $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
415 | - }else{ |
|
416 | - $question= EE_Question::new_instance(); |
|
415 | + } else { |
|
416 | + $question = EE_Question::new_instance(); |
|
417 | 417 | $question->set_order_to_latest(); |
418 | 418 | $this->_set_add_edit_form_tags('insert_question'); |
419 | 419 | } |
420 | - $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category( $question->type() ) : $this->_question_model->allowed_question_types(); |
|
421 | - $this->_template_args['QST_ID']=$ID; |
|
422 | - $this->_template_args['question']=$question; |
|
423 | - $this->_template_args['question_types']= $question_types; |
|
424 | - $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( $question->system_ID() ); |
|
420 | + $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); |
|
421 | + $this->_template_args['QST_ID'] = $ID; |
|
422 | + $this->_template_args['question'] = $question; |
|
423 | + $this->_template_args['question_types'] = $question_types; |
|
424 | + $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question($question->system_ID()); |
|
425 | 425 | $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
426 | - $this->_set_publish_post_box_vars( 'id', $ID ); |
|
427 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', $this->_template_args, TRUE ); |
|
426 | + $this->_set_publish_post_box_vars('id', $ID); |
|
427 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php', $this->_template_args, TRUE); |
|
428 | 428 | |
429 | 429 | // the details template wrapper |
430 | 430 | $this->display_admin_page_with_sidebar(); |
@@ -439,18 +439,18 @@ discard block |
||
439 | 439 | EE_Registry::instance()->load_helper('HTML'); |
440 | 440 | $descriptions = ''; |
441 | 441 | $question_type_descriptions = EEM_Question::instance()->question_descriptions(); |
442 | - foreach ( $question_type_descriptions as $type => $question_type_description ) { |
|
443 | - if ( $type == 'HTML_TEXTAREA' ) { |
|
442 | + foreach ($question_type_descriptions as $type => $question_type_description) { |
|
443 | + if ($type == 'HTML_TEXTAREA') { |
|
444 | 444 | $html = new EE_Simple_HTML_Validation_Strategy(); |
445 | 445 | $question_type_description .= sprintf( |
446 | - esc_html__( '%1$s(allowed tags: %2$s)', 'event_espresso' ), |
|
446 | + esc_html__('%1$s(allowed tags: %2$s)', 'event_espresso'), |
|
447 | 447 | '<br/>', |
448 | 448 | $html->get_list_of_allowed_tags() |
449 | 449 | ); |
450 | 450 | } |
451 | 451 | $descriptions .= EEH_HTML::p( |
452 | 452 | $question_type_description, |
453 | - 'question_type_description-' . $type, |
|
453 | + 'question_type_description-'.$type, |
|
454 | 454 | 'question_type_description description', |
455 | 455 | 'display:none;' |
456 | 456 | ); |
@@ -464,58 +464,58 @@ discard block |
||
464 | 464 | * @param bool|true $new_question |
465 | 465 | * @throws \EE_Error |
466 | 466 | */ |
467 | - protected function _insert_or_update_question( $new_question = TRUE) { |
|
468 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
469 | - $set_column_values=$this->_set_column_values_for($this->_question_model); |
|
470 | - if($new_question){ |
|
471 | - $ID=$this->_question_model->insert($set_column_values); |
|
467 | + protected function _insert_or_update_question($new_question = TRUE) { |
|
468 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
469 | + $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
470 | + if ($new_question) { |
|
471 | + $ID = $this->_question_model->insert($set_column_values); |
|
472 | 472 | $success = $ID ? true : false; |
473 | 473 | $action_desc = 'added'; |
474 | - }else{ |
|
475 | - $ID=absint($this->_req_data['QST_ID']); |
|
476 | - $pk=$this->_question_model->primary_key_name(); |
|
477 | - $wheres=array($pk=>$ID); |
|
474 | + } else { |
|
475 | + $ID = absint($this->_req_data['QST_ID']); |
|
476 | + $pk = $this->_question_model->primary_key_name(); |
|
477 | + $wheres = array($pk=>$ID); |
|
478 | 478 | unset($set_column_values[$pk]); |
479 | - $success= $this->_question_model->update($set_column_values,array($wheres)); |
|
480 | - $action_desc='updated'; |
|
479 | + $success = $this->_question_model->update($set_column_values, array($wheres)); |
|
480 | + $action_desc = 'updated'; |
|
481 | 481 | } |
482 | 482 | |
483 | - if ($ID){ |
|
483 | + if ($ID) { |
|
484 | 484 | //save the related options |
485 | 485 | //trash removed options, save old ones |
486 | 486 | //get list of all options |
487 | 487 | /** @type EE_Question $question */ |
488 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
489 | - $options=$question->options(); |
|
490 | - if(! empty($options)){ |
|
491 | - foreach($options as $option_ID=>$option){ |
|
492 | - $option_req_index=$this->_get_option_req_data_index($option_ID); |
|
493 | - if($option_req_index!==FALSE){ |
|
488 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
489 | + $options = $question->options(); |
|
490 | + if ( ! empty($options)) { |
|
491 | + foreach ($options as $option_ID=>$option) { |
|
492 | + $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
493 | + if ($option_req_index !== FALSE) { |
|
494 | 494 | $option->save($this->_req_data['question_options'][$option_req_index]); |
495 | - }else{ |
|
495 | + } else { |
|
496 | 496 | //not found, remove it |
497 | 497 | $option->delete(); |
498 | 498 | } |
499 | 499 | } |
500 | 500 | } |
501 | 501 | //save new related options |
502 | - foreach($this->_req_data['question_options'] as $index=>$option_req_data){ |
|
503 | - if( empty($option_req_data['QSO_ID'] ) && ( ( isset( $option_req_data['QSO_value'] ) && $option_req_data['QSO_value'] !== '' ) || ! empty( $option_req_data['QSO_desc'] ) ) ) {//no ID! save it! |
|
504 | - if( ! isset( $option_req_data['QSO_value'] ) || $option_req_data['QSO_value'] === '' ){ |
|
505 | - $option_req_data['QSO_value']=$option_req_data['QSO_desc']; |
|
502 | + foreach ($this->_req_data['question_options'] as $index=>$option_req_data) { |
|
503 | + if (empty($option_req_data['QSO_ID']) && ((isset($option_req_data['QSO_value']) && $option_req_data['QSO_value'] !== '') || ! empty($option_req_data['QSO_desc']))) {//no ID! save it! |
|
504 | + if ( ! isset($option_req_data['QSO_value']) || $option_req_data['QSO_value'] === '') { |
|
505 | + $option_req_data['QSO_value'] = $option_req_data['QSO_desc']; |
|
506 | 506 | } |
507 | - $new_option=EE_Question_Option::new_instance( array( 'QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID())); |
|
507 | + $new_option = EE_Question_Option::new_instance(array('QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID())); |
|
508 | 508 | $new_option->save(); |
509 | 509 | } |
510 | 510 | } |
511 | 511 | } |
512 | - $query_args = array( 'action' => 'edit_question', 'QST_ID' => $ID ); |
|
513 | - if ( $success !== FALSE ) { |
|
514 | - $msg = $new_question ? sprintf( esc_html__('The %s has been created', 'event_espresso'), $this->_question_model->item_name() ) : sprintf( esc_html__('The %s has been updated', 'event_espresso' ), $this->_question_model->item_name() ); |
|
515 | - EE_Error::add_success( $msg ); |
|
512 | + $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
513 | + if ($success !== FALSE) { |
|
514 | + $msg = $new_question ? sprintf(esc_html__('The %s has been created', 'event_espresso'), $this->_question_model->item_name()) : sprintf(esc_html__('The %s has been updated', 'event_espresso'), $this->_question_model->item_name()); |
|
515 | + EE_Error::add_success($msg); |
|
516 | 516 | } |
517 | 517 | |
518 | - $this->_redirect_after_action( FALSE, '', $action_desc, $query_args, TRUE); |
|
518 | + $this->_redirect_after_action(FALSE, '', $action_desc, $query_args, TRUE); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | * @param int $ID of the question option to find |
529 | 529 | * @return int index in question_options array if successful, FALSE if unsuccessful |
530 | 530 | */ |
531 | - protected function _get_option_req_data_index($ID){ |
|
532 | - $req_data_for_question_options=$this->_req_data['question_options']; |
|
533 | - foreach($req_data_for_question_options as $num=>$option_data){ |
|
534 | - if( array_key_exists('QSO_ID',$option_data) && (int)$option_data['QSO_ID'] === $ID ){ |
|
531 | + protected function _get_option_req_data_index($ID) { |
|
532 | + $req_data_for_question_options = $this->_req_data['question_options']; |
|
533 | + foreach ($req_data_for_question_options as $num=>$option_data) { |
|
534 | + if (array_key_exists('QSO_ID', $option_data) && (int) $option_data['QSO_ID'] === $ID) { |
|
535 | 535 | return $num; |
536 | 536 | } |
537 | 537 | } |
@@ -553,25 +553,25 @@ discard block |
||
553 | 553 | * @param int $current_page |
554 | 554 | * @return array lik EEM_Base::get_all's $query_params parameter |
555 | 555 | */ |
556 | - protected function get_query_params($model, $per_page=10,$current_page=10){ |
|
556 | + protected function get_query_params($model, $per_page = 10, $current_page = 10) { |
|
557 | 557 | $query_params = array(); |
558 | - $offset=($current_page-1)*$per_page; |
|
559 | - $query_params['limit']=array($offset,$per_page); |
|
560 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
558 | + $offset = ($current_page - 1) * $per_page; |
|
559 | + $query_params['limit'] = array($offset, $per_page); |
|
560 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
561 | 561 | $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
562 | 562 | $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
563 | - $query_params['order_by']=array( $field_to_order_by => $order ); |
|
564 | - $search_string = array_key_exists('s',$this->_req_data) ? $this->_req_data['s'] : null; |
|
565 | - if(! empty($search_string)){ |
|
566 | - if($model instanceof EEM_Question_Group){ |
|
567 | - $query_params[0]=array( |
|
563 | + $query_params['order_by'] = array($field_to_order_by => $order); |
|
564 | + $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
565 | + if ( ! empty($search_string)) { |
|
566 | + if ($model instanceof EEM_Question_Group) { |
|
567 | + $query_params[0] = array( |
|
568 | 568 | 'OR'=>array( |
569 | - 'QSG_name'=>array('LIKE',"%$search_string%"), |
|
570 | - 'QSG_desc'=>array('LIKE',"%$search_string%")) |
|
569 | + 'QSG_name'=>array('LIKE', "%$search_string%"), |
|
570 | + 'QSG_desc'=>array('LIKE', "%$search_string%")) |
|
571 | 571 | ); |
572 | - }else{ |
|
573 | - $query_params[0]=array( |
|
574 | - 'QST_display_text'=>array('LIKE',"%$search_string%") |
|
572 | + } else { |
|
573 | + $query_params[0] = array( |
|
574 | + 'QST_display_text'=>array('LIKE', "%$search_string%") |
|
575 | 575 | ); |
576 | 576 | } |
577 | 577 | } |
@@ -619,13 +619,13 @@ discard block |
||
619 | 619 | * @param bool|false $count |
620 | 620 | * @return \EE_Soft_Delete_Base_Class[]|int |
621 | 621 | */ |
622 | - public function get_questions( $per_page=10, $current_page = 1, $count = FALSE ) { |
|
622 | + public function get_questions($per_page = 10, $current_page = 1, $count = FALSE) { |
|
623 | 623 | $QST = EEM_Question::instance(); |
624 | 624 | $query_params = $this->get_query_params($QST, $per_page, $current_page); |
625 | - if ($count){ |
|
626 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
625 | + if ($count) { |
|
626 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
627 | 627 | $results = $QST->count($where); |
628 | - }else{ |
|
628 | + } else { |
|
629 | 629 | $results = $QST->get_all($query_params); |
630 | 630 | } |
631 | 631 | return $results; |
@@ -640,10 +640,10 @@ discard block |
||
640 | 640 | * @param bool|false $count |
641 | 641 | * @return \EE_Soft_Delete_Base_Class[]|int |
642 | 642 | */ |
643 | - public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) { |
|
644 | - $query_params =$this->get_query_params( EEM_Question::instance(), $per_page, $current_page); |
|
645 | - $where = isset( $query_params[0] ) ? array($query_params[0]) : array(); |
|
646 | - $questions =$count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
643 | + public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) { |
|
644 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
645 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
646 | + $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
647 | 647 | return $questions; |
648 | 648 | } |
649 | 649 | |
@@ -655,12 +655,12 @@ discard block |
||
655 | 655 | * @param bool|false $count |
656 | 656 | * @return \EE_Soft_Delete_Base_Class[] |
657 | 657 | */ |
658 | - public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
658 | + public function get_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
659 | 659 | /** @type EEM_Question_Group $questionGroupModel */ |
660 | 660 | $questionGroupModel = EEM_Question_Group::instance(); |
661 | 661 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
662 | 662 | return $questionGroupModel->get_all( |
663 | - $this->get_query_params( $questionGroupModel, $per_page, $current_page ) |
|
663 | + $this->get_query_params($questionGroupModel, $per_page, $current_page) |
|
664 | 664 | ); |
665 | 665 | } |
666 | 666 | |
@@ -677,36 +677,36 @@ discard block |
||
677 | 677 | |
678 | 678 | $this->_template_args['values'] = $this->_yes_no_values; |
679 | 679 | |
680 | - $this->_template_args['use_captcha'] = isset( EE_Registry::instance()->CFG->registration->use_captcha ) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE; |
|
681 | - $this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"': ''; |
|
680 | + $this->_template_args['use_captcha'] = isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE; |
|
681 | + $this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"' : ''; |
|
682 | 682 | |
683 | - $this->_template_args['recaptcha_publickey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) : ''; |
|
684 | - $this->_template_args['recaptcha_privatekey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) : ''; |
|
685 | - $this->_template_args['recaptcha_width'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_width ) ? absint( EE_Registry::instance()->CFG->registration->recaptcha_width ) : 500; |
|
683 | + $this->_template_args['recaptcha_publickey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_publickey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_publickey) : ''; |
|
684 | + $this->_template_args['recaptcha_privatekey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) : ''; |
|
685 | + $this->_template_args['recaptcha_width'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_width) ? absint(EE_Registry::instance()->CFG->registration->recaptcha_width) : 500; |
|
686 | 686 | |
687 | 687 | $this->_template_args['recaptcha_theme_options'] = array( |
688 | - array('id' => 'red','text'=> esc_html__('Red', 'event_espresso')), |
|
689 | - array('id' => 'white','text'=> esc_html__('White', 'event_espresso')), |
|
690 | - array('id' => 'blackglass','text'=> esc_html__('Blackglass', 'event_espresso')), |
|
691 | - array('id' => 'clean','text'=> esc_html__('Clean', 'event_espresso')) |
|
688 | + array('id' => 'red', 'text'=> esc_html__('Red', 'event_espresso')), |
|
689 | + array('id' => 'white', 'text'=> esc_html__('White', 'event_espresso')), |
|
690 | + array('id' => 'blackglass', 'text'=> esc_html__('Blackglass', 'event_espresso')), |
|
691 | + array('id' => 'clean', 'text'=> esc_html__('Clean', 'event_espresso')) |
|
692 | 692 | ); |
693 | - $this->_template_args['recaptcha_theme'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_theme ) ? EE_Registry::instance()->CFG->registration->get_pretty( 'recaptcha_theme' ) : 'clean'; |
|
693 | + $this->_template_args['recaptcha_theme'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_theme) ? EE_Registry::instance()->CFG->registration->get_pretty('recaptcha_theme') : 'clean'; |
|
694 | 694 | |
695 | 695 | $this->_template_args['recaptcha_language_options'] = array( |
696 | - array('id' => 'en','text'=> esc_html__('English', 'event_espresso')), |
|
697 | - array('id' => 'es','text'=> esc_html__('Spanish', 'event_espresso')), |
|
698 | - array('id' => 'nl','text'=> esc_html__('Dutch', 'event_espresso')), |
|
699 | - array('id' => 'fr','text'=> esc_html__('French', 'event_espresso')), |
|
700 | - array('id' => 'de','text'=> esc_html__('German', 'event_espresso')), |
|
701 | - array('id' => 'pt','text'=> esc_html__('Portuguese', 'event_espresso')), |
|
702 | - array('id' => 'ru','text'=> esc_html__('Russian', 'event_espresso')), |
|
703 | - array('id' => 'tr','text'=> esc_html__('Turkish', 'event_espresso')) |
|
696 | + array('id' => 'en', 'text'=> esc_html__('English', 'event_espresso')), |
|
697 | + array('id' => 'es', 'text'=> esc_html__('Spanish', 'event_espresso')), |
|
698 | + array('id' => 'nl', 'text'=> esc_html__('Dutch', 'event_espresso')), |
|
699 | + array('id' => 'fr', 'text'=> esc_html__('French', 'event_espresso')), |
|
700 | + array('id' => 'de', 'text'=> esc_html__('German', 'event_espresso')), |
|
701 | + array('id' => 'pt', 'text'=> esc_html__('Portuguese', 'event_espresso')), |
|
702 | + array('id' => 'ru', 'text'=> esc_html__('Russian', 'event_espresso')), |
|
703 | + array('id' => 'tr', 'text'=> esc_html__('Turkish', 'event_espresso')) |
|
704 | 704 | ); |
705 | - $this->_template_args['recaptcha_language'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_language ) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en'; |
|
705 | + $this->_template_args['recaptcha_language'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_language) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en'; |
|
706 | 706 | |
707 | - $this->_set_add_edit_form_tags( 'update_reg_form_settings' ); |
|
708 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
709 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'reg_form_settings.template.php', $this->_template_args, TRUE ); |
|
707 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
708 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
709 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'reg_form_settings.template.php', $this->_template_args, TRUE); |
|
710 | 710 | $this->display_admin_page_with_sidebar(); |
711 | 711 | } |
712 | 712 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | *_question_model EEM_Question model instance (for queries) |
51 | 51 | * |
52 | 52 | * @var EEM_Question $_question_model; |
53 | - */ |
|
53 | + */ |
|
54 | 54 | protected $_question_model; |
55 | 55 | |
56 | 56 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ), |
152 | 152 | 'list_table' => 'Registration_Form_Questions_Admin_List_Table', |
153 | 153 | 'metaboxes' => $this->_default_espresso_metaboxes, |
154 | - 'help_tabs' => array( |
|
154 | + 'help_tabs' => array( |
|
155 | 155 | 'registration_form_questions_overview_help_tab' => array( |
156 | 156 | 'title' => esc_html__('Questions Overview', 'event_espresso'), |
157 | 157 | 'filename' => 'registration_form_questions_overview' |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | 'filename' => 'registration_form_edit_question' |
203 | 203 | ), |
204 | 204 | ), |
205 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'), |
|
205 | + 'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'), |
|
206 | 206 | 'require_nonce' => FALSE |
207 | 207 | ), |
208 | 208 | ); |