@@ -1,1 +1,1 @@ |
||
1 | -<?php printf( esc_html__('Mijireh is an off-site payment method for accepting payments online through over 80+ payment gateways and is available to event organizers in many countries. An account with Mijireh is required to accept payments. Need a Mijireh account? %1$sClick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/mijireh/" target="_blank">','</a>' ); |
|
2 | 1 | \ No newline at end of file |
2 | +<?php printf(esc_html__('Mijireh is an off-site payment method for accepting payments online through over 80+ payment gateways and is available to event organizers in many countries. An account with Mijireh is required to accept payments. Need a Mijireh account? %1$sClick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/mijireh/" target="_blank">', '</a>'); |
|
3 | 3 | \ No newline at end of file |
@@ -1,1 +1,1 @@ |
||
1 | -<?php printf( esc_html__('PayPal Pro (Website Payments Pro) is an on-site payment method for accepting credit and debit cards and is available to event organizers in the United States, United Kingdom, and Canada. An account with PayPal is required to accept payments. Need a PayPal Pro account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalpro/" target="_blank">','</a>' ); |
|
2 | 1 | \ No newline at end of file |
2 | +<?php printf(esc_html__('PayPal Pro (Website Payments Pro) is an on-site payment method for accepting credit and debit cards and is available to event organizers in the United States, United Kingdom, and Canada. An account with PayPal is required to accept payments. Need a PayPal Pro account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalpro/" target="_blank">', '</a>'); |
|
3 | 3 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -30,25 +30,25 @@ discard block |
||
30 | 30 | class Extend_Events_Admin_Page extends Events_Admin_Page { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $routing = TRUE ) { |
|
34 | - parent::__construct( $routing ); |
|
35 | - define( 'EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
36 | - define( 'EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
37 | - define( 'EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
33 | + public function __construct($routing = TRUE) { |
|
34 | + parent::__construct($routing); |
|
35 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/'); |
|
36 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/'); |
|
37 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
41 | 41 | protected function _extend_page_config() { |
42 | 42 | |
43 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
43 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events'; |
|
44 | 44 | $default_espresso_boxes = $this->_default_espresso_metaboxes; |
45 | 45 | |
46 | 46 | //is there a evt_id in the request? |
47 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
48 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
47 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
48 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
49 | 49 | |
50 | 50 | //tkt_id? |
51 | - $tkt_id = !empty( $this->_req_data['TKT_ID'] ) && ! is_array( $this->_req_data['TKT_ID'] ) ? $this->_req_data['TKT_ID'] : 0; |
|
51 | + $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) ? $this->_req_data['TKT_ID'] : 0; |
|
52 | 52 | |
53 | 53 | $new_page_routes = array( |
54 | 54 | 'duplicate_event' => array( |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | 'capability' => 'ee_delete_default_ticket', |
67 | 67 | 'obj_id' => $tkt_id, |
68 | 68 | 'noheader' => TRUE, |
69 | - 'args' => array( 'trash' => TRUE ) |
|
69 | + 'args' => array('trash' => TRUE) |
|
70 | 70 | ), |
71 | 71 | 'trash_tickets' => array( |
72 | 72 | 'func' => '_trash_or_restore_ticket', |
73 | 73 | 'capability' => 'ee_delete_default_tickets', |
74 | 74 | 'noheader' => TRUE, |
75 | - 'args' => array( 'trash' => TRUE ) |
|
75 | + 'args' => array('trash' => TRUE) |
|
76 | 76 | ), |
77 | 77 | 'restore_ticket' => array( |
78 | 78 | 'func' => '_trash_or_restore_ticket', |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ) |
133 | 133 | ); |
134 | 134 | |
135 | - $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
|
135 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
136 | 136 | |
137 | 137 | |
138 | 138 | //partial route/config override |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
145 | 145 | |
146 | 146 | //add tickets tab but only if there are more than one default ticket! |
147 | - $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(array( array('TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ); |
|
148 | - if ( $tkt_count > 1 ) { |
|
147 | + $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(array(array('TKT_is_default' => 1)), 'TKT_ID', TRUE); |
|
148 | + if ($tkt_count > 1) { |
|
149 | 149 | $new_page_config = array( |
150 | 150 | 'ticket_list_table' => array( |
151 | 151 | 'nav' => array( |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | 'label' => esc_html__('Templates', 'event_espresso'), |
165 | 165 | 'order' => 30 |
166 | 166 | ), |
167 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
167 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
168 | 168 | 'help_tabs' => array( |
169 | 169 | 'general_settings_templates_help_tab' => array( |
170 | 170 | 'title' => __('Templates', 'event_espresso'), |
171 | 171 | 'filename' => 'general_settings_templates' |
172 | 172 | ) |
173 | 173 | ), |
174 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
174 | + 'help_tour' => array('Templates_Help_Tour'), |
|
175 | 175 | 'require_nonce' => FALSE |
176 | 176 | ); |
177 | 177 | |
@@ -190,26 +190,26 @@ discard block |
||
190 | 190 | // 'metaboxes' => $default_espresso_boxes, |
191 | 191 | // 'require_nonce' => FALSE |
192 | 192 | // ); |
193 | - $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
|
193 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
194 | 194 | |
195 | 195 | //add filters and actions |
196 | 196 | //modifying _views |
197 | - add_filter('FHEE_event_datetime_metabox_add_additional_date_time_template', array( $this, 'add_additional_datetime_button' ), 10, 2 ); |
|
198 | - add_filter('FHEE_event_datetime_metabox_clone_button_template', array( $this, 'add_datetime_clone_button' ), 10, 2 ); |
|
199 | - add_filter('FHEE_event_datetime_metabox_timezones_template', array( $this, 'datetime_timezones_template'), 10, 2 ); |
|
197 | + add_filter('FHEE_event_datetime_metabox_add_additional_date_time_template', array($this, 'add_additional_datetime_button'), 10, 2); |
|
198 | + add_filter('FHEE_event_datetime_metabox_clone_button_template', array($this, 'add_datetime_clone_button'), 10, 2); |
|
199 | + add_filter('FHEE_event_datetime_metabox_timezones_template', array($this, 'datetime_timezones_template'), 10, 2); |
|
200 | 200 | |
201 | 201 | |
202 | 202 | //filters for event list table |
203 | - add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array( $this, 'list_table_filters'), 10, 2); |
|
204 | - add_filter('FHEE__Events_Admin_List_Table__column_actions__action_links', array( $this, 'extra_list_table_actions'), 10, 2 ); |
|
203 | + add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
204 | + add_filter('FHEE__Events_Admin_List_Table__column_actions__action_links', array($this, 'extra_list_table_actions'), 10, 2); |
|
205 | 205 | |
206 | 206 | //legend item |
207 | - add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array( $this, 'additional_legend_items') ); |
|
207 | + add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
208 | 208 | |
209 | - add_action('admin_init', array( $this, 'admin_init') ); |
|
209 | + add_action('admin_init', array($this, 'admin_init')); |
|
210 | 210 | |
211 | 211 | //heartbeat stuff |
212 | - add_filter( 'heartbeat_received', array( $this, 'heartbeat_response' ), 10, 2 ); |
|
212 | + add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2); |
|
213 | 213 | |
214 | 214 | } |
215 | 215 | |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | EE_Registry::$i18n_js_strings = array_merge( |
223 | 223 | EE_Registry::$i18n_js_strings, |
224 | 224 | array( |
225 | - 'image_confirm' => __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ), |
|
226 | - 'event_starts_on' => __( 'Event Starts on', 'event_espresso' ), |
|
227 | - 'event_ends_on' => __( 'Event Ends on', 'event_espresso' ), |
|
228 | - 'event_datetime_actions' => __( 'Actions', 'event_espresso' ), |
|
229 | - 'event_clone_dt_msg' => __( 'Clone this Event Date and Time', 'event_espresso' ), |
|
230 | - 'remove_event_dt_msg' => __( 'Remove this Event Time', 'event_espresso' ) |
|
225 | + 'image_confirm' => __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'), |
|
226 | + 'event_starts_on' => __('Event Starts on', 'event_espresso'), |
|
227 | + 'event_ends_on' => __('Event Ends on', 'event_espresso'), |
|
228 | + 'event_datetime_actions' => __('Actions', 'event_espresso'), |
|
229 | + 'event_clone_dt_msg' => __('Clone this Event Date and Time', 'event_espresso'), |
|
230 | + 'remove_event_dt_msg' => __('Remove this Event Time', 'event_espresso') |
|
231 | 231 | ) |
232 | 232 | ); |
233 | 233 | } |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return array possibly appended response. |
244 | 244 | */ |
245 | - public function heartbeat_response( $response, $data ) { |
|
245 | + public function heartbeat_response($response, $data) { |
|
246 | 246 | /** |
247 | 247 | * check whether count of tickets is approaching the potential |
248 | 248 | * limits for the server. |
249 | 249 | */ |
250 | - if ( ! empty( $data['input_count'] ) ) { |
|
250 | + if ( ! empty($data['input_count'])) { |
|
251 | 251 | $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check($data['input_count']); |
252 | 252 | } |
253 | 253 | |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | |
263 | 263 | |
264 | 264 | |
265 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
266 | - $return = parent::extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ); |
|
265 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
266 | + $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
267 | 267 | //make sure this is only when editing |
268 | - if ( !empty( $id ) ) { |
|
269 | - $href = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'duplicate_event', 'EVT_ID' => $id), $this->_admin_base_url ); |
|
268 | + if ( ! empty($id)) { |
|
269 | + $href = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_event', 'EVT_ID' => $id), $this->_admin_base_url); |
|
270 | 270 | $title = esc_attr__('Duplicate Event', 'event_espresso'); |
271 | - $return .= '<a href="' . $href . '" title="' . $title . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' . $title . '</button>'; |
|
271 | + $return .= '<a href="'.$href.'" title="'.$title.'" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">'.$title.'</button>'; |
|
272 | 272 | } |
273 | 273 | return $return; |
274 | 274 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | 'label' => __('Trash', 'event_espresso'), |
292 | 292 | 'count' => 0, |
293 | 293 | 'bulk_action' => array( |
294 | - 'restore_tickets' => __('Restore from Trash' , 'event_espresso'), |
|
294 | + 'restore_tickets' => __('Restore from Trash', 'event_espresso'), |
|
295 | 295 | 'delete_tickets' => __('Delete Permanently', 'event_espresso') |
296 | 296 | ) |
297 | 297 | ) |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | |
303 | 303 | public function load_scripts_styles_edit() { |
304 | - wp_register_script( 'ee-event-editor-heartbeat', EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', array( 'ee_admin_js', 'heartbeat' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
304 | + wp_register_script('ee-event-editor-heartbeat', EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js', array('ee_admin_js', 'heartbeat'), EVENT_ESPRESSO_VERSION, TRUE); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * load accounting js. |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | |
321 | 321 | |
322 | 322 | |
323 | - public function add_additional_datetime_button( $template, $template_args ) { |
|
324 | - return EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', $template_args, TRUE); |
|
323 | + public function add_additional_datetime_button($template, $template_args) { |
|
324 | + return EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php', $template_args, TRUE); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | |
328 | 328 | |
329 | - public function add_datetime_clone_button( $template, $template_args ) { |
|
330 | - return EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', $template_args, TRUE ); |
|
329 | + public function add_datetime_clone_button($template, $template_args) { |
|
330 | + return EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php', $template_args, TRUE); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | |
334 | 334 | |
335 | - public function datetime_timezones_template( $template, $template_args ) { |
|
336 | - return EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', $template_args, TRUE ); |
|
335 | + public function datetime_timezones_template($template, $template_args) { |
|
336 | + return EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php', $template_args, TRUE); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | protected function _set_list_table_views_default() { |
343 | 343 | parent::_set_list_table_views_default(); |
344 | 344 | $export_label = __('Export Events', 'event_espresso'); |
345 | - if ( EE_Registry::instance()->CAP->current_user_can( 'export', 'espresso_events_export' ) ) { |
|
345 | + if (EE_Registry::instance()->CAP->current_user_can('export', 'espresso_events_export')) { |
|
346 | 346 | // $this->_views['all']['bulk_action']['export_events'] = $export_label; |
347 | 347 | // $this->_views['draft']['bulk_action']['export_events'] = $export_label; |
348 | 348 | |
349 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
349 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
350 | 350 | // $this->_views['trash']['bulk_action']['export_events'] = $export_label; |
351 | 351 | } |
352 | 352 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | ) |
373 | 373 | ); |
374 | 374 | |
375 | - $this->_views = array_merge( $this->_views, $new_views); |
|
375 | + $this->_views = array_merge($this->_views, $new_views); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -386,17 +386,17 @@ discard block |
||
386 | 386 | |
387 | 387 | |
388 | 388 | |
389 | - public function extra_list_table_actions( $actionlinks, $event ) { |
|
390 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'espresso_registrations_reports', $event->ID() ) ) { |
|
389 | + public function extra_list_table_actions($actionlinks, $event) { |
|
390 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'espresso_registrations_reports', $event->ID())) { |
|
391 | 391 | $reports_query_args = array( |
392 | 392 | 'action' => 'reports', |
393 | 393 | 'EVT_ID' => $event->ID() |
394 | 394 | ); |
395 | - $reports_link = EE_Admin_Page::add_query_args_and_nonce( $reports_query_args, REG_ADMIN_URL ); |
|
396 | - $actionlinks[] = '<a href="' . $reports_link . '" title="' . esc_attr__('View Report', 'event_espresso') . '"><div class="dashicons dashicons-chart-bar"></div></a>' . "\n\t"; |
|
395 | + $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
396 | + $actionlinks[] = '<a href="'.$reports_link.'" title="'.esc_attr__('View Report', 'event_espresso').'"><div class="dashicons dashicons-chart-bar"></div></a>'."\n\t"; |
|
397 | 397 | } |
398 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
399 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
398 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
399 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
400 | 400 | $actionlinks[] = EEH_MSG_Template::get_message_action_link( |
401 | 401 | 'see_notifications_for', |
402 | 402 | null, |
@@ -411,15 +411,15 @@ discard block |
||
411 | 411 | |
412 | 412 | |
413 | 413 | public function additional_legend_items($items) { |
414 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'espresso_registrations_reports' ) ) { |
|
414 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'espresso_registrations_reports')) { |
|
415 | 415 | $items['reports'] = array( |
416 | 416 | 'class' => 'dashicons dashicons-chart-bar', |
417 | 417 | 'desc' => __('Event Reports', 'event_espresso') |
418 | 418 | ); |
419 | 419 | } |
420 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
421 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' ); |
|
422 | - if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) { |
|
420 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
421 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
422 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
423 | 423 | $items['view_related_messages'] = array( |
424 | 424 | 'class' => $related_for_icon['css_class'], |
425 | 425 | 'desc' => $related_for_icon['label'], |
@@ -444,17 +444,17 @@ discard block |
||
444 | 444 | */ |
445 | 445 | protected function _duplicate_event() { |
446 | 446 | //first make sure the ID for the event is in the request. If it isnt' then we need to bail and redirect back to overview list table (cause how did we get here?) |
447 | - if ( !isset( $this->_req_data['EVT_ID'] ) ) { |
|
448 | - EE_Error::add_error( __('In order to duplicate an event an Event ID is required. None was given.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
449 | - $this->_redirect_after_action( FALSE, '', '', array(), TRUE ); |
|
447 | + if ( ! isset($this->_req_data['EVT_ID'])) { |
|
448 | + EE_Error::add_error(__('In order to duplicate an event an Event ID is required. None was given.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
449 | + $this->_redirect_after_action(FALSE, '', '', array(), TRUE); |
|
450 | 450 | return; |
451 | 451 | } |
452 | 452 | |
453 | 453 | //k we've got EVT_ID so let's use that to get the event we'll duplicate |
454 | - $orig_event = EEM_Event::instance()->get_one_by_ID( $this->_req_data['EVT_ID'] ); |
|
454 | + $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
455 | 455 | |
456 | - if ( ! $orig_event instanceof EE_Event ) |
|
457 | - throw new EE_Error( sprintf( __('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), $this->_req_data['EVT_ID'] ) ); |
|
456 | + if ( ! $orig_event instanceof EE_Event) |
|
457 | + throw new EE_Error(sprintf(__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), $this->_req_data['EVT_ID'])); |
|
458 | 458 | |
459 | 459 | //k now let's clone the $orig_event before getting relations |
460 | 460 | $new_event = clone $orig_event; |
@@ -467,43 +467,43 @@ discard block |
||
467 | 467 | |
468 | 468 | |
469 | 469 | //reset the ID and modify other details to make it clear this is a dupe |
470 | - $new_event->set( 'EVT_ID', 0 ); |
|
471 | - $new_name = $new_event->name() . ' ' . __('**DUPLICATE**', 'event_espresso'); |
|
472 | - $new_event->set( 'EVT_name', $new_name ); |
|
473 | - $new_event->set( 'EVT_slug', wp_unique_post_slug( sanitize_title( $orig_event->name() ), 0, 'publish', 'espresso_events', 0 ) ); |
|
474 | - $new_event->set( 'status', 'draft' ); |
|
470 | + $new_event->set('EVT_ID', 0); |
|
471 | + $new_name = $new_event->name().' '.__('**DUPLICATE**', 'event_espresso'); |
|
472 | + $new_event->set('EVT_name', $new_name); |
|
473 | + $new_event->set('EVT_slug', wp_unique_post_slug(sanitize_title($orig_event->name()), 0, 'publish', 'espresso_events', 0)); |
|
474 | + $new_event->set('status', 'draft'); |
|
475 | 475 | |
476 | 476 | //duplicate discussion settings |
477 | - $new_event->set( 'comment_status', $orig_event->get('comment_status') ); |
|
478 | - $new_event->set( 'ping_status', $orig_event->get( 'ping_status' ) ); |
|
477 | + $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
478 | + $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
479 | 479 | |
480 | 480 | //save the new event |
481 | 481 | $new_event->save(); |
482 | 482 | |
483 | 483 | //venues |
484 | - foreach( $orig_ven as $ven ) { |
|
485 | - $new_event->_add_relation_to( $ven, 'Venue' ); |
|
484 | + foreach ($orig_ven as $ven) { |
|
485 | + $new_event->_add_relation_to($ven, 'Venue'); |
|
486 | 486 | } |
487 | 487 | $new_event->save(); |
488 | 488 | |
489 | 489 | |
490 | 490 | //now we need to get the question group relations and handle that |
491 | 491 | //first primary question groups |
492 | - $orig_primary_qgs = $orig_event->get_many_related('Question_Group', array( array('Event_Question_Group.EQG_primary' => 1 ) ) ); |
|
493 | - if ( !empty( $orig_primary_qgs ) ) { |
|
494 | - foreach ( $orig_primary_qgs as $id => $obj ) { |
|
495 | - if ( $obj instanceof EE_Question_Group ) { |
|
496 | - $new_event->_add_relation_to( $obj, 'Question_Group', array( 'EQG_primary' => 1 ) ); |
|
492 | + $orig_primary_qgs = $orig_event->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 1))); |
|
493 | + if ( ! empty($orig_primary_qgs)) { |
|
494 | + foreach ($orig_primary_qgs as $id => $obj) { |
|
495 | + if ($obj instanceof EE_Question_Group) { |
|
496 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1)); |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
500 | 500 | |
501 | 501 | //next additional attendee question groups |
502 | - $orig_additional_qgs = $orig_event->get_many_related('Question_Group', array( array('Event_Question_Group.EQG_primary' => 0 ) ) ); |
|
503 | - if ( !empty( $orig_additional_qgs ) ) { |
|
504 | - foreach ( $orig_additional_qgs as $id => $obj ) { |
|
505 | - if ( $obj instanceof EE_Question_Group ) { |
|
506 | - $new_event->_add_relation_to( $obj, 'Question_Group', array( 'EQG_primary' => 0 ) ); |
|
502 | + $orig_additional_qgs = $orig_event->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 0))); |
|
503 | + if ( ! empty($orig_additional_qgs)) { |
|
504 | + foreach ($orig_additional_qgs as $id => $obj) { |
|
505 | + if ($obj instanceof EE_Question_Group) { |
|
506 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0)); |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | } |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | |
515 | 515 | //k now that we have the new event saved we can loop through the datetimes and start adding relations. |
516 | 516 | $cloned_tickets = array(); |
517 | - foreach ( $orig_datetimes as $orig_dtt ) { |
|
517 | + foreach ($orig_datetimes as $orig_dtt) { |
|
518 | 518 | $new_dtt = clone $orig_dtt; |
519 | 519 | $orig_tkts = $orig_dtt->tickets(); |
520 | 520 | |
@@ -522,22 +522,22 @@ discard block |
||
522 | 522 | $new_dtt->set('DTT_ID', 0); |
523 | 523 | $new_dtt->set('DTT_sold', 0); |
524 | 524 | $new_dtt->save(); |
525 | - $new_event->_add_relation_to( $new_dtt, 'Datetime'); |
|
525 | + $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
526 | 526 | $new_event->save(); |
527 | 527 | |
528 | 528 | //now let's get the ticket relations setup. |
529 | - foreach ( (array) $orig_tkts as $orig_tkt ) { |
|
529 | + foreach ((array) $orig_tkts as $orig_tkt) { |
|
530 | 530 | //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
531 | - if ( ! $orig_tkt instanceof EE_Ticket ) |
|
531 | + if ( ! $orig_tkt instanceof EE_Ticket) |
|
532 | 532 | continue; |
533 | 533 | |
534 | 534 | //is this ticket archived? If it is then let's skip |
535 | - if ( $orig_tkt->get( 'TKT_deleted' ) ) { |
|
535 | + if ($orig_tkt->get('TKT_deleted')) { |
|
536 | 536 | continue; |
537 | 537 | } |
538 | 538 | |
539 | 539 | //does this original ticket already exist in the clone_tickets cache? If so we'll just use the new ticket from it. |
540 | - if ( isset( $cloned_tickets[$orig_tkt->ID()] ) ) { |
|
540 | + if (isset($cloned_tickets[$orig_tkt->ID()])) { |
|
541 | 541 | $new_tkt = $cloned_tickets[$orig_tkt->ID()]; |
542 | 542 | } else { |
543 | 543 | $new_tkt = clone $orig_tkt; |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | $new_tkt->save(); //make sure new ticket has ID. |
550 | 550 | |
551 | 551 | //price relations on new ticket need to be setup. |
552 | - foreach ( $orig_prices as $orig_price ) { |
|
552 | + foreach ($orig_prices as $orig_price) { |
|
553 | 553 | $new_price = clone $orig_price; |
554 | 554 | $new_price->set('PRC_ID', 0); |
555 | 555 | $new_price->save(); |
@@ -566,39 +566,39 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | //clone taxonomy information |
569 | - $taxonomies_to_clone_with = apply_filters( 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', array( 'espresso_event_categories', 'espresso_event_type', 'post_tag' ) ); |
|
569 | + $taxonomies_to_clone_with = apply_filters('FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', array('espresso_event_categories', 'espresso_event_type', 'post_tag')); |
|
570 | 570 | |
571 | 571 | //get terms for original event (notice) |
572 | - $orig_terms = wp_get_object_terms( $orig_event->ID(), $taxonomies_to_clone_with ); |
|
572 | + $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
573 | 573 | |
574 | 574 | //loop through terms and add them to new event. |
575 | - foreach ( $orig_terms as $term ) { |
|
576 | - wp_set_object_terms( $new_event->ID(), $term->term_id, $term->taxonomy, true ); |
|
575 | + foreach ($orig_terms as $term) { |
|
576 | + wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | |
580 | - do_action( 'AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event ); |
|
580 | + do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
581 | 581 | |
582 | 582 | //now let's redirect to the edit page for this duplicated event if we have a new event id. |
583 | - if ( $new_event->ID() ) { |
|
583 | + if ($new_event->ID()) { |
|
584 | 584 | $redirect_args = array( |
585 | 585 | 'post' => $new_event->ID(), |
586 | 586 | 'action' => 'edit' |
587 | 587 | ); |
588 | - EE_Error::add_success( __('Event successfully duplicated. Please review the details below and make any necessary edits', 'event_espresso') ); |
|
588 | + EE_Error::add_success(__('Event successfully duplicated. Please review the details below and make any necessary edits', 'event_espresso')); |
|
589 | 589 | } else { |
590 | 590 | $redirect_args = array( |
591 | 591 | 'action' => 'default' |
592 | 592 | ); |
593 | - EE_Error::add_error( __('Not able to duplicate event. Something went wrong.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
593 | + EE_Error::add_error(__('Not able to duplicate event. Something went wrong.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
594 | 594 | } |
595 | 595 | |
596 | - $this->_redirect_after_action(FALSE, '', '', $redirect_args, TRUE ); |
|
596 | + $this->_redirect_after_action(FALSE, '', '', $redirect_args, TRUE); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | |
600 | 600 | |
601 | - protected function _import_page(){ |
|
601 | + protected function _import_page() { |
|
602 | 602 | |
603 | 603 | $title = __('Import', 'event_espresso'); |
604 | 604 | $intro = __('If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', 'event_espresso'); |
@@ -606,8 +606,8 @@ discard block |
||
606 | 606 | $action = 'import_events'; |
607 | 607 | $type = 'csv'; |
608 | 608 | $this->_template_args['form'] = EE_Import::instance()->upload_form($title, $intro, $form_url, $action, $type); |
609 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'sample_export_file'),$this->_admin_base_url); |
|
610 | - $content = EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',$this->_template_args,true); |
|
609 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'sample_export_file'), $this->_admin_base_url); |
|
610 | + $content = EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php', $this->_template_args, true); |
|
611 | 611 | |
612 | 612 | |
613 | 613 | $this->_template_args['admin_page_content'] = $content; |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | * @return string html |
621 | 621 | */ |
622 | 622 | protected function _import_events() { |
623 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
623 | + require_once(EE_CLASSES.'EE_Import.class.php'); |
|
624 | 624 | $success = EE_Import::instance()->import(); |
625 | - $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'),true); |
|
625 | + $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
626 | 626 | |
627 | 627 | } |
628 | 628 | |
@@ -636,23 +636,23 @@ discard block |
||
636 | 636 | * @return file |
637 | 637 | */ |
638 | 638 | protected function _events_export() { |
639 | - if(isset($this->_req_data['EVT_ID'])){ |
|
639 | + if (isset($this->_req_data['EVT_ID'])) { |
|
640 | 640 | $event_ids = $this->_req_data['EVT_ID']; |
641 | - }elseif(isset($this->_req_data['EVT_IDs'])){ |
|
641 | + }elseif (isset($this->_req_data['EVT_IDs'])) { |
|
642 | 642 | $event_ids = $this->_req_data['EVT_IDs']; |
643 | - }else{ |
|
643 | + } else { |
|
644 | 644 | $event_ids = NULL; |
645 | 645 | } |
646 | 646 | //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
647 | 647 | $new_request_args = array( |
648 | 648 | 'export' => 'report', |
649 | 649 | 'action' => 'all_event_data', |
650 | - 'EVT_ID' => $event_ids , |
|
650 | + 'EVT_ID' => $event_ids, |
|
651 | 651 | ); |
652 | 652 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
653 | 653 | |
654 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
655 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
654 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
655 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
656 | 656 | $EE_Export = EE_Export::instance($this->_req_data); |
657 | 657 | $EE_Export->export(); |
658 | 658 | } |
@@ -674,11 +674,11 @@ discard block |
||
674 | 674 | 'category_ids' => $this->_req_data['EVT_CAT_ID'] |
675 | 675 | ); |
676 | 676 | |
677 | - $this->_req_data = array_merge( $this->_req_data, $new_request_args ); |
|
677 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
678 | 678 | |
679 | - if ( is_readable( EE_CLASSES . 'EE_Export.class.php') ) { |
|
680 | - require_once( EE_CLASSES . 'EE_Export.class.php'); |
|
681 | - $EE_Export = EE_Export::instance( $this->_req_data ); |
|
679 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
680 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
681 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
682 | 682 | $EE_Export->export(); |
683 | 683 | } |
684 | 684 | |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | /** |
690 | 690 | * Creates a sample CSV file for importing |
691 | 691 | */ |
692 | - protected function _sample_export_file(){ |
|
692 | + protected function _sample_export_file() { |
|
693 | 693 | // require_once(EE_CLASSES . 'EE_Export.class.php'); |
694 | 694 | EE_Export::instance()->export_sample(); |
695 | 695 | } |
@@ -706,10 +706,10 @@ discard block |
||
706 | 706 | * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
707 | 707 | * from General_Settings_Admin_Page to here. |
708 | 708 | */ |
709 | - $this->_template_args = apply_filters( 'FHEE__General_Settings_Admin_Page__template_settings__template_args', $this->_template_args ); |
|
710 | - $this->_set_add_edit_form_tags( 'update_template_settings' ); |
|
711 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
712 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', $this->_template_args, TRUE ); |
|
709 | + $this->_template_args = apply_filters('FHEE__General_Settings_Admin_Page__template_settings__template_args', $this->_template_args); |
|
710 | + $this->_set_add_edit_form_tags('update_template_settings'); |
|
711 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
712 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php', $this->_template_args, TRUE); |
|
713 | 713 | $this->display_admin_page_with_sidebar(); |
714 | 714 | } |
715 | 715 | |
@@ -721,24 +721,24 @@ discard block |
||
721 | 721 | * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
722 | 722 | * from General_Settings_Admin_Page to here. |
723 | 723 | */ |
724 | - EE_Registry::instance()->CFG->template_settings = apply_filters( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', EE_Registry::instance()->CFG->template_settings, $this->_req_data ); |
|
724 | + EE_Registry::instance()->CFG->template_settings = apply_filters('FHEE__General_Settings_Admin_Page__update_template_settings__data', EE_Registry::instance()->CFG->template_settings, $this->_req_data); |
|
725 | 725 | |
726 | 726 | |
727 | 727 | //update custom post type slugs and detect if we need to flush rewrite rules |
728 | 728 | $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
729 | - EE_Registry::instance()->CFG->core->event_cpt_slug = empty( $this->_req_data['event_cpt_slug'] ) ? EE_Registry::instance()->CFG->core->event_cpt_slug : sanitize_title_with_dashes( $this->_req_data['event_cpt_slug'] ); |
|
729 | + EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) ? EE_Registry::instance()->CFG->core->event_cpt_slug : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']); |
|
730 | 730 | |
731 | 731 | |
732 | 732 | $what = 'Template Settings'; |
733 | - $success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->template_settings, __FILE__, __FUNCTION__, __LINE__ ); |
|
733 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG->template_settings, __FILE__, __FUNCTION__, __LINE__); |
|
734 | 734 | |
735 | 735 | |
736 | - if ( EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug ) { |
|
737 | - update_option( 'ee_flush_rewrite_rules', true ); |
|
736 | + if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) { |
|
737 | + update_option('ee_flush_rewrite_rules', true); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | |
741 | - $this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'template_settings' ) ); |
|
741 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
742 | 742 | |
743 | 743 | } |
744 | 744 | |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | |
757 | 757 | $this->verify_cpt_object(); |
758 | 758 | |
759 | - add_meta_box('espresso_event_editor_event_options', __('Event Registration Options', 'event_espresso'), array( $this, 'registration_options_meta_box' ), $this->page_slug, 'side', 'core'); |
|
759 | + add_meta_box('espresso_event_editor_event_options', __('Event Registration Options', 'event_espresso'), array($this, 'registration_options_meta_box'), $this->page_slug, 'side', 'core'); |
|
760 | 760 | //add_meta_box('espresso_event_types', __('Event Type', 'event_espresso'), array( $this, 'event_type_meta_box' ), $this->page_slug, 'side', 'default' ); //add this back in when the feature is ready. |
761 | 761 | |
762 | 762 | //todo feature in progress |
@@ -780,16 +780,16 @@ discard block |
||
780 | 780 | array('id' => true, 'text' => __('Yes', 'event_espresso')), |
781 | 781 | array('id' => false, 'text' => __('No', 'event_espresso')) |
782 | 782 | ); |
783 | - $default_reg_status_values = EEM_Registration::reg_status_array(array(EEM_Registration::status_id_cancelled, EEM_Registration::status_id_declined, EEM_Registration::status_id_incomplete ), TRUE); |
|
783 | + $default_reg_status_values = EEM_Registration::reg_status_array(array(EEM_Registration::status_id_cancelled, EEM_Registration::status_id_declined, EEM_Registration::status_id_incomplete), TRUE); |
|
784 | 784 | $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(FALSE); |
785 | 785 | $template_args['_event'] = $this->_cpt_model_obj; |
786 | 786 | $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
787 | 787 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
788 | 788 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
789 | 789 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
790 | - $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input('EVT_default_registration_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status() ); |
|
791 | - $template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values ); |
|
792 | - $templatepath = EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
790 | + $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input('EVT_default_registration_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
|
791 | + $template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values); |
|
792 | + $templatepath = EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
793 | 793 | EEH_Template::display_template($templatepath, $template_args); |
794 | 794 | } |
795 | 795 | |
@@ -802,9 +802,9 @@ discard block |
||
802 | 802 | * @param array $box metabox args |
803 | 803 | * @return string metabox contents |
804 | 804 | */ |
805 | - public function event_type_meta_box( $post, $box ) { |
|
806 | - $template_args['radio_list'] = $this->wp_terms_radio($post->ID, array( 'taxonomy' => 'espresso_event_type' ) ); |
|
807 | - $template = EVENTS_CAF_TEMPLATE_PATH . 'event_type_metabox_contents.template.php'; |
|
805 | + public function event_type_meta_box($post, $box) { |
|
806 | + $template_args['radio_list'] = $this->wp_terms_radio($post->ID, array('taxonomy' => 'espresso_event_type')); |
|
807 | + $template = EVENTS_CAF_TEMPLATE_PATH.'event_type_metabox_contents.template.php'; |
|
808 | 808 | EEH_Template::display_template($template, $template_args); |
809 | 809 | } |
810 | 810 | |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | |
815 | 815 | |
816 | 816 | |
817 | - public function wp_terms_radio( $post_id = 0, $args = array() ) { |
|
817 | + public function wp_terms_radio($post_id = 0, $args = array()) { |
|
818 | 818 | $defaults = array( |
819 | 819 | 'descendants_and_self' => 0, |
820 | 820 | 'selected_cats' => false, |
@@ -823,11 +823,11 @@ discard block |
||
823 | 823 | 'taxonomy' => 'category', |
824 | 824 | 'checked_ontop' => true |
825 | 825 | ); |
826 | - $args = apply_filters( 'wp_terms_checklist_args', $args, $post_id ); |
|
826 | + $args = apply_filters('wp_terms_checklist_args', $args, $post_id); |
|
827 | 827 | |
828 | - extract( wp_parse_args($args, $defaults), EXTR_SKIP ); |
|
828 | + extract(wp_parse_args($args, $defaults), EXTR_SKIP); |
|
829 | 829 | |
830 | - if ( empty($walker) || !is_a($walker, 'Walker') ) |
|
830 | + if (empty($walker) || ! is_a($walker, 'Walker')) |
|
831 | 831 | $walker = new Walker_Radio_Checklist; |
832 | 832 | |
833 | 833 | $descendants_and_self = (int) $descendants_and_self; |
@@ -835,37 +835,37 @@ discard block |
||
835 | 835 | $args = array('taxonomy' => $taxonomy); |
836 | 836 | |
837 | 837 | $tax = get_taxonomy($taxonomy); |
838 | - $args['disabled'] = !current_user_can($tax->cap->assign_terms); |
|
838 | + $args['disabled'] = ! current_user_can($tax->cap->assign_terms); |
|
839 | 839 | |
840 | - if ( is_array( $selected_cats ) ) |
|
840 | + if (is_array($selected_cats)) |
|
841 | 841 | $args['selected_cats'] = $selected_cats; |
842 | - elseif ( $post_id ) |
|
842 | + elseif ($post_id) |
|
843 | 843 | $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); |
844 | 844 | else |
845 | 845 | $args['selected_cats'] = array(); |
846 | 846 | |
847 | - if ( is_array( $popular_cats ) ) |
|
847 | + if (is_array($popular_cats)) |
|
848 | 848 | $args['popular_cats'] = $popular_cats; |
849 | 849 | else |
850 | - $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
|
850 | + $args['popular_cats'] = get_terms($taxonomy, array('fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false)); |
|
851 | 851 | |
852 | - if ( $descendants_and_self ) { |
|
853 | - $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) ); |
|
854 | - $self = get_term( $descendants_and_self, $taxonomy ); |
|
855 | - array_unshift( $categories, $self ); |
|
852 | + if ($descendants_and_self) { |
|
853 | + $categories = (array) get_terms($taxonomy, array('child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0)); |
|
854 | + $self = get_term($descendants_and_self, $taxonomy); |
|
855 | + array_unshift($categories, $self); |
|
856 | 856 | } else { |
857 | 857 | $categories = (array) get_terms($taxonomy, array('get' => 'all')); |
858 | 858 | } |
859 | 859 | |
860 | - if ( $checked_ontop ) { |
|
860 | + if ($checked_ontop) { |
|
861 | 861 | // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) |
862 | 862 | $checked_categories = array(); |
863 | - $keys = array_keys( $categories ); |
|
863 | + $keys = array_keys($categories); |
|
864 | 864 | |
865 | - foreach( $keys as $k ) { |
|
866 | - if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) { |
|
865 | + foreach ($keys as $k) { |
|
866 | + if (in_array($categories[$k]->term_id, $args['selected_cats'])) { |
|
867 | 867 | $checked_categories[] = $categories[$k]; |
868 | - unset( $categories[$k] ); |
|
868 | + unset($categories[$k]); |
|
869 | 869 | } |
870 | 870 | } |
871 | 871 | |
@@ -890,18 +890,18 @@ discard block |
||
890 | 890 | * @param array $list_table_obj the list table object |
891 | 891 | * @return array new filters |
892 | 892 | */ |
893 | - public function list_table_filters( $oldfilters, $list_table_obj ) { |
|
893 | + public function list_table_filters($oldfilters, $list_table_obj) { |
|
894 | 894 | $filters = array(); |
895 | 895 | |
896 | 896 | //first month/year filters |
897 | 897 | $filters[] = $this->espresso_event_months_dropdown(); |
898 | 898 | |
899 | 899 | |
900 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
900 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
901 | 901 | |
902 | 902 | //active status dropdown |
903 | - if ( $status !== 'draft' ) |
|
904 | - $filter[] = $this->active_status_dropdown( isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : '' ); |
|
903 | + if ($status !== 'draft') |
|
904 | + $filter[] = $this->active_status_dropdown(isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''); |
|
905 | 905 | |
906 | 906 | //category filter |
907 | 907 | $filters[] = $this->category_dropdown(); |
@@ -923,17 +923,17 @@ discard block |
||
923 | 923 | */ |
924 | 924 | public function espresso_event_months_dropdown() { |
925 | 925 | //what we need to do is get all PRIMARY datetimes for all events to filter on. Note we need to include any other filters that are set! |
926 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
926 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
927 | 927 | |
928 | 928 | //categories? |
929 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
929 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
930 | 930 | |
931 | 931 | //active status? |
932 | - $active_status = isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : NULL; |
|
932 | + $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : NULL; |
|
933 | 933 | |
934 | 934 | $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
935 | 935 | |
936 | - return EEH_Form_Fields::generate_event_months_dropdown( $cur_date, $status, $category, $active_status ); |
|
936 | + return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | |
@@ -944,12 +944,12 @@ discard block |
||
944 | 944 | * @param string $current_value whatever the ucrrent active status is |
945 | 945 | * @return string html dropdown. |
946 | 946 | */ |
947 | - public function active_status_dropdown( $current_value = '' ) { |
|
947 | + public function active_status_dropdown($current_value = '') { |
|
948 | 948 | $select_name = 'active_status'; |
949 | - $values = array('none' => __('Show Active/Inactive', 'event_espresso'), 'active' => __('Active', 'event_espresso'), 'upcoming' => __('Upcoming', 'event_espresso'), 'expired' => __('Expired', 'event_espresso'), 'inactive' => __('Inactive', 'event_espresso') ); |
|
949 | + $values = array('none' => __('Show Active/Inactive', 'event_espresso'), 'active' => __('Active', 'event_espresso'), 'upcoming' => __('Upcoming', 'event_espresso'), 'expired' => __('Expired', 'event_espresso'), 'inactive' => __('Inactive', 'event_espresso')); |
|
950 | 950 | $id = 'id="espresso-active-status-dropdown-filter"'; |
951 | 951 | $class = 'wide'; |
952 | - echo EEH_Form_Fields::select_input( $select_name, $values, $current_value, $id, $class ); |
|
952 | + echo EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class); |
|
953 | 953 | } |
954 | 954 | |
955 | 955 | |
@@ -961,9 +961,9 @@ discard block |
||
961 | 961 | * @return string html |
962 | 962 | */ |
963 | 963 | public function category_dropdown() { |
964 | - $cur_cat = isset( $this->_req_data['EVT_CAT'] ) ? $this->_req_data['EVT_CAT'] : -1; |
|
964 | + $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
965 | 965 | |
966 | - return EEH_Form_Fields::generate_event_category_dropdown( $cur_cat ); |
|
966 | + return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | |
@@ -975,14 +975,14 @@ discard block |
||
975 | 975 | * @return int |
976 | 976 | */ |
977 | 977 | public function total_events_today() { |
978 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', date('Y-m-d' ) . ' 00:00:00', 'Y-m-d H:i:s', 'UTC' ); |
|
979 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', date('Y-m-d' ) . ' 23:59:59', 'Y-m-d H:i:s', 'UTC' ); |
|
978 | + $start = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', date('Y-m-d').' 00:00:00', 'Y-m-d H:i:s', 'UTC'); |
|
979 | + $end = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', date('Y-m-d').' 23:59:59', 'Y-m-d H:i:s', 'UTC'); |
|
980 | 980 | |
981 | 981 | $where = array( |
982 | - 'Datetime.DTT_EVT_start' => array( 'BETWEEN', array($start, $end ) ) |
|
982 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)) |
|
983 | 983 | ); |
984 | 984 | |
985 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
985 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
986 | 986 | return $count; |
987 | 987 | } |
988 | 988 | |
@@ -997,14 +997,14 @@ discard block |
||
997 | 997 | $this_year_r = date('Y'); |
998 | 998 | $this_month_r = date('m'); |
999 | 999 | $days_this_month = date('t'); |
1000 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', $this_year_r . '-' . $this_month_r . '-01 00:00:00', 'Y-m-d H:i:s', 'UTC' ); |
|
1001 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', 'Y-m-d H:i:s', 'UTC' ); |
|
1000 | + $start = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', $this_year_r.'-'.$this_month_r.'-01 00:00:00', 'Y-m-d H:i:s', 'UTC'); |
|
1001 | + $end = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59', 'Y-m-d H:i:s', 'UTC'); |
|
1002 | 1002 | |
1003 | 1003 | $where = array( |
1004 | - 'Datetime.DTT_EVT_start' => array( 'BETWEEN', array($start, $end ) ) |
|
1004 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)) |
|
1005 | 1005 | ); |
1006 | 1006 | |
1007 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
1007 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1008 | 1008 | return $count; |
1009 | 1009 | } |
1010 | 1010 | |
@@ -1021,53 +1021,53 @@ discard block |
||
1021 | 1021 | |
1022 | 1022 | |
1023 | 1023 | |
1024 | - public function get_default_tickets( $per_page = 10, $count = FALSE, $trashed = FALSE ) { |
|
1024 | + public function get_default_tickets($per_page = 10, $count = FALSE, $trashed = FALSE) { |
|
1025 | 1025 | |
1026 | - $orderby= empty( $this->_req_data['orderby'] ) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1027 | - $order = empty( $this->_req_data['order'] ) ? 'ASC' : $this->_req_data['order']; |
|
1026 | + $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1027 | + $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1028 | 1028 | |
1029 | - switch ( $orderby ) { |
|
1029 | + switch ($orderby) { |
|
1030 | 1030 | case 'TKT_name' : |
1031 | - $orderby = array( 'TKT_name' => $order ); |
|
1031 | + $orderby = array('TKT_name' => $order); |
|
1032 | 1032 | break; |
1033 | 1033 | |
1034 | 1034 | case 'TKT_price' : |
1035 | - $orderby = array( 'TKT_price' => $order ); |
|
1035 | + $orderby = array('TKT_price' => $order); |
|
1036 | 1036 | break; |
1037 | 1037 | |
1038 | 1038 | case 'TKT_uses' : |
1039 | - $orderby = array( 'TKT_uses' => $order ); |
|
1039 | + $orderby = array('TKT_uses' => $order); |
|
1040 | 1040 | break; |
1041 | 1041 | |
1042 | 1042 | case 'TKT_min' : |
1043 | - $orderby = array( 'TKT_min' => $order ); |
|
1043 | + $orderby = array('TKT_min' => $order); |
|
1044 | 1044 | break; |
1045 | 1045 | |
1046 | 1046 | case 'TKT_max' : |
1047 | - $orderby = array( 'TKT_max' => $order ); |
|
1047 | + $orderby = array('TKT_max' => $order); |
|
1048 | 1048 | break; |
1049 | 1049 | |
1050 | 1050 | case 'TKT_qty' : |
1051 | - $orderby = array( 'TKT_qty' => $order ); |
|
1051 | + $orderby = array('TKT_qty' => $order); |
|
1052 | 1052 | break; |
1053 | 1053 | } |
1054 | 1054 | |
1055 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
1056 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
1055 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
1056 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
1057 | 1057 | |
1058 | 1058 | $_where = array( |
1059 | 1059 | 'TKT_is_default' => 1, |
1060 | 1060 | 'TKT_deleted' => $trashed |
1061 | 1061 | ); |
1062 | 1062 | |
1063 | - $offset = ($current_page-1)*$per_page; |
|
1064 | - $limit = array( $offset, $per_page ); |
|
1063 | + $offset = ($current_page - 1) * $per_page; |
|
1064 | + $limit = array($offset, $per_page); |
|
1065 | 1065 | |
1066 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1067 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1066 | + if (isset($this->_req_data['s'])) { |
|
1067 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1068 | 1068 | $_where['OR'] = array( |
1069 | - 'TKT_name' => array('LIKE',$sstr ), |
|
1070 | - 'TKT_description' => array('LIKE',$sstr ) |
|
1069 | + 'TKT_name' => array('LIKE', $sstr), |
|
1070 | + 'TKT_description' => array('LIKE', $sstr) |
|
1071 | 1071 | ); |
1072 | 1072 | } |
1073 | 1073 | |
@@ -1078,9 +1078,9 @@ discard block |
||
1078 | 1078 | 'group_by'=>'TKT_ID' |
1079 | 1079 | ); |
1080 | 1080 | |
1081 | - if($count){ |
|
1081 | + if ($count) { |
|
1082 | 1082 | return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
1083 | - }else{ |
|
1083 | + } else { |
|
1084 | 1084 | return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
1085 | 1085 | } |
1086 | 1086 | |
@@ -1090,35 +1090,35 @@ discard block |
||
1090 | 1090 | |
1091 | 1091 | |
1092 | 1092 | |
1093 | - protected function _trash_or_restore_ticket( $trash = FALSE ) { |
|
1093 | + protected function _trash_or_restore_ticket($trash = FALSE) { |
|
1094 | 1094 | $success = 1; |
1095 | 1095 | |
1096 | 1096 | $TKT = EEM_Ticket::instance(); |
1097 | 1097 | |
1098 | 1098 | //checkboxes? |
1099 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) { |
|
1099 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1100 | 1100 | //if array has more than one element then success message should be plural |
1101 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
1101 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1102 | 1102 | |
1103 | 1103 | //cycle thru the boxes |
1104 | - while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
|
1105 | - if ( $trash ) { |
|
1106 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) |
|
1104 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1105 | + if ($trash) { |
|
1106 | + if ( ! $TKT->delete_by_ID($TKT_ID)) |
|
1107 | 1107 | $success = 0; |
1108 | 1108 | } else { |
1109 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) |
|
1109 | + if ( ! $TKT->restore_by_ID($TKT_ID)) |
|
1110 | 1110 | $success = 0; |
1111 | 1111 | } |
1112 | 1112 | } |
1113 | 1113 | } else { |
1114 | 1114 | //grab single id and trash |
1115 | - $TKT_ID = absint( $this->_req_data['TKT_ID'] ); |
|
1115 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1116 | 1116 | |
1117 | - if ( $trash ) { |
|
1118 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) |
|
1117 | + if ($trash) { |
|
1118 | + if ( ! $TKT->delete_by_ID($TKT_ID)) |
|
1119 | 1119 | $success = 0; |
1120 | 1120 | } else { |
1121 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) |
|
1121 | + if ( ! $TKT->restore_by_ID($TKT_ID)) |
|
1122 | 1122 | $success = 0; |
1123 | 1123 | } |
1124 | 1124 | } |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | 'action' => 'ticket_list_table', |
1129 | 1129 | 'status' => $trash ? '' : 'trashed' |
1130 | 1130 | ); |
1131 | - $this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args ); |
|
1131 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | |
@@ -1141,21 +1141,21 @@ discard block |
||
1141 | 1141 | $TKT = EEM_Ticket::instance(); |
1142 | 1142 | |
1143 | 1143 | //checkboxes? |
1144 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) { |
|
1144 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1145 | 1145 | //if array has more than one element then success message should be plural |
1146 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
1146 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1147 | 1147 | |
1148 | 1148 | //cycle thru the boxes |
1149 | - while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
|
1149 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1150 | 1150 | //delete |
1151 | - if ( ! $this->_delete_the_ticket( $TKT_ID ) ) { |
|
1151 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1152 | 1152 | $success = 0; |
1153 | 1153 | } |
1154 | 1154 | } |
1155 | 1155 | } else { |
1156 | 1156 | //grab single id and trash |
1157 | - $TKT_ID = absint( $this->_req_data['TKT_ID'] ); |
|
1158 | - if ( ! $this->_delete_the_ticket( $TKT_ID ) ) { |
|
1157 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1158 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1159 | 1159 | $success = 0; |
1160 | 1160 | } |
1161 | 1161 | } |
@@ -1167,16 +1167,16 @@ discard block |
||
1167 | 1167 | ); |
1168 | 1168 | |
1169 | 1169 | //failsafe. If the default ticket count === 1 then we need to redirect to event overview. |
1170 | - if ( EEM_Ticket::instance()->count_deleted_and_undeleted( array( array( 'TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ) ) |
|
1170 | + if (EEM_Ticket::instance()->count_deleted_and_undeleted(array(array('TKT_is_default' => 1)), 'TKT_ID', TRUE)) |
|
1171 | 1171 | $query_args = array(); |
1172 | - $this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args ); |
|
1172 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | |
1176 | 1176 | |
1177 | 1177 | |
1178 | - protected function _delete_the_ticket( $TKT_ID ) { |
|
1179 | - $tkt = EEM_Ticket::instance()->get_one_by_ID( $TKT_ID ); |
|
1178 | + protected function _delete_the_ticket($TKT_ID) { |
|
1179 | + $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1180 | 1180 | $tkt->_remove_relations('Datetime'); |
1181 | 1181 | //delete all related prices first |
1182 | 1182 | $tkt->delete_related_permanently('Price'); |
@@ -1,6 +1,7 @@ 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 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -453,8 +454,9 @@ discard block |
||
453 | 454 | //k we've got EVT_ID so let's use that to get the event we'll duplicate |
454 | 455 | $orig_event = EEM_Event::instance()->get_one_by_ID( $this->_req_data['EVT_ID'] ); |
455 | 456 | |
456 | - if ( ! $orig_event instanceof EE_Event ) |
|
457 | - throw new EE_Error( sprintf( __('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), $this->_req_data['EVT_ID'] ) ); |
|
457 | + if ( ! $orig_event instanceof EE_Event ) { |
|
458 | + throw new EE_Error( sprintf( __('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), $this->_req_data['EVT_ID'] ) ); |
|
459 | + } |
|
458 | 460 | |
459 | 461 | //k now let's clone the $orig_event before getting relations |
460 | 462 | $new_event = clone $orig_event; |
@@ -528,8 +530,9 @@ discard block |
||
528 | 530 | //now let's get the ticket relations setup. |
529 | 531 | foreach ( (array) $orig_tkts as $orig_tkt ) { |
530 | 532 | //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
531 | - if ( ! $orig_tkt instanceof EE_Ticket ) |
|
532 | - continue; |
|
533 | + if ( ! $orig_tkt instanceof EE_Ticket ) { |
|
534 | + continue; |
|
535 | + } |
|
533 | 536 | |
534 | 537 | //is this ticket archived? If it is then let's skip |
535 | 538 | if ( $orig_tkt->get( 'TKT_deleted' ) ) { |
@@ -638,9 +641,9 @@ discard block |
||
638 | 641 | protected function _events_export() { |
639 | 642 | if(isset($this->_req_data['EVT_ID'])){ |
640 | 643 | $event_ids = $this->_req_data['EVT_ID']; |
641 | - }elseif(isset($this->_req_data['EVT_IDs'])){ |
|
644 | + } elseif(isset($this->_req_data['EVT_IDs'])){ |
|
642 | 645 | $event_ids = $this->_req_data['EVT_IDs']; |
643 | - }else{ |
|
646 | + } else{ |
|
644 | 647 | $event_ids = NULL; |
645 | 648 | } |
646 | 649 | //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
@@ -827,8 +830,9 @@ discard block |
||
827 | 830 | |
828 | 831 | extract( wp_parse_args($args, $defaults), EXTR_SKIP ); |
829 | 832 | |
830 | - if ( empty($walker) || !is_a($walker, 'Walker') ) |
|
831 | - $walker = new Walker_Radio_Checklist; |
|
833 | + if ( empty($walker) || !is_a($walker, 'Walker') ) { |
|
834 | + $walker = new Walker_Radio_Checklist; |
|
835 | + } |
|
832 | 836 | |
833 | 837 | $descendants_and_self = (int) $descendants_and_self; |
834 | 838 | |
@@ -837,17 +841,19 @@ discard block |
||
837 | 841 | $tax = get_taxonomy($taxonomy); |
838 | 842 | $args['disabled'] = !current_user_can($tax->cap->assign_terms); |
839 | 843 | |
840 | - if ( is_array( $selected_cats ) ) |
|
841 | - $args['selected_cats'] = $selected_cats; |
|
842 | - elseif ( $post_id ) |
|
843 | - $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); |
|
844 | - else |
|
845 | - $args['selected_cats'] = array(); |
|
844 | + if ( is_array( $selected_cats ) ) { |
|
845 | + $args['selected_cats'] = $selected_cats; |
|
846 | + } elseif ( $post_id ) { |
|
847 | + $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); |
|
848 | + } else { |
|
849 | + $args['selected_cats'] = array(); |
|
850 | + } |
|
846 | 851 | |
847 | - if ( is_array( $popular_cats ) ) |
|
848 | - $args['popular_cats'] = $popular_cats; |
|
849 | - else |
|
850 | - $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
|
852 | + if ( is_array( $popular_cats ) ) { |
|
853 | + $args['popular_cats'] = $popular_cats; |
|
854 | + } else { |
|
855 | + $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
|
856 | + } |
|
851 | 857 | |
852 | 858 | if ( $descendants_and_self ) { |
853 | 859 | $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) ); |
@@ -900,8 +906,9 @@ discard block |
||
900 | 906 | $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
901 | 907 | |
902 | 908 | //active status dropdown |
903 | - if ( $status !== 'draft' ) |
|
904 | - $filter[] = $this->active_status_dropdown( isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : '' ); |
|
909 | + if ( $status !== 'draft' ) { |
|
910 | + $filter[] = $this->active_status_dropdown( isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : '' ); |
|
911 | + } |
|
905 | 912 | |
906 | 913 | //category filter |
907 | 914 | $filters[] = $this->category_dropdown(); |
@@ -1080,7 +1087,7 @@ discard block |
||
1080 | 1087 | |
1081 | 1088 | if($count){ |
1082 | 1089 | return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
1083 | - }else{ |
|
1090 | + } else{ |
|
1084 | 1091 | return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
1085 | 1092 | } |
1086 | 1093 | |
@@ -1103,11 +1110,13 @@ discard block |
||
1103 | 1110 | //cycle thru the boxes |
1104 | 1111 | while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
1105 | 1112 | if ( $trash ) { |
1106 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) |
|
1107 | - $success = 0; |
|
1113 | + if ( ! $TKT->delete_by_ID( $TKT_ID ) ) { |
|
1114 | + $success = 0; |
|
1115 | + } |
|
1108 | 1116 | } else { |
1109 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) |
|
1110 | - $success = 0; |
|
1117 | + if ( ! $TKT->restore_by_ID( $TKT_ID ) ) { |
|
1118 | + $success = 0; |
|
1119 | + } |
|
1111 | 1120 | } |
1112 | 1121 | } |
1113 | 1122 | } else { |
@@ -1115,11 +1124,13 @@ discard block |
||
1115 | 1124 | $TKT_ID = absint( $this->_req_data['TKT_ID'] ); |
1116 | 1125 | |
1117 | 1126 | if ( $trash ) { |
1118 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) |
|
1119 | - $success = 0; |
|
1127 | + if ( ! $TKT->delete_by_ID( $TKT_ID ) ) { |
|
1128 | + $success = 0; |
|
1129 | + } |
|
1120 | 1130 | } else { |
1121 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) |
|
1122 | - $success = 0; |
|
1131 | + if ( ! $TKT->restore_by_ID( $TKT_ID ) ) { |
|
1132 | + $success = 0; |
|
1133 | + } |
|
1123 | 1134 | } |
1124 | 1135 | } |
1125 | 1136 | |
@@ -1167,8 +1178,9 @@ discard block |
||
1167 | 1178 | ); |
1168 | 1179 | |
1169 | 1180 | //failsafe. If the default ticket count === 1 then we need to redirect to event overview. |
1170 | - if ( EEM_Ticket::instance()->count_deleted_and_undeleted( array( array( 'TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ) ) |
|
1171 | - $query_args = array(); |
|
1181 | + if ( EEM_Ticket::instance()->count_deleted_and_undeleted( array( array( 'TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ) ) { |
|
1182 | + $query_args = array(); |
|
1183 | + } |
|
1172 | 1184 | $this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args ); |
1173 | 1185 | } |
1174 | 1186 |
@@ -1,69 +1,69 @@ |
||
1 | 1 | <?php |
2 | 2 | //echo '<br/><h6 style="color:#2EA2CC;">'. __FILE__ . ' <span style="font-weight:normal;color:#E76700"> Line #: ' . __LINE__ . '</span></h6>'; |
3 | 3 | if ( |
4 | - ( is_single() && espresso_display_venue_in_event_details() ) |
|
5 | - || ( is_archive() && espresso_display_venue_in_event_list() ) |
|
4 | + (is_single() && espresso_display_venue_in_event_details()) |
|
5 | + || (is_archive() && espresso_display_venue_in_event_list()) |
|
6 | 6 | ) : |
7 | 7 | global $post; |
8 | - do_action( 'AHEE_event_details_before_venue_details', $post ); |
|
9 | - $venue_name = espresso_venue_name( 0, 'details', FALSE ); |
|
10 | - if ( empty( $venue_name ) && espresso_is_venue_private() ) { |
|
11 | - do_action( 'AHEE_event_details_after_venue_details', $post ); |
|
8 | + do_action('AHEE_event_details_before_venue_details', $post); |
|
9 | + $venue_name = espresso_venue_name(0, 'details', FALSE); |
|
10 | + if (empty($venue_name) && espresso_is_venue_private()) { |
|
11 | + do_action('AHEE_event_details_after_venue_details', $post); |
|
12 | 12 | return ''; |
13 | 13 | } |
14 | 14 | ?> |
15 | 15 | |
16 | 16 | <div class="espresso-venue-dv<?php echo espresso_is_venue_private() ? ' espresso-private-venue-dv' : ''; ?>"> |
17 | 17 | <h3 class="event-venues-h3 ee-event-h3"> |
18 | - <?php _e( 'Location', 'event_espresso' ); ?> |
|
18 | + <?php _e('Location', 'event_espresso'); ?> |
|
19 | 19 | </h3> |
20 | - <h4><strong><?php _e( 'Venue:', 'event_espresso' ); ?></strong> <strong> <?php echo $venue_name; ?></strong></h4> |
|
20 | + <h4><strong><?php _e('Venue:', 'event_espresso'); ?></strong> <strong> <?php echo $venue_name; ?></strong></h4> |
|
21 | 21 | <p><span class="smaller-text tags-links"><?php echo espresso_venue_categories(); ?></span></p> |
22 | -<?php if ( $venue_phone = espresso_venue_phone( $post->ID, FALSE )) : ?> |
|
22 | +<?php if ($venue_phone = espresso_venue_phone($post->ID, FALSE)) : ?> |
|
23 | 23 | <p> |
24 | - <span class="small-text"><strong><?php _e( 'Venue Phone:', 'event_espresso' ); ?></strong></span> <?php echo $venue_phone; ?> |
|
24 | + <span class="small-text"><strong><?php _e('Venue Phone:', 'event_espresso'); ?></strong></span> <?php echo $venue_phone; ?> |
|
25 | 25 | </p> |
26 | -<?php endif; ?> |
|
27 | -<?php if ( $venue_website = espresso_venue_website( $post->ID, FALSE )) : ?> |
|
26 | +<?php endif; ?> |
|
27 | +<?php if ($venue_website = espresso_venue_website($post->ID, FALSE)) : ?> |
|
28 | 28 | <p> |
29 | - <span class="small-text"><strong><?php _e( 'Venue Website:', 'event_espresso' ); ?></strong></span> <?php echo $venue_website; ?> |
|
29 | + <span class="small-text"><strong><?php _e('Venue Website:', 'event_espresso'); ?></strong></span> <?php echo $venue_website; ?> |
|
30 | 30 | </p> |
31 | 31 | <?php endif; ?> |
32 | -<?php if ( espresso_venue_has_address( $post->ID )) : ?> |
|
33 | - <strong><span class="dashicons dashicons-location-alt"></span><?php _e( 'Address:', 'event_espresso' ); ?></strong> |
|
34 | - <?php espresso_venue_address( 'inline' ); ?> |
|
35 | - <?php espresso_venue_gmap( $post->ID ); ?> |
|
32 | +<?php if (espresso_venue_has_address($post->ID)) : ?> |
|
33 | + <strong><span class="dashicons dashicons-location-alt"></span><?php _e('Address:', 'event_espresso'); ?></strong> |
|
34 | + <?php espresso_venue_address('inline'); ?> |
|
35 | + <?php espresso_venue_gmap($post->ID); ?> |
|
36 | 36 | <div class="clear"><br/></div> |
37 | -<?php endif; ?> |
|
37 | +<?php endif; ?> |
|
38 | 38 | |
39 | - <?php $VNU_ID = espresso_venue_id( $post->ID ); ?> |
|
40 | - <?php if ( is_single() ) : ?> |
|
41 | - <?php $venue_description = espresso_venue_description( $VNU_ID, FALSE ); ?> |
|
42 | - <?php if ( $venue_description ) : ?> |
|
39 | + <?php $VNU_ID = espresso_venue_id($post->ID); ?> |
|
40 | + <?php if (is_single()) : ?> |
|
41 | + <?php $venue_description = espresso_venue_description($VNU_ID, FALSE); ?> |
|
42 | + <?php if ($venue_description) : ?> |
|
43 | 43 | <p> |
44 | - <strong><?php _e( 'Description:', 'event_espresso' ); ?></strong><br/> |
|
45 | - <?php echo do_shortcode( $venue_description ); ?> |
|
44 | + <strong><?php _e('Description:', 'event_espresso'); ?></strong><br/> |
|
45 | + <?php echo do_shortcode($venue_description); ?> |
|
46 | 46 | </p> |
47 | - <?php endif; ?> |
|
47 | + <?php endif; ?> |
|
48 | 48 | <?php else : ?> |
49 | - <?php $venue_excerpt = espresso_venue_excerpt( $VNU_ID, FALSE ); ?> |
|
50 | - <?php if ( $venue_excerpt ) : ?> |
|
49 | + <?php $venue_excerpt = espresso_venue_excerpt($VNU_ID, FALSE); ?> |
|
50 | + <?php if ($venue_excerpt) : ?> |
|
51 | 51 | <p> |
52 | - <strong><?php _e( 'Description:', 'event_espresso' ); ?></strong><br/> |
|
52 | + <strong><?php _e('Description:', 'event_espresso'); ?></strong><br/> |
|
53 | 53 | <?php echo $venue_excerpt; ?> |
54 | 54 | </p> |
55 | - <?php endif; ?> |
|
56 | - <?php endif; ?> |
|
55 | + <?php endif; ?> |
|
56 | + <?php endif; ?> |
|
57 | 57 | </div> |
58 | 58 | <!-- .espresso-venue-dv --> |
59 | 59 | <?php |
60 | -do_action( 'AHEE_event_details_after_venue_details', $post ); |
|
60 | +do_action('AHEE_event_details_after_venue_details', $post); |
|
61 | 61 | else : |
62 | - if ( espresso_venue_is_password_protected() ) : |
|
62 | + if (espresso_venue_is_password_protected()) : |
|
63 | 63 | ?> |
64 | 64 | <div class="espresso-venue-dv espresso-password-protected-venue-dv" > |
65 | 65 | <h3 class="event-venues-h3 ee-event-h3"> |
66 | - <?php _e( 'Location', 'event_espresso' );?> |
|
66 | + <?php _e('Location', 'event_espresso'); ?> |
|
67 | 67 | </h3> |
68 | 68 | <?php echo espresso_password_protected_venue_form(); ?> |
69 | 69 | </div> |
@@ -2,7 +2,7 @@ |
||
2 | 2 | $closing_tag = '</a>'; |
3 | 3 | //if this is decaf, which is put on WordPress.org, we need to inform users that |
4 | 4 | //we just put an affiliate link there. See https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/ section 12 |
5 | -if( apply_filters( 'FHEE__ee_show_affiliate_links', true ) ) { |
|
6 | - $closing_tag .= esc_html__( ' (affiliate link)', 'event_espresso' ); |
|
5 | +if (apply_filters('FHEE__ee_show_affiliate_links', true)) { |
|
6 | + $closing_tag .= esc_html__(' (affiliate link)', 'event_espresso'); |
|
7 | 7 | } |
8 | -printf( esc_html__('PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">', $closing_tag ); |
|
9 | 8 | \ No newline at end of file |
9 | +printf(esc_html__('PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">', $closing_tag); |
|
10 | 10 | \ No newline at end of file |
@@ -14,7 +14,7 @@ |
||
14 | 14 | * @param string $email_address |
15 | 15 | * @return string |
16 | 16 | */ |
17 | - function prepare_for_set($email_address ) { |
|
17 | + function prepare_for_set($email_address) { |
|
18 | 18 | $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
19 | 19 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
20 | 20 | : 'wp_default'; |
@@ -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 | |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | * ------------------------------------------------------------------------ |
32 | 32 | */ |
33 | 33 | |
34 | -if ( ! class_exists( 'WP_List_Table' )) { |
|
35 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
34 | +if ( ! class_exists('WP_List_Table')) { |
|
35 | + require_once(ABSPATH.'wp-admin/includes/class-wp-list-table.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | abstract class EE_Admin_List_Table extends WP_List_Table { |
@@ -244,16 +244,16 @@ discard block |
||
244 | 244 | * constructor |
245 | 245 | * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table. |
246 | 246 | */ |
247 | - public function __construct( EE_Admin_Page $admin_page ) { |
|
247 | + public function __construct(EE_Admin_Page $admin_page) { |
|
248 | 248 | $this->_admin_page = $admin_page; |
249 | 249 | $this->_req_data = $this->_admin_page->get_request_data(); |
250 | 250 | $this->_view = $this->_admin_page->get_view(); |
251 | - $this->_views = empty( $this->_views ) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
251 | + $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
252 | 252 | $this->_current_page = $this->get_pagenum(); |
253 | - $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view(); |
|
254 | - $this->_yes_no = array( __('No', 'event_espresso'), __('Yes', 'event_espresso')); |
|
253 | + $this->_screen = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view(); |
|
254 | + $this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso')); |
|
255 | 255 | |
256 | - $this->_per_page = $this->get_items_per_page( $this->_screen . '_per_page', 10 ); |
|
256 | + $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page', 10); |
|
257 | 257 | |
258 | 258 | $this->_setup_data(); |
259 | 259 | $this->_add_view_counts(); |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | $this->_set_properties(); |
264 | 264 | |
265 | 265 | //set primary column |
266 | - add_filter( 'list_table_primary_column', array( $this, 'set_primary_column' ) ); |
|
266 | + add_filter('list_table_primary_column', array($this, 'set_primary_column')); |
|
267 | 267 | |
268 | 268 | //set parent defaults |
269 | 269 | parent::__construct($this->_wp_list_args); |
@@ -339,17 +339,17 @@ discard block |
||
339 | 339 | * @return string |
340 | 340 | */ |
341 | 341 | protected function _get_hidden_fields() { |
342 | - $action = isset( $this->_req_data['route'] ) ? $this->_req_data['route'] : ''; |
|
343 | - $action = empty( $action ) && isset( $this->_req_data['action'] ) ? $this->_req_data['action'] : $action; |
|
342 | + $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : ''; |
|
343 | + $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action; |
|
344 | 344 | //if action is STILL empty, then we set it to default |
345 | - $action = empty( $action ) ? 'default' : $action; |
|
346 | - $field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n"; |
|
347 | - $field .= '<input type="hidden" name="route" value="'. $action .'" />' . "\n";/**/ |
|
348 | - $field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n"; |
|
345 | + $action = empty($action) ? 'default' : $action; |
|
346 | + $field = '<input type="hidden" name="page" value="'.$this->_req_data['page'].'" />'."\n"; |
|
347 | + $field .= '<input type="hidden" name="route" value="'.$action.'" />'."\n"; /**/ |
|
348 | + $field .= '<input type="hidden" name="perpage" value="'.$this->_per_page.'" />'."\n"; |
|
349 | 349 | |
350 | 350 | $bulk_actions = $this->_get_bulk_actions(); |
351 | - foreach ( $bulk_actions as $bulk_action => $label ) { |
|
352 | - $field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce ( $bulk_action . '_nonce' ) . '" />' . "\n"; |
|
351 | + foreach ($bulk_actions as $bulk_action => $label) { |
|
352 | + $field .= '<input type="hidden" name="'.$bulk_action.'_nonce" value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n"; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | return $field; |
@@ -379,15 +379,15 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @var array |
381 | 381 | */ |
382 | - $_sortable = apply_filters( "FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen ); |
|
382 | + $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen); |
|
383 | 383 | |
384 | 384 | $sortable = array(); |
385 | - foreach ( $_sortable as $id => $data ) { |
|
386 | - if ( empty( $data ) ) |
|
385 | + foreach ($_sortable as $id => $data) { |
|
386 | + if (empty($data)) |
|
387 | 387 | continue; |
388 | 388 | |
389 | 389 | //fix for offset errors with WP_List_Table default get_columninfo() |
390 | - if ( is_array($data) ) { |
|
390 | + if (is_array($data)) { |
|
391 | 391 | $_data[0] = key($data); |
392 | 392 | $_data[1] = isset($data[1]) ? $data[1] : false; |
393 | 393 | } else { |
@@ -396,14 +396,14 @@ discard block |
||
396 | 396 | |
397 | 397 | $data = (array) $data; |
398 | 398 | |
399 | - if ( !isset( $data[1] ) ) |
|
399 | + if ( ! isset($data[1])) |
|
400 | 400 | $_data[1] = false; |
401 | 401 | |
402 | 402 | |
403 | 403 | $sortable[$id] = $_data; |
404 | 404 | } |
405 | 405 | $primary = $this->get_primary_column_name(); |
406 | - $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); |
|
406 | + $this->_column_headers = array($columns, $hidden, $sortable, $primary); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -412,8 +412,8 @@ discard block |
||
412 | 412 | * @return string |
413 | 413 | */ |
414 | 414 | protected function get_primary_column_name() { |
415 | - foreach( class_parents( $this ) as $parent ) { |
|
416 | - if ( method_exists( $parent, 'get_primary_column_name' ) && $parent == 'WP_List_Table' ) { |
|
415 | + foreach (class_parents($this) as $parent) { |
|
416 | + if (method_exists($parent, 'get_primary_column_name') && $parent == 'WP_List_Table') { |
|
417 | 417 | return parent::get_primary_column_name(); |
418 | 418 | } |
419 | 419 | } |
@@ -430,10 +430,10 @@ discard block |
||
430 | 430 | * @param string $primary |
431 | 431 | * @return string |
432 | 432 | */ |
433 | - protected function handle_row_actions( $item, $column_name, $primary ) { |
|
434 | - foreach( class_parents( $this ) as $parent ) { |
|
435 | - if ( method_exists( $parent, 'handle_row_actions' ) && $parent == 'WP_List_Table' ) { |
|
436 | - return parent::handle_row_actions( $item, $column_name, $primary ); |
|
433 | + protected function handle_row_actions($item, $column_name, $primary) { |
|
434 | + foreach (class_parents($this) as $parent) { |
|
435 | + if (method_exists($parent, 'handle_row_actions') && $parent == 'WP_List_Table') { |
|
436 | + return parent::handle_row_actions($item, $column_name, $primary); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | return ''; |
@@ -451,11 +451,11 @@ discard block |
||
451 | 451 | protected function _get_bulk_actions() { |
452 | 452 | $actions = array(); |
453 | 453 | //the _views property should have the bulk_actions, so let's go through and extract them into a properly formatted array for the wp_list_table(); |
454 | - foreach ( $this->_views as $view => $args) { |
|
455 | - if ( isset( $args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view ) |
|
454 | + foreach ($this->_views as $view => $args) { |
|
455 | + if (isset($args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view) |
|
456 | 456 | //each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user. |
457 | - foreach ( $args['bulk_action'] as $route =>$label ) { |
|
458 | - if ( $this->_admin_page->check_user_access( $route, true ) ) { |
|
457 | + foreach ($args['bulk_action'] as $route =>$label) { |
|
458 | + if ($this->_admin_page->check_user_access($route, true)) { |
|
459 | 459 | $actions[$route] = $label; |
460 | 460 | } |
461 | 461 | } |
@@ -473,18 +473,18 @@ discard block |
||
473 | 473 | */ |
474 | 474 | private function _filters() { |
475 | 475 | $classname = get_class($this); |
476 | - $filters = apply_filters( "FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen ); |
|
476 | + $filters = apply_filters("FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen); |
|
477 | 477 | |
478 | - if ( empty( $filters )) { |
|
478 | + if (empty($filters)) { |
|
479 | 479 | return; |
480 | 480 | } |
481 | - foreach ( $filters as $filter ) { |
|
481 | + foreach ($filters as $filter) { |
|
482 | 482 | echo $filter; |
483 | 483 | } |
484 | 484 | //add filter button at end |
485 | - echo '<input type="submit" class="button-secondary" value="' . __('Filter', 'event_espresso') . '" id="post-query-submit" />'; |
|
485 | + echo '<input type="submit" class="button-secondary" value="'.__('Filter', 'event_espresso').'" id="post-query-submit" />'; |
|
486 | 486 | //add reset filters button at end |
487 | - echo '<a class="button button-secondary" href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters', 'event_espresso') . '</a>'; |
|
487 | + echo '<a class="button button-secondary" href="'.$this->_admin_page->get_current_page_view_url().'" style="display:inline-block">'.__('Reset Filters', 'event_espresso').'</a>'; |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | |
@@ -498,8 +498,8 @@ discard block |
||
498 | 498 | * @param string $column_name |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - public function set_primary_column( $column_name ) { |
|
502 | - return ! empty( $this->_primary_column ) ? $this->_primary_column : $column_name; |
|
501 | + public function set_primary_column($column_name) { |
|
502 | + return ! empty($this->_primary_column) ? $this->_primary_column : $column_name; |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | array( |
519 | 519 | 'total_items' => $total_items, |
520 | 520 | 'per_page' => $this->_per_page, |
521 | - 'total_pages' => ceil($total_items / $this->_per_page ) |
|
521 | + 'total_pages' => ceil($total_items / $this->_per_page) |
|
522 | 522 | ) |
523 | 523 | ); |
524 | 524 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * |
535 | 535 | * @return string html content for the column |
536 | 536 | */ |
537 | - public function column_default( $item, $column_name ) { |
|
537 | + public function column_default($item, $column_name) { |
|
538 | 538 | /** |
539 | 539 | * Dynamic hook allowing for adding additional column content in this list table. |
540 | 540 | * Note that $this->screen->id is in the format |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | * hook prefix ("event-espresso") will be different. |
545 | 545 | * |
546 | 546 | */ |
547 | - do_action( 'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item, $this->_screen ); |
|
547 | + do_action('AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id, $item, $this->_screen); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * |
561 | 561 | * @var array |
562 | 562 | */ |
563 | - $columns = apply_filters( 'FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen ); |
|
563 | + $columns = apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen); |
|
564 | 564 | return $columns; |
565 | 565 | } |
566 | 566 | |
@@ -572,18 +572,18 @@ discard block |
||
572 | 572 | $views = $this->get_views(); |
573 | 573 | $assembled_views = ''; |
574 | 574 | |
575 | - if ( empty( $views )) { |
|
575 | + if (empty($views)) { |
|
576 | 576 | return; |
577 | 577 | } |
578 | 578 | echo "<ul class='subsubsub'>\n"; |
579 | - foreach ( $views as $view ) { |
|
580 | - $count = isset($view['count'] ) && !empty($view['count']) ? absint( $view['count'] ) : 0; |
|
581 | - if ( isset( $view['slug'] ) && isset( $view['class'] ) && isset( $view['url'] ) && isset( $view['label']) ) { |
|
582 | - $assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>'; |
|
579 | + foreach ($views as $view) { |
|
580 | + $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0; |
|
581 | + if (isset($view['slug']) && isset($view['class']) && isset($view['url']) && isset($view['label'])) { |
|
582 | + $assembled_views[$view['slug']] = "\t<li class='".$view['class']."'>".'<a href="'.$view['url'].'">'.$view['label'].'</a> <span class="count">('.$count.')</span>'; |
|
583 | 583 | } |
584 | 584 | } |
585 | 585 | |
586 | - echo is_array( $assembled_views) && ! empty( $assembled_views ) ? implode( " |</li>\n", $assembled_views ) . "</li>\n" : ''; |
|
586 | + echo is_array($assembled_views) && ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views)."</li>\n" : ''; |
|
587 | 587 | echo "</ul>"; |
588 | 588 | } |
589 | 589 | |
@@ -596,10 +596,10 @@ discard block |
||
596 | 596 | * |
597 | 597 | * @param object $item The current item |
598 | 598 | */ |
599 | - public function single_row( $item ) { |
|
600 | - $row_class = $this->_get_row_class( $item ); |
|
601 | - echo '<tr class="' . esc_attr( $row_class ) . '">'; |
|
602 | - $this->single_row_columns( $item ); |
|
599 | + public function single_row($item) { |
|
600 | + $row_class = $this->_get_row_class($item); |
|
601 | + echo '<tr class="'.esc_attr($row_class).'">'; |
|
602 | + $this->single_row_columns($item); |
|
603 | 603 | echo '</tr>'; |
604 | 604 | } |
605 | 605 | |
@@ -610,13 +610,13 @@ discard block |
||
610 | 610 | * @param object $item the current item |
611 | 611 | * @return string |
612 | 612 | */ |
613 | - protected function _get_row_class( $item ) { |
|
613 | + protected function _get_row_class($item) { |
|
614 | 614 | static $row_class = ''; |
615 | - $row_class = ( $row_class == '' ? 'alternate' : '' ); |
|
615 | + $row_class = ($row_class == '' ? 'alternate' : ''); |
|
616 | 616 | |
617 | 617 | $new_row_class = $row_class; |
618 | 618 | |
619 | - if ( !empty($this->_ajax_sorting_callback) ) { |
|
619 | + if ( ! empty($this->_ajax_sorting_callback)) { |
|
620 | 620 | $new_row_class .= ' rowsortable'; |
621 | 621 | } |
622 | 622 | |
@@ -635,13 +635,13 @@ discard block |
||
635 | 635 | |
636 | 636 | public function get_hidden_columns() { |
637 | 637 | $user_id = get_current_user_id(); |
638 | - $has_default = get_user_option('default'. $this->screen->id . 'columnshidden', $user_id); |
|
639 | - if ( empty( $has_default ) && !empty($this->_hidden_columns ) ) { |
|
640 | - update_user_option($user_id, 'default'.$this->screen->id . 'columnshidden', TRUE); |
|
641 | - update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, TRUE ); |
|
638 | + $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id); |
|
639 | + if (empty($has_default) && ! empty($this->_hidden_columns)) { |
|
640 | + update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', TRUE); |
|
641 | + update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, TRUE); |
|
642 | 642 | } |
643 | - $ref = 'manage' . $this->screen->id . 'columnshidden'; |
|
644 | - $saved_columns = (array) get_user_option( $ref, $user_id ); |
|
643 | + $ref = 'manage'.$this->screen->id.'columnshidden'; |
|
644 | + $saved_columns = (array) get_user_option($ref, $user_id); |
|
645 | 645 | return $saved_columns; |
646 | 646 | } |
647 | 647 | |
@@ -656,47 +656,47 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @param object $item The current item |
658 | 658 | */ |
659 | - public function single_row_columns( $item ) { |
|
660 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
659 | + public function single_row_columns($item) { |
|
660 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
661 | 661 | |
662 | 662 | global $wp_version; |
663 | - $use_hidden_class = version_compare( $wp_version, '4.3-RC', '>=' ); |
|
663 | + $use_hidden_class = version_compare($wp_version, '4.3-RC', '>='); |
|
664 | 664 | |
665 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
665 | + foreach ($columns as $column_name => $column_display_name) { |
|
666 | 666 | |
667 | 667 | /** |
668 | 668 | * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns are |
669 | 669 | * hidden or not instead of using "display:none;". This bit of code provides backward compat. |
670 | 670 | */ |
671 | - $hidden_class = $use_hidden_class && in_array( $column_name, $hidden ) ? ' hidden' : ''; |
|
672 | - $style = ! $use_hidden_class && in_array( $column_name, $hidden ) ? ' style="display:none;"' : ''; |
|
671 | + $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : ''; |
|
672 | + $style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : ''; |
|
673 | 673 | |
674 | - $classes = $column_name . ' column-' . $column_name.$hidden_class; |
|
675 | - if ( $primary == $column_name ) { |
|
674 | + $classes = $column_name.' column-'.$column_name.$hidden_class; |
|
675 | + if ($primary == $column_name) { |
|
676 | 676 | $classes .= ' has-row-actions column-primary'; |
677 | 677 | } |
678 | 678 | |
679 | - $data = ' data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; |
|
679 | + $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"'; |
|
680 | 680 | |
681 | 681 | $class = "class='$classes'"; |
682 | 682 | |
683 | 683 | $attributes = "$class$style$data"; |
684 | 684 | |
685 | - if ( 'cb' === $column_name ) { |
|
685 | + if ('cb' === $column_name) { |
|
686 | 686 | echo '<th scope="row" class="check-column">'; |
687 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb( $item ), $item, $this ); |
|
687 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb($item), $item, $this); |
|
688 | 688 | echo '</th>'; |
689 | 689 | } |
690 | - elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
690 | + elseif (method_exists($this, 'column_'.$column_name)) { |
|
691 | 691 | echo "<td $attributes>"; |
692 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', call_user_func( array( $this, 'column_' . $column_name ), $item ), $item, $this ); |
|
693 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
692 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content', call_user_func(array($this, 'column_'.$column_name), $item), $item, $this); |
|
693 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
694 | 694 | echo "</td>"; |
695 | 695 | } |
696 | 696 | else { |
697 | 697 | echo "<td $attributes>"; |
698 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default( $item, $column_name ), $item, $column_name, $this ); |
|
699 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
698 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default($item, $column_name), $item, $column_name, $this); |
|
699 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
700 | 700 | echo "</td>"; |
701 | 701 | } |
702 | 702 | } |
@@ -704,19 +704,19 @@ discard block |
||
704 | 704 | |
705 | 705 | |
706 | 706 | |
707 | - public function extra_tablenav( $which ) { |
|
708 | - if ( $which == 'top' ) { |
|
707 | + public function extra_tablenav($which) { |
|
708 | + if ($which == 'top') { |
|
709 | 709 | $this->_filters(); |
710 | 710 | echo $this->_get_hidden_fields(); |
711 | 711 | echo '<br class="clear">'; |
712 | - }else{ |
|
712 | + } else { |
|
713 | 713 | echo '<div class="list-table-bottom-buttons alignleft actions">'; |
714 | - foreach($this->_bottom_buttons as $type => $action){ |
|
715 | - $route = isset( $action['route'] ) ? $action['route'] : ''; |
|
716 | - $extra_request = isset( $action['extra_request'] ) ? $action['extra_request'] : ''; |
|
714 | + foreach ($this->_bottom_buttons as $type => $action) { |
|
715 | + $route = isset($action['route']) ? $action['route'] : ''; |
|
716 | + $extra_request = isset($action['extra_request']) ? $action['extra_request'] : ''; |
|
717 | 717 | echo $this->_admin_page->get_action_link_or_button($route, $type, $extra_request); |
718 | 718 | } |
719 | - do_action( 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen ); |
|
719 | + do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen); |
|
720 | 720 | echo '</div>'; |
721 | 721 | } |
722 | 722 | //echo $this->_entries_per_page_dropdown; |
@@ -766,13 +766,13 @@ discard block |
||
766 | 766 | * |
767 | 767 | * @return string The assembled action elements container. |
768 | 768 | */ |
769 | - protected function _action_string( $action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '' ) { |
|
769 | + protected function _action_string($action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '') { |
|
770 | 770 | $content = ''; |
771 | - $action_class = ! empty( $action_class ) ? ' class="' . $action_class . '"' : ''; |
|
772 | - $action_id = ! empty( $action_id ) ? ' id="' . $action_id . '"' : ''; |
|
773 | - $content .= ! empty( $action_container ) ? '<' . $action_container . $action_class . $action_id . '>' : ''; |
|
774 | - $content .= apply_filters( 'FHEE__EE_Admin_List_Table___action_string__action_items', $action_items, $item, $this ); |
|
775 | - $content .= ! empty( $action_container ) ? '</' . $action_container . '>' : ''; |
|
771 | + $action_class = ! empty($action_class) ? ' class="'.$action_class.'"' : ''; |
|
772 | + $action_id = ! empty($action_id) ? ' id="'.$action_id.'"' : ''; |
|
773 | + $content .= ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : ''; |
|
774 | + $content .= apply_filters('FHEE__EE_Admin_List_Table___action_string__action_items', $action_items, $item, $this); |
|
775 | + $content .= ! empty($action_container) ? '</'.$action_container.'>' : ''; |
|
776 | 776 | return $content; |
777 | 777 | } |
778 | 778 | } |
@@ -58,7 +58,7 @@ |
||
58 | 58 | */ |
59 | 59 | public function processCapCheck($cap_check) |
60 | 60 | { |
61 | - if (is_array($cap_check)){ |
|
61 | + if (is_array($cap_check)) { |
|
62 | 62 | foreach ($cap_check as $check) { |
63 | 63 | $this->processCapCheck($check); |
64 | 64 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use EventEspresso\core\exceptions\InvalidClassException; |
6 | 6 | |
7 | 7 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
8 | - exit('No direct script access allowed'); |
|
8 | + exit('No direct script access allowed'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | |
@@ -21,89 +21,89 @@ discard block |
||
21 | 21 | class CapabilitiesChecker |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @type \EE_Capabilities $capabilities |
|
26 | - */ |
|
27 | - private $capabilities; |
|
28 | - |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * CapabilitiesChecker constructor |
|
33 | - * |
|
34 | - * @param \EE_Capabilities $capabilities |
|
35 | - */ |
|
36 | - public function __construct(\EE_Capabilities $capabilities) |
|
37 | - { |
|
38 | - $this->capabilities = $capabilities; |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * @return \EE_Capabilities |
|
45 | - */ |
|
46 | - protected function capabilities() |
|
47 | - { |
|
48 | - return $this->capabilities; |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
55 | - * If any of the individual capability checks fails, then the command will NOT be executed. |
|
56 | - * |
|
57 | - * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
58 | - * @return bool |
|
59 | - * @throws InvalidClassException |
|
60 | - * @throws InsufficientPermissionsException |
|
61 | - */ |
|
62 | - public function processCapCheck($cap_check) |
|
63 | - { |
|
64 | - if (is_array($cap_check)){ |
|
65 | - foreach ($cap_check as $check) { |
|
66 | - $this->processCapCheck($check); |
|
67 | - } |
|
68 | - return true; |
|
69 | - } |
|
70 | - // at this point, $cap_check should be an individual instance of CapCheck |
|
71 | - if ( ! $cap_check instanceof CapCheckInterface) { |
|
72 | - throw new InvalidClassException( |
|
73 | - '\EventEspresso\core\domain\services\capabilities\CapCheckInterface' |
|
74 | - ); |
|
75 | - } |
|
76 | - // sometimes cap checks are conditional, and no capabilities are required |
|
77 | - if ($cap_check instanceof PublicCapabilities) { |
|
78 | - return true; |
|
79 | - } |
|
80 | - $capabilities = (array) $cap_check->capability(); |
|
81 | - foreach ($capabilities as $capability) { |
|
82 | - if ( |
|
83 | - ! $this->capabilities()->current_user_can( |
|
84 | - $capability, |
|
85 | - $cap_check->context(), |
|
86 | - $cap_check->ID() |
|
87 | - ) |
|
88 | - ) { |
|
89 | - throw new InsufficientPermissionsException($cap_check->context()); |
|
90 | - } |
|
91 | - } |
|
92 | - return true; |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * @param string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
99 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
100 | - * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
101 | - * @return bool |
|
102 | - */ |
|
103 | - public function process($capability, $context, $ID = 0) |
|
104 | - { |
|
105 | - return $this->processCapCheck(new CapCheck($capability, $context, $ID)); |
|
106 | - } |
|
24 | + /** |
|
25 | + * @type \EE_Capabilities $capabilities |
|
26 | + */ |
|
27 | + private $capabilities; |
|
28 | + |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * CapabilitiesChecker constructor |
|
33 | + * |
|
34 | + * @param \EE_Capabilities $capabilities |
|
35 | + */ |
|
36 | + public function __construct(\EE_Capabilities $capabilities) |
|
37 | + { |
|
38 | + $this->capabilities = $capabilities; |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * @return \EE_Capabilities |
|
45 | + */ |
|
46 | + protected function capabilities() |
|
47 | + { |
|
48 | + return $this->capabilities; |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
55 | + * If any of the individual capability checks fails, then the command will NOT be executed. |
|
56 | + * |
|
57 | + * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
58 | + * @return bool |
|
59 | + * @throws InvalidClassException |
|
60 | + * @throws InsufficientPermissionsException |
|
61 | + */ |
|
62 | + public function processCapCheck($cap_check) |
|
63 | + { |
|
64 | + if (is_array($cap_check)){ |
|
65 | + foreach ($cap_check as $check) { |
|
66 | + $this->processCapCheck($check); |
|
67 | + } |
|
68 | + return true; |
|
69 | + } |
|
70 | + // at this point, $cap_check should be an individual instance of CapCheck |
|
71 | + if ( ! $cap_check instanceof CapCheckInterface) { |
|
72 | + throw new InvalidClassException( |
|
73 | + '\EventEspresso\core\domain\services\capabilities\CapCheckInterface' |
|
74 | + ); |
|
75 | + } |
|
76 | + // sometimes cap checks are conditional, and no capabilities are required |
|
77 | + if ($cap_check instanceof PublicCapabilities) { |
|
78 | + return true; |
|
79 | + } |
|
80 | + $capabilities = (array) $cap_check->capability(); |
|
81 | + foreach ($capabilities as $capability) { |
|
82 | + if ( |
|
83 | + ! $this->capabilities()->current_user_can( |
|
84 | + $capability, |
|
85 | + $cap_check->context(), |
|
86 | + $cap_check->ID() |
|
87 | + ) |
|
88 | + ) { |
|
89 | + throw new InsufficientPermissionsException($cap_check->context()); |
|
90 | + } |
|
91 | + } |
|
92 | + return true; |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * @param string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
99 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
100 | + * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
101 | + * @return bool |
|
102 | + */ |
|
103 | + public function process($capability, $context, $ID = 0) |
|
104 | + { |
|
105 | + return $this->processCapCheck(new CapCheck($capability, $context, $ID)); |
|
106 | + } |
|
107 | 107 | |
108 | 108 | |
109 | 109 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * the input's name attribute |
@@ -143,54 +143,54 @@ discard block |
||
143 | 143 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
144 | 144 | * } |
145 | 145 | */ |
146 | - public function __construct( $input_args = array() ){ |
|
147 | - $input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
146 | + public function __construct($input_args = array()) { |
|
147 | + $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
148 | 148 | // the following properties must be cast as arrays |
149 | - if ( isset( $input_args['validation_strategies'] ) ) { |
|
150 | - foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) { |
|
151 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
152 | - $this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy; |
|
149 | + if (isset($input_args['validation_strategies'])) { |
|
150 | + foreach ((array) $input_args['validation_strategies'] as $validation_strategy) { |
|
151 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
152 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
153 | 153 | } |
154 | 154 | } |
155 | - unset( $input_args['validation_strategies'] ); |
|
155 | + unset($input_args['validation_strategies']); |
|
156 | 156 | } |
157 | 157 | // loop thru incoming options |
158 | - foreach( $input_args as $key => $value ) { |
|
158 | + foreach ($input_args as $key => $value) { |
|
159 | 159 | // add underscore to $key to match property names |
160 | - $_key = '_' . $key; |
|
161 | - if ( property_exists( $this, $_key )) { |
|
160 | + $_key = '_'.$key; |
|
161 | + if (property_exists($this, $_key)) { |
|
162 | 162 | $this->{$_key} = $value; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | // ensure that "required" is set correctly |
166 | 166 | $this->set_required( |
167 | - $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) |
|
168 | - ? $input_args[ 'required_validation_error_message' ] |
|
167 | + $this->_required, isset($input_args['required_validation_error_message']) |
|
168 | + ? $input_args['required_validation_error_message'] |
|
169 | 169 | : null |
170 | 170 | ); |
171 | 171 | |
172 | 172 | //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
173 | 173 | |
174 | 174 | $this->_display_strategy->_construct_finalize($this); |
175 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
175 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
176 | 176 | $validation_strategy->_construct_finalize($this); |
177 | 177 | } |
178 | 178 | |
179 | - if( ! $this->_normalization_strategy){ |
|
179 | + if ( ! $this->_normalization_strategy) { |
|
180 | 180 | $this->_normalization_strategy = new EE_Text_Normalization(); |
181 | 181 | } |
182 | 182 | $this->_normalization_strategy->_construct_finalize($this); |
183 | 183 | |
184 | 184 | //at least we can use the normalization strategy to populate the default |
185 | - if( isset( $input_args[ 'default' ] ) ) { |
|
186 | - $this->set_default( $input_args[ 'default' ] ); |
|
185 | + if (isset($input_args['default'])) { |
|
186 | + $this->set_default($input_args['default']); |
|
187 | 187 | } |
188 | 188 | |
189 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
189 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
190 | 190 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
191 | 191 | } |
192 | 192 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
193 | - parent::__construct( $input_args ); |
|
193 | + parent::__construct($input_args); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @throws \EE_Error |
203 | 203 | */ |
204 | - protected function _set_default_html_name_if_empty(){ |
|
205 | - if( ! $this->_html_name){ |
|
204 | + protected function _set_default_html_name_if_empty() { |
|
205 | + if ( ! $this->_html_name) { |
|
206 | 206 | $this->_html_name = $this->name(); |
207 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
208 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
207 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
208 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | public function _construct_finalize($parent_form_section, $name) { |
221 | 221 | parent::_construct_finalize($parent_form_section, $name); |
222 | 222 | $this->_set_default_html_name_if_empty(); |
223 | - if( ! $this->_html_label && ! $this->_html_label_text){ |
|
224 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
223 | + if ( ! $this->_html_label && ! $this->_html_label_text) { |
|
224 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
225 | 225 | } |
226 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
226 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * @return EE_Display_Strategy_Base |
232 | 232 | * @throws EE_Error |
233 | 233 | */ |
234 | - protected function _get_display_strategy(){ |
|
235 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
234 | + protected function _get_display_strategy() { |
|
235 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
236 | 236 | throw new EE_Error( |
237 | 237 | sprintf( |
238 | 238 | __( |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $this->html_id() |
244 | 244 | ) |
245 | 245 | ); |
246 | - }else{ |
|
246 | + } else { |
|
247 | 247 | return $this->_display_strategy; |
248 | 248 | } |
249 | 249 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * Sets the display strategy. |
252 | 252 | * @param EE_Display_Strategy_Base $strategy |
253 | 253 | */ |
254 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
254 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
255 | 255 | $this->_display_strategy = $strategy; |
256 | 256 | } |
257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * Sets the sanitization strategy |
260 | 260 | * @param EE_Normalization_Strategy_Base $strategy |
261 | 261 | */ |
262 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
262 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
263 | 263 | $this->_normalization_strategy = $strategy; |
264 | 264 | } |
265 | 265 | |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | * Gets the display strategy for this input |
286 | 286 | * @return EE_Display_Strategy_Base |
287 | 287 | */ |
288 | - public function get_display_strategy(){ |
|
288 | + public function get_display_strategy() { |
|
289 | 289 | return $this->_display_strategy; |
290 | 290 | } |
291 | 291 | /** |
292 | 292 | * Overwrites the display strategy |
293 | 293 | * @param EE_Display_Strategy_Base $display_strategy |
294 | 294 | */ |
295 | - public function set_display_strategy($display_strategy){ |
|
295 | + public function set_display_strategy($display_strategy) { |
|
296 | 296 | $this->_display_strategy = $display_strategy; |
297 | 297 | $this->_display_strategy->_construct_finalize($this); |
298 | 298 | } |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | * Gets the normalization strategy set on this input |
301 | 301 | * @return EE_Normalization_Strategy_Base |
302 | 302 | */ |
303 | - public function get_normalization_strategy(){ |
|
303 | + public function get_normalization_strategy() { |
|
304 | 304 | return $this->_normalization_strategy; |
305 | 305 | } |
306 | 306 | /** |
307 | 307 | * Overwrites the normalization strategy |
308 | 308 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
309 | 309 | */ |
310 | - public function set_normalization_strategy($normalization_strategy){ |
|
310 | + public function set_normalization_strategy($normalization_strategy) { |
|
311 | 311 | $this->_normalization_strategy = $normalization_strategy; |
312 | 312 | $this->_normalization_strategy->_construct_finalize($this); |
313 | 313 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * Returns all teh validation strategies which apply to this field, numerically indexed |
317 | 317 | * @return EE_Validation_Strategy_Base[] |
318 | 318 | */ |
319 | - public function get_validation_strategies(){ |
|
319 | + public function get_validation_strategies() { |
|
320 | 320 | return $this->_validation_strategies; |
321 | 321 | } |
322 | 322 | |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * @param EE_Validation_Strategy_Base $validation_strategy |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
331 | - $validation_strategy->_construct_finalize( $this ); |
|
330 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
331 | + $validation_strategy->_construct_finalize($this); |
|
332 | 332 | $this->_validation_strategies[] = $validation_strategy; |
333 | 333 | } |
334 | 334 | |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_Validation_Strategy_Base $validation_strategy |
340 | 340 | * @return void |
341 | 341 | */ |
342 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
343 | - $this->_add_validation_strategy( $validation_strategy ); |
|
342 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
343 | + $this->_add_validation_strategy($validation_strategy); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -350,13 +350,13 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @param string $validation_strategy_classname |
352 | 352 | */ |
353 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
354 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
355 | - if( |
|
353 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
354 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
355 | + if ( |
|
356 | 356 | $validation_strategy instanceof $validation_strategy_classname |
357 | - || is_subclass_of( $validation_strategy, $validation_strategy_classname ) |
|
357 | + || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
358 | 358 | ) { |
359 | - unset( $this->_validation_strategies[ $key ] ); |
|
359 | + unset($this->_validation_strategies[$key]); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | } |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | * @param array $validation_strategy_classnames |
370 | 370 | * @return bool |
371 | 371 | */ |
372 | - public function has_validation_strategy( $validation_strategy_classnames ) { |
|
373 | - $validation_strategy_classnames = is_array( $validation_strategy_classnames ) |
|
372 | + public function has_validation_strategy($validation_strategy_classnames) { |
|
373 | + $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
374 | 374 | ? $validation_strategy_classnames |
375 | - : array( $validation_strategy_classnames ); |
|
376 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
377 | - if( in_array( $key, $validation_strategy_classnames ) ) { |
|
375 | + : array($validation_strategy_classnames); |
|
376 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
377 | + if (in_array($key, $validation_strategy_classnames)) { |
|
378 | 378 | return true; |
379 | 379 | } |
380 | 380 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * Gets the HTML |
388 | 388 | * @return string |
389 | 389 | */ |
390 | - public function get_html(){ |
|
390 | + public function get_html() { |
|
391 | 391 | return $this->_parent_section->get_html_for_input($this); |
392 | 392 | } |
393 | 393 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return string |
402 | 402 | * @throws \EE_Error |
403 | 403 | */ |
404 | - public function get_html_for_input(){ |
|
404 | + public function get_html_for_input() { |
|
405 | 405 | return $this->_get_display_strategy()->display(); |
406 | 406 | } |
407 | 407 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * @return string |
412 | 412 | */ |
413 | 413 | public function html_other_attributes() { |
414 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
414 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | /** |
420 | 420 | * @param string $html_other_attributes |
421 | 421 | */ |
422 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
422 | + public function set_html_other_attributes($html_other_attributes) { |
|
423 | 423 | $this->_html_other_attributes = $html_other_attributes; |
424 | 424 | } |
425 | 425 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * according to the form section's layout strategy |
429 | 429 | * @return string |
430 | 430 | */ |
431 | - public function get_html_for_label(){ |
|
431 | + public function get_html_for_label() { |
|
432 | 432 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
433 | 433 | } |
434 | 434 | /** |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | * according to the form section's layout strategy |
437 | 437 | * @return string |
438 | 438 | */ |
439 | - public function get_html_for_errors(){ |
|
439 | + public function get_html_for_errors() { |
|
440 | 440 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
441 | 441 | } |
442 | 442 | /** |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * according to the form section's layout strategy |
445 | 445 | * @return string |
446 | 446 | */ |
447 | - public function get_html_for_help(){ |
|
447 | + public function get_html_for_help() { |
|
448 | 448 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
449 | 449 | } |
450 | 450 | /** |
@@ -453,18 +453,18 @@ discard block |
||
453 | 453 | * @return boolean |
454 | 454 | */ |
455 | 455 | protected function _validate() { |
456 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
457 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
458 | - try{ |
|
456 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
457 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
458 | + try { |
|
459 | 459 | $validation_strategy->validate($this->normalized_value()); |
460 | - }catch(EE_Validation_Error $e){ |
|
460 | + } catch (EE_Validation_Error $e) { |
|
461 | 461 | $this->add_validation_error($e); |
462 | 462 | } |
463 | 463 | } |
464 | 464 | } |
465 | - if( $this->get_validation_errors()){ |
|
465 | + if ($this->get_validation_errors()) { |
|
466 | 466 | return false; |
467 | - }else{ |
|
467 | + } else { |
|
468 | 468 | return true; |
469 | 469 | } |
470 | 470 | } |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | * @param string $value |
479 | 479 | * @return null|string |
480 | 480 | */ |
481 | - private function _sanitize( $value ) { |
|
482 | - return $value !== null ? stripslashes( html_entity_decode( trim( $value ) ) ) : null; |
|
481 | + private function _sanitize($value) { |
|
482 | + return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
@@ -493,25 +493,25 @@ discard block |
||
493 | 493 | * @return boolean whether or not there was an error |
494 | 494 | * @throws \EE_Error |
495 | 495 | */ |
496 | - protected function _normalize( $req_data ) { |
|
496 | + protected function _normalize($req_data) { |
|
497 | 497 | //any existing validation errors don't apply so clear them |
498 | 498 | $this->_validation_errors = array(); |
499 | 499 | try { |
500 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
500 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
501 | 501 | //super simple sanitization for now |
502 | - if ( is_array( $raw_input )) { |
|
502 | + if (is_array($raw_input)) { |
|
503 | 503 | $raw_value = array(); |
504 | - foreach( $raw_input as $key => $value ) { |
|
505 | - $raw_value[ $key ] = $this->_sanitize( $value ); |
|
504 | + foreach ($raw_input as $key => $value) { |
|
505 | + $raw_value[$key] = $this->_sanitize($value); |
|
506 | 506 | } |
507 | - $this->_set_raw_value( $raw_value ); |
|
507 | + $this->_set_raw_value($raw_value); |
|
508 | 508 | } else { |
509 | - $this->_set_raw_value( $this->_sanitize( $raw_input ) ); |
|
509 | + $this->_set_raw_value($this->_sanitize($raw_input)); |
|
510 | 510 | } |
511 | 511 | //we want to mostly leave the input alone in case we need to re-display it to the user |
512 | - $this->_set_normalized_value( $this->_normalization_strategy->normalize( $this->raw_value() ) ); |
|
513 | - } catch ( EE_Validation_Error $e ) { |
|
514 | - $this->add_validation_error( $e ); |
|
512 | + $this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value())); |
|
513 | + } catch (EE_Validation_Error $e) { |
|
514 | + $this->add_validation_error($e); |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | /** |
521 | 521 | * @return string |
522 | 522 | */ |
523 | - public function html_name(){ |
|
523 | + public function html_name() { |
|
524 | 524 | return $this->_html_name; |
525 | 525 | } |
526 | 526 | |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | /** |
530 | 530 | * @return string |
531 | 531 | */ |
532 | - public function html_label_id(){ |
|
533 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
532 | + public function html_label_id() { |
|
533 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | /** |
539 | 539 | * @return string |
540 | 540 | */ |
541 | - public function html_label_class(){ |
|
541 | + public function html_label_class() { |
|
542 | 542 | return $this->_html_label_class; |
543 | 543 | } |
544 | 544 | |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | /** |
548 | 548 | * @return string |
549 | 549 | */ |
550 | - public function html_label_style(){ |
|
550 | + public function html_label_style() { |
|
551 | 551 | return $this->_html_label_style; |
552 | 552 | } |
553 | 553 | |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | /** |
557 | 557 | * @return string |
558 | 558 | */ |
559 | - public function html_label_text(){ |
|
559 | + public function html_label_text() { |
|
560 | 560 | return $this->_html_label_text; |
561 | 561 | } |
562 | 562 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | /** |
566 | 566 | * @return string |
567 | 567 | */ |
568 | - public function html_help_text(){ |
|
568 | + public function html_help_text() { |
|
569 | 569 | return $this->_html_help_text; |
570 | 570 | } |
571 | 571 | |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | /** |
575 | 575 | * @return string |
576 | 576 | */ |
577 | - public function html_help_class(){ |
|
577 | + public function html_help_class() { |
|
578 | 578 | return $this->_html_help_class; |
579 | 579 | } |
580 | 580 | |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | /** |
584 | 584 | * @return string |
585 | 585 | */ |
586 | - public function html_help_style(){ |
|
586 | + public function html_help_style() { |
|
587 | 587 | return $this->_html_style; |
588 | 588 | } |
589 | 589 | /** |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * in which case, we would have stored the malicious content to our database. |
597 | 597 | * @return string |
598 | 598 | */ |
599 | - public function raw_value(){ |
|
599 | + public function raw_value() { |
|
600 | 600 | return $this->_raw_value; |
601 | 601 | } |
602 | 602 | /** |
@@ -604,15 +604,15 @@ discard block |
||
604 | 604 | * it escapes all html entities |
605 | 605 | * @return string |
606 | 606 | */ |
607 | - public function raw_value_in_form(){ |
|
608 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
607 | + public function raw_value_in_form() { |
|
608 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
609 | 609 | } |
610 | 610 | /** |
611 | 611 | * returns the value after it's been sanitized, and then converted into it's proper type |
612 | 612 | * in PHP. Eg, a string, an int, an array, |
613 | 613 | * @return mixed |
614 | 614 | */ |
615 | - public function normalized_value(){ |
|
615 | + public function normalized_value() { |
|
616 | 616 | return $this->_normalized_value; |
617 | 617 | } |
618 | 618 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * the best thing to display |
623 | 623 | * @return string |
624 | 624 | */ |
625 | - public function pretty_value(){ |
|
625 | + public function pretty_value() { |
|
626 | 626 | return $this->_normalized_value; |
627 | 627 | } |
628 | 628 | /** |
@@ -641,19 +641,19 @@ discard block |
||
641 | 641 | }</code> |
642 | 642 | * @return array |
643 | 643 | */ |
644 | - public function get_jquery_validation_rules(){ |
|
644 | + public function get_jquery_validation_rules() { |
|
645 | 645 | $jquery_validation_js = array(); |
646 | 646 | $jquery_validation_rules = array(); |
647 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
647 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
648 | 648 | $jquery_validation_rules = array_replace_recursive( |
649 | 649 | $jquery_validation_rules, |
650 | 650 | $validation_strategy->get_jquery_validation_rule_array() |
651 | 651 | ); |
652 | 652 | } |
653 | 653 | |
654 | - if(! empty($jquery_validation_rules)){ |
|
655 | - foreach( $this->get_display_strategy()->get_html_input_ids( true ) as $html_id_with_pound_sign ) { |
|
656 | - $jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules; |
|
654 | + if ( ! empty($jquery_validation_rules)) { |
|
655 | + foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) { |
|
656 | + $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules; |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | return $jquery_validation_js; |
@@ -665,16 +665,16 @@ discard block |
||
665 | 665 | * @param mixed $value |
666 | 666 | * @return void |
667 | 667 | */ |
668 | - public function set_default($value){ |
|
669 | - $this->_set_normalized_value( $value ); |
|
670 | - $this->_set_raw_value( $value ); |
|
668 | + public function set_default($value) { |
|
669 | + $this->_set_normalized_value($value); |
|
670 | + $this->_set_raw_value($value); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
674 | 674 | * Sets the normalized value on this input |
675 | 675 | * @param mixed $value |
676 | 676 | */ |
677 | - protected function _set_normalized_value( $value ) { |
|
677 | + protected function _set_normalized_value($value) { |
|
678 | 678 | $this->_normalized_value = $value; |
679 | 679 | } |
680 | 680 | |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | * Sets the raw value on this input (ie, exactly as the user submitted it) |
683 | 683 | * @param mixed $value |
684 | 684 | */ |
685 | - protected function _set_raw_value( $value ) { |
|
686 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
685 | + protected function _set_raw_value($value) { |
|
686 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | * @param string $label |
692 | 692 | * @return void |
693 | 693 | */ |
694 | - public function set_html_label_text($label){ |
|
694 | + public function set_html_label_text($label) { |
|
695 | 695 | $this->_html_label_text = $label; |
696 | 696 | } |
697 | 697 | |
@@ -705,13 +705,13 @@ discard block |
||
705 | 705 | * @param boolean $required boolean |
706 | 706 | * @param null $required_text |
707 | 707 | */ |
708 | - public function set_required($required = true, $required_text = NULL ){ |
|
709 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
708 | + public function set_required($required = true, $required_text = NULL) { |
|
709 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
710 | 710 | //whether $required is a string or a boolean, we want to add a required validation strategy |
711 | - if ( $required ) { |
|
712 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
711 | + if ($required) { |
|
712 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
713 | 713 | } else { |
714 | - unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] ); |
|
714 | + unset($this->_validation_strategies['EE_Required_Validation_Strategy']); |
|
715 | 715 | } |
716 | 716 | $this->_required = $required; |
717 | 717 | } |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | * Returns whether or not this field is required |
720 | 720 | * @return boolean |
721 | 721 | */ |
722 | - public function required(){ |
|
722 | + public function required() { |
|
723 | 723 | return $this->_required; |
724 | 724 | } |
725 | 725 | |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | /** |
729 | 729 | * @param string $required_css_class |
730 | 730 | */ |
731 | - public function set_required_css_class( $required_css_class ) { |
|
731 | + public function set_required_css_class($required_css_class) { |
|
732 | 732 | $this->_required_css_class = $required_css_class; |
733 | 733 | } |
734 | 734 | |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | * Sets the help text, in case |
748 | 748 | * @param string $text |
749 | 749 | */ |
750 | - public function set_html_help_text($text){ |
|
750 | + public function set_html_help_text($text) { |
|
751 | 751 | $this->_html_help_text = $text; |
752 | 752 | } |
753 | 753 | /** |
@@ -759,9 +759,9 @@ discard block |
||
759 | 759 | public function clean_sensitive_data() { |
760 | 760 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
761 | 761 | //if we need more logic than this we'll make a strategy for it |
762 | - if( $this->_sensitive_data_removal_strategy && |
|
763 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
764 | - $this->_set_raw_value( null ); |
|
762 | + if ($this->_sensitive_data_removal_strategy && |
|
763 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
764 | + $this->_set_raw_value(null); |
|
765 | 765 | } |
766 | 766 | //and clean the normalized value according to the appropriate strategy |
767 | 767 | $this->_set_normalized_value( |
@@ -778,10 +778,10 @@ discard block |
||
778 | 778 | * @param string $button_size |
779 | 779 | * @param string $other_attributes |
780 | 780 | */ |
781 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
781 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
782 | 782 | $button_css_attributes = 'button'; |
783 | 783 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
784 | - switch ( $button_size ) { |
|
784 | + switch ($button_size) { |
|
785 | 785 | case 'xs' : |
786 | 786 | case 'extra-small' : |
787 | 787 | $button_css_attributes .= ' button-xs'; |
@@ -802,8 +802,8 @@ discard block |
||
802 | 802 | default : |
803 | 803 | $button_css_attributes .= ''; |
804 | 804 | } |
805 | - $this->_button_css_attributes .= ! empty( $other_attributes ) |
|
806 | - ? $button_css_attributes . ' ' . $other_attributes |
|
805 | + $this->_button_css_attributes .= ! empty($other_attributes) |
|
806 | + ? $button_css_attributes.' '.$other_attributes |
|
807 | 807 | : $button_css_attributes; |
808 | 808 | } |
809 | 809 | |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | * @return string |
814 | 814 | */ |
815 | 815 | public function button_css_attributes() { |
816 | - if ( empty( $this->_button_css_attributes )) { |
|
816 | + if (empty($this->_button_css_attributes)) { |
|
817 | 817 | $this->set_button_css_attributes(); |
818 | 818 | } |
819 | 819 | return $this->_button_css_attributes; |
@@ -835,26 +835,26 @@ discard block |
||
835 | 835 | * @return mixed whatever the raw value of this form section is in the request data |
836 | 836 | * @throws \EE_Error |
837 | 837 | */ |
838 | - public function find_form_data_for_this_section( $req_data ){ |
|
838 | + public function find_form_data_for_this_section($req_data) { |
|
839 | 839 | // break up the html name by "[]" |
840 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
841 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
840 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
841 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
842 | 842 | } else { |
843 | 843 | $before_any_brackets = $this->html_name(); |
844 | 844 | } |
845 | 845 | // grab all of the segments |
846 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
847 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
848 | - $name_parts = $matches[ 1 ]; |
|
846 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
847 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
848 | + $name_parts = $matches[1]; |
|
849 | 849 | array_unshift($name_parts, $before_any_brackets); |
850 | - }else{ |
|
851 | - $name_parts = array( $before_any_brackets ); |
|
850 | + } else { |
|
851 | + $name_parts = array($before_any_brackets); |
|
852 | 852 | } |
853 | 853 | // now get the value for the input |
854 | 854 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
855 | 855 | // check if this thing's name is at the TOP level of the request data |
856 | - if( $value === null && isset( $req_data[ $this->name() ] ) ){ |
|
857 | - $value = $req_data[ $this->name() ]; |
|
856 | + if ($value === null && isset($req_data[$this->name()])) { |
|
857 | + $value = $req_data[$this->name()]; |
|
858 | 858 | } |
859 | 859 | return $value; |
860 | 860 | } |
@@ -867,18 +867,18 @@ discard block |
||
867 | 867 | * @param array $req_data |
868 | 868 | * @return array | NULL |
869 | 869 | */ |
870 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
871 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
872 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
873 | - if( empty($html_name_parts ) ){ |
|
874 | - return $req_data[ $first_part_to_consider ]; |
|
875 | - }else{ |
|
870 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
871 | + $first_part_to_consider = array_shift($html_name_parts); |
|
872 | + if (isset($req_data[$first_part_to_consider])) { |
|
873 | + if (empty($html_name_parts)) { |
|
874 | + return $req_data[$first_part_to_consider]; |
|
875 | + } else { |
|
876 | 876 | return $this->_find_form_data_for_this_section_using_name_parts( |
877 | 877 | $html_name_parts, |
878 | - $req_data[ $first_part_to_consider ] |
|
878 | + $req_data[$first_part_to_consider] |
|
879 | 879 | ); |
880 | 880 | } |
881 | - }else{ |
|
881 | + } else { |
|
882 | 882 | return NULL; |
883 | 883 | } |
884 | 884 | } |
@@ -892,14 +892,14 @@ discard block |
||
892 | 892 | * @return boolean |
893 | 893 | * @throws \EE_Error |
894 | 894 | */ |
895 | - public function form_data_present_in($req_data = NULL){ |
|
896 | - if( $req_data === NULL ){ |
|
895 | + public function form_data_present_in($req_data = NULL) { |
|
896 | + if ($req_data === NULL) { |
|
897 | 897 | $req_data = $_POST; |
898 | 898 | } |
899 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
900 | - if( $checked_value !== null ){ |
|
899 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
900 | + if ($checked_value !== null) { |
|
901 | 901 | return TRUE; |
902 | - }else{ |
|
902 | + } else { |
|
903 | 903 | return FALSE; |
904 | 904 | } |
905 | 905 | } |
@@ -910,8 +910,8 @@ discard block |
||
910 | 910 | * @param array $form_other_js_data |
911 | 911 | * @return array |
912 | 912 | */ |
913 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
914 | - $form_other_js_data = $this->get_other_js_data_from_strategies( $form_other_js_data ); |
|
913 | + public function get_other_js_data($form_other_js_data = array()) { |
|
914 | + $form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data); |
|
915 | 915 | return $form_other_js_data; |
916 | 916 | } |
917 | 917 | |
@@ -924,10 +924,10 @@ discard block |
||
924 | 924 | * @param array $form_other_js_data |
925 | 925 | * @return array |
926 | 926 | */ |
927 | - public function get_other_js_data_from_strategies( $form_other_js_data = array() ) { |
|
928 | - $form_other_js_data = $this->get_display_strategy()->get_other_js_data( $form_other_js_data ); |
|
929 | - foreach( $this->get_validation_strategies() as $validation_strategy ) { |
|
930 | - $form_other_js_data = $validation_strategy->get_other_js_data( $form_other_js_data ); |
|
927 | + public function get_other_js_data_from_strategies($form_other_js_data = array()) { |
|
928 | + $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data); |
|
929 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
930 | + $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data); |
|
931 | 931 | } |
932 | 932 | return $form_other_js_data; |
933 | 933 | } |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | * Override parent because we want to give our strategies an opportunity to enqueue some js and css |
937 | 937 | * @return void |
938 | 938 | */ |
939 | - public function enqueue_js(){ |
|
939 | + public function enqueue_js() { |
|
940 | 940 | //ask our display strategy and validation strategies if they have js to enqueue |
941 | 941 | $this->enqueue_js_from_strategies(); |
942 | 942 | } |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | */ |
948 | 948 | public function enqueue_js_from_strategies() { |
949 | 949 | $this->get_display_strategy()->enqueue_js(); |
950 | - foreach( $this->get_validation_strategies() as $validation_strategy ) { |
|
950 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
951 | 951 | $validation_strategy->enqueue_js(); |
952 | 952 | } |
953 | 953 | } |