@@ -10,20 +10,20 @@ discard block |
||
10 | 10 | * @since 4.6 |
11 | 11 | * |
12 | 12 | */ |
13 | -class EE_Full_HTML_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
13 | +class EE_Full_HTML_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @param null $validation_error_message |
17 | 17 | */ |
18 | - public function __construct( $validation_error_message = NULL ) { |
|
19 | - if ( ! $validation_error_message ) { |
|
18 | + public function __construct($validation_error_message = NULL) { |
|
19 | + if ( ! $validation_error_message) { |
|
20 | 20 | $validation_error_message = sprintf( |
21 | - __( 'Only the following HTML tags are allowed:%1$s%2$s', "event_espresso" ), |
|
21 | + __('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"), |
|
22 | 22 | '<br />', |
23 | 23 | $this->get_list_of_allowed_tags() |
24 | 24 | ); |
25 | 25 | } |
26 | - parent::__construct( $validation_error_message ); |
|
26 | + parent::__construct($validation_error_message); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function get_list_of_allowed_tags() { |
39 | 39 | global $allowedposttags; |
40 | - ksort( $allowedposttags ); |
|
41 | - return implode( ', ', array_keys( $allowedposttags ) ); |
|
40 | + ksort($allowedposttags); |
|
41 | + return implode(', ', array_keys($allowedposttags)); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function validate($normalized_value) { |
51 | 51 | global $allowedposttags; |
52 | - parent::validate( $normalized_value ); |
|
53 | - $normalized_value_sans_tags = wp_kses( "$normalized_value", $allowedposttags ); |
|
54 | - if ( strlen( $normalized_value ) > strlen( $normalized_value_sans_tags ) ) { |
|
55 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'complex_html_tags' ); |
|
52 | + parent::validate($normalized_value); |
|
53 | + $normalized_value_sans_tags = wp_kses("$normalized_value", $allowedposttags); |
|
54 | + if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) { |
|
55 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | } |
59 | 59 | \ No newline at end of file |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EE_Admin_File_Uploader_Display_Strategy extends EE_Display_Strategy_Base{ |
|
11 | +class EE_Admin_File_Uploader_Display_Strategy extends EE_Display_Strategy_Base { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Its important this media only get enqueued AFTER init, but before the footer... where the |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | * this input displayed. |
21 | 21 | * @deprecated. enqueue_js should be called automatically now |
22 | 22 | */ |
23 | - static function enqueue_scripts(){ |
|
24 | - EE_Error::doing_it_wrong( __FUNCTION__, __( 'EE_Admin_File_Uploader_Display_Strategy::enqueue_scripts() no longer needs to be called in order to display the admin uploader input correctly. This is handled now by EE_Admin_File_Uploader_Display_Strategy::enqueue_js() which is called automatically when enqueueing JS and CSS for the form'), '4.9.8.rc.015' ); |
|
23 | + static function enqueue_scripts() { |
|
24 | + EE_Error::doing_it_wrong(__FUNCTION__, __('EE_Admin_File_Uploader_Display_Strategy::enqueue_scripts() no longer needs to be called in order to display the admin uploader input correctly. This is handled now by EE_Admin_File_Uploader_Display_Strategy::enqueue_js() which is called automatically when enqueueing JS and CSS for the form'), '4.9.8.rc.015'); |
|
25 | 25 | wp_enqueue_media(); |
26 | 26 | wp_enqueue_script('media-upload'); |
27 | - wp_enqueue_script('ee-payments',EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
27 | + wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public function enqueue_js() { |
34 | 34 | wp_enqueue_media(); |
35 | 35 | wp_enqueue_script('media-upload'); |
36 | - wp_enqueue_script('ee-payments',EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
36 | + wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
37 | 37 | parent::enqueue_js(); |
38 | 38 | } |
39 | 39 | |
@@ -44,19 +44,19 @@ discard block |
||
44 | 44 | * @return string of html to display the field |
45 | 45 | */ |
46 | 46 | |
47 | - function display(){ |
|
47 | + function display() { |
|
48 | 48 | // the actual input |
49 | 49 | $input = '<input type="text" size="34" '; |
50 | - $input .= 'name="' . $this->_input->html_name() . '" '; |
|
51 | - $input .= $this->_input->html_class() != '' ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" ' : 'class="large-text ee_media_url" '; |
|
52 | - $input .= 'value="' . $this->_input->raw_value_in_form() . '" '; |
|
53 | - $input .= $this->_input->other_html_attributes() . '>'; |
|
50 | + $input .= 'name="'.$this->_input->html_name().'" '; |
|
51 | + $input .= $this->_input->html_class() != '' ? 'class="large-text ee_media_url '.$this->_input->html_class().'" ' : 'class="large-text ee_media_url" '; |
|
52 | + $input .= 'value="'.$this->_input->raw_value_in_form().'" '; |
|
53 | + $input .= $this->_input->other_html_attributes().'>'; |
|
54 | 54 | // image uploader |
55 | - $uploader = EEH_HTML::link( '#', '<img src="' . admin_url( 'images/media-button-image.gif' ) . '" >', __( 'click to add an image', 'event_espresso' ), '', 'ee_media_upload' ); |
|
55 | + $uploader = EEH_HTML::link('#', '<img src="'.admin_url('images/media-button-image.gif').'" >', __('click to add an image', 'event_espresso'), '', 'ee_media_upload'); |
|
56 | 56 | //only attempt to show the image if it at least exists |
57 | - $image = $this->src_exists( $this->_input->raw_value() ) ? EEH_HTML::br(2) . EEH_HTML::img( $this->_input->raw_value(), __( 'logo', 'event_espresso' ), '', 'ee_media_image' ) : ''; |
|
57 | + $image = $this->src_exists($this->_input->raw_value()) ? EEH_HTML::br(2).EEH_HTML::img($this->_input->raw_value(), __('logo', 'event_espresso'), '', 'ee_media_image') : ''; |
|
58 | 58 | // html string |
59 | - return EEH_HTML::div( $input . EEH_HTML::nbsp() . $uploader . $image, '', 'ee_media_uploader_area' ); |
|
59 | + return EEH_HTML::div($input.EEH_HTML::nbsp().$uploader.$image, '', 'ee_media_uploader_area'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | * @param string $src |
68 | 68 | * @return boolean |
69 | 69 | */ |
70 | - protected function src_exists( $src ){ |
|
71 | - $results = wp_remote_head( $src ); |
|
72 | - if( is_array( $results) && ! $results instanceof WP_Error){ |
|
73 | - return strpos($results['headers']['content-type'], "image" ) !== FALSE; |
|
74 | - }else{ |
|
70 | + protected function src_exists($src) { |
|
71 | + $results = wp_remote_head($src); |
|
72 | + if (is_array($results) && ! $results instanceof WP_Error) { |
|
73 | + return strpos($results['headers']['content-type'], "image") !== FALSE; |
|
74 | + } else { |
|
75 | 75 | return FALSE; |
76 | 76 | } |
77 | 77 | } |
@@ -881,7 +881,7 @@ |
||
881 | 881 | |
882 | 882 | /** |
883 | 883 | * @deprecated 4.9.0 |
884 | - * @return array |
|
884 | + * @return EE_messenger[] |
|
885 | 885 | */ |
886 | 886 | public function get_installed_messengers() { |
887 | 887 | // EE_messages has been deprecated |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * ************************************************************************ |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param \EE_Checkout $checkout |
32 | 32 | * @return string |
33 | 33 | */ |
34 | -function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) { |
|
34 | +function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) { |
|
35 | 35 | // list of old filters |
36 | 36 | $deprecated_filters = array( |
37 | 37 | 'update_registration_details' => true, |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | 'proceed_to' => true, |
42 | 42 | ); |
43 | 43 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
44 | - foreach ( $deprecated_filters as $deprecated_filter => $on ) { |
|
44 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
45 | 45 | // was this filter called ? |
46 | - if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) { |
|
46 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
47 | 47 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
48 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) { |
|
48 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) { |
|
49 | 49 | EE_Error::doing_it_wrong( |
50 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
50 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
51 | 51 | sprintf( |
52 | - __( 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ), |
|
53 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
52 | + __('The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'), |
|
53 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
54 | 54 | '<br />', |
55 | 55 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
56 | 56 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -59,24 +59,24 @@ discard block |
||
59 | 59 | ); |
60 | 60 | } |
61 | 61 | } else { |
62 | - unset( $deprecated_filters[ $deprecated_filter ] ); |
|
62 | + unset($deprecated_filters[$deprecated_filter]); |
|
63 | 63 | } |
64 | 64 | } |
65 | - if ( ! empty( $deprecated_filters )) { |
|
65 | + if ( ! empty($deprecated_filters)) { |
|
66 | 66 | |
67 | - if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) { |
|
68 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text ); |
|
69 | - } else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) { |
|
70 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text ); |
|
71 | - } else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) { |
|
72 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text ); |
|
67 | + if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
68 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text); |
|
69 | + } else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
70 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text); |
|
71 | + } else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
72 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text); |
|
73 | 73 | } |
74 | - if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
75 | - if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) { |
|
76 | - $submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text ); |
|
74 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
75 | + if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
76 | + $submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text); |
|
77 | 77 | } |
78 | - if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) { |
|
79 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name(); |
|
78 | + if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
79 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name(); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | return $submit_button_text; |
85 | 85 | |
86 | 86 | } |
87 | -add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 ); |
|
87 | +add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2); |
|
88 | 88 | |
89 | 89 | |
90 | 90 | |
@@ -95,16 +95,16 @@ discard block |
||
95 | 95 | * @param \EE_Checkout $checkout |
96 | 96 | * @param boolean $status_updates |
97 | 97 | */ |
98 | -function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) { |
|
98 | +function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) { |
|
99 | 99 | $action_ref = NULL; |
100 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
101 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
102 | - if ( $action_ref ) { |
|
100 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
101 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
102 | + if ($action_ref) { |
|
103 | 103 | |
104 | 104 | EE_Error::doing_it_wrong( |
105 | 105 | $action_ref, |
106 | 106 | sprintf( |
107 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ), |
|
107 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'), |
|
108 | 108 | '<br />', |
109 | 109 | '/core/business/EE_Transaction_Processor.class.php', |
110 | 110 | 'AHEE__EE_Transaction_Processor__finalize', |
@@ -114,39 +114,39 @@ discard block |
||
114 | 114 | ), |
115 | 115 | '4.6.0' |
116 | 116 | ); |
117 | - switch ( $action_ref ) { |
|
117 | + switch ($action_ref) { |
|
118 | 118 | case 'AHEE__EE_Transaction__finalize__new_transaction' : |
119 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request ); |
|
119 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request); |
|
120 | 120 | break; |
121 | 121 | case 'AHEE__EE_Transaction__finalize__all_transaction' : |
122 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request ); |
|
122 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request); |
|
123 | 123 | break; |
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
127 | -add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 ); |
|
127 | +add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2); |
|
128 | 128 | /** |
129 | 129 | * ee_deprecated_finalize_registration |
130 | 130 | * |
131 | 131 | * @param EE_Registration $registration |
132 | 132 | */ |
133 | -function ee_deprecated_finalize_registration( EE_Registration $registration ) { |
|
134 | - $action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
135 | - if ( $action_ref ) { |
|
133 | +function ee_deprecated_finalize_registration(EE_Registration $registration) { |
|
134 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
135 | + if ($action_ref) { |
|
136 | 136 | EE_Error::doing_it_wrong( |
137 | 137 | $action_ref, |
138 | 138 | sprintf( |
139 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ), |
|
139 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'), |
|
140 | 140 | '<br />', |
141 | 141 | '/core/business/EE_Registration_Processor.class.php', |
142 | 142 | 'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook' |
143 | 143 | ), |
144 | 144 | '4.6.0' |
145 | 145 | ); |
146 | - do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ))); |
|
146 | + do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))); |
|
147 | 147 | } |
148 | 148 | } |
149 | -add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 ); |
|
149 | +add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1); |
|
150 | 150 | |
151 | 151 | |
152 | 152 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called. |
155 | 155 | * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately. |
156 | 156 | */ |
157 | -function ee_deprecated_hooks(){ |
|
157 | +function ee_deprecated_hooks() { |
|
158 | 158 | /** |
159 | 159 | * @var $hooks array where keys are hook names, and their values are array{ |
160 | 160 | * @type string $version when deprecated |
@@ -165,25 +165,25 @@ discard block |
||
165 | 165 | $hooks = array( |
166 | 166 | 'AHEE__EE_System___do_setup_validations' => array( |
167 | 167 | 'version' => '4.6.0', |
168 | - 'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ), |
|
168 | + 'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'), |
|
169 | 169 | 'still_works' => FALSE |
170 | 170 | ) |
171 | 171 | ); |
172 | - foreach( $hooks as $name => $deprecation_info ){ |
|
173 | - if( has_action( $name ) ){ |
|
172 | + foreach ($hooks as $name => $deprecation_info) { |
|
173 | + if (has_action($name)) { |
|
174 | 174 | EE_Error::doing_it_wrong( |
175 | 175 | $name, |
176 | 176 | sprintf( |
177 | - __('This filter is deprecated. %1$s%2$s','event_espresso'), |
|
178 | - $deprecation_info[ 'still_works' ] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ), |
|
179 | - isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' ) |
|
177 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
178 | + $deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'), |
|
179 | + isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso') |
|
180 | 180 | ), |
181 | - isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ) |
|
181 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
182 | 182 | ); |
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
186 | -add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' ); |
|
186 | +add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
|
187 | 187 | |
188 | 188 | |
189 | 189 | |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | * @return boolean |
195 | 195 | */ |
196 | 196 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() { |
197 | - $in_use = has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' ) |
|
198 | - || has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' ); |
|
199 | - if( $in_use ) { |
|
197 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
198 | + || has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'); |
|
199 | + if ($in_use) { |
|
200 | 200 | $msg = __( |
201 | 201 | 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
202 | 202 | . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
@@ -205,18 +205,18 @@ discard block |
||
205 | 205 | 'event_espresso' ) |
206 | 206 | ; |
207 | 207 | EE_Error::doing_it_wrong( |
208 | - __CLASS__ . '::' . __FUNCTION__, |
|
208 | + __CLASS__.'::'.__FUNCTION__, |
|
209 | 209 | $msg, |
210 | 210 | '4.8.32.rc.000' |
211 | 211 | ); |
212 | 212 | //it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
213 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
214 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
213 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
214 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | return $in_use; |
218 | 218 | } |
219 | -add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' ); |
|
219 | +add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'); |
|
220 | 220 | |
221 | 221 | /** |
222 | 222 | * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165 |
@@ -225,34 +225,34 @@ discard block |
||
225 | 225 | * @param EE_Admin_Page $admin_page |
226 | 226 | * @return void |
227 | 227 | */ |
228 | -function ee_deprecated_update_attendee_registration_form_old( $admin_page ) { |
|
228 | +function ee_deprecated_update_attendee_registration_form_old($admin_page) { |
|
229 | 229 | //check if the old hooks are in use. If not, do the default |
230 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
231 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
230 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
231 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
232 | 232 | return; |
233 | 233 | } |
234 | 234 | $req_data = $admin_page->get_request_data(); |
235 | - $qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE; |
|
236 | - $REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE; |
|
237 | - $qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns ); |
|
238 | - if ( ! $REG_ID || ! $qstns ) { |
|
239 | - EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
235 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE; |
|
236 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE; |
|
237 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
238 | + if ( ! $REG_ID || ! $qstns) { |
|
239 | + EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
240 | 240 | } |
241 | 241 | $success = TRUE; |
242 | 242 | |
243 | 243 | // allow others to get in on this awesome fun :D |
244 | - do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns ); |
|
244 | + do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns); |
|
245 | 245 | // loop thru questions... FINALLY!!! |
246 | 246 | |
247 | - foreach ( $qstns as $QST_ID => $qstn ) { |
|
247 | + foreach ($qstns as $QST_ID => $qstn) { |
|
248 | 248 | //if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
249 | - if ( !is_array($qstn) ) { |
|
250 | - $success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn); |
|
249 | + if ( ! is_array($qstn)) { |
|
250 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
251 | 251 | continue; |
252 | 252 | } |
253 | 253 | |
254 | 254 | |
255 | - foreach ( $qstn as $ANS_ID => $ANS_value ) { |
|
255 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
256 | 256 | //get answer |
257 | 257 | $query_params = array( |
258 | 258 | 0 => array( |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | ); |
264 | 264 | $answer = EEM_Answer::instance()->get_one($query_params); |
265 | 265 | //this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
266 | - if ( ! $answer instanceof EE_Answer ) { |
|
266 | + if ( ! $answer instanceof EE_Answer) { |
|
267 | 267 | $set_values = array( |
268 | 268 | 'QST_ID' => $QST_ID, |
269 | 269 | 'REG_ID' => $REG_ID, |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | } |
279 | 279 | } |
280 | 280 | $what = __('Registration Form', 'event_espresso'); |
281 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
282 | - $admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
281 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
282 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
283 | 283 | exit; |
284 | 284 | } |
285 | -add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 ); |
|
285 | +add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1); |
|
286 | 286 | /** |
287 | 287 | * Render the registration admin page's custom questions area in the old fashion |
288 | 288 | * and firing the old hooks. When this method is removed, we can probably also |
@@ -295,31 +295,31 @@ discard block |
||
295 | 295 | * @return bool |
296 | 296 | * @throws \EE_Error |
297 | 297 | */ |
298 | -function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) { |
|
298 | +function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) { |
|
299 | 299 | //check if the old hooks are in use. If not, do the default |
300 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
301 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
300 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
301 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
302 | 302 | return $do_default_action; |
303 | 303 | } |
304 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 ); |
|
305 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 ); |
|
306 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 ); |
|
307 | - add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 ); |
|
304 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1); |
|
305 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1); |
|
306 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
307 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
308 | 308 | |
309 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') ); |
|
309 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID')); |
|
310 | 310 | |
311 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
311 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
312 | 312 | $template_args = array( |
313 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ), |
|
313 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
314 | 314 | 'reg_questions_form_action' => 'edit_registration', |
315 | 315 | 'REG_ID' => $registration->ID() |
316 | 316 | ); |
317 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
318 | - echo EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
317 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
318 | + echo EEH_Template::display_template($template_path, $template_args, TRUE); |
|
319 | 319 | //indicate that we should not do the default admin page code |
320 | 320 | return false; |
321 | 321 | } |
322 | -add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 ); |
|
322 | +add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3); |
|
323 | 323 | |
324 | 324 | |
325 | 325 | |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | '4.9.0' |
361 | 361 | ); |
362 | 362 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
363 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
364 | - $messenger = $message_resource_manager->get_messenger( $messenger_name ); |
|
365 | - $message_type = $message_resource_manager->get_message_type( $message_type_name ); |
|
363 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
364 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
365 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
366 | 366 | return EE_Registry::instance()->load_lib( |
367 | 367 | 'Messages_Template_Defaults', |
368 | 368 | array( |
@@ -427,15 +427,15 @@ discard block |
||
427 | 427 | /** |
428 | 428 | * @param string $method |
429 | 429 | */ |
430 | - public function _class_is_deprecated( $method ) { |
|
430 | + public function _class_is_deprecated($method) { |
|
431 | 431 | EE_Error::doing_it_wrong( |
432 | - 'EE_messages::' . $method, |
|
433 | - __( 'EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.' ), |
|
432 | + 'EE_messages::'.$method, |
|
433 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
434 | 434 | '4.9.0', |
435 | 435 | '4.10.0.p' |
436 | 436 | ); |
437 | 437 | // Please use EE_Message_Resource_Manager instead |
438 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
438 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | |
@@ -445,10 +445,10 @@ discard block |
||
445 | 445 | * @param string $messenger_name |
446 | 446 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
447 | 447 | */ |
448 | - public function ensure_messenger_is_active( $messenger_name ) { |
|
448 | + public function ensure_messenger_is_active($messenger_name) { |
|
449 | 449 | // EE_messages has been deprecated |
450 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
451 | - return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name ); |
|
450 | + $this->_class_is_deprecated(__FUNCTION__); |
|
451 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | |
@@ -460,10 +460,10 @@ discard block |
||
460 | 460 | * @return bool true if it got activated (or was active) and false if not. |
461 | 461 | * @throws \EE_Error |
462 | 462 | */ |
463 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
463 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
464 | 464 | // EE_messages has been deprecated |
465 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
466 | - return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger ); |
|
465 | + $this->_class_is_deprecated(__FUNCTION__); |
|
466 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | |
@@ -476,10 +476,10 @@ discard block |
||
476 | 476 | * they are already setup.) |
477 | 477 | * @return boolean an array of generated templates or false if nothing generated/activated. |
478 | 478 | */ |
479 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ) { |
|
479 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
480 | 480 | // EE_messages has been deprecated |
481 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
482 | - return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate ); |
|
481 | + $this->_class_is_deprecated(__FUNCTION__); |
|
482 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
@@ -491,10 +491,10 @@ discard block |
||
491 | 491 | * |
492 | 492 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
493 | 493 | */ |
494 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
494 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
495 | 495 | // EE_messages has been deprecated |
496 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
497 | - return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type ); |
|
496 | + $this->_class_is_deprecated(__FUNCTION__); |
|
497 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -504,10 +504,10 @@ discard block |
||
504 | 504 | * @param string $messenger |
505 | 505 | * @return EE_messenger | null |
506 | 506 | */ |
507 | - public function get_messenger_if_active( $messenger ) { |
|
507 | + public function get_messenger_if_active($messenger) { |
|
508 | 508 | // EE_messages has been deprecated |
509 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
510 | - return $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
509 | + $this->_class_is_deprecated(__FUNCTION__); |
|
510 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | |
@@ -528,9 +528,9 @@ discard block |
||
528 | 528 | * 'message_type' => null |
529 | 529 | * ) |
530 | 530 | */ |
531 | - public function validate_for_use( EE_Message $message ) { |
|
531 | + public function validate_for_use(EE_Message $message) { |
|
532 | 532 | // EE_messages has been deprecated |
533 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
533 | + $this->_class_is_deprecated(__FUNCTION__); |
|
534 | 534 | return array( |
535 | 535 | 'messenger' => $message->messenger_object(), |
536 | 536 | 'message_type' => $message->message_type_object(), |
@@ -558,41 +558,41 @@ discard block |
||
558 | 558 | $send = true |
559 | 559 | ) { |
560 | 560 | // EE_messages has been deprecated |
561 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
561 | + $this->_class_is_deprecated(__FUNCTION__); |
|
562 | 562 | /** @type EE_Messages_Processor $processor */ |
563 | - $processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
563 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
564 | 564 | $error = false; |
565 | 565 | //try to intelligently determine what method we'll call based on the incoming data. |
566 | 566 | //if generating and sending are different then generate and send immediately. |
567 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
567 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
568 | 568 | //in the legacy system, when generating and sending were different, that means all the |
569 | 569 | //vars are already in the request object. So let's just use that. |
570 | 570 | try { |
571 | 571 | /** @type EE_Message_To_Generate_From_Request $mtg */ |
572 | - $mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
573 | - $processor->generate_and_send_now( $mtg ); |
|
574 | - } catch ( EE_Error $e ) { |
|
572 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
573 | + $processor->generate_and_send_now($mtg); |
|
574 | + } catch (EE_Error $e) { |
|
575 | 575 | $error_msg = __( |
576 | 576 | 'Please note that a system message failed to send due to a technical issue.', |
577 | 577 | 'event_espresso' |
578 | 578 | ); |
579 | 579 | // add specific message for developers if WP_DEBUG in on |
580 | - $error_msg .= '||' . $e->getMessage(); |
|
581 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
580 | + $error_msg .= '||'.$e->getMessage(); |
|
581 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
582 | 582 | $error = true; |
583 | 583 | } |
584 | 584 | } else { |
585 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
585 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
586 | 586 | //let's find out if there were any errors and how many successfully were queued. |
587 | 587 | $count_errors = $processor->get_queue()->count_STS_in_queue( |
588 | - array( EEM_Message::status_failed, EEM_Message::status_debug_only ) |
|
588 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
589 | 589 | ); |
590 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
591 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
590 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
591 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
592 | 592 | $count_errors = $count_errors + $count_retry; |
593 | - if ( $count_errors > 0 ) { |
|
593 | + if ($count_errors > 0) { |
|
594 | 594 | $error = true; |
595 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
595 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
596 | 596 | $message = sprintf( |
597 | 597 | __( |
598 | 598 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | $count_errors, |
602 | 602 | $count_queued |
603 | 603 | ); |
604 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
604 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
605 | 605 | $message = sprintf( |
606 | 606 | __( |
607 | 607 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | $count_errors, |
611 | 611 | $count_queued |
612 | 612 | ); |
613 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
613 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
614 | 614 | $message = sprintf( |
615 | 615 | __( |
616 | 616 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | $count_errors |
629 | 629 | ); |
630 | 630 | } |
631 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
631 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
632 | 632 | } else { |
633 | - if ( $count_queued === 1 ) { |
|
633 | + if ($count_queued === 1) { |
|
634 | 634 | $message = sprintf( |
635 | 635 | __( |
636 | 636 | '%d message successfully queued for generation.', |
@@ -647,18 +647,18 @@ discard block |
||
647 | 647 | $count_queued |
648 | 648 | ); |
649 | 649 | } |
650 | - EE_Error::add_success( $message ); |
|
650 | + EE_Error::add_success($message); |
|
651 | 651 | } |
652 | 652 | } |
653 | 653 | //if no error then return the generated message(s). |
654 | - if ( ! $error && ! $send ) { |
|
655 | - $generated_queue = $processor->generate_queue( false ); |
|
654 | + if ( ! $error && ! $send) { |
|
655 | + $generated_queue = $processor->generate_queue(false); |
|
656 | 656 | //get message and return. |
657 | 657 | $generated_queue->get_message_repository()->rewind(); |
658 | 658 | $messages = array(); |
659 | - while ( $generated_queue->get_message_repository()->valid() ) { |
|
659 | + while ($generated_queue->get_message_repository()->valid()) { |
|
660 | 660 | $message = $generated_queue->get_message_repository()->current(); |
661 | - if ( $message instanceof EE_Message ) { |
|
661 | + if ($message instanceof EE_Message) { |
|
662 | 662 | //set properties that might be expected by add-ons (backward compat) |
663 | 663 | $message->content = $message->content(); |
664 | 664 | $message->template_pack = $message->get_template_pack(); |
@@ -683,10 +683,10 @@ discard block |
||
683 | 683 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
684 | 684 | * @return string The body of the message. |
685 | 685 | */ |
686 | - public function preview_message( $type, $context, $messenger, $send = false ) { |
|
686 | + public function preview_message($type, $context, $messenger, $send = false) { |
|
687 | 687 | // EE_messages has been deprecated |
688 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
689 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
688 | + $this->_class_is_deprecated(__FUNCTION__); |
|
689 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | |
@@ -700,14 +700,14 @@ discard block |
||
700 | 700 | * |
701 | 701 | * @return bool success or fail. |
702 | 702 | */ |
703 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
703 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
704 | 704 | // EE_messages has been deprecated |
705 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
705 | + $this->_class_is_deprecated(__FUNCTION__); |
|
706 | 706 | //setup for sending to new method. |
707 | 707 | /** @type EE_Messages_Queue $queue */ |
708 | - $queue = EE_Registry::instance()->load_lib( 'Messages_Queue' ); |
|
708 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
709 | 709 | //make sure we have a proper message object |
710 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
710 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
711 | 711 | $msg = EE_Message_Factory::create( |
712 | 712 | array( |
713 | 713 | 'MSG_messenger' => $messenger, |
@@ -719,15 +719,15 @@ discard block |
||
719 | 719 | } else { |
720 | 720 | $msg = $message; |
721 | 721 | } |
722 | - if ( ! $msg instanceof EE_Message ) { |
|
722 | + if ( ! $msg instanceof EE_Message) { |
|
723 | 723 | return false; |
724 | 724 | } |
725 | 725 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
726 | - if ( ! empty( $msg->content ) ) { |
|
727 | - $msg->set( 'MSG_content', $msg->content ); |
|
726 | + if ( ! empty($msg->content)) { |
|
727 | + $msg->set('MSG_content', $msg->content); |
|
728 | 728 | } |
729 | - $queue->add( $msg ); |
|
730 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
729 | + $queue->add($msg); |
|
730 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | |
@@ -741,11 +741,11 @@ discard block |
||
741 | 741 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
742 | 742 | * @throws \EE_Error |
743 | 743 | */ |
744 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
744 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
745 | 745 | // EE_messages has been deprecated |
746 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
747 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
748 | - return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global ); |
|
746 | + $this->_class_is_deprecated(__FUNCTION__); |
|
747 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
748 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | |
@@ -756,11 +756,11 @@ discard block |
||
756 | 756 | * @param string $message_type_name name of EE_message_type |
757 | 757 | * @return array |
758 | 758 | */ |
759 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
759 | + public function get_fields($messenger_name, $message_type_name) { |
|
760 | 760 | // EE_messages has been deprecated |
761 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
762 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
763 | - return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name ); |
|
761 | + $this->_class_is_deprecated(__FUNCTION__); |
|
762 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
763 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | |
@@ -774,13 +774,13 @@ discard block |
||
774 | 774 | * @return array multidimensional array of messenger and message_type objects |
775 | 775 | * (messengers index, and message_type index); |
776 | 776 | */ |
777 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
777 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
778 | 778 | // EE_messages has been deprecated |
779 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
780 | - if ( $skip_cache ) { |
|
779 | + $this->_class_is_deprecated(__FUNCTION__); |
|
780 | + if ($skip_cache) { |
|
781 | 781 | $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
782 | 782 | } |
783 | - switch ( $type ) { |
|
783 | + switch ($type) { |
|
784 | 784 | case 'messengers' : |
785 | 785 | return array( |
786 | 786 | 'messenger' => $this->_message_resource_manager->installed_messengers(), |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | */ |
810 | 810 | public function get_active_messengers() { |
811 | 811 | // EE_messages has been deprecated |
812 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
812 | + $this->_class_is_deprecated(__FUNCTION__); |
|
813 | 813 | return $this->_message_resource_manager->active_messengers(); |
814 | 814 | } |
815 | 815 | |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | */ |
822 | 822 | public function get_active_message_types() { |
823 | 823 | // EE_messages has been deprecated |
824 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
824 | + $this->_class_is_deprecated(__FUNCTION__); |
|
825 | 825 | return $this->_message_resource_manager->list_of_active_message_types(); |
826 | 826 | } |
827 | 827 | |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | */ |
834 | 834 | public function get_active_message_type_objects() { |
835 | 835 | // EE_messages has been deprecated |
836 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
836 | + $this->_class_is_deprecated(__FUNCTION__); |
|
837 | 837 | return $this->_message_resource_manager->get_active_message_type_objects(); |
838 | 838 | } |
839 | 839 | |
@@ -845,10 +845,10 @@ discard block |
||
845 | 845 | * @param string $messenger The messenger being checked |
846 | 846 | * @return EE_message_type[] (or empty array if none present) |
847 | 847 | */ |
848 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
848 | + public function get_active_message_types_per_messenger($messenger) { |
|
849 | 849 | // EE_messages has been deprecated |
850 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
851 | - return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger ); |
|
850 | + $this->_class_is_deprecated(__FUNCTION__); |
|
851 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | |
@@ -859,10 +859,10 @@ discard block |
||
859 | 859 | * @param string $message_type The string should correspond to a message type. |
860 | 860 | * @return EE_message_type|null |
861 | 861 | */ |
862 | - public function get_active_message_type( $messenger, $message_type ) { |
|
862 | + public function get_active_message_type($messenger, $message_type) { |
|
863 | 863 | // EE_messages has been deprecated |
864 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
865 | - return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type ); |
|
864 | + $this->_class_is_deprecated(__FUNCTION__); |
|
865 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | |
@@ -873,7 +873,7 @@ discard block |
||
873 | 873 | */ |
874 | 874 | public function get_installed_message_types() { |
875 | 875 | // EE_messages has been deprecated |
876 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
876 | + $this->_class_is_deprecated(__FUNCTION__); |
|
877 | 877 | return $this->_message_resource_manager->installed_message_types(); |
878 | 878 | } |
879 | 879 | |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | */ |
886 | 886 | public function get_installed_messengers() { |
887 | 887 | // EE_messages has been deprecated |
888 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
888 | + $this->_class_is_deprecated(__FUNCTION__); |
|
889 | 889 | return $this->_message_resource_manager->installed_messengers(); |
890 | 890 | } |
891 | 891 | |
@@ -896,10 +896,10 @@ discard block |
||
896 | 896 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
897 | 897 | * @return array |
898 | 898 | */ |
899 | - public function get_all_contexts( $slugs_only = true ) { |
|
899 | + public function get_all_contexts($slugs_only = true) { |
|
900 | 900 | // EE_messages has been deprecated |
901 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
902 | - return $this->_message_resource_manager->get_all_contexts( $slugs_only ); |
|
901 | + $this->_class_is_deprecated(__FUNCTION__); |
|
902 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is |
503 | 503 | * allowed) |
504 | 504 | * @param string $datetime_string mysql timestamp in UTC |
505 | - * @return mixed null | DateTime |
|
505 | + * @return null|DateTime null | DateTime |
|
506 | 506 | */ |
507 | 507 | public function prepare_for_set_from_db( $datetime_string ) { |
508 | 508 | //if $datetime_value is empty, and ! $this->_nullable, just use time() |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * |
620 | 620 | * @param \DateTimeZone $DateTimeZone |
621 | 621 | * @param null $time |
622 | - * @return mixed |
|
622 | + * @return string |
|
623 | 623 | */ |
624 | 624 | public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) { |
625 | 625 | $time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time(); |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * EE_Datetime_Field |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | * @param string $pretty_date_format |
119 | 119 | * @param string $pretty_time_format |
120 | 120 | */ |
121 | - public function __construct( $table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '' ){ |
|
121 | + public function __construct($table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '') { |
|
122 | 122 | |
123 | - $this->_date_format = ! empty( $date_format ) ? $date_format : get_option('date_format'); |
|
124 | - $this->_time_format = ! empty( $time_format ) ? $time_format : get_option('time_format'); |
|
125 | - $this->_pretty_date_format = ! empty( $pretty_date_format ) ? $pretty_date_format : get_option('date_format'); |
|
126 | - $this->_pretty_time_format = ! empty( $pretty_time_format ) ? $pretty_time_format : get_option('time_format'); |
|
123 | + $this->_date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
124 | + $this->_time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
125 | + $this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format'); |
|
126 | + $this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format'); |
|
127 | 127 | |
128 | - parent::__construct( $table_column, $nice_name, $nullable, $default_value ); |
|
129 | - $this->set_timezone( $timezone_string ); |
|
128 | + parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
129 | + $this->set_timezone($timezone_string); |
|
130 | 130 | |
131 | 131 | } |
132 | 132 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @return DateTimeZone |
146 | 146 | */ |
147 | 147 | public function get_UTC_DateTimeZone() { |
148 | - return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string( 'UTC' ); |
|
148 | + return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string('UTC'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @return DateTimeZone |
155 | 155 | */ |
156 | 156 | public function get_blog_DateTimeZone() { |
157 | - return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string( '' ); |
|
157 | + return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string(''); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix timestamp |
165 | 165 | * @return DateTime |
166 | 166 | */ |
167 | - public function prepare_for_set( $value_inputted_for_field_on_model_object ) { |
|
168 | - return $this->_get_date_object( $value_inputted_for_field_on_model_object ); |
|
167 | + public function prepare_for_set($value_inputted_for_field_on_model_object) { |
|
168 | + return $this->_get_date_object($value_inputted_for_field_on_model_object); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | * @param bool $pretty If we're returning the pretty formats or standard format string. |
182 | 182 | * @return string The final assembled format string. |
183 | 183 | */ |
184 | - protected function _get_date_time_output( $pretty = FALSE ) { |
|
184 | + protected function _get_date_time_output($pretty = FALSE) { |
|
185 | 185 | |
186 | - switch ( $this->_date_time_output ) { |
|
186 | + switch ($this->_date_time_output) { |
|
187 | 187 | case 'time' : |
188 | 188 | return $pretty ? $this->_pretty_time_format : $this->_time_format; |
189 | 189 | break; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | break; |
194 | 194 | |
195 | 195 | default : |
196 | - return $pretty ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format : $this->_date_format . ' ' . $this->_time_format; |
|
196 | + return $pretty ? $this->_pretty_date_format.' '.$this->_pretty_time_format : $this->_date_format.' '.$this->_time_format; |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param string $what acceptable values are 'time' or 'date'. Any other value will be set but will always result in both 'date' and 'time' being returned. |
208 | 208 | * @return void |
209 | 209 | */ |
210 | - public function set_date_time_output( $what = NULL ) { |
|
210 | + public function set_date_time_output($what = NULL) { |
|
211 | 211 | $this->_date_time_output = $what; |
212 | 212 | } |
213 | 213 | |
@@ -223,15 +223,15 @@ discard block |
||
223 | 223 | * @param string $timezone_string A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - public function set_timezone( $timezone_string ) { |
|
227 | - if( empty( $timezone_string ) && $this->_timezone_string != NULL ){ |
|
226 | + public function set_timezone($timezone_string) { |
|
227 | + if (empty($timezone_string) && $this->_timezone_string != NULL) { |
|
228 | 228 | // leave the timezone AS-IS if we already have one and |
229 | 229 | // the function arg didn't provide one |
230 | 230 | return; |
231 | 231 | } |
232 | - $timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ); |
|
233 | - $this->_timezone_string = ! empty( $timezone_string ) ? $timezone_string : 'UTC'; |
|
234 | - $this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string( $this->_timezone_string ); |
|
232 | + $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
233 | + $this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC'; |
|
234 | + $this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string($this->_timezone_string); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | * @param string $timezone_string |
244 | 244 | * @return \DateTimeZone |
245 | 245 | */ |
246 | - protected function _create_timezone_object_from_timezone_string( $timezone_string = '' ) { |
|
247 | - return new DateTimeZone( EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ) ); |
|
246 | + protected function _create_timezone_object_from_timezone_string($timezone_string = '') { |
|
247 | + return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string)); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @param bool $pretty Whether to set pretty format or not. |
270 | 270 | * @return void |
271 | 271 | */ |
272 | - public function set_date_format( $format, $pretty = false ) { |
|
273 | - if ( $pretty ) { |
|
272 | + public function set_date_format($format, $pretty = false) { |
|
273 | + if ($pretty) { |
|
274 | 274 | $this->_pretty_date_format = $format; |
275 | 275 | } else { |
276 | 276 | $this->_date_format = $format; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * @param bool $pretty Whether to get pretty format or not. |
286 | 286 | * @return string |
287 | 287 | */ |
288 | - public function get_date_format( $pretty = false ) { |
|
288 | + public function get_date_format($pretty = false) { |
|
289 | 289 | return $pretty ? $this->_pretty_date_format : $this->_date_format; |
290 | 290 | } |
291 | 291 | |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | * @param bool $pretty Whether to set pretty format or not. |
301 | 301 | * @return void |
302 | 302 | */ |
303 | - public function set_time_format( $format, $pretty = false ) { |
|
304 | - if ( $pretty ) { |
|
303 | + public function set_time_format($format, $pretty = false) { |
|
304 | + if ($pretty) { |
|
305 | 305 | $this->_pretty_time_format = $format; |
306 | 306 | } else { |
307 | 307 | $this->_time_format = $format; |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @param bool $pretty Whether to get pretty format or not. |
317 | 317 | * @return string |
318 | 318 | */ |
319 | - public function get_time_format( $pretty = false ) { |
|
319 | + public function get_time_format($pretty = false) { |
|
320 | 320 | return $pretty ? $this->_pretty_time_format : $this->_time_format; |
321 | 321 | } |
322 | 322 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function) |
332 | 332 | * @return void |
333 | 333 | */ |
334 | - public function set_pretty_date_format( $format ) { |
|
334 | + public function set_pretty_date_format($format) { |
|
335 | 335 | $this->_pretty_date_format = $format; |
336 | 336 | } |
337 | 337 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function) |
349 | 349 | * @return void |
350 | 350 | */ |
351 | - public function set_pretty_time_format( $format ) { |
|
351 | + public function set_pretty_time_format($format) { |
|
352 | 352 | $this->_pretty_time_format = $format; |
353 | 353 | } |
354 | 354 | |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | * @param DateTime $current current DateTime object for the datetime field |
361 | 361 | * @return DateTime |
362 | 362 | */ |
363 | - public function prepare_for_set_with_new_time( $time_to_set_string, DateTime $current ){ |
|
363 | + public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current) { |
|
364 | 364 | //if $time_to_set_string is datetime object, then let's use it to set the parse array. Otherwise parse the string. |
365 | - if ( $time_to_set_string instanceof DateTime ) { |
|
365 | + if ($time_to_set_string instanceof DateTime) { |
|
366 | 366 | $parsed = array( |
367 | 367 | 'hour' => $time_to_set_string->format('H'), |
368 | 368 | 'minute' => $time_to_set_string->format('i'), |
@@ -370,12 +370,12 @@ discard block |
||
370 | 370 | ); |
371 | 371 | } else { |
372 | 372 | //parse incoming string |
373 | - $parsed = date_parse_from_format( $this->_time_format, $time_to_set_string ); |
|
373 | + $parsed = date_parse_from_format($this->_time_format, $time_to_set_string); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | //make sure $current is in the correct timezone. |
377 | - $current->setTimezone( $this->_DateTimeZone ); |
|
378 | - return $current->setTime( $parsed['hour'], $parsed['minute'], $parsed['second'] ); |
|
377 | + $current->setTimezone($this->_DateTimeZone); |
|
378 | + return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | |
@@ -386,9 +386,9 @@ discard block |
||
386 | 386 | * @param DateTime $current current DateTime object for the datetime field |
387 | 387 | * @return DateTime |
388 | 388 | */ |
389 | - public function prepare_for_set_with_new_date( $date_to_set_string, DateTime $current ){ |
|
389 | + public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current) { |
|
390 | 390 | //if $time_to_set_string is datetime object, then let's use it to set the parse array. Otherwise parse the string. |
391 | - if ( $date_to_set_string instanceof DateTime ) { |
|
391 | + if ($date_to_set_string instanceof DateTime) { |
|
392 | 392 | $parsed = array( |
393 | 393 | 'year' => $date_to_set_string->format('Y'), |
394 | 394 | 'month' => $date_to_set_string->format('m'), |
@@ -396,12 +396,12 @@ discard block |
||
396 | 396 | ); |
397 | 397 | } else { |
398 | 398 | //parse incoming string |
399 | - $parsed = date_parse_from_format( $this->_date_format, $date_to_set_string ); |
|
399 | + $parsed = date_parse_from_format($this->_date_format, $date_to_set_string); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | //make sure $current is in the correct timezone |
403 | - $current->setTimezone( $this->_DateTimeZone ); |
|
404 | - return $current->setDate( $parsed['year'], $parsed['month'], $parsed['day'] ); |
|
403 | + $current->setTimezone($this->_DateTimeZone); |
|
404 | + return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | * @param DateTime $DateTime |
414 | 414 | * @return string formatted date time for given timezone |
415 | 415 | */ |
416 | - public function prepare_for_get( $DateTime ) { |
|
417 | - return $this->_prepare_for_display( $DateTime ); |
|
416 | + public function prepare_for_get($DateTime) { |
|
417 | + return $this->_prepare_for_display($DateTime); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | * @param null $schema |
430 | 430 | * @return string |
431 | 431 | */ |
432 | - public function prepare_for_pretty_echoing( $DateTime, $schema = null ) { |
|
433 | - return $this->_prepare_for_display( $DateTime, $schema ? $schema : true ); |
|
432 | + public function prepare_for_pretty_echoing($DateTime, $schema = null) { |
|
433 | + return $this->_prepare_for_display($DateTime, $schema ? $schema : true); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | |
@@ -444,36 +444,36 @@ discard block |
||
444 | 444 | * @return string |
445 | 445 | * @throws \EE_Error |
446 | 446 | */ |
447 | - protected function _prepare_for_display( $DateTime, $schema = false ) { |
|
448 | - if ( ! $DateTime instanceof DateTime ) { |
|
449 | - if ( $this->_nullable ) { |
|
447 | + protected function _prepare_for_display($DateTime, $schema = false) { |
|
448 | + if ( ! $DateTime instanceof DateTime) { |
|
449 | + if ($this->_nullable) { |
|
450 | 450 | return ''; |
451 | 451 | } else { |
452 | - if ( WP_DEBUG ) { |
|
453 | - throw new EE_Error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso' ), $this->_nicename ) ); |
|
452 | + if (WP_DEBUG) { |
|
453 | + throw new EE_Error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso'), $this->_nicename)); |
|
454 | 454 | } else { |
455 | - $DateTime = new DateTime( "now" ); |
|
456 | - EE_Error::add_error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable. When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso' ), $this->_nicename ) ); |
|
455 | + $DateTime = new DateTime("now"); |
|
456 | + EE_Error::add_error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable. When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso'), $this->_nicename)); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | } |
460 | - $format_string = $this->_get_date_time_output( $schema ); |
|
460 | + $format_string = $this->_get_date_time_output($schema); |
|
461 | 461 | //make sure datetime_value is in the correct timezone (in case that's been updated). |
462 | - $DateTime->setTimezone( $this->_DateTimeZone ); |
|
463 | - if ( $schema ) { |
|
464 | - if( $this->_display_timezone() ) { |
|
462 | + $DateTime->setTimezone($this->_DateTimeZone); |
|
463 | + if ($schema) { |
|
464 | + if ($this->_display_timezone()) { |
|
465 | 465 | //must be explicit because schema could equal true. |
466 | - if( $schema === 'no_html' ){ |
|
467 | - $timezone_string = ' (' . $DateTime->format( 'T' ) . ')'; |
|
468 | - }else{ |
|
469 | - $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format( 'T' ) . ')</span>'; |
|
466 | + if ($schema === 'no_html') { |
|
467 | + $timezone_string = ' ('.$DateTime->format('T').')'; |
|
468 | + } else { |
|
469 | + $timezone_string = ' <span class="ee_dtt_timezone_string">('.$DateTime->format('T').')</span>'; |
|
470 | 470 | } |
471 | 471 | } else { |
472 | 472 | $timezone_string = ''; |
473 | 473 | } |
474 | - return $DateTime->format( $format_string ) . $timezone_string; |
|
474 | + return $DateTime->format($format_string).$timezone_string; |
|
475 | 475 | } else { |
476 | - return $DateTime->format( $format_string ); |
|
476 | + return $DateTime->format($format_string); |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
@@ -487,18 +487,18 @@ discard block |
||
487 | 487 | * @return string mysql timestamp in UTC |
488 | 488 | * @throws \EE_Error |
489 | 489 | */ |
490 | - public function prepare_for_use_in_db( $datetime_value ) { |
|
490 | + public function prepare_for_use_in_db($datetime_value) { |
|
491 | 491 | //we allow an empty value or DateTime object, but nothing else. |
492 | - if ( ! empty( $datetime_value ) && ! $datetime_value instanceof DateTime ) { |
|
493 | - throw new EE_Error( __('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso' ) ); |
|
492 | + if ( ! empty($datetime_value) && ! $datetime_value instanceof DateTime) { |
|
493 | + throw new EE_Error(__('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso')); |
|
494 | 494 | } |
495 | 495 | |
496 | - if ( $datetime_value instanceof DateTime ) { |
|
497 | - return $datetime_value->setTimezone( $this->get_UTC_DateTimeZone() )->format( EE_Datetime_Field::mysql_timestamp_format ); |
|
496 | + if ($datetime_value instanceof DateTime) { |
|
497 | + return $datetime_value->setTimezone($this->get_UTC_DateTimeZone())->format(EE_Datetime_Field::mysql_timestamp_format); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | // if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true |
501 | - return ! $this->_nullable && empty( $datetime_value ) ? current_time( 'mysql', true ) : null; |
|
501 | + return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null; |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | |
@@ -511,20 +511,20 @@ discard block |
||
511 | 511 | * @param string $datetime_string mysql timestamp in UTC |
512 | 512 | * @return mixed null | DateTime |
513 | 513 | */ |
514 | - public function prepare_for_set_from_db( $datetime_string ) { |
|
514 | + public function prepare_for_set_from_db($datetime_string) { |
|
515 | 515 | //if $datetime_value is empty, and ! $this->_nullable, just use time() |
516 | - if ( empty( $datetime_string) && $this->_nullable ) { |
|
516 | + if (empty($datetime_string) && $this->_nullable) { |
|
517 | 517 | return null; |
518 | 518 | } |
519 | 519 | // datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating |
520 | - $DateTime = empty( $datetime_string ) ? new DateTime( 'now', $this->get_UTC_DateTimeZone() ) : DateTime::createFromFormat( EE_Datetime_Field::mysql_timestamp_format, $datetime_string, $this->get_UTC_DateTimeZone() ); |
|
520 | + $DateTime = empty($datetime_string) ? new DateTime('now', $this->get_UTC_DateTimeZone()) : DateTime::createFromFormat(EE_Datetime_Field::mysql_timestamp_format, $datetime_string, $this->get_UTC_DateTimeZone()); |
|
521 | 521 | |
522 | - if ( ! $DateTime instanceof DateTime ) { |
|
522 | + if ( ! $DateTime instanceof DateTime) { |
|
523 | 523 | //if still no datetime object, then let's just use now |
524 | - $DateTime = new DateTime( 'now', $this->get_UTC_DateTimeZone() ); |
|
524 | + $DateTime = new DateTime('now', $this->get_UTC_DateTimeZone()); |
|
525 | 525 | } |
526 | 526 | // THEN apply the field's set DateTimeZone |
527 | - $DateTime->setTimezone( $this->_DateTimeZone ); |
|
527 | + $DateTime->setTimezone($this->_DateTimeZone); |
|
528 | 528 | return $DateTime; |
529 | 529 | } |
530 | 530 | |
@@ -541,15 +541,15 @@ discard block |
||
541 | 541 | protected function _display_timezone() { |
542 | 542 | |
543 | 543 | // first let's do a comparison of timezone strings. If they match then we can get out without any further calculations |
544 | - $blog_string = get_option( 'timezone_string' ); |
|
545 | - if ( $blog_string == $this->_timezone_string ) { |
|
544 | + $blog_string = get_option('timezone_string'); |
|
545 | + if ($blog_string == $this->_timezone_string) { |
|
546 | 546 | return FALSE; |
547 | 547 | } |
548 | 548 | // now we need to calc the offset for the timezone string so we can compare with the blog offset. |
549 | - $this_offset = $this->get_timezone_offset( $this->_DateTimeZone ); |
|
550 | - $blog_offset = $this->get_timezone_offset( $this->get_blog_DateTimeZone() ); |
|
549 | + $this_offset = $this->get_timezone_offset($this->_DateTimeZone); |
|
550 | + $blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone()); |
|
551 | 551 | // now compare |
552 | - if ( $blog_offset === $this_offset ) { |
|
552 | + if ($blog_offset === $this_offset) { |
|
553 | 553 | return FALSE; |
554 | 554 | } |
555 | 555 | return TRUE; |
@@ -567,24 +567,24 @@ discard block |
||
567 | 567 | * |
568 | 568 | * @return DateTime |
569 | 569 | */ |
570 | - protected function _get_date_object( $date_string ) { |
|
570 | + protected function _get_date_object($date_string) { |
|
571 | 571 | //first if this is an empty date_string and nullable is allowed, just return null. |
572 | - if ( $this->_nullable && empty( $date_string ) ) { |
|
572 | + if ($this->_nullable && empty($date_string)) { |
|
573 | 573 | return null; |
574 | 574 | } |
575 | 575 | |
576 | 576 | // if incoming date |
577 | - if ( $date_string instanceof DateTime ) { |
|
578 | - $date_string->setTimezone( $this->_DateTimeZone ); |
|
577 | + if ($date_string instanceof DateTime) { |
|
578 | + $date_string->setTimezone($this->_DateTimeZone); |
|
579 | 579 | return $date_string; |
580 | 580 | } |
581 | 581 | // if empty date_string and made it here. |
582 | 582 | // Return a datetime object for now in the given timezone. |
583 | - if ( empty( $date_string ) ) { |
|
584 | - return new DateTime( "now", $this->_DateTimeZone ); |
|
583 | + if (empty($date_string)) { |
|
584 | + return new DateTime("now", $this->_DateTimeZone); |
|
585 | 585 | } |
586 | 586 | // if $date_string is matches something that looks like a Unix timestamp let's just use it. |
587 | - if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $date_string ) ) { |
|
587 | + if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) { |
|
588 | 588 | try { |
589 | 589 | /** |
590 | 590 | * This is operating under the assumption that the incoming Unix timestamp is |
@@ -592,29 +592,29 @@ discard block |
||
592 | 592 | * current_time('timestamp'); |
593 | 593 | * |
594 | 594 | */ |
595 | - $DateTime = new DateTime( "now", $this->_DateTimeZone ); |
|
596 | - return $DateTime->setTimestamp( $date_string ); |
|
597 | - } catch ( Exception $e ) { |
|
595 | + $DateTime = new DateTime("now", $this->_DateTimeZone); |
|
596 | + return $DateTime->setTimestamp($date_string); |
|
597 | + } catch (Exception $e) { |
|
598 | 598 | // should be rare, but if things got fooled then let's just continue |
599 | 599 | } |
600 | 600 | } |
601 | 601 | //not a unix timestamp. So we will use the set format on this object and set timezone to |
602 | 602 | //create the DateTime object. |
603 | - $format = $this->_date_format . ' ' . $this->_time_format; |
|
603 | + $format = $this->_date_format.' '.$this->_time_format; |
|
604 | 604 | try { |
605 | - $DateTime = DateTime::createFromFormat( $format, $date_string, $this->_DateTimeZone ); |
|
606 | - if ( ! $DateTime instanceof DateTime ) { |
|
605 | + $DateTime = DateTime::createFromFormat($format, $date_string, $this->_DateTimeZone); |
|
606 | + if ( ! $DateTime instanceof DateTime) { |
|
607 | 607 | throw new EE_Error( |
608 | 608 | sprintf( |
609 | - __( '"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso' ), |
|
609 | + __('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'), |
|
610 | 610 | $date_string, |
611 | 611 | $format |
612 | 612 | ) |
613 | 613 | ); |
614 | 614 | } |
615 | - } catch ( Exception $e ) { |
|
615 | + } catch (Exception $e) { |
|
616 | 616 | // if we made it here then likely then something went really wrong. Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone. |
617 | - $DateTime = new DateTime( "now", $this->_DateTimeZone ); |
|
617 | + $DateTime = new DateTime("now", $this->_DateTimeZone); |
|
618 | 618 | } |
619 | 619 | return $DateTime; |
620 | 620 | } |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | * @param null $time |
629 | 629 | * @return mixed |
630 | 630 | */ |
631 | - public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) { |
|
632 | - $time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time(); |
|
633 | - $transitions = $DateTimeZone->getTransitions( $time ); |
|
631 | + public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null) { |
|
632 | + $time = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time(); |
|
633 | + $transitions = $DateTimeZone->getTransitions($time); |
|
634 | 634 | return $transitions[0]['offset']; |
635 | 635 | } |
636 | 636 | |
@@ -642,10 +642,10 @@ discard block |
||
642 | 642 | * @param string $timezone_string |
643 | 643 | * @return string abbreviation |
644 | 644 | */ |
645 | - public function get_timezone_abbrev( $timezone_string ) { |
|
646 | - $timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ); |
|
647 | - $dateTime = new DateTime( 'now', new DateTimeZone( $timezone_string ) ); |
|
648 | - return $dateTime->format( 'T' ); |
|
645 | + public function get_timezone_abbrev($timezone_string) { |
|
646 | + $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
647 | + $dateTime = new DateTime('now', new DateTimeZone($timezone_string)); |
|
648 | + return $dateTime->format('T'); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | /** |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * @return |
654 | 654 | */ |
655 | 655 | public function get_default_value() { |
656 | - if( $this->_default_value === EE_Datetime_Field::now ) { |
|
656 | + if ($this->_default_value === EE_Datetime_Field::now) { |
|
657 | 657 | return time(); |
658 | 658 | } else { |
659 | 659 | return parent::get_default_value(); |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\CPTs; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | \WP_Query $WP_Query, |
81 | 81 | \EE_Request_Handler $request |
82 | 82 | ) { |
83 | - $this->setRequest( $request ); |
|
84 | - $this->setWpQuery( $WP_Query ); |
|
85 | - $this->setPostType( $post_type ); |
|
86 | - $this->setCptDetails( $cpt_details ); |
|
83 | + $this->setRequest($request); |
|
84 | + $this->setWpQuery($WP_Query); |
|
85 | + $this->setPostType($post_type); |
|
86 | + $this->setCptDetails($cpt_details); |
|
87 | 87 | $this->init(); |
88 | 88 | } |
89 | 89 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * @param string $post_type |
103 | 103 | */ |
104 | - protected function setPostType( $post_type ) { |
|
104 | + protected function setPostType($post_type) { |
|
105 | 105 | $this->post_type = $post_type; |
106 | 106 | } |
107 | 107 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * @param array $cpt_details |
121 | 121 | */ |
122 | - protected function setCptDetails( $cpt_details ) { |
|
122 | + protected function setCptDetails($cpt_details) { |
|
123 | 123 | $this->cpt_details = $cpt_details; |
124 | 124 | } |
125 | 125 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * @param \EE_Table_Base[] $model_tables |
139 | 139 | */ |
140 | - protected function setModelTables( $model_tables ) { |
|
140 | + protected function setModelTables($model_tables) { |
|
141 | 141 | $this->model_tables = $model_tables; |
142 | 142 | } |
143 | 143 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return array |
148 | 148 | */ |
149 | 149 | public function taxonomies() { |
150 | - if ( empty( $this->taxonomies ) ) { |
|
150 | + if (empty($this->taxonomies)) { |
|
151 | 151 | $this->initializeTaxonomies(); |
152 | 152 | } |
153 | 153 | return $this->taxonomies; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | /** |
159 | 159 | * @param array $taxonomies |
160 | 160 | */ |
161 | - protected function setTaxonomies( array $taxonomies ) { |
|
161 | + protected function setTaxonomies(array $taxonomies) { |
|
162 | 162 | $this->taxonomies = $taxonomies; |
163 | 163 | } |
164 | 164 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | /** |
177 | 177 | * @param \EE_Secondary_Table $meta_table |
178 | 178 | */ |
179 | - public function setMetaTable( \EE_Secondary_Table $meta_table ) { |
|
179 | + public function setMetaTable(\EE_Secondary_Table $meta_table) { |
|
180 | 180 | $this->meta_table = $meta_table; |
181 | 181 | } |
182 | 182 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | /** |
195 | 195 | * @param \EEM_Base $CPT_model |
196 | 196 | */ |
197 | - protected function setModel( \EEM_Base $CPT_model ) { |
|
197 | + protected function setModel(\EEM_Base $CPT_model) { |
|
198 | 198 | $this->model = $CPT_model; |
199 | 199 | } |
200 | 200 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | /** |
213 | 213 | * @param \EE_Request_Handler $request |
214 | 214 | */ |
215 | - protected function setRequest( \EE_Request_Handler $request ) { |
|
215 | + protected function setRequest(\EE_Request_Handler $request) { |
|
216 | 216 | $this->request = $request; |
217 | 217 | } |
218 | 218 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | /** |
231 | 231 | * @param \WP_Query $wp_query |
232 | 232 | */ |
233 | - public function setWpQuery( \WP_Query $wp_query ) { |
|
233 | + public function setWpQuery(\WP_Query $wp_query) { |
|
234 | 234 | $this->wp_query = $wp_query; |
235 | 235 | } |
236 | 236 | |
@@ -245,22 +245,22 @@ discard block |
||
245 | 245 | protected function initializeTaxonomies() { |
246 | 246 | // check if taxonomies have already been set and that this CPT has taxonomies registered for it |
247 | 247 | if ( |
248 | - empty( $this->taxonomies ) |
|
249 | - && isset( $this->cpt_details['args'], $this->cpt_details['args']['taxonomies'] ) |
|
248 | + empty($this->taxonomies) |
|
249 | + && isset($this->cpt_details['args'], $this->cpt_details['args']['taxonomies']) |
|
250 | 250 | ) { |
251 | 251 | // if so then grab them, but we want the taxonomy name as the key |
252 | - $taxonomies = array_flip( $this->cpt_details['args']['taxonomies'] ); |
|
252 | + $taxonomies = array_flip($this->cpt_details['args']['taxonomies']); |
|
253 | 253 | // then grab the list of ALL taxonomies |
254 | 254 | $all_taxonomies = \EE_Register_CPTs::get_taxonomies(); |
255 | - foreach ( $taxonomies as $taxonomy => &$details ) { |
|
255 | + foreach ($taxonomies as $taxonomy => &$details) { |
|
256 | 256 | // add details to our taxonomies if they exist |
257 | - $details = isset( $all_taxonomies[ $taxonomy ] ) |
|
258 | - ? $all_taxonomies[ $taxonomy ] |
|
257 | + $details = isset($all_taxonomies[$taxonomy]) |
|
258 | + ? $all_taxonomies[$taxonomy] |
|
259 | 259 | : array(); |
260 | 260 | } |
261 | 261 | // ALWAYS unset() variables that were passed by reference |
262 | - unset( $details ); |
|
263 | - $this->setTaxonomies( $taxonomies ); |
|
262 | + unset($details); |
|
263 | + $this->setTaxonomies($taxonomies); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | $this->setAdditionalCptDetails(); |
271 | 271 | $this->setRequestVarsIfCpt(); |
272 | 272 | // convert post_type to model name |
273 | - $model_name = str_replace( 'EE_', '', $this->cpt_details['class_name'] ); |
|
273 | + $model_name = str_replace('EE_', '', $this->cpt_details['class_name']); |
|
274 | 274 | // load all tables related to CPT |
275 | - $this->setupModelsAndTables( $model_name ); |
|
275 | + $this->setupModelsAndTables($model_name); |
|
276 | 276 | // load and instantiate CPT_*_Strategy |
277 | - $CPT_Strategy = $this->cptStrategyClass( $model_name ); |
|
277 | + $CPT_Strategy = $this->cptStrategyClass($model_name); |
|
278 | 278 | // !!!!!!!!!! IMPORTANT !!!!!!!!!!!! |
279 | 279 | // here's the list of available filters in the WP_Query object |
280 | 280 | // 'posts_where_paged' |
@@ -285,17 +285,17 @@ discard block |
||
285 | 285 | // 'post_limits' |
286 | 286 | // 'posts_fields' |
287 | 287 | // 'posts_join' |
288 | - add_filter( 'posts_fields', array( $this, 'postsFields' ) ); |
|
289 | - add_filter( 'posts_join', array( $this, 'postsJoin' ) ); |
|
288 | + add_filter('posts_fields', array($this, 'postsFields')); |
|
289 | + add_filter('posts_join', array($this, 'postsJoin')); |
|
290 | 290 | add_filter( |
291 | - 'get_' . $this->post_type . '_metadata', |
|
292 | - array( $CPT_Strategy, 'get_EE_post_type_metadata' ), |
|
291 | + 'get_'.$this->post_type.'_metadata', |
|
292 | + array($CPT_Strategy, 'get_EE_post_type_metadata'), |
|
293 | 293 | 1, |
294 | 294 | 4 |
295 | 295 | ); |
296 | - add_filter( 'the_posts', array( $this, 'thePosts' ), 1, 1 ); |
|
297 | - if ( $this->wp_query->is_main_query() ) { |
|
298 | - add_filter( 'get_edit_post_link', array( $this, 'getEditPostLink' ), 10, 2 ); |
|
296 | + add_filter('the_posts', array($this, 'thePosts'), 1, 1); |
|
297 | + if ($this->wp_query->is_main_query()) { |
|
298 | + add_filter('get_edit_post_link', array($this, 'getEditPostLink'), 10, 2); |
|
299 | 299 | $this->addTemplateFilters(); |
300 | 300 | } |
301 | 301 | } |
@@ -312,18 +312,18 @@ discard block |
||
312 | 312 | // the post or category or term that is triggering EE |
313 | 313 | $this->cpt_details['espresso_page'] = $this->request->is_espresso_page(); |
314 | 314 | // requested post name |
315 | - $this->cpt_details['post_name'] = $this->request->get( 'post_name' ); |
|
315 | + $this->cpt_details['post_name'] = $this->request->get('post_name'); |
|
316 | 316 | // add support for viewing 'private', 'draft', or 'pending' posts |
317 | 317 | if ( |
318 | - isset( $this->wp_query->query_vars['p'] ) |
|
318 | + isset($this->wp_query->query_vars['p']) |
|
319 | 319 | && $this->wp_query->query_vars['p'] !== 0 |
320 | 320 | && is_user_logged_in() |
321 | - && current_user_can( 'edit_post', $this->wp_query->query_vars['p'] ) |
|
321 | + && current_user_can('edit_post', $this->wp_query->query_vars['p']) |
|
322 | 322 | ) { |
323 | 323 | // we can just inject directly into the WP_Query object |
324 | - $this->wp_query->query['post_status'] = array( 'publish', 'private', 'draft', 'pending' ); |
|
324 | + $this->wp_query->query['post_status'] = array('publish', 'private', 'draft', 'pending'); |
|
325 | 325 | // now set the main 'ee' request var so that the appropriate module can load the appropriate template(s) |
326 | - $this->request->set( 'ee', $this->cpt_details['singular_slug'] ); |
|
326 | + $this->request->set('ee', $this->cpt_details['singular_slug']); |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | */ |
341 | 341 | public function setRequestVarsIfCpt() { |
342 | 342 | // check if ee action var has been set |
343 | - if ( ! $this->request->is_set( 'ee' ) ) { |
|
343 | + if ( ! $this->request->is_set('ee')) { |
|
344 | 344 | // check that route exists for CPT archive slug |
345 | - if ( is_archive() && \EE_Config::get_route( $this->cpt_details['plural_slug'] ) ) { |
|
345 | + if (is_archive() && \EE_Config::get_route($this->cpt_details['plural_slug'])) { |
|
346 | 346 | // ie: set "ee" to "events" |
347 | - $this->request->set( 'ee', $this->cpt_details['plural_slug'] ); |
|
347 | + $this->request->set('ee', $this->cpt_details['plural_slug']); |
|
348 | 348 | // or does it match a single page CPT like /event/ |
349 | - } else if ( is_single() && \EE_Config::get_route( $this->cpt_details['singular_slug'] ) ) { |
|
349 | + } else if (is_single() && \EE_Config::get_route($this->cpt_details['singular_slug'])) { |
|
350 | 350 | // ie: set "ee" to "event" |
351 | - $this->request->set( 'ee', $this->cpt_details['singular_slug'] ); |
|
351 | + $this->request->set('ee', $this->cpt_details['singular_slug']); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | } |
@@ -362,11 +362,11 @@ discard block |
||
362 | 362 | * @param string $model_name |
363 | 363 | * @throws \EE_Error |
364 | 364 | */ |
365 | - protected function setupModelsAndTables( $model_name ) { |
|
365 | + protected function setupModelsAndTables($model_name) { |
|
366 | 366 | // get CPT table data via CPT Model |
367 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
368 | - if ( ! $model instanceof \EEM_Base ) { |
|
369 | - throw new \EE_Error ( |
|
367 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
368 | + if ( ! $model instanceof \EEM_Base) { |
|
369 | + throw new \EE_Error( |
|
370 | 370 | sprintf( |
371 | 371 | __( |
372 | 372 | 'The "%1$s" model could not be loaded.', |
@@ -376,14 +376,14 @@ discard block |
||
376 | 376 | ) |
377 | 377 | ); |
378 | 378 | } |
379 | - $this->setModel( $model ); |
|
380 | - $this->setModelTables( $this->model->get_tables() ); |
|
379 | + $this->setModel($model); |
|
380 | + $this->setModelTables($this->model->get_tables()); |
|
381 | 381 | // is there a Meta Table for this CPT? |
382 | 382 | if ( |
383 | - isset( $this->cpt_details['tables'][ $model_name . '_Meta' ] ) |
|
384 | - && $this->cpt_details['tables'][ $model_name . '_Meta' ] instanceof \EE_Secondary_Table |
|
383 | + isset($this->cpt_details['tables'][$model_name.'_Meta']) |
|
384 | + && $this->cpt_details['tables'][$model_name.'_Meta'] instanceof \EE_Secondary_Table |
|
385 | 385 | ) { |
386 | - $this->setMetaTable( $this->cpt_details['tables'][ $model_name . '_Meta' ] ); |
|
386 | + $this->setMetaTable($this->cpt_details['tables'][$model_name.'_Meta']); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
@@ -396,18 +396,18 @@ discard block |
||
396 | 396 | * @param string $model_name |
397 | 397 | * @return string |
398 | 398 | */ |
399 | - protected function cptStrategyClass( $model_name ) { |
|
399 | + protected function cptStrategyClass($model_name) { |
|
400 | 400 | // creates classname like: CPT_Event_Strategy |
401 | - $CPT_Strategy_class_name = 'CPT_' . $model_name . '_Strategy'; |
|
401 | + $CPT_Strategy_class_name = 'CPT_'.$model_name.'_Strategy'; |
|
402 | 402 | // load and instantiate |
403 | 403 | $CPT_Strategy = \EE_Registry::instance()->load_core( |
404 | 404 | $CPT_Strategy_class_name, |
405 | - array( 'WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details ) |
|
405 | + array('WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details) |
|
406 | 406 | ); |
407 | - if ( $CPT_Strategy === null ) { |
|
407 | + if ($CPT_Strategy === null) { |
|
408 | 408 | $CPT_Strategy = \EE_Registry::instance()->load_core( |
409 | 409 | 'CPT_Default_Strategy', |
410 | - array( 'WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details ) |
|
410 | + array('WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details) |
|
411 | 411 | ); |
412 | 412 | } |
413 | 413 | return $CPT_Strategy; |
@@ -422,13 +422,13 @@ discard block |
||
422 | 422 | * @param $SQL |
423 | 423 | * @return string |
424 | 424 | */ |
425 | - public function postsFields( $SQL ) { |
|
425 | + public function postsFields($SQL) { |
|
426 | 426 | // does this CPT have a meta table ? |
427 | - if ( $this->meta_table instanceof \EE_Secondary_Table ) { |
|
427 | + if ($this->meta_table instanceof \EE_Secondary_Table) { |
|
428 | 428 | // adds something like ", wp_esp_event_meta.* " to WP Query SELECT statement |
429 | - $SQL .= ', ' . $this->meta_table->get_table_name() . '.* '; |
|
429 | + $SQL .= ', '.$this->meta_table->get_table_name().'.* '; |
|
430 | 430 | } |
431 | - remove_filter( 'posts_fields', array( $this, 'postsFields' ) ); |
|
431 | + remove_filter('posts_fields', array($this, 'postsFields')); |
|
432 | 432 | return $SQL; |
433 | 433 | } |
434 | 434 | |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | * @param $SQL |
442 | 442 | * @return string |
443 | 443 | */ |
444 | - public function postsJoin( $SQL ) { |
|
444 | + public function postsJoin($SQL) { |
|
445 | 445 | // does this CPT have a meta table ? |
446 | - if ( $this->meta_table instanceof \EE_Secondary_Table ) { |
|
446 | + if ($this->meta_table instanceof \EE_Secondary_Table) { |
|
447 | 447 | global $wpdb; |
448 | 448 | // adds something like " LEFT JOIN wp_esp_event_meta ON ( wp_esp_event_meta.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement |
449 | 449 | $SQL .= ' LEFT JOIN ' |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | . $wpdb->posts |
457 | 457 | . '.ID ) '; |
458 | 458 | } |
459 | - remove_filter( 'posts_join', array( $this, 'postsJoin' ) ); |
|
459 | + remove_filter('posts_join', array($this, 'postsJoin')); |
|
460 | 460 | return $SQL; |
461 | 461 | } |
462 | 462 | |
@@ -469,17 +469,17 @@ discard block |
||
469 | 469 | * @param \WP_Post[] $posts |
470 | 470 | * @return \WP_Post[] |
471 | 471 | */ |
472 | - public function thePosts( $posts ) { |
|
472 | + public function thePosts($posts) { |
|
473 | 473 | $CPT_class = $this->cpt_details['class_name']; |
474 | 474 | // loop thru posts |
475 | - if ( is_array( $posts ) && $this->model instanceof \EEM_CPT_Base ) { |
|
476 | - foreach ( $posts as $key => $post ) { |
|
477 | - if ( $post->post_type === $this->post_type ) { |
|
478 | - $post->{$CPT_class} = $this->model->instantiate_class_from_post_object( $post ); |
|
475 | + if (is_array($posts) && $this->model instanceof \EEM_CPT_Base) { |
|
476 | + foreach ($posts as $key => $post) { |
|
477 | + if ($post->post_type === $this->post_type) { |
|
478 | + $post->{$CPT_class} = $this->model->instantiate_class_from_post_object($post); |
|
479 | 479 | } |
480 | 480 | } |
481 | 481 | } |
482 | - remove_filter( 'the_posts', array( $this, 'thePosts' ), 1 ); |
|
482 | + remove_filter('the_posts', array($this, 'thePosts'), 1); |
|
483 | 483 | return $posts; |
484 | 484 | } |
485 | 485 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | * @param $ID |
491 | 491 | * @return string |
492 | 492 | */ |
493 | - public function getEditPostLink( $url, $ID ) { |
|
493 | + public function getEditPostLink($url, $ID) { |
|
494 | 494 | // need to make sure we only edit links if our cpt |
495 | 495 | global $post; |
496 | 496 | //notice if the cpt is registered with `show_ee_ui` set to false, we take that to mean that the WordPress core ui |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | ! $post instanceof \WP_Post |
500 | 500 | || $post->post_type !== $this->post_type |
501 | 501 | || ( |
502 | - isset( $this->cpt_details['args']['show_ee_ui'] ) |
|
502 | + isset($this->cpt_details['args']['show_ee_ui']) |
|
503 | 503 | && ! $this->cpt_details['args']['show_ee_ui'] |
504 | 504 | ) |
505 | 505 | ) { |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | //k made it here so all is good. |
509 | 509 | return wp_nonce_url( |
510 | 510 | add_query_arg( |
511 | - array( 'page' => $this->post_type, 'post' => $ID, 'action' => 'edit' ), |
|
512 | - admin_url( 'admin.php' ) |
|
511 | + array('page' => $this->post_type, 'post' => $ID, 'action' => 'edit'), |
|
512 | + admin_url('admin.php') |
|
513 | 513 | ), |
514 | 514 | 'edit', |
515 | 515 | 'edit_nonce' |
@@ -526,9 +526,9 @@ discard block |
||
526 | 526 | */ |
527 | 527 | public function addTemplateFilters() { |
528 | 528 | // if requested cpt supports page_templates and it's the main query |
529 | - if ( ! empty( $this->cpt_details['args']['page_templates'] ) && $this->wp_query->is_main_query() ) { |
|
529 | + if ( ! empty($this->cpt_details['args']['page_templates']) && $this->wp_query->is_main_query()) { |
|
530 | 530 | // then let's hook into the appropriate query_template hook |
531 | - add_filter( 'single_template', array( $this, 'singleCptTemplate' ) ); |
|
531 | + add_filter('single_template', array($this, 'singleCptTemplate')); |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | |
@@ -542,20 +542,20 @@ discard block |
||
542 | 542 | * @param string $current_template Existing default template path derived for this page call. |
543 | 543 | * @return string the path to the full template file. |
544 | 544 | */ |
545 | - public function singleCptTemplate( $current_template ) { |
|
545 | + public function singleCptTemplate($current_template) { |
|
546 | 546 | $object = get_queried_object(); |
547 | 547 | //does this called object HAVE a page template set that is something other than the default. |
548 | - $template = get_post_meta( $object->ID, '_wp_page_template', true ); |
|
548 | + $template = get_post_meta($object->ID, '_wp_page_template', true); |
|
549 | 549 | //exit early if default or not set or invalid path (accounts for theme changes) |
550 | 550 | if ( |
551 | 551 | $template === 'default' |
552 | - || empty( $template ) |
|
553 | - || ! is_readable( get_stylesheet_directory() . '/' . $template ) |
|
552 | + || empty($template) |
|
553 | + || ! is_readable(get_stylesheet_directory().'/'.$template) |
|
554 | 554 | ) { |
555 | 555 | return $current_template; |
556 | 556 | } |
557 | 557 | //made it here so we SHOULD be able to just locate the template and then return it. |
558 | - return locate_template( array( $template ) ); |
|
558 | + return locate_template(array($template)); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @subpackage |
12 | 12 | * @author Mike Nelson |
13 | 13 | */ |
14 | -class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base{ |
|
14 | +class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @var string $_model_name |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * And the arguments accepted by EE_Form_Input_With_Options_Base |
51 | 51 | * @throws \EE_Error |
52 | 52 | */ |
53 | - public function __construct( $input_settings = array() ) { |
|
53 | + public function __construct($input_settings = array()) { |
|
54 | 54 | //needed input settings: |
55 | 55 | //select2_args |
56 | 56 | $this->_model_name = EEH_Array::is_set( |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ); |
67 | 67 | // make sure limit and caps are always set |
68 | 68 | $query_params = array_merge( |
69 | - array( 'limit' => 10, 'caps' => EEM_Base::caps_read_admin ), |
|
69 | + array('limit' => 10, 'caps' => EEM_Base::caps_read_admin), |
|
70 | 70 | $query_params |
71 | 71 | ); |
72 | 72 | $this->_value_field_name = EEH_Array::is_set( |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $this->_display_field_name = EEH_Array::is_set( |
78 | 78 | $input_settings, |
79 | 79 | 'display_field_name', |
80 | - $model->get_a_field_of_type( 'EE_Text_Field_Base' )->get_name() |
|
80 | + $model->get_a_field_of_type('EE_Text_Field_Base')->get_name() |
|
81 | 81 | ); |
82 | 82 | $this->_extra_select_columns = EEH_Array::is_set( |
83 | 83 | $input_settings, |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | ); |
95 | 95 | //get resource endpoint |
96 | 96 | $rest_controller = new EventEspresso\core\libraries\rest_api\controllers\model\Read(); |
97 | - $rest_controller->set_requested_version( EED_Core_Rest_Api::latest_rest_api_version() ); |
|
97 | + $rest_controller->set_requested_version(EED_Core_Rest_Api::latest_rest_api_version()); |
|
98 | 98 | $default_select2_args = array( |
99 | 99 | 'ajax' => array( |
100 | 100 | 'url' => $rest_controller->get_versioned_link_to( |
101 | - EEH_Inflector::pluralize_and_lower( $this->_model_name ) |
|
101 | + EEH_Inflector::pluralize_and_lower($this->_model_name) |
|
102 | 102 | ), |
103 | 103 | 'dataType' => 'json', |
104 | 104 | 'delay' => '250', |
105 | 105 | 'data_interface' => 'EE_Select2_REST_API_Interface', |
106 | 106 | 'data_interface_args' => array( |
107 | - 'default_query_params' => (object)Model_Data_Translator::prepare_query_params_for_rest_api( |
|
107 | + 'default_query_params' => (object) Model_Data_Translator::prepare_query_params_for_rest_api( |
|
108 | 108 | $query_params, |
109 | 109 | $model |
110 | 110 | ), |
111 | 111 | 'display_field' => $this->_display_field_name, |
112 | 112 | 'value_field' => $this->_value_field_name, |
113 | - 'nonce' => wp_create_nonce( 'wp_rest' ), |
|
114 | - 'locale' => str_replace( '_', '-', strtolower( get_locale() ) ) |
|
113 | + 'nonce' => wp_create_nonce('wp_rest'), |
|
114 | + 'locale' => str_replace('_', '-', strtolower(get_locale())) |
|
115 | 115 | ), |
116 | 116 | ), |
117 | 117 | 'cache' => true, |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | ); |
120 | 120 | $select2_args = array_replace_recursive( |
121 | 121 | $default_select2_args, |
122 | - (array)EEH_Array::is_set( $input_settings, 'select2_args', array() ) |
|
122 | + (array) EEH_Array::is_set($input_settings, 'select2_args', array()) |
|
123 | 123 | ); |
124 | - $this->set_display_strategy( new EE_Select2_Display_Strategy( $select2_args ) ); |
|
125 | - parent::__construct( array(), $input_settings ); |
|
124 | + $this->set_display_strategy(new EE_Select2_Display_Strategy($select2_args)); |
|
125 | + parent::__construct(array(), $input_settings); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -140,34 +140,34 @@ discard block |
||
140 | 140 | * @return void |
141 | 141 | * @throws \EE_Error |
142 | 142 | */ |
143 | - public function _set_raw_value( $value ) { |
|
144 | - $values_for_options = (array)$value; |
|
145 | - $value_field = $this->_get_model()->field_settings_for( $this->_value_field_name ); |
|
146 | - $display_field = $this->_get_model()->field_settings_for( $this->_display_field_name ); |
|
147 | - $this->_extra_select_columns[] = $value_field->get_qualified_column() . ' AS ' . $this->_value_field_name; |
|
148 | - $this->_extra_select_columns[] = $display_field->get_qualified_column() . ' AS ' . $this->_display_field_name; |
|
143 | + public function _set_raw_value($value) { |
|
144 | + $values_for_options = (array) $value; |
|
145 | + $value_field = $this->_get_model()->field_settings_for($this->_value_field_name); |
|
146 | + $display_field = $this->_get_model()->field_settings_for($this->_display_field_name); |
|
147 | + $this->_extra_select_columns[] = $value_field->get_qualified_column().' AS '.$this->_value_field_name; |
|
148 | + $this->_extra_select_columns[] = $display_field->get_qualified_column().' AS '.$this->_display_field_name; |
|
149 | 149 | $display_values = $this->_get_model()->get_all_wpdb_results( |
150 | 150 | array( |
151 | 151 | array( |
152 | - $this->_value_field_name => array( 'IN', $values_for_options ) |
|
152 | + $this->_value_field_name => array('IN', $values_for_options) |
|
153 | 153 | ) |
154 | 154 | ), |
155 | 155 | ARRAY_A, |
156 | - implode( ',', $this->_extra_select_columns ) |
|
156 | + implode(',', $this->_extra_select_columns) |
|
157 | 157 | ); |
158 | 158 | $select_options = array(); |
159 | - if( is_array( $select_options ) ) { |
|
160 | - foreach( $display_values as $db_rows ) { |
|
161 | - $db_rows = (array)$db_rows; |
|
162 | - $select_options[ $db_rows[ $this->_value_field_name ] ] = apply_filters( |
|
159 | + if (is_array($select_options)) { |
|
160 | + foreach ($display_values as $db_rows) { |
|
161 | + $db_rows = (array) $db_rows; |
|
162 | + $select_options[$db_rows[$this->_value_field_name]] = apply_filters( |
|
163 | 163 | 'FHEE__EE_Select_Ajax_Model_Rest_Input___set_raw_value__select_option_value', |
164 | - $db_rows[ $this->_display_field_name ], |
|
164 | + $db_rows[$this->_display_field_name], |
|
165 | 165 | $db_rows |
166 | 166 | ); |
167 | 167 | } |
168 | 168 | } |
169 | - $this->set_select_options( $select_options ); |
|
170 | - parent::_set_raw_value( $value ); |
|
169 | + $this->set_select_options($select_options); |
|
170 | + parent::_set_raw_value($value); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @throws EE_Error |
177 | 177 | */ |
178 | 178 | protected function _get_model() { |
179 | - if( ! EE_Registry::instance()->is_model_name( $this->_model_name ) ) { |
|
179 | + if ( ! EE_Registry::instance()->is_model_name($this->_model_name)) { |
|
180 | 180 | throw new EE_Error( |
181 | 181 | sprintf( |
182 | 182 | __( |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | ) |
188 | 188 | ); |
189 | 189 | } else { |
190 | - return EE_Registry::instance()->load_model( $this->_model_name ); |
|
190 | + return EE_Registry::instance()->load_model($this->_model_name); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 |
@@ -66,23 +66,23 @@ discard block |
||
66 | 66 | * @param string $min_core_version |
67 | 67 | * @return string always like '4.3.0.rc.000' |
68 | 68 | */ |
69 | - protected static function _effective_version( $min_core_version ) { |
|
69 | + protected static function _effective_version($min_core_version) { |
|
70 | 70 | // versions: 4 . 3 . 1 . p . 123 |
71 | 71 | // offsets: 0 . 1 . 2 . 3 . 4 |
72 | - $version_parts = explode( '.', $min_core_version ); |
|
72 | + $version_parts = explode('.', $min_core_version); |
|
73 | 73 | //check they specified the micro version (after 2nd period) |
74 | - if( ! isset( $version_parts[ 2 ] ) ) { |
|
75 | - $version_parts[ 2] = '0'; |
|
74 | + if ( ! isset($version_parts[2])) { |
|
75 | + $version_parts[2] = '0'; |
|
76 | 76 | } |
77 | 77 | //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
78 | 78 | //soon we can assume that's 'rc', but this current version is 'alpha' |
79 | - if( ! isset( $version_parts[ 3 ] ) ) { |
|
80 | - $version_parts[ 3 ] = 'dev'; |
|
79 | + if ( ! isset($version_parts[3])) { |
|
80 | + $version_parts[3] = 'dev'; |
|
81 | 81 | } |
82 | - if( ! isset( $version_parts[ 4 ] ) ) { |
|
83 | - $version_parts[ 4 ] = '000'; |
|
82 | + if ( ! isset($version_parts[4])) { |
|
83 | + $version_parts[4] = '000'; |
|
84 | 84 | } |
85 | - return implode( '.', $version_parts ); |
|
85 | + return implode('.', $version_parts); |
|
86 | 86 | |
87 | 87 | } |
88 | 88 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | * @param string $actual_core_version the actual core version, optional |
93 | 93 | * @return boolean |
94 | 94 | */ |
95 | - public static function _meets_min_core_version_requirement( $min_core_version, $actual_core_version = EVENT_ESPRESSO_VERSION ) { |
|
96 | - return version_compare( self::_effective_version( $actual_core_version ), self::_effective_version( $min_core_version ), '>=' ); |
|
95 | + public static function _meets_min_core_version_requirement($min_core_version, $actual_core_version = EVENT_ESPRESSO_VERSION) { |
|
96 | + return version_compare(self::_effective_version($actual_core_version), self::_effective_version($min_core_version), '>='); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -155,112 +155,112 @@ discard block |
||
155 | 155 | * @throws EE_Error |
156 | 156 | * @return void |
157 | 157 | */ |
158 | - public static function register( $addon_name = '', $setup_args = array() ) { |
|
158 | + public static function register($addon_name = '', $setup_args = array()) { |
|
159 | 159 | // required fields MUST be present, so let's make sure they are. |
160 | - if ( empty( $addon_name ) || ! is_array( $setup_args )) { |
|
161 | - throw new EE_Error( __( 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', 'event_espresso' )); |
|
160 | + if (empty($addon_name) || ! is_array($setup_args)) { |
|
161 | + throw new EE_Error(__('In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', 'event_espresso')); |
|
162 | 162 | } |
163 | - if ( ! isset($setup_args[ 'main_file_path' ]) || empty( $setup_args[ 'main_file_path' ] ) ){ |
|
164 | - throw new EE_Error( sprintf( __( 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', 'event_espresso' ), implode(",", array_keys( $setup_args ) ) ) ); |
|
163 | + if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
164 | + throw new EE_Error(sprintf(__('When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', 'event_espresso'), implode(",", array_keys($setup_args)))); |
|
165 | 165 | } |
166 | 166 | // check that addon has not already been registered with that name |
167 | - if ( isset( self::$_settings[ $addon_name ] ) && ! did_action( 'activate_plugin' ) ) { |
|
168 | - throw new EE_Error( sprintf( __( 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', 'event_espresso' ), $addon_name )); |
|
167 | + if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
168 | + throw new EE_Error(sprintf(__('An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', 'event_espresso'), $addon_name)); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
172 | 172 | // no class name for addon? |
173 | - if ( empty( $setup_args['class_name'] )) { |
|
173 | + if (empty($setup_args['class_name'])) { |
|
174 | 174 | // generate one by first separating name with spaces |
175 | - $class_name = str_replace( array( '-', '_' ), ' ', trim( $addon_name )); |
|
175 | + $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
176 | 176 | //capitalize, then replace spaces with underscores |
177 | - $class_name = str_replace( ' ', '_', ucwords( $class_name )); |
|
177 | + $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
178 | 178 | } else { |
179 | 179 | $class_name = $setup_args['class_name']; |
180 | 180 | } |
181 | - $class_name = strpos( $class_name, 'EE_' ) === 0 ? $class_name : 'EE_' . $class_name; |
|
181 | + $class_name = strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_'.$class_name; |
|
182 | 182 | //setup $_settings array from incoming values. |
183 | 183 | $addon_settings = array( |
184 | 184 | // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
185 | 185 | 'class_name' => $class_name, |
186 | 186 | // the addon slug for use in URLs, etc |
187 | - 'plugin_slug' => isset( $setup_args['plugin_slug'] ) ? (string)$setup_args['plugin_slug'] : '', |
|
187 | + 'plugin_slug' => isset($setup_args['plugin_slug']) ? (string) $setup_args['plugin_slug'] : '', |
|
188 | 188 | // page slug to be used when generating the "Settings" link on the WP plugin page |
189 | - 'plugin_action_slug' => isset( $setup_args[ 'plugin_action_slug' ] ) ? (string)$setup_args[ 'plugin_action_slug' ] : '', |
|
189 | + 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) ? (string) $setup_args['plugin_action_slug'] : '', |
|
190 | 190 | // the "software" version for the addon |
191 | - 'version' => isset( $setup_args['version'] ) ? (string)$setup_args['version'] : '', |
|
191 | + 'version' => isset($setup_args['version']) ? (string) $setup_args['version'] : '', |
|
192 | 192 | // the minimum version of EE Core that the addon will work with |
193 | - 'min_core_version' => isset( $setup_args['min_core_version'] ) ? (string)$setup_args['min_core_version'] : '', |
|
193 | + 'min_core_version' => isset($setup_args['min_core_version']) ? (string) $setup_args['min_core_version'] : '', |
|
194 | 194 | // the minimum version of WordPress that the addon will work with |
195 | - 'min_wp_version' => isset( $setup_args['min_wp_version'] ) ? (string)$setup_args['min_wp_version'] : EE_MIN_WP_VER_REQUIRED, |
|
195 | + 'min_wp_version' => isset($setup_args['min_wp_version']) ? (string) $setup_args['min_wp_version'] : EE_MIN_WP_VER_REQUIRED, |
|
196 | 196 | // full server path to main file (file loaded directly by WP) |
197 | - 'main_file_path' => isset( $setup_args['main_file_path'] ) ? (string)$setup_args['main_file_path'] : '', |
|
197 | + 'main_file_path' => isset($setup_args['main_file_path']) ? (string) $setup_args['main_file_path'] : '', |
|
198 | 198 | // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
199 | - 'admin_path' => isset( $setup_args['admin_path'] ) ? (string)$setup_args['admin_path'] : '', |
|
199 | + 'admin_path' => isset($setup_args['admin_path']) ? (string) $setup_args['admin_path'] : '', |
|
200 | 200 | // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
201 | - 'admin_callback' => isset( $setup_args['admin_callback'] ) ? (string)$setup_args['admin_callback'] : '', |
|
201 | + 'admin_callback' => isset($setup_args['admin_callback']) ? (string) $setup_args['admin_callback'] : '', |
|
202 | 202 | // the section name for this addon's configuration settings section (defaults to "addons") |
203 | - 'config_section' => isset( $setup_args['config_section'] ) ? (string)$setup_args['config_section'] : 'addons', |
|
203 | + 'config_section' => isset($setup_args['config_section']) ? (string) $setup_args['config_section'] : 'addons', |
|
204 | 204 | // the class name for this addon's configuration settings object |
205 | - 'config_class' => isset( $setup_args['config_class'] ) ? (string)$setup_args['config_class'] : '', |
|
205 | + 'config_class' => isset($setup_args['config_class']) ? (string) $setup_args['config_class'] : '', |
|
206 | 206 | //the name given to the config for this addons' configuration settings object (optional) |
207 | - 'config_name' => isset( $setup_args['config_name'] ) ? (string) $setup_args['config_name']: '', |
|
207 | + 'config_name' => isset($setup_args['config_name']) ? (string) $setup_args['config_name'] : '', |
|
208 | 208 | // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
209 | - 'autoloader_paths' => isset( $setup_args['autoloader_paths'] ) ? (array)$setup_args['autoloader_paths'] : array(), |
|
209 | + 'autoloader_paths' => isset($setup_args['autoloader_paths']) ? (array) $setup_args['autoloader_paths'] : array(), |
|
210 | 210 | // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
211 | - 'autoloader_folders' => isset( $setup_args['autoloader_folders'] ) ? (array)$setup_args['autoloader_folders'] : array(), |
|
211 | + 'autoloader_folders' => isset($setup_args['autoloader_folders']) ? (array) $setup_args['autoloader_folders'] : array(), |
|
212 | 212 | // array of full server paths to any EE_DMS data migration scripts used by the addon |
213 | - 'dms_paths' => isset( $setup_args['dms_paths'] ) ? (array)$setup_args['dms_paths'] : array(), |
|
213 | + 'dms_paths' => isset($setup_args['dms_paths']) ? (array) $setup_args['dms_paths'] : array(), |
|
214 | 214 | // array of full server paths to any EED_Modules used by the addon |
215 | - 'module_paths' => isset( $setup_args['module_paths'] ) ? (array)$setup_args['module_paths'] : array(), |
|
215 | + 'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(), |
|
216 | 216 | // array of full server paths to any EES_Shortcodes used by the addon |
217 | - 'shortcode_paths' => isset( $setup_args['shortcode_paths'] ) ? (array)$setup_args['shortcode_paths'] : array(), |
|
217 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) ? (array) $setup_args['shortcode_paths'] : array(), |
|
218 | 218 | // array of full server paths to any WP_Widgets used by the addon |
219 | - 'widget_paths' => isset( $setup_args['widget_paths'] ) ? (array)$setup_args['widget_paths'] : array(), |
|
219 | + 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(), |
|
220 | 220 | // array of PUE options used by the addon |
221 | - 'pue_options' => isset( $setup_args['pue_options'] ) ? (array)$setup_args['pue_options'] : array(), |
|
222 | - 'message_types' => isset( $setup_args['message_types'] ) ? (array) $setup_args['message_types'] : array(), |
|
223 | - 'capabilities' => isset( $setup_args['capabilities'] ) ? (array) $setup_args['capabilities'] : array(), |
|
224 | - 'capability_maps' => isset( $setup_args['capability_maps'] ) ? (array) $setup_args['capability_maps'] : array(), |
|
225 | - 'model_paths' => isset( $setup_args['model_paths'] ) ? (array) $setup_args['model_paths'] : array(), |
|
226 | - 'class_paths' => isset( $setup_args['class_paths'] ) ? (array) $setup_args['class_paths'] : array(), |
|
227 | - 'model_extension_paths' => isset( $setup_args['model_extension_paths'] ) ? (array) $setup_args['model_extension_paths'] : array(), |
|
228 | - 'class_extension_paths' => isset( $setup_args['class_extension_paths'] ) ? (array) $setup_args['class_extension_paths'] : array(), |
|
229 | - 'custom_post_types' => isset( $setup_args['custom_post_types'] ) ? (array) $setup_args['custom_post_types'] : array(), |
|
230 | - 'custom_taxonomies' => isset( $setup_args['custom_taxonomies'] ) ? (array) $setup_args['custom_taxonomies'] : array(), |
|
231 | - 'payment_method_paths' => isset( $setup_args[ 'payment_method_paths' ] ) ? (array) $setup_args[ 'payment_method_paths' ] : array(), |
|
232 | - 'default_terms' => isset( $setup_args['default_terms'] ) ? (array) $setup_args['default_terms'] : array(), |
|
221 | + 'pue_options' => isset($setup_args['pue_options']) ? (array) $setup_args['pue_options'] : array(), |
|
222 | + 'message_types' => isset($setup_args['message_types']) ? (array) $setup_args['message_types'] : array(), |
|
223 | + 'capabilities' => isset($setup_args['capabilities']) ? (array) $setup_args['capabilities'] : array(), |
|
224 | + 'capability_maps' => isset($setup_args['capability_maps']) ? (array) $setup_args['capability_maps'] : array(), |
|
225 | + 'model_paths' => isset($setup_args['model_paths']) ? (array) $setup_args['model_paths'] : array(), |
|
226 | + 'class_paths' => isset($setup_args['class_paths']) ? (array) $setup_args['class_paths'] : array(), |
|
227 | + 'model_extension_paths' => isset($setup_args['model_extension_paths']) ? (array) $setup_args['model_extension_paths'] : array(), |
|
228 | + 'class_extension_paths' => isset($setup_args['class_extension_paths']) ? (array) $setup_args['class_extension_paths'] : array(), |
|
229 | + 'custom_post_types' => isset($setup_args['custom_post_types']) ? (array) $setup_args['custom_post_types'] : array(), |
|
230 | + 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) ? (array) $setup_args['custom_taxonomies'] : array(), |
|
231 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) ? (array) $setup_args['payment_method_paths'] : array(), |
|
232 | + 'default_terms' => isset($setup_args['default_terms']) ? (array) $setup_args['default_terms'] : array(), |
|
233 | 233 | // if not empty, inserts a new table row after this plugin's row on the WP Plugins page that can be used for adding upgrading/marketing info |
234 | - 'plugins_page_row' => isset( $setup_args['plugins_page_row'] ) ? $setup_args['plugins_page_row'] : '', |
|
234 | + 'plugins_page_row' => isset($setup_args['plugins_page_row']) ? $setup_args['plugins_page_row'] : '', |
|
235 | 235 | ); |
236 | 236 | |
237 | 237 | // if plugin_action_slug is NOT set, but an admin page path IS set, then let's just use the plugin_slug since that will be used for linking to the admin page |
238 | - $addon_settings[ 'plugin_action_slug' ] = empty( $addon_settings[ 'plugin_action_slug' ] ) && ! empty( $addon_settings[ 'admin_path' ] ) ? $addon_settings[ 'plugin_slug' ] : $addon_settings[ 'plugin_action_slug' ]; |
|
238 | + $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) && ! empty($addon_settings['admin_path']) ? $addon_settings['plugin_slug'] : $addon_settings['plugin_action_slug']; |
|
239 | 239 | // full server path to main file (file loaded directly by WP) |
240 | - $addon_settings['plugin_basename'] = plugin_basename( $addon_settings[ 'main_file_path' ] ); |
|
240 | + $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
241 | 241 | |
242 | 242 | global $wp_version; |
243 | 243 | //check whether this addon version is compatible with EE core |
244 | - if ( isset( EE_Register_Addon::$_incompatible_addons[ $addon_name ] ) && |
|
245 | - ! self::_meets_min_core_version_requirement( EE_Register_Addon::$_incompatible_addons[ $addon_name ], $addon_settings[ 'version' ] ) ) { |
|
244 | + if (isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) && |
|
245 | + ! self::_meets_min_core_version_requirement(EE_Register_Addon::$_incompatible_addons[$addon_name], $addon_settings['version'])) { |
|
246 | 246 | $incompatibility_message = sprintf( |
247 | - __( 'The Event Espresso "%1$s" addon was deactivated because it is incompatible with this version of core.%2$s Only version %3$s or higher of "%1$s" can run with this version of core. This can happen when attempting to run beta versions or release candidates with older versions of core, or running old versions of addons with a newer version of core.%2$sPlease upgrade Event Espresso Core and the "%1$s" addon, then re-attempt activating it.', 'event_espresso' ), |
|
247 | + __('The Event Espresso "%1$s" addon was deactivated because it is incompatible with this version of core.%2$s Only version %3$s or higher of "%1$s" can run with this version of core. This can happen when attempting to run beta versions or release candidates with older versions of core, or running old versions of addons with a newer version of core.%2$sPlease upgrade Event Espresso Core and the "%1$s" addon, then re-attempt activating it.', 'event_espresso'), |
|
248 | 248 | $addon_name, |
249 | 249 | '<br />', |
250 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ] |
|
250 | + EE_Register_Addon::$_incompatible_addons[$addon_name] |
|
251 | 251 | ); |
252 | - } else if ( ! self::_meets_min_core_version_requirement( $addon_settings[ 'min_core_version' ], espresso_version() ) ) { |
|
252 | + } else if ( ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())) { |
|
253 | 253 | $incompatibility_message = sprintf( |
254 | 254 | __( |
255 | 255 | 'The Event Espresso "%1$s" addon could not be activated because it requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-attempt activating "%1$s".', |
256 | 256 | 'event_espresso' |
257 | 257 | ), |
258 | 258 | $addon_name, |
259 | - self::_effective_version( $addon_settings[ 'min_core_version' ] ), |
|
260 | - self::_effective_version( espresso_version() ), |
|
259 | + self::_effective_version($addon_settings['min_core_version']), |
|
260 | + self::_effective_version(espresso_version()), |
|
261 | 261 | '<br />' |
262 | 262 | ); |
263 | - } else if (version_compare( $wp_version, $addon_settings['min_wp_version'], '<' )) { |
|
263 | + } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
264 | 264 | $incompatibility_message = sprintf( |
265 | 265 | __( |
266 | 266 | 'The Event Espresso "%1$s" addon could not be activated because it requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
@@ -269,137 +269,137 @@ discard block |
||
269 | 269 | $addon_name, |
270 | 270 | $addon_settings['min_wp_version'], |
271 | 271 | '<br />' |
272 | - );; |
|
272 | + ); ; |
|
273 | 273 | } else { |
274 | 274 | $incompatibility_message = ''; |
275 | 275 | } |
276 | - if ( ! empty( $incompatibility_message ) ) { |
|
276 | + if ( ! empty($incompatibility_message)) { |
|
277 | 277 | //remove 'activate' from the REQUEST so WP doesn't erroneously tell the user the |
278 | 278 | //plugin activated fine when it didn't |
279 | - if( isset( $_GET[ 'activate' ]) ) { |
|
280 | - unset( $_GET[ 'activate' ] ); |
|
279 | + if (isset($_GET['activate'])) { |
|
280 | + unset($_GET['activate']); |
|
281 | 281 | } |
282 | - if( isset( $_REQUEST[ 'activate' ] ) ){ |
|
283 | - unset( $_REQUEST[ 'activate' ] ); |
|
282 | + if (isset($_REQUEST['activate'])) { |
|
283 | + unset($_REQUEST['activate']); |
|
284 | 284 | } |
285 | 285 | //and show an error message indicating the plugin didn't activate properly |
286 | - EE_Error::add_error( $incompatibility_message, __FILE__, __FUNCTION__, __LINE__ ); |
|
287 | - if ( current_user_can( 'activate_plugins' )) { |
|
288 | - require_once( ABSPATH.'wp-admin/includes/plugin.php' ); |
|
289 | - deactivate_plugins( plugin_basename( $addon_settings[ 'main_file_path' ] ), TRUE ); |
|
286 | + EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
287 | + if (current_user_can('activate_plugins')) { |
|
288 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
289 | + deactivate_plugins(plugin_basename($addon_settings['main_file_path']), TRUE); |
|
290 | 290 | } |
291 | 291 | return; |
292 | 292 | } |
293 | 293 | //this is an activation request |
294 | - if( did_action( 'activate_plugin' ) ){ |
|
294 | + if (did_action('activate_plugin')) { |
|
295 | 295 | //to find if THIS is the addon that was activated, |
296 | 296 | //just check if we have already registered it or not |
297 | 297 | //(as the newly-activated addon wasn't around the first time addons were registered) |
298 | - if( ! isset( self::$_settings[ $addon_name ] ) ){ |
|
299 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
298 | + if ( ! isset(self::$_settings[$addon_name])) { |
|
299 | + self::$_settings[$addon_name] = $addon_settings; |
|
300 | 300 | $addon = self::_load_and_init_addon_class($addon_name); |
301 | 301 | $addon->set_activation_indicator_option(); |
302 | 302 | //dont bother setting up the rest of the addon. |
303 | 303 | //we know it was just activated and the request will end soon |
304 | 304 | } |
305 | 305 | return; |
306 | - }else{ |
|
306 | + } else { |
|
307 | 307 | // make sure this was called in the right place! |
308 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' )) { |
|
308 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) { |
|
309 | 309 | EE_Error::doing_it_wrong( |
310 | 310 | __METHOD__, |
311 | 311 | sprintf( |
312 | - __( 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.','event_espresso'), |
|
312 | + __('An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', 'event_espresso'), |
|
313 | 313 | $addon_name |
314 | 314 | ), |
315 | 315 | '4.3.0' |
316 | 316 | ); |
317 | 317 | } |
318 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
318 | + self::$_settings[$addon_name] = $addon_settings; |
|
319 | 319 | } |
320 | 320 | // we need cars |
321 | - if ( ! empty( self::$_settings[ $addon_name ]['autoloader_paths'] )) { |
|
321 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
322 | 322 | // setup autoloader for single file |
323 | - EEH_Autoloader::instance()->register_autoloader( self::$_settings[ $addon_name ]['autoloader_paths'] ); |
|
323 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
324 | 324 | } |
325 | 325 | // setup autoloaders for folders |
326 | - if ( ! empty( self::$_settings[ $addon_name ]['autoloader_folders'] )) { |
|
327 | - foreach ( self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder ) { |
|
328 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $autoloader_folder ); |
|
326 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
327 | + foreach (self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
328 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | // register new models |
332 | - if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) || ! empty( self::$_settings[ $addon_name ]['class_paths'] )) { |
|
333 | - EE_Register_Model::register( $addon_name, array( 'model_paths' => self::$_settings[ $addon_name ]['model_paths'] , 'class_paths' => self::$_settings[ $addon_name ]['class_paths'])); |
|
332 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) || ! empty(self::$_settings[$addon_name]['class_paths'])) { |
|
333 | + EE_Register_Model::register($addon_name, array('model_paths' => self::$_settings[$addon_name]['model_paths'], 'class_paths' => self::$_settings[$addon_name]['class_paths'])); |
|
334 | 334 | } |
335 | 335 | // register model extensions |
336 | - if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) || ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] )) { |
|
337 | - EE_Register_Model_Extensions::register( $addon_name, array( 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'] , 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'])); |
|
336 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) || ! empty(self::$_settings[$addon_name]['class_extension_paths'])) { |
|
337 | + EE_Register_Model_Extensions::register($addon_name, array('model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'])); |
|
338 | 338 | } |
339 | 339 | // setup DMS |
340 | - if ( ! empty( self::$_settings[ $addon_name ]['dms_paths'] )) { |
|
341 | - EE_Register_Data_Migration_Scripts::register( $addon_name, array( 'dms_paths' => self::$_settings[ $addon_name ]['dms_paths'] )); |
|
340 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
341 | + EE_Register_Data_Migration_Scripts::register($addon_name, array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])); |
|
342 | 342 | } |
343 | 343 | // if config_class is present let's register config. |
344 | - if ( ! empty( self::$_settings[ $addon_name ]['config_class'] )) { |
|
344 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
345 | 345 | EE_Register_Config::register( |
346 | - self::$_settings[ $addon_name ]['config_class'], |
|
346 | + self::$_settings[$addon_name]['config_class'], |
|
347 | 347 | array( |
348 | - 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
349 | - 'config_name' => self::$_settings[ $addon_name ]['config_name'] |
|
348 | + 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
349 | + 'config_name' => self::$_settings[$addon_name]['config_name'] |
|
350 | 350 | ) |
351 | 351 | ); |
352 | 352 | } |
353 | 353 | // register admin page |
354 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_path'] )) { |
|
355 | - EE_Register_Admin_Page::register( $addon_name, array( 'page_path' => self::$_settings[ $addon_name ]['admin_path'] )); |
|
354 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
355 | + EE_Register_Admin_Page::register($addon_name, array('page_path' => self::$_settings[$addon_name]['admin_path'])); |
|
356 | 356 | |
357 | 357 | } |
358 | 358 | // add to list of modules to be registered |
359 | - if ( ! empty( self::$_settings[ $addon_name ]['module_paths'] )) { |
|
360 | - EE_Register_Module::register( $addon_name, array( 'module_paths' => self::$_settings[ $addon_name ]['module_paths'] )); |
|
359 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
360 | + EE_Register_Module::register($addon_name, array('module_paths' => self::$_settings[$addon_name]['module_paths'])); |
|
361 | 361 | } |
362 | 362 | // add to list of shortcodes to be registered |
363 | - if ( ! empty( self::$_settings[ $addon_name ]['shortcode_paths'] )) { |
|
364 | - EE_Register_Shortcode::register( $addon_name, array( 'shortcode_paths' => self::$_settings[ $addon_name ]['shortcode_paths'] )); |
|
363 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
364 | + EE_Register_Shortcode::register($addon_name, array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths'])); |
|
365 | 365 | } |
366 | 366 | // add to list of widgets to be registered |
367 | - if ( ! empty( self::$_settings[ $addon_name ]['widget_paths'] )) { |
|
368 | - EE_Register_Widget::register( $addon_name, array( 'widget_paths' => self::$_settings[ $addon_name ]['widget_paths'] )); |
|
367 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
368 | + EE_Register_Widget::register($addon_name, array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | //register capability related stuff. |
372 | - if ( ! empty( self::$_settings[ $addon_name ]['capabilities'] ) ) { |
|
373 | - EE_Register_Capabilities::register( $addon_name , array( 'capabilities' => self::$_settings[$addon_name]['capabilities'], 'capability_maps' => self::$_settings[$addon_name]['capability_maps'] ) ); |
|
372 | + if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
373 | + EE_Register_Capabilities::register($addon_name, array('capabilities' => self::$_settings[$addon_name]['capabilities'], 'capability_maps' => self::$_settings[$addon_name]['capability_maps'])); |
|
374 | 374 | } |
375 | 375 | //any message type to register? |
376 | - if ( !empty( self::$_settings[$addon_name]['message_types'] ) ) { |
|
377 | - add_action( 'EE_Brewing_Regular___messages_caf', array( 'EE_Register_Addon', 'register_message_types' ) ); |
|
376 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
377 | + add_action('EE_Brewing_Regular___messages_caf', array('EE_Register_Addon', 'register_message_types')); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | // if plugin update engine is being used for auto-updates (not needed if PUE is not being used) |
381 | - if ( ! empty( $setup_args['pue_options'] )) { |
|
382 | - self::$_settings[ $addon_name ]['pue_options'] = array( |
|
383 | - 'pue_plugin_slug' => isset( $setup_args['pue_options']['pue_plugin_slug'] ) ? (string)$setup_args['pue_options']['pue_plugin_slug'] : 'espresso_' . strtolower( $class_name ), |
|
384 | - 'plugin_basename' => isset( $setup_args['pue_options']['plugin_basename'] ) ? (string)$setup_args['pue_options']['plugin_basename'] : plugin_basename( self::$_settings[ $addon_name ]['main_file_path'] ), |
|
385 | - 'checkPeriod' => isset( $setup_args['pue_options']['checkPeriod'] ) ? (string)$setup_args['pue_options']['checkPeriod'] : '24', |
|
386 | - 'use_wp_update' => isset( $setup_args['pue_options']['use_wp_update'] ) ? (string)$setup_args['pue_options']['use_wp_update'] : FALSE |
|
381 | + if ( ! empty($setup_args['pue_options'])) { |
|
382 | + self::$_settings[$addon_name]['pue_options'] = array( |
|
383 | + 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) ? (string) $setup_args['pue_options']['pue_plugin_slug'] : 'espresso_'.strtolower($class_name), |
|
384 | + 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) ? (string) $setup_args['pue_options']['plugin_basename'] : plugin_basename(self::$_settings[$addon_name]['main_file_path']), |
|
385 | + 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) ? (string) $setup_args['pue_options']['checkPeriod'] : '24', |
|
386 | + 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) ? (string) $setup_args['pue_options']['use_wp_update'] : FALSE |
|
387 | 387 | ); |
388 | - add_action( 'AHEE__EE_System__brew_espresso__after_pue_init', array( 'EE_Register_Addon', 'load_pue_update' )); |
|
388 | + add_action('AHEE__EE_System__brew_espresso__after_pue_init', array('EE_Register_Addon', 'load_pue_update')); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | //any custom post type/ custom capabilities or default terms to register |
392 | - if ( !empty( self::$_settings[$addon_name]['custom_post_types'] ) || !empty( self::$_settings[$addon_name]['custom_taxonomies'] ) ) { |
|
393 | - EE_Register_CPT::register( $addon_name, array( 'cpts' => self::$_settings[$addon_name]['custom_post_types'] , 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], 'default_terms' => self::$_settings[$addon_name]['default_terms'] ) ); |
|
392 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types']) || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])) { |
|
393 | + EE_Register_CPT::register($addon_name, array('cpts' => self::$_settings[$addon_name]['custom_post_types'], 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], 'default_terms' => self::$_settings[$addon_name]['default_terms'])); |
|
394 | 394 | } |
395 | - if( ! empty( self::$_settings[ $addon_name ][ 'payment_method_paths' ] ) ){ |
|
396 | - EE_Register_Payment_Method::register($addon_name, array( 'payment_method_paths' => self::$_settings[ $addon_name ][ 'payment_method_paths' ] ) ); |
|
395 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
396 | + EE_Register_Payment_Method::register($addon_name, array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])); |
|
397 | 397 | } |
398 | 398 | // load and instantiate main addon class |
399 | 399 | $addon = self::_load_and_init_addon_class($addon_name); |
400 | 400 | // call any additional admin_callback functions during load_admin_controller hook |
401 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_callback'] )) { |
|
402 | - add_action( 'AHEE__EE_System__load_controllers__load_admin_controllers', array( $addon, self::$_settings[ $addon_name ]['admin_callback'] )); |
|
401 | + if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
402 | + add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($addon, self::$_settings[$addon_name]['admin_callback'])); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -410,22 +410,22 @@ discard block |
||
410 | 410 | * @param string $addon_name |
411 | 411 | * @return EE_Addon |
412 | 412 | */ |
413 | - private static function _load_and_init_addon_class($addon_name){ |
|
414 | - $addon = EE_Registry::instance()->load_addon( dirname( self::$_settings[ $addon_name ]['main_file_path'] ), self::$_settings[ $addon_name ]['class_name'] ); |
|
415 | - $addon->set_name( $addon_name ); |
|
416 | - $addon->set_plugin_slug( self::$_settings[ $addon_name ][ 'plugin_slug' ] ); |
|
417 | - $addon->set_plugin_basename( self::$_settings[ $addon_name ][ 'plugin_basename' ] ); |
|
418 | - $addon->set_main_plugin_file( self::$_settings[ $addon_name ]['main_file_path'] ); |
|
419 | - $addon->set_plugin_action_slug( self::$_settings[ $addon_name ][ 'plugin_action_slug' ] ); |
|
420 | - $addon->set_plugins_page_row( self::$_settings[ $addon_name ][ 'plugins_page_row' ] ); |
|
421 | - $addon->set_version( self::$_settings[ $addon_name ]['version'] ); |
|
422 | - $addon->set_min_core_version( self::_effective_version( self::$_settings[ $addon_name ]['min_core_version'] ) ); |
|
423 | - $addon->set_config_section( self::$_settings[ $addon_name ]['config_section'] ); |
|
424 | - $addon->set_config_class( self::$_settings[ $addon_name ]['config_class'] ); |
|
425 | - $addon->set_config_name( self::$_settings[ $addon_name ]['config_name'] ); |
|
413 | + private static function _load_and_init_addon_class($addon_name) { |
|
414 | + $addon = EE_Registry::instance()->load_addon(dirname(self::$_settings[$addon_name]['main_file_path']), self::$_settings[$addon_name]['class_name']); |
|
415 | + $addon->set_name($addon_name); |
|
416 | + $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']); |
|
417 | + $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']); |
|
418 | + $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']); |
|
419 | + $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']); |
|
420 | + $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']); |
|
421 | + $addon->set_version(self::$_settings[$addon_name]['version']); |
|
422 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version'])); |
|
423 | + $addon->set_config_section(self::$_settings[$addon_name]['config_section']); |
|
424 | + $addon->set_config_class(self::$_settings[$addon_name]['config_class']); |
|
425 | + $addon->set_config_name(self::$_settings[$addon_name]['config_name']); |
|
426 | 426 | //unfortunately this can't be hooked in upon construction, because we don't have |
427 | 427 | //the plugin mainfile's path upon construction. |
428 | - register_deactivation_hook($addon->get_main_plugin_file(), array($addon,'deactivation')); |
|
428 | + register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
429 | 429 | return $addon; |
430 | 430 | } |
431 | 431 | |
@@ -438,18 +438,18 @@ discard block |
||
438 | 438 | */ |
439 | 439 | public static function load_pue_update() { |
440 | 440 | // load PUE client |
441 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
441 | + require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php'; |
|
442 | 442 | // cycle thru settings |
443 | - foreach ( self::$_settings as $settings ) { |
|
444 | - if ( ! empty( $settings['pue_options'] )) { |
|
443 | + foreach (self::$_settings as $settings) { |
|
444 | + if ( ! empty($settings['pue_options'])) { |
|
445 | 445 | // initiate the class and start the plugin update engine! |
446 | 446 | new PluginUpdateEngineChecker( |
447 | 447 | // host file URL |
448 | 448 | 'https://eventespresso.com', |
449 | 449 | // plugin slug(s) |
450 | 450 | array( |
451 | - 'premium' => array( 'p' => $settings['pue_options']['pue_plugin_slug'] ), |
|
452 | - 'prerelease' => array( 'beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr' ) |
|
451 | + 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
452 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr') |
|
453 | 453 | ), |
454 | 454 | // options |
455 | 455 | array( |
@@ -477,9 +477,9 @@ discard block |
||
477 | 477 | * @return void |
478 | 478 | */ |
479 | 479 | public static function register_message_types() { |
480 | - foreach ( self::$_settings as $settings ) { |
|
481 | - foreach( $settings['message_types'] as $message_type => $message_type_settings ) { |
|
482 | - EE_Register_Message_Type::register( $message_type, $message_type_settings ); |
|
480 | + foreach (self::$_settings as $settings) { |
|
481 | + foreach ($settings['message_types'] as $message_type => $message_type_settings) { |
|
482 | + EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
@@ -495,60 +495,60 @@ discard block |
||
495 | 495 | * @throws EE_Error |
496 | 496 | * @return void |
497 | 497 | */ |
498 | - public static function deregister( $addon_name = NULL ) { |
|
499 | - if ( isset( self::$_settings[ $addon_name ] )) { |
|
500 | - $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
501 | - if ( ! empty( self::$_settings[ $addon_name ]['dms_paths'] )) { |
|
498 | + public static function deregister($addon_name = NULL) { |
|
499 | + if (isset(self::$_settings[$addon_name])) { |
|
500 | + $class_name = self::$_settings[$addon_name]['class_name']; |
|
501 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
502 | 502 | // setup DMS |
503 | - EE_Register_Data_Migration_Scripts::deregister( $addon_name ); |
|
503 | + EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
504 | 504 | } |
505 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_path'] )) { |
|
505 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
506 | 506 | // register admin page |
507 | - EE_Register_Admin_Page::deregister( $addon_name ); |
|
507 | + EE_Register_Admin_Page::deregister($addon_name); |
|
508 | 508 | } |
509 | - if ( ! empty( self::$_settings[ $addon_name ]['module_paths'] )) { |
|
509 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
510 | 510 | // add to list of modules to be registered |
511 | - EE_Register_Module::deregister( $addon_name ); |
|
511 | + EE_Register_Module::deregister($addon_name); |
|
512 | 512 | } |
513 | - if ( ! empty( self::$_settings[ $addon_name ]['shortcode_paths'] )) { |
|
513 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
514 | 514 | // add to list of shortcodes to be registered |
515 | - EE_Register_Shortcode::deregister( $addon_name ); |
|
515 | + EE_Register_Shortcode::deregister($addon_name); |
|
516 | 516 | } |
517 | - if ( ! empty( self::$_settings[ $addon_name ]['config_class'] )) { |
|
517 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
518 | 518 | // if config_class present let's register config. |
519 | - EE_Register_Config::deregister( self::$_settings[ $addon_name ]['config_class']); |
|
519 | + EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
|
520 | 520 | } |
521 | - if ( ! empty( self::$_settings[ $addon_name ]['widget_paths'] )) { |
|
521 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
522 | 522 | // add to list of widgets to be registered |
523 | - EE_Register_Widget::deregister( $addon_name ); |
|
523 | + EE_Register_Widget::deregister($addon_name); |
|
524 | 524 | } |
525 | - if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) || |
|
526 | - ! empty( self::$_settings[ $addon_name ]['class_paths'] )) { |
|
525 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) || |
|
526 | + ! empty(self::$_settings[$addon_name]['class_paths'])) { |
|
527 | 527 | // add to list of shortcodes to be registered |
528 | - EE_Register_Model::deregister( $addon_name ); |
|
528 | + EE_Register_Model::deregister($addon_name); |
|
529 | 529 | } |
530 | - if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) || |
|
531 | - ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] )) { |
|
530 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) || |
|
531 | + ! empty(self::$_settings[$addon_name]['class_extension_paths'])) { |
|
532 | 532 | // add to list of shortcodes to be registered |
533 | - EE_Register_Model_Extensions::deregister( $addon_name ); |
|
533 | + EE_Register_Model_Extensions::deregister($addon_name); |
|
534 | 534 | } |
535 | - if ( !empty( self::$_settings[$addon_name]['message_types'] ) ) { |
|
536 | - foreach( self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings ) { |
|
537 | - EE_Register_Message_Type::deregister( $message_type ); |
|
535 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
536 | + foreach (self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
537 | + EE_Register_Message_Type::deregister($message_type); |
|
538 | 538 | } |
539 | 539 | } |
540 | 540 | //deregister capabilities for addon |
541 | - if ( ! empty( self::$_settings[$addon_name]['capabilities'] ) || ! empty( self::$_settings[$addon_name]['capability_maps']) ) { |
|
542 | - EE_Register_Capabilities::deregister( $addon_name ); |
|
541 | + if ( ! empty(self::$_settings[$addon_name]['capabilities']) || ! empty(self::$_settings[$addon_name]['capability_maps'])) { |
|
542 | + EE_Register_Capabilities::deregister($addon_name); |
|
543 | 543 | } |
544 | 544 | //deregister custom_post_types for addon |
545 | - if ( ! empty( self::$_settings[$addon_name]['custom_post_types'] ) ) { |
|
546 | - EE_Register_CPT::deregister( $addon_name ); |
|
545 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
546 | + EE_Register_CPT::deregister($addon_name); |
|
547 | 547 | } |
548 | - remove_action('deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), array( EE_Registry::instance()->addons->{$class_name}, 'deactivation' ) ); |
|
549 | - remove_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required' ) ); |
|
548 | + remove_action('deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), array(EE_Registry::instance()->addons->{$class_name}, 'deactivation')); |
|
549 | + remove_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required')); |
|
550 | 550 | unset(EE_Registry::instance()->addons->{$class_name}); |
551 | - unset( self::$_settings[ $addon_name ] ); |
|
551 | + unset(self::$_settings[$addon_name]); |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * @param \Transactions_Admin_Page $admin_page |
33 | 33 | */ |
34 | - public function __construct( \Transactions_Admin_Page $admin_page ){ |
|
35 | - parent::__construct( $admin_page ); |
|
34 | + public function __construct(\Transactions_Admin_Page $admin_page) { |
|
35 | + parent::__construct($admin_page); |
|
36 | 36 | $this->_status = $this->_admin_page->get_transaction_status_array(); |
37 | 37 | } |
38 | 38 | |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | *_setup_data |
43 | 43 | */ |
44 | 44 | protected function _setup_data() { |
45 | - $this->_data = $this->_admin_page->get_transactions( $this->_per_page ); |
|
46 | - $status = ! empty( $this->_req_data['status'] )? $this->_req_data['status'] : 'all'; |
|
47 | - $this->_all_data_count = $this->_admin_page->get_transactions( $this->_per_page, TRUE, $status ); |
|
45 | + $this->_data = $this->_admin_page->get_transactions($this->_per_page); |
|
46 | + $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all'; |
|
47 | + $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, TRUE, $status); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -59,25 +59,25 @@ discard block |
||
59 | 59 | 'ajax' => TRUE, |
60 | 60 | 'screen' => $this->_admin_page->get_current_screen()->id |
61 | 61 | ); |
62 | - $ID_column_name = __( 'ID', 'event_espresso' ); |
|
62 | + $ID_column_name = __('ID', 'event_espresso'); |
|
63 | 63 | $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
64 | - $ID_column_name .= __( 'Transaction Date', 'event_espresso' ); |
|
64 | + $ID_column_name .= __('Transaction Date', 'event_espresso'); |
|
65 | 65 | $ID_column_name .= '</span> '; |
66 | 66 | $this->_columns = array( |
67 | 67 | 'TXN_ID' => $ID_column_name, |
68 | - 'TXN_timestamp' => __( 'Transaction Date', 'event_espresso' ), |
|
69 | - 'TXN_total' => __( 'Total', 'event_espresso' ), |
|
70 | - 'TXN_paid' => __( 'Paid', 'event_espresso' ), |
|
71 | - 'ATT_fname' => __( 'Primary Registrant', 'event_espresso' ), |
|
72 | - 'event_name' => __( 'Event', 'event_espresso' ), |
|
73 | - 'actions' => __( 'Actions', 'event_espresso' ) |
|
68 | + 'TXN_timestamp' => __('Transaction Date', 'event_espresso'), |
|
69 | + 'TXN_total' => __('Total', 'event_espresso'), |
|
70 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
71 | + 'ATT_fname' => __('Primary Registrant', 'event_espresso'), |
|
72 | + 'event_name' => __('Event', 'event_espresso'), |
|
73 | + 'actions' => __('Actions', 'event_espresso') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $this->_sortable_columns = array( |
77 | - 'TXN_ID' => array( 'TXN_ID' => FALSE ), |
|
78 | - 'event_name' => array( 'event_name'=> FALSE ), |
|
79 | - 'ATT_fname' => array( 'ATT_fname'=> FALSE ), |
|
80 | - 'TXN_timestamp' => array( 'TXN_timestamp'=> TRUE ) //true means its already sorted |
|
77 | + 'TXN_ID' => array('TXN_ID' => FALSE), |
|
78 | + 'event_name' => array('event_name'=> FALSE), |
|
79 | + 'ATT_fname' => array('ATT_fname'=> FALSE), |
|
80 | + 'TXN_timestamp' => array('TXN_timestamp'=> TRUE) //true means its already sorted |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | $this->_primary_column = 'TXN_ID'; |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * @return string |
96 | 96 | * @throws \EE_Error |
97 | 97 | */ |
98 | - protected function _get_row_class( $item ) { |
|
99 | - $class = parent::_get_row_class( $item ); |
|
98 | + protected function _get_row_class($item) { |
|
99 | + $class = parent::_get_row_class($item); |
|
100 | 100 | //add status class |
101 | - $class .= ' ee-status-strip txn-status-' . $item->status_ID(); |
|
102 | - if ( $this->_has_checkbox_column ) { |
|
101 | + $class .= ' ee-status-strip txn-status-'.$item->status_ID(); |
|
102 | + if ($this->_has_checkbox_column) { |
|
103 | 103 | $class .= ' has-checkbox-column'; |
104 | 104 | } |
105 | 105 | return $class; |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function _get_table_filters() { |
118 | 118 | $filters = array(); |
119 | - $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' )); |
|
120 | - $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y', current_time('timestamp') ); |
|
119 | + $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year')); |
|
120 | + $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y', current_time('timestamp')); |
|
121 | 121 | ob_start(); |
122 | 122 | ?> |
123 | 123 | <label for="txn-filter-start-date">Display Transactions from </label> |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | *_add_view_counts |
137 | 137 | */ |
138 | 138 | protected function _add_view_counts() { |
139 | - $this->_views['all']['count'] = $this->_admin_page->get_transactions( $this->_per_page, TRUE, 'all' ); |
|
140 | - $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions( $this->_per_page, TRUE, 'abandoned' ); |
|
141 | - $this->_views['failed']['count'] = $this->_admin_page->get_transactions( $this->_per_page, TRUE, 'failed' ); |
|
139 | + $this->_views['all']['count'] = $this->_admin_page->get_transactions($this->_per_page, TRUE, 'all'); |
|
140 | + $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, TRUE, 'abandoned'); |
|
141 | + $this->_views['failed']['count'] = $this->_admin_page->get_transactions($this->_per_page, TRUE, 'failed'); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | * @return string |
151 | 151 | * @throws \EE_Error |
152 | 152 | */ |
153 | - public function column_TXN_ID( EE_Transaction $item ){ |
|
154 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
155 | - $content = '<a href="' . $view_lnk_url . '" title="' . esc_attr__( 'Go to Transaction Details', 'event_espresso' ) . '">' . $item->ID() . '</a>'; |
|
153 | + public function column_TXN_ID(EE_Transaction $item) { |
|
154 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
155 | + $content = '<a href="'.$view_lnk_url.'" title="'.esc_attr__('Go to Transaction Details', 'event_espresso').'">'.$item->ID().'</a>'; |
|
156 | 156 | |
157 | 157 | //txn timestamp |
158 | - $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp( $item ) . '</span>'; |
|
158 | + $content .= ' <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($item).'</span>'; |
|
159 | 159 | return $content; |
160 | 160 | } |
161 | 161 | |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | * @return mixed|string|void |
167 | 167 | * @throws \EE_Error |
168 | 168 | */ |
169 | - protected function _get_txn_timestamp( EE_Transaction $item ) { |
|
169 | + protected function _get_txn_timestamp(EE_Transaction $item) { |
|
170 | 170 | //txn timestamp |
171 | 171 | // is TXN less than 2 hours old ? |
172 | 172 | if ( |
173 | - ( $item->failed() || $item->is_abandoned() ) |
|
173 | + ($item->failed() || $item->is_abandoned()) |
|
174 | 174 | && ( |
175 | - ( time() - EE_Registry::instance()->SSN->lifespan() ) < $item->datetime( false, true ) |
|
175 | + (time() - EE_Registry::instance()->SSN->lifespan()) < $item->datetime(false, true) |
|
176 | 176 | ) |
177 | 177 | ) { |
178 | - $timestamp = __( 'TXN in progress...', 'event_espresso' ); |
|
178 | + $timestamp = __('TXN in progress...', 'event_espresso'); |
|
179 | 179 | } else { |
180 | - $timestamp = $item->get_i18n_datetime( 'TXN_timestamp' ); |
|
180 | + $timestamp = $item->get_i18n_datetime('TXN_timestamp'); |
|
181 | 181 | } |
182 | 182 | return $timestamp; |
183 | 183 | } |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | * @return string |
192 | 192 | * @throws \EE_Error |
193 | 193 | */ |
194 | - public function column_cb($item ){ |
|
195 | - return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_wp_list_args['singular'], $item->ID()); |
|
194 | + public function column_cb($item) { |
|
195 | + return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_wp_list_args['singular'], $item->ID()); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | * @return string |
205 | 205 | * @throws \EE_Error |
206 | 206 | */ |
207 | - public function column_TXN_timestamp( EE_Transaction $item ){ |
|
208 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
209 | - $txn_date = '<a href="'.$view_lnk_url.'" title="' . esc_attr__( 'View Transaction Details for TXN #', 'event_espresso' ) . $item->ID() . '">' . $this->_get_txn_timestamp( $item ) . '</a>'; |
|
207 | + public function column_TXN_timestamp(EE_Transaction $item) { |
|
208 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
209 | + $txn_date = '<a href="'.$view_lnk_url.'" title="'.esc_attr__('View Transaction Details for TXN #', 'event_espresso').$item->ID().'">'.$this->_get_txn_timestamp($item).'</a>'; |
|
210 | 210 | //status |
211 | - $txn_date .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
211 | + $txn_date .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false, 'sentence').'</span>'; |
|
212 | 212 | return $txn_date; |
213 | 213 | } |
214 | 214 | |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | * @return string |
222 | 222 | * @throws \EE_Error |
223 | 223 | */ |
224 | - public function column_TXN_total( EE_Transaction $item ){ |
|
225 | - if ( $item->get('TXN_total') > 0 ) { |
|
226 | - return '<span class="txn-pad-rght">' . apply_filters( 'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', $item->get_pretty('TXN_total'), $item ) . '</span>'; |
|
224 | + public function column_TXN_total(EE_Transaction $item) { |
|
225 | + if ($item->get('TXN_total') > 0) { |
|
226 | + return '<span class="txn-pad-rght">'.apply_filters('FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', $item->get_pretty('TXN_total'), $item).'</span>'; |
|
227 | 227 | } else { |
228 | - return '<span class="txn-overview-free-event-spn">' . __( 'free', 'event_espresso' ) . '</span>'; |
|
228 | + return '<span class="txn-overview-free-event-spn">'.__('free', 'event_espresso').'</span>'; |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | * @return mixed|string |
239 | 239 | * @throws \EE_Error |
240 | 240 | */ |
241 | - public function column_TXN_paid( EE_Transaction $item ){ |
|
241 | + public function column_TXN_paid(EE_Transaction $item) { |
|
242 | 242 | $transaction_total = $item->get('TXN_total'); |
243 | 243 | $transaction_paid = $item->get('TXN_paid'); |
244 | 244 | |
245 | - if ( \EEH_Money::compare_floats( $transaction_total, 0,'>' ) ) { |
|
245 | + if (\EEH_Money::compare_floats($transaction_total, 0, '>')) { |
|
246 | 246 | // monies owing |
247 | 247 | $span_class = 'txn-overview-part-payment-spn'; |
248 | - if ( \EEH_Money::compare_floats( $transaction_paid, $transaction_total, '>=' ) ) { |
|
248 | + if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) { |
|
249 | 249 | // paid in full |
250 | 250 | $span_class = 'txn-overview-full-payment-spn'; |
251 | - } elseif ( \EEH_Money::compare_floats( $transaction_paid, 0, '==' ) ) { |
|
251 | + } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) { |
|
252 | 252 | // no payments made |
253 | 253 | $span_class = 'txn-overview-no-payment-spn'; |
254 | 254 | } |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | $payment_method = $item->payment_method(); |
261 | - $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __( 'Unknown', 'event_espresso' ); |
|
261 | + $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', 'event_espresso'); |
|
262 | 262 | |
263 | - $content = '<span class="' . $span_class . ' txn-pad-rght">' . $transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid . '</span>'; |
|
264 | - if ( $transaction_paid > 0 ) { |
|
265 | - $content .= '<br><span class="ee-status-text-small">' . sprintf( __( '...via %s', 'event_espresso' ), $payment_method_name ) . '</span>'; |
|
263 | + $content = '<span class="'.$span_class.' txn-pad-rght">'.$transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid.'</span>'; |
|
264 | + if ($transaction_paid > 0) { |
|
265 | + $content .= '<br><span class="ee-status-text-small">'.sprintf(__('...via %s', 'event_espresso'), $payment_method_name).'</span>'; |
|
266 | 266 | } |
267 | 267 | return $content; |
268 | 268 | } |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | * @return string|void |
277 | 277 | * @throws \EE_Error |
278 | 278 | */ |
279 | - public function column_ATT_fname( EE_Transaction $item ){ |
|
279 | + public function column_ATT_fname(EE_Transaction $item) { |
|
280 | 280 | $primary_reg = $item->primary_registration(); |
281 | 281 | $attendee = $primary_reg->get_first_related('Attendee'); |
282 | - if ( $attendee instanceof EE_Attendee ) { |
|
283 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$primary_reg->ID() ), REG_ADMIN_URL ); |
|
284 | - $content = EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $primary_reg->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' . $attendee->full_name() . '</a>' : $attendee->full_name(); |
|
285 | - $content .= '<br>' . $attendee->email(); |
|
282 | + if ($attendee instanceof EE_Attendee) { |
|
283 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$primary_reg->ID()), REG_ADMIN_URL); |
|
284 | + $content = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $primary_reg->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'.$attendee->full_name().'</a>' : $attendee->full_name(); |
|
285 | + $content .= '<br>'.$attendee->email(); |
|
286 | 286 | return $content; |
287 | 287 | } |
288 | 288 | return $item->failed() || $item->is_abandoned() ? __('no contact record.', 'event_espresso') : __('No contact record, because the transaction was abandoned or the registration process failed.', 'event_espresso'); |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | * @return string|void |
298 | 298 | * @throws \EE_Error |
299 | 299 | */ |
300 | - public function column_ATT_email( EE_Transaction $item ){ |
|
300 | + public function column_ATT_email(EE_Transaction $item) { |
|
301 | 301 | $attendee = $item->primary_registration()->get_first_related('Attendee'); |
302 | - if ( ! empty( $attendee ) ) { |
|
303 | - return '<a href="mailto:' . $attendee->get( 'ATT_email' ) . '">' . $attendee->get( 'ATT_email' ) . '</a>'; |
|
302 | + if ( ! empty($attendee)) { |
|
303 | + return '<a href="mailto:'.$attendee->get('ATT_email').'">'.$attendee->get('ATT_email').'</a>'; |
|
304 | 304 | } else { |
305 | 305 | return $item->failed() || $item->is_abandoned() |
306 | - ? __( 'no contact record.', 'event_espresso' ) |
|
306 | + ? __('no contact record.', 'event_espresso') |
|
307 | 307 | : __( |
308 | 308 | 'No contact record, because the transaction was abandoned or the registration process failed.', |
309 | 309 | 'event_espresso' |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | * @return string|void |
321 | 321 | * @throws \EE_Error |
322 | 322 | */ |
323 | - public function column_event_name( EE_Transaction $item ){ |
|
323 | + public function column_event_name(EE_Transaction $item) { |
|
324 | 324 | $actions = array(); |
325 | 325 | $event = $item->primary_registration()->get_first_related('Event'); |
326 | - if ( !empty( $event ) ) { |
|
327 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$event->ID() ), EVENTS_ADMIN_URL ); |
|
326 | + if ( ! empty($event)) { |
|
327 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$event->ID()), EVENTS_ADMIN_URL); |
|
328 | 328 | $event_name = $event->get('EVT_name'); |
329 | 329 | |
330 | 330 | //filter this view by transactions for this event |
331 | - $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event->ID() ) ); |
|
332 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $event->ID() ) ) { |
|
333 | - $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '" title="' . esc_attr__('Filter transactions by this event', 'event_espresso') . '">' . __('View Transactions for this event', 'event_espresso') . '</a>'; |
|
331 | + $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'EVT_ID' => $event->ID())); |
|
332 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID())) { |
|
333 | + $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'" title="'.esc_attr__('Filter transactions by this event', 'event_espresso').'">'.__('View Transactions for this event', 'event_espresso').'</a>'; |
|
334 | 334 | } |
335 | 335 | |
336 | - return sprintf('%1$s %2$s', EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $event->ID() ) ? '<a href="' . $edit_event_url . '" title="' . sprintf( esc_attr__( 'Edit Event: %s', 'event_espresso' ), $event->get('EVT_name') ) .'">' . wp_trim_words( $event_name, 30, '...' ) . '</a>' : wp_trim_words( $event_name, 30, '...' ), $this->row_actions($actions) ); |
|
336 | + return sprintf('%1$s %2$s', EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID()) ? '<a href="'.$edit_event_url.'" title="'.sprintf(esc_attr__('Edit Event: %s', 'event_espresso'), $event->get('EVT_name')).'">'.wp_trim_words($event_name, 30, '...').'</a>' : wp_trim_words($event_name, 30, '...'), $this->row_actions($actions)); |
|
337 | 337 | } else { |
338 | 338 | return __('The event associated with this transaction via the primary registration cannot be retrieved.', 'event_espresso'); |
339 | 339 | } |
@@ -348,35 +348,35 @@ discard block |
||
348 | 348 | * @return string |
349 | 349 | * @throws \EE_Error |
350 | 350 | */ |
351 | - public function column_actions( EE_Transaction $item ){ |
|
351 | + public function column_actions(EE_Transaction $item) { |
|
352 | 352 | |
353 | 353 | $registration = $item->primary_registration(); |
354 | 354 | $attendee = $registration->attendee(); |
355 | 355 | |
356 | 356 | //Build row actions |
357 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
357 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
358 | 358 | $dl_invoice_lnk_url = $registration->invoice_url(); |
359 | 359 | $dl_receipt_lnk_url = $registration->receipt_url(); |
360 | - $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$registration->ID() ), REG_ADMIN_URL ); |
|
361 | - $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'send_payment_reminder', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
362 | - $related_messages_link = EEH_MSG_Template::get_message_action_link( 'see_notifications_for', null, array( |
|
360 | + $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$registration->ID()), REG_ADMIN_URL); |
|
361 | + $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'send_payment_reminder', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
362 | + $related_messages_link = EEH_MSG_Template::get_message_action_link('see_notifications_for', null, array( |
|
363 | 363 | 'TXN_ID' => $item->ID() |
364 | 364 | )); |
365 | 365 | |
366 | 366 | //Build row actions |
367 | 367 | $view_lnk = ' |
368 | 368 | <li> |
369 | - <a href="'.$view_lnk_url.'" title="' . esc_attr__( 'View Transaction Details', 'event_espresso' ) . '" class="tiny-text"> |
|
369 | + <a href="'.$view_lnk_url.'" title="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text"> |
|
370 | 370 | <span class="dashicons dashicons-cart"></span> |
371 | 371 | </a> |
372 | 372 | </li>'; |
373 | 373 | |
374 | 374 | $dl_invoice_lnk = ''; |
375 | 375 | //only show invoice link if message type is active. |
376 | - if ( $attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active( 'invoice' ) ) { |
|
376 | + if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('invoice')) { |
|
377 | 377 | $dl_invoice_lnk = ' |
378 | 378 | <li> |
379 | - <a title="' . esc_attr__( 'View Transaction Invoice', 'event_espresso' ) . '" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
379 | + <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
380 | 380 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
381 | 381 | </a> |
382 | 382 | </li>'; |
@@ -384,17 +384,17 @@ discard block |
||
384 | 384 | |
385 | 385 | $dl_receipt_lnk = ''; |
386 | 386 | //only show receipt link if message type is active. |
387 | - if ( $attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active( 'receipt' ) ) { |
|
387 | + if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('receipt')) { |
|
388 | 388 | $dl_receipt_lnk = ' |
389 | 389 | <li> |
390 | - <a title="' . esc_attr__( 'View Transaction Receipt', 'event_espresso' ) . '" target="_blank" href="'.$dl_receipt_lnk_url.'" class="tiny-text"> |
|
390 | + <a title="' . esc_attr__('View Transaction Receipt', 'event_espresso').'" target="_blank" href="'.$dl_receipt_lnk_url.'" class="tiny-text"> |
|
391 | 391 | <span class="dashicons dashicons-media-default ee-icon-size-18"></span> |
392 | 392 | </a> |
393 | 393 | </li>'; |
394 | 394 | } |
395 | 395 | |
396 | 396 | //only show payment reminder link if the message type is active. |
397 | - if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) { |
|
397 | + if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
398 | 398 | $send_pay_lnk = $attendee instanceof EE_Attendee |
399 | 399 | && EE_Registry::instance()->CAP->current_user_can( |
400 | 400 | 'ee_send_message', |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | ) |
403 | 403 | ? ' |
404 | 404 | <li> |
405 | - <a href="'.$send_pay_lnk_url.'" title="' . esc_attr__( 'Send Payment Reminder', 'event_espresso' ) . '" class="tiny-text"> |
|
405 | + <a href="'.$send_pay_lnk_url.'" title="'.esc_attr__('Send Payment Reminder', 'event_espresso').'" class="tiny-text"> |
|
406 | 406 | <span class="dashicons dashicons-email-alt"></span> |
407 | 407 | </a> |
408 | 408 | </li>' |
@@ -422,18 +422,18 @@ discard block |
||
422 | 422 | ) |
423 | 423 | ? ' |
424 | 424 | <li> |
425 | - <a href="'.$view_reg_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '" class="tiny-text"> |
|
425 | + <a href="'.$view_reg_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text"> |
|
426 | 426 | <span class="dashicons dashicons-clipboard"></span> |
427 | 427 | </a> |
428 | 428 | </li>' |
429 | 429 | : ''; |
430 | 430 | |
431 | 431 | $view_related_messages_lnk = ''; |
432 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
433 | - $view_related_messages_lnk = '<li>' . $related_messages_link . '</li>'; |
|
432 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
433 | + $view_related_messages_lnk = '<li>'.$related_messages_link.'</li>'; |
|
434 | 434 | } |
435 | 435 | |
436 | - return $this->_action_string( $view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk . $view_related_messages_lnk, $item, 'ul', 'txn-overview-actions-ul' ); |
|
436 | + return $this->_action_string($view_lnk.$dl_invoice_lnk.$dl_receipt_lnk.$view_reg_lnk.$send_pay_lnk.$view_related_messages_lnk, $item, 'ul', 'txn-overview-actions-ul'); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 |
@@ -31,29 +31,29 @@ discard block |
||
31 | 31 | <tbody> |
32 | 32 | <tr> |
33 | 33 | <td> |
34 | - <h2><?php printf( esc_html__( 'Hello, %s:', 'event_espresso' ), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]' ); ?></h2> |
|
35 | - <p class="lead"><?php esc_html_e( "We'd like to remind you that you still owe money for the following transaction:", 'event_espresso' ); ?></p> |
|
36 | - <h3><?php esc_html_e( 'Payment Details:', 'event_espresso' ); ?></h3> |
|
34 | + <h2><?php printf(esc_html__('Hello, %s:', 'event_espresso'), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]'); ?></h2> |
|
35 | + <p class="lead"><?php esc_html_e("We'd like to remind you that you still owe money for the following transaction:", 'event_espresso'); ?></p> |
|
36 | + <h3><?php esc_html_e('Payment Details:', 'event_espresso'); ?></h3> |
|
37 | 37 | <ul> |
38 | 38 | <li> |
39 | - <strong><?php esc_html_e( 'Payment Status:', 'event_espresso' ); ?></strong> [PAYMENT_STATUS] |
|
39 | + <strong><?php esc_html_e('Payment Status:', 'event_espresso'); ?></strong> [PAYMENT_STATUS] |
|
40 | 40 | </li> |
41 | 41 | <li> |
42 | - <strong><?php esc_html_e( 'Transaction ID:', 'event_espresso' ); ?></strong> [TXN_ID] |
|
42 | + <strong><?php esc_html_e('Transaction ID:', 'event_espresso'); ?></strong> [TXN_ID] |
|
43 | 43 | </li> |
44 | 44 | <li> |
45 | - <strong><?php esc_html_e( 'Total Cost:', 'event_espresso' ); ?></strong> [TOTAL_COST] |
|
45 | + <strong><?php esc_html_e('Total Cost:', 'event_espresso'); ?></strong> [TOTAL_COST] |
|
46 | 46 | </li> |
47 | 47 | <li> |
48 | - <strong><?php esc_html_e( 'Amount Due:', 'event_espresso' ); ?></strong> [TOTAL_OWING] |
|
48 | + <strong><?php esc_html_e('Amount Due:', 'event_espresso'); ?></strong> [TOTAL_OWING] |
|
49 | 49 | </li> |
50 | 50 | </ul> |
51 | 51 | <p class="callout"> |
52 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
52 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
53 | 53 | </p> |
54 | 54 | [EVENT_LIST] |
55 | 55 | <p class="callout"> |
56 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
56 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
57 | 57 | </p> |
58 | 58 | </td> |
59 | 59 | </tr> |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | <tbody> |
79 | 79 | <tr> |
80 | 80 | <td> |
81 | - <h3><?php esc_html_e( 'Connect with Us:', 'event_espresso' ); ?></h3> |
|
82 | - <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e( 'Facebook', 'event_espresso' ); ?></a> |
|
83 | - <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e( 'Twitter', 'event_espresso' ); ?></a> |
|
84 | - <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e( 'Google+', 'event_espresso' ); ?></a> |
|
81 | + <h3><?php esc_html_e('Connect with Us:', 'event_espresso'); ?></h3> |
|
82 | + <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e('Facebook', 'event_espresso'); ?></a> |
|
83 | + <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e('Twitter', 'event_espresso'); ?></a> |
|
84 | + <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e('Google+', 'event_espresso'); ?></a> |
|
85 | 85 | </td> |
86 | 86 | </tr> |
87 | 87 | </tbody> |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | <tbody> |
92 | 92 | <tr> |
93 | 93 | <td> |
94 | - <h3><?php esc_html_e( 'Contact Info:', 'event_espresso' ); ?></h3> |
|
95 | - <?php esc_html_e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong> |
|
96 | - <?php esc_html_e( 'Email:', 'event_espresso' ); ?> |
|
94 | + <h3><?php esc_html_e('Contact Info:', 'event_espresso'); ?></h3> |
|
95 | + <?php esc_html_e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong> |
|
96 | + <?php esc_html_e('Email:', 'event_espresso'); ?> |
|
97 | 97 | <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong> |
98 | 98 | </td> |
99 | 99 | </tr> |