@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * |
4 | 6 | * EED_Add_New_State class |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @return EED_Add_New_State |
17 | 17 | */ |
18 | 18 | public static function instance() { |
19 | - return parent::get_instance( __CLASS__ ); |
|
19 | + return parent::get_instance(__CLASS__); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | * @return void |
28 | 28 | */ |
29 | 29 | public static function set_hooks() { |
30 | - add_action( 'wp_loaded', array( 'EED_Add_New_State', 'set_definitions' ), 2 ); |
|
31 | - add_action( 'wp_enqueue_scripts', array( 'EED_Add_New_State', 'translate_js_strings' ), 0 ); |
|
32 | - add_action( 'wp_enqueue_scripts', array( 'EED_Add_New_State', 'wp_enqueue_scripts' ), 10 ); |
|
33 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
34 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
35 | - add_filter( 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array( 'EED_Add_New_State', 'unset_new_state_request_params' ), 10, 1 ); |
|
36 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array( 'EED_Add_New_State', 'inject_new_reg_state_into_options' ), 10, 5 ); |
|
37 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array( 'EED_Add_New_State', 'inject_new_reg_country_into_options' ), 10, 5 ); |
|
38 | - add_filter( 'FHEE__EE_State_Select_Input____construct__state_options', array( 'EED_Add_New_State', 'state_options' ), 10, 1 ); |
|
39 | - add_filter( 'FHEE__EE_Country_Select_Input____construct__country_options', array( 'EED_Add_New_State', 'country_options' ), 10, 1 ); |
|
30 | + add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
31 | + add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0); |
|
32 | + add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10); |
|
33 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
34 | + add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
35 | + add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
36 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
37 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
38 | + add_filter('FHEE__EE_State_Select_Input____construct__state_options', array('EED_Add_New_State', 'state_options'), 10, 1); |
|
39 | + add_filter('FHEE__EE_Country_Select_Input____construct__country_options', array('EED_Add_New_State', 'country_options'), 10, 1); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,20 +46,20 @@ discard block |
||
46 | 46 | * @return void |
47 | 47 | */ |
48 | 48 | public static function set_hooks_admin() { |
49 | - add_action( 'wp_loaded', array( 'EED_Add_New_State', 'set_definitions' ), 2 ); |
|
50 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
51 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
52 | - add_action( 'wp_ajax_espresso_add_new_state', array( 'EED_Add_New_State', 'add_new_state' )); |
|
53 | - add_action( 'wp_ajax_nopriv_espresso_add_new_state', array( 'EED_Add_New_State', 'add_new_state' )); |
|
54 | - add_filter( 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array( 'EED_Add_New_State', 'unset_new_state_request_params' ), 10, 1 ); |
|
55 | - add_action( 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', array( 'EED_Add_New_State', 'update_country_settings' ), 10, 3 ); |
|
56 | - add_action( 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', array( 'EED_Add_New_State', 'update_country_settings' ), 10, 3 ); |
|
57 | - add_filter( 'FHEE__EE_State_Select_Input____construct__state_options', array( 'EED_Add_New_State', 'state_options' ), 10, 1 ); |
|
58 | - add_filter( 'FHEE__EE_Country_Select_Input____construct__country_options', array( 'EED_Add_New_State', 'country_options' ), 10, 1 ); |
|
49 | + add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
50 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
51 | + add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
52 | + add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
53 | + add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
54 | + add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
55 | + add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
56 | + add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
57 | + add_filter('FHEE__EE_State_Select_Input____construct__state_options', array('EED_Add_New_State', 'state_options'), 10, 1); |
|
58 | + add_filter('FHEE__EE_Country_Select_Input____construct__country_options', array('EED_Add_New_State', 'country_options'), 10, 1); |
|
59 | 59 | //add_filter( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', array( 'EED_Add_New_State', 'filter_checkout_request_params' ), 10, 1 ); |
60 | - add_filter( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', array( 'EED_Add_New_State', 'filter_checkout_request_params' ), 10, 1 ); |
|
61 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array( 'EED_Add_New_State', 'inject_new_reg_state_into_options' ), 10, 5 ); |
|
62 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array( 'EED_Add_New_State', 'inject_new_reg_country_into_options' ), 10, 5 ); |
|
60 | + add_filter('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1); |
|
61 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
62 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @return void |
72 | 72 | */ |
73 | 73 | public static function set_definitions() { |
74 | - define( 'ANS_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
75 | - define( 'ANS_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
74 | + define('ANS_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
75 | + define('ANS_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param \WP $WP |
85 | 85 | * @return void |
86 | 86 | */ |
87 | - public function run( $WP ) { |
|
87 | + public function run($WP) { |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * @return void |
113 | 113 | */ |
114 | 114 | public static function wp_enqueue_scripts() { |
115 | - if ( apply_filters( 'EED_Single_Page_Checkout__SPCO_active', false ) ) { |
|
116 | - wp_register_script( 'add_new_state', ANS_ASSETS_URL . 'add_new_state.js', array( 'espresso_core', 'single_page_checkout' ), EVENT_ESPRESSO_VERSION, true ); |
|
117 | - wp_enqueue_script( 'add_new_state' ); |
|
115 | + if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) { |
|
116 | + wp_register_script('add_new_state', ANS_ASSETS_URL.'add_new_state.js', array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true); |
|
117 | + wp_enqueue_script('add_new_state'); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -128,34 +128,34 @@ discard block |
||
128 | 128 | * @return string |
129 | 129 | */ |
130 | 130 | // public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){ |
131 | - public static function display_add_new_state_micro_form( EE_Form_Section_Proper $question_group_reg_form ){ |
|
131 | + public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form) { |
|
132 | 132 | // only add the 'new_state_micro_form' when displaying reg forms, |
133 | 133 | // not during processing since we process the 'new_state_micro_form' in it's own AJAX request |
134 | - $action = EE_Registry::instance()->REQ->get( 'action', '' ); |
|
134 | + $action = EE_Registry::instance()->REQ->get('action', ''); |
|
135 | 135 | // is the "state" question in this form section? |
136 | - $input = $question_group_reg_form->get_subsection( 'state' ); |
|
137 | - if ( $action === 'process_reg_step' || $action === 'update_reg_step' ) { |
|
136 | + $input = $question_group_reg_form->get_subsection('state'); |
|
137 | + if ($action === 'process_reg_step' || $action === 'update_reg_step') { |
|
138 | 138 | //ok then all we need to do is make sure the input's HTML name is consistent |
139 | 139 | //by forcing it to set it now, like it did while getting the form for display |
140 | - if( $input instanceof EE_State_Select_Input ) { |
|
140 | + if ($input instanceof EE_State_Select_Input) { |
|
141 | 141 | $input->html_name(); |
142 | 142 | } |
143 | 143 | return $question_group_reg_form; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // we're only doing this for state select inputs |
147 | - if ( $input instanceof EE_State_Select_Input ) { |
|
147 | + if ($input instanceof EE_State_Select_Input) { |
|
148 | 148 | // grab any set values from the request |
149 | - $country_name = str_replace( 'state', 'nsmf_new_state_country', $input->html_name() ); |
|
150 | - $state_name = str_replace( 'state', 'nsmf_new_state_name', $input->html_name() ); |
|
151 | - $abbrv_name = str_replace( 'state', 'nsmf_new_state_abbrv', $input->html_name() ); |
|
152 | - $new_state_submit_id = str_replace( 'state', 'new_state', $input->html_id() ); |
|
149 | + $country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name()); |
|
150 | + $state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name()); |
|
151 | + $abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name()); |
|
152 | + $new_state_submit_id = str_replace('state', 'new_state', $input->html_id()); |
|
153 | 153 | $country_options = array(); |
154 | 154 | $countries = EEM_Country::instance()->get_all_countries(); |
155 | - if ( ! empty( $countries )) { |
|
156 | - foreach( $countries as $country ){ |
|
157 | - if ( $country instanceof EE_Country ) { |
|
158 | - $country_options[ $country->ID() ] = $country->name(); |
|
155 | + if ( ! empty($countries)) { |
|
156 | + foreach ($countries as $country) { |
|
157 | + if ($country instanceof EE_Country) { |
|
158 | + $country_options[$country->ID()] = $country->name(); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | // add hidden input to indicate that a new state is being added |
169 | 169 | 'add_new_state' => new EE_Hidden_Input( |
170 | 170 | array( |
171 | - 'html_name' => str_replace( 'state', 'nsmf_add_new_state', $input->html_name() ), |
|
172 | - 'html_id' => str_replace( 'state', 'nsmf_add_new_state', $input->html_id() ), |
|
171 | + 'html_name' => str_replace('state', 'nsmf_add_new_state', $input->html_name()), |
|
172 | + 'html_id' => str_replace('state', 'nsmf_add_new_state', $input->html_id()), |
|
173 | 173 | 'default' => 0 |
174 | 174 | ) |
175 | 175 | ), |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | '', |
182 | 182 | __('click here to add a new state/province', 'event_espresso'), |
183 | 183 | '', |
184 | - 'display-' . $input->html_id(), |
|
184 | + 'display-'.$input->html_id(), |
|
185 | 185 | 'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js', |
186 | 186 | '', |
187 | - 'data-target="' . $input->html_id() . '"' |
|
187 | + 'data-target="'.$input->html_id().'"' |
|
188 | 188 | ) |
189 | 189 | ) |
190 | 190 | ), |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | 'add_new_state_micro_form' =>new EE_Form_Section_HTML( |
193 | 193 | apply_filters( |
194 | 194 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form', |
195 | - EEH_HTML::div( '', $input->html_id() . '-dv', 'ee-form-add-new-state-dv', 'display: none;' ) . |
|
196 | - EEH_HTML::h6( __('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso')) . |
|
197 | - EEH_HTML::ul() . |
|
198 | - EEH_HTML::li( __('first select the Country that your State/Province belongs to', 'event_espresso') ) . |
|
199 | - EEH_HTML::li( __('enter the name of your State/Province', 'event_espresso') ) . |
|
200 | - EEH_HTML::li( __('enter a two to six letter abbreviation for the name of your State/Province', 'event_espresso') ) . |
|
201 | - EEH_HTML::li( __('click the ADD button', 'event_espresso') ) . |
|
195 | + EEH_HTML::div('', $input->html_id().'-dv', 'ee-form-add-new-state-dv', 'display: none;'). |
|
196 | + EEH_HTML::h6(__('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso')). |
|
197 | + EEH_HTML::ul(). |
|
198 | + EEH_HTML::li(__('first select the Country that your State/Province belongs to', 'event_espresso')). |
|
199 | + EEH_HTML::li(__('enter the name of your State/Province', 'event_espresso')). |
|
200 | + EEH_HTML::li(__('enter a two to six letter abbreviation for the name of your State/Province', 'event_espresso')). |
|
201 | + EEH_HTML::li(__('click the ADD button', 'event_espresso')). |
|
202 | 202 | EEH_HTML::ulx() |
203 | 203 | ) |
204 | 204 | ), |
@@ -207,10 +207,10 @@ discard block |
||
207 | 207 | $country_options, |
208 | 208 | array( |
209 | 209 | 'html_name' => $country_name, |
210 | - 'html_id' => str_replace( 'state', 'nsmf_new_state_country', $input->html_id() ), |
|
211 | - 'html_class' => $input->html_class() . ' new-state-country', |
|
210 | + 'html_id' => str_replace('state', 'nsmf_new_state_country', $input->html_id()), |
|
211 | + 'html_class' => $input->html_class().' new-state-country', |
|
212 | 212 | 'html_label_text' => __('New State/Province Country', 'event_espresso'), |
213 | - 'default' => EE_Registry::instance()->REQ->get( $country_name, '' ), |
|
213 | + 'default' => EE_Registry::instance()->REQ->get($country_name, ''), |
|
214 | 214 | 'required' => false |
215 | 215 | ) |
216 | 216 | ), |
@@ -218,23 +218,23 @@ discard block |
||
218 | 218 | 'new_state_name' => new EE_Text_Input( |
219 | 219 | array( |
220 | 220 | 'html_name' => $state_name, |
221 | - 'html_id' => str_replace( 'state', 'nsmf_new_state_name', $input->html_id() ), |
|
222 | - 'html_class' => $input->html_class() . ' new-state-state', |
|
221 | + 'html_id' => str_replace('state', 'nsmf_new_state_name', $input->html_id()), |
|
222 | + 'html_class' => $input->html_class().' new-state-state', |
|
223 | 223 | 'html_label_text' => __('New State/Province Name', 'event_espresso'), |
224 | - 'default' => EE_Registry::instance()->REQ->get( $state_name, '' ), |
|
224 | + 'default' => EE_Registry::instance()->REQ->get($state_name, ''), |
|
225 | 225 | 'required' => false |
226 | 226 | ) |
227 | 227 | ), |
228 | - 'spacer' => new EE_Form_Section_HTML( EEH_HTML::br() ), |
|
228 | + 'spacer' => new EE_Form_Section_HTML(EEH_HTML::br()), |
|
229 | 229 | // NEW STATE NAME |
230 | 230 | 'new_state_abbrv' => new EE_Text_Input( |
231 | 231 | array( |
232 | 232 | 'html_name' => $abbrv_name, |
233 | - 'html_id' => str_replace( 'state', 'nsmf_new_state_abbrv', $input->html_id() ), |
|
234 | - 'html_class' => $input->html_class() . ' new-state-abbrv', |
|
233 | + 'html_id' => str_replace('state', 'nsmf_new_state_abbrv', $input->html_id()), |
|
234 | + 'html_class' => $input->html_class().' new-state-abbrv', |
|
235 | 235 | 'html_label_text' => __('New State/Province Abbreviation', 'event_espresso'), |
236 | 236 | 'html_other_attributes' => 'size="24"', |
237 | - 'default' => EE_Registry::instance()->REQ->get( $abbrv_name, '' ), |
|
237 | + 'default' => EE_Registry::instance()->REQ->get($abbrv_name, ''), |
|
238 | 238 | 'required' => false |
239 | 239 | ) |
240 | 240 | ), |
@@ -242,15 +242,15 @@ discard block |
||
242 | 242 | 'add_new_state_submit_button' => new EE_Form_Section_HTML( |
243 | 243 | apply_filters( |
244 | 244 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button', |
245 | - EEH_HTML::nbsp(3) . |
|
245 | + EEH_HTML::nbsp(3). |
|
246 | 246 | EEH_HTML::link( |
247 | 247 | '', |
248 | 248 | __('ADD', 'event_espresso'), |
249 | 249 | '', |
250 | - 'submit-' . $new_state_submit_id, |
|
250 | + 'submit-'.$new_state_submit_id, |
|
251 | 251 | 'ee-form-add-new-state-submit button button-secondary', |
252 | 252 | '', |
253 | - 'data-target="' . $new_state_submit_id . '"' |
|
253 | + 'data-target="'.$new_state_submit_id.'"' |
|
254 | 254 | ) |
255 | 255 | ) |
256 | 256 | ), |
@@ -258,18 +258,18 @@ discard block |
||
258 | 258 | 'add_new_state_extra' => new EE_Form_Section_HTML( |
259 | 259 | apply_filters( |
260 | 260 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra', |
261 | - EEH_HTML::br(2) . |
|
262 | - EEH_HTML::div( '', '', 'small-text' ) . |
|
263 | - EEH_HTML::strong( __('Don\'t know your State/Province Abbreviation?', 'event_espresso') ) . |
|
264 | - EEH_HTML::br() . |
|
261 | + EEH_HTML::br(2). |
|
262 | + EEH_HTML::div('', '', 'small-text'). |
|
263 | + EEH_HTML::strong(__('Don\'t know your State/Province Abbreviation?', 'event_espresso')). |
|
264 | + EEH_HTML::br(). |
|
265 | 265 | sprintf( |
266 | 266 | __('You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).', 'event_espresso'), |
267 | - EEH_HTML::link( 'http://en.wikipedia.org/wiki/ISO_3166-2', 'http://en.wikipedia.org/wiki/ISO_3166-2', '', '', 'ee-form-add-new-state-wiki-lnk' ) |
|
268 | - ) . |
|
269 | - EEH_HTML::divx() . |
|
270 | - EEH_HTML::br() . |
|
271 | - EEH_HTML::link( '', __('cancel new state/province', 'event_espresso'), '', 'hide-' . $input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '', 'data-target="' . $input->html_id() . '"' ) . |
|
272 | - EEH_HTML::divx() . |
|
267 | + EEH_HTML::link('http://en.wikipedia.org/wiki/ISO_3166-2', 'http://en.wikipedia.org/wiki/ISO_3166-2', '', '', 'ee-form-add-new-state-wiki-lnk') |
|
268 | + ). |
|
269 | + EEH_HTML::divx(). |
|
270 | + EEH_HTML::br(). |
|
271 | + EEH_HTML::link('', __('cancel new state/province', 'event_espresso'), '', 'hide-'.$input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '', 'data-target="'.$input->html_id().'"'). |
|
272 | + EEH_HTML::divx(). |
|
273 | 273 | EEH_HTML::br() |
274 | 274 | ) |
275 | 275 | ) |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | ) |
278 | 278 | ) |
279 | 279 | ); |
280 | - $question_group_reg_form->add_subsections( array( 'new_state_micro_form' => $new_state_micro_form ), 'state', false ); |
|
280 | + $question_group_reg_form->add_subsections(array('new_state_micro_form' => $new_state_micro_form), 'state', false); |
|
281 | 281 | } |
282 | 282 | return $question_group_reg_form; |
283 | 283 | } |
@@ -295,50 +295,50 @@ discard block |
||
295 | 295 | public static function add_new_state() { |
296 | 296 | $REQ = EE_Registry::instance()->load_core('Request_Handler'); |
297 | 297 | if ( |
298 | - $REQ->is_set( 'nsmf_add_new_state' ) |
|
299 | - && $REQ->get( 'nsmf_add_new_state' ) == 1 |
|
298 | + $REQ->is_set('nsmf_add_new_state') |
|
299 | + && $REQ->get('nsmf_add_new_state') == 1 |
|
300 | 300 | ) { |
301 | 301 | EE_Registry::instance()->load_model('State'); |
302 | 302 | // grab country ISO code, new state name, and new state abbreviation |
303 | - $state_country = $REQ->is_set( 'nsmf_new_state_country' ) |
|
304 | - ? sanitize_text_field( $REQ->get( 'nsmf_new_state_country' ) ) |
|
303 | + $state_country = $REQ->is_set('nsmf_new_state_country') |
|
304 | + ? sanitize_text_field($REQ->get('nsmf_new_state_country')) |
|
305 | 305 | : false; |
306 | - $state_name = $REQ->is_set( 'nsmf_new_state_name' ) |
|
307 | - ? sanitize_text_field( $REQ->get( 'nsmf_new_state_name' ) ) |
|
306 | + $state_name = $REQ->is_set('nsmf_new_state_name') |
|
307 | + ? sanitize_text_field($REQ->get('nsmf_new_state_name')) |
|
308 | 308 | : false; |
309 | - $state_abbr = $REQ->is_set( 'nsmf_new_state_abbrv' ) |
|
310 | - ? sanitize_text_field( $REQ->get( 'nsmf_new_state_abbrv' ) ) |
|
309 | + $state_abbr = $REQ->is_set('nsmf_new_state_abbrv') |
|
310 | + ? sanitize_text_field($REQ->get('nsmf_new_state_abbrv')) |
|
311 | 311 | : false; |
312 | 312 | //echo '<h4>$state_country : ' . $state_country . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
313 | 313 | //echo '<h4>$state_name : ' . $state_name . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
314 | 314 | //echo '<h4>$state_abbr : ' . $state_abbr . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
315 | 315 | |
316 | - if ( $state_country && $state_name && $state_abbr ) { |
|
317 | - $new_state = EED_Add_New_State::save_new_state_to_db( array( |
|
318 | - 'CNT_ISO'=> strtoupper( $state_country ), |
|
319 | - 'STA_abbrev' => strtoupper( $state_abbr ), |
|
320 | - 'STA_name' => ucwords( $state_name ), |
|
316 | + if ($state_country && $state_name && $state_abbr) { |
|
317 | + $new_state = EED_Add_New_State::save_new_state_to_db(array( |
|
318 | + 'CNT_ISO'=> strtoupper($state_country), |
|
319 | + 'STA_abbrev' => strtoupper($state_abbr), |
|
320 | + 'STA_name' => ucwords($state_name), |
|
321 | 321 | 'STA_active' => FALSE |
322 | 322 | )); |
323 | 323 | |
324 | - if ( $new_state instanceof EE_State ) { |
|
324 | + if ($new_state instanceof EE_State) { |
|
325 | 325 | // clean house |
326 | - EE_Registry::instance()->REQ->un_set( 'nsmf_add_new_state' ); |
|
327 | - EE_Registry::instance()->REQ->un_set( 'nsmf_new_state_country' ); |
|
328 | - EE_Registry::instance()->REQ->un_set( 'nsmf_new_state_name' ); |
|
329 | - EE_Registry::instance()->REQ->un_set( 'nsmf_new_state_abbrv' ); |
|
326 | + EE_Registry::instance()->REQ->un_set('nsmf_add_new_state'); |
|
327 | + EE_Registry::instance()->REQ->un_set('nsmf_new_state_country'); |
|
328 | + EE_Registry::instance()->REQ->un_set('nsmf_new_state_name'); |
|
329 | + EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv'); |
|
330 | 330 | |
331 | 331 | // get any existing new states |
332 | 332 | $new_states = EE_Registry::instance()->SSN->get_session_data( |
333 | 333 | 'nsmf_new_states' |
334 | 334 | ); |
335 | - $new_states[ $new_state->ID() ] = $new_state; |
|
335 | + $new_states[$new_state->ID()] = $new_state; |
|
336 | 336 | EE_Registry::instance()->SSN->set_session_data( |
337 | - array( 'nsmf_new_states' => $new_states ) |
|
337 | + array('nsmf_new_states' => $new_states) |
|
338 | 338 | ); |
339 | 339 | |
340 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
341 | - echo json_encode( array( |
|
340 | + if (EE_Registry::instance()->REQ->ajax) { |
|
341 | + echo json_encode(array( |
|
342 | 342 | 'success' => TRUE, |
343 | 343 | 'id' => $new_state->ID(), |
344 | 344 | 'name' => $new_state->name(), |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | } else { |
356 | - $error = __( 'A new State/Province could not be added because invalid or missing data was received.', 'event_espresso' ); |
|
357 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
358 | - echo json_encode( array( 'error' => $error )); |
|
356 | + $error = __('A new State/Province could not be added because invalid or missing data was received.', 'event_espresso'); |
|
357 | + if (EE_Registry::instance()->REQ->ajax) { |
|
358 | + echo json_encode(array('error' => $error)); |
|
359 | 359 | exit(); |
360 | 360 | } else { |
361 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
361 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | } |
@@ -376,11 +376,11 @@ discard block |
||
376 | 376 | * @param array $request_params |
377 | 377 | * @return array |
378 | 378 | */ |
379 | - public static function filter_checkout_request_params ( $request_params ) { |
|
380 | - foreach ( $request_params as $form_section ) { |
|
381 | - if ( is_array( $form_section )) { |
|
382 | - EED_Add_New_State::unset_new_state_request_params( $form_section ); |
|
383 | - EED_Add_New_State::filter_checkout_request_params( $form_section ); |
|
379 | + public static function filter_checkout_request_params($request_params) { |
|
380 | + foreach ($request_params as $form_section) { |
|
381 | + if (is_array($form_section)) { |
|
382 | + EED_Add_New_State::unset_new_state_request_params($form_section); |
|
383 | + EED_Add_New_State::filter_checkout_request_params($form_section); |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | return $request_params; |
@@ -395,12 +395,12 @@ discard block |
||
395 | 395 | * @param array $request_params |
396 | 396 | * @return boolean |
397 | 397 | */ |
398 | - public static function unset_new_state_request_params ( $request_params ) { |
|
399 | - unset( $request_params[ 'new_state_micro_form' ] ); |
|
400 | - unset( $request_params[ 'new_state_micro_add_new_state' ] ); |
|
401 | - unset( $request_params[ 'new_state_micro_new_state_country' ] ); |
|
402 | - unset( $request_params[ 'new_state_micro_new_state_name' ] ); |
|
403 | - unset( $request_params[ 'new_state_micro_new_state_abbrv' ] ); |
|
398 | + public static function unset_new_state_request_params($request_params) { |
|
399 | + unset($request_params['new_state_micro_form']); |
|
400 | + unset($request_params['new_state_micro_add_new_state']); |
|
401 | + unset($request_params['new_state_micro_new_state_country']); |
|
402 | + unset($request_params['new_state_micro_new_state_name']); |
|
403 | + unset($request_params['new_state_micro_new_state_abbrv']); |
|
404 | 404 | return $request_params; |
405 | 405 | } |
406 | 406 | |
@@ -413,25 +413,25 @@ discard block |
||
413 | 413 | * @param array $props_n_values |
414 | 414 | * @return boolean |
415 | 415 | */ |
416 | - public static function save_new_state_to_db ( $props_n_values = array() ) { |
|
416 | + public static function save_new_state_to_db($props_n_values = array()) { |
|
417 | 417 | // EEH_Debug_Tools::printr( $props_n_values, '$props_n_values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
418 | - $existing_state = EEM_State::instance()->get_all( array( $props_n_values, 'limit' => 1 )); |
|
419 | - if ( ! empty( $existing_state )) { |
|
420 | - return array_pop( $existing_state ); |
|
418 | + $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1)); |
|
419 | + if ( ! empty($existing_state)) { |
|
420 | + return array_pop($existing_state); |
|
421 | 421 | } |
422 | - $new_state = EE_State::new_instance( $props_n_values ); |
|
423 | - if ( $new_state instanceof EE_State ) { |
|
422 | + $new_state = EE_State::new_instance($props_n_values); |
|
423 | + if ($new_state instanceof EE_State) { |
|
424 | 424 | // if not non-ajax admin |
425 | - $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(); |
|
425 | + $new_state_key = 'new-state-added-'.$new_state->country_iso().'-'.$new_state->abbrev(); |
|
426 | 426 | $new_state_notice = sprintf( |
427 | - __( 'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', 'event_espresso' ), |
|
428 | - '<b>' . $new_state->name() . '</b>', |
|
429 | - '<b>' . $new_state->abbrev() . '</b>', |
|
430 | - '<b>' . $new_state->country()->name() . '</b>', |
|
431 | - '<a href="' . add_query_arg( array( 'page' => 'espresso_general_settings', 'action' => 'country_settings', 'country' => $new_state->country_iso() ), admin_url( 'admin.php' )) . '">' . __( 'Event Espresso - General Settings > Countries Tab', 'event_espresso' ) . '</a>', |
|
427 | + __('A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', 'event_espresso'), |
|
428 | + '<b>'.$new_state->name().'</b>', |
|
429 | + '<b>'.$new_state->abbrev().'</b>', |
|
430 | + '<b>'.$new_state->country()->name().'</b>', |
|
431 | + '<a href="'.add_query_arg(array('page' => 'espresso_general_settings', 'action' => 'country_settings', 'country' => $new_state->country_iso()), admin_url('admin.php')).'">'.__('Event Espresso - General Settings > Countries Tab', 'event_espresso').'</a>', |
|
432 | 432 | '<br />' |
433 | 433 | ); |
434 | - EE_Error::add_persistent_admin_notice( $new_state_key, $new_state_notice ); |
|
434 | + EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice); |
|
435 | 435 | $new_state->save(); |
436 | 436 | EEM_State::instance()->reset_cached_states(); |
437 | 437 | return $new_state; |
@@ -450,22 +450,22 @@ discard block |
||
450 | 450 | * @param array $cols_n_values |
451 | 451 | * @return boolean |
452 | 452 | */ |
453 | - public static function update_country_settings( $CNT_ISO = '', $STA_ID = '', $cols_n_values = array() ) { |
|
454 | - $CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : FALSE; |
|
455 | - if ( ! $CNT_ISO ) { |
|
456 | - EE_Error::add_error( __( 'An invalid or missing Country ISO Code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
453 | + public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array()) { |
|
454 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : FALSE; |
|
455 | + if ( ! $CNT_ISO) { |
|
456 | + EE_Error::add_error(__('An invalid or missing Country ISO Code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
457 | 457 | } |
458 | - $STA_abbrev = is_array( $cols_n_values ) && isset( $cols_n_values['STA_abbrev'] ) ? $cols_n_values['STA_abbrev'] : FALSE; |
|
459 | - if ( ! $STA_abbrev && ! empty( $STA_ID )) { |
|
460 | - $state = EEM_State::instance()->get_one_by_ID( $STA_ID ); |
|
461 | - if ( $state instanceof EE_State ) { |
|
458 | + $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev'] : FALSE; |
|
459 | + if ( ! $STA_abbrev && ! empty($STA_ID)) { |
|
460 | + $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
461 | + if ($state instanceof EE_State) { |
|
462 | 462 | $STA_abbrev = $state->abbrev(); |
463 | 463 | } |
464 | 464 | } |
465 | - if ( ! $STA_abbrev ) { |
|
466 | - EE_Error::add_error( __( 'An invalid or missing State Abbreviation was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
465 | + if ( ! $STA_abbrev) { |
|
466 | + EE_Error::add_error(__('An invalid or missing State Abbreviation was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
467 | 467 | } |
468 | - EE_Error::dismiss_persistent_admin_notice( $CNT_ISO . '-' . $STA_abbrev, TRUE, TRUE ); |
|
468 | + EE_Error::dismiss_persistent_admin_notice($CNT_ISO.'-'.$STA_abbrev, TRUE, TRUE); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | |
@@ -481,19 +481,19 @@ discard block |
||
481 | 481 | * @param $answer |
482 | 482 | * @return bool |
483 | 483 | */ |
484 | - public static function inject_new_reg_state_into_options( $state_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer ) { |
|
485 | - if ( $answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_state ) { |
|
484 | + public static function inject_new_reg_state_into_options($state_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer) { |
|
485 | + if ($answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_state) { |
|
486 | 486 | $STA_ID = $answer->value(); |
487 | - if ( ! empty( $STA_ID ) ) { |
|
488 | - $state = EEM_State::instance()->get_one_by_ID( $STA_ID ); |
|
489 | - if ( $state instanceof EE_State ) { |
|
487 | + if ( ! empty($STA_ID)) { |
|
488 | + $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
489 | + if ($state instanceof EE_State) { |
|
490 | 490 | $country = $state->country(); |
491 | - if ( $country instanceof EE_Country ) { |
|
492 | - if ( ! isset( $state_options[ $country->name() ] )) { |
|
493 | - $state_options[ $country->name() ] = array(); |
|
491 | + if ($country instanceof EE_Country) { |
|
492 | + if ( ! isset($state_options[$country->name()])) { |
|
493 | + $state_options[$country->name()] = array(); |
|
494 | 494 | } |
495 | - if ( ! isset( $state_options[ $country->name() ][ $STA_ID ] )) { |
|
496 | - $state_options[ $country->name() ][ $STA_ID ] = $state->name(); |
|
495 | + if ( ! isset($state_options[$country->name()][$STA_ID])) { |
|
496 | + $state_options[$country->name()][$STA_ID] = $state->name(); |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
@@ -515,14 +515,14 @@ discard block |
||
515 | 515 | * @param $answer |
516 | 516 | * @return bool |
517 | 517 | */ |
518 | - public static function inject_new_reg_country_into_options( $country_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer ) { |
|
519 | - if ( $answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_country ) { |
|
518 | + public static function inject_new_reg_country_into_options($country_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer) { |
|
519 | + if ($answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_country) { |
|
520 | 520 | $CNT_ISO = $answer->value(); |
521 | - if ( ! empty( $CNT_ISO ) ) { |
|
522 | - $country = EEM_Country::instance()->get_one_by_ID( $CNT_ISO ); |
|
523 | - if ( $country instanceof EE_Country ) { |
|
524 | - if ( ! isset( $country_options[ $CNT_ISO ] ) ) { |
|
525 | - $country_options[ $CNT_ISO ] = $country->name(); |
|
521 | + if ( ! empty($CNT_ISO)) { |
|
522 | + $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
523 | + if ($country instanceof EE_Country) { |
|
524 | + if ( ! isset($country_options[$CNT_ISO])) { |
|
525 | + $country_options[$CNT_ISO] = $country->name(); |
|
526 | 526 | } |
527 | 527 | } |
528 | 528 | } |
@@ -539,14 +539,14 @@ discard block |
||
539 | 539 | * @param EE_State[] $state_options |
540 | 540 | * @return boolean |
541 | 541 | */ |
542 | - public static function state_options( $state_options = array() ) { |
|
542 | + public static function state_options($state_options = array()) { |
|
543 | 543 | $new_states = EED_Add_New_State::_get_new_states(); |
544 | - foreach ( $new_states as $new_state ) { |
|
544 | + foreach ($new_states as $new_state) { |
|
545 | 545 | if ( |
546 | 546 | $new_state instanceof EE_State |
547 | 547 | && $new_state->country() instanceof EE_Country |
548 | 548 | ) { |
549 | - $state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name(); |
|
549 | + $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name(); |
|
550 | 550 | } |
551 | 551 | } |
552 | 552 | return $state_options; |
@@ -562,12 +562,12 @@ discard block |
||
562 | 562 | */ |
563 | 563 | protected static function _get_new_states() { |
564 | 564 | $new_states = array(); |
565 | - if ( EE_Registry::instance()->SSN instanceof EE_Session ) { |
|
565 | + if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
566 | 566 | $new_states = EE_Registry::instance()->SSN->get_session_data( |
567 | 567 | 'nsmf_new_states' |
568 | 568 | ); |
569 | 569 | } |
570 | - return is_array( $new_states ) ? $new_states : array(); |
|
570 | + return is_array($new_states) ? $new_states : array(); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | |
@@ -579,14 +579,14 @@ discard block |
||
579 | 579 | * @param EE_Country[] $country_options |
580 | 580 | * @return boolean |
581 | 581 | */ |
582 | - public static function country_options( $country_options = array() ) { |
|
582 | + public static function country_options($country_options = array()) { |
|
583 | 583 | $new_states = EED_Add_New_State::_get_new_states(); |
584 | - foreach ( $new_states as $new_state ) { |
|
584 | + foreach ($new_states as $new_state) { |
|
585 | 585 | if ( |
586 | 586 | $new_state instanceof EE_State |
587 | 587 | && $new_state->country() instanceof EE_Country |
588 | 588 | ) { |
589 | - $country_options[ $new_state->country()->ID() ] = $new_state->country()->name(); |
|
589 | + $country_options[$new_state->country()->ID()] = $new_state->country()->name(); |
|
590 | 590 | } |
591 | 591 | } |
592 | 592 | return $country_options; |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | * @param string $CNT_ISO |
449 | 449 | * @param string $STA_ID |
450 | 450 | * @param array $cols_n_values |
451 | - * @return boolean |
|
451 | + * @return boolean|null |
|
452 | 452 | */ |
453 | 453 | public static function update_country_settings( $CNT_ISO = '', $STA_ID = '', $cols_n_values = array() ) { |
454 | 454 | $CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : FALSE; |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * |
538 | 538 | * @access public |
539 | 539 | * @param EE_State[] $state_options |
540 | - * @return boolean |
|
540 | + * @return EE_State[] |
|
541 | 541 | */ |
542 | 542 | public static function state_options( $state_options = array() ) { |
543 | 543 | $new_states = EED_Add_New_State::_get_new_states(); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @since 4.5.0 |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Model_Form_Section extends EE_Form_Section_Proper{ |
|
14 | +class EE_Model_Form_Section extends EE_Form_Section_Proper { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * |
@@ -36,36 +36,36 @@ discard block |
||
36 | 36 | * } |
37 | 37 | * @throws EE_Error |
38 | 38 | */ |
39 | - public function __construct($options_array = array()){ |
|
40 | - if(isset($options_array['model']) && $options_array['model'] instanceof EEM_Base){ |
|
39 | + public function __construct($options_array = array()) { |
|
40 | + if (isset($options_array['model']) && $options_array['model'] instanceof EEM_Base) { |
|
41 | 41 | $this->_model = $options_array['model']; |
42 | 42 | } |
43 | - if( ! $this->_model || ! $this->_model instanceof EEM_Base ){ |
|
43 | + if ( ! $this->_model || ! $this->_model instanceof EEM_Base) { |
|
44 | 44 | throw new EE_Error(sprintf(__("Model Form Sections must first specify the _model property to be a subclass of EEM_Base", "event_espresso"))); |
45 | 45 | } |
46 | 46 | |
47 | - if(isset($options_array['subsection_args'])){ |
|
47 | + if (isset($options_array['subsection_args'])) { |
|
48 | 48 | $subsection_args = $options_array['subsection_args']; |
49 | - }else{ |
|
49 | + } else { |
|
50 | 50 | $subsection_args = array(); |
51 | 51 | } |
52 | 52 | |
53 | 53 | //gather fields and relations to convert to inputs |
54 | 54 | //but if they're just going to exclude a field anyways, don't bother converting it to an input |
55 | 55 | $exclude = $this->_subsections; |
56 | - if(isset($options_array['exclude'])){ |
|
57 | - $exclude = array_merge($exclude,array_flip($options_array['exclude'])); |
|
56 | + if (isset($options_array['exclude'])) { |
|
57 | + $exclude = array_merge($exclude, array_flip($options_array['exclude'])); |
|
58 | 58 | } |
59 | 59 | $model_fields = array_diff_key($this->_model->field_settings(), $exclude); |
60 | 60 | $model_relations = array_diff_key($this->_model->relation_settings(), $exclude); |
61 | 61 | //convert fields and relations to inputs |
62 | 62 | $this->_subsections = array_merge( |
63 | 63 | $this->_convert_model_fields_to_inputs($model_fields), |
64 | - $this->_convert_model_relations_to_inputs($model_relations,$subsection_args), |
|
64 | + $this->_convert_model_relations_to_inputs($model_relations, $subsection_args), |
|
65 | 65 | $this->_subsections |
66 | 66 | ); |
67 | 67 | parent::__construct($options_array); |
68 | - if(isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class){ |
|
68 | + if (isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class) { |
|
69 | 69 | $this->populate_model_obj($options_array['model_object']); |
70 | 70 | } |
71 | 71 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * } |
84 | 84 | * @return array |
85 | 85 | */ |
86 | - protected function _convert_model_relations_to_inputs($relations,$subsection_args = array()){ |
|
86 | + protected function _convert_model_relations_to_inputs($relations, $subsection_args = array()) { |
|
87 | 87 | $inputs = array(); |
88 | - foreach( $relations as $relation_name => $relation_obj ) { |
|
88 | + foreach ($relations as $relation_name => $relation_obj) { |
|
89 | 89 | $input_constructor_args = array( |
90 | 90 | array_merge( |
91 | 91 | array( |
@@ -96,19 +96,19 @@ discard block |
||
96 | 96 | ) |
97 | 97 | ); |
98 | 98 | $input = NULL; |
99 | - switch(get_class($relation_obj)){ |
|
99 | + switch (get_class($relation_obj)) { |
|
100 | 100 | case 'EE_HABTM_Relation': |
101 | - if(isset($subsection_args[$relation_name]) && |
|
102 | - isset($subsection_args[$relation_name]['model_objects'])){ |
|
101 | + if (isset($subsection_args[$relation_name]) && |
|
102 | + isset($subsection_args[$relation_name]['model_objects'])) { |
|
103 | 103 | $model_objects = $subsection_args[$relation_name]['model_objects']; |
104 | - }else{ |
|
104 | + } else { |
|
105 | 105 | $model_objects = $relation_obj->get_other_model()->get_all(); |
106 | 106 | } |
107 | - $input = new EE_Select_Multi_Model_Input($model_objects,$input_constructor_args); |
|
107 | + $input = new EE_Select_Multi_Model_Input($model_objects, $input_constructor_args); |
|
108 | 108 | break; |
109 | 109 | default: |
110 | 110 | } |
111 | - if($input){ |
|
111 | + if ($input) { |
|
112 | 112 | $inputs[$relation_name] = $input; |
113 | 113 | } |
114 | 114 | } |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | * @throws EE_Error |
124 | 124 | * @return EE_Form_Input_Base[] |
125 | 125 | */ |
126 | - protected function _convert_model_fields_to_inputs( $model_fields = array() ){ |
|
126 | + protected function _convert_model_fields_to_inputs($model_fields = array()) { |
|
127 | 127 | $inputs = array(); |
128 | - foreach( $model_fields as $field_name=>$model_field ){ |
|
129 | - if ( $model_field instanceof EE_Model_Field_Base ) { |
|
128 | + foreach ($model_fields as $field_name=>$model_field) { |
|
129 | + if ($model_field instanceof EE_Model_Field_Base) { |
|
130 | 130 | $input_constructor_args = array( |
131 | 131 | array( |
132 | 132 | 'required'=> ! $model_field->is_nullable() && $model_field->get_default_value() === NULL, |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | 'default'=>$model_field->get_default_value(), |
135 | 135 | ) |
136 | 136 | ); |
137 | - switch(get_class($model_field)){ |
|
137 | + switch (get_class($model_field)) { |
|
138 | 138 | case 'EE_All_Caps_Text_Field': |
139 | 139 | case 'EE_Any_Foreign_Model_Name_Field': |
140 | 140 | $input_class = 'EE_Text_Input'; |
@@ -143,16 +143,16 @@ discard block |
||
143 | 143 | $input_class = 'EE_Yes_No_Input'; |
144 | 144 | break; |
145 | 145 | case 'EE_Datetime_Field': |
146 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
146 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
147 | 147 | break; |
148 | 148 | case 'EE_Email_Field': |
149 | 149 | $input_class = 'EE_Email_Input'; |
150 | 150 | break; |
151 | 151 | case 'EE_Enum_Integer_Field': |
152 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
152 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
153 | 153 | break; |
154 | 154 | case 'EE_Enum_Text_Field': |
155 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
155 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
156 | 156 | break; |
157 | 157 | case 'EE_Float_Field': |
158 | 158 | $input_class = 'EE_Float_Input'; |
@@ -161,15 +161,15 @@ discard block |
||
161 | 161 | case 'EE_Foreign_Key_String_Field': |
162 | 162 | case 'EE_WP_User_Field': |
163 | 163 | $models_pointed_to = $model_field instanceof EE_Field_With_Model_Name ? $model_field->get_model_class_names_pointed_to() : array(); |
164 | - if(true || is_array($models_pointed_to) && count($models_pointed_to) > 1){ |
|
164 | + if (true || is_array($models_pointed_to) && count($models_pointed_to) > 1) { |
|
165 | 165 | $input_class = 'EE_Text_Input'; |
166 | - }else{ |
|
166 | + } else { |
|
167 | 167 | //so its just one model |
168 | 168 | $model_name = is_array($models_pointed_to) ? reset($models_pointed_to) : $models_pointed_to; |
169 | 169 | $model = EE_Registry::instance()->load_model($model_name); |
170 | 170 | $model_names = $model->get_all_names(array('limit'=>10)); |
171 | - if($model_field->is_nullable()){ |
|
172 | - array_unshift( $model_names, __( "Please Select", 'event_espresso' )); |
|
171 | + if ($model_field->is_nullable()) { |
|
172 | + array_unshift($model_names, __("Please Select", 'event_espresso')); |
|
173 | 173 | } |
174 | 174 | $input_constructor_args[1] = $input_constructor_args[0]; |
175 | 175 | $input_constructor_args[0] = $model_names; |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | break; |
179 | 179 | case 'EE_Full_HTML_Field': |
180 | 180 | $input_class = 'EE_Text_Area_Input'; |
181 | - $input_constructor_args[ 0 ]['validation_strategies'] = array( new EE_Full_HTML_Validation_Strategy() ); |
|
181 | + $input_constructor_args[0]['validation_strategies'] = array(new EE_Full_HTML_Validation_Strategy()); |
|
182 | 182 | break; |
183 | 183 | case 'EE_Infinite_Integer': |
184 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
184 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
185 | 185 | break; |
186 | 186 | case 'EE_Integer_Field': |
187 | 187 | $input_class = 'EE_Text_Input'; |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | $input_class = 'EE_Text_Area_Input'; |
191 | 191 | break; |
192 | 192 | case 'EE_Money_Field': |
193 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
193 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
194 | 194 | break; |
195 | 195 | case 'EE_Post_Content_Field': |
196 | 196 | $input_class = 'EE_Text_Area_Input'; |
197 | - $input_constructor_args[ 0 ][ 'validation_strategies' ] = array( new EE_Full_HTML_Validation_Strategy() ); |
|
197 | + $input_constructor_args[0]['validation_strategies'] = array(new EE_Full_HTML_Validation_Strategy()); |
|
198 | 198 | break; |
199 | 199 | case 'EE_Plain_Text_Field': |
200 | 200 | $input_class = 'EE_Text_Input'; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | break; |
212 | 212 | case 'EE_Simple_HTML_Field': |
213 | 213 | $input_class = 'EE_Text_Area_Input'; |
214 | - $input_constructor_args[ 0 ][ 'validation_strategies' ] = array( new EE_Simple_HTML_Validation_Strategy() ); |
|
214 | + $input_constructor_args[0]['validation_strategies'] = array(new EE_Simple_HTML_Validation_Strategy()); |
|
215 | 215 | break; |
216 | 216 | case 'EE_Slug_Field': |
217 | 217 | $input_class = 'EE_Text_Input'; |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | $input_class = 'EE_Yes_No_Input'; |
221 | 221 | break; |
222 | 222 | case 'EE_WP_Post_Status_Field': |
223 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
223 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
224 | 224 | break; |
225 | 225 | case 'EE_WP_Post_Type_Field': |
226 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
226 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
227 | 227 | break; |
228 | 228 | default: |
229 | - throw new EE_Error(sprintf(__("Model field of type '%s' does not convert to any known Form Input. Please add a case to EE_Model_Form_section's _convert_model_fields_to_inputs switch statement", "event_espresso"),get_class($model_field))); |
|
229 | + throw new EE_Error(sprintf(__("Model field of type '%s' does not convert to any known Form Input. Please add a case to EE_Model_Form_section's _convert_model_fields_to_inputs switch statement", "event_espresso"), get_class($model_field))); |
|
230 | 230 | } |
231 | 231 | $reflection = new ReflectionClass($input_class); |
232 | 232 | $input = $reflection->newInstanceArgs($input_constructor_args); |
@@ -245,21 +245,21 @@ discard block |
||
245 | 245 | * @param EE_Base_Class $model_obj |
246 | 246 | * @return void |
247 | 247 | */ |
248 | - public function populate_model_obj($model_obj){ |
|
248 | + public function populate_model_obj($model_obj) { |
|
249 | 249 | $model_obj = $this->_model->ensure_is_obj($model_obj); |
250 | 250 | $this->_model_object = $model_obj; |
251 | 251 | $defaults = $model_obj->model_field_array(); |
252 | - foreach($this->_model->relation_settings() as $relation_name => $relation_obj){ |
|
252 | + foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) { |
|
253 | 253 | $form_inputs = $this->inputs(); |
254 | - if(isset($form_inputs[$relation_name])){ |
|
255 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
254 | + if (isset($form_inputs[$relation_name])) { |
|
255 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
256 | 256 | //then we only expect there to be one |
257 | 257 | $related_item = $this->_model_object->get_first_related($relation_name); |
258 | 258 | $defaults[$relation_name] = $related_item->ID(); |
259 | - }else{ |
|
259 | + } else { |
|
260 | 260 | $related_items = $this->_model_object->get_many_related($relation_name); |
261 | 261 | $ids = array(); |
262 | - foreach($related_items as $related_item){ |
|
262 | + foreach ($related_items as $related_item) { |
|
263 | 263 | $ids[] = $related_item->ID(); |
264 | 264 | } |
265 | 265 | $defaults[$relation_name] = $ids; |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * values are their normalized values |
282 | 282 | * @return array |
283 | 283 | */ |
284 | - public function inputs_values_corresponding_to_model_fields(){ |
|
285 | - return array_intersect_key($this->input_values(),$this->_model->field_settings()); |
|
284 | + public function inputs_values_corresponding_to_model_fields() { |
|
285 | + return array_intersect_key($this->input_values(), $this->_model->field_settings()); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -293,17 +293,17 @@ discard block |
||
293 | 293 | * @param array $req_data should usually be $_REQUEST (the default). |
294 | 294 | * @return void |
295 | 295 | */ |
296 | - public function _normalize( $req_data ) { |
|
297 | - parent::_normalize( $req_data ); |
|
296 | + public function _normalize($req_data) { |
|
297 | + parent::_normalize($req_data); |
|
298 | 298 | //create or set the model object, if it isn't already |
299 | - if( ! $this->_model_object ){ |
|
299 | + if ( ! $this->_model_object) { |
|
300 | 300 | //check to see if the form indicates a PK, in which case we want to only retrieve it and update it |
301 | 301 | $pk_name = $this->_model->primary_key_name(); |
302 | 302 | $model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name)); |
303 | - if($model_obj){ |
|
303 | + if ($model_obj) { |
|
304 | 304 | $this->_model_object = $model_obj; |
305 | - }else{ |
|
306 | - $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name() ); |
|
305 | + } else { |
|
306 | + $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name()); |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | } |
@@ -318,24 +318,24 @@ discard block |
||
318 | 318 | * @return int, 1 on a successful update, the ID of |
319 | 319 | * the new entry on insert; 0 on failure |
320 | 320 | */ |
321 | - public function save(){ |
|
322 | - if( ! $this->_model_object){ |
|
323 | - throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"),get_class($this->_model))); |
|
321 | + public function save() { |
|
322 | + if ( ! $this->_model_object) { |
|
323 | + throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"), get_class($this->_model))); |
|
324 | 324 | } |
325 | 325 | //ok so the model object is set. Just set it with the submitted form data |
326 | - foreach($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value){ |
|
326 | + foreach ($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value) { |
|
327 | 327 | //only set the non-primary key |
328 | - if($field_name != $this->_model->primary_key_name()){ |
|
329 | - $this->_model_object->set($field_name,$field_value); |
|
328 | + if ($field_name != $this->_model->primary_key_name()) { |
|
329 | + $this->_model_object->set($field_name, $field_value); |
|
330 | 330 | } |
331 | 331 | } |
332 | - $success = $this->_model_object->save(); |
|
333 | - foreach($this->_model->relation_settings() as $relation_name => $relation_obj){ |
|
334 | - if(isset($this->_subsections[$relation_name])){ |
|
332 | + $success = $this->_model_object->save(); |
|
333 | + foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) { |
|
334 | + if (isset($this->_subsections[$relation_name])) { |
|
335 | 335 | $success = $this->_save_related_info($relation_name); |
336 | 336 | } |
337 | 337 | } |
338 | - do_action( 'AHEE__EE_Model_Form_Section__save__done', $this, $success ); |
|
338 | + do_action('AHEE__EE_Model_Form_Section__save__done', $this, $success); |
|
339 | 339 | return $success; |
340 | 340 | } |
341 | 341 | |
@@ -348,29 +348,29 @@ discard block |
||
348 | 348 | * @return bool |
349 | 349 | * @throws EE_Error |
350 | 350 | */ |
351 | - protected function _save_related_info($relation_name){ |
|
351 | + protected function _save_related_info($relation_name) { |
|
352 | 352 | $relation_obj = $this->_model->related_settings_for($relation_name); |
353 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
353 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
354 | 354 | //there is just a foreign key on this model pointing to that one |
355 | 355 | $this->_model_object->_add_relation_to($this->get_input_value($relation_name), $relation_name); |
356 | - }elseif($relation_obj instanceof EE_Has_Many_Relation){ |
|
356 | + }elseif ($relation_obj instanceof EE_Has_Many_Relation) { |
|
357 | 357 | //then we want to consider all of its currently-related things. |
358 | 358 | //if they're in this list, keep them |
359 | 359 | //if they're not in this list, remove them |
360 | 360 | //and lastly add all the new items |
361 | 361 | throw new EE_Error(sprintf(__('Automatic saving of related info across a "has many" relation is not yet supported', "event_espresso"))); |
362 | - }elseif($relation_obj instanceof EE_HABTM_Relation){ |
|
362 | + }elseif ($relation_obj instanceof EE_HABTM_Relation) { |
|
363 | 363 | //delete everything NOT in this list |
364 | 364 | $normalized_input_value = $this->get_input_value($relation_name); |
365 | - if($normalized_input_value && is_array($normalized_input_value)){ |
|
365 | + if ($normalized_input_value && is_array($normalized_input_value)) { |
|
366 | 366 | $where_query_params = array( |
367 | - $relation_obj->get_other_model()->primary_key_name() => array('NOT_IN',$normalized_input_value)); |
|
368 | - }else{ |
|
367 | + $relation_obj->get_other_model()->primary_key_name() => array('NOT_IN', $normalized_input_value)); |
|
368 | + } else { |
|
369 | 369 | $where_query_params = array(); |
370 | 370 | } |
371 | - $this->_model_object->_remove_relations( $relation_name, $where_query_params ); |
|
372 | - foreach($normalized_input_value as $id){ |
|
373 | - $this->_model_object->_add_relation_to( $id, $relation_name ); |
|
371 | + $this->_model_object->_remove_relations($relation_name, $where_query_params); |
|
372 | + foreach ($normalized_input_value as $id) { |
|
373 | + $this->_model_object->_add_relation_to($id, $relation_name); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | return TRUE; |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * Gets the model of this model form |
383 | 383 | * @return EEM_Base |
384 | 384 | */ |
385 | - public function get_model(){ |
|
385 | + public function get_model() { |
|
386 | 386 | return $this->_model; |
387 | 387 | } |
388 | 388 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * when receive_form_submission($req_data) was called. |
396 | 396 | * @return EE_Base_Class |
397 | 397 | */ |
398 | - public function get_model_object(){ |
|
398 | + public function get_model_object() { |
|
399 | 399 | return $this->_model_object; |
400 | 400 | } |
401 | 401 | |
@@ -405,10 +405,10 @@ discard block |
||
405 | 405 | * gets teh default name of this form section if none is specified |
406 | 406 | * @return string |
407 | 407 | */ |
408 | - protected function _set_default_name_if_empty(){ |
|
409 | - if( ! $this->_name ){ |
|
410 | - $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
411 | - $this->_name = $default_name; |
|
408 | + protected function _set_default_name_if_empty() { |
|
409 | + if ( ! $this->_name) { |
|
410 | + $default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form"; |
|
411 | + $this->_name = $default_name; |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
45 | 45 | * @return \Payments_Admin_Page |
46 | 46 | */ |
47 | - public function __construct( $routing = TRUE ) { |
|
48 | - parent::__construct( $routing ); |
|
47 | + public function __construct($routing = TRUE) { |
|
48 | + parent::__construct($routing); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | protected function _set_page_config() { |
131 | 131 | $payment_method_list_config = array( |
132 | 132 | 'nav' => array( |
133 | - 'label' => __( 'Payment Methods', 'event_espresso' ), |
|
133 | + 'label' => __('Payment Methods', 'event_espresso'), |
|
134 | 134 | 'order' => 10 |
135 | 135 | ), |
136 | 136 | 'metaboxes' => $this->_default_espresso_metaboxes, |
137 | 137 | 'help_tabs' => array_merge( |
138 | 138 | array( |
139 | 139 | 'payment_methods_overview_help_tab' => array( |
140 | - 'title' => __( 'Payment Methods Overview', 'event_espresso' ), |
|
140 | + 'title' => __('Payment Methods Overview', 'event_espresso'), |
|
141 | 141 | 'filename' => 'payment_methods_overview' |
142 | 142 | ) |
143 | 143 | ), |
144 | 144 | $this->_add_payment_method_help_tabs() ), |
145 | - 'help_tour' => array( 'Payment_Methods_Selection_Help_Tour' ), |
|
145 | + 'help_tour' => array('Payment_Methods_Selection_Help_Tour'), |
|
146 | 146 | 'require_nonce' => false |
147 | 147 | ); |
148 | 148 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | ) |
161 | 161 | ), |
162 | 162 | //'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ), |
163 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
163 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
164 | 164 | 'require_nonce' => FALSE |
165 | 165 | ), |
166 | 166 | 'payment_log'=>array( |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | /** |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - protected function _add_payment_method_help_tabs(){ |
|
182 | + protected function _add_payment_method_help_tabs() { |
|
183 | 183 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
184 | 184 | $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
185 | 185 | $all_pmt_help_tabs_config = array(); |
186 | - foreach( $payment_method_types as $payment_method_type ){ |
|
187 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $payment_method_type->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
186 | + foreach ($payment_method_types as $payment_method_type) { |
|
187 | + if ( ! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(), 'specific_payment_method_type_access')) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | - foreach( $payment_method_type->help_tabs_config() as $help_tab_name => $config ){ |
|
191 | - $template_args = isset( $config[ 'template_args' ] ) ? $config[ 'template_args' ] : array(); |
|
192 | - $template_args[ 'admin_page_obj' ] = $this; |
|
190 | + foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
191 | + $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
|
192 | + $template_args['admin_page_obj'] = $this; |
|
193 | 193 | $all_pmt_help_tabs_config[$help_tab_name] = array( |
194 | 194 | 'title'=>$config['title'], |
195 | 195 | 'content'=>EEH_Template::display_template( |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | |
217 | 217 | |
218 | 218 | public function load_scripts_styles() { |
219 | - wp_enqueue_script( 'ee_admin_js' ); |
|
220 | - wp_enqueue_script( 'ee-text-links' ); |
|
221 | - wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
219 | + wp_enqueue_script('ee_admin_js'); |
|
220 | + wp_enqueue_script('ee-text-links'); |
|
221 | + wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | |
228 | 228 | public function load_scripts_styles_default() { |
229 | 229 | //styles |
230 | - wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION ); |
|
231 | - wp_enqueue_style( 'espresso_payments' ); |
|
232 | - wp_enqueue_style( 'ee-text-links' ); |
|
230 | + wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION); |
|
231 | + wp_enqueue_style('espresso_payments'); |
|
232 | + wp_enqueue_style('ee-text-links'); |
|
233 | 233 | //scripts |
234 | 234 | } |
235 | 235 | |
@@ -243,44 +243,44 @@ discard block |
||
243 | 243 | * to the loading process. However, people MUST setup the details for the payment method so its safe to do a |
244 | 244 | * recheck here. |
245 | 245 | */ |
246 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
246 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
247 | 247 | EEM_Payment_Method::instance()->verify_button_urls(); |
248 | 248 | //setup tabs, one for each payment method type |
249 | 249 | $tabs = array(); |
250 | 250 | $payment_methods = array(); |
251 | - foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) { |
|
251 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
252 | 252 | // we don't want to show admin-only PMTs for now |
253 | - if ( $pmt_obj instanceof EE_PMT_Admin_Only ) { |
|
253 | + if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
254 | 254 | continue; |
255 | 255 | } |
256 | 256 | //check access |
257 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
257 | + if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) { |
|
258 | 258 | continue; |
259 | 259 | } |
260 | 260 | //check for any active pms of that type |
261 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() ); |
|
262 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
261 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
262 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
263 | 263 | $payment_method = EE_Payment_Method::new_instance( |
264 | 264 | array( |
265 | - 'PMD_slug' =>sanitize_key( $pmt_obj->system_name() ), |
|
265 | + 'PMD_slug' =>sanitize_key($pmt_obj->system_name()), |
|
266 | 266 | 'PMD_type' =>$pmt_obj->system_name(), |
267 | 267 | 'PMD_name' =>$pmt_obj->pretty_name(), |
268 | 268 | 'PMD_admin_name' =>$pmt_obj->pretty_name() |
269 | 269 | ) |
270 | 270 | ); |
271 | 271 | } |
272 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
272 | + $payment_methods[$payment_method->slug()] = $payment_method; |
|
273 | 273 | } |
274 | - $payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods ); |
|
275 | - foreach( $payment_methods as $payment_method ) { |
|
276 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
274 | + $payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods); |
|
275 | + foreach ($payment_methods as $payment_method) { |
|
276 | + if ($payment_method instanceof EE_Payment_Method) { |
|
277 | 277 | add_meta_box( |
278 | 278 | //html id |
279 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
279 | + 'espresso_'.$payment_method->slug().'_payment_settings', |
|
280 | 280 | //title |
281 | - sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
281 | + sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
282 | 282 | //callback |
283 | - array( $this, 'payment_method_settings_meta_box' ), |
|
283 | + array($this, 'payment_method_settings_meta_box'), |
|
284 | 284 | //post type |
285 | 285 | null, |
286 | 286 | //context |
@@ -288,19 +288,19 @@ discard block |
||
288 | 288 | //priority |
289 | 289 | 'default', |
290 | 290 | //callback args |
291 | - array( 'payment_method' => $payment_method ) |
|
291 | + array('payment_method' => $payment_method) |
|
292 | 292 | ); |
293 | 293 | //setup for tabbed content |
294 | - $tabs[ $payment_method->slug() ] = array( |
|
294 | + $tabs[$payment_method->slug()] = array( |
|
295 | 295 | 'label' => $payment_method->admin_name(), |
296 | 296 | 'class' => $payment_method->active() ? 'gateway-active' : '', |
297 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
298 | - 'title' => __( 'Modify this Payment Method', 'event_espresso' ), |
|
297 | + 'href' => 'espresso_'.$payment_method->slug().'_payment_settings', |
|
298 | + 'title' => __('Modify this Payment Method', 'event_espresso'), |
|
299 | 299 | 'slug' => $payment_method->slug() |
300 | 300 | ); |
301 | 301 | } |
302 | 302 | } |
303 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() ); |
|
303 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug()); |
|
304 | 304 | $this->display_admin_page_with_sidebar(); |
305 | 305 | |
306 | 306 | } |
@@ -311,20 +311,20 @@ discard block |
||
311 | 311 | * _get_active_payment_method_slug |
312 | 312 | * @return string |
313 | 313 | */ |
314 | - protected function _get_active_payment_method_slug(){ |
|
314 | + protected function _get_active_payment_method_slug() { |
|
315 | 315 | $payment_method_slug = FALSE; |
316 | 316 | //decide which payment method tab to open first, as dictated by the request's 'payment_method' |
317 | - if ( isset( $this->_req_data['payment_method'] )) { |
|
317 | + if (isset($this->_req_data['payment_method'])) { |
|
318 | 318 | // if they provided the current payment method, use it |
319 | - $payment_method_slug = sanitize_key( $this->_req_data['payment_method'] ); |
|
319 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
320 | 320 | } |
321 | - $payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug ))); |
|
321 | + $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
322 | 322 | // if that didn't work or wasn't provided, find another way to select the current pm |
323 | - if ( ! $this->_verify_payment_method( $payment_method )) { |
|
323 | + if ( ! $this->_verify_payment_method($payment_method)) { |
|
324 | 324 | // like, looking for an active one |
325 | - $payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' ); |
|
325 | + $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
326 | 326 | // test that one as well |
327 | - if ( $this->_verify_payment_method( $payment_method )) { |
|
327 | + if ($this->_verify_payment_method($payment_method)) { |
|
328 | 328 | $payment_method_slug = $payment_method->slug(); |
329 | 329 | } else { |
330 | 330 | $payment_method_slug = 'paypal_standard'; |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | * @param \EE_Payment_Method $payment_method |
343 | 343 | * @return boolean |
344 | 344 | */ |
345 | - protected function _verify_payment_method( $payment_method ){ |
|
345 | + protected function _verify_payment_method($payment_method) { |
|
346 | 346 | if ( |
347 | 347 | $payment_method instanceof EE_Payment_Method && |
348 | 348 | $payment_method->type_obj() instanceof EE_PMT_Base && |
349 | - EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' ) |
|
349 | + EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access') |
|
350 | 350 | ) { |
351 | 351 | return TRUE; |
352 | 352 | } |
@@ -363,21 +363,21 @@ discard block |
||
363 | 363 | * @return string |
364 | 364 | * @throws EE_Error |
365 | 365 | */ |
366 | - public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){ |
|
367 | - $payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL; |
|
368 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
369 | - throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' ))); |
|
366 | + public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) { |
|
367 | + $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL; |
|
368 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
369 | + throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso'))); |
|
370 | 370 | } |
371 | 371 | $payment_method_scopes = $payment_method->active(); |
372 | 372 | // if the payment method really exists show its form, otherwise the activation template |
373 | - if ( $payment_method->ID() && ! empty( $payment_method_scopes )) { |
|
374 | - $form = $this->_generate_payment_method_settings_form( $payment_method ); |
|
375 | - if ( $form->form_data_present_in( $this->_req_data )) { |
|
376 | - $form->receive_form_submission( $this->_req_data ); |
|
373 | + if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
374 | + $form = $this->_generate_payment_method_settings_form($payment_method); |
|
375 | + if ($form->form_data_present_in($this->_req_data)) { |
|
376 | + $form->receive_form_submission($this->_req_data); |
|
377 | 377 | } |
378 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
378 | + echo $form->form_open().$form->get_html_and_js().$form->form_close(); |
|
379 | 379 | } else { |
380 | - echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js(); |
|
380 | + echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
@@ -390,14 +390,14 @@ discard block |
||
390 | 390 | * @param \EE_Payment_Method $payment_method |
391 | 391 | * @return \EE_Form_Section_Proper |
392 | 392 | */ |
393 | - protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) { |
|
394 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
393 | + protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) { |
|
394 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
395 | 395 | return new EE_Form_Section_Proper(); |
396 | 396 | } |
397 | 397 | return new EE_Form_Section_Proper( |
398 | 398 | array( |
399 | - 'name' => $payment_method->slug() . '_settings_form', |
|
400 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
399 | + 'name' => $payment_method->slug().'_settings_form', |
|
400 | + 'html_id' => $payment_method->slug().'_settings_form', |
|
401 | 401 | 'action' => EE_Admin_Page::add_query_args_and_nonce( |
402 | 402 | array( |
403 | 403 | 'action' => 'update_payment_method', |
@@ -409,12 +409,12 @@ discard block |
||
409 | 409 | 'subsections' => apply_filters( |
410 | 410 | 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
411 | 411 | array( |
412 | - 'pci_dss_compliance_' . $payment_method->slug() => $this->_pci_dss_compliance( $payment_method ), |
|
413 | - 'currency_support_' . $payment_method->slug() => $this->_currency_support( $payment_method ), |
|
414 | - 'payment_method_settings_' . $payment_method->slug() => $this->_payment_method_settings( $payment_method ), |
|
415 | - 'update_' . $payment_method->slug() => $this->_update_payment_method_button( $payment_method ), |
|
416 | - 'deactivate_' . $payment_method->slug() => $this->_deactivate_payment_method_button( $payment_method ), |
|
417 | - 'fine_print_' . $payment_method->slug() => $this->_fine_print() |
|
412 | + 'pci_dss_compliance_'.$payment_method->slug() => $this->_pci_dss_compliance($payment_method), |
|
413 | + 'currency_support_'.$payment_method->slug() => $this->_currency_support($payment_method), |
|
414 | + 'payment_method_settings_'.$payment_method->slug() => $this->_payment_method_settings($payment_method), |
|
415 | + 'update_'.$payment_method->slug() => $this->_update_payment_method_button($payment_method), |
|
416 | + 'deactivate_'.$payment_method->slug() => $this->_deactivate_payment_method_button($payment_method), |
|
417 | + 'fine_print_'.$payment_method->slug() => $this->_fine_print() |
|
418 | 418 | ), |
419 | 419 | $payment_method |
420 | 420 | ) |
@@ -431,19 +431,19 @@ discard block |
||
431 | 431 | * @param \EE_Payment_Method $payment_method |
432 | 432 | * @return \EE_Form_Section_Proper |
433 | 433 | */ |
434 | - protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) { |
|
435 | - if ( $payment_method->type_obj()->requires_https() ) { |
|
434 | + protected function _pci_dss_compliance(EE_Payment_Method $payment_method) { |
|
435 | + if ($payment_method->type_obj()->requires_https()) { |
|
436 | 436 | return new EE_Form_Section_HTML( |
437 | 437 | EEH_HTML::tr( |
438 | 438 | EEH_HTML::th( |
439 | 439 | EEH_HTML::label( |
440 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
440 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
441 | 441 | ) |
442 | - ) . |
|
442 | + ). |
|
443 | 443 | EEH_HTML::td( |
444 | - EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) . |
|
445 | - EEH_HTML::br() . |
|
446 | - __( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' )) |
|
444 | + EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')). |
|
445 | + EEH_HTML::br(). |
|
446 | + __('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso')) |
|
447 | 447 | ) |
448 | 448 | ) |
449 | 449 | ); |
@@ -461,19 +461,19 @@ discard block |
||
461 | 461 | * @param \EE_Payment_Method $payment_method |
462 | 462 | * @return \EE_Form_Section_Proper |
463 | 463 | */ |
464 | - protected function _currency_support( EE_Payment_Method $payment_method ) { |
|
465 | - if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) { |
|
464 | + protected function _currency_support(EE_Payment_Method $payment_method) { |
|
465 | + if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
466 | 466 | return new EE_Form_Section_HTML( |
467 | 467 | EEH_HTML::tr( |
468 | 468 | EEH_HTML::th( |
469 | 469 | EEH_HTML::label( |
470 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
470 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
471 | 471 | ) |
472 | - ) . |
|
472 | + ). |
|
473 | 473 | EEH_HTML::td( |
474 | 474 | EEH_HTML::strong( |
475 | 475 | sprintf( |
476 | - __( 'This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
476 | + __('This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
477 | 477 | EE_Config::instance()->currency->code |
478 | 478 | ) |
479 | 479 | ) |
@@ -493,9 +493,9 @@ discard block |
||
493 | 493 | * @param \EE_Payment_Method $payment_method |
494 | 494 | * @return \EE_Form_Section_HTML |
495 | 495 | */ |
496 | - protected function _payment_method_settings( EE_Payment_Method $payment_method ) { |
|
496 | + protected function _payment_method_settings(EE_Payment_Method $payment_method) { |
|
497 | 497 | //modify the form so we only have/show fields that will be implemented for this version |
498 | - return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() ); |
|
498 | + return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | * @return \EE_Payment_Method_Form |
509 | 509 | * @throws \EE_Error |
510 | 510 | */ |
511 | - protected function _simplify_form( $form_section, $payment_method_name = '' ){ |
|
512 | - if ( $form_section instanceof EE_Payment_Method_Form ) { |
|
511 | + protected function _simplify_form($form_section, $payment_method_name = '') { |
|
512 | + if ($form_section instanceof EE_Payment_Method_Form) { |
|
513 | 513 | $form_section->exclude( |
514 | 514 | array( |
515 | 515 | 'PMD_type', //dont want them changing the type |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | ); |
521 | 521 | return $form_section; |
522 | 522 | } else { |
523 | - throw new EE_Error( sprintf( __( 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso' ), $payment_method_name )); |
|
523 | + throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name)); |
|
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
@@ -533,19 +533,19 @@ discard block |
||
533 | 533 | * @param \EE_Payment_Method $payment_method |
534 | 534 | * @return \EE_Form_Section_HTML |
535 | 535 | */ |
536 | - protected function _update_payment_method_button( EE_Payment_Method $payment_method ) { |
|
536 | + protected function _update_payment_method_button(EE_Payment_Method $payment_method) { |
|
537 | 537 | $update_button = new EE_Submit_Input( |
538 | 538 | array( |
539 | 539 | 'name' => 'submit', |
540 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
541 | - 'default' => sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
540 | + 'html_id' => 'save_'.$payment_method->slug().'_settings', |
|
541 | + 'default' => sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()), |
|
542 | 542 | 'html_label' => EEH_HTML::nbsp() |
543 | 543 | ) |
544 | 544 | ); |
545 | 545 | return new EE_Form_Section_HTML( |
546 | - EEH_HTML::no_row( EEH_HTML::br(2) ) . |
|
546 | + EEH_HTML::no_row(EEH_HTML::br(2)). |
|
547 | 547 | EEH_HTML::tr( |
548 | - EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) . |
|
548 | + EEH_HTML::th(__('Update Settings', 'event_espresso')). |
|
549 | 549 | EEH_HTML::td( |
550 | 550 | $update_button->get_html_for_input() |
551 | 551 | ) |
@@ -562,11 +562,11 @@ discard block |
||
562 | 562 | * @param \EE_Payment_Method $payment_method |
563 | 563 | * @return \EE_Form_Section_Proper |
564 | 564 | */ |
565 | - protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
566 | - $link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() ); |
|
565 | + protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) { |
|
566 | + $link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name()); |
|
567 | 567 | return new EE_Form_Section_HTML( |
568 | 568 | EEH_HTML::tr( |
569 | - EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) . |
|
569 | + EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')). |
|
570 | 570 | EEH_HTML::td( |
571 | 571 | EEH_HTML::link( |
572 | 572 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | ), |
579 | 579 | $link_text_and_title, |
580 | 580 | $link_text_and_title, |
581 | - 'deactivate_' . $payment_method->slug(), |
|
581 | + 'deactivate_'.$payment_method->slug(), |
|
582 | 582 | 'espresso-button button-secondary' |
583 | 583 | ) |
584 | 584 | ) |
@@ -594,12 +594,12 @@ discard block |
||
594 | 594 | * @param \EE_Payment_Method $payment_method |
595 | 595 | * @return \EE_Form_Section_Proper |
596 | 596 | */ |
597 | - protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
598 | - $link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() ); |
|
597 | + protected function _activate_payment_method_button(EE_Payment_Method $payment_method) { |
|
598 | + $link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name()); |
|
599 | 599 | return new EE_Form_Section_Proper( |
600 | 600 | array( |
601 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
602 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
601 | + 'name' => 'activate_'.$payment_method->slug().'_settings_form', |
|
602 | + 'html_id' => 'activate_'.$payment_method->slug().'_settings_form', |
|
603 | 603 | 'action' => '#', |
604 | 604 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
605 | 605 | 'subsections' => apply_filters( |
@@ -607,17 +607,17 @@ discard block |
||
607 | 607 | array( |
608 | 608 | new EE_Form_Section_HTML( |
609 | 609 | EEH_HTML::tr( |
610 | - EEH_HTML::td( $payment_method->type_obj()->introductory_html(), |
|
610 | + EEH_HTML::td($payment_method->type_obj()->introductory_html(), |
|
611 | 611 | '', |
612 | 612 | '', |
613 | 613 | '', |
614 | 614 | 'colspan="2"' |
615 | 615 | ) |
616 | - ) . |
|
616 | + ). |
|
617 | 617 | EEH_HTML::tr( |
618 | 618 | EEH_HTML::th( |
619 | - EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' )) |
|
620 | - ) . |
|
619 | + EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
|
620 | + ). |
|
621 | 621 | EEH_HTML::td( |
622 | 622 | EEH_HTML::link( |
623 | 623 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | ), |
630 | 630 | $link_text_and_title, |
631 | 631 | $link_text_and_title, |
632 | - 'activate_' . $payment_method->slug(), |
|
632 | + 'activate_'.$payment_method->slug(), |
|
633 | 633 | 'espresso-button-green button-primary' |
634 | 634 | ) |
635 | 635 | ) |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | protected function _fine_print() { |
652 | 652 | return new EE_Form_Section_HTML( |
653 | 653 | EEH_HTML::tr( |
654 | - EEH_HTML::th() . |
|
654 | + EEH_HTML::th(). |
|
655 | 655 | EEH_HTML::td( |
656 | - EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' ) |
|
656 | + EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
657 | 657 | ) |
658 | 658 | ) |
659 | 659 | ); |
@@ -665,15 +665,15 @@ discard block |
||
665 | 665 | * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
666 | 666 | * @global WP_User $current_user |
667 | 667 | */ |
668 | - protected function _activate_payment_method(){ |
|
669 | - if(isset($this->_req_data['payment_method_type'])){ |
|
668 | + protected function _activate_payment_method() { |
|
669 | + if (isset($this->_req_data['payment_method_type'])) { |
|
670 | 670 | $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
671 | 671 | //see if one exists |
672 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
673 | - $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type ); |
|
672 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
673 | + $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type); |
|
674 | 674 | |
675 | - $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
|
676 | - }else{ |
|
675 | + $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug())); |
|
676 | + } else { |
|
677 | 677 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
678 | 678 | } |
679 | 679 | } |
@@ -681,14 +681,14 @@ discard block |
||
681 | 681 | /** |
682 | 682 | * Deactivates the payment method with the specified slug, and redirects. |
683 | 683 | */ |
684 | - protected function _deactivate_payment_method(){ |
|
685 | - if(isset($this->_req_data['payment_method'])){ |
|
684 | + protected function _deactivate_payment_method() { |
|
685 | + if (isset($this->_req_data['payment_method'])) { |
|
686 | 686 | $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
687 | 687 | //deactivate it |
688 | 688 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
689 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug ); |
|
690 | - $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug)); |
|
691 | - }else{ |
|
689 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
690 | + $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug)); |
|
691 | + } else { |
|
692 | 692 | $this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default')); |
693 | 693 | } |
694 | 694 | } |
@@ -702,46 +702,46 @@ discard block |
||
702 | 702 | * subsequently called 'headers_sent_func' which is _payment_methods_list) |
703 | 703 | * @return void |
704 | 704 | */ |
705 | - protected function _update_payment_method(){ |
|
706 | - if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
705 | + protected function _update_payment_method() { |
|
706 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
707 | 707 | //ok let's find which gateway form to use based on the form input |
708 | 708 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
709 | 709 | /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
710 | 710 | $correct_pmt_form_to_use = NULL; |
711 | 711 | $payment_method = NULL; |
712 | - foreach( EEM_Payment_Method::instance()->get_all() as $payment_method){ |
|
712 | + foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) { |
|
713 | 713 | //get the form and simplify it, like what we do when we display it |
714 | - $pmt_form = $this->_generate_payment_method_settings_form( $payment_method ); |
|
715 | - if($pmt_form->form_data_present_in($this->_req_data)){ |
|
714 | + $pmt_form = $this->_generate_payment_method_settings_form($payment_method); |
|
715 | + if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
716 | 716 | $correct_pmt_form_to_use = $pmt_form; |
717 | 717 | break; |
718 | 718 | } |
719 | 719 | } |
720 | 720 | //if we couldn't find the correct payment method type... |
721 | - if( ! $correct_pmt_form_to_use ){ |
|
721 | + if ( ! $correct_pmt_form_to_use) { |
|
722 | 722 | EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support", 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
723 | 723 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
724 | 724 | } |
725 | 725 | $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
726 | - if($correct_pmt_form_to_use->is_valid()){ |
|
727 | - $subsection_name = 'payment_method_settings_' . $payment_method->slug(); |
|
728 | - $payment_settings_subform = $correct_pmt_form_to_use->get_subsection( $subsection_name ); |
|
729 | - if( ! $payment_settings_subform instanceof EE_Payment_Method_Form ) { |
|
726 | + if ($correct_pmt_form_to_use->is_valid()) { |
|
727 | + $subsection_name = 'payment_method_settings_'.$payment_method->slug(); |
|
728 | + $payment_settings_subform = $correct_pmt_form_to_use->get_subsection($subsection_name); |
|
729 | + if ( ! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
730 | 730 | throw new EE_Error( |
731 | 731 | sprintf( |
732 | - __( 'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.','event_espresso' ), |
|
732 | + __('The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.', 'event_espresso'), |
|
733 | 733 | $subsection_name |
734 | 734 | ) |
735 | 735 | ); |
736 | 736 | } |
737 | 737 | $payment_settings_subform->save(); |
738 | 738 | /** @var $pm EE_Payment_Method */ |
739 | - $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
|
740 | - }else{ |
|
739 | + $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$payment_method->slug())); |
|
740 | + } else { |
|
741 | 741 | EE_Error::add_error( |
742 | 742 | sprintf( |
743 | 743 | __('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'), |
744 | - $payment_method instanceof EE_PMT_Base ? $payment_method->pretty_name() : __( '"(unknown)"', 'event_espresso' ) |
|
744 | + $payment_method instanceof EE_PMT_Base ? $payment_method->pretty_name() : __('"(unknown)"', 'event_espresso') |
|
745 | 745 | ), |
746 | 746 | __FILE__, |
747 | 747 | __FUNCTION__, |
@@ -758,11 +758,11 @@ discard block |
||
758 | 758 | protected function _payment_settings() { |
759 | 759 | |
760 | 760 | $this->_template_args['values'] = $this->_yes_no_values; |
761 | - $this->_template_args['show_pending_payment_options'] = isset( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) ? absint( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) : FALSE; |
|
761 | + $this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : FALSE; |
|
762 | 762 | |
763 | - $this->_set_add_edit_form_tags( 'update_payment_settings' ); |
|
764 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
765 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE ); |
|
763 | + $this->_set_add_edit_form_tags('update_payment_settings'); |
|
764 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
765 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE); |
|
766 | 766 | $this->display_admin_page_with_sidebar(); |
767 | 767 | |
768 | 768 | } |
@@ -776,8 +776,8 @@ discard block |
||
776 | 776 | * @return array |
777 | 777 | */ |
778 | 778 | protected function _update_payment_settings() { |
779 | - EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset( $this->_req_data['show_pending_payment_options'] ) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
780 | - EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG ); |
|
779 | + EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options']) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
780 | + EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG); |
|
781 | 781 | |
782 | 782 | // $superform = new EE_Form_Section_Proper( |
783 | 783 | // array( |
@@ -797,9 +797,9 @@ discard block |
||
797 | 797 | // $this->_redirect_after_action( 0, 'settings', 'updated', array( 'action' => 'payment_settings' ) ); |
798 | 798 | // } |
799 | 799 | |
800 | - $what = __('Payment Settings','event_espresso'); |
|
801 | - $success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ ); |
|
802 | - $this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) ); |
|
800 | + $what = __('Payment Settings', 'event_espresso'); |
|
801 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__); |
|
802 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings')); |
|
803 | 803 | |
804 | 804 | } |
805 | 805 | protected function _payment_log_overview_list_table() { |
@@ -825,18 +825,18 @@ discard block |
||
825 | 825 | * @param bool $count |
826 | 826 | * @return array |
827 | 827 | */ |
828 | - public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){ |
|
829 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
828 | + public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) { |
|
829 | + EE_Registry::instance()->load_model('Change_Log'); |
|
830 | 830 | //we may need to do multiple queries (joining differently), so we actually wan tan array of query params |
831 | - $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
831 | + $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
832 | 832 | //check if they've selected a specific payment method |
833 | - if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){ |
|
833 | + if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
834 | 834 | $query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'], |
835 | 835 | 'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']); |
836 | 836 | } |
837 | 837 | //take into account search |
838 | - if(isset($this->_req_data['s']) && $this->_req_data['s']){ |
|
839 | - $similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%'); |
|
838 | + if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
839 | + $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%'); |
|
840 | 840 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
841 | 841 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
842 | 842 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
@@ -851,48 +851,48 @@ discard block |
||
851 | 851 | $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
852 | 852 | |
853 | 853 | } |
854 | - if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){ |
|
854 | + if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) { |
|
855 | 855 | //add date |
856 | - $start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] ); |
|
857 | - $end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] ); |
|
856 | + $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
857 | + $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
858 | 858 | //make sure our timestamps start and end right at the boundaries for each day |
859 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
860 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
859 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
860 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
861 | 861 | |
862 | 862 | //convert to timestamps |
863 | - $start_date = strtotime( $start_date ); |
|
864 | - $end_date = strtotime( $end_date ); |
|
863 | + $start_date = strtotime($start_date); |
|
864 | + $end_date = strtotime($end_date); |
|
865 | 865 | |
866 | 866 | //makes sure start date is the lowest value and vice versa |
867 | - $start_date = min( $start_date, $end_date ); |
|
868 | - $end_date = max( $start_date, $end_date ); |
|
867 | + $start_date = min($start_date, $end_date); |
|
868 | + $end_date = max($start_date, $end_date); |
|
869 | 869 | |
870 | 870 | //convert for query |
871 | - $start_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' ); |
|
872 | - $end_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' ); |
|
871 | + $start_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
872 | + $end_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
873 | 873 | |
874 | - $query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date)); |
|
874 | + $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
875 | 875 | |
876 | 876 | } |
877 | - if($count){ |
|
877 | + if ($count) { |
|
878 | 878 | return EEM_Change_Log::instance()->count($query_params); |
879 | 879 | } |
880 | - if(isset($this->_req_data['order'])){ |
|
881 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
880 | + if (isset($this->_req_data['order'])) { |
|
881 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
882 | 882 | $query_params['order_by'] = array('LOG_time' => $sort); |
883 | - }else{ |
|
883 | + } else { |
|
884 | 884 | $query_params['order_by'] = array('LOG_time' => 'DESC'); |
885 | 885 | } |
886 | - $offset = ($current_page-1)*$per_page; |
|
886 | + $offset = ($current_page - 1) * $per_page; |
|
887 | 887 | |
888 | - if( ! isset($this->_req_data['download_results'])){ |
|
889 | - $query_params['limit'] = array( $offset, $per_page ); |
|
888 | + if ( ! isset($this->_req_data['download_results'])) { |
|
889 | + $query_params['limit'] = array($offset, $per_page); |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | |
893 | 893 | |
894 | 894 | //now they've requested to instead just download the file instead of viewing it. |
895 | - if(isset($this->_req_data['download_results'])){ |
|
895 | + if (isset($this->_req_data['download_results'])) { |
|
896 | 896 | $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
897 | 897 | header('Content-Disposition: attachment'); |
898 | 898 | header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url())); |
@@ -914,36 +914,36 @@ discard block |
||
914 | 914 | * @param EE_Change_Log $logB |
915 | 915 | * @return int |
916 | 916 | */ |
917 | - protected function _sort_logs_again($logA,$logB){ |
|
917 | + protected function _sort_logs_again($logA, $logB) { |
|
918 | 918 | $timeA = $logA->get_raw('LOG_time'); |
919 | 919 | $timeB = $logB->get_raw('LOG_time'); |
920 | - if($timeA == $timeB){ |
|
920 | + if ($timeA == $timeB) { |
|
921 | 921 | return 0; |
922 | 922 | } |
923 | 923 | $comparison = $timeA < $timeB ? -1 : 1; |
924 | - if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){ |
|
924 | + if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
925 | 925 | return $comparison * -1; |
926 | - }else{ |
|
926 | + } else { |
|
927 | 927 | return $comparison; |
928 | 928 | } |
929 | 929 | } |
930 | 930 | |
931 | 931 | protected function _payment_log_details() { |
932 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
932 | + EE_Registry::instance()->load_model('Change_Log'); |
|
933 | 933 | /** @var $payment_log EE_Change_Log */ |
934 | 934 | $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
935 | 935 | $payment_method = NULL; |
936 | 936 | $transaction = NULL; |
937 | - if( $payment_log instanceof EE_Change_Log ){ |
|
938 | - if( $payment_log->object() instanceof EE_Payment ){ |
|
937 | + if ($payment_log instanceof EE_Change_Log) { |
|
938 | + if ($payment_log->object() instanceof EE_Payment) { |
|
939 | 939 | $payment_method = $payment_log->object()->payment_method(); |
940 | 940 | $transaction = $payment_log->object()->transaction(); |
941 | - }elseif($payment_log->object() instanceof EE_Payment_Method){ |
|
941 | + }elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
942 | 942 | $payment_method = $payment_log->object(); |
943 | 943 | } |
944 | 944 | } |
945 | 945 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
946 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
946 | + EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php', |
|
947 | 947 | array( |
948 | 948 | 'payment_log'=>$payment_log, |
949 | 949 | 'payment_method'=>$payment_method, |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -673,7 +674,7 @@ discard block |
||
673 | 674 | $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type ); |
674 | 675 | |
675 | 676 | $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
676 | - }else{ |
|
677 | + } else{ |
|
677 | 678 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
678 | 679 | } |
679 | 680 | } |
@@ -688,7 +689,7 @@ discard block |
||
688 | 689 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
689 | 690 | $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug ); |
690 | 691 | $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug)); |
691 | - }else{ |
|
692 | + } else{ |
|
692 | 693 | $this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default')); |
693 | 694 | } |
694 | 695 | } |
@@ -737,7 +738,7 @@ discard block |
||
737 | 738 | $payment_settings_subform->save(); |
738 | 739 | /** @var $pm EE_Payment_Method */ |
739 | 740 | $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
740 | - }else{ |
|
741 | + } else{ |
|
741 | 742 | EE_Error::add_error( |
742 | 743 | sprintf( |
743 | 744 | __('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'), |
@@ -880,7 +881,7 @@ discard block |
||
880 | 881 | if(isset($this->_req_data['order'])){ |
881 | 882 | $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
882 | 883 | $query_params['order_by'] = array('LOG_time' => $sort); |
883 | - }else{ |
|
884 | + } else{ |
|
884 | 885 | $query_params['order_by'] = array('LOG_time' => 'DESC'); |
885 | 886 | } |
886 | 887 | $offset = ($current_page-1)*$per_page; |
@@ -923,7 +924,7 @@ discard block |
||
923 | 924 | $comparison = $timeA < $timeB ? -1 : 1; |
924 | 925 | if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){ |
925 | 926 | return $comparison * -1; |
926 | - }else{ |
|
927 | + } else{ |
|
927 | 928 | return $comparison; |
928 | 929 | } |
929 | 930 | } |
@@ -938,7 +939,7 @@ discard block |
||
938 | 939 | if( $payment_log->object() instanceof EE_Payment ){ |
939 | 940 | $payment_method = $payment_log->object()->payment_method(); |
940 | 941 | $transaction = $payment_log->object()->transaction(); |
941 | - }elseif($payment_log->object() instanceof EE_Payment_Method){ |
|
942 | + } elseif($payment_log->object() instanceof EE_Payment_Method){ |
|
942 | 943 | $payment_method = $payment_log->object(); |
943 | 944 | } |
944 | 945 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')){ |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | } |
5 | 5 | /** |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | * @type $name string the name for this form section, if you want to explicitly define it |
80 | 80 | * } |
81 | 81 | */ |
82 | - public function __construct( $options_array = array() ) { |
|
82 | + public function __construct($options_array = array()) { |
|
83 | 83 | // used by display strategies |
84 | 84 | // assign incoming values to properties |
85 | - foreach( $options_array as $key => $value ) { |
|
86 | - $key = '_' . $key; |
|
87 | - if ( property_exists( $this, $key ) && empty( $this->{$key} )) { |
|
85 | + foreach ($options_array as $key => $value) { |
|
86 | + $key = '_'.$key; |
|
87 | + if (property_exists($this, $key) && empty($this->{$key} )) { |
|
88 | 88 | $this->{$key} = $value; |
89 | 89 | } |
90 | 90 | } |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | * @param $name |
98 | 98 | * @throws \EE_Error |
99 | 99 | */ |
100 | - protected function _construct_finalize( $parent_form_section, $name ){ |
|
100 | + protected function _construct_finalize($parent_form_section, $name) { |
|
101 | 101 | $this->_construction_finalized = TRUE; |
102 | 102 | $this->_parent_section = $parent_form_section; |
103 | - if( $name !== null ) { |
|
103 | + if ($name !== null) { |
|
104 | 104 | $this->_name = $name; |
105 | 105 | } |
106 | 106 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | * @return void |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public function ensure_construct_finalized_called(){ |
|
115 | - if( ! $this->_construction_finalized ){ |
|
116 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
114 | + public function ensure_construct_finalized_called() { |
|
115 | + if ( ! $this->_construction_finalized) { |
|
116 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * @param string $action |
133 | 133 | */ |
134 | - public function set_action( $action ) { |
|
134 | + public function set_action($action) { |
|
135 | 135 | $this->_action = $action; |
136 | 136 | } |
137 | 137 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @return string |
142 | 142 | */ |
143 | 143 | public function method() { |
144 | - return ! empty( $this->_method ) ? $this->_method : 'POST'; |
|
144 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | /** |
150 | 150 | * @param string $method |
151 | 151 | */ |
152 | - public function set_method( $method ) { |
|
153 | - switch ( $method ) { |
|
152 | + public function set_method($method) { |
|
153 | + switch ($method) { |
|
154 | 154 | case 'get' : |
155 | 155 | case 'GET' : |
156 | 156 | $this->_method = 'GET'; |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @throws \EE_Error |
171 | 171 | */ |
172 | - protected function _set_default_html_id_if_empty(){ |
|
173 | - if( ! $this->_html_id ){ |
|
174 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
|
175 | - $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
|
176 | - }else{ |
|
177 | - $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
|
172 | + protected function _set_default_html_id_if_empty() { |
|
173 | + if ( ! $this->_html_id) { |
|
174 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
175 | + $this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name()); |
|
176 | + } else { |
|
177 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | } |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param $name |
187 | 187 | * @return string |
188 | 188 | */ |
189 | - private function _prep_name_for_html_id( $name ) { |
|
190 | - return sanitize_key( str_replace( array( ' ', ' ', '_' ), '-', $name )); |
|
189 | + private function _prep_name_for_html_id($name) { |
|
190 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * and so might stop working anytime. |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public function get_html_and_js(){ |
|
204 | + public function get_html_and_js() { |
|
205 | 205 | return $this->get_html(); |
206 | 206 | } |
207 | 207 | |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | * @param bool $add_pound_sign |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public function html_id( $add_pound_sign = FALSE ){ |
|
220 | + public function html_id($add_pound_sign = FALSE) { |
|
221 | 221 | $this->_set_default_html_id_if_empty(); |
222 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
222 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | /** |
228 | 228 | * @return string |
229 | 229 | */ |
230 | - public function html_class(){ |
|
230 | + public function html_class() { |
|
231 | 231 | return $this->_html_class; |
232 | 232 | } |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | /** |
237 | 237 | * @return string |
238 | 238 | */ |
239 | - public function html_style(){ |
|
239 | + public function html_style() { |
|
240 | 240 | return $this->_html_style; |
241 | 241 | } |
242 | 242 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | /** |
246 | 246 | * @param mixed $html_class |
247 | 247 | */ |
248 | - public function set_html_class( $html_class ) { |
|
248 | + public function set_html_class($html_class) { |
|
249 | 249 | $this->_html_class = $html_class; |
250 | 250 | } |
251 | 251 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | /** |
255 | 255 | * @param mixed $html_id |
256 | 256 | */ |
257 | - public function set_html_id( $html_id ) { |
|
257 | + public function set_html_id($html_id) { |
|
258 | 258 | $this->_html_id = $html_id; |
259 | 259 | } |
260 | 260 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | /** |
264 | 264 | * @param mixed $html_style |
265 | 265 | */ |
266 | - public function set_html_style( $html_style ) { |
|
266 | + public function set_html_style($html_style) { |
|
267 | 267 | $this->_html_style = $html_style; |
268 | 268 | } |
269 | 269 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | /** |
273 | 273 | * @param string $other_html_attributes |
274 | 274 | */ |
275 | - public function set_other_html_attributes( $other_html_attributes ) { |
|
275 | + public function set_other_html_attributes($other_html_attributes) { |
|
276 | 276 | $this->_other_html_attributes = $other_html_attributes; |
277 | 277 | } |
278 | 278 | |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * @throws EE_Error |
293 | 293 | * @return string |
294 | 294 | */ |
295 | - public function name(){ |
|
296 | - if( ! $this->_construction_finalized ){ |
|
297 | - throw new EE_Error(sprintf( __( 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso' ), get_class($this) ) ); |
|
295 | + public function name() { |
|
296 | + if ( ! $this->_construction_finalized) { |
|
297 | + throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso'), get_class($this))); |
|
298 | 298 | } |
299 | 299 | return $this->_name; |
300 | 300 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * Gets the parent section |
306 | 306 | * @return EE_Form_Section_Proper |
307 | 307 | */ |
308 | - public function parent_section(){ |
|
308 | + public function parent_section() { |
|
309 | 309 | return $this->_parent_section; |
310 | 310 | } |
311 | 311 | |
@@ -318,18 +318,18 @@ discard block |
||
318 | 318 | * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
319 | 319 | * @return string |
320 | 320 | */ |
321 | - public function form_open( $action = '', $method = '', $other_attributes = '' ) { |
|
322 | - if ( ! empty( $action )) { |
|
323 | - $this->set_action( $action ); |
|
321 | + public function form_open($action = '', $method = '', $other_attributes = '') { |
|
322 | + if ( ! empty($action)) { |
|
323 | + $this->set_action($action); |
|
324 | 324 | } |
325 | - if ( ! empty( $method )) { |
|
326 | - $this->set_method( $method ); |
|
325 | + if ( ! empty($method)) { |
|
326 | + $this->set_method($method); |
|
327 | 327 | } |
328 | - $html = EEH_HTML::nl( 1, 'form' ) . '<form'; |
|
329 | - $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
330 | - $html .= ' action="' . $this->action() . '"'; |
|
331 | - $html .= ' method="' . $this->method() . '"'; |
|
332 | - $html .= $other_attributes . '>'; |
|
328 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
329 | + $html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : ''; |
|
330 | + $html .= ' action="'.$this->action().'"'; |
|
331 | + $html .= ' method="'.$this->method().'"'; |
|
332 | + $html .= $other_attributes.'>'; |
|
333 | 333 | return $html; |
334 | 334 | } |
335 | 335 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * @return string |
341 | 341 | */ |
342 | 342 | public function form_close() { |
343 | - return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl(); |
|
343 | + return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl(); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | * Default does nothing, but child classes can override |
350 | 350 | * @return void |
351 | 351 | */ |
352 | - public function enqueue_js(){ |
|
352 | + public function enqueue_js() { |
|
353 | 353 | //defaults to enqueue NO js or css |
354 | 354 | } |
355 | 355 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @param array $form_other_js_data |
366 | 366 | * @return array |
367 | 367 | */ |
368 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
368 | + public function get_other_js_data($form_other_js_data = array()) { |
|
369 | 369 | return $form_other_js_data; |
370 | 370 | } |
371 | 371 | |
@@ -383,20 +383,20 @@ discard block |
||
383 | 383 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
384 | 384 | * @return EE_Form_Section_Base |
385 | 385 | */ |
386 | - public function find_section_from_path( $form_section_path ) { |
|
387 | - if( strpos( $form_section_path, '/' ) === 0 ) { |
|
388 | - $form_section_path = substr( $form_section_path, strlen( '/' ) ); |
|
386 | + public function find_section_from_path($form_section_path) { |
|
387 | + if (strpos($form_section_path, '/') === 0) { |
|
388 | + $form_section_path = substr($form_section_path, strlen('/')); |
|
389 | 389 | } |
390 | - if( empty( $form_section_path ) ) { |
|
390 | + if (empty($form_section_path)) { |
|
391 | 391 | return $this; |
392 | 392 | } |
393 | - if( strpos( $form_section_path, '../' ) === 0 ) { |
|
393 | + if (strpos($form_section_path, '../') === 0) { |
|
394 | 394 | $parent = $this->parent_section(); |
395 | 395 | |
396 | - $form_section_path = substr( $form_section_path, strlen( '../' ) ); |
|
397 | - if( $parent instanceof EE_Form_Section_Base ) { |
|
398 | - return $parent->find_section_from_path( $form_section_path ); |
|
399 | - } elseif( empty( $form_section_path ) ) { |
|
396 | + $form_section_path = substr($form_section_path, strlen('../')); |
|
397 | + if ($parent instanceof EE_Form_Section_Base) { |
|
398 | + return $parent->find_section_from_path($form_section_path); |
|
399 | + } elseif (empty($form_section_path)) { |
|
400 | 400 | return $this; |
401 | 401 | } |
402 | 402 | } |
@@ -173,7 +173,7 @@ |
||
173 | 173 | if( ! $this->_html_id ){ |
174 | 174 | if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
175 | 175 | $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
176 | - }else{ |
|
176 | + } else{ |
|
177 | 177 | $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
178 | 178 | } |
179 | 179 | } |
@@ -57,11 +57,11 @@ |
||
57 | 57 | |
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * @param array $req_data |
|
62 | - * @throws EE_Error |
|
63 | - */ |
|
64 | - public function _normalize( $req_data ) { |
|
60 | + /** |
|
61 | + * @param array $req_data |
|
62 | + * @throws EE_Error |
|
63 | + */ |
|
64 | + public function _normalize( $req_data ) { |
|
65 | 65 | parent::_normalize( $req_data ); |
66 | 66 | $paypal_calculates_shipping = $this->get_input_value( 'paypal_shipping' ); |
67 | 67 | $paypal_calculates_taxes = $this->get_input_value( 'paypal_taxes' ); |
@@ -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 | /** |
@@ -21,35 +21,35 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * @param EE_PMT_Paypal_Standard $payment_method_type |
23 | 23 | */ |
24 | - public function __construct( $payment_method_type ){ |
|
24 | + public function __construct($payment_method_type) { |
|
25 | 25 | parent::__construct( |
26 | 26 | array( |
27 | 27 | 'payment_method_type' => $payment_method_type, |
28 | 28 | 'extra_meta_inputs' => array( |
29 | - 'paypal_id' => new EE_Text_Input( array( |
|
30 | - 'html_label_text' => sprintf( __( "Paypal Email %s", 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
31 | - 'html_help_text' => __( "Typically [email protected]", 'event_espresso' ), |
|
29 | + 'paypal_id' => new EE_Text_Input(array( |
|
30 | + 'html_label_text' => sprintf(__("Paypal Email %s", 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
31 | + 'html_help_text' => __("Typically [email protected]", 'event_espresso'), |
|
32 | 32 | 'required' => true |
33 | - ) ), |
|
34 | - 'image_url' => new EE_Admin_File_Uploader_Input( array( |
|
35 | - 'html_help_text' => __( "Used for your business/personal logo on the PayPal page", 'event_espresso' ), |
|
36 | - 'html_label_text' => __( 'Image URL', 'event_espresso' ) |
|
37 | - ) ), |
|
38 | - 'paypal_taxes' => new EE_Yes_No_Input( array( |
|
39 | - 'html_label_text' => sprintf( __( 'Paypal Calculates Taxes %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
40 | - 'html_help_text' => __( 'Whether Paypal should add taxes to the order', 'event_espresso' ), |
|
33 | + )), |
|
34 | + 'image_url' => new EE_Admin_File_Uploader_Input(array( |
|
35 | + 'html_help_text' => __("Used for your business/personal logo on the PayPal page", 'event_espresso'), |
|
36 | + 'html_label_text' => __('Image URL', 'event_espresso') |
|
37 | + )), |
|
38 | + 'paypal_taxes' => new EE_Yes_No_Input(array( |
|
39 | + 'html_label_text' => sprintf(__('Paypal Calculates Taxes %s', 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
40 | + 'html_help_text' => __('Whether Paypal should add taxes to the order', 'event_espresso'), |
|
41 | 41 | 'default' => false |
42 | - ) ), |
|
43 | - 'paypal_shipping' => new EE_Yes_No_Input( array( |
|
44 | - 'html_label_text' => sprintf( __( 'Paypal Calculates Shipping %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
45 | - 'html_help_text' => __( 'Whether Paypal should add shipping surcharges', 'event_espresso' ), |
|
42 | + )), |
|
43 | + 'paypal_shipping' => new EE_Yes_No_Input(array( |
|
44 | + 'html_label_text' => sprintf(__('Paypal Calculates Shipping %s', 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
45 | + 'html_help_text' => __('Whether Paypal should add shipping surcharges', 'event_espresso'), |
|
46 | 46 | 'default' => false |
47 | - ) ), |
|
48 | - 'shipping_details' => new EE_Select_Input( array( |
|
49 | - EE_PMT_Paypal_Standard::shipping_info_none => __( "Do not prompt for an address", 'event_espresso' ), |
|
50 | - EE_PMT_Paypal_Standard::shipping_info_optional => __( "Prompt for an address, but do not require it", 'event_espresso' ), |
|
51 | - EE_PMT_Paypal_Standard::shipping_info_required => __( "Prompt for an address, and require it", 'event_espresso' ) |
|
52 | - ) ) |
|
47 | + )), |
|
48 | + 'shipping_details' => new EE_Select_Input(array( |
|
49 | + EE_PMT_Paypal_Standard::shipping_info_none => __("Do not prompt for an address", 'event_espresso'), |
|
50 | + EE_PMT_Paypal_Standard::shipping_info_optional => __("Prompt for an address, but do not require it", 'event_espresso'), |
|
51 | + EE_PMT_Paypal_Standard::shipping_info_required => __("Prompt for an address, and require it", 'event_espresso') |
|
52 | + )) |
|
53 | 53 | ) |
54 | 54 | ) |
55 | 55 | ); |
@@ -61,28 +61,28 @@ discard block |
||
61 | 61 | * @param array $req_data |
62 | 62 | * @throws EE_Error |
63 | 63 | */ |
64 | - public function _normalize( $req_data ) { |
|
65 | - parent::_normalize( $req_data ); |
|
66 | - $paypal_calculates_shipping = $this->get_input_value( 'paypal_shipping' ); |
|
67 | - $paypal_calculates_taxes = $this->get_input_value( 'paypal_taxes' ); |
|
68 | - $paypal_requests_address_info = $this->get_input_value( 'shipping_details' ); |
|
64 | + public function _normalize($req_data) { |
|
65 | + parent::_normalize($req_data); |
|
66 | + $paypal_calculates_shipping = $this->get_input_value('paypal_shipping'); |
|
67 | + $paypal_calculates_taxes = $this->get_input_value('paypal_taxes'); |
|
68 | + $paypal_requests_address_info = $this->get_input_value('shipping_details'); |
|
69 | 69 | if ( |
70 | - ( $paypal_calculates_shipping || $paypal_calculates_taxes ) && |
|
70 | + ($paypal_calculates_shipping || $paypal_calculates_taxes) && |
|
71 | 71 | $paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none |
72 | 72 | ) { |
73 | 73 | //they want paypal to calculate taxes or shipping. They need to ask for |
74 | 74 | //address info, otherwise paypal can't calculate taxes or shipping |
75 | 75 | /** @type EE_Select_Input $shipping_details_input */ |
76 | - $shipping_details_input = $this->get_input( 'shipping_details' ); |
|
77 | - $shipping_details_input->set_default( EE_PMT_Paypal_Standard::shipping_info_optional ); |
|
76 | + $shipping_details_input = $this->get_input('shipping_details'); |
|
77 | + $shipping_details_input->set_default(EE_PMT_Paypal_Standard::shipping_info_optional); |
|
78 | 78 | $shipping_details_input_options = $shipping_details_input->options(); |
79 | 79 | EE_Error::add_attention( |
80 | 80 | sprintf( |
81 | - __( 'Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso' ), |
|
82 | - strip_tags( $shipping_details_input->html_label_text() ), |
|
83 | - isset( $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] ) |
|
84 | - ? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] |
|
85 | - : __( 'Unknown', 'event_espresso' ) |
|
81 | + __('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'), |
|
82 | + strip_tags($shipping_details_input->html_label_text()), |
|
83 | + isset($shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional]) |
|
84 | + ? $shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional] |
|
85 | + : __('Unknown', 'event_espresso') |
|
86 | 86 | ), |
87 | 87 | __FILE__, __FUNCTION__, __LINE__ |
88 | 88 | ); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * the input's name attribute |
@@ -143,54 +143,54 @@ discard block |
||
143 | 143 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
144 | 144 | * } |
145 | 145 | */ |
146 | - public function __construct( $input_args = array() ){ |
|
147 | - $input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
146 | + public function __construct($input_args = array()) { |
|
147 | + $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
148 | 148 | // the following properties must be cast as arrays |
149 | - if ( isset( $input_args['validation_strategies'] ) ) { |
|
150 | - foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) { |
|
151 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
152 | - $this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy; |
|
149 | + if (isset($input_args['validation_strategies'])) { |
|
150 | + foreach ((array) $input_args['validation_strategies'] as $validation_strategy) { |
|
151 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
152 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
153 | 153 | } |
154 | 154 | } |
155 | - unset( $input_args['validation_strategies'] ); |
|
155 | + unset($input_args['validation_strategies']); |
|
156 | 156 | } |
157 | 157 | // loop thru incoming options |
158 | - foreach( $input_args as $key => $value ) { |
|
158 | + foreach ($input_args as $key => $value) { |
|
159 | 159 | // add underscore to $key to match property names |
160 | - $_key = '_' . $key; |
|
161 | - if ( property_exists( $this, $_key )) { |
|
160 | + $_key = '_'.$key; |
|
161 | + if (property_exists($this, $_key)) { |
|
162 | 162 | $this->{$_key} = $value; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | // ensure that "required" is set correctly |
166 | 166 | $this->set_required( |
167 | - $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) |
|
168 | - ? $input_args[ 'required_validation_error_message' ] |
|
167 | + $this->_required, isset($input_args['required_validation_error_message']) |
|
168 | + ? $input_args['required_validation_error_message'] |
|
169 | 169 | : null |
170 | 170 | ); |
171 | 171 | |
172 | 172 | //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
173 | 173 | |
174 | 174 | $this->_display_strategy->_construct_finalize($this); |
175 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
175 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
176 | 176 | $validation_strategy->_construct_finalize($this); |
177 | 177 | } |
178 | 178 | |
179 | - if( ! $this->_normalization_strategy){ |
|
179 | + if ( ! $this->_normalization_strategy) { |
|
180 | 180 | $this->_normalization_strategy = new EE_Text_Normalization(); |
181 | 181 | } |
182 | 182 | $this->_normalization_strategy->_construct_finalize($this); |
183 | 183 | |
184 | 184 | //at least we can use the normalization strategy to populate the default |
185 | - if( isset( $input_args[ 'default' ] ) ) { |
|
186 | - $this->set_default( $input_args[ 'default' ] ); |
|
185 | + if (isset($input_args['default'])) { |
|
186 | + $this->set_default($input_args['default']); |
|
187 | 187 | } |
188 | 188 | |
189 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
189 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
190 | 190 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
191 | 191 | } |
192 | 192 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
193 | - parent::__construct( $input_args ); |
|
193 | + parent::__construct($input_args); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @throws \EE_Error |
203 | 203 | */ |
204 | - protected function _set_default_html_name_if_empty(){ |
|
205 | - if( ! $this->_html_name){ |
|
204 | + protected function _set_default_html_name_if_empty() { |
|
205 | + if ( ! $this->_html_name) { |
|
206 | 206 | $this->_html_name = $this->name(); |
207 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
208 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
207 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
208 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public function _construct_finalize($parent_form_section, $name) { |
221 | 221 | parent::_construct_finalize($parent_form_section, $name); |
222 | - if( $this->_html_label === null && $this->_html_label_text === null ){ |
|
223 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
222 | + if ($this->_html_label === null && $this->_html_label_text === null) { |
|
223 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
224 | 224 | } |
225 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
225 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | * @return EE_Display_Strategy_Base |
231 | 231 | * @throws EE_Error |
232 | 232 | */ |
233 | - protected function _get_display_strategy(){ |
|
233 | + protected function _get_display_strategy() { |
|
234 | 234 | $this->ensure_construct_finalized_called(); |
235 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
235 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
236 | 236 | throw new EE_Error( |
237 | 237 | sprintf( |
238 | 238 | __( |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $this->html_id() |
244 | 244 | ) |
245 | 245 | ); |
246 | - }else{ |
|
246 | + } else { |
|
247 | 247 | return $this->_display_strategy; |
248 | 248 | } |
249 | 249 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * Sets the display strategy. |
252 | 252 | * @param EE_Display_Strategy_Base $strategy |
253 | 253 | */ |
254 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
254 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
255 | 255 | $this->_display_strategy = $strategy; |
256 | 256 | } |
257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * Sets the sanitization strategy |
260 | 260 | * @param EE_Normalization_Strategy_Base $strategy |
261 | 261 | */ |
262 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
262 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
263 | 263 | $this->_normalization_strategy = $strategy; |
264 | 264 | } |
265 | 265 | |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | * Gets the display strategy for this input |
286 | 286 | * @return EE_Display_Strategy_Base |
287 | 287 | */ |
288 | - public function get_display_strategy(){ |
|
288 | + public function get_display_strategy() { |
|
289 | 289 | return $this->_display_strategy; |
290 | 290 | } |
291 | 291 | /** |
292 | 292 | * Overwrites the display strategy |
293 | 293 | * @param EE_Display_Strategy_Base $display_strategy |
294 | 294 | */ |
295 | - public function set_display_strategy($display_strategy){ |
|
295 | + public function set_display_strategy($display_strategy) { |
|
296 | 296 | $this->_display_strategy = $display_strategy; |
297 | 297 | $this->_display_strategy->_construct_finalize($this); |
298 | 298 | } |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | * Gets the normalization strategy set on this input |
301 | 301 | * @return EE_Normalization_Strategy_Base |
302 | 302 | */ |
303 | - public function get_normalization_strategy(){ |
|
303 | + public function get_normalization_strategy() { |
|
304 | 304 | return $this->_normalization_strategy; |
305 | 305 | } |
306 | 306 | /** |
307 | 307 | * Overwrites the normalization strategy |
308 | 308 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
309 | 309 | */ |
310 | - public function set_normalization_strategy($normalization_strategy){ |
|
310 | + public function set_normalization_strategy($normalization_strategy) { |
|
311 | 311 | $this->_normalization_strategy = $normalization_strategy; |
312 | 312 | $this->_normalization_strategy->_construct_finalize($this); |
313 | 313 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * Returns all teh validation strategies which apply to this field, numerically indexed |
317 | 317 | * @return EE_Validation_Strategy_Base[] |
318 | 318 | */ |
319 | - public function get_validation_strategies(){ |
|
319 | + public function get_validation_strategies() { |
|
320 | 320 | return $this->_validation_strategies; |
321 | 321 | } |
322 | 322 | |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * @param EE_Validation_Strategy_Base $validation_strategy |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
331 | - $validation_strategy->_construct_finalize( $this ); |
|
330 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
331 | + $validation_strategy->_construct_finalize($this); |
|
332 | 332 | $this->_validation_strategies[] = $validation_strategy; |
333 | 333 | } |
334 | 334 | |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_Validation_Strategy_Base $validation_strategy |
340 | 340 | * @return void |
341 | 341 | */ |
342 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
343 | - $this->_add_validation_strategy( $validation_strategy ); |
|
342 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
343 | + $this->_add_validation_strategy($validation_strategy); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -350,13 +350,13 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @param string $validation_strategy_classname |
352 | 352 | */ |
353 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
354 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
355 | - if( |
|
353 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
354 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
355 | + if ( |
|
356 | 356 | $validation_strategy instanceof $validation_strategy_classname |
357 | - || is_subclass_of( $validation_strategy, $validation_strategy_classname ) |
|
357 | + || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
358 | 358 | ) { |
359 | - unset( $this->_validation_strategies[ $key ] ); |
|
359 | + unset($this->_validation_strategies[$key]); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | } |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | * @param array $validation_strategy_classnames |
370 | 370 | * @return bool |
371 | 371 | */ |
372 | - public function has_validation_strategy( $validation_strategy_classnames ) { |
|
373 | - $validation_strategy_classnames = is_array( $validation_strategy_classnames ) |
|
372 | + public function has_validation_strategy($validation_strategy_classnames) { |
|
373 | + $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
374 | 374 | ? $validation_strategy_classnames |
375 | - : array( $validation_strategy_classnames ); |
|
376 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
377 | - if( in_array( $key, $validation_strategy_classnames ) ) { |
|
375 | + : array($validation_strategy_classnames); |
|
376 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
377 | + if (in_array($key, $validation_strategy_classnames)) { |
|
378 | 378 | return true; |
379 | 379 | } |
380 | 380 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * Gets the HTML |
388 | 388 | * @return string |
389 | 389 | */ |
390 | - public function get_html(){ |
|
390 | + public function get_html() { |
|
391 | 391 | return $this->_parent_section->get_html_for_input($this); |
392 | 392 | } |
393 | 393 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return string |
402 | 402 | * @throws \EE_Error |
403 | 403 | */ |
404 | - public function get_html_for_input(){ |
|
404 | + public function get_html_for_input() { |
|
405 | 405 | |
406 | 406 | return $this->_get_display_strategy()->display(); |
407 | 407 | } |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @return string |
413 | 413 | */ |
414 | 414 | public function html_other_attributes() { |
415 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
415 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | /** |
421 | 421 | * @param string $html_other_attributes |
422 | 422 | */ |
423 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
423 | + public function set_html_other_attributes($html_other_attributes) { |
|
424 | 424 | $this->_html_other_attributes = $html_other_attributes; |
425 | 425 | } |
426 | 426 | |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * according to the form section's layout strategy |
430 | 430 | * @return string |
431 | 431 | */ |
432 | - public function get_html_for_label(){ |
|
432 | + public function get_html_for_label() { |
|
433 | 433 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
434 | 434 | } |
435 | 435 | /** |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * according to the form section's layout strategy |
438 | 438 | * @return string |
439 | 439 | */ |
440 | - public function get_html_for_errors(){ |
|
440 | + public function get_html_for_errors() { |
|
441 | 441 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
442 | 442 | } |
443 | 443 | /** |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * according to the form section's layout strategy |
446 | 446 | * @return string |
447 | 447 | */ |
448 | - public function get_html_for_help(){ |
|
448 | + public function get_html_for_help() { |
|
449 | 449 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
450 | 450 | } |
451 | 451 | /** |
@@ -454,18 +454,18 @@ discard block |
||
454 | 454 | * @return boolean |
455 | 455 | */ |
456 | 456 | protected function _validate() { |
457 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
458 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
459 | - try{ |
|
457 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
458 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
459 | + try { |
|
460 | 460 | $validation_strategy->validate($this->normalized_value()); |
461 | - }catch(EE_Validation_Error $e){ |
|
461 | + } catch (EE_Validation_Error $e) { |
|
462 | 462 | $this->add_validation_error($e); |
463 | 463 | } |
464 | 464 | } |
465 | 465 | } |
466 | - if( $this->get_validation_errors()){ |
|
466 | + if ($this->get_validation_errors()) { |
|
467 | 467 | return false; |
468 | - }else{ |
|
468 | + } else { |
|
469 | 469 | return true; |
470 | 470 | } |
471 | 471 | } |
@@ -479,8 +479,8 @@ discard block |
||
479 | 479 | * @param string $value |
480 | 480 | * @return null|string |
481 | 481 | */ |
482 | - private function _sanitize( $value ) { |
|
483 | - return $value !== null ? stripslashes( html_entity_decode( trim( $value ) ) ) : null; |
|
482 | + private function _sanitize($value) { |
|
483 | + return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null; |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | |
@@ -494,25 +494,25 @@ discard block |
||
494 | 494 | * @return boolean whether or not there was an error |
495 | 495 | * @throws \EE_Error |
496 | 496 | */ |
497 | - protected function _normalize( $req_data ) { |
|
497 | + protected function _normalize($req_data) { |
|
498 | 498 | //any existing validation errors don't apply so clear them |
499 | 499 | $this->_validation_errors = array(); |
500 | 500 | try { |
501 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
501 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
502 | 502 | //super simple sanitization for now |
503 | - if ( is_array( $raw_input )) { |
|
503 | + if (is_array($raw_input)) { |
|
504 | 504 | $raw_value = array(); |
505 | - foreach( $raw_input as $key => $value ) { |
|
506 | - $raw_value[ $key ] = $this->_sanitize( $value ); |
|
505 | + foreach ($raw_input as $key => $value) { |
|
506 | + $raw_value[$key] = $this->_sanitize($value); |
|
507 | 507 | } |
508 | - $this->_set_raw_value( $raw_value ); |
|
508 | + $this->_set_raw_value($raw_value); |
|
509 | 509 | } else { |
510 | - $this->_set_raw_value( $this->_sanitize( $raw_input ) ); |
|
510 | + $this->_set_raw_value($this->_sanitize($raw_input)); |
|
511 | 511 | } |
512 | 512 | //we want to mostly leave the input alone in case we need to re-display it to the user |
513 | - $this->_set_normalized_value( $this->_normalization_strategy->normalize( $this->raw_value() ) ); |
|
514 | - } catch ( EE_Validation_Error $e ) { |
|
515 | - $this->add_validation_error( $e ); |
|
513 | + $this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value())); |
|
514 | + } catch (EE_Validation_Error $e) { |
|
515 | + $this->add_validation_error($e); |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | /** |
522 | 522 | * @return string |
523 | 523 | */ |
524 | - public function html_name(){ |
|
524 | + public function html_name() { |
|
525 | 525 | $this->_set_default_html_name_if_empty(); |
526 | 526 | return $this->_html_name; |
527 | 527 | } |
@@ -531,8 +531,8 @@ discard block |
||
531 | 531 | /** |
532 | 532 | * @return string |
533 | 533 | */ |
534 | - public function html_label_id(){ |
|
535 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
534 | + public function html_label_id() { |
|
535 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | /** |
541 | 541 | * @return string |
542 | 542 | */ |
543 | - public function html_label_class(){ |
|
543 | + public function html_label_class() { |
|
544 | 544 | return $this->_html_label_class; |
545 | 545 | } |
546 | 546 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | /** |
550 | 550 | * @return string |
551 | 551 | */ |
552 | - public function html_label_style(){ |
|
552 | + public function html_label_style() { |
|
553 | 553 | return $this->_html_label_style; |
554 | 554 | } |
555 | 555 | |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | /** |
559 | 559 | * @return string |
560 | 560 | */ |
561 | - public function html_label_text(){ |
|
561 | + public function html_label_text() { |
|
562 | 562 | return $this->_html_label_text; |
563 | 563 | } |
564 | 564 | |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | /** |
568 | 568 | * @return string |
569 | 569 | */ |
570 | - public function html_help_text(){ |
|
570 | + public function html_help_text() { |
|
571 | 571 | return $this->_html_help_text; |
572 | 572 | } |
573 | 573 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | /** |
577 | 577 | * @return string |
578 | 578 | */ |
579 | - public function html_help_class(){ |
|
579 | + public function html_help_class() { |
|
580 | 580 | return $this->_html_help_class; |
581 | 581 | } |
582 | 582 | |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | /** |
586 | 586 | * @return string |
587 | 587 | */ |
588 | - public function html_help_style(){ |
|
588 | + public function html_help_style() { |
|
589 | 589 | return $this->_html_style; |
590 | 590 | } |
591 | 591 | /** |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | * in which case, we would have stored the malicious content to our database. |
599 | 599 | * @return string |
600 | 600 | */ |
601 | - public function raw_value(){ |
|
601 | + public function raw_value() { |
|
602 | 602 | return $this->_raw_value; |
603 | 603 | } |
604 | 604 | /** |
@@ -606,15 +606,15 @@ discard block |
||
606 | 606 | * it escapes all html entities |
607 | 607 | * @return string |
608 | 608 | */ |
609 | - public function raw_value_in_form(){ |
|
610 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
609 | + public function raw_value_in_form() { |
|
610 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
611 | 611 | } |
612 | 612 | /** |
613 | 613 | * returns the value after it's been sanitized, and then converted into it's proper type |
614 | 614 | * in PHP. Eg, a string, an int, an array, |
615 | 615 | * @return mixed |
616 | 616 | */ |
617 | - public function normalized_value(){ |
|
617 | + public function normalized_value() { |
|
618 | 618 | return $this->_normalized_value; |
619 | 619 | } |
620 | 620 | |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | * the best thing to display |
625 | 625 | * @return string |
626 | 626 | */ |
627 | - public function pretty_value(){ |
|
627 | + public function pretty_value() { |
|
628 | 628 | return $this->_normalized_value; |
629 | 629 | } |
630 | 630 | /** |
@@ -643,19 +643,19 @@ discard block |
||
643 | 643 | }</code> |
644 | 644 | * @return array |
645 | 645 | */ |
646 | - public function get_jquery_validation_rules(){ |
|
646 | + public function get_jquery_validation_rules() { |
|
647 | 647 | $jquery_validation_js = array(); |
648 | 648 | $jquery_validation_rules = array(); |
649 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
649 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
650 | 650 | $jquery_validation_rules = array_replace_recursive( |
651 | 651 | $jquery_validation_rules, |
652 | 652 | $validation_strategy->get_jquery_validation_rule_array() |
653 | 653 | ); |
654 | 654 | } |
655 | 655 | |
656 | - if(! empty($jquery_validation_rules)){ |
|
657 | - foreach( $this->get_display_strategy()->get_html_input_ids( true ) as $html_id_with_pound_sign ) { |
|
658 | - $jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules; |
|
656 | + if ( ! empty($jquery_validation_rules)) { |
|
657 | + foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) { |
|
658 | + $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules; |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | return $jquery_validation_js; |
@@ -667,16 +667,16 @@ discard block |
||
667 | 667 | * @param mixed $value |
668 | 668 | * @return void |
669 | 669 | */ |
670 | - public function set_default($value){ |
|
671 | - $this->_set_normalized_value( $value ); |
|
672 | - $this->_set_raw_value( $value ); |
|
670 | + public function set_default($value) { |
|
671 | + $this->_set_normalized_value($value); |
|
672 | + $this->_set_raw_value($value); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | /** |
676 | 676 | * Sets the normalized value on this input |
677 | 677 | * @param mixed $value |
678 | 678 | */ |
679 | - protected function _set_normalized_value( $value ) { |
|
679 | + protected function _set_normalized_value($value) { |
|
680 | 680 | $this->_normalized_value = $value; |
681 | 681 | } |
682 | 682 | |
@@ -684,8 +684,8 @@ discard block |
||
684 | 684 | * Sets the raw value on this input (ie, exactly as the user submitted it) |
685 | 685 | * @param mixed $value |
686 | 686 | */ |
687 | - protected function _set_raw_value( $value ) { |
|
688 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
687 | + protected function _set_raw_value($value) { |
|
688 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * @param string $label |
694 | 694 | * @return void |
695 | 695 | */ |
696 | - public function set_html_label_text($label){ |
|
696 | + public function set_html_label_text($label) { |
|
697 | 697 | $this->_html_label_text = $label; |
698 | 698 | } |
699 | 699 | |
@@ -707,13 +707,13 @@ discard block |
||
707 | 707 | * @param boolean $required boolean |
708 | 708 | * @param null $required_text |
709 | 709 | */ |
710 | - public function set_required($required = true, $required_text = NULL ){ |
|
711 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
710 | + public function set_required($required = true, $required_text = NULL) { |
|
711 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
712 | 712 | //whether $required is a string or a boolean, we want to add a required validation strategy |
713 | - if ( $required ) { |
|
714 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
713 | + if ($required) { |
|
714 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
715 | 715 | } else { |
716 | - $this->remove_validation_strategy( 'EE_Required_Validation_Strategy' ); |
|
716 | + $this->remove_validation_strategy('EE_Required_Validation_Strategy'); |
|
717 | 717 | } |
718 | 718 | $this->_required = $required; |
719 | 719 | } |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | * Returns whether or not this field is required |
722 | 722 | * @return boolean |
723 | 723 | */ |
724 | - public function required(){ |
|
724 | + public function required() { |
|
725 | 725 | return $this->_required; |
726 | 726 | } |
727 | 727 | |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | /** |
731 | 731 | * @param string $required_css_class |
732 | 732 | */ |
733 | - public function set_required_css_class( $required_css_class ) { |
|
733 | + public function set_required_css_class($required_css_class) { |
|
734 | 734 | $this->_required_css_class = $required_css_class; |
735 | 735 | } |
736 | 736 | |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * Sets the help text, in case |
750 | 750 | * @param string $text |
751 | 751 | */ |
752 | - public function set_html_help_text($text){ |
|
752 | + public function set_html_help_text($text) { |
|
753 | 753 | $this->_html_help_text = $text; |
754 | 754 | } |
755 | 755 | /** |
@@ -761,9 +761,9 @@ discard block |
||
761 | 761 | public function clean_sensitive_data() { |
762 | 762 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
763 | 763 | //if we need more logic than this we'll make a strategy for it |
764 | - if( $this->_sensitive_data_removal_strategy && |
|
765 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
766 | - $this->_set_raw_value( null ); |
|
764 | + if ($this->_sensitive_data_removal_strategy && |
|
765 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
766 | + $this->_set_raw_value(null); |
|
767 | 767 | } |
768 | 768 | //and clean the normalized value according to the appropriate strategy |
769 | 769 | $this->_set_normalized_value( |
@@ -780,10 +780,10 @@ discard block |
||
780 | 780 | * @param string $button_size |
781 | 781 | * @param string $other_attributes |
782 | 782 | */ |
783 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
783 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
784 | 784 | $button_css_attributes = 'button'; |
785 | 785 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
786 | - switch ( $button_size ) { |
|
786 | + switch ($button_size) { |
|
787 | 787 | case 'xs' : |
788 | 788 | case 'extra-small' : |
789 | 789 | $button_css_attributes .= ' button-xs'; |
@@ -804,8 +804,8 @@ discard block |
||
804 | 804 | default : |
805 | 805 | $button_css_attributes .= ''; |
806 | 806 | } |
807 | - $this->_button_css_attributes .= ! empty( $other_attributes ) |
|
808 | - ? $button_css_attributes . ' ' . $other_attributes |
|
807 | + $this->_button_css_attributes .= ! empty($other_attributes) |
|
808 | + ? $button_css_attributes.' '.$other_attributes |
|
809 | 809 | : $button_css_attributes; |
810 | 810 | } |
811 | 811 | |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | * @return string |
816 | 816 | */ |
817 | 817 | public function button_css_attributes() { |
818 | - if ( empty( $this->_button_css_attributes )) { |
|
818 | + if (empty($this->_button_css_attributes)) { |
|
819 | 819 | $this->set_button_css_attributes(); |
820 | 820 | } |
821 | 821 | return $this->_button_css_attributes; |
@@ -837,26 +837,26 @@ discard block |
||
837 | 837 | * @return mixed whatever the raw value of this form section is in the request data |
838 | 838 | * @throws \EE_Error |
839 | 839 | */ |
840 | - public function find_form_data_for_this_section( $req_data ){ |
|
840 | + public function find_form_data_for_this_section($req_data) { |
|
841 | 841 | // break up the html name by "[]" |
842 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
843 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
842 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
843 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
844 | 844 | } else { |
845 | 845 | $before_any_brackets = $this->html_name(); |
846 | 846 | } |
847 | 847 | // grab all of the segments |
848 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
849 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
850 | - $name_parts = $matches[ 1 ]; |
|
848 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
849 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
850 | + $name_parts = $matches[1]; |
|
851 | 851 | array_unshift($name_parts, $before_any_brackets); |
852 | - }else{ |
|
853 | - $name_parts = array( $before_any_brackets ); |
|
852 | + } else { |
|
853 | + $name_parts = array($before_any_brackets); |
|
854 | 854 | } |
855 | 855 | // now get the value for the input |
856 | 856 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
857 | 857 | // check if this thing's name is at the TOP level of the request data |
858 | - if( $value === null && isset( $req_data[ $this->name() ] ) ){ |
|
859 | - $value = $req_data[ $this->name() ]; |
|
858 | + if ($value === null && isset($req_data[$this->name()])) { |
|
859 | + $value = $req_data[$this->name()]; |
|
860 | 860 | } |
861 | 861 | return $value; |
862 | 862 | } |
@@ -869,18 +869,18 @@ discard block |
||
869 | 869 | * @param array $req_data |
870 | 870 | * @return array | NULL |
871 | 871 | */ |
872 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
873 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
874 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
875 | - if( empty($html_name_parts ) ){ |
|
876 | - return $req_data[ $first_part_to_consider ]; |
|
877 | - }else{ |
|
872 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
873 | + $first_part_to_consider = array_shift($html_name_parts); |
|
874 | + if (isset($req_data[$first_part_to_consider])) { |
|
875 | + if (empty($html_name_parts)) { |
|
876 | + return $req_data[$first_part_to_consider]; |
|
877 | + } else { |
|
878 | 878 | return $this->_find_form_data_for_this_section_using_name_parts( |
879 | 879 | $html_name_parts, |
880 | - $req_data[ $first_part_to_consider ] |
|
880 | + $req_data[$first_part_to_consider] |
|
881 | 881 | ); |
882 | 882 | } |
883 | - }else{ |
|
883 | + } else { |
|
884 | 884 | return NULL; |
885 | 885 | } |
886 | 886 | } |
@@ -894,14 +894,14 @@ discard block |
||
894 | 894 | * @return boolean |
895 | 895 | * @throws \EE_Error |
896 | 896 | */ |
897 | - public function form_data_present_in($req_data = NULL){ |
|
898 | - if( $req_data === NULL ){ |
|
897 | + public function form_data_present_in($req_data = NULL) { |
|
898 | + if ($req_data === NULL) { |
|
899 | 899 | $req_data = $_POST; |
900 | 900 | } |
901 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
902 | - if( $checked_value !== null ){ |
|
901 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
902 | + if ($checked_value !== null) { |
|
903 | 903 | return TRUE; |
904 | - }else{ |
|
904 | + } else { |
|
905 | 905 | return FALSE; |
906 | 906 | } |
907 | 907 | } |
@@ -912,8 +912,8 @@ discard block |
||
912 | 912 | * @param array $form_other_js_data |
913 | 913 | * @return array |
914 | 914 | */ |
915 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
916 | - $form_other_js_data = $this->get_other_js_data_from_strategies( $form_other_js_data ); |
|
915 | + public function get_other_js_data($form_other_js_data = array()) { |
|
916 | + $form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data); |
|
917 | 917 | return $form_other_js_data; |
918 | 918 | } |
919 | 919 | |
@@ -926,10 +926,10 @@ discard block |
||
926 | 926 | * @param array $form_other_js_data |
927 | 927 | * @return array |
928 | 928 | */ |
929 | - public function get_other_js_data_from_strategies( $form_other_js_data = array() ) { |
|
930 | - $form_other_js_data = $this->get_display_strategy()->get_other_js_data( $form_other_js_data ); |
|
931 | - foreach( $this->get_validation_strategies() as $validation_strategy ) { |
|
932 | - $form_other_js_data = $validation_strategy->get_other_js_data( $form_other_js_data ); |
|
929 | + public function get_other_js_data_from_strategies($form_other_js_data = array()) { |
|
930 | + $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data); |
|
931 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
932 | + $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data); |
|
933 | 933 | } |
934 | 934 | return $form_other_js_data; |
935 | 935 | } |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | * Override parent because we want to give our strategies an opportunity to enqueue some js and css |
939 | 939 | * @return void |
940 | 940 | */ |
941 | - public function enqueue_js(){ |
|
941 | + public function enqueue_js() { |
|
942 | 942 | //ask our display strategy and validation strategies if they have js to enqueue |
943 | 943 | $this->enqueue_js_from_strategies(); |
944 | 944 | } |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | */ |
950 | 950 | public function enqueue_js_from_strategies() { |
951 | 951 | $this->get_display_strategy()->enqueue_js(); |
952 | - foreach( $this->get_validation_strategies() as $validation_strategy ) { |
|
952 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
953 | 953 | $validation_strategy->enqueue_js(); |
954 | 954 | } |
955 | 955 | } |
@@ -472,13 +472,13 @@ |
||
472 | 472 | |
473 | 473 | function set_must_use_event_types() { |
474 | 474 | $term_details = array( |
475 | - //Attendee's register for the first date-time only |
|
475 | + //Attendee's register for the first date-time only |
|
476 | 476 | 'single-event' => array( __('Single Event', 'event_espresso'), __('A single event that spans one or more consecutive days.', 'event_espresso') ), //example: a party or two-day long workshop |
477 | - //Attendee's can register for any of the date-times |
|
477 | + //Attendee's can register for any of the date-times |
|
478 | 478 | 'multi-event' => array( __('Multi Event', 'event_espresso'), __('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso') ), //example: a three day music festival or week long conference |
479 | - //Attendee's register for the first date-time only |
|
479 | + //Attendee's register for the first date-time only |
|
480 | 480 | 'event-series' => array( __('Event Series', 'event_espresso'), __(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso') ), //example: an 8 week introduction to basket weaving course |
481 | - //Attendee's can register for any of the date-times. |
|
481 | + //Attendee's can register for any of the date-times. |
|
482 | 482 | 'recurring-event' => array( __('Recurring Event', 'event_espresso'), __('Multiple events that occur over multiple non-consecutive days.', 'event_espresso') ), //example: a yoga class |
483 | 483 | |
484 | 484 | 'ongoing' => array( __('Ongoing Event', 'event_espresso'), __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', 'event_espresso') ) //example: access to a museum |
@@ -23,37 +23,37 @@ discard block |
||
23 | 23 | * constructor |
24 | 24 | * instantiated at init priority 5 |
25 | 25 | */ |
26 | - function __construct(){ |
|
26 | + function __construct() { |
|
27 | 27 | // register taxonomies |
28 | 28 | $taxonomies = self::get_taxonomies(); |
29 | - foreach ( $taxonomies as $taxonomy => $tax ) { |
|
30 | - $this->register_taxonomy( $taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args'] ); |
|
29 | + foreach ($taxonomies as $taxonomy => $tax) { |
|
30 | + $this->register_taxonomy($taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args']); |
|
31 | 31 | } |
32 | 32 | // register CPTs |
33 | - $CPTs =self::get_CPTs(); |
|
34 | - foreach ( $CPTs as $CPT_name => $CPT ) { |
|
35 | - $this->register_CPT( $CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'], $CPT['singular_slug'], $CPT['plural_slug'] ); |
|
33 | + $CPTs = self::get_CPTs(); |
|
34 | + foreach ($CPTs as $CPT_name => $CPT) { |
|
35 | + $this->register_CPT($CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'], $CPT['singular_slug'], $CPT['plural_slug']); |
|
36 | 36 | } |
37 | 37 | // setup default terms in any of our taxonomies (but only if we're in admin). |
38 | 38 | // Why not added via register_activation_hook? |
39 | 39 | // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin. |
40 | 40 | // Keep in mind that this will READ these terms if they are deleted by the user. Hence MUST use terms. |
41 | - if ( is_admin() ) { |
|
41 | + if (is_admin()) { |
|
42 | 42 | $this->set_must_use_event_types(); |
43 | 43 | } |
44 | 44 | //set default terms |
45 | - $this->set_default_term( 'espresso_event_type', 'single-event', array('espresso_events') ); |
|
45 | + $this->set_default_term('espresso_event_type', 'single-event', array('espresso_events')); |
|
46 | 46 | |
47 | 47 | |
48 | - add_action( 'AHEE__EE_System__initialize_last', array( __CLASS__, 'maybe_flush_rewrite_rules' ), 10 ); |
|
48 | + add_action('AHEE__EE_System__initialize_last', array(__CLASS__, 'maybe_flush_rewrite_rules'), 10); |
|
49 | 49 | |
50 | 50 | //hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts IF they don't have a term for that taxonomy set. |
51 | - add_action('save_post', array( $this, 'save_default_term' ), 100, 2 ); |
|
51 | + add_action('save_post', array($this, 'save_default_term'), 100, 2); |
|
52 | 52 | |
53 | 53 | //remove no html restrictions from core wp saving of term descriptions. Note. this will affect only registered EE taxonomies. |
54 | 54 | $this->_allow_html_descriptions_for_ee_taxonomies(); |
55 | 55 | |
56 | - do_action( 'AHEE__EE_Register_CPTs__construct_end', $this ); |
|
56 | + do_action('AHEE__EE_Register_CPTs__construct_end', $this); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @return void |
67 | 67 | */ |
68 | 68 | public static function maybe_flush_rewrite_rules() { |
69 | - if ( get_option( 'ee_flush_rewrite_rules', TRUE )) { |
|
69 | + if (get_option('ee_flush_rewrite_rules', TRUE)) { |
|
70 | 70 | flush_rewrite_rules(); |
71 | - update_option( 'ee_flush_rewrite_rules', FALSE ); |
|
71 | + update_option('ee_flush_rewrite_rules', FALSE); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | protected function _allow_html_descriptions_for_ee_taxonomies() { |
84 | 84 | //first remove default filter for term description but we have to do this earlier before wp sets their own filter |
85 | 85 | //because they just set a global filter on all term descriptions before the custom term description filter. Really sux. |
86 | - add_filter( 'pre_term_description', array( $this, 'ee_filter_ee_term_description_not_wp' ), 1, 2 ); |
|
86 | + add_filter('pre_term_description', array($this, 'ee_filter_ee_term_description_not_wp'), 1, 2); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -93,16 +93,16 @@ discard block |
||
93 | 93 | * @param string $taxonomy The taxonomy name for the taxonomy being filtered. |
94 | 94 | * @return string |
95 | 95 | */ |
96 | - public function ee_filter_ee_term_description_not_wp( $description, $taxonomy ) { |
|
96 | + public function ee_filter_ee_term_description_not_wp($description, $taxonomy) { |
|
97 | 97 | //get a list of EE taxonomies |
98 | - $ee_taxonomies = array_keys( self::get_taxonomies() ); |
|
98 | + $ee_taxonomies = array_keys(self::get_taxonomies()); |
|
99 | 99 | |
100 | 100 | //only do our own thing if the taxonomy listed is an ee taxonomy. |
101 | - if ( in_array( $taxonomy, $ee_taxonomies ) ) { |
|
101 | + if (in_array($taxonomy, $ee_taxonomies)) { |
|
102 | 102 | //remove default wp filter |
103 | - remove_filter( 'pre_term_description', 'wp_filter_kses' ); |
|
103 | + remove_filter('pre_term_description', 'wp_filter_kses'); |
|
104 | 104 | //sanitize THIS content. |
105 | - $description = wp_kses( $description, wp_kses_allowed_html( 'post' ) ); |
|
105 | + $description = wp_kses($description, wp_kses_allowed_html('post')); |
|
106 | 106 | } |
107 | 107 | return $description; |
108 | 108 | } |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @access public |
117 | 117 | * @return array |
118 | 118 | */ |
119 | - public static function get_taxonomies(){ |
|
119 | + public static function get_taxonomies() { |
|
120 | 120 | // define taxonomies |
121 | - return apply_filters( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( |
|
121 | + return apply_filters('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( |
|
122 | 122 | 'espresso_event_categories' => array( |
123 | 123 | 'singular_name' => __("Event Category", "event_espresso"), |
124 | 124 | 'plural_name' => __("Event Categories", "event_espresso"), |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | 'delete_terms' => 'ee_delete_event_category', |
133 | 133 | 'assign_terms' => 'ee_assign_event_category' |
134 | 134 | ), |
135 | - 'rewrite' => array( 'slug' => __( 'event-category', 'event_espresso' )) |
|
135 | + 'rewrite' => array('slug' => __('event-category', 'event_espresso')) |
|
136 | 136 | )), |
137 | 137 | 'espresso_venue_categories' => array( |
138 | 138 | 'singular_name' => __("Venue Category", "event_espresso"), |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | 'delete_terms' => 'ee_delete_venue_category', |
148 | 148 | 'assign_terms' => 'ee_assign_venue_category' |
149 | 149 | ), |
150 | - 'rewrite' => array( 'slug' => __( 'venue-category', 'event_espresso' )) |
|
150 | + 'rewrite' => array('slug' => __('venue-category', 'event_espresso')) |
|
151 | 151 | )), |
152 | 152 | 'espresso_event_type' => array( |
153 | 153 | 'singular_name' => __("Event Type", "event_espresso"), |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | 'delete_terms' => 'ee_delete_event_type', |
163 | 163 | 'assign_terms' => 'ee_assign_event_type' |
164 | 164 | ), |
165 | - 'rewrite' => array( 'slug' => __( 'event-type', 'event_espresso' )), |
|
165 | + 'rewrite' => array('slug' => __('event-type', 'event_espresso')), |
|
166 | 166 | 'hierarchical'=>true |
167 | 167 | )) |
168 | - ) ); |
|
168 | + )); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
@@ -183,26 +183,26 @@ discard block |
||
183 | 183 | * @return array Empty array if no matching model names for the given slug or an array of model |
184 | 184 | * names indexed by post type slug. |
185 | 185 | */ |
186 | - public static function get_cpt_model_names( $post_type_slug = '' ) { |
|
186 | + public static function get_cpt_model_names($post_type_slug = '') { |
|
187 | 187 | $cpts = self::get_CPTs(); |
188 | 188 | |
189 | 189 | //first if slug passed in... |
190 | - if ( ! empty( $post_type_slug ) ) { |
|
190 | + if ( ! empty($post_type_slug)) { |
|
191 | 191 | //match? |
192 | - if ( ! isset( $cpts[$post_type_slug] ) || ( isset( $cpts[$post_type_slug] ) && empty( $cpts[$post_type_slug]['class_name'] ) ) ) { |
|
192 | + if ( ! isset($cpts[$post_type_slug]) || (isset($cpts[$post_type_slug]) && empty($cpts[$post_type_slug]['class_name']))) { |
|
193 | 193 | return array(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | //k let's get the model name for this cpt. |
197 | - return array( $post_type_slug => str_replace( 'EE', 'EEM', $cpts[$post_type_slug]['class_name'] ) ); |
|
197 | + return array($post_type_slug => str_replace('EE', 'EEM', $cpts[$post_type_slug]['class_name'])); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
201 | 201 | //if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
202 | 202 | $cpt_models = array(); |
203 | - foreach ( $cpts as $slug => $args ) { |
|
204 | - if ( ! empty( $args['class_name'] ) ) { |
|
205 | - $cpt_models[$slug] = str_replace( 'EE', 'EEM', $args['class_name'] ); |
|
203 | + foreach ($cpts as $slug => $args) { |
|
204 | + if ( ! empty($args['class_name'])) { |
|
205 | + $cpt_models[$slug] = str_replace('EE', 'EEM', $args['class_name']); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | return $cpt_models; |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated EEM |
224 | 224 | * models indexed by post slug. |
225 | 225 | */ |
226 | - public static function instantiate_cpt_models( $post_type_slug = '' ) { |
|
227 | - $cpt_model_names = self::get_cpt_model_names( $post_type_slug ); |
|
226 | + public static function instantiate_cpt_models($post_type_slug = '') { |
|
227 | + $cpt_model_names = self::get_cpt_model_names($post_type_slug); |
|
228 | 228 | $instantiated = array(); |
229 | - foreach ( $cpt_model_names as $slug => $model_name ) { |
|
230 | - $instance = EE_Registry::instance()->load_model( str_replace( 'EEM_', '', $model_name ) ); |
|
231 | - if ( $instance instanceof EEM_CPT_Base ) { |
|
229 | + foreach ($cpt_model_names as $slug => $model_name) { |
|
230 | + $instance = EE_Registry::instance()->load_model(str_replace('EEM_', '', $model_name)); |
|
231 | + if ($instance instanceof EEM_CPT_Base) { |
|
232 | 232 | $instantiated[$slug] = $instance; |
233 | 233 | } |
234 | 234 | } |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | * @access public |
246 | 246 | * @return array |
247 | 247 | */ |
248 | - public static function get_CPTs(){ |
|
248 | + public static function get_CPTs() { |
|
249 | 249 | // define CPTs |
250 | 250 | // NOTE the ['args']['page_templates'] array index is something specific to our CPTs and not part of the WP custom post type api. |
251 | - return apply_filters( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', array( |
|
251 | + return apply_filters('FHEE__EE_Register_CPTs__get_CPTs__cpts', array( |
|
252 | 252 | 'espresso_events' => array( |
253 | 253 | 'singular_name' => __("Event", "event_espresso"), |
254 | 254 | 'plural_name' => __("Events", "event_espresso"), |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | 'publicly_queryable'=> FALSE, |
324 | 324 | 'hierarchical'=> FALSE, |
325 | 325 | 'has_archive' => FALSE, |
326 | - 'taxonomies' => array( 'post_tag' ), |
|
326 | + 'taxonomies' => array('post_tag'), |
|
327 | 327 | 'capability_type' => 'contact', |
328 | 328 | 'capabilities' => array( |
329 | 329 | 'edit_post' => 'ee_edit_contact', |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | 'edit_private_posts' => 'ee_edit_contacts', |
341 | 341 | 'edit_published_posts' => 'ee_edit_contacts' |
342 | 342 | ), |
343 | - 'supports' => array( 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments' ), |
|
343 | + 'supports' => array('editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'), |
|
344 | 344 | )) |
345 | - ) ); |
|
345 | + )); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | public static function get_private_CPTs() { |
356 | 356 | $CPTs = self::get_CPTs(); |
357 | 357 | $private_CPTs = array(); |
358 | - foreach ( $CPTs as $CPT => $details ) { |
|
359 | - if ( empty( $details['args']['public'] ) ) |
|
360 | - $private_CPTs[ $CPT ] = $details; |
|
358 | + foreach ($CPTs as $CPT => $details) { |
|
359 | + if (empty($details['args']['public'])) |
|
360 | + $private_CPTs[$CPT] = $details; |
|
361 | 361 | } |
362 | 362 | return $private_CPTs; |
363 | 363 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param string $plural_name internationalized plural name |
376 | 376 | * @param array $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy |
377 | 377 | */ |
378 | - function register_taxonomy( $taxonomy_name, $singular_name, $plural_name, $override_args = array() ){ |
|
378 | + function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array()) { |
|
379 | 379 | |
380 | 380 | $args = array( |
381 | 381 | 'hierarchical' => true, |
@@ -392,15 +392,15 @@ discard block |
||
392 | 392 | //'rewrite' => array( 'slug' => 'genre' ), |
393 | 393 | ); |
394 | 394 | |
395 | - if($override_args){ |
|
396 | - if(isset($override_args['labels'])){ |
|
397 | - $labels = array_merge($args['labels'],$override_args['labels']); |
|
395 | + if ($override_args) { |
|
396 | + if (isset($override_args['labels'])) { |
|
397 | + $labels = array_merge($args['labels'], $override_args['labels']); |
|
398 | 398 | $args['labels'] = $labels; |
399 | 399 | } |
400 | - $args = array_merge($args,$override_args); |
|
400 | + $args = array_merge($args, $override_args); |
|
401 | 401 | |
402 | 402 | } |
403 | - register_taxonomy($taxonomy_name,null, $args); |
|
403 | + register_taxonomy($taxonomy_name, null, $args); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -414,27 +414,27 @@ discard block |
||
414 | 414 | * The default values set in this function will be overridden by whatever you set in $override_args |
415 | 415 | * @return void, but registers the custom post type |
416 | 416 | */ |
417 | - function register_CPT($post_type, $singular_name,$plural_name,$override_args = array(), $singular_slug = '', $plural_slug = '' ) { |
|
417 | + function register_CPT($post_type, $singular_name, $plural_name, $override_args = array(), $singular_slug = '', $plural_slug = '') { |
|
418 | 418 | |
419 | 419 | $labels = array( |
420 | 420 | 'name' => $plural_name, |
421 | 421 | 'singular_name' => $singular_name, |
422 | - 'add_new' => sprintf(__("Add %s", "event_espresso"),$singular_name), |
|
423 | - 'add_new_item' => sprintf(__("Add New %s", "event_espresso"),$singular_name), |
|
424 | - 'edit_item' => sprintf(__("Edit %s", "event_espresso"),$singular_name), |
|
425 | - 'new_item' => sprintf(__("New %s", "event_espresso"),$singular_name), |
|
426 | - 'all_items' => sprintf(__("All %s", "event_espresso"),$plural_name), |
|
427 | - 'view_item' => sprintf(__("View %s", "event_espresso"),$singular_name), |
|
428 | - 'search_items' => sprintf(__("Search %s", "event_espresso"),$plural_name), |
|
429 | - 'not_found' => sprintf(__("No %s found", "event_espresso"),$plural_name), |
|
430 | - 'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"),$plural_name), |
|
422 | + 'add_new' => sprintf(__("Add %s", "event_espresso"), $singular_name), |
|
423 | + 'add_new_item' => sprintf(__("Add New %s", "event_espresso"), $singular_name), |
|
424 | + 'edit_item' => sprintf(__("Edit %s", "event_espresso"), $singular_name), |
|
425 | + 'new_item' => sprintf(__("New %s", "event_espresso"), $singular_name), |
|
426 | + 'all_items' => sprintf(__("All %s", "event_espresso"), $plural_name), |
|
427 | + 'view_item' => sprintf(__("View %s", "event_espresso"), $singular_name), |
|
428 | + 'search_items' => sprintf(__("Search %s", "event_espresso"), $plural_name), |
|
429 | + 'not_found' => sprintf(__("No %s found", "event_espresso"), $plural_name), |
|
430 | + 'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"), $plural_name), |
|
431 | 431 | 'parent_item_colon' => '', |
432 | - 'menu_name' => sprintf(__("%s", "event_espresso"),$plural_name) |
|
432 | + 'menu_name' => sprintf(__("%s", "event_espresso"), $plural_name) |
|
433 | 433 | ); |
434 | 434 | |
435 | 435 | //verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name |
436 | - $singular_slug = ! empty( $singular_slug ) ? $singular_slug : $singular_name; |
|
437 | - $plural_slug = ! empty( $plural_slug ) ? $plural_slug : $plural_name; |
|
436 | + $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name; |
|
437 | + $plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name; |
|
438 | 438 | |
439 | 439 | |
440 | 440 | //note the page_templates arg in the supports index is something specific to EE. WordPress doesn't actually have that in their register_post_type api. |
@@ -447,24 +447,24 @@ discard block |
||
447 | 447 | 'show_in_menu' => false, |
448 | 448 | 'show_in_nav_menus' => false, |
449 | 449 | 'query_var' => true, |
450 | - 'rewrite' => apply_filters( 'FHEE__EE_Register_CPTs__register_CPT__rewrite', array( 'slug' => $plural_slug ), $post_type ), |
|
450 | + 'rewrite' => apply_filters('FHEE__EE_Register_CPTs__register_CPT__rewrite', array('slug' => $plural_slug), $post_type), |
|
451 | 451 | 'capability_type' => 'post', |
452 | 452 | 'map_meta_cap' => true, |
453 | 453 | 'has_archive' => true, |
454 | 454 | 'hierarchical' => true, |
455 | 455 | 'menu_position' => null, |
456 | - 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments' ) |
|
456 | + 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments') |
|
457 | 457 | ); |
458 | 458 | |
459 | - if($override_args){ |
|
460 | - if(isset($override_args['labels'])){ |
|
461 | - $labels = array_merge($args['labels'],$override_args['labels']); |
|
459 | + if ($override_args) { |
|
460 | + if (isset($override_args['labels'])) { |
|
461 | + $labels = array_merge($args['labels'], $override_args['labels']); |
|
462 | 462 | } |
463 | - $args = array_merge($args,$override_args); |
|
463 | + $args = array_merge($args, $override_args); |
|
464 | 464 | $args['labels'] = $labels; |
465 | 465 | } |
466 | 466 | |
467 | - register_post_type( $post_type, $args ); |
|
467 | + register_post_type($post_type, $args); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | |
@@ -473,15 +473,15 @@ discard block |
||
473 | 473 | function set_must_use_event_types() { |
474 | 474 | $term_details = array( |
475 | 475 | //Attendee's register for the first date-time only |
476 | - 'single-event' => array( __('Single Event', 'event_espresso'), __('A single event that spans one or more consecutive days.', 'event_espresso') ), //example: a party or two-day long workshop |
|
476 | + 'single-event' => array(__('Single Event', 'event_espresso'), __('A single event that spans one or more consecutive days.', 'event_espresso')), //example: a party or two-day long workshop |
|
477 | 477 | //Attendee's can register for any of the date-times |
478 | - 'multi-event' => array( __('Multi Event', 'event_espresso'), __('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso') ), //example: a three day music festival or week long conference |
|
478 | + 'multi-event' => array(__('Multi Event', 'event_espresso'), __('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso')), //example: a three day music festival or week long conference |
|
479 | 479 | //Attendee's register for the first date-time only |
480 | - 'event-series' => array( __('Event Series', 'event_espresso'), __(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso') ), //example: an 8 week introduction to basket weaving course |
|
480 | + 'event-series' => array(__('Event Series', 'event_espresso'), __(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso')), //example: an 8 week introduction to basket weaving course |
|
481 | 481 | //Attendee's can register for any of the date-times. |
482 | - 'recurring-event' => array( __('Recurring Event', 'event_espresso'), __('Multiple events that occur over multiple non-consecutive days.', 'event_espresso') ), //example: a yoga class |
|
482 | + 'recurring-event' => array(__('Recurring Event', 'event_espresso'), __('Multiple events that occur over multiple non-consecutive days.', 'event_espresso')), //example: a yoga class |
|
483 | 483 | |
484 | - 'ongoing' => array( __('Ongoing Event', 'event_espresso'), __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', 'event_espresso') ) //example: access to a museum |
|
484 | + 'ongoing' => array(__('Ongoing Event', 'event_espresso'), __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', 'event_espresso')) //example: access to a museum |
|
485 | 485 | |
486 | 486 | //'walk-in' => array( __('Walk In', 'event_espresso'), __('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ), |
487 | 487 | //'reservation' => array( __('Reservation', 'event_espresso'), __('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | //'appointment' => array( __('Appointments', 'event_espresso'), __('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') ) |
490 | 490 | |
491 | 491 | ); |
492 | - $this->set_must_use_terms( 'espresso_event_type', $term_details ); |
|
492 | + $this->set_must_use_terms('espresso_event_type', $term_details); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | |
@@ -503,16 +503,16 @@ discard block |
||
503 | 503 | * |
504 | 504 | * @return void |
505 | 505 | */ |
506 | - function set_must_use_terms( $taxonomy, $term_details ) { |
|
506 | + function set_must_use_terms($taxonomy, $term_details) { |
|
507 | 507 | $term_details = (array) $term_details; |
508 | 508 | |
509 | - foreach ( $term_details as $slug => $details ) { |
|
510 | - if ( !term_exists( $slug, $taxonomy ) ) { |
|
509 | + foreach ($term_details as $slug => $details) { |
|
510 | + if ( ! term_exists($slug, $taxonomy)) { |
|
511 | 511 | $insert_arr = array( |
512 | 512 | 'slug' => $slug, |
513 | 513 | 'description' => $details[1] |
514 | 514 | ); |
515 | - wp_insert_term( $details[0], $taxonomy, $insert_arr ); |
|
515 | + wp_insert_term($details[0], $taxonomy, $insert_arr); |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | } |
@@ -526,8 +526,8 @@ discard block |
||
526 | 526 | * @param string $term_slug The slug of the term that will be the default. |
527 | 527 | * @param array $cpt_slugs An array of custom post types we want the default assigned to |
528 | 528 | */ |
529 | - function set_default_term( $taxonomy, $term_slug, $cpt_slugs = array() ) { |
|
530 | - $this->_default_terms[][$term_slug] = new EE_Default_Term( $taxonomy, $term_slug, $cpt_slugs ); |
|
529 | + function set_default_term($taxonomy, $term_slug, $cpt_slugs = array()) { |
|
530 | + $this->_default_terms[][$term_slug] = new EE_Default_Term($taxonomy, $term_slug, $cpt_slugs); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | |
@@ -539,20 +539,20 @@ discard block |
||
539 | 539 | * @param object $post Post object |
540 | 540 | * @return void |
541 | 541 | */ |
542 | - function save_default_term( $post_id, $post ) { |
|
543 | - if ( empty( $this->_default_terms ) ) |
|
542 | + function save_default_term($post_id, $post) { |
|
543 | + if (empty($this->_default_terms)) |
|
544 | 544 | return; //no default terms set so lets just exit. |
545 | 545 | |
546 | - foreach ( $this->_default_terms as $defaults ) { |
|
547 | - foreach ( $defaults as $default_obj ) { |
|
548 | - if ( $post->post_status == 'publish' && in_array( $post->post_type, $default_obj->cpt_slugs ) ) { |
|
546 | + foreach ($this->_default_terms as $defaults) { |
|
547 | + foreach ($defaults as $default_obj) { |
|
548 | + if ($post->post_status == 'publish' && in_array($post->post_type, $default_obj->cpt_slugs)) { |
|
549 | 549 | |
550 | 550 | //note some error proofing going on here to save unnecessary db queries |
551 | - $taxonomies = get_object_taxonomies( $post->post_type ); |
|
552 | - foreach ( (array) $taxonomies as $taxonomy ) { |
|
553 | - $terms = wp_get_post_terms( $post_id, $taxonomy); |
|
554 | - if ( empty( $terms ) && $taxonomy == $default_obj->taxonomy ) { |
|
555 | - wp_set_object_terms( $post_id, array( $default_obj->term_slug ), $taxonomy ); |
|
551 | + $taxonomies = get_object_taxonomies($post->post_type); |
|
552 | + foreach ((array) $taxonomies as $taxonomy) { |
|
553 | + $terms = wp_get_post_terms($post_id, $taxonomy); |
|
554 | + if (empty($terms) && $taxonomy == $default_obj->taxonomy) { |
|
555 | + wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy); |
|
556 | 556 | } |
557 | 557 | } |
558 | 558 | } |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * @param string $term_slug The slug of the term that will be the default. |
585 | 585 | * @param array $cpt_slugs The custom post type the default term gets saved with |
586 | 586 | */ |
587 | - public function __construct( $taxonomy, $term_slug, $cpt_slugs = array() ) { |
|
587 | + public function __construct($taxonomy, $term_slug, $cpt_slugs = array()) { |
|
588 | 588 | $this->taxonomy = $taxonomy; |
589 | 589 | $this->cpt_slugs = (array) $cpt_slugs; |
590 | 590 | $this->term_slug = $term_slug; |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | && $most_recent_migration->is_broken() |
234 | 234 | ) |
235 | 235 | ) { |
236 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
236 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_was_borked_page.template.php'; |
|
237 | 237 | $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
238 | 238 | $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', |
239 | 239 | 'success' => '0', |
240 | 240 | ), EE_MAINTENANCE_ADMIN_URL); |
241 | 241 | } elseif ($addons_should_be_upgraded_first) { |
242 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
242 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_upgrade_addons_before_migrating.template.php'; |
|
243 | 243 | } else { |
244 | 244 | if ($most_recent_migration |
245 | 245 | && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $new_version, $plugin_slug) : null, |
267 | 267 | )); |
268 | 268 | } |
269 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
269 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_page.template.php'; |
|
270 | 270 | $this->_template_args = array_merge( |
271 | 271 | $this->_template_args, |
272 | 272 | array( |
@@ -303,13 +303,13 @@ discard block |
||
303 | 303 | 'status_completed' => EE_Data_Migration_Manager::status_completed, |
304 | 304 | )); |
305 | 305 | } |
306 | - $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
306 | + $this->_template_args['most_recent_migration'] = $most_recent_migration; //the actual most recently ran migration |
|
307 | 307 | //now render the migration options part, and put it in a variable |
308 | 308 | $migration_options_template_file = apply_filters( |
309 | 309 | 'FHEE__ee_migration_page__migration_options_template', |
310 | - EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php' |
|
310 | + EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee4.template.php' |
|
311 | 311 | ); |
312 | - $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true); |
|
312 | + $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args, true); |
|
313 | 313 | $this->_template_args['migration_options_html'] = $migration_options_html; |
314 | 314 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
315 | 315 | $this->_template_args, true); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | */ |
368 | 368 | public function _data_reset_and_delete() |
369 | 369 | { |
370 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
370 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_data_reset_and_delete.template.php'; |
|
371 | 371 | $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button( |
372 | 372 | 'reset_capabilities', |
373 | 373 | 'reset_capabilities', |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | */ |
423 | 423 | public function _system_status() |
424 | 424 | { |
425 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
425 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_system_stati_page.template.php'; |
|
426 | 426 | $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
427 | 427 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
428 | 428 | $this->_template_args, true); |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | try { |
440 | 440 | $success = wp_mail(EE_SUPPORT_EMAIL, |
441 | 441 | 'Migration Crash Report', |
442 | - $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
442 | + $body."/r/n<br>".print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
443 | 443 | array( |
444 | 444 | "from:$from_name<$from>", |
445 | 445 | // 'content-type:text/html charset=UTF-8' |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | EE_MAINTENANCE_ADMIN_URL); |
475 | 475 | $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), |
476 | 476 | EE_MAINTENANCE_ADMIN_URL); |
477 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
477 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_confirm_migration_crash_report_sent.template.php'; |
|
478 | 478 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
479 | 479 | $this->_template_args, true); |
480 | 480 | $this->display_admin_page_with_sidebar(); |
@@ -575,9 +575,9 @@ discard block |
||
575 | 575 | wp_enqueue_script('ee_admin_js'); |
576 | 576 | // wp_enqueue_media(); |
577 | 577 | // wp_enqueue_script('media-upload'); |
578 | - wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'), |
|
578 | + wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL.'/ee-maintenance.js', array('jquery'), |
|
579 | 579 | EVENT_ESPRESSO_VERSION, true); |
580 | - wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), |
|
580 | + wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL.'ee-maintenance.css', array(), |
|
581 | 581 | EVENT_ESPRESSO_VERSION); |
582 | 582 | wp_enqueue_style('espresso_maintenance'); |
583 | 583 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -28,571 +28,571 @@ discard block |
||
28 | 28 | { |
29 | 29 | |
30 | 30 | |
31 | - public function __construct($routing = true) |
|
32 | - { |
|
33 | - parent::__construct($routing); |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - |
|
38 | - protected function _init_page_props() |
|
39 | - { |
|
40 | - $this->page_slug = EE_MAINTENANCE_PG_SLUG; |
|
41 | - $this->page_label = EE_MAINTENANCE_LABEL; |
|
42 | - $this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL; |
|
43 | - $this->_admin_base_path = EE_MAINTENANCE_ADMIN; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - protected function _ajax_hooks() |
|
49 | - { |
|
50 | - add_action('wp_ajax_migration_step', array($this, 'migration_step')); |
|
51 | - add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran')); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - protected function _define_page_props() |
|
57 | - { |
|
58 | - $this->_admin_page_title = EE_MAINTENANCE_LABEL; |
|
59 | - $this->_labels = array( |
|
60 | - 'buttons' => array( |
|
61 | - 'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'), |
|
62 | - ), |
|
63 | - ); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - protected function _set_page_routes() |
|
69 | - { |
|
70 | - $this->_page_routes = array( |
|
71 | - 'default' => array( |
|
72 | - 'func' => '_maintenance', |
|
73 | - 'capability' => 'manage_options', |
|
74 | - ), |
|
75 | - 'change_maintenance_level' => array( |
|
76 | - 'func' => '_change_maintenance_level', |
|
77 | - 'capability' => 'manage_options', |
|
78 | - 'noheader' => true, |
|
79 | - ), |
|
80 | - 'system_status' => array( |
|
81 | - 'func' => '_system_status', |
|
82 | - 'capability' => 'manage_options', |
|
83 | - ), |
|
84 | - 'send_migration_crash_report' => array( |
|
85 | - 'func' => '_send_migration_crash_report', |
|
86 | - 'capability' => 'manage_options', |
|
87 | - 'noheader' => true, |
|
88 | - ), |
|
89 | - 'confirm_migration_crash_report_sent' => array( |
|
90 | - 'func' => '_confirm_migration_crash_report_sent', |
|
91 | - 'capability' => 'manage_options', |
|
92 | - ), |
|
93 | - 'data_reset' => array( |
|
94 | - 'func' => '_data_reset_and_delete', |
|
95 | - 'capability' => 'manage_options', |
|
96 | - ), |
|
97 | - 'reset_db' => array( |
|
98 | - 'func' => '_reset_db', |
|
99 | - 'capability' => 'manage_options', |
|
100 | - 'noheader' => true, |
|
101 | - 'args' => array('nuke_old_ee4_data' => true), |
|
102 | - ), |
|
103 | - 'start_with_fresh_ee4_db' => array( |
|
104 | - 'func' => '_reset_db', |
|
105 | - 'capability' => 'manage_options', |
|
106 | - 'noheader' => true, |
|
107 | - 'args' => array('nuke_old_ee4_data' => false), |
|
108 | - ), |
|
109 | - 'delete_db' => array( |
|
110 | - 'func' => '_delete_db', |
|
111 | - 'capability' => 'manage_options', |
|
112 | - 'noheader' => true, |
|
113 | - ), |
|
114 | - 'rerun_migration_from_ee3' => array( |
|
115 | - 'func' => '_rerun_migration_from_ee3', |
|
116 | - 'capability' => 'manage_options', |
|
117 | - 'noheader' => true, |
|
118 | - ), |
|
119 | - 'reset_capabilities' => array( |
|
120 | - 'func' => '_reset_capabilities', |
|
121 | - 'capability' => 'manage_options', |
|
122 | - 'noheader' => true, |
|
123 | - ), |
|
124 | - 'reattempt_migration' => array( |
|
125 | - 'func' => '_reattempt_migration', |
|
126 | - 'capability' => 'manage_options', |
|
127 | - 'noheader' => true, |
|
128 | - ), |
|
129 | - ); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - |
|
134 | - protected function _set_page_config() |
|
135 | - { |
|
136 | - $this->_page_config = array( |
|
137 | - 'default' => array( |
|
138 | - 'nav' => array( |
|
139 | - 'label' => esc_html__('Maintenance', 'event_espresso'), |
|
140 | - 'order' => 10, |
|
141 | - ), |
|
142 | - 'require_nonce' => false, |
|
143 | - ), |
|
144 | - 'data_reset' => array( |
|
145 | - 'nav' => array( |
|
146 | - 'label' => esc_html__('Reset/Delete Data', 'event_espresso'), |
|
147 | - 'order' => 20, |
|
148 | - ), |
|
149 | - 'require_nonce' => false, |
|
150 | - ), |
|
151 | - 'system_status' => array( |
|
152 | - 'nav' => array( |
|
153 | - 'label' => esc_html__("System Information", "event_espresso"), |
|
154 | - 'order' => 30, |
|
155 | - ), |
|
156 | - 'require_nonce' => false, |
|
157 | - ), |
|
158 | - ); |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * default maintenance page. If we're in maintenance mode level 2, then we need to show |
|
165 | - * the migration scripts and all that UI. |
|
166 | - */ |
|
167 | - public function _maintenance() |
|
168 | - { |
|
169 | - //it all depends if we're in maintenance model level 1 (frontend-only) or |
|
170 | - //level 2 (everything except maintenance page) |
|
171 | - try { |
|
172 | - //get the current maintenance level and check if |
|
173 | - //we are removed |
|
174 | - $mm = EE_Maintenance_Mode::instance()->level(); |
|
175 | - $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
176 | - if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) { |
|
177 | - //we just took the site out of maintenance mode, so notify the user. |
|
178 | - //unfortunately this message appears to be echoed on the NEXT page load... |
|
179 | - //oh well, we should really be checking for this on addon deactivation anyways |
|
180 | - EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required', |
|
181 | - 'event_espresso')); |
|
182 | - $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false); |
|
183 | - } |
|
184 | - //in case an exception is thrown while trying to handle migrations |
|
185 | - switch (EE_Maintenance_Mode::instance()->level()) { |
|
186 | - case EE_Maintenance_Mode::level_0_not_in_maintenance: |
|
187 | - case EE_Maintenance_Mode::level_1_frontend_only_maintenance: |
|
188 | - $show_maintenance_switch = true; |
|
189 | - $show_backup_db_text = false; |
|
190 | - $show_migration_progress = false; |
|
191 | - $script_names = array(); |
|
192 | - $addons_should_be_upgraded_first = false; |
|
193 | - break; |
|
194 | - case EE_Maintenance_Mode::level_2_complete_maintenance: |
|
195 | - $show_maintenance_switch = false; |
|
196 | - $show_migration_progress = true; |
|
197 | - if (isset($this->_req_data['continue_migration'])) { |
|
198 | - $show_backup_db_text = false; |
|
199 | - } else { |
|
200 | - $show_backup_db_text = true; |
|
201 | - } |
|
202 | - $scripts_needing_to_run = EE_Data_Migration_Manager::instance() |
|
203 | - ->check_for_applicable_data_migration_scripts(); |
|
204 | - $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating(); |
|
205 | - $script_names = array(); |
|
206 | - $current_script = null; |
|
207 | - foreach ($scripts_needing_to_run as $script) { |
|
208 | - if ($script instanceof EE_Data_Migration_Script_Base) { |
|
209 | - if ( ! $current_script) { |
|
210 | - $current_script = $script; |
|
211 | - $current_script->migration_page_hooks(); |
|
212 | - } |
|
213 | - $script_names[] = $script->pretty_name(); |
|
214 | - } |
|
215 | - } |
|
216 | - break; |
|
217 | - } |
|
218 | - $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
219 | - $exception_thrown = false; |
|
220 | - } catch (EE_Error $e) { |
|
221 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
222 | - //now, just so we can display the page correctly, make a error migration script stage object |
|
223 | - //and also put the error on it. It only persists for the duration of this request |
|
224 | - $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
225 | - $most_recent_migration->add_error($e->getMessage()); |
|
226 | - $exception_thrown = true; |
|
227 | - } |
|
228 | - $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set(); |
|
229 | - $current_db_state = str_replace('.decaf', '', $current_db_state); |
|
230 | - if ($exception_thrown |
|
231 | - || ($most_recent_migration |
|
232 | - && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
233 | - && $most_recent_migration->is_broken() |
|
234 | - ) |
|
235 | - ) { |
|
236 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
237 | - $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
|
238 | - $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', |
|
239 | - 'success' => '0', |
|
240 | - ), EE_MAINTENANCE_ADMIN_URL); |
|
241 | - } elseif ($addons_should_be_upgraded_first) { |
|
242 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
243 | - } else { |
|
244 | - if ($most_recent_migration |
|
245 | - && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
246 | - && $most_recent_migration->can_continue() |
|
247 | - ) { |
|
248 | - $show_backup_db_text = false; |
|
249 | - $show_continue_current_migration_script = true; |
|
250 | - $show_most_recent_migration = true; |
|
251 | - } elseif (isset($this->_req_data['continue_migration'])) { |
|
252 | - $show_most_recent_migration = true; |
|
253 | - $show_continue_current_migration_script = false; |
|
254 | - } else { |
|
255 | - $show_most_recent_migration = false; |
|
256 | - $show_continue_current_migration_script = false; |
|
257 | - } |
|
258 | - if (isset($current_script)) { |
|
259 | - $migrates_to = $current_script->migrates_to_version(); |
|
260 | - $plugin_slug = $migrates_to['slug']; |
|
261 | - $new_version = $migrates_to['version']; |
|
262 | - $this->_template_args = array_merge($this->_template_args, array( |
|
263 | - 'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"), |
|
264 | - isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug), |
|
265 | - 'next_db_state' => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'), |
|
266 | - $new_version, $plugin_slug) : null, |
|
267 | - )); |
|
268 | - } |
|
269 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
270 | - $this->_template_args = array_merge( |
|
271 | - $this->_template_args, |
|
272 | - array( |
|
273 | - 'show_most_recent_migration' => $show_most_recent_migration, |
|
274 | - //flag for showing the most recent migration's status and/or errors |
|
275 | - 'show_migration_progress' => $show_migration_progress, |
|
276 | - //flag for showing the option to run migrations and see their progress |
|
277 | - 'show_backup_db_text' => $show_backup_db_text, |
|
278 | - //flag for showing text telling the user to backup their DB |
|
279 | - 'show_maintenance_switch' => $show_maintenance_switch, |
|
280 | - //flag for showing the option to change maintenance mode between levels 0 and 1 |
|
281 | - 'script_names' => $script_names, |
|
282 | - //array of names of scripts that have run |
|
283 | - 'show_continue_current_migration_script' => $show_continue_current_migration_script, |
|
284 | - //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0 |
|
285 | - 'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
286 | - EE_MAINTENANCE_ADMIN_URL), |
|
287 | - 'data_reset_page' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
288 | - EE_MAINTENANCE_ADMIN_URL), |
|
289 | - 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'), |
|
290 | - EE_MAINTENANCE_ADMIN_URL), |
|
291 | - 'ultimate_db_state' => sprintf(__("EE%s", 'event_espresso'), |
|
292 | - espresso_version()), |
|
293 | - ) |
|
294 | - ); |
|
295 | - //make sure we have the form fields helper available. It usually is, but sometimes it isn't |
|
296 | - //localize script stuff |
|
297 | - wp_localize_script('ee-maintenance', 'ee_maintenance', array( |
|
298 | - 'migrating' => esc_html__("Updating Database...", "event_espresso"), |
|
299 | - 'next' => esc_html__("Next", "event_espresso"), |
|
300 | - 'fatal_error' => esc_html__("A Fatal Error Has Occurred", "event_espresso"), |
|
301 | - 'click_next_when_ready' => esc_html__("The current Database Update has ended. Click 'next' when ready to proceed", |
|
302 | - "event_espresso"), |
|
303 | - 'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts, |
|
304 | - 'status_fatal_error' => EE_Data_Migration_Manager::status_fatal_error, |
|
305 | - 'status_completed' => EE_Data_Migration_Manager::status_completed, |
|
306 | - )); |
|
307 | - } |
|
308 | - $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
309 | - //now render the migration options part, and put it in a variable |
|
310 | - $migration_options_template_file = apply_filters( |
|
311 | - 'FHEE__ee_migration_page__migration_options_template', |
|
312 | - EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php' |
|
313 | - ); |
|
314 | - $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true); |
|
315 | - $this->_template_args['migration_options_html'] = $migration_options_html; |
|
316 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
317 | - $this->_template_args, true); |
|
318 | - $this->display_admin_page_with_sidebar(); |
|
319 | - } |
|
320 | - |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * returns JSON and executes another step of the currently-executing data migration (called via ajax) |
|
325 | - */ |
|
326 | - public function migration_step() |
|
327 | - { |
|
328 | - $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request(); |
|
329 | - $this->_return_json(); |
|
330 | - } |
|
331 | - |
|
332 | - |
|
333 | - |
|
334 | - /** |
|
335 | - * Can be used by js when it notices a response with HTML in it in order |
|
336 | - * to log the malformed response |
|
337 | - */ |
|
338 | - public function add_error_to_migrations_ran() |
|
339 | - { |
|
340 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']); |
|
341 | - $this->_template_args['data'] = array('ok' => true); |
|
342 | - $this->_return_json(); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * changes the maintenance level, provided there are still no migration scripts that shoudl run |
|
349 | - */ |
|
350 | - public function _change_maintenance_level() |
|
351 | - { |
|
352 | - $new_level = intval($this->_req_data['maintenance_mode_level']); |
|
353 | - if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
354 | - EE_Maintenance_Mode::instance()->set_maintenance_level($new_level); |
|
355 | - $success = true; |
|
356 | - } else { |
|
357 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
358 | - $success = false; |
|
359 | - } |
|
360 | - $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso")); |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * a tab with options for resetting and/or deleting EE data |
|
367 | - * |
|
368 | - * @throws \EE_Error |
|
369 | - */ |
|
370 | - public function _data_reset_and_delete() |
|
371 | - { |
|
372 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
373 | - $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button( |
|
374 | - 'reset_capabilities', |
|
375 | - 'reset_capabilities', |
|
376 | - array(), |
|
377 | - 'button button-primary', |
|
378 | - '', |
|
379 | - false |
|
380 | - ); |
|
381 | - $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
382 | - array('action' => 'delete_db'), |
|
383 | - EE_MAINTENANCE_ADMIN_URL |
|
384 | - ); |
|
385 | - $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
386 | - array('action' => 'reset_db'), |
|
387 | - EE_MAINTENANCE_ADMIN_URL |
|
388 | - ); |
|
389 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
390 | - $this->_template_path, |
|
391 | - $this->_template_args, |
|
392 | - true |
|
393 | - ); |
|
394 | - $this->display_admin_page_with_sidebar(); |
|
395 | - } |
|
396 | - |
|
397 | - |
|
398 | - |
|
399 | - protected function _reset_capabilities() |
|
400 | - { |
|
401 | - EE_Registry::instance()->CAP->init_caps(true); |
|
402 | - EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.', |
|
403 | - 'event_espresso')); |
|
404 | - $this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true); |
|
405 | - } |
|
406 | - |
|
407 | - |
|
408 | - |
|
409 | - /** |
|
410 | - * resets the DMSs so we can attempt to continue migrating after a fatal error |
|
411 | - * (only a good idea when someone has somehow tried ot fix whatever caused |
|
412 | - * the fatal error in teh first place) |
|
413 | - */ |
|
414 | - protected function _reattempt_migration() |
|
415 | - { |
|
416 | - EE_Data_Migration_Manager::instance()->reattempt(); |
|
417 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), true); |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * shows the big ol' System Information page |
|
424 | - */ |
|
425 | - public function _system_status() |
|
426 | - { |
|
427 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
428 | - $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
|
429 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
430 | - $this->_template_args, true); |
|
431 | - $this->display_admin_page_with_sidebar(); |
|
432 | - } |
|
433 | - |
|
434 | - |
|
435 | - |
|
436 | - public function _send_migration_crash_report() |
|
437 | - { |
|
438 | - $from = $this->_req_data['from']; |
|
439 | - $from_name = $this->_req_data['from_name']; |
|
440 | - $body = $this->_req_data['body']; |
|
441 | - try { |
|
442 | - $success = wp_mail(EE_SUPPORT_EMAIL, |
|
443 | - 'Migration Crash Report', |
|
444 | - $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
445 | - array( |
|
446 | - "from:$from_name<$from>", |
|
447 | - // 'content-type:text/html charset=UTF-8' |
|
448 | - )); |
|
449 | - } catch (Exception $e) { |
|
450 | - $success = false; |
|
451 | - } |
|
452 | - $this->_redirect_after_action($success, esc_html__("Migration Crash Report", "event_espresso"), |
|
453 | - esc_html__("sent", "event_espresso"), |
|
454 | - array('success' => $success, 'action' => 'confirm_migration_crash_report_sent')); |
|
455 | - } |
|
456 | - |
|
457 | - |
|
458 | - |
|
459 | - public function _confirm_migration_crash_report_sent() |
|
460 | - { |
|
461 | - try { |
|
462 | - $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
463 | - } catch (EE_Error $e) { |
|
464 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
465 | - //now, just so we can display the page correctly, make a error migration script stage object |
|
466 | - //and also put the error on it. It only persists for the duration of this request |
|
467 | - $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
468 | - $most_recent_migration->add_error($e->getMessage()); |
|
469 | - } |
|
470 | - $success = $this->_req_data['success'] == '1' ? true : false; |
|
471 | - $this->_template_args['success'] = $success; |
|
472 | - $this->_template_args['most_recent_migration'] = $most_recent_migration; |
|
473 | - $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
474 | - EE_MAINTENANCE_ADMIN_URL); |
|
475 | - $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
476 | - EE_MAINTENANCE_ADMIN_URL); |
|
477 | - $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), |
|
478 | - EE_MAINTENANCE_ADMIN_URL); |
|
479 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
480 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
481 | - $this->_template_args, true); |
|
482 | - $this->display_admin_page_with_sidebar(); |
|
483 | - } |
|
484 | - |
|
485 | - |
|
486 | - |
|
487 | - /** |
|
488 | - * Resets the entire EE4 database. |
|
489 | - * Currently basically only sets up ee4 database for a fresh install- doesn't |
|
490 | - * actually clean out the old wp options, or cpts (although does erase old ee table data) |
|
491 | - * |
|
492 | - * @param boolean $nuke_old_ee4_data controls whether or not we |
|
493 | - * destroy the old ee4 data, or just try initializing ee4 default data |
|
494 | - */ |
|
495 | - public function _reset_db($nuke_old_ee4_data = true) |
|
496 | - { |
|
497 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
498 | - if ($nuke_old_ee4_data) { |
|
499 | - EEH_Activation::delete_all_espresso_cpt_data(); |
|
500 | - EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
501 | - EEH_Activation::remove_cron_tasks(); |
|
502 | - } |
|
503 | - //make sure when we reset the registry's config that it |
|
504 | - //switches to using the new singleton |
|
505 | - EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true); |
|
506 | - EE_System::instance()->initialize_db_if_no_migrations_required(true); |
|
507 | - EE_System::instance()->redirect_to_about_ee(); |
|
508 | - } |
|
509 | - |
|
510 | - |
|
511 | - |
|
512 | - /** |
|
513 | - * Deletes ALL EE tables, Records, and Options from the database. |
|
514 | - */ |
|
515 | - public function _delete_db() |
|
516 | - { |
|
517 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
518 | - EEH_Activation::delete_all_espresso_cpt_data(); |
|
519 | - EEH_Activation::delete_all_espresso_tables_and_data(); |
|
520 | - EEH_Activation::remove_cron_tasks(); |
|
521 | - EEH_Activation::deactivate_event_espresso(); |
|
522 | - wp_safe_redirect(admin_url('plugins.php')); |
|
523 | - exit; |
|
524 | - } |
|
525 | - |
|
526 | - |
|
527 | - |
|
528 | - /** |
|
529 | - * sets up EE4 to rerun the migrations from ee3 to ee4 |
|
530 | - */ |
|
531 | - public function _rerun_migration_from_ee3() |
|
532 | - { |
|
533 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
534 | - EEH_Activation::delete_all_espresso_cpt_data(); |
|
535 | - EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
536 | - //set the db state to something that will require migrations |
|
537 | - update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0'); |
|
538 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance); |
|
539 | - $this->_redirect_after_action(true, esc_html__("Database", 'event_espresso'), esc_html__("reset", 'event_espresso')); |
|
540 | - } |
|
541 | - |
|
542 | - |
|
543 | - |
|
544 | - //none of the below group are currently used for Gateway Settings |
|
545 | - protected function _add_screen_options() |
|
546 | - { |
|
547 | - } |
|
548 | - |
|
549 | - |
|
550 | - |
|
551 | - protected function _add_feature_pointers() |
|
552 | - { |
|
553 | - } |
|
554 | - |
|
31 | + public function __construct($routing = true) |
|
32 | + { |
|
33 | + parent::__construct($routing); |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + |
|
38 | + protected function _init_page_props() |
|
39 | + { |
|
40 | + $this->page_slug = EE_MAINTENANCE_PG_SLUG; |
|
41 | + $this->page_label = EE_MAINTENANCE_LABEL; |
|
42 | + $this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL; |
|
43 | + $this->_admin_base_path = EE_MAINTENANCE_ADMIN; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + protected function _ajax_hooks() |
|
49 | + { |
|
50 | + add_action('wp_ajax_migration_step', array($this, 'migration_step')); |
|
51 | + add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran')); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + protected function _define_page_props() |
|
57 | + { |
|
58 | + $this->_admin_page_title = EE_MAINTENANCE_LABEL; |
|
59 | + $this->_labels = array( |
|
60 | + 'buttons' => array( |
|
61 | + 'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'), |
|
62 | + ), |
|
63 | + ); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + protected function _set_page_routes() |
|
69 | + { |
|
70 | + $this->_page_routes = array( |
|
71 | + 'default' => array( |
|
72 | + 'func' => '_maintenance', |
|
73 | + 'capability' => 'manage_options', |
|
74 | + ), |
|
75 | + 'change_maintenance_level' => array( |
|
76 | + 'func' => '_change_maintenance_level', |
|
77 | + 'capability' => 'manage_options', |
|
78 | + 'noheader' => true, |
|
79 | + ), |
|
80 | + 'system_status' => array( |
|
81 | + 'func' => '_system_status', |
|
82 | + 'capability' => 'manage_options', |
|
83 | + ), |
|
84 | + 'send_migration_crash_report' => array( |
|
85 | + 'func' => '_send_migration_crash_report', |
|
86 | + 'capability' => 'manage_options', |
|
87 | + 'noheader' => true, |
|
88 | + ), |
|
89 | + 'confirm_migration_crash_report_sent' => array( |
|
90 | + 'func' => '_confirm_migration_crash_report_sent', |
|
91 | + 'capability' => 'manage_options', |
|
92 | + ), |
|
93 | + 'data_reset' => array( |
|
94 | + 'func' => '_data_reset_and_delete', |
|
95 | + 'capability' => 'manage_options', |
|
96 | + ), |
|
97 | + 'reset_db' => array( |
|
98 | + 'func' => '_reset_db', |
|
99 | + 'capability' => 'manage_options', |
|
100 | + 'noheader' => true, |
|
101 | + 'args' => array('nuke_old_ee4_data' => true), |
|
102 | + ), |
|
103 | + 'start_with_fresh_ee4_db' => array( |
|
104 | + 'func' => '_reset_db', |
|
105 | + 'capability' => 'manage_options', |
|
106 | + 'noheader' => true, |
|
107 | + 'args' => array('nuke_old_ee4_data' => false), |
|
108 | + ), |
|
109 | + 'delete_db' => array( |
|
110 | + 'func' => '_delete_db', |
|
111 | + 'capability' => 'manage_options', |
|
112 | + 'noheader' => true, |
|
113 | + ), |
|
114 | + 'rerun_migration_from_ee3' => array( |
|
115 | + 'func' => '_rerun_migration_from_ee3', |
|
116 | + 'capability' => 'manage_options', |
|
117 | + 'noheader' => true, |
|
118 | + ), |
|
119 | + 'reset_capabilities' => array( |
|
120 | + 'func' => '_reset_capabilities', |
|
121 | + 'capability' => 'manage_options', |
|
122 | + 'noheader' => true, |
|
123 | + ), |
|
124 | + 'reattempt_migration' => array( |
|
125 | + 'func' => '_reattempt_migration', |
|
126 | + 'capability' => 'manage_options', |
|
127 | + 'noheader' => true, |
|
128 | + ), |
|
129 | + ); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + |
|
134 | + protected function _set_page_config() |
|
135 | + { |
|
136 | + $this->_page_config = array( |
|
137 | + 'default' => array( |
|
138 | + 'nav' => array( |
|
139 | + 'label' => esc_html__('Maintenance', 'event_espresso'), |
|
140 | + 'order' => 10, |
|
141 | + ), |
|
142 | + 'require_nonce' => false, |
|
143 | + ), |
|
144 | + 'data_reset' => array( |
|
145 | + 'nav' => array( |
|
146 | + 'label' => esc_html__('Reset/Delete Data', 'event_espresso'), |
|
147 | + 'order' => 20, |
|
148 | + ), |
|
149 | + 'require_nonce' => false, |
|
150 | + ), |
|
151 | + 'system_status' => array( |
|
152 | + 'nav' => array( |
|
153 | + 'label' => esc_html__("System Information", "event_espresso"), |
|
154 | + 'order' => 30, |
|
155 | + ), |
|
156 | + 'require_nonce' => false, |
|
157 | + ), |
|
158 | + ); |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * default maintenance page. If we're in maintenance mode level 2, then we need to show |
|
165 | + * the migration scripts and all that UI. |
|
166 | + */ |
|
167 | + public function _maintenance() |
|
168 | + { |
|
169 | + //it all depends if we're in maintenance model level 1 (frontend-only) or |
|
170 | + //level 2 (everything except maintenance page) |
|
171 | + try { |
|
172 | + //get the current maintenance level and check if |
|
173 | + //we are removed |
|
174 | + $mm = EE_Maintenance_Mode::instance()->level(); |
|
175 | + $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
176 | + if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) { |
|
177 | + //we just took the site out of maintenance mode, so notify the user. |
|
178 | + //unfortunately this message appears to be echoed on the NEXT page load... |
|
179 | + //oh well, we should really be checking for this on addon deactivation anyways |
|
180 | + EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required', |
|
181 | + 'event_espresso')); |
|
182 | + $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false); |
|
183 | + } |
|
184 | + //in case an exception is thrown while trying to handle migrations |
|
185 | + switch (EE_Maintenance_Mode::instance()->level()) { |
|
186 | + case EE_Maintenance_Mode::level_0_not_in_maintenance: |
|
187 | + case EE_Maintenance_Mode::level_1_frontend_only_maintenance: |
|
188 | + $show_maintenance_switch = true; |
|
189 | + $show_backup_db_text = false; |
|
190 | + $show_migration_progress = false; |
|
191 | + $script_names = array(); |
|
192 | + $addons_should_be_upgraded_first = false; |
|
193 | + break; |
|
194 | + case EE_Maintenance_Mode::level_2_complete_maintenance: |
|
195 | + $show_maintenance_switch = false; |
|
196 | + $show_migration_progress = true; |
|
197 | + if (isset($this->_req_data['continue_migration'])) { |
|
198 | + $show_backup_db_text = false; |
|
199 | + } else { |
|
200 | + $show_backup_db_text = true; |
|
201 | + } |
|
202 | + $scripts_needing_to_run = EE_Data_Migration_Manager::instance() |
|
203 | + ->check_for_applicable_data_migration_scripts(); |
|
204 | + $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating(); |
|
205 | + $script_names = array(); |
|
206 | + $current_script = null; |
|
207 | + foreach ($scripts_needing_to_run as $script) { |
|
208 | + if ($script instanceof EE_Data_Migration_Script_Base) { |
|
209 | + if ( ! $current_script) { |
|
210 | + $current_script = $script; |
|
211 | + $current_script->migration_page_hooks(); |
|
212 | + } |
|
213 | + $script_names[] = $script->pretty_name(); |
|
214 | + } |
|
215 | + } |
|
216 | + break; |
|
217 | + } |
|
218 | + $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
219 | + $exception_thrown = false; |
|
220 | + } catch (EE_Error $e) { |
|
221 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
222 | + //now, just so we can display the page correctly, make a error migration script stage object |
|
223 | + //and also put the error on it. It only persists for the duration of this request |
|
224 | + $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
225 | + $most_recent_migration->add_error($e->getMessage()); |
|
226 | + $exception_thrown = true; |
|
227 | + } |
|
228 | + $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set(); |
|
229 | + $current_db_state = str_replace('.decaf', '', $current_db_state); |
|
230 | + if ($exception_thrown |
|
231 | + || ($most_recent_migration |
|
232 | + && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
233 | + && $most_recent_migration->is_broken() |
|
234 | + ) |
|
235 | + ) { |
|
236 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
237 | + $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
|
238 | + $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', |
|
239 | + 'success' => '0', |
|
240 | + ), EE_MAINTENANCE_ADMIN_URL); |
|
241 | + } elseif ($addons_should_be_upgraded_first) { |
|
242 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
243 | + } else { |
|
244 | + if ($most_recent_migration |
|
245 | + && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
246 | + && $most_recent_migration->can_continue() |
|
247 | + ) { |
|
248 | + $show_backup_db_text = false; |
|
249 | + $show_continue_current_migration_script = true; |
|
250 | + $show_most_recent_migration = true; |
|
251 | + } elseif (isset($this->_req_data['continue_migration'])) { |
|
252 | + $show_most_recent_migration = true; |
|
253 | + $show_continue_current_migration_script = false; |
|
254 | + } else { |
|
255 | + $show_most_recent_migration = false; |
|
256 | + $show_continue_current_migration_script = false; |
|
257 | + } |
|
258 | + if (isset($current_script)) { |
|
259 | + $migrates_to = $current_script->migrates_to_version(); |
|
260 | + $plugin_slug = $migrates_to['slug']; |
|
261 | + $new_version = $migrates_to['version']; |
|
262 | + $this->_template_args = array_merge($this->_template_args, array( |
|
263 | + 'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"), |
|
264 | + isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug), |
|
265 | + 'next_db_state' => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'), |
|
266 | + $new_version, $plugin_slug) : null, |
|
267 | + )); |
|
268 | + } |
|
269 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
270 | + $this->_template_args = array_merge( |
|
271 | + $this->_template_args, |
|
272 | + array( |
|
273 | + 'show_most_recent_migration' => $show_most_recent_migration, |
|
274 | + //flag for showing the most recent migration's status and/or errors |
|
275 | + 'show_migration_progress' => $show_migration_progress, |
|
276 | + //flag for showing the option to run migrations and see their progress |
|
277 | + 'show_backup_db_text' => $show_backup_db_text, |
|
278 | + //flag for showing text telling the user to backup their DB |
|
279 | + 'show_maintenance_switch' => $show_maintenance_switch, |
|
280 | + //flag for showing the option to change maintenance mode between levels 0 and 1 |
|
281 | + 'script_names' => $script_names, |
|
282 | + //array of names of scripts that have run |
|
283 | + 'show_continue_current_migration_script' => $show_continue_current_migration_script, |
|
284 | + //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0 |
|
285 | + 'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
286 | + EE_MAINTENANCE_ADMIN_URL), |
|
287 | + 'data_reset_page' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
288 | + EE_MAINTENANCE_ADMIN_URL), |
|
289 | + 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'), |
|
290 | + EE_MAINTENANCE_ADMIN_URL), |
|
291 | + 'ultimate_db_state' => sprintf(__("EE%s", 'event_espresso'), |
|
292 | + espresso_version()), |
|
293 | + ) |
|
294 | + ); |
|
295 | + //make sure we have the form fields helper available. It usually is, but sometimes it isn't |
|
296 | + //localize script stuff |
|
297 | + wp_localize_script('ee-maintenance', 'ee_maintenance', array( |
|
298 | + 'migrating' => esc_html__("Updating Database...", "event_espresso"), |
|
299 | + 'next' => esc_html__("Next", "event_espresso"), |
|
300 | + 'fatal_error' => esc_html__("A Fatal Error Has Occurred", "event_espresso"), |
|
301 | + 'click_next_when_ready' => esc_html__("The current Database Update has ended. Click 'next' when ready to proceed", |
|
302 | + "event_espresso"), |
|
303 | + 'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts, |
|
304 | + 'status_fatal_error' => EE_Data_Migration_Manager::status_fatal_error, |
|
305 | + 'status_completed' => EE_Data_Migration_Manager::status_completed, |
|
306 | + )); |
|
307 | + } |
|
308 | + $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
309 | + //now render the migration options part, and put it in a variable |
|
310 | + $migration_options_template_file = apply_filters( |
|
311 | + 'FHEE__ee_migration_page__migration_options_template', |
|
312 | + EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php' |
|
313 | + ); |
|
314 | + $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true); |
|
315 | + $this->_template_args['migration_options_html'] = $migration_options_html; |
|
316 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
317 | + $this->_template_args, true); |
|
318 | + $this->display_admin_page_with_sidebar(); |
|
319 | + } |
|
320 | + |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * returns JSON and executes another step of the currently-executing data migration (called via ajax) |
|
325 | + */ |
|
326 | + public function migration_step() |
|
327 | + { |
|
328 | + $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request(); |
|
329 | + $this->_return_json(); |
|
330 | + } |
|
331 | + |
|
332 | + |
|
333 | + |
|
334 | + /** |
|
335 | + * Can be used by js when it notices a response with HTML in it in order |
|
336 | + * to log the malformed response |
|
337 | + */ |
|
338 | + public function add_error_to_migrations_ran() |
|
339 | + { |
|
340 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']); |
|
341 | + $this->_template_args['data'] = array('ok' => true); |
|
342 | + $this->_return_json(); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * changes the maintenance level, provided there are still no migration scripts that shoudl run |
|
349 | + */ |
|
350 | + public function _change_maintenance_level() |
|
351 | + { |
|
352 | + $new_level = intval($this->_req_data['maintenance_mode_level']); |
|
353 | + if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
354 | + EE_Maintenance_Mode::instance()->set_maintenance_level($new_level); |
|
355 | + $success = true; |
|
356 | + } else { |
|
357 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
358 | + $success = false; |
|
359 | + } |
|
360 | + $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso")); |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * a tab with options for resetting and/or deleting EE data |
|
367 | + * |
|
368 | + * @throws \EE_Error |
|
369 | + */ |
|
370 | + public function _data_reset_and_delete() |
|
371 | + { |
|
372 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
373 | + $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button( |
|
374 | + 'reset_capabilities', |
|
375 | + 'reset_capabilities', |
|
376 | + array(), |
|
377 | + 'button button-primary', |
|
378 | + '', |
|
379 | + false |
|
380 | + ); |
|
381 | + $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
382 | + array('action' => 'delete_db'), |
|
383 | + EE_MAINTENANCE_ADMIN_URL |
|
384 | + ); |
|
385 | + $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
386 | + array('action' => 'reset_db'), |
|
387 | + EE_MAINTENANCE_ADMIN_URL |
|
388 | + ); |
|
389 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
390 | + $this->_template_path, |
|
391 | + $this->_template_args, |
|
392 | + true |
|
393 | + ); |
|
394 | + $this->display_admin_page_with_sidebar(); |
|
395 | + } |
|
396 | + |
|
397 | + |
|
398 | + |
|
399 | + protected function _reset_capabilities() |
|
400 | + { |
|
401 | + EE_Registry::instance()->CAP->init_caps(true); |
|
402 | + EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.', |
|
403 | + 'event_espresso')); |
|
404 | + $this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true); |
|
405 | + } |
|
406 | + |
|
407 | + |
|
408 | + |
|
409 | + /** |
|
410 | + * resets the DMSs so we can attempt to continue migrating after a fatal error |
|
411 | + * (only a good idea when someone has somehow tried ot fix whatever caused |
|
412 | + * the fatal error in teh first place) |
|
413 | + */ |
|
414 | + protected function _reattempt_migration() |
|
415 | + { |
|
416 | + EE_Data_Migration_Manager::instance()->reattempt(); |
|
417 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), true); |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * shows the big ol' System Information page |
|
424 | + */ |
|
425 | + public function _system_status() |
|
426 | + { |
|
427 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
428 | + $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
|
429 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
430 | + $this->_template_args, true); |
|
431 | + $this->display_admin_page_with_sidebar(); |
|
432 | + } |
|
433 | + |
|
434 | + |
|
435 | + |
|
436 | + public function _send_migration_crash_report() |
|
437 | + { |
|
438 | + $from = $this->_req_data['from']; |
|
439 | + $from_name = $this->_req_data['from_name']; |
|
440 | + $body = $this->_req_data['body']; |
|
441 | + try { |
|
442 | + $success = wp_mail(EE_SUPPORT_EMAIL, |
|
443 | + 'Migration Crash Report', |
|
444 | + $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
445 | + array( |
|
446 | + "from:$from_name<$from>", |
|
447 | + // 'content-type:text/html charset=UTF-8' |
|
448 | + )); |
|
449 | + } catch (Exception $e) { |
|
450 | + $success = false; |
|
451 | + } |
|
452 | + $this->_redirect_after_action($success, esc_html__("Migration Crash Report", "event_espresso"), |
|
453 | + esc_html__("sent", "event_espresso"), |
|
454 | + array('success' => $success, 'action' => 'confirm_migration_crash_report_sent')); |
|
455 | + } |
|
456 | + |
|
457 | + |
|
458 | + |
|
459 | + public function _confirm_migration_crash_report_sent() |
|
460 | + { |
|
461 | + try { |
|
462 | + $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
463 | + } catch (EE_Error $e) { |
|
464 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
465 | + //now, just so we can display the page correctly, make a error migration script stage object |
|
466 | + //and also put the error on it. It only persists for the duration of this request |
|
467 | + $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
468 | + $most_recent_migration->add_error($e->getMessage()); |
|
469 | + } |
|
470 | + $success = $this->_req_data['success'] == '1' ? true : false; |
|
471 | + $this->_template_args['success'] = $success; |
|
472 | + $this->_template_args['most_recent_migration'] = $most_recent_migration; |
|
473 | + $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
474 | + EE_MAINTENANCE_ADMIN_URL); |
|
475 | + $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
476 | + EE_MAINTENANCE_ADMIN_URL); |
|
477 | + $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), |
|
478 | + EE_MAINTENANCE_ADMIN_URL); |
|
479 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
480 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
481 | + $this->_template_args, true); |
|
482 | + $this->display_admin_page_with_sidebar(); |
|
483 | + } |
|
484 | + |
|
485 | + |
|
486 | + |
|
487 | + /** |
|
488 | + * Resets the entire EE4 database. |
|
489 | + * Currently basically only sets up ee4 database for a fresh install- doesn't |
|
490 | + * actually clean out the old wp options, or cpts (although does erase old ee table data) |
|
491 | + * |
|
492 | + * @param boolean $nuke_old_ee4_data controls whether or not we |
|
493 | + * destroy the old ee4 data, or just try initializing ee4 default data |
|
494 | + */ |
|
495 | + public function _reset_db($nuke_old_ee4_data = true) |
|
496 | + { |
|
497 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
498 | + if ($nuke_old_ee4_data) { |
|
499 | + EEH_Activation::delete_all_espresso_cpt_data(); |
|
500 | + EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
501 | + EEH_Activation::remove_cron_tasks(); |
|
502 | + } |
|
503 | + //make sure when we reset the registry's config that it |
|
504 | + //switches to using the new singleton |
|
505 | + EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true); |
|
506 | + EE_System::instance()->initialize_db_if_no_migrations_required(true); |
|
507 | + EE_System::instance()->redirect_to_about_ee(); |
|
508 | + } |
|
509 | + |
|
510 | + |
|
511 | + |
|
512 | + /** |
|
513 | + * Deletes ALL EE tables, Records, and Options from the database. |
|
514 | + */ |
|
515 | + public function _delete_db() |
|
516 | + { |
|
517 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
518 | + EEH_Activation::delete_all_espresso_cpt_data(); |
|
519 | + EEH_Activation::delete_all_espresso_tables_and_data(); |
|
520 | + EEH_Activation::remove_cron_tasks(); |
|
521 | + EEH_Activation::deactivate_event_espresso(); |
|
522 | + wp_safe_redirect(admin_url('plugins.php')); |
|
523 | + exit; |
|
524 | + } |
|
525 | + |
|
526 | + |
|
527 | + |
|
528 | + /** |
|
529 | + * sets up EE4 to rerun the migrations from ee3 to ee4 |
|
530 | + */ |
|
531 | + public function _rerun_migration_from_ee3() |
|
532 | + { |
|
533 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
534 | + EEH_Activation::delete_all_espresso_cpt_data(); |
|
535 | + EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
536 | + //set the db state to something that will require migrations |
|
537 | + update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0'); |
|
538 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance); |
|
539 | + $this->_redirect_after_action(true, esc_html__("Database", 'event_espresso'), esc_html__("reset", 'event_espresso')); |
|
540 | + } |
|
541 | + |
|
542 | + |
|
543 | + |
|
544 | + //none of the below group are currently used for Gateway Settings |
|
545 | + protected function _add_screen_options() |
|
546 | + { |
|
547 | + } |
|
548 | + |
|
549 | + |
|
550 | + |
|
551 | + protected function _add_feature_pointers() |
|
552 | + { |
|
553 | + } |
|
554 | + |
|
555 | 555 | |
556 | 556 | |
557 | - public function admin_init() |
|
558 | - { |
|
559 | - } |
|
560 | - |
|
561 | - |
|
562 | - |
|
563 | - public function admin_notices() |
|
564 | - { |
|
565 | - } |
|
566 | - |
|
557 | + public function admin_init() |
|
558 | + { |
|
559 | + } |
|
560 | + |
|
561 | + |
|
562 | + |
|
563 | + public function admin_notices() |
|
564 | + { |
|
565 | + } |
|
566 | + |
|
567 | 567 | |
568 | 568 | |
569 | - public function admin_footer_scripts() |
|
570 | - { |
|
571 | - } |
|
569 | + public function admin_footer_scripts() |
|
570 | + { |
|
571 | + } |
|
572 | 572 | |
573 | 573 | |
574 | 574 | |
575 | - public function load_scripts_styles() |
|
576 | - { |
|
577 | - wp_enqueue_script('ee_admin_js'); |
|
575 | + public function load_scripts_styles() |
|
576 | + { |
|
577 | + wp_enqueue_script('ee_admin_js'); |
|
578 | 578 | // wp_enqueue_media(); |
579 | 579 | // wp_enqueue_script('media-upload'); |
580 | - wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'), |
|
581 | - EVENT_ESPRESSO_VERSION, true); |
|
582 | - wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), |
|
583 | - EVENT_ESPRESSO_VERSION); |
|
584 | - wp_enqueue_style('espresso_maintenance'); |
|
585 | - } |
|
580 | + wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'), |
|
581 | + EVENT_ESPRESSO_VERSION, true); |
|
582 | + wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), |
|
583 | + EVENT_ESPRESSO_VERSION); |
|
584 | + wp_enqueue_style('espresso_maintenance'); |
|
585 | + } |
|
586 | 586 | |
587 | 587 | |
588 | 588 | |
589 | - public function load_scripts_styles_default() |
|
590 | - { |
|
591 | - //styles |
|
589 | + public function load_scripts_styles_default() |
|
590 | + { |
|
591 | + //styles |
|
592 | 592 | // wp_enqueue_style('ee-text-links'); |
593 | 593 | // //scripts |
594 | 594 | // wp_enqueue_script('ee-text-links'); |
595 | - } |
|
595 | + } |
|
596 | 596 | |
597 | 597 | |
598 | 598 |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @param array $dir_ref original array of paths |
93 | 93 | * |
94 | - * @return array appended paths |
|
94 | + * @return string[] appended paths |
|
95 | 95 | */ |
96 | 96 | public function messages_autoload_paths($dir_ref) |
97 | 97 | { |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | * @param EE_Question[] $questions An array of questions indexed by answer id. |
702 | 702 | * @param EE_Answer[] $answers An array of answer objects |
703 | 703 | * @param string $template Template content to be parsed. |
704 | - * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
704 | + * @param string[] $valid_shortcodes Valid shortcodes for the template being parsed. |
|
705 | 705 | * @param array $extra_data Extra data that might be used when parsing the template. |
706 | 706 | */ |
707 | 707 | protected function _parse_question_list_for_primary_or_recipient_registration( |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @since 4.3.2 |
8 | 8 | */ |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -22,722 +22,722 @@ discard block |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * constructor. |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - $this->_caf_hooks(); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Contains all the hooks filters for setting up caffeinated messages functionality. |
|
36 | - * |
|
37 | - * @since 4.3.2 |
|
38 | - * |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - private function _caf_hooks() |
|
42 | - { |
|
43 | - add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5); |
|
44 | - add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'), |
|
45 | - 5, 2); |
|
46 | - add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5, |
|
47 | - 2); |
|
48 | - add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5, |
|
49 | - 2); |
|
50 | - add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5, |
|
51 | - 2); |
|
52 | - add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2); |
|
53 | - add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5, |
|
54 | - 2); |
|
55 | - add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', |
|
56 | - array($this, 'new_default_templates'), 5, 7); |
|
57 | - add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5, |
|
58 | - 2); |
|
59 | - |
|
60 | - //shortcode parsers |
|
61 | - add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2); |
|
62 | - add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5); |
|
63 | - add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes', |
|
64 | - array($this, 'additional_recipient_details_shortcodes'), 5, 2); |
|
65 | - add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after', |
|
66 | - array($this, 'additional_recipient_details_parser'), 5, 5); |
|
67 | - add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes', |
|
68 | - array($this, 'additional_primary_registration_details_shortcodes'), 5, 2); |
|
69 | - add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after', |
|
70 | - array($this, 'additional_primary_registration_details_parser'), 5, 5); |
|
71 | - |
|
72 | - /** |
|
73 | - * @since 4.2.0 |
|
74 | - */ |
|
75 | - add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2); |
|
76 | - add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5); |
|
77 | - |
|
78 | - /** |
|
79 | - * @since 4.3.0 |
|
80 | - */ |
|
81 | - //eat our own dog food! |
|
82 | - add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types')); |
|
83 | - add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes')); |
|
84 | - do_action('EE_Brewing_Regular___messages_caf'); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the |
|
90 | - * messages system. |
|
91 | - * |
|
92 | - * @param array $dir_ref original array of paths |
|
93 | - * |
|
94 | - * @return array appended paths |
|
95 | - */ |
|
96 | - public function messages_autoload_paths($dir_ref) |
|
97 | - { |
|
98 | - $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
99 | - |
|
100 | - return $dir_ref; |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger) |
|
105 | - { |
|
106 | - $validator_config['attendee_list'] = array( |
|
107 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
108 | - 'required' => array('[ATTENDEE_LIST]') |
|
109 | - ); |
|
110 | - $validator_config['question_list'] = array( |
|
111 | - 'shortcodes' => array('question'), |
|
112 | - 'required' => array('[QUESTION_LIST]') |
|
113 | - ); |
|
114 | - |
|
115 | - return $validator_config; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger) |
|
120 | - { |
|
121 | - $validator_config['attendee_list'] = array( |
|
122 | - 'shortcodes' => array('attendee', 'question_list'), |
|
123 | - 'required' => array('[ATTENDEE_LIST]') |
|
124 | - ); |
|
125 | - $validator_config['question_list'] = array( |
|
126 | - 'shortcodes' => array('question'), |
|
127 | - 'required' => array('[QUESTION_LIST]') |
|
128 | - ); |
|
129 | - |
|
130 | - return $validator_config; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger) |
|
135 | - { |
|
136 | - $validator_config['attendee_list'] = array( |
|
137 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
138 | - 'required' => array('[ATTENDEE_LIST]') |
|
139 | - ); |
|
140 | - $validator_config['question_list'] = array( |
|
141 | - 'shortcodes' => array('question'), |
|
142 | - 'required' => array('[QUESTION_LIST]') |
|
143 | - ); |
|
144 | - |
|
145 | - return $validator_config; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger) |
|
150 | - { |
|
151 | - $template_fields['extra']['content']['question_list'] = array( |
|
152 | - 'input' => 'textarea', |
|
153 | - 'label' => '[QUESTION_LIST]', |
|
154 | - 'type' => 'string', |
|
155 | - 'required' => true, |
|
156 | - 'validation' => true, |
|
157 | - 'format' => '%s', |
|
158 | - 'css_class' => 'large-text', |
|
159 | - 'rows' => '5', |
|
160 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
161 | - ); |
|
162 | - |
|
163 | - return $template_fields; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger) |
|
168 | - { |
|
169 | - $template_fields['extra']['content']['question_list'] = array( |
|
170 | - 'input' => 'textarea', |
|
171 | - 'label' => '[QUESTION_LIST]', |
|
172 | - 'type' => 'string', |
|
173 | - 'required' => true, |
|
174 | - 'validation' => true, |
|
175 | - 'format' => '%s', |
|
176 | - 'css_class' => 'large-text', |
|
177 | - 'rows' => '5', |
|
178 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
179 | - ); |
|
180 | - |
|
181 | - return $template_fields; |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger) |
|
186 | - { |
|
187 | - $template_fields['extra']['content']['question_list'] = array( |
|
188 | - 'input' => 'textarea', |
|
189 | - 'label' => '[QUESTION_LIST]', |
|
190 | - 'type' => 'string', |
|
191 | - 'required' => true, |
|
192 | - 'validation' => true, |
|
193 | - 'format' => '%s', |
|
194 | - 'css_class' => 'large-text', |
|
195 | - 'rows' => '5', |
|
196 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
197 | - ); |
|
198 | - |
|
199 | - return $template_fields; |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - public function new_default_templates( |
|
204 | - $contents, |
|
205 | - $actual_path, |
|
206 | - EE_messenger $messenger, |
|
207 | - EE_message_type $message_type, |
|
208 | - $field, |
|
209 | - $context, |
|
210 | - EE_Messages_Template_Pack $template_pack |
|
211 | - ) { |
|
212 | - |
|
213 | - //we're only modifying templates for the default template pack |
|
214 | - if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
215 | - return $contents; |
|
216 | - } |
|
217 | - |
|
218 | - //the template file name we're replacing contents for. |
|
219 | - $template_file_prefix = $field . '_' . $context; |
|
220 | - $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
221 | - |
|
222 | - $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
223 | - |
|
224 | - if ($messenger->name == 'email' && $message_type->name == 'registration') { |
|
25 | + /** |
|
26 | + * constructor. |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + $this->_caf_hooks(); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Contains all the hooks filters for setting up caffeinated messages functionality. |
|
36 | + * |
|
37 | + * @since 4.3.2 |
|
38 | + * |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + private function _caf_hooks() |
|
42 | + { |
|
43 | + add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5); |
|
44 | + add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'), |
|
45 | + 5, 2); |
|
46 | + add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5, |
|
47 | + 2); |
|
48 | + add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5, |
|
49 | + 2); |
|
50 | + add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5, |
|
51 | + 2); |
|
52 | + add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2); |
|
53 | + add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5, |
|
54 | + 2); |
|
55 | + add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', |
|
56 | + array($this, 'new_default_templates'), 5, 7); |
|
57 | + add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5, |
|
58 | + 2); |
|
59 | + |
|
60 | + //shortcode parsers |
|
61 | + add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2); |
|
62 | + add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5); |
|
63 | + add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes', |
|
64 | + array($this, 'additional_recipient_details_shortcodes'), 5, 2); |
|
65 | + add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after', |
|
66 | + array($this, 'additional_recipient_details_parser'), 5, 5); |
|
67 | + add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes', |
|
68 | + array($this, 'additional_primary_registration_details_shortcodes'), 5, 2); |
|
69 | + add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after', |
|
70 | + array($this, 'additional_primary_registration_details_parser'), 5, 5); |
|
71 | + |
|
72 | + /** |
|
73 | + * @since 4.2.0 |
|
74 | + */ |
|
75 | + add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2); |
|
76 | + add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5); |
|
77 | + |
|
78 | + /** |
|
79 | + * @since 4.3.0 |
|
80 | + */ |
|
81 | + //eat our own dog food! |
|
82 | + add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types')); |
|
83 | + add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes')); |
|
84 | + do_action('EE_Brewing_Regular___messages_caf'); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the |
|
90 | + * messages system. |
|
91 | + * |
|
92 | + * @param array $dir_ref original array of paths |
|
93 | + * |
|
94 | + * @return array appended paths |
|
95 | + */ |
|
96 | + public function messages_autoload_paths($dir_ref) |
|
97 | + { |
|
98 | + $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
99 | + |
|
100 | + return $dir_ref; |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger) |
|
105 | + { |
|
106 | + $validator_config['attendee_list'] = array( |
|
107 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
108 | + 'required' => array('[ATTENDEE_LIST]') |
|
109 | + ); |
|
110 | + $validator_config['question_list'] = array( |
|
111 | + 'shortcodes' => array('question'), |
|
112 | + 'required' => array('[QUESTION_LIST]') |
|
113 | + ); |
|
114 | + |
|
115 | + return $validator_config; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger) |
|
120 | + { |
|
121 | + $validator_config['attendee_list'] = array( |
|
122 | + 'shortcodes' => array('attendee', 'question_list'), |
|
123 | + 'required' => array('[ATTENDEE_LIST]') |
|
124 | + ); |
|
125 | + $validator_config['question_list'] = array( |
|
126 | + 'shortcodes' => array('question'), |
|
127 | + 'required' => array('[QUESTION_LIST]') |
|
128 | + ); |
|
129 | + |
|
130 | + return $validator_config; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger) |
|
135 | + { |
|
136 | + $validator_config['attendee_list'] = array( |
|
137 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
138 | + 'required' => array('[ATTENDEE_LIST]') |
|
139 | + ); |
|
140 | + $validator_config['question_list'] = array( |
|
141 | + 'shortcodes' => array('question'), |
|
142 | + 'required' => array('[QUESTION_LIST]') |
|
143 | + ); |
|
144 | + |
|
145 | + return $validator_config; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger) |
|
150 | + { |
|
151 | + $template_fields['extra']['content']['question_list'] = array( |
|
152 | + 'input' => 'textarea', |
|
153 | + 'label' => '[QUESTION_LIST]', |
|
154 | + 'type' => 'string', |
|
155 | + 'required' => true, |
|
156 | + 'validation' => true, |
|
157 | + 'format' => '%s', |
|
158 | + 'css_class' => 'large-text', |
|
159 | + 'rows' => '5', |
|
160 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
161 | + ); |
|
162 | + |
|
163 | + return $template_fields; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger) |
|
168 | + { |
|
169 | + $template_fields['extra']['content']['question_list'] = array( |
|
170 | + 'input' => 'textarea', |
|
171 | + 'label' => '[QUESTION_LIST]', |
|
172 | + 'type' => 'string', |
|
173 | + 'required' => true, |
|
174 | + 'validation' => true, |
|
175 | + 'format' => '%s', |
|
176 | + 'css_class' => 'large-text', |
|
177 | + 'rows' => '5', |
|
178 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
179 | + ); |
|
180 | + |
|
181 | + return $template_fields; |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger) |
|
186 | + { |
|
187 | + $template_fields['extra']['content']['question_list'] = array( |
|
188 | + 'input' => 'textarea', |
|
189 | + 'label' => '[QUESTION_LIST]', |
|
190 | + 'type' => 'string', |
|
191 | + 'required' => true, |
|
192 | + 'validation' => true, |
|
193 | + 'format' => '%s', |
|
194 | + 'css_class' => 'large-text', |
|
195 | + 'rows' => '5', |
|
196 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
197 | + ); |
|
198 | + |
|
199 | + return $template_fields; |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + public function new_default_templates( |
|
204 | + $contents, |
|
205 | + $actual_path, |
|
206 | + EE_messenger $messenger, |
|
207 | + EE_message_type $message_type, |
|
208 | + $field, |
|
209 | + $context, |
|
210 | + EE_Messages_Template_Pack $template_pack |
|
211 | + ) { |
|
212 | + |
|
213 | + //we're only modifying templates for the default template pack |
|
214 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
215 | + return $contents; |
|
216 | + } |
|
217 | + |
|
218 | + //the template file name we're replacing contents for. |
|
219 | + $template_file_prefix = $field . '_' . $context; |
|
220 | + $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
221 | + |
|
222 | + $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
223 | + |
|
224 | + if ($messenger->name == 'email' && $message_type->name == 'registration') { |
|
225 | 225 | |
226 | - switch ($template_file_prefix) { |
|
226 | + switch ($template_file_prefix) { |
|
227 | 227 | |
228 | - case 'question_list_admin' : |
|
229 | - case 'question_list_attendee' : |
|
230 | - case 'question_list_primary_attendee' : |
|
231 | - $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
232 | - $contents = EEH_Template::display_template($path, array(), true); |
|
233 | - break; |
|
228 | + case 'question_list_admin' : |
|
229 | + case 'question_list_attendee' : |
|
230 | + case 'question_list_primary_attendee' : |
|
231 | + $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
232 | + $contents = EEH_Template::display_template($path, array(), true); |
|
233 | + break; |
|
234 | 234 | |
235 | - case 'attendee_list_primary_attendee' : |
|
236 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
237 | - $contents = EEH_Template::display_template($path, array(), true); |
|
238 | - break; |
|
235 | + case 'attendee_list_primary_attendee' : |
|
236 | + $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
237 | + $contents = EEH_Template::display_template($path, array(), true); |
|
238 | + break; |
|
239 | 239 | |
240 | - case 'attendee_list_admin' : |
|
241 | - $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
242 | - $contents = EEH_Template::display_template($path, |
|
243 | - array(), true); |
|
244 | - break; |
|
240 | + case 'attendee_list_admin' : |
|
241 | + $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
242 | + $contents = EEH_Template::display_template($path, |
|
243 | + array(), true); |
|
244 | + break; |
|
245 | 245 | |
246 | - case 'attendee_list_attendee' : |
|
247 | - $contents = ''; |
|
248 | - break; |
|
246 | + case 'attendee_list_attendee' : |
|
247 | + $contents = ''; |
|
248 | + break; |
|
249 | 249 | |
250 | - case 'event_list_attendee' : |
|
251 | - $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
252 | - $contents = EEH_Template::display_template($path, array(), true); |
|
253 | - break; |
|
254 | - } |
|
255 | - } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') { |
|
256 | - switch ($template_file_prefix) { |
|
250 | + case 'event_list_attendee' : |
|
251 | + $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
252 | + $contents = EEH_Template::display_template($path, array(), true); |
|
253 | + break; |
|
254 | + } |
|
255 | + } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') { |
|
256 | + switch ($template_file_prefix) { |
|
257 | 257 | |
258 | - case 'content_attendee' : |
|
259 | - $path = $base_path . $msg_prefix . 'content.template.php'; |
|
260 | - $contents = EEH_Template::display_template($path, array(), true); |
|
261 | - break; |
|
258 | + case 'content_attendee' : |
|
259 | + $path = $base_path . $msg_prefix . 'content.template.php'; |
|
260 | + $contents = EEH_Template::display_template($path, array(), true); |
|
261 | + break; |
|
262 | 262 | |
263 | - case 'newsletter_content_attendee' : |
|
264 | - $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
265 | - $contents = EEH_Template::display_template($path, array(), true); |
|
266 | - break; |
|
263 | + case 'newsletter_content_attendee' : |
|
264 | + $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
265 | + $contents = EEH_Template::display_template($path, array(), true); |
|
266 | + break; |
|
267 | 267 | |
268 | - case 'newsletter_subject_attendee' : |
|
269 | - $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
270 | - $contents = EEH_Template::display_template($path, array(), true); |
|
271 | - break; |
|
272 | - } |
|
273 | - } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
|
274 | - switch ($template_file_prefix) { |
|
275 | - case 'attendee_list_purchaser' : |
|
276 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
277 | - $contents = EEH_Template::display_template($path, array(), true); |
|
278 | - break; |
|
279 | - } |
|
280 | - } |
|
281 | - |
|
282 | - return $contents; |
|
283 | - |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg) |
|
288 | - { |
|
289 | - //make sure question_list and question are ONLY added for the core message types. Any other message types will have to explicitly set question_list as a valid shortcode. |
|
290 | - $include_with = array( |
|
291 | - 'registration', |
|
292 | - 'cancelled_registration', |
|
293 | - 'declined_registration', |
|
294 | - 'not_approved_registration', |
|
295 | - 'payment_declined', |
|
296 | - 'payment_failed', |
|
297 | - 'payment_cancelled', |
|
298 | - 'payment', |
|
299 | - 'payment_reminder', |
|
300 | - 'pending_approval', |
|
301 | - 'registration_summary', |
|
302 | - 'invoice', |
|
303 | - 'receipt' |
|
304 | - ); |
|
305 | - if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) { |
|
306 | - $contexts = array_keys($msg->get_contexts()); |
|
307 | - foreach ($contexts as $context) { |
|
308 | - $valid_shortcodes[$context][] = 'question_list'; |
|
309 | - $valid_shortcodes[$context][] = 'question'; |
|
310 | - } |
|
311 | - } |
|
312 | - |
|
313 | - return $valid_shortcodes; |
|
314 | - } |
|
315 | - |
|
316 | - |
|
317 | - public function additional_attendee_shortcodes($shortcodes, $shortcode_parser) |
|
318 | - { |
|
319 | - $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.', |
|
320 | - 'event_espresso'); |
|
321 | - |
|
322 | - return $shortcodes; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
327 | - { |
|
328 | - |
|
329 | - if (strpos($shortcode, |
|
330 | - '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations) |
|
331 | - ) { |
|
332 | - return $parsed; |
|
333 | - } |
|
334 | - |
|
335 | - //let's get the question from the code. |
|
336 | - $shortcode = str_replace('[ANSWER_*', '', $shortcode); |
|
337 | - $shortcode = trim(str_replace(']', '', $shortcode)); |
|
338 | - |
|
339 | - $registration = $data instanceof EE_Registration ? $data : null; |
|
340 | - $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration; |
|
341 | - |
|
342 | - $aee = $data instanceof EE_Messages_Addressee ? $data : null; |
|
343 | - $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee; |
|
344 | - |
|
345 | - if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) { |
|
346 | - return $parsed; |
|
347 | - } |
|
348 | - |
|
349 | - //now let's figure out which question has this text. |
|
350 | - foreach ($aee->questions as $ansid => $question) { |
|
351 | - if ( |
|
352 | - $question instanceof EE_Question |
|
353 | - && trim($question->display_text()) == trim($shortcode) |
|
354 | - && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid]) |
|
355 | - ) { |
|
356 | - return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', |
|
357 | - 'no_wpautop'); |
|
358 | - } |
|
359 | - } |
|
360 | - |
|
361 | - //nothing! |
|
362 | - return $parsed; |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - /** |
|
367 | - * Callback for additional shortcodes filter for adding additional datetime shortcodes. |
|
368 | - * |
|
369 | - * @since 4.2 |
|
370 | - * |
|
371 | - * @param array $shortcodes array of shortcodes and |
|
372 | - * descriptions |
|
373 | - * @param EE_Datetime_Shortcodes $shortcode_parser EE_Shortcodes object |
|
374 | - * |
|
375 | - * @return array array of shortcodes and |
|
376 | - * descriptions |
|
377 | - */ |
|
378 | - public function additional_datetime_shortcodes($shortcodes, $shortcode_parser) |
|
379 | - { |
|
380 | - $shortcodes['[DTT_NAME]'] = __('This will be parsed to the Title given for a Datetime', |
|
381 | - 'event_espresso'); |
|
382 | - $shortcodes['[DTT_DESCRIPTION]'] = __('This will be parsed to the description for a Datetime', |
|
383 | - 'event_espresso'); |
|
384 | - $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.', |
|
385 | - 'event_espresso'); |
|
386 | - |
|
387 | - return $shortcodes; |
|
388 | - } |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * Callback for additional shortcodes parser filter used for adding parser for new |
|
393 | - * Datetime shortcodes |
|
394 | - * |
|
395 | - * @since 4.2 |
|
396 | - * |
|
397 | - * @param string $parsed The finished parsed string for the given shortcode. |
|
398 | - * @param string $shortcode The shortcode being parsed. |
|
399 | - * @param object $data The incoming data object for the Shortcode Parser. |
|
400 | - * @param object $extra_data The incoming extra date object for the Shortcode |
|
401 | - * Parser. |
|
402 | - * @param EE_Datetime_Shortcodes $shortcode_parser |
|
403 | - * |
|
404 | - * @return string The new parsed string. |
|
405 | - */ |
|
406 | - public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
407 | - { |
|
408 | - |
|
409 | - if ( ! $data instanceof EE_Datetime) { |
|
410 | - return ''; //get out because we can only parse with the datetime object. |
|
411 | - } |
|
412 | - |
|
413 | - switch ($shortcode) { |
|
414 | - case '[DTT_NAME]' : |
|
415 | - return $data->name(); |
|
416 | - break; |
|
417 | - case '[DTT_DESCRIPTION]' : |
|
418 | - return $data->description(); |
|
419 | - break; |
|
420 | - case '[DTT_NAME_OR_DATES]' : |
|
421 | - return $data->get_dtt_display_name(true); |
|
422 | - break; |
|
423 | - default : |
|
424 | - return $parsed; |
|
425 | - break; |
|
426 | - } |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser) |
|
431 | - { |
|
432 | - $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.', |
|
433 | - 'event_espresso'); |
|
434 | - |
|
435 | - return $shortcodes; |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - /** |
|
440 | - * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter). |
|
441 | - * |
|
442 | - * @param string $parsed The original parsed content for the shortcode |
|
443 | - * @param string $shortcode The shortcode being parsed |
|
444 | - * @param array $data The shortcode parser data array |
|
445 | - * @param array $extra_data The shortcode parser extra data array |
|
446 | - * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
447 | - * |
|
448 | - * @return string |
|
449 | - */ |
|
450 | - public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
451 | - { |
|
452 | - |
|
453 | - if (array($data) && ! isset($data['data'])) { |
|
454 | - return $parsed; |
|
455 | - } |
|
456 | - |
|
457 | - $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
458 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
459 | - |
|
460 | - if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
461 | - return $parsed; |
|
462 | - } |
|
463 | - |
|
464 | - switch ($shortcode) { |
|
465 | - case '[RECIPIENT_QUESTION_LIST]' : |
|
466 | - $att = $recipient->att_obj; |
|
467 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array(); |
|
468 | - $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee; |
|
469 | - $answers = array(); |
|
268 | + case 'newsletter_subject_attendee' : |
|
269 | + $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
270 | + $contents = EEH_Template::display_template($path, array(), true); |
|
271 | + break; |
|
272 | + } |
|
273 | + } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
|
274 | + switch ($template_file_prefix) { |
|
275 | + case 'attendee_list_purchaser' : |
|
276 | + $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
277 | + $contents = EEH_Template::display_template($path, array(), true); |
|
278 | + break; |
|
279 | + } |
|
280 | + } |
|
281 | + |
|
282 | + return $contents; |
|
283 | + |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg) |
|
288 | + { |
|
289 | + //make sure question_list and question are ONLY added for the core message types. Any other message types will have to explicitly set question_list as a valid shortcode. |
|
290 | + $include_with = array( |
|
291 | + 'registration', |
|
292 | + 'cancelled_registration', |
|
293 | + 'declined_registration', |
|
294 | + 'not_approved_registration', |
|
295 | + 'payment_declined', |
|
296 | + 'payment_failed', |
|
297 | + 'payment_cancelled', |
|
298 | + 'payment', |
|
299 | + 'payment_reminder', |
|
300 | + 'pending_approval', |
|
301 | + 'registration_summary', |
|
302 | + 'invoice', |
|
303 | + 'receipt' |
|
304 | + ); |
|
305 | + if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) { |
|
306 | + $contexts = array_keys($msg->get_contexts()); |
|
307 | + foreach ($contexts as $context) { |
|
308 | + $valid_shortcodes[$context][] = 'question_list'; |
|
309 | + $valid_shortcodes[$context][] = 'question'; |
|
310 | + } |
|
311 | + } |
|
312 | + |
|
313 | + return $valid_shortcodes; |
|
314 | + } |
|
315 | + |
|
316 | + |
|
317 | + public function additional_attendee_shortcodes($shortcodes, $shortcode_parser) |
|
318 | + { |
|
319 | + $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.', |
|
320 | + 'event_espresso'); |
|
321 | + |
|
322 | + return $shortcodes; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
327 | + { |
|
328 | + |
|
329 | + if (strpos($shortcode, |
|
330 | + '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations) |
|
331 | + ) { |
|
332 | + return $parsed; |
|
333 | + } |
|
334 | + |
|
335 | + //let's get the question from the code. |
|
336 | + $shortcode = str_replace('[ANSWER_*', '', $shortcode); |
|
337 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
338 | + |
|
339 | + $registration = $data instanceof EE_Registration ? $data : null; |
|
340 | + $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration; |
|
341 | + |
|
342 | + $aee = $data instanceof EE_Messages_Addressee ? $data : null; |
|
343 | + $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee; |
|
344 | + |
|
345 | + if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) { |
|
346 | + return $parsed; |
|
347 | + } |
|
348 | + |
|
349 | + //now let's figure out which question has this text. |
|
350 | + foreach ($aee->questions as $ansid => $question) { |
|
351 | + if ( |
|
352 | + $question instanceof EE_Question |
|
353 | + && trim($question->display_text()) == trim($shortcode) |
|
354 | + && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid]) |
|
355 | + ) { |
|
356 | + return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', |
|
357 | + 'no_wpautop'); |
|
358 | + } |
|
359 | + } |
|
360 | + |
|
361 | + //nothing! |
|
362 | + return $parsed; |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + /** |
|
367 | + * Callback for additional shortcodes filter for adding additional datetime shortcodes. |
|
368 | + * |
|
369 | + * @since 4.2 |
|
370 | + * |
|
371 | + * @param array $shortcodes array of shortcodes and |
|
372 | + * descriptions |
|
373 | + * @param EE_Datetime_Shortcodes $shortcode_parser EE_Shortcodes object |
|
374 | + * |
|
375 | + * @return array array of shortcodes and |
|
376 | + * descriptions |
|
377 | + */ |
|
378 | + public function additional_datetime_shortcodes($shortcodes, $shortcode_parser) |
|
379 | + { |
|
380 | + $shortcodes['[DTT_NAME]'] = __('This will be parsed to the Title given for a Datetime', |
|
381 | + 'event_espresso'); |
|
382 | + $shortcodes['[DTT_DESCRIPTION]'] = __('This will be parsed to the description for a Datetime', |
|
383 | + 'event_espresso'); |
|
384 | + $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.', |
|
385 | + 'event_espresso'); |
|
386 | + |
|
387 | + return $shortcodes; |
|
388 | + } |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * Callback for additional shortcodes parser filter used for adding parser for new |
|
393 | + * Datetime shortcodes |
|
394 | + * |
|
395 | + * @since 4.2 |
|
396 | + * |
|
397 | + * @param string $parsed The finished parsed string for the given shortcode. |
|
398 | + * @param string $shortcode The shortcode being parsed. |
|
399 | + * @param object $data The incoming data object for the Shortcode Parser. |
|
400 | + * @param object $extra_data The incoming extra date object for the Shortcode |
|
401 | + * Parser. |
|
402 | + * @param EE_Datetime_Shortcodes $shortcode_parser |
|
403 | + * |
|
404 | + * @return string The new parsed string. |
|
405 | + */ |
|
406 | + public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
407 | + { |
|
408 | + |
|
409 | + if ( ! $data instanceof EE_Datetime) { |
|
410 | + return ''; //get out because we can only parse with the datetime object. |
|
411 | + } |
|
412 | + |
|
413 | + switch ($shortcode) { |
|
414 | + case '[DTT_NAME]' : |
|
415 | + return $data->name(); |
|
416 | + break; |
|
417 | + case '[DTT_DESCRIPTION]' : |
|
418 | + return $data->description(); |
|
419 | + break; |
|
420 | + case '[DTT_NAME_OR_DATES]' : |
|
421 | + return $data->get_dtt_display_name(true); |
|
422 | + break; |
|
423 | + default : |
|
424 | + return $parsed; |
|
425 | + break; |
|
426 | + } |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser) |
|
431 | + { |
|
432 | + $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.', |
|
433 | + 'event_espresso'); |
|
434 | + |
|
435 | + return $shortcodes; |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + /** |
|
440 | + * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter). |
|
441 | + * |
|
442 | + * @param string $parsed The original parsed content for the shortcode |
|
443 | + * @param string $shortcode The shortcode being parsed |
|
444 | + * @param array $data The shortcode parser data array |
|
445 | + * @param array $extra_data The shortcode parser extra data array |
|
446 | + * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
447 | + * |
|
448 | + * @return string |
|
449 | + */ |
|
450 | + public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
451 | + { |
|
452 | + |
|
453 | + if (array($data) && ! isset($data['data'])) { |
|
454 | + return $parsed; |
|
455 | + } |
|
456 | + |
|
457 | + $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
458 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
459 | + |
|
460 | + if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
461 | + return $parsed; |
|
462 | + } |
|
463 | + |
|
464 | + switch ($shortcode) { |
|
465 | + case '[RECIPIENT_QUESTION_LIST]' : |
|
466 | + $att = $recipient->att_obj; |
|
467 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array(); |
|
468 | + $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee; |
|
469 | + $answers = array(); |
|
470 | 470 | |
471 | - $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
472 | - $valid_shortcodes = array('question'); |
|
471 | + $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
472 | + $valid_shortcodes = array('question'); |
|
473 | 473 | |
474 | - //if the context is main_content then get all answers for all registrations on this attendee |
|
475 | - if ($data['data'] instanceof EE_Messages_Addressee) { |
|
474 | + //if the context is main_content then get all answers for all registrations on this attendee |
|
475 | + if ($data['data'] instanceof EE_Messages_Addressee) { |
|
476 | 476 | |
477 | - foreach ($registrations_on_attendee as $reg) { |
|
478 | - if ($reg instanceof EE_Registration) { |
|
479 | - $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
480 | - foreach ($anss as $ans) { |
|
481 | - if ($ans instanceof EE_Answer) { |
|
482 | - $answers[$ans->ID()] = $ans; |
|
483 | - } |
|
484 | - } |
|
485 | - } |
|
486 | - } |
|
487 | - } |
|
477 | + foreach ($registrations_on_attendee as $reg) { |
|
478 | + if ($reg instanceof EE_Registration) { |
|
479 | + $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
480 | + foreach ($anss as $ans) { |
|
481 | + if ($ans instanceof EE_Answer) { |
|
482 | + $answers[$ans->ID()] = $ans; |
|
483 | + } |
|
484 | + } |
|
485 | + } |
|
486 | + } |
|
487 | + } |
|
488 | 488 | |
489 | - //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event. |
|
490 | - if ($data['data'] instanceof EE_Event) { |
|
491 | - $event = $data['data']; |
|
492 | - foreach ($registrations_on_attendee as $reg) { |
|
493 | - if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
494 | - $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
495 | - foreach ($anss as $ans) { |
|
496 | - if ($ans instanceof EE_Answer) { |
|
497 | - $answers[$ans->ID()] = $ans; |
|
498 | - } |
|
499 | - } |
|
500 | - } |
|
501 | - } |
|
502 | - } |
|
489 | + //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event. |
|
490 | + if ($data['data'] instanceof EE_Event) { |
|
491 | + $event = $data['data']; |
|
492 | + foreach ($registrations_on_attendee as $reg) { |
|
493 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
494 | + $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
495 | + foreach ($anss as $ans) { |
|
496 | + if ($ans instanceof EE_Answer) { |
|
497 | + $answers[$ans->ID()] = $ans; |
|
498 | + } |
|
499 | + } |
|
500 | + } |
|
501 | + } |
|
502 | + } |
|
503 | 503 | |
504 | - $questions = $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
504 | + $questions = $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
505 | 505 | |
506 | - //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
507 | - //object on it. |
|
508 | - if ( ! isset( $extra_data['data'] ) ) { |
|
509 | - $extra_data['data'] = $recipient; |
|
510 | - } |
|
506 | + //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
507 | + //object on it. |
|
508 | + if ( ! isset( $extra_data['data'] ) ) { |
|
509 | + $extra_data['data'] = $recipient; |
|
510 | + } |
|
511 | 511 | |
512 | - return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
513 | - $shortcode_parser, |
|
514 | - $questions, |
|
515 | - $answers, |
|
516 | - $template, |
|
517 | - $valid_shortcodes, |
|
518 | - $extra_data |
|
519 | - ); |
|
520 | - break; |
|
512 | + return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
513 | + $shortcode_parser, |
|
514 | + $questions, |
|
515 | + $answers, |
|
516 | + $template, |
|
517 | + $valid_shortcodes, |
|
518 | + $extra_data |
|
519 | + ); |
|
520 | + break; |
|
521 | 521 | |
522 | - default : |
|
523 | - return $parsed; |
|
524 | - break; |
|
525 | - } |
|
526 | - } |
|
527 | - |
|
528 | - |
|
529 | - public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser) |
|
530 | - { |
|
531 | - $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field', |
|
532 | - 'event_espresso'); |
|
533 | - |
|
534 | - return $shortcodes; |
|
535 | - } |
|
536 | - |
|
537 | - |
|
538 | - /** |
|
539 | - * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter). |
|
540 | - * |
|
541 | - * @param string $parsed The original parsed content for the shortcode |
|
542 | - * @param string $shortcode The shortcode being parsed |
|
543 | - * @param array $data The shortcode parser data array |
|
544 | - * @param array $extra_data The shortcode parser extra data array |
|
545 | - * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
546 | - * |
|
547 | - * @return string |
|
548 | - */ |
|
549 | - public function additional_primary_registration_details_parser( |
|
550 | - $parsed, |
|
551 | - $shortcode, |
|
552 | - $data, |
|
553 | - $extra_data, |
|
554 | - $shortcode_parser |
|
555 | - ) { |
|
556 | - if (array($data) && ! isset($data['data'])) { |
|
557 | - return $parsed; |
|
558 | - } |
|
559 | - |
|
560 | - $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
561 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
562 | - |
|
563 | - if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
564 | - return $parsed; |
|
565 | - } |
|
566 | - |
|
567 | - switch ($shortcode) { |
|
568 | - case '[PRIMARY_REGISTRANT_QUESTION_LIST]' : |
|
569 | - if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) { |
|
570 | - return ''; |
|
571 | - } |
|
572 | - $registration = $recipient->primary_reg_obj; |
|
573 | - $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
574 | - $valid_shortcodes = array('question'); |
|
575 | - $answers = $recipient->registrations[$registration->ID()]['ans_objs']; |
|
576 | - $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
577 | - //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
578 | - //object on it. |
|
579 | - if ( ! isset( $extra_data['data'] ) ){ |
|
580 | - $extra_data['data'] = $recipient; |
|
581 | - } |
|
582 | - return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
583 | - $shortcode_parser, |
|
584 | - $questions, |
|
585 | - $answers, |
|
586 | - $template, |
|
587 | - $valid_shortcodes, |
|
588 | - $extra_data |
|
589 | - ); |
|
590 | - break; |
|
522 | + default : |
|
523 | + return $parsed; |
|
524 | + break; |
|
525 | + } |
|
526 | + } |
|
527 | + |
|
528 | + |
|
529 | + public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser) |
|
530 | + { |
|
531 | + $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field', |
|
532 | + 'event_espresso'); |
|
533 | + |
|
534 | + return $shortcodes; |
|
535 | + } |
|
536 | + |
|
537 | + |
|
538 | + /** |
|
539 | + * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter). |
|
540 | + * |
|
541 | + * @param string $parsed The original parsed content for the shortcode |
|
542 | + * @param string $shortcode The shortcode being parsed |
|
543 | + * @param array $data The shortcode parser data array |
|
544 | + * @param array $extra_data The shortcode parser extra data array |
|
545 | + * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
546 | + * |
|
547 | + * @return string |
|
548 | + */ |
|
549 | + public function additional_primary_registration_details_parser( |
|
550 | + $parsed, |
|
551 | + $shortcode, |
|
552 | + $data, |
|
553 | + $extra_data, |
|
554 | + $shortcode_parser |
|
555 | + ) { |
|
556 | + if (array($data) && ! isset($data['data'])) { |
|
557 | + return $parsed; |
|
558 | + } |
|
559 | + |
|
560 | + $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
561 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
562 | + |
|
563 | + if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
564 | + return $parsed; |
|
565 | + } |
|
566 | + |
|
567 | + switch ($shortcode) { |
|
568 | + case '[PRIMARY_REGISTRANT_QUESTION_LIST]' : |
|
569 | + if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) { |
|
570 | + return ''; |
|
571 | + } |
|
572 | + $registration = $recipient->primary_reg_obj; |
|
573 | + $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
574 | + $valid_shortcodes = array('question'); |
|
575 | + $answers = $recipient->registrations[$registration->ID()]['ans_objs']; |
|
576 | + $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
577 | + //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
578 | + //object on it. |
|
579 | + if ( ! isset( $extra_data['data'] ) ){ |
|
580 | + $extra_data['data'] = $recipient; |
|
581 | + } |
|
582 | + return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
583 | + $shortcode_parser, |
|
584 | + $questions, |
|
585 | + $answers, |
|
586 | + $template, |
|
587 | + $valid_shortcodes, |
|
588 | + $extra_data |
|
589 | + ); |
|
590 | + break; |
|
591 | 591 | |
592 | - default : |
|
593 | - return $parsed; |
|
594 | - break; |
|
595 | - } |
|
596 | - } |
|
597 | - |
|
598 | - |
|
599 | - /** |
|
600 | - * Takes care of registering the message types that are only available in caffeinated EE. |
|
601 | - * |
|
602 | - * @since 4.3.2 |
|
603 | - * |
|
604 | - * @return void |
|
605 | - */ |
|
606 | - public function register_caf_message_types() |
|
607 | - { |
|
608 | - //register newsletter message type |
|
609 | - $setup_args = array( |
|
610 | - 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
|
611 | - 'autoloadpaths' => array( |
|
612 | - EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
613 | - ), |
|
614 | - 'messengers_to_activate_with' => array('email'), |
|
615 | - 'messengers_to_validate_with' => array('email') |
|
616 | - ); |
|
617 | - EE_Register_Message_Type::register('newsletter', $setup_args); |
|
618 | - |
|
619 | - //register payment reminder message type |
|
620 | - $setup_args = array( |
|
621 | - 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
|
622 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
623 | - 'messengers_to_activate_with' => array('email'), |
|
624 | - 'messengers_to_validate_with' => array('email') |
|
625 | - ); |
|
626 | - EE_Register_Message_Type::register('payment_reminder', $setup_args); |
|
627 | - |
|
628 | - //register payment declined message type |
|
629 | - $setup_args = array( |
|
630 | - 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
|
631 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
632 | - 'messengers_to_activate_with' => array('email'), |
|
633 | - 'messengers_to_validate_with' => array('email') |
|
634 | - ); |
|
635 | - EE_Register_Message_Type::register('payment_declined', $setup_args); |
|
636 | - |
|
637 | - //register registration declined message type |
|
638 | - $setup_args = array( |
|
639 | - 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
|
640 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
641 | - 'messengers_to_activate_with' => array('email'), |
|
642 | - 'messengers_to_validate_with' => array('email') |
|
643 | - ); |
|
644 | - EE_Register_Message_Type::register('declined_registration', $setup_args); |
|
645 | - |
|
646 | - //register registration cancelled message type |
|
647 | - $setup_args = array( |
|
648 | - 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
|
649 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
650 | - 'messengers_to_activate_with' => array('email'), |
|
651 | - 'messengers_to_validate_with' => array('email') |
|
652 | - ); |
|
653 | - EE_Register_Message_Type::register('cancelled_registration', $setup_args); |
|
654 | - |
|
655 | - |
|
656 | - //register payment failed message type |
|
657 | - $setup_args = array( |
|
658 | - 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
|
659 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
660 | - 'messengers_to_activate_with' => array('email'), |
|
661 | - 'messengers_to_validate_with' => array('email') |
|
662 | - ); |
|
663 | - EE_Register_Message_Type::register('payment_failed', $setup_args); |
|
664 | - |
|
665 | - //register payment declined message type |
|
666 | - $setup_args = array( |
|
667 | - 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
|
668 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
669 | - 'messengers_to_activate_with' => array('email'), |
|
670 | - 'messengers_to_validate_with' => array('email') |
|
671 | - ); |
|
672 | - EE_Register_Message_Type::register('payment_cancelled', $setup_args); |
|
673 | - } |
|
674 | - |
|
675 | - |
|
676 | - /** |
|
677 | - * Takes care of registering the shortcode libraries implemented with caffeinated EE and set up related items. |
|
678 | - * |
|
679 | - * @since 4.3.2 |
|
680 | - * |
|
681 | - * @return void |
|
682 | - */ |
|
683 | - public function register_caf_shortcodes() |
|
684 | - { |
|
685 | - $setup_args = array( |
|
686 | - 'autoloadpaths' => array( |
|
687 | - EE_CAF_LIBRARIES . 'shortcodes/' |
|
688 | - ), |
|
689 | - 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
|
690 | - 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
|
691 | - 'list_type_shortcodes' => array('[NEWSLETTER_CONTENT]') |
|
692 | - ); |
|
693 | - EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args); |
|
694 | - } |
|
695 | - |
|
696 | - |
|
697 | - /** |
|
698 | - * Parses a question list shortcode using given data and template |
|
699 | - * |
|
700 | - * @param \EE_Shortcodes $shortcode_parser |
|
701 | - * @param EE_Question[] $questions An array of questions indexed by answer id. |
|
702 | - * @param EE_Answer[] $answers An array of answer objects |
|
703 | - * @param string $template Template content to be parsed. |
|
704 | - * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
705 | - * @param array $extra_data Extra data that might be used when parsing the template. |
|
706 | - */ |
|
707 | - protected function _parse_question_list_for_primary_or_recipient_registration( |
|
708 | - $shortcode_parser, |
|
709 | - $questions, |
|
710 | - $answers, |
|
711 | - $template, |
|
712 | - $valid_shortcodes, |
|
713 | - $extra_data |
|
714 | - ) { |
|
715 | - $question_list = ''; |
|
716 | - /** @var EEH_Parse_Shortcodes $shortcode_helper */ |
|
717 | - $shortcode_helper = $shortcode_parser->get_shortcode_helper(); |
|
718 | - foreach ($answers as $answer) { |
|
719 | - if ($answer instanceof EE_Answer) { |
|
720 | - //first see if the question is in our $questions array. If not then try to get from answer object. |
|
721 | - $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null; |
|
722 | - $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
723 | - if ( |
|
724 | - ! $question instanceof EE_Question |
|
725 | - || ( |
|
726 | - $question instanceof EE_Question |
|
727 | - && $question->admin_only() |
|
728 | - ) |
|
729 | - ) { |
|
730 | - continue; |
|
731 | - } |
|
732 | - $question_list .= $shortcode_helper->parse_question_list_template( |
|
733 | - $template, |
|
734 | - $answer, |
|
735 | - $valid_shortcodes, |
|
736 | - $extra_data |
|
737 | - ); |
|
738 | - } |
|
739 | - } |
|
740 | - |
|
741 | - return $question_list; |
|
742 | - } |
|
592 | + default : |
|
593 | + return $parsed; |
|
594 | + break; |
|
595 | + } |
|
596 | + } |
|
597 | + |
|
598 | + |
|
599 | + /** |
|
600 | + * Takes care of registering the message types that are only available in caffeinated EE. |
|
601 | + * |
|
602 | + * @since 4.3.2 |
|
603 | + * |
|
604 | + * @return void |
|
605 | + */ |
|
606 | + public function register_caf_message_types() |
|
607 | + { |
|
608 | + //register newsletter message type |
|
609 | + $setup_args = array( |
|
610 | + 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
|
611 | + 'autoloadpaths' => array( |
|
612 | + EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
613 | + ), |
|
614 | + 'messengers_to_activate_with' => array('email'), |
|
615 | + 'messengers_to_validate_with' => array('email') |
|
616 | + ); |
|
617 | + EE_Register_Message_Type::register('newsletter', $setup_args); |
|
618 | + |
|
619 | + //register payment reminder message type |
|
620 | + $setup_args = array( |
|
621 | + 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
|
622 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
623 | + 'messengers_to_activate_with' => array('email'), |
|
624 | + 'messengers_to_validate_with' => array('email') |
|
625 | + ); |
|
626 | + EE_Register_Message_Type::register('payment_reminder', $setup_args); |
|
627 | + |
|
628 | + //register payment declined message type |
|
629 | + $setup_args = array( |
|
630 | + 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
|
631 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
632 | + 'messengers_to_activate_with' => array('email'), |
|
633 | + 'messengers_to_validate_with' => array('email') |
|
634 | + ); |
|
635 | + EE_Register_Message_Type::register('payment_declined', $setup_args); |
|
636 | + |
|
637 | + //register registration declined message type |
|
638 | + $setup_args = array( |
|
639 | + 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
|
640 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
641 | + 'messengers_to_activate_with' => array('email'), |
|
642 | + 'messengers_to_validate_with' => array('email') |
|
643 | + ); |
|
644 | + EE_Register_Message_Type::register('declined_registration', $setup_args); |
|
645 | + |
|
646 | + //register registration cancelled message type |
|
647 | + $setup_args = array( |
|
648 | + 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
|
649 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
650 | + 'messengers_to_activate_with' => array('email'), |
|
651 | + 'messengers_to_validate_with' => array('email') |
|
652 | + ); |
|
653 | + EE_Register_Message_Type::register('cancelled_registration', $setup_args); |
|
654 | + |
|
655 | + |
|
656 | + //register payment failed message type |
|
657 | + $setup_args = array( |
|
658 | + 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
|
659 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
660 | + 'messengers_to_activate_with' => array('email'), |
|
661 | + 'messengers_to_validate_with' => array('email') |
|
662 | + ); |
|
663 | + EE_Register_Message_Type::register('payment_failed', $setup_args); |
|
664 | + |
|
665 | + //register payment declined message type |
|
666 | + $setup_args = array( |
|
667 | + 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
|
668 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
669 | + 'messengers_to_activate_with' => array('email'), |
|
670 | + 'messengers_to_validate_with' => array('email') |
|
671 | + ); |
|
672 | + EE_Register_Message_Type::register('payment_cancelled', $setup_args); |
|
673 | + } |
|
674 | + |
|
675 | + |
|
676 | + /** |
|
677 | + * Takes care of registering the shortcode libraries implemented with caffeinated EE and set up related items. |
|
678 | + * |
|
679 | + * @since 4.3.2 |
|
680 | + * |
|
681 | + * @return void |
|
682 | + */ |
|
683 | + public function register_caf_shortcodes() |
|
684 | + { |
|
685 | + $setup_args = array( |
|
686 | + 'autoloadpaths' => array( |
|
687 | + EE_CAF_LIBRARIES . 'shortcodes/' |
|
688 | + ), |
|
689 | + 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
|
690 | + 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
|
691 | + 'list_type_shortcodes' => array('[NEWSLETTER_CONTENT]') |
|
692 | + ); |
|
693 | + EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args); |
|
694 | + } |
|
695 | + |
|
696 | + |
|
697 | + /** |
|
698 | + * Parses a question list shortcode using given data and template |
|
699 | + * |
|
700 | + * @param \EE_Shortcodes $shortcode_parser |
|
701 | + * @param EE_Question[] $questions An array of questions indexed by answer id. |
|
702 | + * @param EE_Answer[] $answers An array of answer objects |
|
703 | + * @param string $template Template content to be parsed. |
|
704 | + * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
705 | + * @param array $extra_data Extra data that might be used when parsing the template. |
|
706 | + */ |
|
707 | + protected function _parse_question_list_for_primary_or_recipient_registration( |
|
708 | + $shortcode_parser, |
|
709 | + $questions, |
|
710 | + $answers, |
|
711 | + $template, |
|
712 | + $valid_shortcodes, |
|
713 | + $extra_data |
|
714 | + ) { |
|
715 | + $question_list = ''; |
|
716 | + /** @var EEH_Parse_Shortcodes $shortcode_helper */ |
|
717 | + $shortcode_helper = $shortcode_parser->get_shortcode_helper(); |
|
718 | + foreach ($answers as $answer) { |
|
719 | + if ($answer instanceof EE_Answer) { |
|
720 | + //first see if the question is in our $questions array. If not then try to get from answer object. |
|
721 | + $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null; |
|
722 | + $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
723 | + if ( |
|
724 | + ! $question instanceof EE_Question |
|
725 | + || ( |
|
726 | + $question instanceof EE_Question |
|
727 | + && $question->admin_only() |
|
728 | + ) |
|
729 | + ) { |
|
730 | + continue; |
|
731 | + } |
|
732 | + $question_list .= $shortcode_helper->parse_question_list_template( |
|
733 | + $template, |
|
734 | + $answer, |
|
735 | + $valid_shortcodes, |
|
736 | + $extra_data |
|
737 | + ); |
|
738 | + } |
|
739 | + } |
|
740 | + |
|
741 | + return $question_list; |
|
742 | + } |
|
743 | 743 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function messages_autoload_paths($dir_ref) |
97 | 97 | { |
98 | - $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
98 | + $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/'; |
|
99 | 99 | |
100 | 100 | return $dir_ref; |
101 | 101 | } |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | //the template file name we're replacing contents for. |
219 | - $template_file_prefix = $field . '_' . $context; |
|
220 | - $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
219 | + $template_file_prefix = $field.'_'.$context; |
|
220 | + $msg_prefix = $messenger->name.'_'.$message_type->name.'_'; |
|
221 | 221 | |
222 | - $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
222 | + $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/'; |
|
223 | 223 | |
224 | 224 | if ($messenger->name == 'email' && $message_type->name == 'registration') { |
225 | 225 | |
@@ -228,17 +228,17 @@ discard block |
||
228 | 228 | case 'question_list_admin' : |
229 | 229 | case 'question_list_attendee' : |
230 | 230 | case 'question_list_primary_attendee' : |
231 | - $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
231 | + $path = $base_path.$msg_prefix.'question_list.template.php'; |
|
232 | 232 | $contents = EEH_Template::display_template($path, array(), true); |
233 | 233 | break; |
234 | 234 | |
235 | 235 | case 'attendee_list_primary_attendee' : |
236 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
236 | + $path = $base_path.$msg_prefix.'attendee_list.template.php'; |
|
237 | 237 | $contents = EEH_Template::display_template($path, array(), true); |
238 | 238 | break; |
239 | 239 | |
240 | 240 | case 'attendee_list_admin' : |
241 | - $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
241 | + $path = $base_path.$msg_prefix.'attendee_list_admin.template.php'; |
|
242 | 242 | $contents = EEH_Template::display_template($path, |
243 | 243 | array(), true); |
244 | 244 | break; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | break; |
249 | 249 | |
250 | 250 | case 'event_list_attendee' : |
251 | - $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
251 | + $path = $base_path.$msg_prefix.'event_list_attendee.template.php'; |
|
252 | 252 | $contents = EEH_Template::display_template($path, array(), true); |
253 | 253 | break; |
254 | 254 | } |
@@ -256,24 +256,24 @@ discard block |
||
256 | 256 | switch ($template_file_prefix) { |
257 | 257 | |
258 | 258 | case 'content_attendee' : |
259 | - $path = $base_path . $msg_prefix . 'content.template.php'; |
|
259 | + $path = $base_path.$msg_prefix.'content.template.php'; |
|
260 | 260 | $contents = EEH_Template::display_template($path, array(), true); |
261 | 261 | break; |
262 | 262 | |
263 | 263 | case 'newsletter_content_attendee' : |
264 | - $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
264 | + $path = $base_path.$msg_prefix.'newsletter_content.template.php'; |
|
265 | 265 | $contents = EEH_Template::display_template($path, array(), true); |
266 | 266 | break; |
267 | 267 | |
268 | 268 | case 'newsletter_subject_attendee' : |
269 | - $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
269 | + $path = $base_path.$msg_prefix.'subject.template.php'; |
|
270 | 270 | $contents = EEH_Template::display_template($path, array(), true); |
271 | 271 | break; |
272 | 272 | } |
273 | 273 | } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
274 | 274 | switch ($template_file_prefix) { |
275 | 275 | case 'attendee_list_purchaser' : |
276 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
276 | + $path = $base_path.$msg_prefix.'attendee_list.template.php'; |
|
277 | 277 | $contents = EEH_Template::display_template($path, array(), true); |
278 | 278 | break; |
279 | 279 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | |
506 | 506 | //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
507 | 507 | //object on it. |
508 | - if ( ! isset( $extra_data['data'] ) ) { |
|
508 | + if ( ! isset($extra_data['data'])) { |
|
509 | 509 | $extra_data['data'] = $recipient; |
510 | 510 | } |
511 | 511 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $questions = isset($recipient->questions) ? $recipient->questions : array(); |
577 | 577 | //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
578 | 578 | //object on it. |
579 | - if ( ! isset( $extra_data['data'] ) ){ |
|
579 | + if ( ! isset($extra_data['data'])) { |
|
580 | 580 | $extra_data['data'] = $recipient; |
581 | 581 | } |
582 | 582 | return $this->_parse_question_list_for_primary_or_recipient_registration( |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | $setup_args = array( |
610 | 610 | 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
611 | 611 | 'autoloadpaths' => array( |
612 | - EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
612 | + EE_CAF_LIBRARIES.'messages/message_type/newsletter/' |
|
613 | 613 | ), |
614 | 614 | 'messengers_to_activate_with' => array('email'), |
615 | 615 | 'messengers_to_validate_with' => array('email') |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | //register payment reminder message type |
620 | 620 | $setup_args = array( |
621 | 621 | 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
622 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
622 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'), |
|
623 | 623 | 'messengers_to_activate_with' => array('email'), |
624 | 624 | 'messengers_to_validate_with' => array('email') |
625 | 625 | ); |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | //register payment declined message type |
629 | 629 | $setup_args = array( |
630 | 630 | 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
631 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
631 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'), |
|
632 | 632 | 'messengers_to_activate_with' => array('email'), |
633 | 633 | 'messengers_to_validate_with' => array('email') |
634 | 634 | ); |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | //register registration declined message type |
638 | 638 | $setup_args = array( |
639 | 639 | 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
640 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
640 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'), |
|
641 | 641 | 'messengers_to_activate_with' => array('email'), |
642 | 642 | 'messengers_to_validate_with' => array('email') |
643 | 643 | ); |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | //register registration cancelled message type |
647 | 647 | $setup_args = array( |
648 | 648 | 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
649 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
649 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'), |
|
650 | 650 | 'messengers_to_activate_with' => array('email'), |
651 | 651 | 'messengers_to_validate_with' => array('email') |
652 | 652 | ); |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | //register payment failed message type |
657 | 657 | $setup_args = array( |
658 | 658 | 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
659 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
659 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'), |
|
660 | 660 | 'messengers_to_activate_with' => array('email'), |
661 | 661 | 'messengers_to_validate_with' => array('email') |
662 | 662 | ); |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | //register payment declined message type |
666 | 666 | $setup_args = array( |
667 | 667 | 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
668 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
668 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'), |
|
669 | 669 | 'messengers_to_activate_with' => array('email'), |
670 | 670 | 'messengers_to_validate_with' => array('email') |
671 | 671 | ); |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | { |
685 | 685 | $setup_args = array( |
686 | 686 | 'autoloadpaths' => array( |
687 | - EE_CAF_LIBRARIES . 'shortcodes/' |
|
687 | + EE_CAF_LIBRARIES.'shortcodes/' |
|
688 | 688 | ), |
689 | 689 | 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
690 | 690 | 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |